summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/analysis/binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/analysis/binary.c')
-rw-r--r--plugins/pychrysa/analysis/binary.c64
1 files changed, 54 insertions, 10 deletions
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index fad84cd..31fbfc2 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -35,12 +35,15 @@
-/* Lance l'analyse d'un élément binaire chargé. */
-static PyObject *py_loaded_binary_analyse(PyObject *, PyObject *);
+/* Crée un nouvel objet Python de type 'LoadedBinary'. */
+static PyObject *py_loaded_binary_new(PyTypeObject *, PyObject *, PyObject *);
/* Fournit le nom associé à l'élément binaire. */
static PyObject *py_loaded_binary_get_name(PyObject *, void *);
+/* Lance l'analyse d'un élément binaire chargé. */
+static PyObject *py_loaded_binary_analyse(PyObject *, PyObject *);
+
/* Fournit le format de fichier reconnu dans le contenu binaire. */
static PyObject *py_loaded_binary_get_format(PyObject *, void *);
@@ -54,26 +57,40 @@ static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *, void *);
/******************************************************************************
* *
-* Paramètres : self = contenu binaire à manipuler. *
-* args = non utilisé ici. *
+* Paramètres : type = type de l'objet à instancier. *
+* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
* *
-* Description : Lance l'analyse d'un élément binaire chargé. *
+* Description : Crée un nouvel objet Python de type 'LoadedBinary'. *
* *
-* Retour : Rien (None). *
+* Retour : Instance Python mise en place. *
* *
* Remarques : - *
* *
******************************************************************************/
-static PyObject *py_loaded_binary_analyse(PyObject *self, PyObject *args)
+static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
+ PyObject *result; /* Instance à retourner */
+ PyObject *content_obj; /* Objet pour le contenu */
+ int ret; /* Bilan de lecture des args. */
+ GBinContent *content; /* Instance GLib correspondante*/
GLoadedBinary *binary; /* Version GLib du format */
- binary = G_LOADED_BINARY(pygobject_get(self));
+ ret = PyArg_ParseTuple(args, "O", &content_obj);
+ if (!ret) return NULL;
- g_loaded_binary_analyse(binary);
+ ret = PyObject_IsInstance(content_obj, (PyObject *)get_python_binary_content_type());
+ if (!ret) return NULL;
- Py_RETURN_NONE;
+ content = G_BIN_CONTENT(pygobject_get(content_obj));
+ binary = g_loaded_binary_new(content);
+
+ result = pygobject_new(G_OBJECT(binary));
+
+ g_object_unref(binary);
+
+ return result;
}
@@ -110,6 +127,32 @@ static PyObject *py_loaded_binary_get_name(PyObject *self, void *closure)
/******************************************************************************
* *
+* Paramètres : self = contenu binaire à manipuler. *
+* args = non utilisé ici. *
+* *
+* Description : Lance l'analyse d'un élément binaire chargé. *
+* *
+* Retour : Rien (None). *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_loaded_binary_analyse(PyObject *self, PyObject *args)
+{
+ GLoadedBinary *binary; /* Version GLib du format */
+
+ binary = G_LOADED_BINARY(pygobject_get(self));
+
+ g_loaded_binary_analyse(binary);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
@@ -255,6 +298,7 @@ PyTypeObject *get_python_loaded_binary_type(void)
.tp_methods = py_loaded_binary_methods,
.tp_getset = py_loaded_binary_getseters,
+ .tp_new = (newfunc)py_loaded_binary_new
};