Skip to content

Commit

Permalink
feat: add low part of xmm0-2 registers
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrewh committed Jul 1, 2024
1 parent 0c1b967 commit 5e44122
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/pyda
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

ROOT=$(dirname "$0")/../
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHONHOME/lib/ PYDA_SCRIPT=$1 PWNLIB_NOTERM=1 $DYNAMORIO_HOME/bin64/drrun -stack_size 1024K -c $ROOT/build/pyda_core/libtool.so ${@:2}
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHONHOME/lib/ PYDA_SCRIPT=$1 PWNLIB_NOTERM=1 exec $DYNAMORIO_HOME/bin64/drrun -stack_size 1024K -c $ROOT/build/pyda_core/libtool.so ${@:2}
16 changes: 16 additions & 0 deletions pyda_core/pyda_core_py.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@ PydaProcess_get_register(PyObject *self, PyObject *args) {
return PyLong_FromUnsignedLong((unsigned long)dr_get_tls_field(dr_get_current_drcontext()));
} else if (strcmp(regname, "rip") == 0 || strcmp(regname, "pc") == 0) {
return PyLong_FromUnsignedLong((unsigned long)mc->pc);
} else if (strcmp(regname, "xmm0") == 0) {
uint64_t val[2];
reg_get_value_ex(DR_REG_XMM0, mc, (uint8_t*)&val);
return PyLong_FromUnsignedLong(val[0]); // todo: we lose the top
} else if (strcmp(regname, "xmm1") == 0) {
uint64_t val[2];
reg_get_value_ex(DR_REG_XMM1, mc, (uint8_t*)&val);
return PyLong_FromUnsignedLong(val[0]); // todo: we lose the top
} else if (strcmp(regname, "xmm2") == 0) {
uint64_t val[2];
reg_get_value_ex(DR_REG_XMM2, mc, (uint8_t*)&val);
return PyLong_FromUnsignedLong(val[0]); // todo: we lose the top
} else if (strcmp(regname, "xmm3") == 0) {
uint64_t val[2];
reg_get_value_ex(DR_REG_XMM3, mc, (uint8_t*)&val);
return PyLong_FromUnsignedLong(val[0]); // todo: we lose the top
}
#endif // PYDA_DYNAMORIO_CLIENT

Expand Down
2 changes: 1 addition & 1 deletion pyda_core/tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ event_insert(void *drcontext, void *tag, instrlist_t *bb, instr_t *instr,
} else if ((callback = pyda_get_callback(t->proc, instr_get_app_pc(instr)))) {
DEBUG_PRINTF("installing hook at %p\n", instr_get_app_pc(instr));
dr_insert_clean_call(drcontext, bb, instr, (void *)pyda_hook_cleancall,
false /* save fpstate */, 1, OPND_CREATE_INTPTR(callback));
true /* save fpstate */, 1, OPND_CREATE_INTPTR(callback));
}
return DR_EMIT_DEFAULT;
}
Expand Down

0 comments on commit 5e44122

Please sign in to comment.