| 69 | } |
| 70 | |
| 71 | void 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 | |
| 95 | DWORD Function::getBytecodeIndex(int instructionIndex) |
| 96 | { |
no test coverage detected