From a819ce2256e7142e15f87f9f62f56f24688e33fc Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 15 Mar 2020 21:07:25 +0100 Subject: Provided a way to analyze a binary format without performing disassembling. --- plugins/pychrysalide/format/format.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/plugins/pychrysalide/format/format.c b/plugins/pychrysalide/format/format.c index 3709f6d..a0f8079 100644 --- a/plugins/pychrysalide/format/format.c +++ b/plugins/pychrysalide/format/format.c @@ -43,6 +43,9 @@ /* ---------------------------- FORMAT BINAIRE GENERIQUE ---------------------------- */ +/* Assure l'interprétation d'un format en différé. */ +static PyObject *py_binary_format_analyze(PyObject *, PyObject *, PyObject *); + /* Enregistre une adresse comme début d'une zone de code. */ static PyObject *py_binary_format_register_code_point(PyObject *, PyObject *); @@ -104,6 +107,50 @@ static bool define_python_binary_format_constants(PyTypeObject *); /****************************************************************************** * * +* Paramètres : self = contenu binaire à manipuler. * +* args = arguments fournis à l'appel. * +* kwds = arguments de type key=val fournis. * +* * +* Description : Assure l'interprétation d'un format en différé. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_binary_format_analyze(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *result; /* Bilan à retourner */ + GBinFormat *format; /* Version GLib de l'élément */ + bool status; /* Bilan d'analyse à recevoir */ + +#define BINARY_FORMAT_ANALYZE_METHOD PYTHON_METHOD_DEF \ +( \ + analyze, "$self", \ + METH_NOARGS, py_binary_format, \ + "Analyze the the format recognized from a binary content.\n" \ + "\n" \ + "Once this analysis is done, a few early symbols and the mapped" \ + " sections are expected to be defined.\n" \ + "\n" \ + "The return value is a boolean status of the operation." \ +) + + format = G_BIN_FORMAT(pygobject_get(self)); + + status = g_binary_format_analyze(format, 0, NULL); + + result = status ? Py_True : Py_False; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : self = classe représentant un format. * * args = arguments fournis à l'appel. * * * @@ -669,6 +716,7 @@ static bool define_python_binary_format_constants(PyTypeObject *obj_type) PyTypeObject *get_python_binary_format_type(void) { static PyMethodDef py_bin_format_methods[] = { + BINARY_FORMAT_ANALYZE_METHOD, { "register_code_point", py_binary_format_register_code_point, METH_VARARGS, -- cgit v0.11.2-87-g4458