From 286ba13e0a5e908f9ebe67286bb6006adb4102fc Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 4 Apr 2020 23:57:54 +0200 Subject: Simplified the plugin interface. --- plugins/androhelpers/Makefile.am | 3 +- plugins/arm/Makefile.am | 4 +- plugins/arm/core.c | 5 +- plugins/bootimg/Makefile.am | 4 +- plugins/bootimg/core.c | 5 +- plugins/dalvik/core.c | 5 +- plugins/devdbg/Makefile.am | 3 +- plugins/devdbg/speed.c | 24 ++++---- plugins/devdbg/speed.h | 4 +- plugins/dex/Makefile.am | 4 +- plugins/dex/core.c | 9 +-- plugins/dexbnf/core.c | 5 +- plugins/dwarf/checks.c | 5 +- plugins/dwarf/core.c | 65 +------------------- plugins/dwarf/core.h | 6 -- plugins/elf/core.c | 5 +- plugins/fmtp/Makefile.am | 3 +- plugins/gdbrsp/Makefile.am | 5 +- plugins/itanium/Makefile.am | 4 +- plugins/itanium/core.c | 5 +- plugins/javadesc/Makefile.am | 4 +- plugins/javadesc/core.c | 5 +- plugins/libcsem/Makefile.am | 3 +- plugins/libcsem/semantic.c | 7 ++- plugins/libcsem/semantic.h | 2 +- plugins/lnxsyscalls/core.c | 17 +++--- plugins/lnxsyscalls/core.h | 2 +- plugins/lnxsyscalls/db.c | 51 +++++++--------- plugins/lnxsyscalls/db.h | 6 +- plugins/lnxsyscalls/hunter.c | 13 ++-- plugins/lnxsyscalls/hunter.h | 4 +- plugins/mobicore/Makefile.am | 3 +- plugins/mobicore/core.c | 7 ++- plugins/pychrysalide/Makefile.am | 5 +- plugins/pychrysalide/core/logs.c | 3 +- plugins/pychrysalide/plugin.c | 6 +- plugins/pychrysalide/pychrysa.c | 43 +++---------- plugins/pychrysalide/pychrysa.h | 3 - plugins/readdex/reader.c | 7 ++- plugins/readdex/reader.h | 2 +- plugins/readelf/reader.c | 7 ++- plugins/readelf/reader.h | 2 +- plugins/readmc/reader.c | 7 ++- plugins/readmc/reader.h | 2 +- plugins/ropgadgets/plugin.c | 5 +- plugins/stackvars/Makefile.am | 3 +- plugins/yaml/Makefile.am | 4 +- plugins/yaml/core.c | 5 +- src/plugins/Makefile.am | 3 +- src/plugins/plugin-def.h | 61 +------------------ src/plugins/plugin-int.h | 12 +--- src/plugins/plugin.c | 23 +++++-- src/plugins/plugin.h | 7 +++ src/plugins/self.h | 128 +++++++++++++++++++++++++++++++++++++++ 54 files changed, 320 insertions(+), 315 deletions(-) create mode 100644 src/plugins/self.h diff --git a/plugins/androhelpers/Makefile.am b/plugins/androhelpers/Makefile.am index c0c423f..4df2b45 100644 --- a/plugins/androhelpers/Makefile.am +++ b/plugins/androhelpers/Makefile.am @@ -10,7 +10,8 @@ libandrohelpers_la_SOURCES = \ try_n_catch.h try_n_catch.c \ switch.h switch.c -libandrohelpers_la_LDFLAGS = -L$(top_srcdir)/src/.libs -lchrysacore +libandrohelpers_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide-$(subdir) diff --git a/plugins/arm/Makefile.am b/plugins/arm/Makefile.am index eb217d7..8a15e46 100644 --- a/plugins/arm/Makefile.am +++ b/plugins/arm/Makefile.am @@ -42,8 +42,8 @@ libarm_la_LIBADD = \ $(PYTHON3_LIBADD) \ v7/libarmv7.la -libarm_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ +libarm_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore \ $(PYTHON3_LDFLAGS) diff --git a/plugins/arm/core.c b/plugins/arm/core.c index f009078..c270c85 100644 --- a/plugins/arm/core.c +++ b/plugins/arm/core.c @@ -25,7 +25,7 @@ #include -#include +#include #ifdef HAVE_PYTHON3_BINDINGS @@ -42,7 +42,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GArmPlugin", "arm", "Add support for the ARM architecture", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Arm", "ARM architecture support", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/architectures"), PG_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT)); diff --git a/plugins/bootimg/Makefile.am b/plugins/bootimg/Makefile.am index 8329665..e37a6ab 100644 --- a/plugins/bootimg/Makefile.am +++ b/plugins/bootimg/Makefile.am @@ -34,8 +34,8 @@ libbootimg_la_SOURCES = \ libbootimg_la_LIBADD = \ $(PYTHON3_LIBADD) -libbootimg_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ +libbootimg_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore \ $(PYTHON3_LDFLAGS) diff --git a/plugins/bootimg/core.c b/plugins/bootimg/core.c index fdf1c95..9c4bc45 100644 --- a/plugins/bootimg/core.c +++ b/plugins/bootimg/core.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "format.h" @@ -43,7 +43,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GBootImgPlugin", "bootimg", "Add support for the BOOT.img format", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("BootImg", "Support for the BOOT.img format", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/formats"), PG_REQ, AL(PGA_PLUGIN_INIT, PGA_CONTENT_EXPLORER)); diff --git a/plugins/dalvik/core.c b/plugins/dalvik/core.c index 09fefd5..2294ed4 100644 --- a/plugins/dalvik/core.c +++ b/plugins/dalvik/core.c @@ -25,7 +25,7 @@ #include -#include +#include #include "register.h" @@ -46,7 +46,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GDalvikPlugin", "dalvik", "Add support for the Dalvik architecture", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Dalvik", "Dalvik architecture support", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/architectures"), PG_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT)); diff --git a/plugins/devdbg/Makefile.am b/plugins/devdbg/Makefile.am index 90553c8..2877411 100644 --- a/plugins/devdbg/Makefile.am +++ b/plugins/devdbg/Makefile.am @@ -7,7 +7,8 @@ libdir = $(pluginslibdir) libspeed_la_SOURCES = \ speed.h speed.c -libspeed_la_LDFLAGS = -L$(top_srcdir)/src/.libs -lchrysacore +libspeed_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide-$(subdir) diff --git a/plugins/devdbg/speed.c b/plugins/devdbg/speed.c index 6b9cc6b..1378c66 100644 --- a/plugins/devdbg/speed.c +++ b/plugins/devdbg/speed.c @@ -34,11 +34,12 @@ #include -#include +#include -DEFINE_CHRYSALIDE_PLUGIN("GSpeedPlugin", "Speed Measure", "Tracks to time spent for disassembling code", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("SpeedMeasure", "Tracker of time spent for disassembling code", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), NO_REQ, AL(PGA_FORMAT_ANALYSIS_STARTED,PGA_FORMAT_ANALYSIS_ENDED, PGA_FORMAT_POST_ANALYSIS_STARTED, PGA_FORMAT_POST_ANALYSIS_ENDED, PGA_DISASSEMBLY_STARTED, PGA_DISASSEMBLY_ENDED)); @@ -53,14 +54,13 @@ typedef struct _speed_measure /* Affiche une mesure de temps écoulé. */ -static void show_elapsed_time(const GPluginModule *, const char *, const speed_measure *); +static void show_elapsed_time(const char *, const speed_measure *); /****************************************************************************** * * -* Paramètres : plugin = greffon à manipuler. * -* title = désignation humaine de la mesure menée. * +* Paramètres : title = désignation humaine de la mesure menée. * * measure = mesure de temps écoulé. * * * * Description : Affiche une mesure de temps écoulé. * @@ -71,7 +71,7 @@ static void show_elapsed_time(const GPluginModule *, const char *, const speed_m * * ******************************************************************************/ -static void show_elapsed_time(const GPluginModule *plugin, const char *title, const speed_measure *measure) +static void show_elapsed_time(const char *title, const speed_measure *measure) { char *tmp; /* Construction temporaire */ double seconds; /* Secondes écoulées */ @@ -132,7 +132,7 @@ static void show_elapsed_time(const GPluginModule *plugin, const char *title, co } if (tmp != NULL) - g_plugin_module_log_simple_message(plugin, LMT_INFO, msg); + log_plugin_simple_message(LMT_INFO, msg); free(msg); @@ -155,7 +155,7 @@ static void show_elapsed_time(const GPluginModule *plugin, const char *title, co * * ******************************************************************************/ -G_MODULE_EXPORT bool handle_binary_format_analysis(const GPluginModule *plugin, PluginAction action, GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) +G_MODULE_EXPORT bool chrysalide_plugin_handle_binary_format_analysis(const GPluginModule *plugin, PluginAction action, GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) { speed_measure *measure; /* Suivi des progressions */ struct timeval point; /* Point de mesure courant */ @@ -182,9 +182,9 @@ G_MODULE_EXPORT bool handle_binary_format_analysis(const GPluginModule *plugin, measure->usages[1] = point.tv_sec * 1000000 + point.tv_usec; if (action == PGA_FORMAT_ANALYSIS_ENDED) - show_elapsed_time(plugin, _("Whole elapsed time for format analysis:"), measure); + show_elapsed_time(_("Whole elapsed time for format analysis:"), measure); else - show_elapsed_time(plugin, _("Whole elapsed time for format post-analysis:"), measure); + show_elapsed_time(_("Whole elapsed time for format post-analysis:"), measure); g_object_set_data(G_OBJECT(format), "speed_measure", NULL); free(measure); @@ -218,7 +218,7 @@ G_MODULE_EXPORT bool handle_binary_format_analysis(const GPluginModule *plugin, * * ******************************************************************************/ -G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary, GtkStatusStack *status, GProcContext *context) +G_MODULE_EXPORT void chrysalide_plugin_process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary, GtkStatusStack *status, GProcContext *context) { speed_measure *measure; /* Suivi des progressions */ struct timeval point; /* Point de mesure courant */ @@ -242,7 +242,7 @@ G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, Plu gettimeofday(&point, NULL); measure->usages[1] = point.tv_sec * 1000000 + point.tv_usec; - show_elapsed_time(plugin, _("Whole elapsed time for disassembly:"), measure); + show_elapsed_time(_("Whole elapsed time for disassembly:"), measure); g_object_set_data(G_OBJECT(binary), "speed_measure", NULL); free(measure); diff --git a/plugins/devdbg/speed.h b/plugins/devdbg/speed.h index dff6a93..7d591fb 100644 --- a/plugins/devdbg/speed.h +++ b/plugins/devdbg/speed.h @@ -31,10 +31,10 @@ /* Procède à une opération liée à l'analyse d'un format. */ -G_MODULE_EXPORT bool handle_binary_format_analysis(const GPluginModule *, PluginAction, GBinFormat *, wgroup_id_t, GtkStatusStack *); +G_MODULE_EXPORT bool chrysalide_plugin_handle_binary_format_analysis(const GPluginModule *, PluginAction, GBinFormat *, wgroup_id_t, GtkStatusStack *); /* Exécute une action pendant un désassemblage de binaire. */ -G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *, PluginAction , GLoadedBinary *, GtkStatusStack *, GProcContext *); +G_MODULE_EXPORT void chrysalide_plugin_process_binary_disassembly(const GPluginModule *, PluginAction , GLoadedBinary *, GtkStatusStack *, GProcContext *); diff --git a/plugins/dex/Makefile.am b/plugins/dex/Makefile.am index 8a092d5..49a2687 100644 --- a/plugins/dex/Makefile.am +++ b/plugins/dex/Makefile.am @@ -40,8 +40,8 @@ libdex_la_SOURCES = \ libdex_la_LIBADD = \ $(PYTHON3_LIBADD) -libdex_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ +libdex_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore \ $(PYTHON3_LDFLAGS) diff --git a/plugins/dex/core.c b/plugins/dex/core.c index f13d521..22ebfff 100644 --- a/plugins/dex/core.c +++ b/plugins/dex/core.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "format.h" @@ -36,14 +36,15 @@ #ifdef HAVE_PYTHON3_BINDINGS -# define PG_REQ RL("PyChrysalide", "dexbnf") +# define PG_REQ RL("PyChrysalide") #else -# define PG_REQ RL("dexbnf") +# define PG_REQ NO_REQ #endif -DEFINE_CHRYSALIDE_PLUGIN("GDexPlugin", "dex", "Add support for the DEX format", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Dex", "DEX format support", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/formats"), PG_REQ, AL(PGA_PLUGIN_INIT, PGA_CONTENT_RESOLVER)); diff --git a/plugins/dexbnf/core.c b/plugins/dexbnf/core.c index 4cdf26b..2b9408a 100644 --- a/plugins/dexbnf/core.c +++ b/plugins/dexbnf/core.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "demangler.h" @@ -43,7 +43,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GDexBnfPlugin", "dexbnf", "Symbol demangler for Dex", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("DexBnf", "Dex symbol demangling", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/mangling"), PG_REQ, AL(PGA_PLUGIN_INIT)); diff --git a/plugins/dwarf/checks.c b/plugins/dwarf/checks.c index 7dc8a7c..ee16b9a 100644 --- a/plugins/dwarf/checks.c +++ b/plugins/dwarf/checks.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "core.h" @@ -142,7 +143,7 @@ bool check_dwarf_abbrev_decl(GDwarfFormat *format, const dw_abbrev_decl *decl, u { vmpa2_phys_to_string(pos, MDS_UNDEFINED, loc, NULL); - log_dwarf_variadic_message(LMT_BAD_BINARY, _("Invalid abbreviation declaration at %s"), loc); + log_plugin_variadic_message(LMT_BAD_BINARY, _("Invalid abbreviation declaration at %s"), loc); } @@ -215,7 +216,7 @@ bool check_dwarf_abbrev_attrib(GDwarfFormat *format, const dw_abbrev_raw_attr *a { vmpa2_phys_to_string(pos, MDS_UNDEFINED, loc, NULL); - log_dwarf_variadic_message(LMT_BAD_BINARY, _("Invalid abbreviation attribute at %s"), loc); + log_plugin_variadic_message(LMT_BAD_BINARY, _("Invalid abbreviation attribute at %s"), loc); } diff --git a/plugins/dwarf/core.c b/plugins/dwarf/core.c index 2d95626..bf1e812 100644 --- a/plugins/dwarf/core.c +++ b/plugins/dwarf/core.c @@ -25,7 +25,7 @@ #include -#include +#include #include "format.h" @@ -39,16 +39,12 @@ -DEFINE_CHRYSALIDE_PLUGIN("GDwarfPlugin", "dwarf", "Add support for the DWARF format", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Dwarf", "DWARF format support", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/formats"), PG_REQ, AL(PGA_PLUGIN_INIT, PGA_FORMAT_ATTACH_DEBUG)); -/* Conservation d'une référence au greffon pour les messages */ -static GPluginModule *_this = NULL; - - - /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * @@ -65,8 +61,6 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) { bool result; /* Bilan à retourner */ - _this = plugin; - result = true; return result; @@ -98,56 +92,3 @@ G_MODULE_EXPORT void chrysalide_plugin_attach_debug(const GPluginModule *plugin, g_exe_format_add_debug_info(format, info); } - - -/****************************************************************************** -* * -* Paramètres : msg = message à faire apparaître à l'écran. * -* * -* Description : Présente dans le journal un message simple. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void log_dwarf_simple_message(LogMessageType type, const char *msg) -{ - g_plugin_module_log_simple_message(_this, type, msg); - -} - - -/****************************************************************************** -* * -* Paramètres : type = espèce du message à ajouter. * -* fmt = format du message à faire apparaître à l'écran. * -* ... = éventuels arguments venant compléter le message. * -* * -* Description : Présente dans le journal un message complexe. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void log_dwarf_variadic_message(LogMessageType type, const char *fmt, ...) -{ - va_list ap; /* Liste d'arguments variable */ - char *buffer; /* Tampon du msg reconstitué */ - - va_start(ap, fmt); - buffer = build_variadic_message(fmt, ap); - va_end(ap); - - if (buffer != NULL) - { - g_plugin_module_log_simple_message(_this, type, buffer); - - free(buffer); - - } - -} diff --git a/plugins/dwarf/core.h b/plugins/dwarf/core.h index 7e2c367..8f4fe9c 100644 --- a/plugins/dwarf/core.h +++ b/plugins/dwarf/core.h @@ -36,12 +36,6 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); /* Procède au rattachement d'éventuelles infos de débogage. */ G_MODULE_EXPORT void chrysalide_plugin_attach_debug(const GPluginModule *, PluginAction, GExeFormat *); -/* Présente dans le journal un message simple. */ -void log_dwarf_simple_message(LogMessageType, const char *); - -/* Présente dans le journal un message complexe. */ -void log_dwarf_variadic_message(LogMessageType, const char *, ...); - #endif /* _PLUGINS_DWARF_CORE_H */ diff --git a/plugins/elf/core.c b/plugins/elf/core.c index 777c554..1e98aba 100644 --- a/plugins/elf/core.c +++ b/plugins/elf/core.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "format.h" @@ -43,7 +43,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GElfPlugin", "elf", "Add support for the ELF format", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Elf", "ELF format support", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/formats"), PG_REQ, AL(PGA_PLUGIN_INIT, PGA_CONTENT_RESOLVER)); diff --git a/plugins/fmtp/Makefile.am b/plugins/fmtp/Makefile.am index de7fdbe..ea9e1dc 100644 --- a/plugins/fmtp/Makefile.am +++ b/plugins/fmtp/Makefile.am @@ -8,7 +8,8 @@ libfmtp_la_SOURCES = \ def.h \ parser.h parser.c -libfmtp_la_LDFLAGS = -L$(top_srcdir)/src/.libs -lchrysacore +libfmtp_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide-$(subdir) diff --git a/plugins/gdbrsp/Makefile.am b/plugins/gdbrsp/Makefile.am index 5ee8df6..0a3ea13 100644 --- a/plugins/gdbrsp/Makefile.am +++ b/plugins/gdbrsp/Makefile.am @@ -16,7 +16,10 @@ libdebuggdbrsp_la_SOURCES = \ tcp.h tcp.c \ utils.h utils.c -libdebuggdbrsp_la_CFLAGS = $(AM_CFLAGS) +libdebuggdbrsp_la_LIBADD = + +libdebuggdbrsp_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide/$(subdir:src/%=%) diff --git a/plugins/itanium/Makefile.am b/plugins/itanium/Makefile.am index 3d87d41..b34e379 100644 --- a/plugins/itanium/Makefile.am +++ b/plugins/itanium/Makefile.am @@ -36,8 +36,8 @@ libitanium_la_SOURCES = \ libitanium_la_LIBADD = \ $(PYTHON3_LIBADD) -libitanium_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ +libitanium_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore \ $(PYTHON3_LDFLAGS) diff --git a/plugins/itanium/core.c b/plugins/itanium/core.c index 1f00cba..6bf67c1 100644 --- a/plugins/itanium/core.c +++ b/plugins/itanium/core.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "demangler.h" @@ -43,7 +43,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GItaniumPlugin", "itanium", "Symbol demangler for Itanium", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Itanium", "Itanium demangling", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/mangling"), PG_REQ, AL(PGA_PLUGIN_INIT)); diff --git a/plugins/javadesc/Makefile.am b/plugins/javadesc/Makefile.am index c2ad3e7..5b7d285 100644 --- a/plugins/javadesc/Makefile.am +++ b/plugins/javadesc/Makefile.am @@ -35,8 +35,8 @@ libjavadesc_la_SOURCES = \ libjavadesc_la_LIBADD = \ $(PYTHON3_LIBADD) -libjavadesc_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ +libjavadesc_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore \ $(PYTHON3_LDFLAGS) diff --git a/plugins/javadesc/core.c b/plugins/javadesc/core.c index 4c0d620..bda0f56 100644 --- a/plugins/javadesc/core.c +++ b/plugins/javadesc/core.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "demangler.h" @@ -43,7 +43,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GJavaDescPlugin", "javadesc", "Symbol demangler for Java", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("JavaDesc", "Java symbol demangling", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/mangling"), PG_REQ, AL(PGA_PLUGIN_INIT)); diff --git a/plugins/libcsem/Makefile.am b/plugins/libcsem/Makefile.am index 077a5b5..00ad075 100644 --- a/plugins/libcsem/Makefile.am +++ b/plugins/libcsem/Makefile.am @@ -8,7 +8,8 @@ liblibcsem_la_SOURCES = \ exit.h exit.c \ semantic.h semantic.c -liblibcsem_la_LDFLAGS = -L$(top_srcdir)/src/.libs -lchrysacore +liblibcsem_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide-$(subdir) diff --git a/plugins/libcsem/semantic.c b/plugins/libcsem/semantic.c index b5e2a1a..00e174f 100644 --- a/plugins/libcsem/semantic.c +++ b/plugins/libcsem/semantic.c @@ -25,14 +25,15 @@ #include -#include +#include #include "exit.h" -DEFINE_CHRYSALIDE_PLUGIN("GCSemPlugin", "LibC semantics", "Register semantic information relative to the libc", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("CSem", "Semantic information relative to the libc", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), NO_REQ, AL(PGA_DISASSEMBLY_HOOKED_POST)); @@ -53,7 +54,7 @@ DEFINE_CHRYSALIDE_PLUGIN("GCSemPlugin", "LibC semantics", "Register semantic inf * * ******************************************************************************/ -G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary, GtkStatusStack *status, GProcContext *context) +G_MODULE_EXPORT void chrysalide_plugin_process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary, GtkStatusStack *status, GProcContext *context) { if (action == PGA_DISASSEMBLY_HOOKED_POST) { diff --git a/plugins/libcsem/semantic.h b/plugins/libcsem/semantic.h index fddbc58..58c14ef 100644 --- a/plugins/libcsem/semantic.h +++ b/plugins/libcsem/semantic.h @@ -31,7 +31,7 @@ /* Exécute une action pendant un désassemblage de binaire. */ -G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *, PluginAction, GLoadedBinary *, GtkStatusStack *, GProcContext *); +G_MODULE_EXPORT void chrysalide_plugin_process_binary_disassembly(const GPluginModule *, PluginAction, GLoadedBinary *, GtkStatusStack *, GProcContext *); diff --git a/plugins/lnxsyscalls/core.c b/plugins/lnxsyscalls/core.c index fffb72f..02e109d 100644 --- a/plugins/lnxsyscalls/core.c +++ b/plugins/lnxsyscalls/core.c @@ -29,6 +29,7 @@ #include #include +#include #include "db.h" @@ -37,8 +38,9 @@ -DEFINE_CHRYSALIDE_PLUGIN("GLnxSyscallsPlugin", "Linux System Calls", "Describes each Linux system call with its arguments", \ - "0.1.0", EMPTY_PG_LIST(.required), AL(PGA_PLUGIN_INIT, PGA_DISASSEMBLY_ENDED)); +DEFINE_CHRYSALIDE_PLUGIN("LinuxSyscalls", "Describes each Linux system call with its arguments", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), + NO_REQ, AL(PGA_PLUGIN_INIT, PGA_DISASSEMBLY_ENDED)); @@ -59,11 +61,11 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) bool result; /* Bilan à retourner */ sqlite3 *db; /* Base de données présente */ - db = open_syscalls_database(plugin); + db = open_syscalls_database(); if (db != NULL) { - introduce_syscalls_database(db, plugin); + introduce_syscalls_database(db); close_syscalls_database(db); @@ -94,7 +96,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) * * ******************************************************************************/ -G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary, GtkStatusStack *status, GProcContext *context) +G_MODULE_EXPORT void chrysalide_plugin_process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary, GtkStatusStack *status, GProcContext *context) { GBinFormat *format; /* Format du binaire chargé */ const char *arch; /* Architecture d'exécution */ @@ -121,8 +123,7 @@ G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, Plu else { - g_plugin_module_log_variadic_message(plugin, LMT_WARNING, - _("No suitable backend to track syscalls!")); + log_plugin_simple_message(LMT_WARNING, _("No suitable backend to track syscalls!")); goto pbd_exit; } @@ -147,7 +148,7 @@ G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, Plu else end = begin + run_size; - hunter = g_gate_hunter_new(plugin, binary, context, begin, end, id, hops); + hunter = g_gate_hunter_new(binary, context, begin, end, id, hops); g_work_queue_schedule_work(queue, G_DELAYED_WORK(hunter), gid); diff --git a/plugins/lnxsyscalls/core.h b/plugins/lnxsyscalls/core.h index a8e987e..dcf5c11 100644 --- a/plugins/lnxsyscalls/core.h +++ b/plugins/lnxsyscalls/core.h @@ -34,7 +34,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); /* Exécute une action pendant un désassemblage de binaire. */ -G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *, PluginAction , GLoadedBinary *, GtkStatusStack *, GProcContext *); +G_MODULE_EXPORT void chrysalide_plugin_process_binary_disassembly(const GPluginModule *, PluginAction , GLoadedBinary *, GtkStatusStack *, GProcContext *); diff --git a/plugins/lnxsyscalls/db.c b/plugins/lnxsyscalls/db.c index 1c28981..33dd727 100644 --- a/plugins/lnxsyscalls/db.c +++ b/plugins/lnxsyscalls/db.c @@ -32,13 +32,13 @@ #include -#include +#include /****************************************************************************** * * -* Paramètres : plugin = greffon à manipuler. * +* Paramètres : - * * * * Description : Ouvre la base de connaissances quant aux appels système. * * * @@ -48,7 +48,7 @@ * * ******************************************************************************/ -sqlite3 *open_syscalls_database(const GPluginModule *plugin) +sqlite3 *open_syscalls_database(void) { sqlite3 *result; /* Base de données à renvoyer */ char *filename; /* Chemin vers la base */ @@ -58,7 +58,7 @@ sqlite3 *open_syscalls_database(const GPluginModule *plugin) if (filename == NULL) { - g_plugin_module_log_simple_message(plugin, LMT_ERROR, _("Unable to find the syscalls database")); + log_plugin_simple_message(LMT_ERROR, _("Unable to find the syscalls database")); result = NULL; } @@ -68,7 +68,7 @@ sqlite3 *open_syscalls_database(const GPluginModule *plugin) if (ret != SQLITE_OK) { - g_plugin_module_log_simple_message(plugin, LMT_ERROR, _("Unable to load the syscalls database")); + log_plugin_simple_message(LMT_ERROR, _("Unable to load the syscalls database")); result = NULL; } @@ -115,8 +115,7 @@ void close_syscalls_database(sqlite3 *db) /****************************************************************************** * * -* Paramètres : db = base de données SQLite à consulter. * -* plugin = greffon à manipuler. * +* Paramètres : db = base de données SQLite à consulter. * * * * Description : Présente le contenu de la base des appels système. * * * @@ -126,7 +125,7 @@ void close_syscalls_database(sqlite3 *db) * * ******************************************************************************/ -void introduce_syscalls_database(sqlite3 *db, const GPluginModule *plugin) +void introduce_syscalls_database(sqlite3 *db) { const char *sql; /* Requête SQL à construire */ sqlite3_stmt *stmt; /* Déclaration mise en place */ @@ -137,18 +136,16 @@ void introduce_syscalls_database(sqlite3 *db, const GPluginModule *plugin) ret = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { - g_plugin_module_log_variadic_message(plugin, LMT_ERROR, - _("Can't prepare statment '%s' (ret=%d): %s"), - sql, ret, sqlite3_errmsg(db)); + log_plugin_variadic_message(LMT_ERROR, _("Can't prepare statment '%s' (ret=%d): %s"), + sql, ret, sqlite3_errmsg(db)); goto isd_exit; } for (ret = sqlite3_step(stmt); ret == SQLITE_ROW; ret = sqlite3_step(stmt)) { - g_plugin_module_log_variadic_message(plugin, LMT_INFO, - _("The database contains %d syscalls for the '%s' architecture"), - sqlite3_column_int(stmt, 1), - (char *)sqlite3_column_text(stmt, 0)); + log_plugin_variadic_message(LMT_INFO, _("The database contains %d syscalls for the '%s' architecture"), + sqlite3_column_int(stmt, 1), + (char *)sqlite3_column_text(stmt, 0)); } sqlite3_finalize(stmt); @@ -162,10 +159,9 @@ void introduce_syscalls_database(sqlite3 *db, const GPluginModule *plugin) /****************************************************************************** * * -* Paramètres : db = base de données SQLite à consulter. * -* plugin = greffon à manipuler. * -* arch = architecture visée par la procédure. * -* : nr = indice de l'appel système à décrire. * +* Paramètres : db = base de données SQLite à consulter. * +* arch = architecture visée par la procédure. * +* nr = indice de l'appel système à décrire. * * * * Description : Construit l'identité d'un appel système pour un indice donné.* * * @@ -175,7 +171,7 @@ void introduce_syscalls_database(sqlite3 *db, const GPluginModule *plugin) * * ******************************************************************************/ -syscall_info_t *extract_from_syscalls_database(sqlite3 *db, const GPluginModule *plugin, const char *arch, unsigned int nr) +syscall_info_t *extract_from_syscalls_database(sqlite3 *db, const char *arch, unsigned int nr) { syscall_info_t *result; /* Description à retourner */ const char *sql; /* Requête SQL à construire */ @@ -193,27 +189,24 @@ syscall_info_t *extract_from_syscalls_database(sqlite3 *db, const GPluginModule ret = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { - g_plugin_module_log_variadic_message(plugin, LMT_ERROR, - _("Can't prepare statment '%s' (ret=%d): %s"), - sql, ret, sqlite3_errmsg(db)); + log_plugin_variadic_message(LMT_ERROR, _("Can't prepare statment '%s' (ret=%d): %s"), + sql, ret, sqlite3_errmsg(db)); goto efsd_exit; } ret = sqlite3_bind_text(stmt, 1, arch, -1, NULL); if (ret != SQLITE_OK) { - g_plugin_module_log_variadic_message(plugin, LMT_ERROR, - _("Can't bind value for parameter nb 0 in '%s' (ret=%d): %s"), - sql, ret, sqlite3_errmsg(db)); + log_plugin_variadic_message(LMT_ERROR, _("Can't bind value for parameter nb 0 in '%s' (ret=%d): %s"), + sql, ret, sqlite3_errmsg(db)); goto efsd_clean_exit; } ret = sqlite3_bind_int(stmt, 2, nr); if (ret != SQLITE_OK) { - g_plugin_module_log_variadic_message(plugin, LMT_ERROR, - _("Can't bind value for parameter nb 1 in '%s' (ret=%d): %s"), - sql, ret, sqlite3_errmsg(db)); + log_plugin_variadic_message(LMT_ERROR, _("Can't bind value for parameter nb 1 in '%s' (ret=%d): %s"), + sql, ret, sqlite3_errmsg(db)); goto efsd_clean_exit; } diff --git a/plugins/lnxsyscalls/db.h b/plugins/lnxsyscalls/db.h index 7eae005..d0efe8b 100644 --- a/plugins/lnxsyscalls/db.h +++ b/plugins/lnxsyscalls/db.h @@ -36,16 +36,16 @@ /* Ouvre la base de connaissances quant aux appels système. */ -sqlite3 *open_syscalls_database(const GPluginModule *); +sqlite3 *open_syscalls_database(void); /* Ferme la base de connaissances quant aux appels système. */ void close_syscalls_database(sqlite3 *); /* Présente le contenu de la base des appels système. */ -void introduce_syscalls_database(sqlite3 *, const GPluginModule *); +void introduce_syscalls_database(sqlite3 *); /* Construit l'identité d'un appel système pour un indice donné. */ -syscall_info_t *extract_from_syscalls_database(sqlite3 *, const GPluginModule *, const char *, unsigned int); +syscall_info_t *extract_from_syscalls_database(sqlite3 *, const char *, unsigned int); diff --git a/plugins/lnxsyscalls/hunter.c b/plugins/lnxsyscalls/hunter.c index 30329fd..afe73fb 100644 --- a/plugins/lnxsyscalls/hunter.c +++ b/plugins/lnxsyscalls/hunter.c @@ -37,8 +37,6 @@ struct _GGateHunter { GDelayedWork parent; /* A laisser en premier */ - const GPluginModule *plugin; /* Liens pour les messages */ - GLoadedBinary *binary; /* Binaire chargé et concerné */ GBinFormat *format; /* Format de fichier manipulé */ GProcContext *context; /* Contexte de désassemblage */ @@ -179,8 +177,7 @@ static void g_gate_hunter_finalize(GGateHunter *hunter) /****************************************************************************** * * -* Paramètres : plugin = greffon à manipuler. * -* binary = binaire dont la définition est à compléter. * +* Paramètres : binary = binaire dont la définition est à compléter. * * context = contexte de désassemblage. * * begin = point de départ du parcours de liste. * * end = point d'arrivée exclu du parcours. * @@ -195,14 +192,12 @@ static void g_gate_hunter_finalize(GGateHunter *hunter) * * ******************************************************************************/ -GGateHunter *g_gate_hunter_new(const GPluginModule *plugin, GLoadedBinary *binary, GProcContext *context, size_t begin, size_t end, activity_id_t id, const hunting_ops *hops) +GGateHunter *g_gate_hunter_new(GLoadedBinary *binary, GProcContext *context, size_t begin, size_t end, activity_id_t id, const hunting_ops *hops) { GGateHunter *result; /* Tâche à retourner */ result = g_object_new(G_TYPE_GATE_HUNTER, NULL); - result->plugin = plugin; - result->binary = binary; g_object_ref(G_OBJECT(binary)); @@ -220,7 +215,7 @@ GGateHunter *g_gate_hunter_new(const GPluginModule *plugin, GLoadedBinary *binar result->hops = hops; - result->db = open_syscalls_database(plugin); + result->db = open_syscalls_database(); if (result->db == NULL) goto gghn_db_error; return result; @@ -291,7 +286,7 @@ static void g_gate_hunter_process(GGateHunter *hunter, GtkStatusStack *status) ret = hunter->hops->resolve_nr(exec, proc, hunter->hops, &nr); if (!ret) goto unknown_syscall; - info = extract_from_syscalls_database(hunter->db, hunter->plugin, hunter->hops->arch, nr); + info = extract_from_syscalls_database(hunter->db, hunter->hops->arch, nr); if (info == NULL) goto unknown_syscall; loop = count_register_tracker_stacks(exec); diff --git a/plugins/lnxsyscalls/hunter.h b/plugins/lnxsyscalls/hunter.h index ba244e2..ed191f4 100644 --- a/plugins/lnxsyscalls/hunter.h +++ b/plugins/lnxsyscalls/hunter.h @@ -26,7 +26,7 @@ #include -#include +#include #include "hops.h" @@ -52,7 +52,7 @@ typedef struct _GGateHunterClass GGateHunterClass; GType g_gate_hunter_get_type(void); /* Crée une tâche d'étude de routines différée. */ -GGateHunter *g_gate_hunter_new(const GPluginModule *, GLoadedBinary *, GProcContext *, size_t, size_t, activity_id_t, const hunting_ops *); +GGateHunter *g_gate_hunter_new(GLoadedBinary *, GProcContext *, size_t, size_t, activity_id_t, const hunting_ops *); diff --git a/plugins/mobicore/Makefile.am b/plugins/mobicore/Makefile.am index 0790200..4647ceb 100644 --- a/plugins/mobicore/Makefile.am +++ b/plugins/mobicore/Makefile.am @@ -11,7 +11,8 @@ libmobicore_la_SOURCES = \ mclf.h mclf.c \ symbols.h symbols.c -libmobicore_la_LDFLAGS = -L$(top_srcdir)/src/.libs -lchrysacore +libmobicore_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide-$(subdir) diff --git a/plugins/mobicore/core.c b/plugins/mobicore/core.c index 2634b63..555e652 100644 --- a/plugins/mobicore/core.c +++ b/plugins/mobicore/core.c @@ -25,15 +25,16 @@ #include -#include +#include #include "mclf.h" -DEFINE_CHRYSALIDE_PLUGIN("GMobicorePlugin", "mobicore", "Support MobiCore file format for Trusted Applications", "0.1.0", - EMPTY_PG_LIST(.required), AL(PGA_CONTENT_RESOLVER)); +DEFINE_CHRYSALIDE_PLUGIN("Mobicore", "MobiCore file format support for Trusted Applications", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/formats"), + NO_REQ, AL(PGA_CONTENT_RESOLVER)); diff --git a/plugins/pychrysalide/Makefile.am b/plugins/pychrysalide/Makefile.am index 25c3e40..b85f417 100644 --- a/plugins/pychrysalide/Makefile.am +++ b/plugins/pychrysalide/Makefile.am @@ -26,8 +26,9 @@ pychrysalide_la_LIBADD = \ gui/libpychrysagui.la \ mangling/libpychrysamangling.la -pychrysalide_la_LDFLAGS = -module -avoid-version \ - $(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS) \ +pychrysalide_la_LDFLAGS = \ + -module -avoid-version \ + $(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS) \ -L$(top_srcdir)/src/.libs -lchrysacore diff --git a/plugins/pychrysalide/core/logs.c b/plugins/pychrysalide/core/logs.c index 0136b50..0965b4b 100644 --- a/plugins/pychrysalide/core/logs.c +++ b/plugins/pychrysalide/core/logs.c @@ -29,6 +29,7 @@ #include +#include #include "constants.h" @@ -169,7 +170,7 @@ static PyObject *py_logs_log_message(PyObject *self, PyObject *args) case LMT_BAD_BINARY: case LMT_ERROR: case LMT_EXT_ERROR: - log_pychrysalide_simple_message(type, msg); + log_plugin_simple_message(type, msg); result = Py_None; Py_INCREF(result); break; diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c index 07b9224..1736826 100644 --- a/plugins/pychrysalide/plugin.c +++ b/plugins/pychrysalide/plugin.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include "access.h" @@ -1021,8 +1021,8 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) no_class: if (class == NULL) - log_pychrysalide_simple_message(LMT_ERROR, - _("An error occured when looking for the 'AutoLoad': item not found!")); + log_plugin_simple_message(LMT_ERROR, + _("An error occured when looking for the 'AutoLoad': item not found!")); no_import: diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c index 8e37b09..683e41e 100644 --- a/plugins/pychrysalide/pychrysa.c +++ b/plugins/pychrysalide/pychrysa.c @@ -43,8 +43,7 @@ #include #include #include -#include -#include +#include #include "access.h" @@ -66,15 +65,13 @@ -DEFINE_CHRYSALIDE_CONTAINER_PLUGIN("GPyChrysalidePlugin", "PyChrysalide", "Provides bindings to Python", "0.1.0", - EMPTY_PG_LIST(.required), AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT, PGA_NATIVE_LOADED)); +DEFINE_CHRYSALIDE_CONTAINER_PLUGIN("PyChrysalide", "Chrysalide bindings to Python", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE("api/python/pychrysalide"), + NO_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT, PGA_NATIVE_LOADED)); -/* Conservation d'une référence au greffon pour les messages */ -static GPluginModule *_this = NULL; - /* Note la nature du chargement */ -#define _standalone (_this == NULL) +static bool _standalone = true; /* Réceptacle pour le chargement forcé */ static PyObject *_chrysalide_module = NULL; @@ -777,7 +774,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) bool result; /* Bilan à retourner */ int ret; /* Bilan de préparatifs */ - _this = plugin; + _standalone = false; /* Chargement du module pour Python */ @@ -785,8 +782,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) if (ret == -1) { - g_plugin_module_log_variadic_message(plugin, LMT_ERROR, - _("Can not extend the existing table of Python built-in modules.")); + log_plugin_simple_message(LMT_ERROR, _("Can not extend the existing table of Python built-in modules.")); result = false; goto cpi_done; } @@ -900,29 +896,6 @@ PyThreadState *get_pychrysalide_main_tstate(void) /****************************************************************************** * * -* Paramètres : msg = message à faire apparaître à l'écran. * -* * -* Description : Présente dans le journal un message simple. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void log_pychrysalide_simple_message(LogMessageType type, const char *msg) -{ - if (_this != NULL) - g_plugin_module_log_simple_message(_this, type, msg); - - else - log_simple_message(type, msg); - -} - - -/****************************************************************************** -* * * Paramètres : prefix = message d'introduction à faire apparaître à l'écran.* * * * Description : Présente dans le journal une exception survenue. * @@ -976,7 +949,7 @@ void log_pychrysalide_exception(const char *prefix, ...) Py_XDECREF(err_traceback); Py_XDECREF(err_type); - log_pychrysalide_simple_message(LMT_ERROR, msg); + log_plugin_simple_message(LMT_ERROR, msg); free(msg); diff --git a/plugins/pychrysalide/pychrysa.h b/plugins/pychrysalide/pychrysa.h index 8eba5b7..a6d4bb1 100644 --- a/plugins/pychrysalide/pychrysa.h +++ b/plugins/pychrysalide/pychrysa.h @@ -55,9 +55,6 @@ G_MODULE_EXPORT void chrysalide_plugin_on_native_loaded(GPluginModule *, PluginA /* Fournit les informations du thread principal. */ PyThreadState *get_pychrysalide_main_tstate(void); -/* Présente dans le journal un message simple. */ -void log_pychrysalide_simple_message(LogMessageType, const char *); - /* Présente dans le journal une exception survenue. */ void log_pychrysalide_exception(const char *, ...); diff --git a/plugins/readdex/reader.c b/plugins/readdex/reader.c index 8ef20b3..b63769e 100644 --- a/plugins/readdex/reader.c +++ b/plugins/readdex/reader.c @@ -25,7 +25,7 @@ #include -#include +#include #include "class.h" @@ -34,7 +34,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GDexReaderPlugin", "readdex", "Displays information about DEX files", "0.2.0", +DEFINE_CHRYSALIDE_PLUGIN("DexReader", "Information about DEX files", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), NO_REQ, AL(PGA_FORMAT_PRELOAD)); @@ -54,7 +55,7 @@ DEFINE_CHRYSALIDE_PLUGIN("GDexReaderPlugin", "readdex", "Displays information ab * * ******************************************************************************/ -G_MODULE_EXPORT bool preload_binary_format(const GPluginModule *plugin, PluginAction action, GBinFormat *format, GPreloadInfo *info, GtkStatusStack *status) +G_MODULE_EXPORT bool chrysalide_plugin_preload_binary_format(const GPluginModule *plugin, PluginAction action, GBinFormat *format, GPreloadInfo *info, GtkStatusStack *status) { bool result; /* Bilan à retourner */ GDexFormat *dex_fmt; /* Version DEX */ diff --git a/plugins/readdex/reader.h b/plugins/readdex/reader.h index 5982a81..24d4bcc 100644 --- a/plugins/readdex/reader.h +++ b/plugins/readdex/reader.h @@ -31,7 +31,7 @@ /* Etablit des symboles complémentaires dans un format DEX. */ -G_MODULE_EXPORT bool preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); +G_MODULE_EXPORT bool chrysalide_plugin_preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); diff --git a/plugins/readelf/reader.c b/plugins/readelf/reader.c index 53463e9..0c87660 100644 --- a/plugins/readelf/reader.c +++ b/plugins/readelf/reader.c @@ -25,7 +25,7 @@ #include -#include +#include #include "header.h" @@ -35,7 +35,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GElfReaderPlugin", "readelf", "Displays information about ELF files", "0.2.0", +DEFINE_CHRYSALIDE_PLUGIN("ElfReader", "Information about ELF files", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), NO_REQ, AL(PGA_FORMAT_PRELOAD)); @@ -55,7 +56,7 @@ DEFINE_CHRYSALIDE_PLUGIN("GElfReaderPlugin", "readelf", "Displays information ab * * ******************************************************************************/ -G_MODULE_EXPORT bool preload_binary_format(const GPluginModule *plugin, PluginAction action, GBinFormat *format, GPreloadInfo *info, GtkStatusStack *status) +G_MODULE_EXPORT bool chrysalide_plugin_preload_binary_format(const GPluginModule *plugin, PluginAction action, GBinFormat *format, GPreloadInfo *info, GtkStatusStack *status) { bool result; /* Bilan à retourner */ GElfFormat *elf_fmt; /* Version ELF */ diff --git a/plugins/readelf/reader.h b/plugins/readelf/reader.h index 440df67..8c280a4 100644 --- a/plugins/readelf/reader.h +++ b/plugins/readelf/reader.h @@ -31,7 +31,7 @@ /* Etablit des symboles complémentaires dans un format ELF. */ -G_MODULE_EXPORT bool preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); +G_MODULE_EXPORT bool chrysalide_plugin_preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); diff --git a/plugins/readmc/reader.c b/plugins/readmc/reader.c index aa601f5..7239960 100644 --- a/plugins/readmc/reader.c +++ b/plugins/readmc/reader.c @@ -25,7 +25,7 @@ #include -#include +#include #include "header.h" @@ -36,7 +36,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GMCReaderPlugin", "readmc", "Displays information about Mobicore files", "0.2.0", +DEFINE_CHRYSALIDE_PLUGIN("MCReader", "Information about Mobicore files", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), NO_REQ, AL(PGA_FORMAT_PRELOAD)); @@ -56,7 +57,7 @@ DEFINE_CHRYSALIDE_PLUGIN("GMCReaderPlugin", "readmc", "Displays information abou * * ******************************************************************************/ -G_MODULE_EXPORT bool preload_binary_format(const GPluginModule *plugin, PluginAction action, GBinFormat *format, GPreloadInfo *info, GtkStatusStack *status) +G_MODULE_EXPORT bool chrysalide_plugin_preload_binary_format(const GPluginModule *plugin, PluginAction action, GBinFormat *format, GPreloadInfo *info, GtkStatusStack *status) { bool result; /* Bilan à retourner */ vmpa2t pos; /* Tête de lecture des symboles*/ diff --git a/plugins/readmc/reader.h b/plugins/readmc/reader.h index 0eed6e2..e9aae1e 100644 --- a/plugins/readmc/reader.h +++ b/plugins/readmc/reader.h @@ -31,7 +31,7 @@ /* Etablit des symboles complémentaires dans un format Mobicore. */ -G_MODULE_EXPORT bool preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); +G_MODULE_EXPORT bool chrysalide_plugin_preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); diff --git a/plugins/ropgadgets/plugin.c b/plugins/ropgadgets/plugin.c index 0bfde84..c4c33dc 100644 --- a/plugins/ropgadgets/plugin.c +++ b/plugins/ropgadgets/plugin.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include "select.h" @@ -44,7 +44,8 @@ -DEFINE_CHRYSALIDE_PLUGIN("GROPPlugin", "ROP gadgets", "Find available gadgets for a ROP chain", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("RopGadgets", "Gadgets finder for a ROP chain", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), PG_REQ, AL(PGA_PLUGIN_INIT)); diff --git a/plugins/stackvars/Makefile.am b/plugins/stackvars/Makefile.am index d4a7714..46d5639 100644 --- a/plugins/stackvars/Makefile.am +++ b/plugins/stackvars/Makefile.am @@ -10,7 +10,8 @@ libstackvars_la_SOURCES = \ libstackvars_la_CFLAGS = $(AM_CFLAGS) -libstackvars_la_LDFLAGS = -L$(top_srcdir)/src/.libs -lchrysacore +libstackvars_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore devdir = $(includedir)/chrysalide-$(subdir) diff --git a/plugins/yaml/Makefile.am b/plugins/yaml/Makefile.am index 5432c9d..21d6192 100644 --- a/plugins/yaml/Makefile.am +++ b/plugins/yaml/Makefile.am @@ -40,8 +40,8 @@ libyaml_la_SOURCES = \ libyaml_la_LIBADD = \ $(PYTHON3_LIBADD) -libyaml_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ +libyaml_la_LDFLAGS = \ + -L$(top_srcdir)/src/.libs -lchrysacore \ $(PYTHON3_LDFLAGS) diff --git a/plugins/yaml/core.c b/plugins/yaml/core.c index 8bcea05..ffc7edd 100644 --- a/plugins/yaml/core.c +++ b/plugins/yaml/core.c @@ -24,7 +24,7 @@ #include "core.h" -#include +#include #ifdef HAVE_PYTHON3_BINDINGS @@ -39,7 +39,8 @@ #endif -DEFINE_CHRYSALIDE_PLUGIN("GYamlPlugin", "yaml", "Reader for Yaml contents", "0.1.0", +DEFINE_CHRYSALIDE_PLUGIN("Yaml", "Yaml content reader", + PACKAGE_VERSION, CHRYSALIDE_WEBSITE(""), PG_REQ, AL(PGA_PLUGIN_INIT)); diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 4059e0b..be459e3 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -8,7 +8,8 @@ libplugins_la_SOURCES = \ pglist.h pglist.c \ plugin-def.h \ plugin-int.h \ - plugin.h plugin.c + plugin.h plugin.c \ + self.h libplugins_la_CFLAGS = $(AM_CFLAGS) diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index bb5641b..7895eeb 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -45,9 +45,7 @@ typedef uint32_t plugin_abi_version_t; #define GET_ABI_MIN_VERSION(vs) ((vs >> 16) & 0xff) #define GET_ABI_REV_VERSION(vs) (vs & 0xffff) -#define CURRENT_ABI_VERSION DEFINE_PLUGIN_ABI_VERSION(0, 2, 0) - -//#define HARD_CODE_CURRENT_ABI_VERSION const plugin_abi_version_t abi_version = CURRENT_ABI_VERSION +#define CURRENT_ABI_VERSION DEFINE_PLUGIN_ABI_VERSION(0, 3, 0) @@ -235,6 +233,7 @@ typedef struct _plugin_interface char *name; /* Désignation humaine courte */ char *desc; /* Description plus loquace */ char *version; /* Version du greffon */ + char *url; /* Site Web associé */ bool container; /* Mise en place de greffons ? */ @@ -247,61 +246,5 @@ typedef struct _plugin_interface } plugin_interface; -/* Facilitations de déclarations */ - -#define EMPTY_PG_LIST(name) \ - name = NULL, \ - name ## _count = 0 \ - -#define BUILD_PG_LIST(name, lst) \ - name = lst, \ - name ## _count = sizeof(lst) / sizeof(lst[0]) \ - -#define AL(...) BUILD_PG_LIST(.actions, ((plugin_action_t []){ __VA_ARGS__ })) - -#define RL(...) BUILD_PG_LIST(.required, ((char *[]){ __VA_ARGS__ })) - -#define NO_REQ EMPTY_PG_LIST(.required) - - -#define DEFINE_CHRYSALIDE_PLUGIN(t, n, d, v, r, a) \ -G_MODULE_EXPORT const plugin_interface _chrysalide_plugin = { \ - \ - .magic = CHRYSALIDE_PLUGIN_MAGIC, \ - .abi_version = CURRENT_ABI_VERSION, \ - \ - .gtp_name = t, \ - .name = n, \ - .desc = d, \ - .version = v, \ - \ - .container = false, \ - \ - r, \ - \ - a, \ - \ -} - -#define DEFINE_CHRYSALIDE_CONTAINER_PLUGIN(t, n, d, v, r, a) \ -G_MODULE_EXPORT const plugin_interface _chrysalide_plugin = { \ - \ - .magic = CHRYSALIDE_PLUGIN_MAGIC, \ - .abi_version = CURRENT_ABI_VERSION, \ - \ - .gtp_name = t, \ - .name = n, \ - .desc = d, \ - .version = v, \ - \ - .container = true, \ - \ - r, \ - \ - a, \ - \ -} - - #endif /* _PLUGINS_PLUGIN_DEF_H */ diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 62517d0..4f245b1 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -30,14 +30,15 @@ #include "plugin.h" -#include "plugin-def.h" #include "../analysis/content.h" #include "../analysis/loaded.h" #include "../common/bits.h" -#include "../core/logs.h" +/* Transfert de la conscience de soi. */ +typedef void (* pg_set_self_fc) (GPluginModule *); + /* Prend acte du [dé]chargement du greffon. */ typedef bool (* pg_management_fc) (GPluginModule *); @@ -112,12 +113,5 @@ struct _GPluginModuleClass }; -/* Présente dans le journal un message simple. */ -void g_plugin_module_log_simple_message(const GPluginModule *, LogMessageType, const char *); - -/* Présente dans le journal un message complexe. */ -void g_plugin_module_log_variadic_message(const GPluginModule *, LogMessageType, const char *, ...); - - #endif /* _PLUGINS_PLUGIN_INT_H */ diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index a6dadb9..674b1a8 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -207,6 +207,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename) { GPluginModule *result; /* Structure à retourner */ GModule *module; /* Abstration de manipulation */ + pg_set_self_fc set_self; /* Copie du greffon */ const plugin_interface *interface; /* Déclaration d'interfaçage */ plugin_abi_version_t current; /* Version de l'ABI actuelle */ bool valid; /* Statut de validité */ @@ -243,6 +244,9 @@ GPluginModule *g_plugin_module_new(const gchar *filename) /* Récupération de la version d'ABI */ + if (!load_plugin_symbol(module, "chrysalide_plugin_set_self", &set_self)) + goto no_self_setter; + if (!load_plugin_symbol(module, "_chrysalide_plugin", &interface)) goto no_interface; @@ -398,11 +402,11 @@ GPluginModule *g_plugin_module_new(const gchar *filename) case PGA_FORMAT_ANALYSIS_ENDED: case PGA_FORMAT_POST_ANALYSIS_STARTED: case PGA_FORMAT_POST_ANALYSIS_ENDED: - valid = check_plugin_symbol(module, "handle_binary_format_analysis"); + valid = check_plugin_symbol(module, "chrysalide_plugin_handle_binary_format_analysis"); break; case PGA_FORMAT_PRELOAD: - valid = check_plugin_symbol(module, "preload_binary_format"); + valid = check_plugin_symbol(module, "chrysalide_plugin_preload_binary_format"); break; case PGA_FORMAT_ATTACH_DEBUG: @@ -420,7 +424,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename) break; case DPS_DISASSEMBLY: - valid = check_plugin_symbol(module, "process_binary_disassembly"); + valid = check_plugin_symbol(module, "chrysalide_plugin_process_binary_disassembly"); break; case DPS_DETECTION: @@ -461,8 +465,15 @@ GPluginModule *g_plugin_module_new(const gchar *filename) result->interface = interface; + set_self(result); + return result; + no_self_setter: + + log_variadic_message(LMT_ERROR, _("Self pointer setter is missing for plugin '%s'"), filename); + goto bad_plugin; + no_interface: log_variadic_message(LMT_ERROR, _("Main interface is missing for plugin '%s'"), filename); @@ -652,12 +663,12 @@ static void g_plugin_module_init_gclass(GPluginModuleClass *class, GModule *modu case PGA_FORMAT_ANALYSIS_ENDED: case PGA_FORMAT_POST_ANALYSIS_STARTED: case PGA_FORMAT_POST_ANALYSIS_ENDED: - load_plugin_symbol(module, "handle_binary_format_analysis", + load_plugin_symbol(module, "chrysalide_plugin_handle_binary_format_analysis", &class->handle_fmt_analysis); break; case PGA_FORMAT_PRELOAD: - load_plugin_symbol(module, "preload_binary_format", &class->preload_format); + load_plugin_symbol(module, "chrysalide_plugin_preload_binary_format", &class->preload_format); break; case PGA_FORMAT_ATTACH_DEBUG: @@ -673,7 +684,7 @@ static void g_plugin_module_init_gclass(GPluginModuleClass *class, GModule *modu break; case DPS_DISASSEMBLY: - load_plugin_symbol(module, "process_binary_disassembly", &class->process_disass); + load_plugin_symbol(module, "chrysalide_plugin_process_binary_disassembly", &class->process_disass); break; case DPS_DETECTION: diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index c7ecff2..3a55041 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -31,6 +31,7 @@ #include "plugin-def.h" #include "../analysis/binary.h" +#include "../core/logs.h" #include "../format/format.h" #include "../format/known.h" #include "../format/preload.h" @@ -92,6 +93,12 @@ bool g_plugin_module_resolve_dependencies(GPluginModule *, GPluginModule **, siz /* Termine le chargement du greffon préparé. */ bool g_plugin_module_load(GPluginModule *, GPluginModule **, size_t); +/* Présente dans le journal un message simple. */ +void g_plugin_module_log_simple_message(const GPluginModule *, LogMessageType, const char *); + +/* Présente dans le journal un message complexe. */ +void g_plugin_module_log_variadic_message(const GPluginModule *, LogMessageType, const char *, ...); + /* Accompagne la fin du chargement des modules natifs. */ void g_plugin_module_notify_native_loaded(GPluginModule *, PluginAction, void *); diff --git a/src/plugins/self.h b/src/plugins/self.h new file mode 100644 index 0000000..6a2e12d --- /dev/null +++ b/src/plugins/self.h @@ -0,0 +1,128 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * self.h - définitions pour inclusion dans les différents greffons + * + * Copyright (C) 2020 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_SELF_H +#define _PLUGINS_SELF_H + + +#include + + +#ifndef _PLUGINS_PLUGIN_H +# include "plugin.h" +#endif + + + +/* Facilitations de déclarations */ + +#define CHRYSALIDE_WEBSITE(p) "https://www.chrysalide.re/" p + +#define EMPTY_PG_LIST(name) \ + name = NULL, \ + name ## _count = 0 \ + +#define BUILD_PG_LIST(name, lst) \ + name = lst, \ + name ## _count = sizeof(lst) / sizeof(lst[0]) \ + +#define AL(...) BUILD_PG_LIST(.actions, ((plugin_action_t []){ __VA_ARGS__ })) + +#define RL(...) BUILD_PG_LIST(.required, ((char *[]){ __VA_ARGS__ })) + +#define NO_REQ EMPTY_PG_LIST(.required) + + +/* Composants d'interface */ + +#define __private __attribute__((visibility("hidden"))) + +#define PLUGIN_CORE_SELF \ +static GPluginModule *_this_plugin = NULL; \ +G_MODULE_EXPORT void chrysalide_plugin_set_self(GPluginModule *p); \ +G_MODULE_EXPORT void chrysalide_plugin_set_self(GPluginModule *p) { _this_plugin = p; }; \ +__private GPluginModule *_chrysalide_plugin_get_self(void); \ +__private GPluginModule *_chrysalide_plugin_get_self(void) { return _this_plugin; }; + +#define PLUGIN_CORE_PROPS(n, d, v, u, c) \ + \ + .magic = CHRYSALIDE_PLUGIN_MAGIC, \ + .abi_version = CURRENT_ABI_VERSION, \ + \ + .gtp_name = "G" n "Plugin", \ + .name = n, \ + .desc = d, \ + .version = v, \ + .url = u, \ + \ + .container = c + +#define DEFINE_CHRYSALIDE_PLUGIN(n, d, v, u, r, a) \ +PLUGIN_CORE_SELF \ +G_MODULE_EXPORT const plugin_interface _chrysalide_plugin = { \ + PLUGIN_CORE_PROPS(n, d, v, u, false), \ + r, \ + a, \ +} + +#define DEFINE_CHRYSALIDE_CONTAINER_PLUGIN(n, d, v, u, r, a) \ +PLUGIN_CORE_SELF \ +G_MODULE_EXPORT const plugin_interface _chrysalide_plugin = { \ + PLUGIN_CORE_PROPS(n, d, v, u, true), \ + r, \ + a, \ +} + + +/* Manipulations accélérées */ + +__private GPluginModule *_chrysalide_plugin_get_self(void); + +#define log_plugin_simple_message(type, msg) \ + do \ + { \ + GPluginModule *__this; \ + __this = _chrysalide_plugin_get_self(); \ + if (__this != NULL) \ + g_plugin_module_log_simple_message(__this, type, msg); \ + else \ + log_simple_message(type, msg); \ + } \ + while (0) + +#define log_plugin_variadic_message(type, msg, ...) \ + do \ + { \ + GPluginModule *__this; \ + __this = _chrysalide_plugin_get_self(); \ + if (__this != NULL) \ + g_plugin_module_log_variadic_message(__this, type, msg, __VA_ARGS__); \ + else \ + log_variadic_message(type, msg, __VA_ARGS__); \ + } \ + while (0) + + + +#endif /* _PLUGINS_SELF_H */ -- cgit v0.11.2-87-g4458