summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format/format.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-26 19:41:04 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-26 19:41:04 (GMT)
commit2050b07c42c15738662dd9b3c5841694b64ab2a3 (patch)
treef6283df4b4775f0c4e42e14025d67443f8fdf9b5 /plugins/pychrysa/format/format.c
parentb0b35292cb22899b1b23556be452eb827e4010d7 (diff)
Provided some debug helpers as plugin samples.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@330 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/format/format.c')
-rw-r--r--plugins/pychrysa/format/format.c64
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 }
};