From 0194351c3401df90ab8f7cffb0d40968fb4c31ad Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 12 Nov 2017 21:19:25 +0100 Subject: Provided a way to wait for analysis endings without signals. --- ChangeLog | 12 +++++++++ plugins/pychrysa/analysis/binary.c | 35 ++++++++++++++++++++++++ src/analysis/binary.c | 54 +++++++++++++++++++++++++++++++++++--- src/analysis/binary.h | 3 +++ src/analysis/disass/disassembler.c | 4 ++- 5 files changed, 104 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c44bdf..aa699e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 17-11-12 Cyrille Bagard + * plugins/pychrysa/analysis/binary.c: + Update the Python API. + + * src/analysis/binary.c: + * src/analysis/binary.h: + Provide a way to wait for analysis endings without signals. + + * src/analysis/disass/disassembler.c: + Update code. + +17-11-12 Cyrille Bagard + * plugins/pychrysa/glibext/Makefile.am: Add the 'loadedpanel.[ch]' files to libpychrysaglibext_la_SOURCES. diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c index 687565a..6be767c 100644 --- a/plugins/pychrysa/analysis/binary.c +++ b/plugins/pychrysa/analysis/binary.c @@ -48,6 +48,9 @@ static PyObject *py_loaded_binary_get_name(PyObject *, void *); /* Lance l'analyse d'un élément binaire chargé. */ static PyObject *py_loaded_binary_analyse(PyObject *, PyObject *); +/* Lance l'analyse d'un binaire chargé et attend sa conclusion. */ +static PyObject *py_loaded_binary_analyse_and_wait(PyObject *, PyObject *); + /* Fournit le format de fichier reconnu dans le contenu binaire. */ static PyObject *py_loaded_binary_get_format(PyObject *, void *); @@ -161,6 +164,32 @@ static PyObject *py_loaded_binary_analyse(PyObject *self, PyObject *args) /****************************************************************************** * * +* Paramètres : self = contenu binaire à manipuler. * +* args = non utilisé ici. * +* * +* Description : Lance l'analyse d'un binaire chargé et attend sa conclusion. * +* * +* Retour : Rien (None). * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_loaded_binary_analyse_and_wait(PyObject *self, PyObject *args) +{ + GLoadedBinary *binary; /* Version GLib du format */ + + binary = G_LOADED_BINARY(pygobject_get(self)); + + g_loaded_binary_analyse_and_wait(binary); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -273,6 +302,12 @@ PyTypeObject *get_python_loaded_binary_type(void) "analyse(/)\n--\n\nStart the analysis of the loaded binary and " \ "send a \"disassembly-done\" signal when done." }, + { + "analyse_and_wait", py_loaded_binary_analyse_and_wait, + METH_NOARGS, + "analyse_and_wait(/)\n--\n\nRun the analysis of the loaded binary and " \ + "wait for its completion." + }, { NULL } }; diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 4d9e8a8..7b0e528 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -44,6 +44,7 @@ #include "../common/xdg.h" #include "../core/collections.h" #include "../core/formats.h" +#include "../core/global.h" #include "../core/params.h" #include "../core/processors.h" #include "../glibext/chrysamarshal.h" @@ -140,6 +141,8 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *); +/* Lance l'analyse d'un élément binaire chargé. */ +static void _g_loaded_binary_analyse(GLoadedBinary *, disassembly_ack_fc); @@ -1371,10 +1374,10 @@ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *binary, DBFeatures f - /****************************************************************************** * * * Paramètres : binary = élément binaire à traiter. * +* ack = éventuelle fonction à appeler en conclusion. * * * * Description : Lance l'analyse d'un élément binaire chargé. * * * @@ -1384,7 +1387,7 @@ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *binary, DBFeatures f * * ******************************************************************************/ -void g_loaded_binary_analyse(GLoadedBinary *binary) +static void _g_loaded_binary_analyse(GLoadedBinary *binary, disassembly_ack_fc ack) { /* Détermination de l'identifiant */ @@ -1398,7 +1401,7 @@ void g_loaded_binary_analyse(GLoadedBinary *binary) g_loaded_binary_connect_internal(binary); - disassemble_binary(binary, &binary->disass_cache, ack_completed_disassembly); + disassemble_binary(binary, &binary->disass_cache, ack); @@ -1410,6 +1413,51 @@ void g_loaded_binary_analyse(GLoadedBinary *binary) /****************************************************************************** * * +* Paramètres : binary = élément binaire à traiter. * +* * +* Description : Lance l'analyse d'un élément binaire chargé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_loaded_binary_analyse(GLoadedBinary *binary) +{ + _g_loaded_binary_analyse(binary, ack_completed_disassembly); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à traiter. * +* * +* Description : Lance l'analyse d'un binaire chargé et attend sa conclusion. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_loaded_binary_analyse_and_wait(GLoadedBinary *binary) +{ + GWorkQueue *queue; /* Gestionnaire de différés */ + + _g_loaded_binary_analyse(binary, NULL); + + queue = get_work_queue(); + g_work_queue_wait_for_completion(queue, DEFAULT_WORK_GROUP); + + ack_completed_disassembly(NULL, binary); + +} + + +/****************************************************************************** +* * * Paramètres : binary = élément binaire à consulter. * * * * Description : Fournit le format de fichier reconnu dans le contenu binaire.* diff --git a/src/analysis/binary.h b/src/analysis/binary.h index d6b9a5b..2df42aa 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -173,6 +173,9 @@ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *, DBFeatures, GDbIte /* Lance l'analyse d'un élément binaire chargé. */ void g_loaded_binary_analyse(GLoadedBinary *); +/* Lance l'analyse d'un binaire chargé et attend sa conclusion. */ +void g_loaded_binary_analyse_and_wait(GLoadedBinary *); + /* Fournit le format de fichier reconnu dans le contenu binaire. */ bool g_loaded_binary_attach_debug_info(GLoadedBinary *, GBinContent *); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 976ef11..7a066fc 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -706,7 +706,9 @@ void disassemble_binary(GLoadedBinary *binary, GBufferCache **cache, disassembly g_object_unref(G_OBJECT(format)); disass = g_delayed_disassembly_new(binary, *cache); - g_signal_connect(disass, "work-completed", G_CALLBACK(ack), binary); + + if (ack != NULL) + g_signal_connect(disass, "work-completed", G_CALLBACK(ack), binary); queue = get_work_queue(); g_work_queue_schedule_work(queue, G_DELAYED_WORK(disass), DEFAULT_WORK_GROUP); -- cgit v0.11.2-87-g4458