summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r--plugins/pychrysalide/format/executable.c41
-rw-r--r--plugins/pychrysalide/format/format.c36
2 files changed, 77 insertions, 0 deletions
diff --git a/plugins/pychrysalide/format/executable.c b/plugins/pychrysalide/format/executable.c
index 906fae5..5621d26 100644
--- a/plugins/pychrysalide/format/executable.c
+++ b/plugins/pychrysalide/format/executable.c
@@ -38,12 +38,16 @@
#include "../helpers.h"
#include "../arch/processor.h"
#include "../arch/vmpa.h"
+#include "../glibext/binportion.h"
/* ------------------------ DECLARATION DE FORMAT EXECUTABLE ------------------------ */
+/* Enregistre une portion artificielle pour le format. */
+static PyObject *py_exe_format_register_user_portion(PyObject *, PyObject *);
+
/* Fournit l'emplacement correspondant à une position physique. */
static PyObject *py_exe_format_translate_offset_into_vmpa(PyObject *, PyObject *);
@@ -62,6 +66,38 @@ 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 : Enregistre une portion artificielle pour le format. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_exe_format_register_user_portion(PyObject *self, PyObject *args)
+{
+ GBinPortion *portion; /* Portion binaire à conserver */
+ int ret; /* Bilan de lecture des args. */
+ GExeFormat *format; /* Version GLib du format */
+
+ ret = PyArg_ParseTuple(args, "O&", convert_to_binary_portion, &portion);
+ if (!ret) return NULL;
+
+ format = G_EXE_FORMAT(pygobject_get(self));
+
+ g_object_ref(G_OBJECT(portion));
+ g_exe_format_register_user_portion(format, portion);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* 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. *
@@ -161,6 +197,11 @@ PyTypeObject *get_python_executable_format_type(void)
{
static PyMethodDef py_exe_format_methods[] = {
{
+ "register_user_portion", py_exe_format_register_user_portion,
+ METH_VARARGS,
+ "register_user_portion($self, portion, /)\n--\n\nRemember a given user-defined binary portion as part of the executable format content."
+ },
+ {
"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."
diff --git a/plugins/pychrysalide/format/format.c b/plugins/pychrysalide/format/format.c
index 2affeba..e285116 100644
--- a/plugins/pychrysalide/format/format.c
+++ b/plugins/pychrysalide/format/format.c
@@ -43,6 +43,8 @@
/* ---------------------------- FORMAT BINAIRE GENERIQUE ---------------------------- */
+/* Enregistre une adresse comme début d'une zone de code. */
+static PyObject *py_binary_format_register_code_point(PyObject *, PyObject *);
/* Ajoute un symbole à la collection du format binaire. */
static PyObject *py_binary_format_add_symbol(PyObject *, PyObject *);
@@ -100,7 +102,36 @@ static bool define_python_binary_format_constants(PyTypeObject *);
/* ---------------------------------------------------------------------------------- */
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant un format. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Enregistre une adresse comme début d'une zone de code. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_binary_format_register_code_point(PyObject *self, PyObject *args)
+{
+ unsigned long long pt; /* Adresse virtuelle du point */
+ int entry; /* Nature du point fourni */
+ int ret; /* Bilan de lecture des args. */
+ GBinFormat *format; /* Format de binaire manipulé */
+ ret = PyArg_ParseTuple(args, "Kp", &pt, &entry);
+ if (!ret) return NULL;
+
+ format = G_BIN_FORMAT(pygobject_get(self));
+
+ g_binary_format_register_code_point(format, pt, entry);
+
+ Py_RETURN_NONE;
+
+}
/******************************************************************************
@@ -638,6 +669,11 @@ PyTypeObject *get_python_binary_format_type(void)
{
static PyMethodDef py_bin_format_methods[] = {
{
+ "register_code_point", py_binary_format_register_code_point,
+ METH_VARARGS,
+ "register_code_point($self, pt, entry, /)\n--\n\nRegister a virtual address as entry point or basic point."
+ },
+ {
"add_symbol", py_binary_format_add_symbol,
METH_VARARGS,
"add_symbol($self, symbol, /)\n--\n\nRegister a new symbol for the format."