diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/pychrysa/analysis/db/items/comment.c | 2 | ||||
-rw-r--r-- | plugins/pychrysa/arch/processor.c | 49 |
2 files changed, 43 insertions, 8 deletions
diff --git a/plugins/pychrysa/analysis/db/items/comment.c b/plugins/pychrysa/analysis/db/items/comment.c index 936d7cb..4a90f09 100644 --- a/plugins/pychrysa/analysis/db/items/comment.c +++ b/plugins/pychrysa/analysis/db/items/comment.c @@ -144,7 +144,7 @@ static int py_db_comment_set_text(PyObject *self, PyObject *value, void *closure } comment = G_DB_COMMENT(pygobject_get(self)); - g_db_comment_set_text(comment, PyUnicode_DATA(value)); + //g_db_comment_set_text(comment, PyUnicode_DATA(value)); return 0; diff --git a/plugins/pychrysa/arch/processor.c b/plugins/pychrysa/arch/processor.c index 63d93c5..c3d744b 100644 --- a/plugins/pychrysa/arch/processor.c +++ b/plugins/pychrysa/arch/processor.c @@ -25,6 +25,7 @@ #include "processor.h" +#include <malloc.h> #include <pygobject.h> @@ -65,6 +66,9 @@ /* Fournit les instructions désassemblées pour une architecture. */ static PyObject *py_arch_processor_get_instrs(PyObject *, void *); +/* Note les instructions désassemblées avec une architecture. */ +static int py_arch_processor_set_instrs(PyObject *, PyObject *, void *); + /* Recherche une instruction d'après son adresse. */ static PyObject *py_arch_processor_find_instr_by_addr(PyObject *, PyObject *); @@ -121,24 +125,55 @@ static PyObject *py_arch_processor_get_instrs(PyObject *self, void *closure) * * ******************************************************************************/ -static int py_arch_processor_set_disass_instrs(PyObject *self, PyObject *value, void *closure) +static int py_arch_processor_set_instrs(PyObject *self, PyObject *value, void *closure) { + size_t count; /* Nombre d'instructions */ + GArchInstruction **list; /* Liste d'instructions */ + size_t i; /* Boucle de parcours */ + PyObject *instr; /* Instruction en Python */ GArchProcessor *proc; /* Architecture visée */ - GArchInstruction *instrs; /* Série d'instructions liées */ - if (!PyObject_TypeCheck(value, get_python_arch_instruction_type())) + if (!PyTuple_Check(value)) { - PyErr_SetString(PyExc_TypeError, _("The attribute value must be an instruction.")); + PyErr_SetString(PyExc_TypeError, _("The attribute value must be a tuple of instructions.")); return -1; } + count = PyTuple_Size(value); + + list = (GArchInstruction **)calloc(count, sizeof(GArchInstruction *)); + + for (i = 0; i < count; i++) + { + instr = PyTuple_GetItem(value, i); + + if (!PyObject_TypeCheck(value, get_python_arch_instruction_type())) + { + PyErr_SetString(PyExc_TypeError, _("The attribute value must be a tuple of instructions.")); + count = i; + goto papsi_error; + } + + list[i] = G_ARCH_INSTRUCTION(pygobject_get(instr)); + g_object_ref(G_OBJECT(list[i])); + + } + proc = G_ARCH_PROCESSOR(pygobject_get(self)); - instrs = G_ARCH_INSTRUCTION(pygobject_get(value)); - g_arch_processor_set_disassembled_instructions(proc, instrs); + g_arch_processor_set_instructions(proc, list, count); return 0; + papsi_error: + + for (i = 0; i < count; i++) + g_object_unref(G_OBJECT(list[i])); + + free(list); + + return -1; + } @@ -217,7 +252,7 @@ PyTypeObject *get_python_arch_processor_type(void) static PyGetSetDef py_arch_processor_getseters[] = { { - "instrs", py_arch_processor_get_instrs, py_arch_processor_set_disass_instrs, + "instrs", py_arch_processor_get_instrs, py_arch_processor_set_instrs, "Give access to the disassembled instructions run by the current processor.", NULL }, { NULL } |