summaryrefslogtreecommitdiff
path: root/src/analysis/disass/fetch.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-08-05 20:19:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-08-05 20:19:08 (GMT)
commit56ee4d3ecddeee05f11083fcc1595e3756b91790 (patch)
tree5ec6e5449214093280629047c36016a0de09cbeb /src/analysis/disass/fetch.c
parenta2eb5483fe74923e488013b2d8b94ded6340499e (diff)
Defined the first steps for a new disassembling approach.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@387 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/disass/fetch.c')
-rw-r--r--src/analysis/disass/fetch.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index 17eea6a..4686fe2 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -23,6 +23,117 @@
#include "fetch.h"
+
+#include "../../arch/artificial.h"
+
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* 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 basique d'un contenu binaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+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 */
+ 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 */
+
+ 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);
+
+ end = bin_length;
+
+ pos = local_dup_vmpa(base);
+ prev = local_dup_vmpa(base);
+
+ old_phy = get_phy_addr(prev);
+
+ while (old_phy < end)
+ {
+ instr = g_db_instruction_new_from_data(bin_data, pos, end, proc);
+ if (instr == NULL) break;
+
+ new_phy = get_phy_addr(pos);
+
+ g_arch_instruction_set_location(instr, prev, new_phy - old_phy);
+ 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;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifdef DEBUG
# include "../../arch/artificial.h"
#endif
@@ -139,3 +250,14 @@ GArchInstruction *disassemble_binary_parts(const GLoadedBinary *binary, GBinPart
return result;
}
+
+
+
+
+
+
+
+
+
+
+