diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-03-18 23:18:26 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-03-18 23:18:26 (GMT) |
commit | 4cef477cbdfd61a28ed6531d1e91d5a330a67704 (patch) | |
tree | 1b4708f624e0f3bdb26403ab06ac9689cf4cf583 /src/analysis/disass/area.c | |
parent | 5c1636199a06965c549f748014d582dcb85ba7df (diff) |
Computed limits for all routines according to existing symbols.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@491 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/disass/area.c')
-rw-r--r-- | src/analysis/disass/area.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index 916918e..90738be 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -71,6 +71,11 @@ static bool mark_range_in_mem_area_as_processed(mem_area *, phys_t, phys_t, GArc +/* S'assure de la présence d'un début de routine à un point. */ +static void update_address_as_routine(GBinFormat *, const vmpa2t *); + + + /* Procède au désassemblage d'un contenu binaire non exécutable. */ static void load_data_from_mem_area(mem_area *, mem_area *, size_t, const GLoadedBinary *, GProcContext *, const vmpa2t *, status_blob_info *); @@ -377,6 +382,70 @@ static bool mark_range_in_mem_area_as_processed(mem_area *area, phys_t start, ph + + + + + + +/****************************************************************************** +* * +* Paramètres : format = format binaire en cours de traitement. * +* addr = adresse d'une instruction présentée comme première. * +* * +* Description : S'assure de la présence d'un début de routine à un point. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void update_address_as_routine(GBinFormat *format, const vmpa2t *addr) +{ + GBinSymbol *symbol; /* Symbole présent ou créé */ + phys_t offset; /* Décallage trouvé */ + bool found; /* Détection de symbole */ + SymbolType sym_type; /* Type de symbole en place */ + bool wrong_type; /* Analyse plus fine de ce type*/ + mrange_t range; /* Etendue du symbole à créer */ + VMPA_BUFFER(loc); /* Traduction de l'adresse */ + char name[5 + VMPA_MAX_LEN]; /* Nom de symbole nouveau */ + GBinRoutine *routine; /* Nouvelle routine trouvée */ + + found = g_binary_format_resolve_symbol(format, addr, &symbol, &offset); + + if (found) + { + sym_type = g_binary_symbol_get_target_type(symbol); + wrong_type = (sym_type != STP_ROUTINE && sym_type != STP_ENTRY_POINT); + } + + if (!found || (found && offset == 0 && wrong_type)) + { + init_mrange(&range, addr, 0); + + vmpa2_virt_to_string(addr, MDS_UNDEFINED, loc, NULL); + snprintf(name, sizeof(name), "ZZZ_%s", loc + 2); + + routine = g_binary_routine_new(); + g_binary_routine_set_name(routine, strdup(name)); + + g_binary_routine_set_range(routine, &range); + + if (!found) + { + symbol = g_binary_symbol_new(STP_ROUTINE, NULL, ~0); + g_binary_symbol_attach_routine(symbol, routine); + g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol); + } + else _g_binary_symbol_attach_routine(symbol, routine, STP_ROUTINE); + + } + +} + + /****************************************************************************** * * * Paramètres : area = aire représentant à contenu à parcourir. * @@ -489,6 +558,11 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons g_arch_instruction_set_range(instr, &range); + /* Enregistrement d'un éventuel début de routine */ + + if (g_arch_instruction_get_flags(instr) & AIF_ROUTINE_START) + update_address_as_routine(format, &prev); + /* Eventuel renvoi vers d'autres adresses */ g_arch_instruction_call_hook(instr, IPH_LINK, ctx, format); |