diff options
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/pglist.c | 35 | ||||
| -rw-r--r-- | src/plugins/pglist.h | 3 | ||||
| -rw-r--r-- | src/plugins/plugin-def.h | 11 | ||||
| -rw-r--r-- | src/plugins/plugin.c | 19 | ||||
| -rw-r--r-- | src/plugins/plugin.h | 4 | 
5 files changed, 53 insertions, 19 deletions
diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index 85421e6..6d47f57 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -77,7 +77,7 @@ bool init_all_plugins(GObject *ref)  {      _list.ref = ref; -    browse_directory_for_plugins(&_list, PACKAGE_SOURCE_DIR "/src/plugins"); +    browse_directory_for_plugins(&_list, PACKAGE_SOURCE_DIR "/plugins");      return true; @@ -200,3 +200,36 @@ GPluginModule *get_one_plugin_for_action(PluginAction action)      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : action = fonctionnalité recherchée.                          * +*                count  = nombre de greffons trouvés. [OUT]                   * +*                                                                             * +*  Description : Founit less greffons offrant le service demandé.             * +*                                                                             * +*  Retour      : Liste de greffons correspondants à libérer de la mémoire.    * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GPluginModule **get_all_plugins_for_action(PluginAction action, size_t *count) +{ +    GPluginModule **result;                 /* Greffon à retourner         */ +    size_t i;                               /* Boucle de parcours          */ + +    result = NULL; +    *count = 0; + +    for (i = 0; i < _list.plugins_count; i++) +        if (g_plugin_module_get_action(_list.plugins[i]) & action) +        { +            result = (GPluginModule **)realloc(result, ++(*count) * sizeof(GPluginModule *)); +            result[*count - 1] = _list.plugins[i]; +        } + +    return result; + +} diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index 4aa77cd..36b998e 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -41,6 +41,9 @@ bool init_all_plugins(GObject *);  /* Founit un greffon offrant le service demandé. */  GPluginModule *get_one_plugin_for_action(PluginAction); +/* Founit less greffons offrant le service demandé. */ +GPluginModule **get_all_plugins_for_action(PluginAction, size_t *); +  #endif  /* _PLUGINS_PGLIST_H */ diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index 68167e2..44dd3fa 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -27,14 +27,15 @@  #include "../analysis/binary.h" -#include "../analysis/line.h"  /* Action(s) menée(s) par le greffon */  typedef enum _PluginAction  { -    PGA_DISASSEMBLE     = (1 << 0)          /* Désassemblage (non trivial) */ +    PGA_DISASSEMBLE     = (1 << 0),         /* Désassemblage (non trivial) */ + +    PGA_CODE_PROCESS    = (1 << 1)          /* Traitement du code existant */  } PluginAction; @@ -45,10 +46,8 @@ typedef enum _PluginAction  /* Fournit une indication sur le type d'opération(s) menée(s). */  typedef PluginAction (* get_plugin_action_fc) (void); - - -/* S'occupe du désassemblage (pur) de code binaire. */ -typedef GRenderingLine * (* disassemble_binary_parts_fc) (openida_binary *); +/* Exécute une action définie sur un binaire chargé. */ +typedef bool (* execute_action_on_binary_fc) (openida_binary *, PluginAction); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 80daa74..0165dfa 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -48,7 +48,7 @@ struct _GPluginModule      init_plugin_fc init;                    /* Procédure d'initialisation  */ -    disassemble_binary_parts_fc disassemble;/* Fonction de désassemblage   */ +    execute_action_on_binary_fc exec_on_bin;/* Action sur un binaire       */  }; @@ -145,11 +145,9 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)      result->action = __get_action(); - -    /* ... */ -    if (result->action & PGA_DISASSEMBLE) +    if (result->action & (PGA_DISASSEMBLE | PGA_CODE_PROCESS))      { -        if (!g_module_symbol(result->module, "disassemble_binary_parts", (gpointer *)&result->disassemble)) +        if (!g_module_symbol(result->module, "execute_action_on_binary", (gpointer *)&result->exec_on_bin))          {              printf("Err plugin disass sym\n");              //g_object_destroy(result); @@ -202,18 +200,19 @@ PluginAction g_plugin_module_get_action(const GPluginModule *plugin)  /******************************************************************************  *                                                                             *  *  Paramètres  : plugin = greffon à consulter.                                * -*                binary = binaire dont le contenu est à désassembler.         * +*                binary = binaire dont le contenu est à traiter.              * +*                action = action attendue.                                    *  *                                                                             * -*  Description : S'occupe du désassemblage (pur) de code binaire.             * +*  Description : Exécute une action définie sur un binaire chargé.            *  *                                                                             * -*  Retour      : Lignes de code pour la représentation à insérer.             * +*  Retour      : true si une action a été menée, false sinon.                 *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -GRenderingLine *g_plugin_module_disassemble_binary_parts(const GPluginModule *plugin, openida_binary *binary) +bool g_plugin_module_execute_action_on_binary(const GPluginModule *plugin, openida_binary *binary, PluginAction action)  { -    return plugin->disassemble(binary); +    return plugin->exec_on_bin(binary, action);  } diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 455f17c..032f699 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -57,8 +57,8 @@ GPluginModule *g_plugin_module_new(const gchar *, GObject *);  /* Indique les opérations offertes par un greffon donné. */  PluginAction g_plugin_module_get_action(const GPluginModule *); -/* S'occupe du désassemblage (pur) de code binaire. */ -GRenderingLine *g_plugin_module_disassemble_binary_parts(const GPluginModule *, openida_binary *); +/* Exécute une action définie sur un binaire chargé. */ +bool g_plugin_module_execute_action_on_binary(const GPluginModule *, openida_binary *, PluginAction);  | 
