diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-12 18:05:45 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-12 18:05:45 (GMT) |
commit | dcc0438ff24efd5958b8d46940eb395ff2b7ed77 (patch) | |
tree | a977fdbd43abd34bbea73f1fd1aef89f364230f2 | |
parent | b3efd0bbc506e701ea9872f50b8b4db974f35954 (diff) |
Applied some code refactoring to remove usages of GBinFormat in favor of GExeFormat.
39 files changed, 171 insertions, 181 deletions
@@ -1,3 +1,46 @@ +16-12-12 Cyrille Bagard <nocbos@gmail.com> + + * plugins/libcsem/exit.c: + * plugins/ropgadgets/finder.c: + * plugins/ropgadgets/finder.h: + * plugins/ropgadgets/select.c: + * src/analysis/disass/area.c: + * src/analysis/disass/area.h: + * src/analysis/disass/disassembler.c: + * src/analysis/disass/fetch.c: + * src/analysis/disass/instructions.c: + * src/analysis/disass/instructions.h: + * src/arch/arm/link.c: + * src/arch/arm/link.h: + * src/arch/arm/v7/fetch.c: + * src/arch/arm/v7/fetch.h: + * src/arch/arm/v7/link.c: + * src/arch/arm/v7/link.h: + * src/arch/arm/v7/post.c: + * src/arch/arm/v7/post.h: + * src/arch/dalvik/fetch.c: + * src/arch/dalvik/fetch.h: + * src/arch/dalvik/link.c: + * src/arch/dalvik/link.h: + * src/arch/dalvik/post.h: + * src/arch/instruction.c: + * src/arch/instruction.h: + * src/arch/link.c: + * src/arch/link.h: + * src/arch/post.c: + * src/arch/post.h: + * src/arch/processor-int.h: + * src/arch/processor.c: + * src/arch/processor.h: + * src/format/elf/helper_x86.c: + * src/gtkext/gtkgraphview.c: + * src/gtkext/gtkstatusstack.c: + * src/gui/dialogs/gotox.c: + * src/gui/panels/strings.c: + * src/plugins/plugin.h: + Apply some code refactoring to remove usages of GBinFormat in favor of + GExeFormat. + 16-12-05 Cyrille Bagard <nocbos@gmail.com> * src/arch/vmpa.c: diff --git a/plugins/libcsem/exit.c b/plugins/libcsem/exit.c index b5545b9..cbfec64 100644 --- a/plugins/libcsem/exit.c +++ b/plugins/libcsem/exit.c @@ -24,6 +24,9 @@ #include "exit.h" +#include <format/format.h> + + /* Modifie toutes les instructions appelant exit(). */ static void mark_one_kind_of_exit_as_return(const GLoadedBinary *, const char *); diff --git a/plugins/ropgadgets/finder.c b/plugins/ropgadgets/finder.c index 4d48296..6a2283c 100644 --- a/plugins/ropgadgets/finder.c +++ b/plugins/ropgadgets/finder.c @@ -28,6 +28,7 @@ #include <core/processors.h> +#include <format/format.h> #include <i18n.h> @@ -40,7 +41,7 @@ /* Données utiles à transmettre */ typedef struct _search_domain { - GBinFormat *format; /* Format du fichier binaire */ + GExeFormat *format; /* Format du fichier binaire */ GBinContent *content; /* Contenu associé récupéré */ GArchProcessor *proc; /* Processeur idéal en place */ GProcContext *ctx; /* Contexte de désassemblage */ @@ -86,7 +87,7 @@ static GArchInstruction *disassemble_instruction_in_domain(const search_domain * ctx = domain->ctx; /* TODO : copie */ - result = g_arch_processor_disassemble(domain->proc, ctx, domain->content, pos, G_EXE_FORMAT(domain->format)); + result = g_arch_processor_disassemble(domain->proc, ctx, domain->content, pos, domain->format); if (result != NULL) { @@ -317,7 +318,7 @@ static GArchInstruction **list_all_gadgets_in_domain(const search_domain *domain * * ******************************************************************************/ -found_rop_list *list_all_gadgets(GBinFormat *format, unsigned int max_depth, update_search_progress_cb update, GObject *data, size_t *count) +found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, update_search_progress_cb update, GObject *data, size_t *count) { found_rop_list *result; /* Liste de listes à renvoyer */ const char *target; /* Sous-traitance requise */ @@ -331,12 +332,12 @@ found_rop_list *list_all_gadgets(GBinFormat *format, unsigned int max_depth, upd g_object_ref(G_OBJECT(format)); domain.format = format; - domain.content = g_binary_format_get_content(format); + domain.content = g_binary_format_get_content(G_BIN_FORMAT(format)); - target = g_exe_format_get_target_machine(G_EXE_FORMAT(format)); + target = g_exe_format_get_target_machine(format); domain.proc = get_arch_processor_for_type(target); - domain.exe_ranges = g_exe_format_get_x_ranges(G_EXE_FORMAT(format), &domain.exe_count); + domain.exe_ranges = g_exe_format_get_x_ranges(format, &domain.exe_count); /* Récupération des différents contextes */ diff --git a/plugins/ropgadgets/finder.h b/plugins/ropgadgets/finder.h index 2c7d692..6539784 100644 --- a/plugins/ropgadgets/finder.h +++ b/plugins/ropgadgets/finder.h @@ -26,7 +26,7 @@ #include <arch/instruction.h> -#include <format/format.h> +#include <format/executable.h> @@ -46,7 +46,7 @@ typedef struct _found_rop_list /* Etablit une liste de tous les gadgets présents. */ -found_rop_list *list_all_gadgets(GBinFormat *, unsigned int, update_search_progress_cb, GObject *, size_t *); +found_rop_list *list_all_gadgets(GExeFormat *, unsigned int, update_search_progress_cb, GObject *, size_t *); diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c index 8878839..881cd39 100644 --- a/plugins/ropgadgets/select.c +++ b/plugins/ropgadgets/select.c @@ -138,7 +138,7 @@ typedef struct _search_step struct { - GBinFormat *format; /* Format binaire chargé */ + GExeFormat *format; /* Format binaire chargé */ found_rop_list *list; /* Liste de gadgets ROP trouvés*/ size_t count; /* Nombre de gadgets trouvés */ }; @@ -167,13 +167,13 @@ static void push_new_progress_fraction(GObject *, gdouble); static gboolean register_found_rop_gadgets(search_step *); /* Lance une conservation des gadgets trouvés. */ -static void push_found_rop_gadgets(GObject *, GBinFormat *, found_rop_list *, size_t); +static void push_found_rop_gadgets(GObject *, GExeFormat *, found_rop_list *, size_t); /* Charge un format binaire interne déjà chargé. */ -static GBinFormat *load_internal_format_for_rop_gadgets(GObject *); +static GExeFormat *load_internal_format_for_rop_gadgets(GObject *); /* Charge un format binaire externe. */ -static GBinFormat *load_external_format_for_rop_gadgets(GObject *); +static GExeFormat *load_external_format_for_rop_gadgets(GObject *); /* Procède à la recherche de gadgets de façon séparée. */ static gpointer look_for_rop_gadgets(GObject *); @@ -211,7 +211,7 @@ static void on_rop_gadgets_filter_changed(GtkSearchEntry *, GObject *); static gboolean filter_visible_rop_gadgets(GtkTreeModel *, GtkTreeIter *, GObject *); /* Ajoute de nouvelles chaînes de gadgets localisées. */ -static void add_new_gadgets_for_category(GBinFormat *, GtkComboBoxText *, GtkTreeStore *, const char *, GArchInstruction **, size_t); +static void add_new_gadgets_for_category(GExeFormat *, GtkComboBoxText *, GtkTreeStore *, const char *, GArchInstruction **, size_t); @@ -1233,7 +1233,7 @@ static gboolean register_found_rop_gadgets(search_step *step) * * ******************************************************************************/ -static void push_found_rop_gadgets(GObject *ref, GBinFormat *format, found_rop_list *list, size_t count) +static void push_found_rop_gadgets(GObject *ref, GExeFormat *format, found_rop_list *list, size_t count) { search_step *step; /* Informations d'étape */ @@ -1262,9 +1262,9 @@ static void push_found_rop_gadgets(GObject *ref, GBinFormat *format, found_rop_l * * ******************************************************************************/ -static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref) +static GExeFormat *load_internal_format_for_rop_gadgets(GObject *ref) { - GBinFormat *result; /* Format chargé à retourner */ + GExeFormat *result; /* Format chargé à retourner */ GtkComboBox *combo; /* Composant de sélection */ GtkTreeIter iter; /* Tête de lecture à placer */ GtkTreeModel *model; /* Modèle de gestion */ @@ -1283,7 +1283,7 @@ static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref) push_status_printing_of_rop_search_step(ref, "loading", _("done"), true); - result = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); + result = g_loaded_binary_get_format(binary); push_status_printing_of_rop_search_step(ref, "format", _("already loaded"), true); @@ -1306,9 +1306,9 @@ static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref) * * ******************************************************************************/ -static GBinFormat *load_external_format_for_rop_gadgets(GObject *ref) +static GExeFormat *load_external_format_for_rop_gadgets(GObject *ref) { - GBinFormat *result; /* Format chargé à retourner */ + GExeFormat *result; /* Format chargé à retourner */ GtkEntry *entry; /* Zone de saisie de texte */ const gchar *filename; /* Nom du fichier à charger */ GBinContent *content; /* Contenu binaire chargé */ @@ -1346,7 +1346,7 @@ static GBinFormat *load_external_format_for_rop_gadgets(GObject *ref) desc = get_binary_format_name(target); - result = load_new_named_format(target, content, NULL); + result = G_EXE_FORMAT(load_new_named_format(target, content, NULL)); free(target); @@ -1383,7 +1383,7 @@ static gpointer look_for_rop_gadgets(GObject *ref) { GtkToggleButton *internal; /* Bouton de sélection interne */ gboolean state; /* Etat du bouton courant */ - GBinFormat *format; /* Format du binaire à traiter */ + GExeFormat *format; /* Format du binaire à traiter */ found_rop_list *list; /* Liste de gadgets ROP trouvés*/ size_t count; /* Nombre de ces listes */ size_t found; /* Nombre de gadgets trouvés */ @@ -1744,7 +1744,7 @@ static gboolean filter_visible_rop_gadgets(GtkTreeModel *model, GtkTreeIter *ite * * ******************************************************************************/ -static void add_new_gadgets_for_category(GBinFormat *format, GtkComboBoxText *combo, GtkTreeStore *store, const char *category, GArchInstruction **gadgets, size_t count) +static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *combo, GtkTreeStore *store, const char *category, GArchInstruction **gadgets, size_t count) { const char *target; /* Sous-traitance requise */ GArchProcessor *proc; /* Architecture du binaire */ @@ -1764,7 +1764,7 @@ static void add_new_gadgets_for_category(GBinFormat *format, GtkComboBoxText *co /* Définition de l'écosystème nécessaire */ - target = g_exe_format_get_target_machine(G_EXE_FORMAT(format)); + target = g_exe_format_get_target_machine(format); proc = get_arch_processor_for_type(target); msize = g_arch_processor_get_memory_size(proc); diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index 52ba933..48ac6ec 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -33,6 +33,7 @@ #include "../../analysis/contents/restricted.h" #include "../../arch/raw.h" #include "../../common/bits.h" +#include "../../format/format.h" #include "../../gui/panels/log.h" @@ -336,7 +337,7 @@ static void update_address_as_routine(GBinFormat *format, const vmpa2t *addr) { symbol = g_binary_symbol_new(STP_ROUTINE); g_binary_symbol_attach_routine(symbol, routine); - g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol); + g_binary_format_add_symbol(format, symbol); } else _g_binary_symbol_attach_routine(symbol, routine, STP_ROUTINE); @@ -479,7 +480,7 @@ void load_code_from_mem_area(mem_area *area, mem_area *list, size_t count, GProc /* Eventuel renvoi vers d'autres adresses */ - g_arch_instruction_call_hook(instr, IPH_FETCH, proc, ctx, format); + g_arch_instruction_call_hook(instr, IPH_FETCH, proc, ctx, G_EXE_FORMAT(format)); /* Insertion des symboles découverts en parallèle */ diff --git a/src/analysis/disass/area.h b/src/analysis/disass/area.h index f9cd9e6..39313fd 100644 --- a/src/analysis/disass/area.h +++ b/src/analysis/disass/area.h @@ -27,6 +27,7 @@ #include "../binary.h" #include "../../arch/instruction.h" +#include "../../format/symbol.h" #include "../../gtkext/gtkstatusstack.h" diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 8a19f9d..62821ab 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -280,7 +280,7 @@ static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, co else end = begin + run_size; - study = g_instructions_study_new(proc, ctx, G_BIN_FORMAT(format), begin, end, id, fallback); + study = g_instructions_study_new(proc, ctx, format, begin, end, id, fallback); g_work_queue_schedule_work(queue, G_DELAYED_WORK(study), gid); diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 55a23b6..0005378 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -31,6 +31,7 @@ #include "area.h" +#include "../../format/format.h" #include "../../glibext/delayed-int.h" diff --git a/src/analysis/disass/instructions.c b/src/analysis/disass/instructions.c index a3ca662..799d196 100644 --- a/src/analysis/disass/instructions.c +++ b/src/analysis/disass/instructions.c @@ -40,7 +40,7 @@ struct _GInstructionsStudy GArchProcessor *proc; /* Processeurs avec ses instr. */ GProcContext *ctx; /* Suivi du désassemblage */ - GBinFormat *format; /* Format binaire à manipuler */ + GExeFormat *format; /* Format binaire à manipuler */ ins_fallback_cb fallback; /* Routine de traitement finale*/ size_t begin; /* Point de départ du parcours */ @@ -185,7 +185,7 @@ static void g_instructions_study_finalize(GInstructionsStudy *study) * * ******************************************************************************/ -GInstructionsStudy *g_instructions_study_new(GArchProcessor *proc, GProcContext *ctx, GBinFormat *format, size_t begin, size_t end, activity_id_t id, ins_fallback_cb fallback) +GInstructionsStudy *g_instructions_study_new(GArchProcessor *proc, GProcContext *ctx, GExeFormat *format, size_t begin, size_t end, activity_id_t id, ins_fallback_cb fallback) { GInstructionsStudy *result; /* Tâche à retourner */ @@ -310,6 +310,6 @@ void g_instructions_study_establish_links(GInstructionsStudy *study, size_t inde } - establish_links_for_instruction(instr, study->format, study->proc); + establish_links_for_instruction(instr, G_BIN_FORMAT(study->format), study->proc); } diff --git a/src/analysis/disass/instructions.h b/src/analysis/disass/instructions.h index a69e4df..9d76035 100644 --- a/src/analysis/disass/instructions.h +++ b/src/analysis/disass/instructions.h @@ -52,7 +52,7 @@ typedef void (* ins_fallback_cb) (GInstructionsStudy *, size_t); /* Crée une tâche d'étude de instructions différée. */ -GInstructionsStudy *g_instructions_study_new(GArchProcessor *, GProcContext *, GBinFormat *, size_t, size_t, activity_id_t, ins_fallback_cb); +GInstructionsStudy *g_instructions_study_new(GArchProcessor *, GProcContext *, GExeFormat *, size_t, size_t, activity_id_t, ins_fallback_cb); /* Réalise l'appel de type IPH_LINK sur une instruction. */ void g_instructions_study_do_link_operation(GInstructionsStudy *, size_t); diff --git a/src/arch/arm/link.c b/src/arch/arm/link.c index d50ff5f..9b78fa0 100644 --- a/src/arch/arm/link.c +++ b/src/arch/arm/link.c @@ -45,7 +45,7 @@ * * ******************************************************************************/ -void handle_arm_conditional_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void handle_arm_conditional_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { switch (g_arm_instruction_get_cond(G_ARM_INSTRUCTION(instr))) { diff --git a/src/arch/arm/link.h b/src/arch/arm/link.h index 732f203..d461559 100644 --- a/src/arch/arm/link.h +++ b/src/arch/arm/link.h @@ -27,12 +27,11 @@ #include "../instruction.h" #include "../processor.h" -#include "../../format/format.h" /* Etablit un lien conditionnel selon une instruction donnée. */ -void handle_arm_conditional_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_arm_conditional_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c index 8c36f9b..7296717 100644 --- a/src/arch/arm/v7/fetch.c +++ b/src/arch/arm/v7/fetch.c @@ -34,6 +34,7 @@ #include "operands/offset.h" #include "../register.h" #include "../../raw.h" +#include "../../../format/format.h" @@ -53,7 +54,7 @@ * * ******************************************************************************/ -void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset) +void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) { const mrange_t *range; /* Emplacementt d'instruction */ virt_t pc; /* Position dans l'exécution */ @@ -120,7 +121,7 @@ void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchPr * * ******************************************************************************/ -void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset) +void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) { const mrange_t *range; /* Emplacementt d'instruction */ virt_t pc; /* Position dans l'exécution */ @@ -189,7 +190,7 @@ void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchP * * ******************************************************************************/ -void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset) +void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) { const mrange_t *range; /* Emplacementt d'instruction */ virt_t pc; /* Position dans l'exécution */ @@ -248,7 +249,7 @@ void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArch * * ******************************************************************************/ -void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset) +void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) { GArchOperand *op; /* Opérande numérique en place */ GArmRegister *reg; /* Registre matériel manipulé */ @@ -310,7 +311,7 @@ void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchP * * ******************************************************************************/ -void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format) +void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format) { const mrange_t *range; /* Emplacementt d'instruction */ virt_t pc; /* Position dans l'exécution */ @@ -363,7 +364,7 @@ void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcess * * ******************************************************************************/ -void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GBinFormat *format, ArmV7InstrSet iset) +void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) { const mrange_t *range; /* Emplacementt d'instruction */ phys_t phys_pc; /* Position dans l'exécution */ @@ -423,7 +424,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst val_offset = phys_pc + offset; - if (!g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), val_offset, &sym_addr)) + if (!g_exe_format_translate_offset_into_vmpa(format, val_offset, &sym_addr)) { assert(0); return; @@ -441,7 +442,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst /* Lecture de la valeur vers laquelle renvoyer */ - content = g_binary_format_get_content(format); + content = g_binary_format_get_content(G_BIN_FORMAT(format)); copy_vmpa(&pos, &sym_addr); @@ -461,7 +462,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst vmpa2_virt_to_string(get_mrange_addr(range), MDS_32_BITS, loc, NULL); snprintf(name, name_len, _("Value used @ %s"), loc); - ADD_RAW_AS_SYM(format, symbol, &sym_addr, sym_instr, comment, name); + ADD_RAW_AS_SYM(G_BIN_FORMAT(format), symbol, &sym_addr, sym_instr, comment, name); free(name); diff --git a/src/arch/arm/v7/fetch.h b/src/arch/arm/v7/fetch.h index e8e57e5..e8a89d6 100644 --- a/src/arch/arm/v7/fetch.h +++ b/src/arch/arm/v7/fetch.h @@ -27,83 +27,82 @@ #include "context.h" #include "../../instruction.h" -#include "../../../format/format.h" /* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_b_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet); +void help_fetching_with_instruction_b_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); -static inline void help_fetching_with_instruction_b_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_b_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); } -static inline void help_fetching_with_instruction_b_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_b_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); } /* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_bl_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet); +void help_fetching_with_instruction_bl_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); -static inline void help_fetching_with_instruction_bl_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_bl_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); } -static inline void help_fetching_with_instruction_bl_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_bl_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); } /* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_blx_with_dest(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet); +void help_fetching_with_instruction_blx_with_dest(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); -static inline void help_fetching_with_instruction_blx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_blx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_THUMB); } -static inline void help_fetching_with_instruction_blx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_blx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_ARM); } /* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_bx_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet); +void help_fetching_with_instruction_bx_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); -static inline void help_fetching_with_instruction_bx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_bx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); } -static inline void help_fetching_with_instruction_bx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_bx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); } /* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_cb_n_z(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *); +void help_fetching_with_instruction_cb_n_z(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *); /* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GBinFormat *, ArmV7InstrSet); +void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); -static inline void help_fetching_with_instruction_ldr_literal_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_ldr_literal_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); } -static inline void help_fetching_with_instruction_ldr_literal_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GBinFormat *fmt) +static inline void help_fetching_with_instruction_ldr_literal_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) { help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); } diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c index e9fc4bc..90d78bc 100644 --- a/src/arch/arm/v7/link.c +++ b/src/arch/arm/v7/link.c @@ -47,7 +47,7 @@ * * ******************************************************************************/ -void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { GArchOperand *op; /* Opérande numérique en place */ GArmRegister *reg; /* Registre matériel manipulé */ @@ -81,7 +81,7 @@ void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArc * * ******************************************************************************/ -void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { GArchOperand *op; /* Opérande numérique en place */ GArmV7RegListOperand *reglist; /* Autre version de l'instance */ diff --git a/src/arch/arm/v7/link.h b/src/arch/arm/v7/link.h index 0b658fc..136b787 100644 --- a/src/arch/arm/v7/link.h +++ b/src/arch/arm/v7/link.h @@ -27,15 +27,14 @@ #include "context.h" #include "../../instruction.h" -#include "../../../format/format.h" /* Encadre les sauts à partir de registres ARMv7. */ -void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); /* Détecte les fins de procédures à base d'instructions 'pop'. */ -void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c index b6c0f14..9abe232 100644 --- a/src/arch/arm/v7/post.c +++ b/src/arch/arm/v7/post.c @@ -43,10 +43,11 @@ * * ******************************************************************************/ -void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { GArchOperand *op; /* Opérande numérique en place */ uint32_t addr; /* Adresse visée par le saut */ + GBinFormat *bfmt; /* Version basique du format */ GArchOperand *new; /* Instruction de ciblage */ vmpa2t target; mrange_t trange; /* Etendue du symbole à créer */ @@ -62,11 +63,13 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr) - && g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target)) + && g_exe_format_translate_address_into_vmpa(format, addr, &target)) { + bfmt = G_BIN_FORMAT(format); + new = g_target_operand_new(MDS_32_BITS_UNSIGNED, addr); - if (!g_target_operand_resolve(G_TARGET_OPERAND(new), format, true)) + if (!g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true)) { addr &= ~0x1; @@ -96,11 +99,11 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc symbol = g_binary_symbol_new(STP_CODE_LABEL); g_binary_symbol_attach_routine(symbol, routine); - g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol); + g_binary_format_add_symbol(bfmt, symbol); - g_target_operand_resolve(G_TARGET_OPERAND(new), format, true); + g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true); } else diff --git a/src/arch/arm/v7/post.h b/src/arch/arm/v7/post.h index 5237045..a8acb3c 100644 --- a/src/arch/arm/v7/post.h +++ b/src/arch/arm/v7/post.h @@ -27,23 +27,22 @@ #include "../../instruction.h" #include "../../post.h" -#include "../../../format/format.h" -static inline void post_process_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void post_process_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_CODE_LABEL); } -static inline void post_process_branch_and_link_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void post_process_branch_and_link_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_ROUTINE); } -static inline void post_process_comp_and_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void post_process_comp_and_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { post_process_target_resolution(ins, proc, ctx, fmt, 1, STP_CODE_LABEL); @@ -51,7 +50,7 @@ static inline void post_process_comp_and_branch_instructions(GArchInstruction *i /* Complète un désassemblage accompli pour une instruction. */ -void post_process_ldr_instructions(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void post_process_ldr_instructions(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); diff --git a/src/arch/dalvik/fetch.c b/src/arch/dalvik/fetch.c index 89d5bea..e05b7de 100644 --- a/src/arch/dalvik/fetch.c +++ b/src/arch/dalvik/fetch.c @@ -44,7 +44,7 @@ * * ******************************************************************************/ -void help_fetching_with_dalvik_instruction(GArchInstruction *instr, GArchProcessor *proc, GDalvikContext *context, GBinFormat *format, size_t index) +void help_fetching_with_dalvik_instruction(GArchInstruction *instr, GArchProcessor *proc, GDalvikContext *context, GExeFormat *format, size_t index) { GArchOperand *op; /* Opérande numérique en place */ virt_t target; /* Adresse virtuelle visée */ diff --git a/src/arch/dalvik/fetch.h b/src/arch/dalvik/fetch.h index 3a8dda3..1c10bbf 100644 --- a/src/arch/dalvik/fetch.h +++ b/src/arch/dalvik/fetch.h @@ -27,25 +27,24 @@ #include "context.h" #include "../instruction.h" -#include "../../format/format.h" /* Pousse une adresse précisée par un saut pour désassemblage. */ -void help_fetching_with_dalvik_instruction(GArchInstruction *, GArchProcessor *, GDalvikContext *, GBinFormat *, size_t); +void help_fetching_with_dalvik_instruction(GArchInstruction *, GArchProcessor *, GDalvikContext *, GExeFormat *, size_t); -static inline void help_fetching_with_dalvik_goto_instruction(GArchInstruction *ins, GArchProcessor *proc, GDalvikContext *ctx, GBinFormat *fmt) +static inline void help_fetching_with_dalvik_goto_instruction(GArchInstruction *ins, GArchProcessor *proc, GDalvikContext *ctx, GExeFormat *fmt) { help_fetching_with_dalvik_instruction(ins, proc, ctx, fmt, 0); } -static inline void help_fetching_with_dalvik_if_instruction(GArchInstruction *ins, GArchProcessor *proc, GDalvikContext *ctx, GBinFormat *fmt) +static inline void help_fetching_with_dalvik_if_instruction(GArchInstruction *ins, GArchProcessor *proc, GDalvikContext *ctx, GExeFormat *fmt) { help_fetching_with_dalvik_instruction(ins, proc, ctx, fmt, 2); } -static inline void help_fetching_with_dalvik_ifz_instruction(GArchInstruction *ins, GArchProcessor *proc, GDalvikContext *ctx, GBinFormat *fmt) +static inline void help_fetching_with_dalvik_ifz_instruction(GArchInstruction *ins, GArchProcessor *proc, GDalvikContext *ctx, GExeFormat *fmt) { help_fetching_with_dalvik_instruction(ins, proc, ctx, fmt, 1); } diff --git a/src/arch/dalvik/link.c b/src/arch/dalvik/link.c index 2d1b18c..311f672 100644 --- a/src/arch/dalvik/link.c +++ b/src/arch/dalvik/link.c @@ -74,7 +74,7 @@ typedef struct _case_comment * * ******************************************************************************/ -void handle_dalvik_packed_switch_links(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void handle_dalvik_packed_switch_links(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { GArchOperand *op; /* Opérande numérique en place */ virt_t virt; /* Adresse virtuelle */ diff --git a/src/arch/dalvik/link.h b/src/arch/dalvik/link.h index a965b3b..ee5d5db 100644 --- a/src/arch/dalvik/link.h +++ b/src/arch/dalvik/link.h @@ -29,19 +29,19 @@ -static inline void handle_dalvik_if_branch_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void handle_dalvik_if_branch_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { handle_branch_as_link(ins, proc, ctx, fmt, 2); } -static inline void handle_dalvik_ifz_branch_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void handle_dalvik_ifz_branch_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { handle_branch_as_link(ins, proc, ctx, fmt, 1); } /* Etablit tous les liens liés à un embranchement compressé. */ -void handle_dalvik_packed_switch_links(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_dalvik_packed_switch_links(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); diff --git a/src/arch/dalvik/post.h b/src/arch/dalvik/post.h index a86ed4c..a5375b7 100644 --- a/src/arch/dalvik/post.h +++ b/src/arch/dalvik/post.h @@ -29,19 +29,19 @@ -static inline void post_process_dalvik_goto_target_resolution(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void post_process_dalvik_goto_target_resolution(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_CODE_LABEL); } -static inline void post_process_dalvik_if_target_resolution(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void post_process_dalvik_if_target_resolution(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { post_process_target_resolution(ins, proc, ctx, fmt, 2, STP_CODE_LABEL); } -static inline void post_process_dalvik_ifz_target_resolution(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void post_process_dalvik_ifz_target_resolution(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { post_process_target_resolution(ins, proc, ctx, fmt, 1, STP_CODE_LABEL); diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 89b498e..e3490a8 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -251,7 +251,7 @@ void g_arch_instruction_set_hooks(GArchInstruction *instr, const instr_hook_fc h * * ******************************************************************************/ -void g_arch_instruction_call_hook(GArchInstruction *instr, InstrProcessHook type, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void g_arch_instruction_call_hook(GArchInstruction *instr, InstrProcessHook type, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { assert(type < IPH_COUNT); diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 657e25f..d87eb1c 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -36,7 +36,7 @@ #include "../analysis/type.h" #include "../decomp/context.h" #include "../decomp/instruction.h" -//#include "../format/executable.h" +#include "../format/executable.h" //#include "../format/format.h" @@ -79,19 +79,13 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *); /** - * La définition de "GBinFormat", utile aux traitements complémentaires, ne peut - * se faire en incluant le fichier d'en-tête "../format/format.h", pour cause - * de références circulaires. + * La définition de "GArchProcessor", utile aux traitements complémentaires, ne peut + * se faire en incluant le fichier d'en-tête "processor.h", pour cause de références + * circulaires. * * On procède donc à une seconde déclaration, en attendant éventuellement mieux. - * - * Pareil pour "GArchProcessor", définie dans le fichier "processor.h", lequel - * inclut directement ce fichier. */ -/* Format binaire générique (instance) */ -typedef struct _GBinFormat GBinFormat; - /* Ligne de représentation générique (instance) */ typedef struct _GArchProcessor GArchProcessor; @@ -108,13 +102,13 @@ typedef enum _InstrProcessHook } InstrProcessHook; /* Complète un désassemblage accompli pour une instruction. */ -typedef void (* instr_hook_fc) (GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +typedef void (* instr_hook_fc) (GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); /* Définit un traitement complémentare au désassemblage. */ void g_arch_instruction_set_hooks(GArchInstruction *, const instr_hook_fc [IPH_COUNT]); /* Complète un désassemblage accompli pour une instruction. */ -void g_arch_instruction_call_hook(GArchInstruction *, InstrProcessHook, GArchProcessor *, GProcContext *, GBinFormat *); +void g_arch_instruction_call_hook(GArchInstruction *, InstrProcessHook, GArchProcessor *, GProcContext *, GExeFormat *); /* Définit la localisation d'une instruction. */ void g_arch_instruction_set_range(GArchInstruction *, const mrange_t *); diff --git a/src/arch/link.c b/src/arch/link.c index b6d69e0..4519bc5 100644 --- a/src/arch/link.c +++ b/src/arch/link.c @@ -46,7 +46,7 @@ * * ******************************************************************************/ -void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { GArchOperand *op; /* Opérande numérique en place */ virt_t virt; /* Adresse virtuelle */ @@ -89,7 +89,7 @@ void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon * * ******************************************************************************/ -void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format, size_t index) +void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format, size_t index) { GArchOperand *op; /* Opérande numérique en place */ virt_t virt; /* Adresse virtuelle */ @@ -154,7 +154,7 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC * * ******************************************************************************/ -void handle_call_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format) +void handle_call_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { GArchOperand *op; /* Opérande numérique en place */ virt_t virt; /* Adresse virtuelle */ diff --git a/src/arch/link.h b/src/arch/link.h index 1000365..07a3d88 100644 --- a/src/arch/link.h +++ b/src/arch/link.h @@ -27,30 +27,29 @@ #include "instruction.h" #include "processor.h" -#include "../format/format.h" /* Etablit un lien de saut selon une instruction donnée. */ -void handle_jump_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_jump_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); /* Etablit un lien d'appel selon une instruction donnée. */ -void handle_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *, size_t); +void handle_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *, size_t); -static inline void handle_branch_if_true_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void handle_branch_if_true_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { handle_branch_as_link(ins, proc, ctx, fmt, 0); } -static inline void handle_comp_and_branch_if_true_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GBinFormat *fmt) +static inline void handle_comp_and_branch_if_true_as_link(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) { handle_branch_as_link(ins, proc, ctx, fmt, 1); } /* Etablit un lien d'appel selon une instruction donnée. */ -void handle_call_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *); +void handle_call_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); diff --git a/src/arch/post.c b/src/arch/post.c index 4cc6d12..ebbf40b 100644 --- a/src/arch/post.c +++ b/src/arch/post.c @@ -49,16 +49,17 @@ * * ******************************************************************************/ -void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GBinFormat *format, size_t index, SymbolType type) +void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format, size_t index, SymbolType type) { GArchOperand *op; /* Opérande numérique en place */ virt_t addr; /* Adresse visée par le saut */ + GBinFormat *bfmt; /* Version basique du format */ MemoryDataSize ptr_size; /* Taille de l'espace mémoire */ GArchOperand *new; /* Instruction de ciblage */ - vmpa2t target; + vmpa2t target; /* Emplacement de la cible */ mrange_t trange; /* Etendue du symbole à créer */ - VMPA_BUFFER(loc); - char name[5 + VMPA_MAX_LEN]; + VMPA_BUFFER(loc); /* Conversion en chaîne */ + char name[5 + VMPA_MAX_LEN]; /* Etiquette de la destination */ GBinRoutine *routine; /* Nouvelle routine trouvée */ GBinSymbol *symbol; /* Nouveau symbole construit */ @@ -66,13 +67,15 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro assert(G_IS_IMM_OPERAND(op)); if (g_imm_operand_to_virt_t(G_IMM_OPERAND(op), &addr) - && g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target)) + && g_exe_format_translate_address_into_vmpa(format, addr, &target)) { + bfmt = G_BIN_FORMAT(format); + ptr_size = g_arch_processor_get_memory_size(proc); new = g_target_operand_new(ptr_size, addr); - if (!g_target_operand_resolve(G_TARGET_OPERAND(new), format, true)) + if (!g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true)) { vmpa2_virt_to_string(&target, MDS_UNDEFINED, loc, NULL); @@ -100,9 +103,9 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro symbol = g_binary_symbol_new(type); g_binary_symbol_attach_routine(symbol, routine); - g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol); + g_binary_format_add_symbol(bfmt, symbol); - g_target_operand_resolve(G_TARGET_OPERAND(new), format, true); + g_target_operand_resolve(G_TARGET_OPERAND(new), bfmt, true); } diff --git a/src/arch/post.h b/src/arch/post.h index db65ebe..8174f02 100644 --- a/src/arch/post.h +++ b/src/arch/post.h @@ -26,12 +26,12 @@ #include "instruction.h" -#include "../format/format.h" +#include "../format/symbol.h" /* Associe un symbole à la valeur ciblée par un opérande. */ -void post_process_target_resolution(GArchInstruction *, GArchProcessor *, GProcContext *, GBinFormat *, size_t, SymbolType); +void post_process_target_resolution(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *, size_t, SymbolType); diff --git a/src/arch/processor-int.h b/src/arch/processor-int.h index 36f6db5..c92f668 100644 --- a/src/arch/processor-int.h +++ b/src/arch/processor-int.h @@ -54,9 +54,6 @@ typedef GProcContext * (* get_processor_context_fc) (const GArchProcessor *); /* Fournit un contexte lié au processeur pour une décompilation. */ typedef GDecContext * (* get_decomp_context_fc) (const GArchProcessor *); -/* Décode une instruction dans un flux de données. */ -typedef GArchInstruction * (* decode_instruction_fc) (const GArchProcessor *, GProcContext *, const bin_t *, off_t *, off_t, vmpa_t, GBinFormat *); - /* Désassemble une instruction dans un flux de données. */ typedef GArchInstruction * (* disass_instr_fc) (const GArchProcessor *, GProcContext *, const GBinContent *, vmpa2t *, GExeFormat *); @@ -108,7 +105,6 @@ struct _GArchProcessorClass { GObjectClass parent; /* A laisser en premier */ - decode_instruction_fc decode; /* Traduction en instructions */ disass_instr_fc disassemble; /* Traduction en instructions */ }; diff --git a/src/arch/processor.c b/src/arch/processor.c index 95f4b67..bfbc2db 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -232,60 +232,6 @@ MemoryDataSize g_arch_processor_get_instruction_size(const GArchProcessor *proc) /****************************************************************************** * * -* Paramètres : proc = architecture visée par la procédure. * -* ctx = contexte lié à l'exécution du processeur. * -* data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* end = limite des données à analyser. * -* addr = adresse virtuelle de l'instruction. * -* format = format du fichier contenant le code. * -* * -* Description : Décode une instruction dans un flux de données. * -* * -* Retour : Instruction mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *proc, GProcContext *ctx, const bin_t *data, off_t *pos, off_t end, vmpa_t addr, GBinFormat *format) -{ -#if 0 - GArchInstruction *result; /* Instruction à renvoyer */ - off_t old_pos; /* Sauvegarde de la position */ - bool skipped; /* Données prise en compte ? */ - - old_pos = *pos; - - result = G_ARCH_PROCESSOR_GET_CLASS(proc)->decode(proc, ctx, data, pos, end, addr, format); - - if (result == NULL || result == SKIPPED_INSTR) - { - //printf("BAD CODE :: 0x%02hhx @0x%08lx\n", data[*pos], addr); - - skipped = (result == SKIPPED_INSTR); - - *pos = old_pos; - result = NULL;// changed !!! g_db_instruction_new_from_data(data, pos, end, addr, proc); - -#ifdef DEBUG /* FIXME */ - if (skipped) - g_db_instruction_mark_as_skipped(G_DB_INSTRUCTION(result)); -#endif - } - - //g_arch_instruction_set_location(result, old_pos, *pos - old_pos, addr); - - return result; -#endif - - return NULL; - -} - - -/****************************************************************************** -* * * Paramètres : proc = architecture visée par la procédure. * * ctx = contexte lié à l'exécution du processeur. * * content = flux de données à analyser. * diff --git a/src/arch/processor.h b/src/arch/processor.h index c41bccd..5fb3def 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -32,7 +32,6 @@ #include "instruction.h" #include "../common/endianness.h" #include "../decomp/context.h" -#include "../format/format.h" ////////////////// utile ? @@ -70,9 +69,6 @@ MemoryDataSize g_arch_processor_get_memory_size(const GArchProcessor *); /* Fournit la taille min. des instructions d'une architecture. */ MemoryDataSize g_arch_processor_get_instruction_size(const GArchProcessor *); -/* Décode une instruction dans un flux de données. */ -GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *, GProcContext *, const bin_t *, off_t *, off_t, vmpa_t, GBinFormat *) __attribute__ ((deprecated)); - /* Désassemble une instruction dans un flux de données. */ GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *, GProcContext *, const GBinContent *, vmpa2t *, GExeFormat *); diff --git a/src/format/elf/helper_x86.c b/src/format/elf/helper_x86.c index 337607d..859845c 100644 --- a/src/format/elf/helper_x86.c +++ b/src/format/elf/helper_x86.c @@ -241,8 +241,10 @@ GArchInstruction **decode_elf_relocations(GElfFormat *format, const elf_shdr *pl { address = plt_address + pos; +#if 0 instr = g_arch_processor_decode_instruction(proc, NULL /*FIXME*/, &G_BIN_FORMAT(format)->content[plt_start], &pos, plt_size, address, NULL /*FIXME*/); +#endif result = (GArchInstruction **)realloc(result, ++(*count) * sizeof(GArchInstruction *)); result[*count - 1] = instr; diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 469bc46..d205e47 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -32,6 +32,7 @@ #include "gtkdisplaypanel-int.h" #include "graph/cluster.h" #include "../analysis/blocks/flow.h" +#include "../format/format.h" #include "../gui/editem.h" diff --git a/src/gtkext/gtkstatusstack.c b/src/gtkext/gtkstatusstack.c index ac1716e..b5dc0e1 100644 --- a/src/gtkext/gtkstatusstack.c +++ b/src/gtkext/gtkstatusstack.c @@ -35,6 +35,7 @@ #include "easygtk.h" #include "../common/extstr.h" +#include "../format/format.h" diff --git a/src/gui/dialogs/gotox.c b/src/gui/dialogs/gotox.c index 02f1a02..872cd4f 100644 --- a/src/gui/dialogs/gotox.c +++ b/src/gui/dialogs/gotox.c @@ -31,6 +31,7 @@ #include <i18n.h> +#include "../../format/format.h" #include "../../gtkext/easygtk.h" #include "../../gtkext/support.h" diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c index 7a927df..4f919b1 100644 --- a/src/gui/panels/strings.c +++ b/src/gui/panels/strings.c @@ -33,6 +33,7 @@ #include "../dialogs/gotox.h" #include "../../common/extstr.h" #include "../../core/params.h" +#include "../../format/format.h" #include "../../gtkext/easygtk.h" #include "../../gtkext/gtkdockable-int.h" diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 62cade0..fda42e4 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -31,6 +31,7 @@ #include "plugin-def.h" #include "../analysis/binary.h" +#include "../format/format.h" |