diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-14 23:30:12 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-14 23:30:12 (GMT) |
commit | db1a6171007a6641a4659392c9bcc05670396643 (patch) | |
tree | d011651b8b73b2a28d01e416d613d63bf5b0b4e6 /plugins/pychrysa/arch/processor.c | |
parent | ba6ca32c37c5db2582a015ed15d6ba128c36968e (diff) |
Provided an iterator for instructions.
Diffstat (limited to 'plugins/pychrysa/arch/processor.c')
-rw-r--r-- | plugins/pychrysa/arch/processor.c | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/plugins/pychrysa/arch/processor.c b/plugins/pychrysa/arch/processor.c index 291d788..3ef56e4 100644 --- a/plugins/pychrysa/arch/processor.c +++ b/plugins/pychrysa/arch/processor.c @@ -34,6 +34,7 @@ #include <arch/processor.h> +#include "instriter.h" #include "instruction.h" #include "vmpa.h" #include "../helpers.h" @@ -62,7 +63,7 @@ /* Fournit les instructions désassemblées pour une architecture. */ -static PyObject *py_arch_processor_get_disass_instrs(PyObject *, void *); +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 *); @@ -75,8 +76,6 @@ static PyObject *py_arch_processor_get_next_instr(PyObject *, PyObject *); - - /* ---------------------------------------------------------------------------------- */ /* MANIPULATIONS DES INSTRUCTIONS DESASSEMBLEES */ /* ---------------------------------------------------------------------------------- */ @@ -95,22 +94,19 @@ static PyObject *py_arch_processor_get_next_instr(PyObject *, PyObject *); * * ******************************************************************************/ -static PyObject *py_arch_processor_get_disass_instrs(PyObject *self, void *closure) +static PyObject *py_arch_processor_get_instrs(PyObject *self, void *closure) { PyObject *result; /* Instance Python à retourner */ - GArchProcessor *proc; /* Architecture visée */ - GArchInstruction *instrs; /* Série d'instructions liées */ + PyTypeObject *iterator_type; /* Type Python de l'itérateur */ + PyObject *args; /* Liste des arguments d'appel */ - proc = G_ARCH_PROCESSOR(pygobject_get(self)); - instrs = g_arch_processor_get_disassembled_instructions(proc); + iterator_type = get_python_instr_iterator_type(); - if (instrs != NULL) - result = pygobject_new(G_OBJECT(instrs)); - else - { - result = Py_None; - Py_INCREF(result); - } + args = Py_BuildValue("On", self, 0); + + result = PyObject_CallObject((PyObject *)iterator_type, args); + + Py_DECREF(args); return result; @@ -293,22 +289,6 @@ static PyObject *py_arch_processor_get_next_instr(PyObject *self, PyObject *args } - - - - - - - - - - - - - - - - /****************************************************************************** * * * Paramètres : - * @@ -344,7 +324,7 @@ PyTypeObject *get_python_arch_processor_type(void) static PyGetSetDef py_arch_processor_getseters[] = { { - "disass_instrs", py_arch_processor_get_disass_instrs, py_arch_processor_set_disass_instrs, + "instrs", py_arch_processor_get_instrs, py_arch_processor_set_disass_instrs, "Give access to the disassembled instructions run by the current processor.", NULL }, { NULL } |