Skip to content

Commit

Permalink
Fix long conditional jump relocation
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 authored Apr 23, 2024
1 parent cca6ced commit 1bf701f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/generator/X86Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,17 @@ Result<> X86HandlerGenerator::relocateInstruction(cs_insn* insn, uint64_t& tramp

trampolineAddress += 5;
}
else {
else if {
// std::cout << "WARNING: relocating conditional jmp, this is likely broken hehe" << std::endl;
// conditional jumps
// long conditional jmp size
// this is like probably not right idk what instruction this is supposed to be
int addrBytes = jmpTargetAddr - trampolineAddress - 6;
TULIP_HOOK_UNWRAP(Target::get().writeMemory(reinterpret_cast<void*>(trampolineAddress + 2), &addrBytes, sizeof(int)));
inBinary[1] = inBinary[0] + 0x10;
inBinary[0] = 0x0f;
if (detail->x86.operands[0].size == 1) {
inBinary[1] = inBinary[0] + 0x10;
inBinary[0] = 0x0f;
}

trampolineAddress += 6;
}
Expand Down Expand Up @@ -293,4 +295,4 @@ Result<> X86HandlerGenerator::relocateInstruction(cs_insn* insn, uint64_t& tramp
trampolineAddress += size;
originalAddress += size;
return Ok();
}
}

0 comments on commit 1bf701f

Please sign in to comment.