Skip to content
Snippets Groups Projects
Commit 4e612a1a authored by whh8b's avatar whh8b
Browse files

pushf/popf appropriately in 64-bit callback installer

This makes it possible for our callbacks to inspect
register values using a reg_values_t. Note the updated
comment that indicate how it is still necessary
for the caller to save the flags as well.



Former-commit-id: 5521f5d87ad5a0b32521ccef86248f754745fcf0
parent 25bd705d
No related branches found
No related tags found
No related merge requests found
......@@ -1425,6 +1425,13 @@ void Transform::addCallbackHandler64(Instruction_t *p_orig, string p_callbackHan
// x86-64
// register callback handler sequence
//
// This following note is slightly out of date.
// We DO save flags here so that our callbacks are
// able to look at register values using a reg_values_t.
// HOWEVER, the caller of this function should still be sure
// to save flags themselves.
//
// nb: strata semantics is that it does not save flags, so we don't bother
// saving/restoring flags either in the callback handler
// saving/restoring flags must be done outside of this routine
......@@ -1454,6 +1461,7 @@ Instruction_t* Transform::registerCallbackHandler64(string p_callbackHandler, in
instr = addNewAssembly(instr, "push r13");
instr = addNewAssembly(instr, "push r14");
instr = addNewAssembly(instr, "push r15");
instr = addNewAssembly(instr, "pushf");
// handle the arguments (if any): rdi, rsi, rdx, rcx, r8, r9
// first arg starts at byte +144
......@@ -1497,8 +1505,9 @@ Instruction_t* Transform::registerCallbackHandler64(string p_callbackHandler, in
postCallback->SetIndirectBranchTargetAddress(indTarg);
// restore registers
setAssembly(postCallback, "pop r15");
instr = addNewAssembly(postCallback, "pop r14");
setAssembly(postCallback, "popf");
instr = addNewAssembly(postCallback, "pop r15");
instr = addNewAssembly(instr, "pop r14");
instr = addNewAssembly(instr, "pop r13");
instr = addNewAssembly(instr, "pop r12");
instr = addNewAssembly(instr, "pop r11");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment