MCPcopy Create free account
hub / github.com/connorjaydunn/BinaryShield / resolveBranchInstructions

Method resolveBranchInstructions

src/function.cpp:71–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void Function::resolveBranchInstructions(DWORD bytecodeRva)
72{
73 for (int i = 0; i < instructions.size(); i++)
74 {
75 if (instructions[i].isBranchInstruction())
76 {
77 // get bytecode rva of the destination instruction
78 DWORD targetBytecodeRva = getBytecodeIndex(instructions[i].getDestInstructionIndex()) + bytecodeRva;
79
80 // set branch instructions operand to rva of destination instruction's bytecode rva
81 if (instructions[i].isConditionalBranchInstruction())
82 {
83 // if conditional branch, second virtual instruction is the "push target.rva"
84 instructions[i].getVirtualInstructions()[1].setOperand(targetBytecodeRva);
85 }
86 else
87 {
88 // if non-conditional branch, first virtual instruction is the "push target.rva"
89 instructions[i].getVirtualInstructions()[0].setOperand(targetBytecodeRva);
90 }
91 }
92 }
93}
94
95DWORD Function::getBytecodeIndex(int instructionIndex)
96{

Callers 1

virtualizeFunctionMethod · 0.80

Calls 4

isBranchInstructionMethod · 0.80
setOperandMethod · 0.80

Tested by

no test coverage detected