diff options
Diffstat (limited to 'src')
34 files changed, 101 insertions, 158 deletions
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" |