diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-15 13:40:28 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-15 13:40:28 (GMT) |
commit | 124c8410dbfcad59d66b850c50c96ec73a607ab7 (patch) | |
tree | b7127c66abfccd11b9126741e2809a893ee44143 /plugins/pychrysa | |
parent | db1a6171007a6641a4659392c9bcc05670396643 (diff) |
Defined proper accesses to instructions loaded by a processor.
Diffstat (limited to 'plugins/pychrysa')
-rw-r--r-- | plugins/pychrysa/arch/instriter.c | 4 | ||||
-rw-r--r-- | plugins/pychrysa/arch/processor.c | 109 |
2 files changed, 4 insertions, 109 deletions
diff --git a/plugins/pychrysa/arch/instriter.c b/plugins/pychrysa/arch/instriter.c index 1e5346e..0d65f26 100644 --- a/plugins/pychrysa/arch/instriter.c +++ b/plugins/pychrysa/arch/instriter.c @@ -28,7 +28,6 @@ #include <pygobject.h> -#include <arch/instriter.h> #include <arch/processor.h> @@ -101,7 +100,10 @@ static PyObject *py_instr_iterator_next(PyInstrIterator *self) next = get_instruction_iterator_next(self->native); if (next != NULL) + { result = pygobject_new(G_OBJECT(next)); + g_object_unref(G_OBJECT(next)); + } else { diff --git a/plugins/pychrysa/arch/processor.c b/plugins/pychrysa/arch/processor.c index 3ef56e4..e34bf1f 100644 --- a/plugins/pychrysa/arch/processor.c +++ b/plugins/pychrysa/arch/processor.c @@ -68,12 +68,6 @@ static PyObject *py_arch_processor_get_instrs(PyObject *, void *); /* Recherche une instruction d'après son adresse. */ static PyObject *py_arch_processor_find_instr_by_addr(PyObject *, PyObject *); -/* Fournit l'instruction qui en précède une autre. */ -static PyObject *py_arch_processor_get_prev_instr(PyObject *, PyObject *); - -/* Fournit l'instruction qui en suit une autre. */ -static PyObject *py_arch_processor_get_next_instr(PyObject *, PyObject *); - /* ---------------------------------------------------------------------------------- */ @@ -182,102 +176,11 @@ static PyObject *py_arch_processor_find_instr_by_addr(PyObject *self, PyObject * found = g_arch_processor_find_instr_by_address(proc, addr); if (found != NULL) - result = pygobject_new(G_OBJECT(found)); - - else { - result = Py_None; - Py_INCREF(result); - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : self = processeur d'architecture à manipuler. * -* args = instruction représentant le point de départ. * -* * -* Description : Fournit l'instruction qui en précède une autre. * -* * -* Retour : Instruction précédente trouvée, ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_arch_processor_get_prev_instr(PyObject *self, PyObject *args) -{ - PyObject *result; /* Instance à retourner */ - PyObject *instr_obj; /* Objet pour une instruction */ - int ret; /* Bilan de lecture des args. */ - GArchProcessor *proc; /* Processeur manipulé */ - GArchInstruction *instr; /* Instruction de référence */ - GArchInstruction *found; /* Instruction liée trouvée */ - - ret = PyArg_ParseTuple(args, "O", &instr_obj); - if (!ret) return NULL; - - ret = PyObject_IsInstance(instr_obj, (PyObject *)get_python_arch_instruction_type()); - if (!ret) return NULL; - - proc = G_ARCH_PROCESSOR(pygobject_get(self)); - instr = G_ARCH_INSTRUCTION(pygobject_get(instr_obj)); - - found = g_arch_processor_get_prev_instr(proc, instr); - - if (found != NULL) result = pygobject_new(G_OBJECT(found)); - - else - { - result = Py_None; - Py_INCREF(result); + g_object_unref(G_OBJECT(found)); } - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : self = processeur d'architecture à manipuler. * -* args = instruction représentant le point de départ. * -* * -* Description : Fournit l'instruction qui en suit une autre. * -* * -* Retour : Instruction suivante trouvée, ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_arch_processor_get_next_instr(PyObject *self, PyObject *args) -{ - PyObject *result; /* Instance à retourner */ - PyObject *instr_obj; /* Objet pour une instruction */ - int ret; /* Bilan de lecture des args. */ - GArchProcessor *proc; /* Processeur manipulé */ - GArchInstruction *instr; /* Instruction de référence */ - GArchInstruction *found; /* Instruction liée trouvée */ - - ret = PyArg_ParseTuple(args, "O", &instr_obj); - if (!ret) return NULL; - - ret = PyObject_IsInstance(instr_obj, (PyObject *)get_python_arch_instruction_type()); - if (!ret) return NULL; - - proc = G_ARCH_PROCESSOR(pygobject_get(self)); - instr = G_ARCH_INSTRUCTION(pygobject_get(instr_obj)); - - found = g_arch_processor_get_next_instr(proc, instr); - - if (found != NULL) - result = pygobject_new(G_OBJECT(found)); - else { result = Py_None; @@ -309,16 +212,6 @@ PyTypeObject *get_python_arch_processor_type(void) METH_VARARGS, "find_instr_by_addr($self, addr, /)\n--\n\nLook for an instruction located at a given address." }, - { - "get_prev_instr", py_arch_processor_get_prev_instr, - METH_VARARGS, - "get_prev_instr($self, instr, /)\n--\n\nProvide the instruction preceding a given instruction." - }, - { - "get_next_instr", py_arch_processor_get_next_instr, - METH_VARARGS, - "get_next_instr($self, instr, /)\n--\n\nProvide the instruction following a given instruction." - }, { NULL } }; |