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

Function FindJccInFirstBlocks

src/unflat.cpp:1688–1729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1686 }
1687
1688 bool FindJccInFirstBlocks(mbl_array_t* mba, mop_t*& opCopy, mblock_t*& endsWithJcc, mblock_t*& nonJcc, int& actualGotoTarget, int& actualJccTarget)
1689 {
1690 actualGotoTarget = actualJccTarget = -1;
1691 int first = cfi.iFirst;
1692
1693 // search assignment for endsWithJcc (the assignment can be done in every endsWithJcc blocks)
1694 for (int iCurrent = first; iCurrent > 0; iCurrent -= 2) {
1695 endsWithJcc = mba->get_mblock(iCurrent);
1696 if (iCurrent == first || is_mcode_jcond(endsWithJcc->tail->opcode)) {
1697 actualGotoTarget = FindBlockTargetOrLastCopy(endsWithJcc, endsWithJcc, opCopy, false, false);
1698 if (actualGotoTarget > 0)
1699 break;
1700 else {
1701 mop_t* opCopy2nd = m_DeferredErasuresLocal.back().opCopy;
1702 if (!opCopy2nd->equal_mops(*opCopy, EQ_IGNSIZE)) {
1703#if DEBUG_UF >= 3
1704 qstring qs1; opCopy2nd->print(&qs1); tag_remove(&qs1);
1705 qstring qs2; opCopy->print(&qs2); tag_remove(&qs2);
1706 MSG_UF3(("[I] %a: Blk %d FindJccInFirstBlocks %s assigned to %s\n", m_DeferredErasuresLocal.back().insMov->ea, iCurrent, qs1.c_str(), qs2.c_str()));
1707#endif
1708 first = iCurrent;
1709 opCopy = opCopy2nd;
1710 }
1711 }
1712 }
1713 }
1714
1715 // search assignment for nonJcc
1716 for (int iCurrent = first - 1; iCurrent > 0; iCurrent -= 2) {
1717 nonJcc = mba->get_mblock(iCurrent);
1718 if (!is_mcode_jcond(nonJcc->tail->opcode)) {
1719 actualJccTarget = FindBlockTargetOrLastCopy(nonJcc, nonJcc, opCopy, false, false);
1720 if (actualJccTarget > 0 && actualGotoTarget > 0 && endsWithJcc == mba->get_mblock(nonJcc->pred(0))) {
1721 // actual endsWithJcc is the pred of nonJcc
1722 return true;
1723 }
1724 }
1725 }
1726
1727 // handle case then first block assign additional variable
1728 return actualGotoTarget > 0 && endsWithJcc->serial == first;
1729 }
1730
1731 // Erase the now-superfluous chain of instructions that were used to copy a numeric value into the assignment variable.
1732 void ProcessErasures(mbl_array_t *mba)

Callers 1

runFunction · 0.85

Calls 3

backMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected