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.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index 93db685..e8158a2 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -33,6 +33,7 @@
#include "../quirks.h"
#include "../arch/instruction.h"
+#include "../format/executable.h"
#include "../glibext/codebuffer.h"
@@ -43,6 +44,9 @@ 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);
+/* Fournit le format de fichier reconnu dans le contenu binaire. */
+static PyObject *py_loaded_binary_get_format(PyObject *, PyObject *);
+
/* Fournit les instructions issues du désassemblage. */
static PyObject *py_loaded_binary_get_instructions(PyObject *, PyObject *);
@@ -151,6 +155,35 @@ static PyObject *py_loaded_binary_get_filename(PyObject *self, PyObject *args)
* Paramètres : self = classe représentant un binaire. *
* args = arguments fournis à l'appel. *
* *
+* Description : Fournit le format de fichier reconnu dans le contenu binaire.*
+* *
+* Retour : Nom de fichier avec chemin absolu. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_loaded_binary_get_format(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Trouvailles à retourner */
+ GLoadedBinary *binary; /* Version native */
+ GExeFormat *format; /* Format du binaire physique */
+
+ binary = G_LOADED_BINARY(pygobject_get(self));
+ format = g_loaded_binary_get_format(binary);
+
+ result = py_executable_format_from_c(format);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant un binaire. *
+* args = arguments fournis à l'appel. *
+* *
* Description : Fournit les instructions issues du désassemblage. *
* *
* Retour : Instructions issues du désassemblage. *
@@ -239,11 +272,15 @@ bool register_python_loaded_binary(PyObject *module)
"Provide the filename of the loaded binary."
},
{
+ "get_format", (PyCFunction)py_loaded_binary_get_format,
+ METH_NOARGS,
+ "Provide the file format recognized in the binary content."
+ },
+ {
"get_instructions", (PyCFunction)py_loaded_binary_get_instructions,
METH_NOARGS,
"Give access to all disassembled instructions."
},
-
{ NULL }
};