MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / InvertBranch

Method InvertBranch

arch/mips/arch_mips.cpp:1358–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1356 }
1357
1358 virtual bool InvertBranch(uint8_t* data, uint64_t addr, size_t len) override
1359 {
1360 (void)addr;
1361 (void)len;
1362 uint32_t *value = (uint32_t*)data;
1363
1364 uint32_t instValue = *value;
1365 if (GetEndianness() == LittleEndian)
1366 instValue = bswap32(instValue);
1367
1368 uint32_t op = instValue >> 26;
1369 switch (op)
1370 {
1371 case 1: //REGIMM
1372 op = (instValue >> 16) & 0xf;
1373 switch (op)
1374 {
1375 case 0: //BLTZ
1376 case 1: //BGEZ
1377 case 2: //BLTZL
1378 case 3: //BGEZL
1379 case 0x10: //BLTZAL
1380 case 0x11: //BGEZAL
1381 case 0x12: //BLTZALL
1382 case 0x13: //BGEZALL
1383 //Invert the bit
1384 instValue ^= 0x00000100;
1385 break;
1386 default:
1387 return false;
1388 }
1389 break;
1390 case 4: //BEQ
1391 case 5: //BNE
1392 case 6: //BLEZ
1393 case 7: //BGTZ
1394 case 0x14: //BEQL
1395 case 0x15: //BNEL
1396 case 0x16: //BLEZL
1397 case 0x17: //BGTZL
1398 //Invert the bit
1399 instValue ^= 0x00000004;
1400 break;
1401 default:
1402 return false;
1403 }
1404 if (GetEndianness() == LittleEndian)
1405 instValue = bswap32(instValue);
1406
1407 *value = instValue;
1408 return true;
1409 }
1410 /*
1411 virtual bool SkipAndReturnValue(uint8_t* data, uint64_t addr, size_t len, uint64_t value) override
1412 {

Callers

nothing calls this directly

Calls 1

bswap32Function · 0.70

Tested by

no test coverage detected