Disassembler call
| 14 | { |
| 15 | // Disassembler call |
| 16 | static unsigned int DisasmRange(SIZE_T* OutPutInstructionsSize, ULONG_PTR* OutNextInst, SIZE_T HookSize, _OffsetType BaseAddressFormat, int DVer, void* Buffer) |
| 17 | { |
| 18 | if (OutPutInstructionsSize > NULL && OutNextInst > NULL && BaseAddressFormat && Buffer > NULL) |
| 19 | { |
| 20 | // Declare some function variables |
| 21 | _DecodeResult res; |
| 22 | _DecodedInst decodedInstructions[0x1000]; // 1000 should be enough. |
| 23 | unsigned int decodedInstructionsCount = 0; |
| 24 | |
| 25 | // Instructions size |
| 26 | SIZE_T LSize = 0; |
| 27 | |
| 28 | // We disassemble 0x100 bytes |
| 29 | if (ColdHook_Service::Is64BitProcess()) { |
| 30 | res = distorm_decode(BaseAddressFormat, (unsigned char*)Buffer, 0x100, Decode64Bits, decodedInstructions, 0x1000, &decodedInstructionsCount); |
| 31 | } |
| 32 | else { |
| 33 | res = distorm_decode(BaseAddressFormat, (unsigned char*)Buffer, 0x100, Decode32Bits, decodedInstructions, 0x1000, &decodedInstructionsCount); |
| 34 | } |
| 35 | for (unsigned int i = 0; i < decodedInstructionsCount; i++) { |
| 36 | if (LSize >= HookSize) { |
| 37 | // Store the next instruction address. |
| 38 | *OutNextInst = decodedInstructions[i].offset; |
| 39 | break; |
| 40 | } |
| 41 | LSize += decodedInstructions[i].size; |
| 42 | } |
| 43 | *OutPutInstructionsSize = LSize; |
| 44 | return decodedInstructionsCount; |
| 45 | } |
| 46 | return NULL; |
| 47 | } |
| 48 | |
| 49 | // Generate base address |
| 50 | static void* AllocateTrampoline(ULONG_PTR StartBaseAddress, SIZE_T PageS, int32_t* OutErrorCode, SIZE_T* ChangedHookSize) |
no test coverage detected