diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-12-31 19:58:50 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-12-31 19:58:50 (GMT) |
commit | 0f571c20444dbb5d8d8d0fa46a69b31cb89f9583 (patch) | |
tree | 4349b6bdfb1b8adbdc60e0887a2a122ed857b678 /src/analysis/disass/fetch.c | |
parent | 57d7eff57c20e75aaa4ccd34f1d9d733e12bb232 (diff) |
Resolved links in disassembled instructions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@446 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/disass/fetch.c')
-rw-r--r-- | src/analysis/disass/fetch.c | 118 |
1 files changed, 42 insertions, 76 deletions
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 8bddaa1..2e9eb81 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * fetch.c - récupération d'instructions à partir de binaire brut * - * Copyright (C) 2010-2013 Cyrille Bagard + * Copyright (C) 2010-2014 Cyrille Bagard * * This file is part of Chrysalide. * @@ -24,19 +24,15 @@ #include "fetch.h" -#include "area.h" - - - - -/* Suit un flot d'exécution pour désassembler du code. */ -static void follow_execution_flow(const GLoadedBinary *, GProcContext *, mem_area *, size_t, status_info *, virt_t); - +#include <i18n.h> +#include "area.h" +/* Suit un flot d'exécution pour désassembler du code. */ +static void follow_execution_flow(const GLoadedBinary *, GProcContext *, mem_area *, size_t, status_blob_info *, virt_t); @@ -57,23 +53,11 @@ static void follow_execution_flow(const GLoadedBinary *, GProcContext *, mem_are * * ******************************************************************************/ -static void follow_execution_flow(const GLoadedBinary *binary, GProcContext *ctx, mem_area *areas, size_t count, status_info *info, virt_t virt) +static void follow_execution_flow(const GLoadedBinary *binary, GProcContext *ctx, mem_area *areas, size_t count, status_blob_info *info, virt_t virt) { - - - - - vmpa2t addr; /* Conversion en pleine adresse*/ - - mem_area *area; /* Zone de désassemblage */ - - - - - g_proc_context_push_drop_point(ctx, virt); while (g_proc_context_has_drop_points(ctx)) @@ -81,45 +65,15 @@ static void follow_execution_flow(const GLoadedBinary *binary, GProcContext *ctx virt = g_proc_context_pop_drop_point(ctx); init_vmpa(&addr, VMPA_NO_PHYSICAL, virt); - area = find_memory_area_by_addr(areas, count, &addr); - /* - printf("found area = %p\n", area); - - printf(" ... 0x%08x - 0x%08x + %u\n", - area->range.addr.physical, - area->range.addr.virtual, - area->range.length); - */ - - load_code_from_mem_area(area, areas, count, binary, ctx, &addr, info); - - - //exit(0); - } } - - - - - - - - - - - - - - - /****************************************************************************** * * * Paramètres : binary = représentation de binaire chargé. * @@ -134,51 +88,42 @@ static void follow_execution_flow(const GLoadedBinary *binary, GProcContext *ctx * * ******************************************************************************/ -GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExtStatusBar *statusbar, bstatus_id_t id) +GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExtStatusBar *statusbar) { GArchInstruction *result; /* Instruction désassemblées */ - GBinFormat *format; /* Format du fichier binaire */ GArchProcessor *proc; /* Architecture du binaire */ - GProcContext *ctx; /* Contexte de désassemblage */ - - status_info *info; - off_t length; /* Taille des données à lire */ mem_area *areas; /* Zone de productions */ size_t count; /* Nombre de ces zones */ - - + status_blob_info *info; /* Informations de progression */ virt_t virt; /* Point d'accroche virtuelle */ - GBinSymbol **symbols; /* Symboles à représenter */ size_t sym_count; /* Qté de symboles présents */ - size_t i; /* Boucle de parcours */ - - - const mrange_t *range; /* Couverture d'un symbole */ const vmpa2t *addr; /* Point de départ du symbole */ - - - + double done; /* Portion de travail accompli */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); - ctx = g_arch_processor_get_context(proc); - info = NULL; - - /* Définition à la découpe des parties à traiter */ g_loaded_binary_get_data(binary, &length); areas = compute_memory_areas(G_EXE_FORMAT(format), length, &count); + /** + * Première phase de désassemblage : suivi des chemins tracés. + */ + + info = init_progessive_status(statusbar, + _("Disassembling following the execution flow..."), + 0, length); + /* Insertion du point de départ */ virt = g_binary_format_get_entry_point(format); @@ -202,15 +147,36 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt } + done = get_current_progessive_status(info); + + fini_progessive_status(info); + + /** + * Seconde phase : on comble les trous laissés. + */ + + info = init_progessive_status(statusbar, + _("Disassembling the remaining instructions..."), + done, length); + + ensure_all_mem_areas_are_filled(areas, count, binary, ctx, info); + + fini_progessive_status(info); - ensure_all_mem_areas_are_filled(areas, count, binary, ctx, info); + /** + * Troisième et dernière phase : récolte des fruits. + */ + info = init_progessive_status(statusbar, + _("Collecting disassembled instructions..."), + 0, length); + result = collect_instructions_from_mem_areas(areas, count); - result = collect_instructions_from_mem_areas(areas, count); + fini_progessive_status(info); - /* free */ + /* free */ - return result; + return result; } |