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

Function ExtractNumAndNonNum

src/opt.cpp:25–52  ·  view source on GitHub ↗

For microinstructions with two or more operands (in l and r), check to see if one of them is numeric and the other one isn't. If this is the case, return pointers to the operands in the appropriately-named argument variables and return true. Otherwise, return false.

Source from the content-addressed store, hash-verified

23// For microinstructions with two or more operands (in l and r), check to see if one of them is numeric and the other one isn't.
24// If this is the case, return pointers to the operands in the appropriately-named argument variables and return true. Otherwise, return false.
25bool ExtractNumAndNonNum(minsn_t* insn, mop_t*& numOp, mop_t*& otherOp)
26{
27 mop_t* num = NULL, * other = NULL;
28
29 //check right hand before
30 if (insn->r.t == mop_n) {
31 num = &insn->r;
32 other = &insn->l;
33 }
34
35 //check left hand only for commutative ops
36 if (insn->opcode != m_sub) {
37 if (insn->l.t == mop_n) {
38 if (num != NULL) {
39 // Technically we have an option to perform constant folding here... but Hex-Rays should have done / should do that for us
40 return false;
41 }
42 num = &insn->l;
43 other = &insn->r;
44 }
45 }
46 if (num == NULL)
47 return false;
48
49 numOp = num;
50 otherOp = other;
51 return true;
52}
53
54// For microinstructions with two or more operands (in l and r), check to see
55// if one of them is a mop_d (result of another microinstruction), where the

Callers 12

TunnelThroughAnd1Function · 0.85
TunnelThroughOrMinus2Function · 0.85
pat_AddSubFunction · 0.85
pat_MulSubFunction · 0.85
CheckAndExtractOpsSubBy1Function · 0.85
pat_InitedVarCondImmFunction · 0.85
pat_OrAndNotFunction · 0.85
pat_BnotOrBnotConstFunction · 0.85
visit_mopFunction · 0.85
callOrJmp2InitedVarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected