diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-10-06 20:52:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-10-06 20:52:21 (GMT) |
commit | 1d5f7f28f92251dc4d3bff8d87b3e3052ab9cab2 (patch) | |
tree | 1ad4346a8cbcd8379850f68d04cb8757371c05e1 /src/analysis | |
parent | ada6b756efd6ca109f6c46aa4d3eb11c17ad6b84 (diff) |
Got prepared to disassemble some ARMv7 instructions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@409 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/disass/fetch.c | 85 | ||||
-rw-r--r-- | src/analysis/disass/fetch.h | 4 |
2 files changed, 81 insertions, 8 deletions
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 763b37a..97cad33 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -36,7 +36,11 @@ +/* Procède au désassemblage basique d'un contenu binaire. */ +static GArchInstruction *load_raw_binary(const GLoadedBinary *, const vmpa2t *, off_t, GtkExtStatusBar *, bstatus_id_t); +/* Procède au désassemblage d'un contenu binaire exécutable. */ +static GArchInstruction *load_code_binary(const GLoadedBinary *, const vmpa2t *, off_t, GtkExtStatusBar *, bstatus_id_t); @@ -58,7 +62,7 @@ * * ******************************************************************************/ -GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *base, off_t end, GtkExtStatusBar *statusbar, bstatus_id_t id) +static GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *base, off_t end, GtkExtStatusBar *statusbar, bstatus_id_t id) { GArchInstruction *result; /* Liste d'instr. à renvoyer */ GBinFormat *format; /* Format du fichier binaire */ @@ -110,6 +114,79 @@ GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *bas } +/****************************************************************************** +* * +* Paramètres : binary = représentation de binaire chargé. * +* parts = parties binaires à désassembler. * +* count = nombre de parties à traiter. * +* statusbar = barre de statut avec progression à mettre à jour.* +* id = identifiant du message affiché à l'utilisateur. * +* * +* Description : Procède au désassemblage d'un contenu binaire exécutable. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *load_code_binary(const GLoadedBinary *binary, const vmpa2t *base, off_t end, GtkExtStatusBar *statusbar, bstatus_id_t id) +{ + GArchInstruction *result; /* Liste d'instr. à renvoyer */ + GBinFormat *format; /* Format du fichier binaire */ + GArchProcessor *proc; /* Architecture du binaire */ + off_t bin_length; /* Taille des données à lire */ + bin_t *bin_data; /* Données binaires à lire */ + vmpa2t pos; /* Boucle de parcours */ + vmpa2t prev; /* Boucle de parcours */ + off_t old_phy; /* Ancienne position physique */ + GArchInstruction *instr; /* Instruction décodée */ + off_t new_phy; /* Nouvelle position physique */ + mrange_t range; /* Couverture de l'instruction */ + + result = NULL; + + format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); + proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + bin_data = g_loaded_binary_get_data(binary, &bin_length); + + copy_vmpa(&pos, base); + copy_vmpa(&prev, base); + + old_phy = get_phy_addr(&prev); + + while (old_phy < end) + { + instr = g_arch_processor_disassemble(proc, NULL, bin_data, &pos, end); + + if (instr == NULL) + instr = g_raw_instruction_new_array(bin_data, MDS_32_BITS, 1, &pos, end, + g_arch_processor_get_endianness(proc)); + if (instr == NULL) printf(" Break !!!\n"); + if (instr == NULL) break; + + new_phy = get_phy_addr(&pos); + init_mrange(&range, &prev, new_phy - old_phy); + + g_arch_instruction_set_range(instr, &range); + + g_arch_instruction_add_to_list(&result, instr); + + copy_vmpa(&prev, &pos); + old_phy = get_phy_addr(&prev); + + //done += (new_phy - old_phy); + //gtk_extended_status_bar_update_activity(statusbar, id, done * 1.0 / sum); + + } + + return result; + +} + + + + @@ -203,9 +280,9 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt break; case STP_ROUTINE: - instr = load_raw_binary(binary, border, - get_phy_addr(border) + length, - statusbar, id); + instr = load_code_binary(binary, border, + get_phy_addr(border) + length, + statusbar, id); break; default: diff --git a/src/analysis/disass/fetch.h b/src/analysis/disass/fetch.h index b9b3bb4..96d04a2 100644 --- a/src/analysis/disass/fetch.h +++ b/src/analysis/disass/fetch.h @@ -32,10 +32,6 @@ -GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *base, off_t end, GtkExtStatusBar *statusbar, bstatus_id_t id); - - - /* Procède au désassemblage basique d'un contenu binaire. */ GArchInstruction *disassemble_binary_content(const GLoadedBinary *, GtkExtStatusBar *, bstatus_id_t); |