Skip to content

Commit

Permalink
fix: argN convenience registers start at 1 now
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrewh committed Nov 13, 2024
1 parent 948250a commit 44b12b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions examples/ltrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def guess_arg(x):
def lib_hook(p):
name = plt_map[p.regs.pc]
print(f"{name}(" + ", ".join([
f"rdi={guess_arg(p.regs.arg0)}",
f"rsi={guess_arg(p.regs.arg1)}",
f"rdx={guess_arg(p.regs.arg2)}",
f"rcx={guess_arg(p.regs.arg3)}",
f"rdi={guess_arg(p.regs.arg1)}",
f"rsi={guess_arg(p.regs.arg2)}",
f"rdx={guess_arg(p.regs.arg3)}",
f"rcx={guess_arg(p.regs.arg4)}",
]) + ")")

for x in e.plt:
p.hook(e.plt[x], lib_hook)

p.run()
p.run()
24 changes: 12 additions & 12 deletions pyda_core/pyda_core_py.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ PyInit_pyda_core(void) {
PyModule_AddIntConstant(m, "REG_XMM5", DR_REG_XMM5);
PyModule_AddIntConstant(m, "REG_XMM6", DR_REG_XMM6);
PyModule_AddIntConstant(m, "REG_XMM7", DR_REG_XMM7);
PyModule_AddIntConstant(m, "REG_ARG0", DR_REG_RDI);
PyModule_AddIntConstant(m, "REG_ARG1", DR_REG_RSI);
PyModule_AddIntConstant(m, "REG_ARG2", DR_REG_RDX);
PyModule_AddIntConstant(m, "REG_ARG3", DR_REG_RCX);
PyModule_AddIntConstant(m, "REG_ARG4", DR_REG_R8);
PyModule_AddIntConstant(m, "REG_ARG5", DR_REG_R9);
PyModule_AddIntConstant(m, "REG_ARG1", DR_REG_RDI);
PyModule_AddIntConstant(m, "REG_ARG2", DR_REG_RSI);
PyModule_AddIntConstant(m, "REG_ARG3", DR_REG_RDX);
PyModule_AddIntConstant(m, "REG_ARG4", DR_REG_RCX);
PyModule_AddIntConstant(m, "REG_ARG5", DR_REG_R8);
PyModule_AddIntConstant(m, "REG_ARG6", DR_REG_R9);
#elif defined(AARCH64)
PyModule_AddIntConstant(m, "REG_X0", DR_REG_X0);
PyModule_AddIntConstant(m, "REG_X1", DR_REG_X1);
Expand Down Expand Up @@ -155,12 +155,12 @@ PyInit_pyda_core(void) {
PyModule_AddIntConstant(m, "REG_X30", DR_REG_X30);
PyModule_AddIntConstant(m, "REG_SP", DR_REG_SP);
PyModule_AddIntConstant(m, "REG_PC", PYDA_REG_PC);
PyModule_AddIntConstant(m, "REG_ARG0", DR_REG_R0);
PyModule_AddIntConstant(m, "REG_ARG1", DR_REG_R1);
PyModule_AddIntConstant(m, "REG_ARG2", DR_REG_R2);
PyModule_AddIntConstant(m, "REG_ARG3", DR_REG_R3);
PyModule_AddIntConstant(m, "REG_ARG4", DR_REG_R4);
PyModule_AddIntConstant(m, "REG_ARG5", DR_REG_R5);
PyModule_AddIntConstant(m, "REG_ARG1", DR_REG_R0);
PyModule_AddIntConstant(m, "REG_ARG2", DR_REG_R1);
PyModule_AddIntConstant(m, "REG_ARG3", DR_REG_R2);
PyModule_AddIntConstant(m, "REG_ARG4", DR_REG_R3);
PyModule_AddIntConstant(m, "REG_ARG5", DR_REG_R4);
PyModule_AddIntConstant(m, "REG_ARG6", DR_REG_R5);
#endif

return m;
Expand Down

0 comments on commit 44b12b7

Please sign in to comment.