summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-04-21 22:00:00 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-04-21 22:00:00 (GMT)
commit8eb95d316f7b6fbad0ff798abfe7f70f89e812d2 (patch)
tree4f310c7ffdb94d48fff236e63c7e6f0ed9f1dee1 /src/plugins
parent315146a49b5570294ca20beca720c4e3f74a86bd (diff)
Improved the way file formats are detected and loaded.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/pglist.h14
-rw-r--r--src/plugins/plugin-def.h15
-rw-r--r--src/plugins/plugin-int.h6
-rw-r--r--src/plugins/plugin.c45
-rw-r--r--src/plugins/plugin.h3
5 files changed, 73 insertions, 10 deletions
diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h
index d406cc8..4c8194d 100644
--- a/src/plugins/pglist.h
+++ b/src/plugins/pglist.h
@@ -85,14 +85,20 @@ GPluginModule **get_all_plugins_for_action(PluginAction, size_t *);
while (0)
-/* DPS_FORMAT */
-//#define find_matching_format()
-#define handle_binary_format(a, f, s) \
+
+/* DPS_CONTENT */
+
+#define handle_binary_content(a, c, i, s) \
+ process_all_plugins_for(a, g_plugin_module_handle_binary_content, c, i, s)
+
+/* DPS_FORMAT */
+
+#define handle_binary_format(a, f, s) \
process_all_plugins_for(a, g_plugin_module_handle_binary_format, f, s)
-#define preload_binary_format(a, f, i, s) \
+#define preload_binary_format(a, f, i, s) \
process_all_plugins_for(a, g_plugin_module_preload_binary_format, f, i, s)
/* DPS_DISASSEMBLY */
diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h
index ed09e91..c32c9e3 100644
--- a/src/plugins/plugin-def.h
+++ b/src/plugins/plugin-def.h
@@ -79,8 +79,9 @@ typedef uint32_t plugin_action_t;
/* DPC_BINARY_PROCESSING */
-#define DPS_FORMAT DEFINE_PLUGIN_SUB_CATEGORY(0)
-#define DPS_DISASSEMBLY DEFINE_PLUGIN_SUB_CATEGORY(1)
+#define DPS_CONTENT DEFINE_PLUGIN_SUB_CATEGORY(0)
+#define DPS_FORMAT DEFINE_PLUGIN_SUB_CATEGORY(1)
+#define DPS_DISASSEMBLY DEFINE_PLUGIN_SUB_CATEGORY(2)
// GUI -> project
// binary loaded
@@ -111,6 +112,16 @@ typedef enum _PluginAction
PGA_PLUGIN_EXIT = DPC_BASIC | DPS_PG_MANAGEMENT | DEFINE_PLUGIN_ACTION(1),
/**
+ * DPC_BINARY_PROCESSING | DPS_CONTENT
+ */
+
+ /* Exploration de contenus binaires */
+ PGA_CONTENT_EXPLORER = DPC_BINARY_PROCESSING | DPS_CONTENT | DEFINE_PLUGIN_ACTION(0),
+
+ /* Conversion de contenus binaires en contenus chargés */
+ PGA_CONTENT_RESOLVER = DPC_BINARY_PROCESSING | DPS_CONTENT | DEFINE_PLUGIN_ACTION(1),
+
+ /**
* DPC_BINARY_PROCESSING | DPS_FORMAT
*/
diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h
index 213ae92..5fae2de 100644
--- a/src/plugins/plugin-int.h
+++ b/src/plugins/plugin-int.h
@@ -46,8 +46,8 @@ typedef void (* pg_process_disassembly_fc) (const GPluginModule *, PluginAction,
-/* Indique si le format peut être pris en charge ici. */
-//typedef bool (* pg_format_is_matching) (const GPluginModule *, GBinContent **);
+/* Procède à une opération liée à un contenu binaire. */
+typedef void (* pg_handle_content) (const GPluginModule *, PluginAction, GBinContent *, gid_t, GtkStatusStack *);
/* Procède à une opération liée au format de fichier uniquement. */
typedef bool (* pg_handle_format) (const GPluginModule *, PluginAction, GBinFormat *, GtkStatusStack *);
@@ -115,7 +115,7 @@ struct _GPluginModule
//execute_on_debugger_fc handle_debugger; /* Action liée à un débogueur */
- //pg_format_is_matching is_matching; /* Recherche de correspondance */
+ pg_handle_content handle_content; /* Explorations ou résolutions */
pg_handle_format handle_format; /* Manipulation du format */
pg_preload_format preload_format; /* Préchargement d'un format */
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index d9072d7..02684d6 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -260,6 +260,28 @@ GPluginModule *g_plugin_module_new(const gchar *filename)
switch (sub)
{
+ case DPS_CONTENT:
+
+ switch (action)
+ {
+ case PGA_CONTENT_EXPLORER:
+ case PGA_CONTENT_RESOLVER:
+ if (!load_plugin_symbol(result->module,
+ "chrysalide_plugin_handle_binary_content",
+ &result->handle_content))
+ goto bad_plugin;
+ break;
+
+ default:
+ log_variadic_message(LMT_WARNING,
+ _("Unknown action '0x%02x' in plugin '%s'..."),
+ result->interface->actions[i], filename);
+ break;
+
+ }
+
+ break;
+
case DPS_FORMAT:
switch (action)
@@ -684,6 +706,29 @@ void g_plugin_module_log_variadic_message(const GPluginModule *plugin, LogMessag
/******************************************************************************
* *
+* Paramètres : plugin = greffon à manipuler. *
+* action = type d'action attendue. *
+* content = contenu binaire à traiter. *
+* gid = identifiant du groupe de traitement. *
+* status = barre de statut à tenir informée. *
+* *
+* Description : Procède à une opération liée à un contenu binaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_plugin_module_handle_binary_content(const GPluginModule *plugin, PluginAction action, GBinContent *content, gid_t gid, GtkStatusStack *status)
+{
+ return plugin->handle_content(plugin, action, content, gid, status);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : plugin = greffon à manipuler. *
* action = type d'action attendue. *
* format = format de binaire à manipuler pendant l'opération. *
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index d86682c..9ac6aa6 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -91,7 +91,8 @@ 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);
-
+/* Procède à une opération liée à un contenu binaire. */
+void g_plugin_module_handle_binary_content(const GPluginModule *, PluginAction, GBinContent *, gid_t, GtkStatusStack *);
/* Procède à une opération liée au format de fichier uniquement. */
bool g_plugin_module_handle_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GtkStatusStack *);