diff options
Diffstat (limited to 'plugins/pychrysalide/format/known.c')
-rw-r--r-- | plugins/pychrysalide/format/known.c | 173 |
1 files changed, 13 insertions, 160 deletions
diff --git a/plugins/pychrysalide/format/known.c b/plugins/pychrysalide/format/known.c index e38c975..5df2a8f 100644 --- a/plugins/pychrysalide/format/known.c +++ b/plugins/pychrysalide/format/known.c @@ -55,13 +55,8 @@ static char *py_known_format_get_key_wrapper(const GKnownFormat *); /* Fournit une description humaine du format. */ static char *py_known_format_get_description_wrapper(const GKnownFormat *); -#if 0 /* Assure l'interprétation d'un format en différé. */ -static bool py_known_format_analyze_wrapper(GKnownFormat *, wgroup_id_t, GtkStatusStack *); - -/* Réalise un traitement post-désassemblage. */ -static void py_known_format_complete_analysis_wrapper(GKnownFormat *, wgroup_id_t, GtkStatusStack *); -#endif +static bool py_known_format_analyze_wrapper(GKnownFormat *); @@ -69,10 +64,7 @@ static void py_known_format_complete_analysis_wrapper(GKnownFormat *, wgroup_id_ /* Assure l'interprétation d'un format en différé. */ -//static PyObject *py_known_format_analyze(PyObject *, PyObject *); - -/* Réalise un traitement post-désassemblage. */ -//static PyObject *py_known_format_complete_analysis(PyObject *, PyObject *); +static PyObject *py_known_format_analyze(PyObject *, PyObject *); /* Indique la désignation interne du format. */ static PyObject *py_known_format_get_key(PyObject *, void *); @@ -108,8 +100,7 @@ static void py_known_format_init_gclass(GKnownFormatClass *class, gpointer unuse class->get_key = py_known_format_get_key_wrapper; class->get_desc = py_known_format_get_description_wrapper; - //class->analyze = py_known_format_analyze_wrapper; - //class->complete = py_known_format_complete_analysis_wrapper; + class->analyze = py_known_format_analyze_wrapper; } @@ -143,9 +134,6 @@ static int py_known_format_init(PyObject *self, PyObject *args, PyObject *kwds) "* pychrysalide.format.KnownFormat._get_description();\n" \ "* pychrysalide.format.KnownFormat._analyze().\n" \ "\n" \ - "The following method may also be defined for new classes too:\n" \ - "* pychrysalide.format.KnownFormat._complete_analysis().\n" \ - "\n" \ "Calls to the *__init__* constructor of this abstract object expect"\ " only one argument: a binary content, provided as a" \ " pychrysalide.analysis.BinContent instance." @@ -298,12 +286,10 @@ static char *py_known_format_get_description_wrapper(const GKnownFormat *format) } -#if 0 + /****************************************************************************** * * * Paramètres : format = format chargé dont l'analyse est lancée. * -* gid = groupe de travail dédié. * -* status = barre de statut à tenir informée. * * * * Description : Assure l'interprétation d'un format en différé. * * * @@ -313,12 +299,11 @@ static char *py_known_format_get_description_wrapper(const GKnownFormat *format) * * ******************************************************************************/ -static bool py_known_format_analyze_wrapper(GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) +static bool py_known_format_analyze_wrapper(GKnownFormat *format) { bool result; /* Bilan à retourner */ PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ - PyObject *args; /* Arguments pour l'appel */ PyObject *pyret; /* Bilan d'exécution */ #define KNOWN_FORMAT_ANALYZE_WRAPPER PYTHON_WRAPPER_DEF \ @@ -328,12 +313,8 @@ static bool py_known_format_analyze_wrapper(GKnownFormat *format, wgroup_id_t gi "Abstract method used to start the analysis of the known" \ " format and return its status.\n" \ "\n" \ - "The identifier refers to the working queue used to process" \ - " the analysis. A reference to the main status bar may also be" \ - " provided, as a pychrysalide.gtkext.StatusStack instance if" \ - " running in graphical mode or None otherwise.\n" \ - "\n" \ - "The expected result of the call is a boolean." \ + "The expected result of the call is a boolean value: *True* in" \ + " case of success, *False* in case of failure." \ ) result = false; @@ -344,16 +325,10 @@ static bool py_known_format_analyze_wrapper(GKnownFormat *format, wgroup_id_t gi if (has_python_method(pyobj, "_analyze")) { - args = PyTuple_New(2); - - PyTuple_SetItem(args, 0, PyLong_FromUnsignedLong(gid)); - PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(status))); - - pyret = run_python_method(pyobj, "_analyze", args); + pyret = run_python_method(pyobj, "_analyze", NULL); result = (pyret == Py_True); - Py_DECREF(args); Py_XDECREF(pyret); } @@ -367,71 +342,12 @@ static bool py_known_format_analyze_wrapper(GKnownFormat *format, wgroup_id_t gi } -/****************************************************************************** -* * -* Paramètres : format = format chargé dont l'analyse est lancée. * -* gid = groupe de travail dédié. * -* status = barre de statut à tenir informée. * -* * -* Description : Réalise un traitement post-désassemblage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void py_known_format_complete_analysis_wrapper(GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) -{ - PyGILState_STATE gstate; /* Sauvegarde d'environnement */ - PyObject *pyobj; /* Objet Python concerné */ - PyObject *args; /* Arguments pour l'appel */ - PyObject *pyret; /* Bilan d'exécution */ - -#define KNOWN_FORMAT_COMPLETE_ANALYSIS_WRAPPER PYTHON_VOID_WRAPPER_DEF \ -( \ - _complete_analysis, "$self, gid, status, /", \ - METH_VARARGS, \ - "Abstract method used to complete an analysis of a known format.\n" \ - "\n" \ - "The identifier refers to the working queue used to process the" \ - " analysis. A reference to the main status bar may also be" \ - " provided, as a pychrysalide.gtkext.StatusStack instance if" \ - " running in graphical mode or None otherwise.\n" \ -) - - gstate = PyGILState_Ensure(); - - pyobj = pygobject_new(G_OBJECT(format)); - - if (has_python_method(pyobj, "_complete_analysis")) - { - args = PyTuple_New(2); - - PyTuple_SetItem(args, 0, PyLong_FromUnsignedLong(gid)); - PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(status))); - - pyret = run_python_method(pyobj, "_complete_analysis", args); - - Py_DECREF(args); - Py_XDECREF(pyret); - - } - - Py_DECREF(pyobj); - - PyGILState_Release(gstate); - -} -#endif - /* ---------------------------------------------------------------------------------- */ /* DEFINITION DU FORMAT CONNU */ /* ---------------------------------------------------------------------------------- */ -#if 0 /****************************************************************************** * * * Paramètres : self = objet représentant un format connu. * @@ -448,33 +364,24 @@ static void py_known_format_complete_analysis_wrapper(GKnownFormat *format, wgro static PyObject *py_known_format_analyze(PyObject *self, PyObject *args) { PyObject *result; /* Bilan à retourner */ - int ret; /* Bilan de lecture des args. */ GKnownFormat *format; /* Format connu manipulé */ bool status; /* Bilan de l'opération */ #define KNOWN_FORMAT_ANALYZE_METHOD PYTHON_METHOD_DEF \ ( \ - analyze, "$self, gid, status, /", \ - METH_VARARGS, py_known_format, \ + analyze, "$self", \ + METH_NOARGS, py_known_format, \ "Start the analysis of the known format and return its status." \ "\n" \ "Once this analysis is done, a few early symbols and the" \ " mapped sections are expected to be defined, if any.\n" \ "\n" \ - "The identifier refers to the working queue used to process" \ - " the analysis. A reference to the main status bar may also be" \ - " provided, as a pychrysalide.gtkext.StatusStack instance if" \ - " running in graphical mode or None otherwise.\n" \ - "\n" \ "The return value is a boolean status of the operation." \ ) - ret = PyArg_ParseTuple(args, "");//|KO!", &gid, &status); - if (!ret) return NULL; - format = G_KNOWN_FORMAT(pygobject_get(self)); - status = g_known_format_analyze(format, 0, NULL); + status = g_known_format_analyze(format); result = status ? Py_True : Py_False; Py_INCREF(result); @@ -486,58 +393,6 @@ static PyObject *py_known_format_analyze(PyObject *self, PyObject *args) /****************************************************************************** * * -* Paramètres : self = objet représentant un format connu. * -* args = arguments fournis pour l'opération. * -* * -* Description : Réalise un traitement post-désassemblage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_known_format_complete_analysis(PyObject *self, PyObject *args) -{ - PyObject *result; /* Bilan à retourner */ - int ret; /* Bilan de lecture des args. */ - GKnownFormat *format; /* Format connu manipulé */ - -#define KNOWN_FORMAT_COMPLETE_ANALYSIS_METHOD PYTHON_METHOD_DEF \ -( \ - complete_analysis, "$self, gid, status, /", \ - METH_VARARGS, py_known_format, \ - "Complete an analysis of a known format.\n" \ - "\n" \ - "This process is usually done once the disassembling process" \ - " is completed.\n" \ - "\n" \ - "The identifier refers to the working queue used to process" \ - " the analysis. A reference to the main status bar may also be" \ - " provided, as a pychrysalide.gtkext.StatusStack instance if" \ - " running in graphical mode or None otherwise.\n" \ - "\n" \ - "The return value is a boolean status of the operation." \ -) - - ret = PyArg_ParseTuple(args, "");//|KO!", &gid, &status); - if (!ret) return NULL; - - format = G_KNOWN_FORMAT(pygobject_get(self)); - - g_known_format_complete_analysis(format, 0, NULL); - - result = Py_None; - Py_INCREF(result); - - return result; - -} -#endif - - -/****************************************************************************** -* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -718,10 +573,8 @@ PyTypeObject *get_python_known_format_type(void) static PyMethodDef py_known_format_methods[] = { KNOWN_FORMAT_GET_KEY_WRAPPER, KNOWN_FORMAT_GET_DESCRIPTION_WRAPPER, - //KNOWN_FORMAT_ANALYZE_WRAPPER, - //KNOWN_FORMAT_COMPLETE_ANALYSIS_WRAPPER, - //KNOWN_FORMAT_ANALYZE_METHOD, - //KNOWN_FORMAT_COMPLETE_ANALYSIS_METHOD, + KNOWN_FORMAT_ANALYZE_WRAPPER, + KNOWN_FORMAT_ANALYZE_METHOD, { NULL } }; |