diff options
-rw-r--r-- | ChangeLog | 31 | ||||
-rw-r--r-- | plugins/androhelpers/Makefile.am | 1 | ||||
-rw-r--r-- | plugins/androhelpers/androhelpers.c | 9 | ||||
-rw-r--r-- | plugins/androhelpers/params.c | 222 | ||||
-rw-r--r-- | plugins/androhelpers/params.h | 37 | ||||
-rw-r--r-- | plugins/androhelpers/try_n_catch.c | 6 | ||||
-rw-r--r-- | src/analysis/disass/disassembler.c | 52 | ||||
-rw-r--r-- | src/arch/operand-int.h | 4 | ||||
-rw-r--r-- | src/arch/operand.c | 48 | ||||
-rw-r--r-- | src/arch/operand.h | 3 | ||||
-rw-r--r-- | src/plugins/pglist.c | 30 | ||||
-rw-r--r-- | src/plugins/pglist.h | 7 | ||||
-rw-r--r-- | src/plugins/plugin-def.h | 26 | ||||
-rw-r--r-- | src/plugins/plugin.c | 2 |
14 files changed, 428 insertions, 50 deletions
@@ -1,3 +1,34 @@ +12-11-23 Cyrille Bagard <nocbos@gmail.com> + + * plugins/androhelpers/androhelpers.c: + Update the code. + + * plugins/androhelpers/Makefile.am: + Add the params.[ch] files to libandrohelpers_la_SOURCES. + + * plugins/androhelpers/params.c: + * plugins/androhelpers/params.h: + New entries: replace the text of some registers (this and parameters). + + * plugins/androhelpers/try_n_catch.c: + Typo. + + * src/analysis/disass/disassembler.c: + Update the way plugins are run. + + * src/arch/operand.c: + * src/arch/operand.h: + * src/arch/operand-int.h: + Provide a way to set alternative text for rendering operands. + + * src/plugins/pglist.c: + * src/plugins/pglist.h: + * src/plugins/plugin.c: + Provide an easier way to run plugins on binaries. + + * src/plugins/plugin-def.h: + Refine actions which can be run on binaries. + 12-11-22 Cyrille Bagard <nocbos@gmail.com> * plugins/androhelpers/try_n_catch.c: diff --git a/plugins/androhelpers/Makefile.am b/plugins/androhelpers/Makefile.am index 3562206..d5618d1 100644 --- a/plugins/androhelpers/Makefile.am +++ b/plugins/androhelpers/Makefile.am @@ -3,6 +3,7 @@ lib_LTLIBRARIES = libandrohelpers.la libandrohelpers_la_SOURCES = \ androhelpers.h androhelpers.c \ + params.h params.c \ try_n_catch.h try_n_catch.c libandrohelpers_la_LDFLAGS = -L../../src/.libs -L../../src/gui/.libs -lchrysagui \ diff --git a/plugins/androhelpers/androhelpers.c b/plugins/androhelpers/androhelpers.c index a644868..95714fd 100644 --- a/plugins/androhelpers/androhelpers.c +++ b/plugins/androhelpers/androhelpers.c @@ -27,6 +27,7 @@ #include <string.h> +#include "params.h" #include "try_n_catch.h" @@ -66,7 +67,7 @@ PluginAction get_plugin_action(const GPluginModule *plugin) { PluginAction result; /* Combinaison à retourner */ - result = PGA_DISASS_PROCESS; + result = PGA_BINARY_DISASSEMBLED | PGA_BINARY_PRINTED; return result; @@ -93,7 +94,11 @@ bool execute_action_on_binary(GPluginModule *plugin, GLoadedBinary *binary, Plug result = true; - result &= process_exception_handlers(binary); + if (action == PGA_BINARY_DISASSEMBLED) + result &= replace_parameters(binary); + + else if (action == PGA_BINARY_PRINTED) + result &= process_exception_handlers(binary); return result; diff --git a/plugins/androhelpers/params.c b/plugins/androhelpers/params.c new file mode 100644 index 0000000..83cb5ec --- /dev/null +++ b/plugins/androhelpers/params.c @@ -0,0 +1,222 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * params.c - affichage plus adapté des registres liés à des paramètres + * + * Copyright (C) 2012 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA 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. + * + * OpenIDA 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 Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "params.h" + + +#include <stdio.h> + + +#include <arch/dalvik/operands/args.h> +#include <arch/dalvik/operands/register.h> +#include <format/dex/dex-int.h> +#include <format/dex/method.h> + + + +/* Procède si nécessaire au remplacement du texte de l'opérande. */ +static void process_register_operand(const GDexMethod *, GArchOperand *); + +/* Parcours en profondeur un ensemble d'arguments. */ +static void process_args_operand(const GDexMethod *, const GDalvikArgsOperand *); + +/* Visite chaque opérande des instructions d'une méthode. */ +static void visit_all_method_operands(const GDexMethod *, GArchInstruction *); + + + +/****************************************************************************** +* * +* Paramètres : method = routine en cours de parcours. * +* operand = morceau d'instruction en cours de traitement. * +* * +* Description : Procède si nécessaire au remplacement du texte de l'opérande.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void process_register_operand(const GDexMethod *method, GArchOperand *operand) +{ + GDalvikRegister *reg; /* Registre représenté */ + uint16_t index; /* Indice de ce registre */ + DexVariableIndex info; /* Nature réelle du registre */ + char tmp[12 /* 4294967295U */]; /* Construction du texte */ + + reg = g_dalvik_register_operand_get(G_DALVIK_REGISTER_OPERAND(operand)); + index = g_dalvik_register_get_index(reg); + + info = g_dex_method_get_variable(method, index); + + if (info & DVI_THIS) + g_arch_operand_set_alt_text(operand, "this", RTT_REGISTER); + + else if (info & DVI_ARGUMENT) + { + snprintf(tmp, 12, "p%u", (unsigned int)DVI_INDEX(info)); + g_arch_operand_set_alt_text(operand, tmp, RTT_REGISTER); + printf("set '%s'\n", tmp); + } + +} + + +/****************************************************************************** +* * +* Paramètres : method = routine en cours de parcours. * +* args = liste d'opérandes à analyser. * +* * +* Description : Parcours en profondeur un ensemble d'arguments. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void process_args_operand(const GDexMethod *method, const GDalvikArgsOperand *args) +{ + size_t count; /* Nombre d'opérandes */ + size_t i; /* Boucle de parcours */ + GArchOperand *operand; /* Operande à manipuler */ + + count = g_dalvik_args_count(args); + + for (i = 0; i < count; i++) + { + operand = g_dalvik_args_operand_get(args, i); + + if (G_IS_DALVIK_REGISTER_OPERAND(operand)) + process_register_operand(method, operand); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : method = routine à venir parcourir. * +* instrs = liste des instructions pour tout le binaire. * +* * +* Description : Visite chaque opérande des instructions d'une méthode. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void visit_all_method_operands(const GDexMethod *method, GArchInstruction *instrs) +{ + GBinRoutine *routine; /* Abstraction de la méthode */ + vmpa_t start; /* Début de la zone couverte */ + vmpa_t end; /* Fin de la zone couverte */ + GArchInstruction *iter; /* Boucle de parcours #1 */ + size_t count; /* Nombre d'opérandes */ + size_t i; /* Boucle de parcours #2 */ + GArchOperand *operand; /* Operande à manipuler */ + + routine = g_dex_method_get_routine(method); + + start = g_binary_routine_get_address(routine); + end = start + g_binary_routine_get_size(routine); + + for (iter = g_arch_instruction_find_by_address(instrs, start, true); + iter != NULL; + iter = g_arch_instruction_get_next_iter(instrs, iter, end)) + { + count = g_arch_instruction_count_operands(iter); + + for (i = 0; i < count; i++) + { + operand = g_arch_instruction_get_operand(iter, i); + + if (G_IS_DALVIK_REGISTER_OPERAND(operand)) + process_register_operand(method, operand); + + else if (G_IS_DALVIK_ARGS_OPERAND(operand)) + process_args_operand(method, G_DALVIK_ARGS_OPERAND(operand)); + + } + + } + +} + + +/****************************************************************************** +* * +* Paramètres : binary = représentation binaire à traiter. * +* * +* Description : Effectue le remplacement de tous les paramètres. * +* * +* Retour : true si une action a été menée, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool replace_parameters(GLoadedBinary *binary) +{ + GArchInstruction *instrs; /* Instructions Dalvik */ + GDexFormat *format; /* Format du binaire chargé */ + size_t cls_count; /* Nombre de classes trouvées */ + size_t i; /* Boucle de parcours #1 */ + GDexClass *class; /* Classe à analyser */ + size_t meth_count; /* Nombre de méthodes trouvées */ + size_t j; /* Boucle de parcours #2 */ + GDexMethod *method; /* Méthode à parcourir */ + + if (!G_IS_DEX_FORMAT(g_loaded_binary_get_format(binary))) + return false; + + instrs = g_loaded_binary_get_instructions(binary); + format = G_DEX_FORMAT(g_loaded_binary_get_format(binary)); + + cls_count = g_dex_format_count_classes(format); + for (i = 0; i < cls_count; i++) + { + class = g_dex_format_get_class(format, i); + + meth_count = g_dex_class_count_methods(class, false); + for (j = 0; j < meth_count; j++) + { + method = g_dex_class_get_method(class, false, j); + visit_all_method_operands(method, instrs); + } + + meth_count = g_dex_class_count_methods(class, true); + for (j = 0; j < meth_count; j++) + { + method = g_dex_class_get_method(class, true, j); + visit_all_method_operands(method, instrs); + } + + } + + return true; + +} diff --git a/plugins/androhelpers/params.h b/plugins/androhelpers/params.h new file mode 100644 index 0000000..23b2994 --- /dev/null +++ b/plugins/androhelpers/params.h @@ -0,0 +1,37 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * params.h - prototypes pour l'affichage plus adapté des registres liés à des paramètres + * + * Copyright (C) 2012 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA 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. + * + * OpenIDA 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 Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_PARAMS_H +#define _PLUGINS_PARAMS_H + + +#include <analysis/binary.h> + + + +/* Effectue le remplacement de tous les paramètres. */ +bool replace_parameters(GLoadedBinary *); + + + +#endif /* _PLUGINS_PARAMS_H */ diff --git a/plugins/androhelpers/try_n_catch.c b/plugins/androhelpers/try_n_catch.c index 7db0f70..288fa1e 100644 --- a/plugins/androhelpers/try_n_catch.c +++ b/plugins/androhelpers/try_n_catch.c @@ -110,13 +110,13 @@ static bool check_covered_area(const try_item *try, const GBinRoutine *routine) static void attach_caught_code(const GLoadedBinary *binary, const GBinRoutine *routine, const try_item *try, const caught_exception *handlers, size_t count) { vmpa_t start; /* Début de la zone couverte */ - vmpa_t end; /* Début de la zone couverte */ + vmpa_t end; /* Fin de la zone couverte */ GArchInstruction *instrs; /* Instructions Dalvik */ GArchInstruction *first; /* Première instruction */ GArchInstruction *next; /* Dernière instruction + 1 */ GArchInstruction *prev; /* Instruction à détacher */ - GArchInstruction *iter; /* Boucle de parcours */ - size_t i; /* Boucle de parcours */ + GArchInstruction *iter; /* Boucle de parcours #1 */ + size_t i; /* Boucle de parcours #2 */ start = g_binary_routine_get_address(routine); start += try->start_addr * sizeof(uint16_t); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 73d75cf..6d0bd61 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -60,13 +60,13 @@ typedef struct _GDelayedDisassembly { GDelayedWork parent; /* A laisser en premier */ - const GLoadedBinary *binary; /* Destinataire final */ - const GExeFormat *format; /* Format du binaire représenté*/ + GLoadedBinary *binary; /* Destinataire final */ + GExeFormat *format; /* Format du binaire représenté*/ GBinPart **parts; /* Parties binaires à traiter */ size_t count; /* Nombre de ces parties */ - GArchInstruction *instrs; /* Instructions résultantes */ + GArchInstruction **instrs; /* Instructions résultantes */ GCodeBuffer *buffer; /* Tampon pour le rendu */ } GDelayedDisassembly; @@ -89,7 +89,7 @@ static void g_delayed_disassembly_class_init(GDelayedDisassemblyClass *); static void g_delayed_disassembly_init(GDelayedDisassembly *); /* Crée une tâche de désassemblage différé. */ -static GDelayedDisassembly *g_delayed_disassembly_new(const GLoadedBinary *, GBinPart **, size_t, GCodeBuffer *); +static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GBinPart **, size_t, GArchInstruction **, GCodeBuffer *); /* Assure le désassemblage en différé. */ static void g_delayed_disassembly_process(GDelayedDisassembly *, GtkExtStatusBar *); @@ -155,6 +155,7 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass) * format = format du binaire représenté. * * parts = parties binaires à désassembler. * * count = nombre de parties à traiter. * +* instrs = emplacement pour la liste d'instructions. * * buffer = tampon de sortie pour les instructions. * * * * Description : Crée une tâche de désassemblage différé. * @@ -165,7 +166,7 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass) * * ******************************************************************************/ -static GDelayedDisassembly *g_delayed_disassembly_new(const GLoadedBinary *binary, GBinPart **parts, size_t count, GCodeBuffer *buffer) +static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GBinPart **parts, size_t count, GArchInstruction **instrs, GCodeBuffer *buffer) { GDelayedDisassembly *result; /* Tâche à retourner */ @@ -177,6 +178,7 @@ static GDelayedDisassembly *g_delayed_disassembly_new(const GLoadedBinary *binar result->parts = parts; result->count = count; + result->instrs = instrs; result->buffer = buffer; return result; @@ -216,8 +218,8 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta id = gtk_extended_status_bar_push(statusbar, _("Disassembling..."), true); - disass->instrs = disassemble_binary_parts(disass->binary, disass->parts, disass->count, - statusbar, id); + *disass->instrs = disassemble_binary_parts(disass->binary, disass->parts, disass->count, + statusbar, id); gtk_extended_status_bar_remove(statusbar, id); @@ -239,35 +241,43 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta #endif + run_plugins_on_binary(disass->binary, PGA_BINARY_DISASSEMBLED); + /* Seconde étape */ id = gtk_extended_status_bar_push(statusbar, _("Establishing links..."), true); - establish_links_between_lines(disass->instrs, routines, routines_count, statusbar, id); + establish_links_between_lines(*disass->instrs, routines, routines_count, statusbar, id); gtk_extended_status_bar_remove(statusbar, id); + run_plugins_on_binary(disass->binary, PGA_BINARY_LINKED); + /* Troisième étape */ id = gtk_extended_status_bar_push(statusbar, _("Finding remaining limits..."), true); qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); - limit_all_routines(disass->instrs, routines, routines_count, statusbar, id); + limit_all_routines(*disass->instrs, routines, routines_count, statusbar, id); gtk_extended_status_bar_remove(statusbar, id); + run_plugins_on_binary(disass->binary, PGA_BINARY_BOUNDED); + /* Quatrième étape */ id = gtk_extended_status_bar_push(statusbar, _("Printing disassembled code..."), true); qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare); - print_disassembled_instructions(disass->buffer, disass->format, disass->instrs, + print_disassembled_instructions(disass->buffer, disass->format, *disass->instrs, routines, routines_count); gtk_extended_status_bar_remove(statusbar, id); + run_plugins_on_binary(disass->binary, PGA_BINARY_PRINTED); + } @@ -387,39 +397,19 @@ void disassemble_binary(GLoadedBinary *binary, GBinPart **parts, size_t parts_co off_t length; /* Quantité de ces données */ GDelayedDisassembly *disass; /* Désassemblage à mener */ GWorkQueue *queue; /* Gestionnaire de différés */ - GPluginModule **pglist; /* Liste de greffons */ - size_t pgcount; /* Taille de cette liste */ - size_t i; /* Boucle de parcours */ - - /* Déroulement de l'opération principale */ *buffer = g_code_buffer_new(); data = g_loaded_binary_get_data(binary, &length); build_disass_prologue(*buffer, g_loaded_binary_get_filename(binary, true), data, length); - disass = g_delayed_disassembly_new(binary, parts, parts_count, *buffer); + disass = g_delayed_disassembly_new(binary, parts, parts_count, instrs, *buffer); queue = get_work_queue(); g_work_queue_schedule_work(queue, G_DELAYED_WORK(disass)); g_delayed_work_wait_for_completion(G_DELAYED_WORK(disass)); - *instrs = disass->instrs; - g_object_unref(G_OBJECT(disass)); - /* Actions post-désassemblage */ - - pglist = get_all_plugins_for_action(PGA_DISASS_PROCESS, &pgcount); - - if (pgcount > 0) - { - for (i = 0; i < pgcount; i++) - g_plugin_module_execute_action_on_binary(pglist[i], binary, PGA_DISASS_PROCESS); - - free(pglist); - - } - } diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index d9ebde0..b9712c4 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -44,6 +44,10 @@ struct _GArchOperand operand_compare_fc compare; /* Comparaison d'opérandes */ operand_print_fc print; /* Texte humain équivalent */ + char *alt_text; /* Eventuel texte alternatif */ + size_t alt_len; /* Taille de ce texte */ + RenderingTagType alt_tag; /* Type de rendu */ + }; diff --git a/src/arch/operand.c b/src/arch/operand.c index e98683e..667921a 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -24,6 +24,10 @@ #include "operand.h" +#include <malloc.h> +#include <string.h> + + #include "operand-int.h" @@ -107,6 +111,41 @@ bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b) /****************************************************************************** * * * Paramètres : operand = opérande à traiter. * +* text = représentation lisible alternative. * +* tag = style d'impression pour le remplacement. * +* * +* Description : Définit une autre représentation textuelle pour l'opérande. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_arch_operand_set_alt_text(GArchOperand *operand, const char *text, RenderingTagType tag) +{ + if (operand->alt_text != NULL) + free(operand->alt_text); + + if (text != NULL) + { + operand->alt_text = strdup(text); + operand->alt_len = strlen(text); + operand->alt_tag = tag; + } + else + { + operand->alt_text = NULL; + operand->alt_len = 0; + operand->alt_tag = RTT_COUNT; + } + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * * line = ligne tampon où imprimer l'opérande donné. * * syntax = type de représentation demandée. * * * @@ -120,6 +159,13 @@ bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b) void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line, AsmSyntax syntax) { - return operand->print(operand, line, syntax); + if (operand->alt_text != NULL) + g_buffer_line_insert_text(line, BLC_ASSEMBLY, + operand->alt_text, + operand->alt_len, + operand->alt_tag); + + else + operand->print(operand, line, syntax); } diff --git a/src/arch/operand.h b/src/arch/operand.h index c0cd767..b521f7c 100644 --- a/src/arch/operand.h +++ b/src/arch/operand.h @@ -51,6 +51,9 @@ GType g_arch_operand_get_type(void); /* Compare un opérande avec un autre. */ bool g_arch_operand_compare(const GArchOperand *, const GArchOperand *); +/* Définit une autre représentation textuelle pour l'opérande. */ +void g_arch_operand_set_alt_text(GArchOperand *, const char *, RenderingTagType); + /* Traduit un opérande en version humainement lisible. */ void g_arch_operand_print(const GArchOperand *, GBufferLine *, AsmSyntax); diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index 3fd2cb0..14e6b48 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * pglist.c - gestion de l'ensemble des greffons * - * Copyright (C) 2009-2010 Cyrille Bagard + * Copyright (C) 2009-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -33,7 +33,7 @@ #include <config.h> -#include "plugin.h" +#include "plugin-int.h" #include "../common/extstr.h" @@ -207,7 +207,7 @@ GPluginModule *get_one_plugin_for_action(PluginAction action) * Paramètres : action = fonctionnalité recherchée. * * count = nombre de greffons trouvés. [OUT] * * * -* Description : Founit less greffons offrant le service demandé. * +* Description : Founit les greffons offrant le service demandé. * * * * Retour : Liste de greffons correspondants à libérer de la mémoire. * * * @@ -257,3 +257,27 @@ void add_plugin_to_main_list(GPluginModule *plugin) list->plugins[list->plugins_count - 1] = plugin; } + + +/****************************************************************************** +* * +* Paramètres : binary = binaire chargé en mémoire à traiter. * +* action = fonctionnalité recherchée. * +* * +* Description : Opère une action donnée sur un binaire défini. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void run_plugins_on_binary(GLoadedBinary *binary, PluginAction action) +{ + size_t i; /* Boucle de parcours */ + + for (i = 0; i < _list.plugins_count; i++) + if (g_plugin_module_get_action(_list.plugins[i]) & action) + g_plugin_module_execute_action_on_binary(_list.plugins[i], binary, action); + +} diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index 36b998e..2804108 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * pglist.h - prototypes pour la gestion de l'ensemble des greffons * - * Copyright (C) 2009 Cyrille Bagard + * Copyright (C) 2009-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -42,7 +42,10 @@ bool init_all_plugins(GObject *); GPluginModule *get_one_plugin_for_action(PluginAction); /* Founit less greffons offrant le service demandé. */ -GPluginModule **get_all_plugins_for_action(PluginAction, size_t *); +GPluginModule **get_all_plugins_for_action(PluginAction, size_t *) __attribute__ ((deprecated)); + +/*Opère une action donnée sur un binaire défini. */ +void run_plugins_on_binary(GLoadedBinary *, PluginAction); diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index c1579b2..602b296 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -43,22 +43,34 @@ typedef enum _PluginType /* Action(s) menée(s) par le greffon */ typedef enum _PluginAction { - PGA_NONE = (0 << 0), /* Aucun intérêt */ + PGA_NONE = (0 << 0), /* Aucun intérêt */ - PGA_FORMAT_MATCHER = (1 << 0), /* Détection et chargement */ + PGA_FORMAT_MATCHER = (1 << 0), /* Détection et chargement */ - PGA_DISASSEMBLE = (1 << 1), /* Désassemblage (non trivial) */ + PGA_DISASSEMBLE = (1 << 1), /* Désassemblage (non trivial) */ - PGA_DISASS_PROCESS = (1 << 2), /* Traitement niveau assembleur*/ - PGA_CODE_PROCESS = (1 << 3), /* Traitement du code existant */ + PGA_BINARY_DISASSEMBLED = (1 << 2), /* Désassemblage fini */ + PGA_BINARY_LINKED = (1 << 3), /* Liaison en place */ + PGA_BINARY_BOUNDED = (1 << 4), /* Limites de routines définies*/ + PGA_BINARY_PRINTED = (1 << 5), /* Instructions imprimées */ - PGA_DEBUGGER_ATTACH = (1 << 4), /* Activation d'un débogueur */ - PGA_DEBUGGER_DETACH = (1 << 5) /* Désactivation d'un débogueur*/ + PGA_DISASS_PROCESS = (1 << 6), /* Traitement niveau assembleur*/ + PGA_CODE_PROCESS = (1 << 7), /* Traitement du code existant */ + + PGA_DEBUGGER_ATTACH = (1 << 8), /* Activation d'un débogueur */ + PGA_DEBUGGER_DETACH = (1 << 9) /* Désactivation d'un débogueur*/ } PluginAction; +/* Actions éligibles pour run_plugins_on_binary() */ +#define PGA_BINARY_ACTIONS ( 0 \ + | PGA_BINARY_DISASSEMBLED | PGA_BINARY_LINKED \ + | PGA_BINARY_BOUNDED | PGA_BINARY_PRINTED \ + ) + + /* Fournit une indication sur le(s) type(s) du greffon présent. */ typedef PluginType (* get_plugin_type_fc) (void); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 416c647..c6a49c6 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -153,7 +153,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) result->get_action = get_action; - if (g_plugin_module_get_action(result) & (PGA_DISASSEMBLE | PGA_DISASS_PROCESS | PGA_CODE_PROCESS)) + if (g_plugin_module_get_action(result) & (PGA_BINARY_ACTIONS | /* FIXME : supprimer le reste */ PGA_DISASSEMBLE | PGA_DISASS_PROCESS | PGA_CODE_PROCESS)) { if (!g_module_symbol(result->module, "execute_action_on_binary", (gpointer *)&result->exec_on_bin)) { |