int inject_1_bit_0( int pid, long pos ) { int iRet; long origData; long newData; ////read iRet = ptraceGetReg( pid, pos, origData ); if( iRet == RT_FAIL ) { return RT_FAIL; } //random 1 bit set 0 newData = origData & ( ~( 0x0000000000000001L << randBit() ) ); ////write iRet = ptraceSetReg( pid, pos, newData ); if( iRet == RT_FAIL ) { return RT_FAIL; } cout << "Fault on " << offset2name( pos ) << "(0X" << hex << origData << " -> 0X" << newData << ")" << dec << endl; return RT_OK; }
int inject_plus_5( int pid, long pos ) { int iRet; long origData; long newData; ////read iRet = ptraceGetReg( pid, pos, origData ); if( iRet == RT_FAIL ) { return RT_FAIL; } //plus 5 newData = origData + 5; ////write iRet = ptraceSetReg( pid, pos, newData ); if( iRet == RT_FAIL ) { return RT_FAIL; } cout << "Fault on " << offset2name( pos ) << "(0X" << hex << origData << " -> 0X" << newData << ")" << dec << endl; return RT_OK; }
int inject_8_low_error( int pid, long pos ) { int iRet; long origData; long newData; ////read iRet = ptraceGetReg( pid, pos, origData ); if( iRet == RT_FAIL ) { return RT_FAIL; } //low 8 bits random error newData = origData ^ ( myRand() & 0x00000000000000ffL ); ////write iRet = ptraceSetReg( pid, pos, newData ); if( iRet == RT_FAIL ) { return RT_FAIL; } cout << "Fault on " << offset2name( pos ) << "(0X" << hex << origData << " -> 0X" << newData << ")" << dec << endl; return RT_OK; }
int inject_8_low_0( int pid, long pos ) { int iRet; long origData; long newData; ////read iRet = ptraceGetReg( pid, pos, origData ); if( iRet == RT_FAIL ) { return RT_FAIL; } //low 8 bits set 0 newData = origData & 0xffffffffffffff00L; ////write iRet = ptraceSetReg( pid, pos, newData ); if( iRet == RT_FAIL ) { return RT_FAIL; } cout << "Fault on " << offset2name( pos ) << "(0X" << hex << origData << " -> 0X" << newData << ")" << dec << endl; return RT_OK; }
static const char *tnetw1130_cmdname(uint16_t cmd) { return offset2name(cmd2name, cmd); }
static const char *tnetw1130_regname(unsigned addr) { return offset2name(addr2reg, addr); }