Skip to content

Commit

Permalink
fixed unhook code crashing due to bad argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Jan 8, 2024
1 parent 6277432 commit c3ec3f8
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions bindings/python/src/libmem/_libmem/libmem-py.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,16 +1286,12 @@ py_LM_UnhookCode(PyObject *self,
PyObject *args)
{
lm_address_t from;
PyObject *pytrampoline;
lm_address_t trampoline;
lm_size_t size;

if (!PyArg_ParseTuple(args, "k(kk)", &from, &pytrampoline))
if (!PyArg_ParseTuple(args, "k(kk)", &from, &trampoline, &size))
return NULL;

trampoline = (lm_address_t)PyLong_AsSize_t(PyTuple_GetItem(pytrampoline, 0));
size = (lm_size_t)PyLong_AsSize_t(PyTuple_GetItem(pytrampoline, 1));

if (!LM_UnhookCode(from, trampoline, size))
Py_RETURN_FALSE;

Expand All @@ -1310,16 +1306,12 @@ py_LM_UnhookCodeEx(PyObject *self,
{
py_lm_process_obj *pyproc;
lm_address_t from;
PyObject *pytrampoline;
lm_address_t trampoline;
lm_size_t size;

if (!PyArg_ParseTuple(args, "Ok(kk)", &pyproc, &from, &pytrampoline))
if (!PyArg_ParseTuple(args, "Ok(kk)", &pyproc, &from, &trampoline, &size))
return NULL;

trampoline = (lm_address_t)PyLong_AsSize_t(PyTuple_GetItem(pytrampoline, 0));
size = (lm_size_t)PyLong_AsSize_t(PyTuple_GetItem(pytrampoline, 1));

if (!LM_UnhookCodeEx(&pyproc->proc, from, trampoline, size))
Py_RETURN_FALSE;

Expand Down

0 comments on commit c3ec3f8

Please sign in to comment.