Skip to content

Commit

Permalink
fix modrm rip displacement part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Sep 13, 2024
1 parent 05207a1 commit c39fc38
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/generator/X64Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ Result<> X64HandlerGenerator::relocateRIPInstruction(cs_insn* insn, uint8_t* buf
originalAddress += size;
return Ok();
}
else if (detail->x86.encoding.modrm_offset > 0 && ((detail->x86.modrm | 0b11000111) == 5)) {
else if (detail->x86.encoding.modrm_offset > 0 && ((detail->x86.modrm & 0b11000111) == 5)) {
// Trying to catch XMM instructions
X64Assembler a(trampolineAddress);
RegMem64 m;
Expand All @@ -435,7 +435,6 @@ Result<> X64HandlerGenerator::relocateRIPInstruction(cs_insn* insn, uint8_t* buf
auto const absolute = static_cast<intptr_t>(originalAddress) + size + disp;

a.mov(RAX, "absolute-pointer");
a.mov(RAX, m[RAX]);
for (size_t i = 0; i < size; ++i) {
if (i == detail->x86.encoding.modrm_offset) {
// remove the modrm displacement [rip + 0x##] to make it [rax]
Expand Down

0 comments on commit c39fc38

Please sign in to comment.