From 6ba73df8224dc2a88fe5f37a331960936758036e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 30 Aug 2017 00:30:58 +0200 Subject: Skipped the link to the global reference space when loading plugins. --- ChangeLog | 22 ++++++++++++++++++++++ plugins/mobicore/mobicore.c | 6 ++---- plugins/mobicore/mobicore.h | 4 ++-- plugins/pychrysa/plugin.c | 15 +++++++-------- plugins/pychrysa/plugin.h | 2 +- plugins/pychrysa/pychrysa.c | 12 +++++------- plugins/pychrysa/pychrysa.h | 2 +- plugins/ropgadgets/plugin.c | 16 ++++++++++------ plugins/ropgadgets/plugin.h | 2 +- plugins/ropgadgets/select.c | 14 ++++++-------- plugins/ropgadgets/select.h | 5 +---- src/main.c | 2 +- src/plugins/pglist.c | 13 +++---------- src/plugins/pglist.h | 2 +- src/plugins/plugin-int.h | 4 ++-- src/plugins/plugin.c | 12 +++++------- src/plugins/plugin.h | 2 +- 17 files changed, 71 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d62c03..1c8b550 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ 17-08-28 Cyrille Bagard + * plugins/mobicore/mobicore.c: + * plugins/mobicore/mobicore.h: + * plugins/pychrysa/plugin.c: + * plugins/pychrysa/plugin.h: + * plugins/pychrysa/pychrysa.c: + * plugins/pychrysa/pychrysa.h: + * plugins/ropgadgets/plugin.c: + * plugins/ropgadgets/plugin.h: + * plugins/ropgadgets/select.c: + * plugins/ropgadgets/select.h: + * src/main.c: + * src/plugins/pglist.c: + * src/plugins/pglist.h: + Update code. + + * src/plugins/plugin-int.h: + * src/plugins/plugin.c: + * src/plugins/plugin.h: + Skip the link to the global reference space when loading plugins. + +17-08-28 Cyrille Bagard + * src/format/preload.c: Fix a mistake when adding preloaded instructions. diff --git a/plugins/mobicore/mobicore.c b/plugins/mobicore/mobicore.c index 9ed8f32..ac2b7a9 100644 --- a/plugins/mobicore/mobicore.c +++ b/plugins/mobicore/mobicore.c @@ -40,7 +40,6 @@ DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("Mobicore", "Support MobiCore file format for Tr /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * -* ref = espace de référencement global. * * * * Description : Prend acte du chargement du greffon. * * * @@ -50,7 +49,7 @@ DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("Mobicore", "Support MobiCore file format for Tr * * ******************************************************************************/ -G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) { bool result; /* Bilan à retourner */ @@ -68,7 +67,6 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * -* ref = espace de référencement global. * * * * Description : Prend acte du déchargement du greffon. * * * @@ -78,7 +76,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) * * ******************************************************************************/ -G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin, GObject *ref) +G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin) { /* TODO */ diff --git a/plugins/mobicore/mobicore.h b/plugins/mobicore/mobicore.h index 6e17557..e0db617 100644 --- a/plugins/mobicore/mobicore.h +++ b/plugins/mobicore/mobicore.h @@ -31,10 +31,10 @@ /* Prend acte du chargement du greffon. */ -G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *, GObject *); +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); /* Prend acte du déchargement du greffon. */ -G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *, GObject *); +G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *); diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c index 651de7d..7d44f10 100644 --- a/plugins/pychrysa/plugin.c +++ b/plugins/pychrysa/plugin.c @@ -71,7 +71,7 @@ static void g_python_plugin_init(GPythonPlugin *); static bool g_python_plugin_read_interface(GPythonPlugin *); /* Procède à l'initialisation du greffon. */ -static bool g_python_plugin_do_init(GPythonPlugin *, GObject *); +static bool g_python_plugin_do_init(GPythonPlugin *); /* Procède à l'extinction du greffon. */ static bool g_python_plugin_do_exit(GPythonPlugin *, GObject *); @@ -141,7 +141,6 @@ static void g_python_plugin_init(GPythonPlugin *plugin) * * * Paramètres : modname = nom du module à charger. * * filename = chemin d'accès au code Python à charger. * -* ref = espace de référencement global. * * * * Description : Crée un greffon à partir de code Python. * * * @@ -151,7 +150,7 @@ static void g_python_plugin_init(GPythonPlugin *plugin) * * ******************************************************************************/ -GPluginModule *g_python_plugin_new(const char *modname, const char *filename, GObject *ref) +GPluginModule *g_python_plugin_new(const char *modname, const char *filename) { GPythonPlugin *result; /* Structure à retourner */ PyObject *name; /* Chemin d'accès pour Python */ @@ -346,7 +345,7 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename, GO /* Conclusion */ - if (!g_plugin_module_load(G_PLUGIN_MODULE(result), ref)) + if (!g_plugin_module_load(G_PLUGIN_MODULE(result))) goto gppn_bad_plugin; return G_PLUGIN_MODULE(result); @@ -485,18 +484,18 @@ static bool g_python_plugin_read_interface(GPythonPlugin *plugin) * * ******************************************************************************/ -static bool g_python_plugin_do_init(GPythonPlugin *plugin, GObject *ref) +static bool g_python_plugin_do_init(GPythonPlugin *plugin) { bool result; /* Bilan à retourner */ PyObject *args; /* Arguments pour l'appel */ PyObject *value; /* Valeur obtenue */ - args = PyTuple_New(1); - PyTuple_SetItem(args, 0, pygobject_new(ref)); + args = Py_None; + Py_INCREF(args); value = run_python_method(plugin->instance, "init", args); - result = PyObject_IsTrue(value); + result = (value != NULL && PyObject_IsTrue(value)); Py_XDECREF(value); Py_DECREF(args); diff --git a/plugins/pychrysa/plugin.h b/plugins/pychrysa/plugin.h index 04b65ef..ca451a8 100644 --- a/plugins/pychrysa/plugin.h +++ b/plugins/pychrysa/plugin.h @@ -57,7 +57,7 @@ typedef struct _GPythonPluginClass GPythonPluginClass; GType g_python_plugin_get_type(void); /* Crée un greffon à partir de code Python. */ -GPluginModule *g_python_plugin_new(const char *, const char *, GObject *); +GPluginModule *g_python_plugin_new(const char *, const char *); diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c index a404c1a..e9efc54 100644 --- a/plugins/pychrysa/pychrysa.c +++ b/plugins/pychrysa/pychrysa.c @@ -74,7 +74,7 @@ static bool is_current_abi_suitable(void); static bool set_version_for_gtk_namespace(const char *); /* Charge autant de greffons composés en Python que possible. */ -static bool load_python_plugins(GPluginModule *plugin, GObject *); +static bool load_python_plugins(GPluginModule *); @@ -402,7 +402,6 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) /****************************************************************************** * * * Paramètres : plugin = instance représentant le greffon Python d'origine. * -* ref = espace de référencement global. * * * * Description : Charge autant de greffons composés en Python que possible. * * * @@ -412,7 +411,7 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) * * ******************************************************************************/ -static bool load_python_plugins(GPluginModule *plugin, GObject *ref) +static bool load_python_plugins(GPluginModule *plugin) { char *paths; /* Emplacements de greffons */ char *save; /* Sauvegarde pour ré-entrance */ @@ -468,7 +467,7 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref) filename = stradd(filename, G_DIR_SEPARATOR_S); filename = stradd(filename, entry->d_name); - pyplugin = g_python_plugin_new(modname, filename, ref); + pyplugin = g_python_plugin_new(modname, filename); if (pyplugin == NULL) g_plugin_module_log_variadic_message(plugin, LMT_ERROR, @@ -499,7 +498,6 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref) /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * -* ref = espace de référencement global. * * * * Description : Prend acte du chargement du greffon. * * * @@ -509,7 +507,7 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref) * * ******************************************************************************/ -G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) { bool result; /* Bilan à retourner */ DIR *dir; /* Répertoire à parcourir */ @@ -548,7 +546,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) PySys_SetArgv(0, (wchar_t *[]) { NULL }); - result = load_python_plugins(plugin, ref); + result = load_python_plugins(plugin); cpi_done: diff --git a/plugins/pychrysa/pychrysa.h b/plugins/pychrysa/pychrysa.h index 594d362..51d0470 100644 --- a/plugins/pychrysa/pychrysa.h +++ b/plugins/pychrysa/pychrysa.h @@ -89,7 +89,7 @@ PyMODINIT_FUNC initpychrysa(void); PyMODINIT_FUNC PyInit_pychrysalide(void); /* Prend acte du chargement du greffon. */ -G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *, GObject *); +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); diff --git a/plugins/ropgadgets/plugin.c b/plugins/ropgadgets/plugin.c index c81d00a..8b35647 100644 --- a/plugins/ropgadgets/plugin.c +++ b/plugins/ropgadgets/plugin.c @@ -27,6 +27,7 @@ #include +#include #include #include @@ -41,7 +42,7 @@ DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("ROP gadgets", "Find available gadgets for a ROP /* Réagit avec le menu "Greffons -> Lister les gadgets ROP". */ -static void mcb_plugins_list_rop_gadgets(GtkMenuItem *, GObject *); +static void mcb_plugins_list_rop_gadgets(GtkMenuItem *, gpointer); @@ -58,16 +59,19 @@ static void mcb_plugins_list_rop_gadgets(GtkMenuItem *, GObject *); * * ******************************************************************************/ -G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) { + GObject *ref; /* Espace de référencements */ GtkContainer *menubar; /* Support pour éléments */ GtkWidget *submenuitem; /* Sous-élément de menu */ + ref = G_OBJECT(get_editor_window()); /* FIXME */ + menubar = GTK_CONTAINER(g_object_get_data(ref, "menubar_plugins")); if (menubar == NULL) return false; submenuitem = qck_create_menu_item(ref, "mnu_plugins_ropgadgets", _("List ROP gadgets"), - G_CALLBACK(mcb_plugins_list_rop_gadgets), ref); + G_CALLBACK(mcb_plugins_list_rop_gadgets), NULL); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); return true; @@ -78,7 +82,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) /****************************************************************************** * * * Paramètres : menuitem = élément de menu sélectionné. * -* ref = adresse de l'espace de référencement global. * +* unused = adresse non utilisée ici. * * * * Description : Réagit avec le menu "Greffons -> Lister les gadgets ROP". * * * @@ -88,8 +92,8 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref) * * ******************************************************************************/ -static void mcb_plugins_list_rop_gadgets(GtkMenuItem *menuitem, GObject *ref) +static void mcb_plugins_list_rop_gadgets(GtkMenuItem *menuitem, gpointer unused) { - run_rop_finder_assistant(ref, NULL); + run_rop_finder_assistant(get_editor_window()); } diff --git a/plugins/ropgadgets/plugin.h b/plugins/ropgadgets/plugin.h index 9f7a0a1..c76c6c7 100644 --- a/plugins/ropgadgets/plugin.h +++ b/plugins/ropgadgets/plugin.h @@ -30,7 +30,7 @@ /* Prend acte du chargement du greffon. */ -G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *, GObject *ref); +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c index aa6603f..92456e7 100644 --- a/plugins/ropgadgets/select.c +++ b/plugins/ropgadgets/select.c @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -222,8 +223,7 @@ static void add_new_gadgets_for_category(GExeFormat *, GtkComboBoxText *, GtkTre /****************************************************************************** * * -* Paramètres : global = espace de référencements global. * -* parent = fenêtre principale de l'éditeur. * +* Paramètres : parent = fenêtre principale de l'éditeur. * * * * Description : Crée et affiche un assistant de sélection de gadgets ROP. * * * @@ -233,7 +233,7 @@ static void add_new_gadgets_for_category(GExeFormat *, GtkComboBoxText *, GtkTre * * ******************************************************************************/ -void run_rop_finder_assistant(GObject *global, GtkWindow *parent) +void run_rop_finder_assistant(GtkWindow *parent) { GtkWidget *assistant; /* Fenêtre à afficher */ GObject *ref; /* Espace de référencement */ @@ -247,7 +247,6 @@ void run_rop_finder_assistant(GObject *global, GtkWindow *parent) gtk_window_set_transient_for(GTK_WINDOW(assistant), parent); ref = G_OBJECT(assistant); - g_object_set_data(ref, "global", global); register_input_output_panel(GTK_ASSISTANT(assistant), ref); register_search_display_panel(GTK_ASSISTANT(assistant), ref); @@ -503,7 +502,6 @@ static void register_input_output_panel(GtkAssistant *assistant, GObject *ref) static GtkWidget *load_and_populate_current_project_binaries(GObject *ref) { GtkWidget *result; /* Composant à retourner */ - GObject *global; /* Espace de référencements */ GLoadedBinary *current; /* Binaire actif courant */ gint selected; /* Indice à sélectionner */ GtkListStore *store; /* Modèle de gestion en liste */ @@ -515,9 +513,7 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref) /* Récupération du binaire courant */ - global = G_OBJECT(g_object_get_data(ref, "global")); - - current = G_LOADED_BINARY(g_object_get_data(global, "current_binary")); + current = get_current_binary(); /* Constitution d'une liste de binaires courants */ @@ -567,6 +563,8 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref) g_object_unref(G_OBJECT(store)); + g_object_unref(G_OBJECT(current)); + return result; } diff --git a/plugins/ropgadgets/select.h b/plugins/ropgadgets/select.h index a868cd8..913b6cc 100644 --- a/plugins/ropgadgets/select.h +++ b/plugins/ropgadgets/select.h @@ -28,12 +28,9 @@ #include -#include - - /* Crée et affiche un assistant de sélection de gadgets ROP. */ -void run_rop_finder_assistant(GObject *, GtkWindow *); +void run_rop_finder_assistant(GtkWindow *); diff --git a/src/main.c b/src/main.c index 43fa5d3..3bcedf4 100644 --- a/src/main.c +++ b/src/main.c @@ -249,7 +249,7 @@ int main(int argc, char **argv) if (!batch_mode) gtk_widget_show_now(editor); - init_all_plugins(G_OBJECT(editor)); + init_all_plugins(); config = get_main_configuration(); diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index 2edc392..112a560 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -51,8 +51,6 @@ typedef struct _pg_array /* Propriétés de l'ensemble des greffons */ typedef struct _plugins_list { - GObject *ref; /* Référencement global */ - pg_array *all; /* Liste de tous les greffons */ pg_array sorted[PGA_COUNT]; /* Tri par catégories */ @@ -73,7 +71,7 @@ void browse_directory_for_plugins(plugins_list *, const char *); /****************************************************************************** * * -* Paramètres : ref = espace de référencement global. * +* Paramètres : - * * * * Description : Procède au chargement des différents greffons trouvés. * * * @@ -83,13 +81,10 @@ void browse_directory_for_plugins(plugins_list *, const char *); * * ******************************************************************************/ -bool init_all_plugins(GObject *ref) +bool init_all_plugins(void) { size_t i; /* Boucle de parcours */ - _list.ref = ref; - g_object_ref(ref); - for (i = 0; i < PGA_COUNT; i++) _list.sorted[i].action = PGA_EMPTY; @@ -125,8 +120,6 @@ void exit_all_plugins(void) for (i = 0; i < PGA_COUNT; i++) free(_list.sorted[i].plugins); - g_object_unref(_list.ref); - } @@ -197,7 +190,7 @@ void browse_directory_for_plugins(plugins_list *list, const char *dir) else { - plugin = g_plugin_module_new(filename, _list.ref); + plugin = g_plugin_module_new(filename); if (plugin != NULL) add_plugin_to_main_list(plugin); diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index e085102..5dfd6c3 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -36,7 +36,7 @@ /* Procède au chargement des différents greffons trouvés. */ -bool init_all_plugins(GObject *); +bool init_all_plugins(void); /* Procède au déchargement des différents greffons présents. */ void exit_all_plugins(void); diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 7ccd2a6..ac6ade6 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -37,7 +37,7 @@ /* Prend acte du [dé]chargement du greffon. */ -typedef bool (* pg_management_fc) (GPluginModule *, GObject *); +typedef bool (* pg_management_fc) (GPluginModule *); /* Exécute une action pendant un désassemblage de binaire. */ typedef void (* pg_process_disassembly_fc) (const GPluginModule *, PluginAction, GLoadedBinary *); @@ -127,7 +127,7 @@ struct _GPluginModuleClass /* Termine le chargement du greffon préparé. */ -bool g_plugin_module_load(GPluginModule *, GObject *); +bool g_plugin_module_load(GPluginModule *); /* Présente dans le journal un message simple. */ void g_plugin_module_log_simple_message(const GPluginModule *, LogMessageType, const char *); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 0c287d6..03c3b21 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -116,7 +116,7 @@ static void g_plugin_module_init(GPluginModule *plugin) static void g_plugin_module_dispose(GPluginModule *plugin) { if (plugin->exit != NULL) - plugin->exit(plugin, NULL /* FIXME */); + plugin->exit(plugin); if (plugin->module != NULL) g_module_close(plugin->module); @@ -150,7 +150,6 @@ static void g_plugin_module_finalize(GPluginModule *plugin) /****************************************************************************** * * * Paramètres : filename = nom du fichier à charger. * -* ref = espace de référencement global. * * * * Description : Crée un module pour un greffon donné. * * * @@ -160,7 +159,7 @@ static void g_plugin_module_finalize(GPluginModule *plugin) * * ******************************************************************************/ -GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) +GPluginModule *g_plugin_module_new(const gchar *filename) { GPluginModule *result; /* Structure à retourner */ plugin_abi_version_t current; /* Version de l'ABI actuelle */ @@ -321,7 +320,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) /* Conclusion */ - if (!g_plugin_module_load(result, ref)) + if (!g_plugin_module_load(result)) goto bad_plugin; return result; @@ -338,7 +337,6 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) /****************************************************************************** * * * Paramètres : plugin = greffon à valider. * -* ref = espace de référencement global. * * * * Description : Termine le chargement du greffon préparé. * * * @@ -348,7 +346,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) * * ******************************************************************************/ -bool g_plugin_module_load(GPluginModule *plugin, GObject *ref) +bool g_plugin_module_load(GPluginModule *plugin) { bool result; /* Bilan à faire remonter */ char *dir; /* Répertoire modifiable */ @@ -360,7 +358,7 @@ bool g_plugin_module_load(GPluginModule *plugin, GObject *ref) if (plugin->init != NULL) { - if (!plugin->init(plugin, ref)) + if (!plugin->init(plugin)) { log_variadic_message(LMT_ERROR, _("Plugin '%s' failed to load itself..."), plugin->filename); diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index bc52c93..bc6189f 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -56,7 +56,7 @@ typedef struct _GPluginModuleClass GPluginModuleClass; GType g_plugin_module_get_type(void); /* Crée un module pour un greffon donné. */ -GPluginModule *g_plugin_module_new(const gchar *, GObject *); +GPluginModule *g_plugin_module_new(const gchar *); /* Fournit la description du greffon dans son intégralité. */ const plugin_interface *g_plugin_module_get_interface(const GPluginModule *); -- cgit v0.11.2-87-g4458