summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format/executable.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/format/executable.c')
-rw-r--r--plugins/pychrysa/format/executable.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/plugins/pychrysa/format/executable.c b/plugins/pychrysa/format/executable.c
index 96b5e82..1b1bfe8 100644
--- a/plugins/pychrysa/format/executable.c
+++ b/plugins/pychrysa/format/executable.c
@@ -33,9 +33,106 @@
#include "format.h"
#include "../helpers.h"
+#include "../arch/vmpa.h"
+/* Fournit l'emplacement correspondant à une position physique. */
+static PyObject *py_exe_format_translate_offset_into_vmpa(PyObject *, PyObject *);
+
+/* Fournit l'emplacement correspondant à une adresse virtuelle. */
+static PyObject *py_exe_format_translate_address_into_vmpa(PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = description de l'exécutable à consulter. *
+* args = arguments accompagnant l'appel. *
+* *
+* Description : Fournit l'emplacement correspondant à une position physique. *
+* *
+* Retour : Position correspondante ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_exe_format_translate_offset_into_vmpa(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Instance à retourner */
+ GExeFormat *format; /* Version GLib du format */
+ unsigned long long off; /* Adresse en mémoire virtuelle*/
+ int ret; /* Bilan de lecture des args. */
+ vmpa2t pos; /* Position complète déterminée*/
+ bool status; /* Bilan de l'opération */
+
+ format = G_EXE_FORMAT(pygobject_get(self));
+ assert(format != NULL);
+
+ ret = PyArg_ParseTuple(args, "K", &off);
+ if (!ret) return NULL;
+
+ status = g_exe_format_translate_offset_into_vmpa(format, off, &pos);
+
+ if (status)
+ result = build_from_internal_vmpa(&pos);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = description de l'exécutable à consulter. *
+* args = arguments accompagnant l'appel. *
+* *
+* Description : Fournit l'emplacement correspondant à une adresse virtuelle. *
+* *
+* Retour : Position correspondante ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_exe_format_translate_address_into_vmpa(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Instance à retourner */
+ GExeFormat *format; /* Version GLib du format */
+ unsigned long long addr; /* Adresse en mémoire virtuelle*/
+ int ret; /* Bilan de lecture des args. */
+ vmpa2t pos; /* Position complète déterminée*/
+ bool status; /* Bilan de l'opération */
+
+ format = G_EXE_FORMAT(pygobject_get(self));
+ assert(format != NULL);
+
+ ret = PyArg_ParseTuple(args, "K", &addr);
+ if (!ret) return NULL;
+
+ status = g_exe_format_translate_address_into_vmpa(format, addr, &pos);
+
+ if (status)
+ result = build_from_internal_vmpa(&pos);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
/******************************************************************************
* *
* Paramètres : - *
@@ -51,6 +148,16 @@
PyTypeObject *get_python_executable_format_type(void)
{
static PyMethodDef py_exe_format_methods[] = {
+ {
+ "translate_offset_into_vmpa", py_exe_format_translate_offset_into_vmpa,
+ METH_VARARGS,
+ "translate_offset_into_vmpa($self, off, /)\n--\n\nTranslate a physical offset to a full location.."
+ },
+ {
+ "translate_address_into_vmpa", py_exe_format_translate_address_into_vmpa,
+ METH_VARARGS,
+ "translate_address_into_vmpa($self, addr, /)\n--\n\nTranslate a physical offset to a full location.."
+ },
{ NULL }
};