MCPcopy Create free account
hub / github.com/KasperskyLab/hrtng / CorrectStopBlockPreds

Function CorrectStopBlockPreds

src/unflat.cpp:1662–1686  ·  view source on GitHub ↗

ida changes number of stopBlk on inserting new block (CopyMblock), renumbers sucessors/predecessors of moved block but not changes microcode to correlate changed sucessors

Source from the content-addressed store, hash-verified

1660 // ida changes number of stopBlk on inserting new block (CopyMblock), renumbers sucessors/predecessors of moved block
1661 // but not changes microcode to correlate changed sucessors
1662 void CorrectStopBlockPreds(DeferredGraphModifier& dgm, mbl_array_t* mba)
1663 {
1664 int stopBlkNum = mba->qty - 1;
1665 mblock_t* mbCurrentStop = mba->get_mblock(stopBlkNum);
1666 for (auto bNum : mbCurrentStop->predset) {
1667 mblock_t* stopPred = mba->get_mblock(bNum);
1668 if (stopPred->tail != NULL) {
1669 if (is_mcode_jcond(stopPred->tail->opcode)) {
1670 MSG_UF3(("[I] CorrectStopBlockPreds: The pred of BLT_STOP block (%d) with Jcc will be updated\n", stopPred->serial));
1671 if (stopPred->serial + 1 != stopBlkNum && stopPred->tail->d.b != stopBlkNum)
1672 dgm.ChangeGoto(stopPred, stopPred->tail->d.b, stopBlkNum);
1673 else if (stopPred->serial + 1 == stopBlkNum && stopPred->succ(0) != stopBlkNum)
1674 dgm.ChangeGoto(stopPred, stopPred->succ(0), stopBlkNum);
1675 else if (stopPred->tail->d.b == stopBlkNum && stopPred->succ(1) != stopBlkNum)
1676 dgm.ChangeGoto(stopPred, stopPred->succ(1), stopBlkNum);
1677 } else {
1678 MSG_UF3(("[I] CorrectStopBlockPreds: The pred of BLT_STOP block (%d) will be updated\n", stopPred->serial));
1679 if ((stopPred->tail->opcode != m_goto && stopPred->serial + 1 != stopBlkNum) || stopPred->succ(0) != stopBlkNum)
1680 dgm.ChangeGoto(stopPred, stopPred->succ(0), stopBlkNum);
1681 else if (stopPred->tail->opcode == m_goto && stopPred->tail->l.b != stopBlkNum)
1682 dgm.ChangeGoto(stopPred, stopPred->tail->l.b, stopBlkNum);
1683 }
1684 }
1685 }
1686 }
1687
1688 bool FindJccInFirstBlocks(mbl_array_t* mba, mop_t*& opCopy, mblock_t*& endsWithJcc, mblock_t*& nonJcc, int& actualGotoTarget, int& actualJccTarget)
1689 {

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected