Skip to content

Commit

Permalink
add shadow space when calling prehandler
Browse files Browse the repository at this point in the history
  • Loading branch information
dankmeme01 committed Jun 9, 2024
1 parent 63713a5 commit 1ecee12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/generator/X64Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,17 @@ std::vector<uint8_t> X64HandlerGenerator::handlerBytes(uint64_t address) {
// preserve registers
const auto preservedSize = preserveRegisters(a);

// shadow space
a.sub(RSP, 0x20);

// set the parameters
a.mov(FIRST_PARAM, "content");

// call the pre handler, incrementing
a.callip("handlerPre");

a.add(RSP, 0x20);

// store rax (next function ptr) in the shadow space for a bit
a.mov(m[RBP - 0x10], RAX);

Expand Down Expand Up @@ -530,7 +535,7 @@ Result<> X64HandlerGenerator::relocateBranchInstruction(cs_insn* insn, uint8_t*
a.jmpip("absolute-pointer");
a.label("absolute-pointer");
a.write64(targetAddress);

a.label("skip-branch");

a.updateLabels();
Expand Down

0 comments on commit 1ecee12

Please sign in to comment.