summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-08-06 20:29:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-08-06 20:29:20 (GMT)
commitfc49e98dc2b3e0ae08a5874ecacaef046a0f3ec1 (patch)
treee121c5eb5dd0629554a498f8e1a1cce3fc0715b4 /plugins/pychrysa/analysis/binary.c
parentfacec716100f598a8694889274a4589c75c14722 (diff)
Saved progress toward the Android permissions display.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@258 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/analysis/binary.c')
-rw-r--r--plugins/pychrysa/analysis/binary.c106
1 files changed, 97 insertions, 9 deletions
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index 4cfb615..44721b5 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* binary.c - équivalent Python du fichier "analysis/binary.h"
*
- * Copyright (C) 2010 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -29,6 +29,8 @@
#include "../quirks.h"
+#include "../arch/instruction.h"
+#include "../glibext/codebuffer.h"
@@ -38,6 +40,15 @@ 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 les instructions issues du désassemblage. */
+static PyObject *py_loaded_binary_get_instructions(PyObject *, PyObject *);
+
+
+
+/* Fournit le tampon associé au contenu assembleur d'un binaire. */
+static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *, void *);
+
+
/******************************************************************************
@@ -92,7 +103,7 @@ PyObject *py_loaded_binary_from_c(GOpenidaBinary *binary)
PyTypeObject *type; /* Type Python correspondant */
module = PyImport_ImportModule("pychrysalide.analysis");
- type = (PyTypeObject*)PyObject_GetAttrString(module, "LoadedBinary");
+ type = (PyTypeObject *)PyObject_GetAttrString(module, "LoadedBinary");
Py_DECREF(module);
pychrysalide_set_instance_data(G_OBJECT(binary), type);
@@ -102,14 +113,9 @@ PyObject *py_loaded_binary_from_c(GOpenidaBinary *binary)
}
-
-
-
-
-
/******************************************************************************
* *
-* Paramètres : self = classe représentant un débogueur. *
+* Paramètres : self = classe représentant un binaire. *
* args = arguments fournis à l'appel. *
* *
* Description : Fournit le fichier correspondant à l'élément binaire. *
@@ -137,6 +143,73 @@ 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 les instructions issues du désassemblage. *
+* *
+* Retour : Instructions issues du désassemblage. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_loaded_binary_get_instructions(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Trouvailles à retourner */
+ GOpenidaBinary *binary; /* Version native */
+ GArchInstruction *instr; /* Première instruction */
+
+ binary = G_OPENIDA_BINARY(pygobject_get(self));
+
+ instr = g_openida_binary_get_instructions(binary);
+
+ result = py_arch_instruction_from_c(instr);
+
+ return result;
+
+}
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant une instruction. *
+* closure = adresse non utilisée ici. *
+* *
+* Description : Fournit le tampon associé au contenu assembleur d'un binaire.*
+* *
+* Retour : Valeur associée à la propriété consultée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *self, void *closure)
+{
+ PyObject *result; /* Trouvailles à retourner */
+ GOpenidaBinary *binary; /* Version native */
+ GCodeBuffer *buffer; /* Tampon à récupérer */
+
+ binary = G_OPENIDA_BINARY(pygobject_get(self));
+ buffer = g_openida_binary_get_disassembled_buffer(binary);
+
+ result = py_code_buffer_from_c(buffer);
+
+ return result;
+
+}
+
+
+
+
+
+
+
/******************************************************************************
@@ -145,7 +218,7 @@ static PyObject *py_loaded_binary_get_filename(PyObject *self, PyObject *args)
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.LoadedBinary'.*
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
@@ -162,6 +235,20 @@ bool register_python_loaded_binary(PyObject *module)
METH_NOARGS,
"Provide the filename of the loaded binary."
},
+ {
+ "get_instructions", (PyCFunction)py_loaded_binary_get_instructions,
+ METH_NOARGS,
+ "Give access to all disassembled instructions."
+ },
+
+ { NULL }
+ };
+
+ static PyGetSetDef py_loaded_binary_getseters[] = {
+ {
+ "disassembled_buffer", (getter)py_loaded_binary_get_disassembled_buffer, (setter)NULL,
+ "Give access to the disassembled code buffer.", NULL
+ },
{ NULL }
};
@@ -177,6 +264,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
};