diff options
Diffstat (limited to 'plugins/pychrysa/format/format.c')
-rw-r--r-- | plugins/pychrysa/format/format.c | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/plugins/pychrysa/format/format.c b/plugins/pychrysa/format/format.c index 4032da0..8a4bfb4 100644 --- a/plugins/pychrysa/format/format.c +++ b/plugins/pychrysa/format/format.c @@ -31,11 +31,19 @@ #include <format/format.h> -#include "dex/dex.h" #include "../quirks.h" + + + +#define _(str) str + + + + + /* Crée un nouvel objet Python de type 'BinFormat'. */ static PyObject *py_binary_format_new(PyTypeObject *, PyObject *, PyObject *); @@ -43,6 +51,11 @@ static PyObject *py_binary_format_new(PyTypeObject *, PyObject *, PyObject *); static PyObject *py_binary_format_resolve_relative_routine(PyObject *, PyObject *); +/* Fournit le prototype de toutes les routines détectées. */ +static PyObject *py_binary_format_get_routines(PyObject *, void *); + + + /****************************************************************************** * * @@ -60,7 +73,10 @@ static PyObject *py_binary_format_resolve_relative_routine(PyObject *, PyObject static PyObject *py_binary_format_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - Py_RETURN_NONE; + PyErr_SetString(PyExc_ValueError, + _("pychrysalide.format.BinFormat can not be instanciated directly")); + + return NULL; } @@ -70,9 +86,14 @@ static PyObject *py_binary_format_new(PyTypeObject *type, PyObject *args, PyObje + + + + + /****************************************************************************** * * -* Paramètres : self = classe représentant un binaire. * +* Paramètres : self = classe représentant un format binaire. * * args = arguments fournis à l'appel. * * * * Description : Recherche une position dans une routine selon une adresse. * @@ -113,6 +134,39 @@ static PyObject *py_binary_format_resolve_relative_routine(PyObject *self, PyObj +/****************************************************************************** +* * +* Paramètres : self = classe représentant un format binaire. * +* closure = adresse non utilisée ici. * +* * +* Description : Fournit le prototype de toutes les routines détectées. * +* * +* Retour : Liste de routine, vide ou non. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_binary_format_get_routines(PyObject *self, void *closure) +{ + PyObject *result; /* Tuple à retourner */ + GBinFormat *format; /* Format à manipuler */ + GBinRoutine **routines; /* Routines binaires présentes */ + size_t count; /* Quantité de ces routines */ + size_t i; /* Boucle de parcours */ + + format = G_BIN_FORMAT(pygobject_get(self)); + routines = g_binary_format_get_routines(format, &count); + + result = PyTuple_New(count); + + for (i = 0; i < count; i++) + PyTuple_SetItem(result, i, pygobject_new(G_OBJECT(routines[i]))); + + return result; + +} + @@ -143,6 +197,10 @@ bool register_python_binary_format(PyObject *module) }; static PyGetSetDef py_binary_format_getseters[] = { + { + "routines", (getter)py_binary_format_get_routines, (setter)NULL, + "Provide the list of all detected routines in the binary format.", NULL + }, { NULL } }; |