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.c76
1 files changed, 5 insertions, 71 deletions
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index e8158a2..abbbad5 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -28,7 +28,7 @@
#include <pygobject.h>
-#include <analysis/binaries/file.h> /* REMME ! */
+#include <analysis/binary.h>
#include "../quirks.h"
@@ -38,9 +38,6 @@
-/* Crée un nouvel objet Python de type 'LoadedBinary'. */
-static PyObject *py_loaded_binary_new(PyTypeObject *, PyObject *, PyObject *);
-
/* Fournit le fichier correspondant à l'élément binaire. */
static PyObject *py_loaded_binary_get_filename(PyObject *self, PyObject *args);
@@ -60,68 +57,6 @@ static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *, void *);
/******************************************************************************
* *
-* Paramètres : type = type de l'objet à instancier. *
-* args = arguments fournis à l'appel. *
-* kwds = arguments de type key=val fournis. *
-* *
-* Description : Crée un nouvel objet Python de type 'LoadedBinary'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- PyObject *result; /* Instance à retourner */
- char *filename; /* Nom du fichier à charger */
- int ret; /* Bilan de lecture des args. */
- GLoadedBinary *binary; /* Version GLib du format */
-
- ret = PyArg_ParseTuple(args, "s", &filename);
- if (!ret) return Py_None;
-
- binary = g_file_binary_new_from_file(filename);
-
- result = py_loaded_binary_from_c(binary);
- g_object_unref(binary);
-
- return (PyObject *)result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = instance existante GLib. *
-* *
-* Description : Crée un nouvel objet Python de type 'LoadedBinary'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyObject *py_loaded_binary_from_c(GLoadedBinary *binary)
-{
- PyObject *module; /* Module d'appartenance */
- PyTypeObject *type; /* Type Python correspondant */
-
- module = PyImport_ImportModule("pychrysalide.analysis");
- type = (PyTypeObject *)PyObject_GetAttrString(module, "LoadedBinary");
- Py_DECREF(module);
-
- pychrysalide_set_instance_data(G_OBJECT(binary), type);
-
- return pygobject_new(G_OBJECT(binary));
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : self = classe représentant un binaire. *
* args = arguments fournis à l'appel. *
* *
@@ -172,7 +107,7 @@ static PyObject *py_loaded_binary_get_format(PyObject *self, PyObject *args)
binary = G_LOADED_BINARY(pygobject_get(self));
format = g_loaded_binary_get_format(binary);
- result = py_executable_format_from_c(format);
+ result = pygobject_new(G_OBJECT(format));
return result;
@@ -202,7 +137,7 @@ static PyObject *py_loaded_binary_get_instructions(PyObject *self, PyObject *arg
instr = g_loaded_binary_get_instructions(binary);
- result = py_arch_instruction_from_c(instr);
+ result = pygobject_new(G_OBJECT(instr));
return result;
@@ -234,7 +169,7 @@ static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *self, void *
binary = G_LOADED_BINARY(pygobject_get(self));
buffer = g_loaded_binary_get_disassembled_buffer(binary);
- result = py_code_buffer_from_c(buffer);
+ result = pygobject_new(G_OBJECT(buffer));
return result;
@@ -304,8 +239,7 @@ bool register_python_loaded_binary(PyObject *module)
.tp_doc = "PyChrysalide loaded binary",
.tp_methods = py_loaded_binary_methods,
- .tp_getset = py_loaded_binary_getseters,
- .tp_new = (newfunc)py_loaded_binary_new
+ .tp_getset = py_loaded_binary_getseters
};