diff options
Diffstat (limited to 'src/analysis/disass')
-rw-r--r-- | src/analysis/disass/disassembler.c | 60 | ||||
-rw-r--r-- | src/analysis/disass/fetch.c | 5 |
2 files changed, 51 insertions, 14 deletions
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index ca5e565..efe50e1 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -36,6 +36,7 @@ #include "instructions.h" #include "output.h" #include "routines.h" +#include "../../arch/storage.h" #include "../../core/global.h" #include "../../glibext/generators/prologue.h" #include "../../plugins/pglist.h" @@ -216,6 +217,10 @@ static void compute_disassembly(GLoadedBinary *binary, GProcContext *context, wg { GArchProcessor *proc; /* Architecture du binaire */ GExeFormat *format; /* Format du binaire représenté*/ + GBinContent *content; /* Contenu brut représenté */ + const gchar *id; /* Identifiant court et unique */ + GAsmStorage *storage; /* Cache propre à constituer */ + bool cached; /* Instructions en cache */ GArchInstruction **instrs; /* Instructions résultantes */ size_t count; /* Quantité de ces instructions*/ @@ -227,25 +232,54 @@ static void compute_disassembly(GLoadedBinary *binary, GProcContext *context, wg format = g_loaded_binary_get_format(binary); + g_binary_format_preload_disassembling_context(G_BIN_FORMAT(format), context, status); + + /** + * Etape zéro : récupération des instructions depuis un cache, si ce dernier exitste. + */ + + content = g_loaded_content_get_content(G_LOADED_CONTENT(binary)); + + id = g_binary_content_get_checksum(content); + + storage = g_asm_storage_new_compressed(proc, id); + + g_object_unref(G_OBJECT(content)); + + cached = g_asm_storage_has_cache(storage); + + if (cached) + cached = g_asm_storage_open(storage, G_BIN_FORMAT(format), gid); + + g_object_unref(G_OBJECT(storage)); + /** * Première étape : collecte des instructions. */ - instrs = disassemble_binary_content(binary, context, gid, status, &count); + if (!cached) + { + instrs = disassemble_binary_content(binary, context, gid, status, &count); + + g_arch_processor_set_instructions(proc, instrs, count); - g_arch_processor_set_instructions(proc, instrs, count); + process_disassembly_event(PGA_DISASSEMBLY_RAW, binary); - process_disassembly_event(PGA_DISASSEMBLY_RAW, binary); + } /** * Seconde étape : liaisons des instructions. */ - process_all_instructions(gid, status, _("Calling 'link' hook on all instructions..."), - g_instructions_study_do_link_operation, - proc, context, format); + if (!cached) + { + process_all_instructions(gid, status, _("Calling 'link' hook on all instructions..."), + g_instructions_study_do_link_operation, + proc, context, format); - process_disassembly_event(PGA_DISASSEMBLY_HOOKED_LINK, binary); + process_disassembly_event(PGA_DISASSEMBLY_HOOKED_LINK, binary); + + } /** * Troisième étape : exécution d'éventuels post-traitements. @@ -271,11 +305,15 @@ static void compute_disassembly(GLoadedBinary *binary, GProcContext *context, wg * Cinquième étape : liaisons entre instructions. */ - process_all_instructions(gid, status, _("Establishing links betweek all instructions..."), - g_instructions_study_establish_links, - proc, context, format); + if (!cached) + { + process_all_instructions(gid, status, _("Establishing links betweek all instructions..."), + g_instructions_study_establish_links, + proc, context, format); - process_disassembly_event(PGA_DISASSEMBLY_LINKED, binary); + process_disassembly_event(PGA_DISASSEMBLY_LINKED, binary); + + } /** * Sixième étape : regroupement en blocs basiques. diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 934c755..03b3ff0 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -431,11 +431,10 @@ GArchInstruction **disassemble_binary_content(GLoadedBinary *binary, GProcContex g_proc_context_attach_counter(template.ctx, &remaining_counter); /** - * Première phase de désassemblage : intégration des infos du format. + * Première phase de désassemblage : intégration des infos du format, + * récupérées dans le contexte via un appel à g_binary_format_preload_disassembling_context(). */ - g_binary_format_preload_disassembling_context(format, template.ctx, status); - populate_fresh_memory_areas(gid, status, template.areas, template.count, G_PRELOAD_INFO(ctx)); g_work_queue_wait_for_completion(queue, gid); |