summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-08-19 20:25:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-08-19 20:25:20 (GMT)
commit2425953ed7330c8f92ec7d04a5f248db1ed98a9d (patch)
treef389f040f6bcc9f88d837e0e2f37cbd49758f610 /src/analysis
parenta0a7b6c1e05c78ae433f353d15e3366107b67d03 (diff)
Added a demo symbol when loading an ELF header.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@390 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/disass/disassembler.c7
-rw-r--r--src/analysis/disass/fetch.c128
-rw-r--r--src/analysis/disass/fetch.h6
3 files changed, 139 insertions, 2 deletions
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 9344089..e20429c 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -243,7 +243,12 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
ustart += usage.ru_stime.tv_sec * 1000000 + usage.ru_stime.tv_usec;
- *disass->instrs = load_raw_binary(disass->binary, &base, 100, statusbar, id);
+ //*disass->instrs = load_raw_binary(disass->binary, &base, 314744/*100*/, statusbar, id);
+
+
+ *disass->instrs = disassemble_binary_content(disass->binary, statusbar, id);
+
+
/*
*disass->instrs = disassemble_binary_parts(disass->binary, disass->parts, disass->count,
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index 1f93465..9ef6f29 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -29,6 +29,15 @@
+#include "../../arch/raw.h"
+#include "../../arch/instruction-int.h"
+
+
+
+
+
+
+
@@ -77,7 +86,9 @@ GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *bas
while (old_phy < end)
{
- instr = g_db_instruction_new_from_data(bin_data, &pos, end, proc);
+ 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);
@@ -102,26 +113,141 @@ GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *bas
+/******************************************************************************
+* *
+* Paramètres : binary = représentation de binaire chargé. *
+* 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 *disassemble_binary_content(const GLoadedBinary *binary, GtkExtStatusBar *statusbar, bstatus_id_t id)
+{
+ GArchInstruction *result; /* Instruction désassemblées */
+ GBinFormat *format; /* Format du fichier binaire */
+
+
+
+ GBinSymbol **symbols; /* Symboles à représenter */
+ size_t sym_count; /* Qté de symboles présents */
+
+
+ size_t i; /* Boucle de parcours */
+
+ GArchInstruction *instr; /* Instruction à insérer */
+
+
+ vmpa2t *last; /* Dernière bordure rencontrée */
+
+ const vmpa2t *border; /* Nouvelle bordure rencontrée */
+ off_t length; /* Taille d'une partie traitée */
+ GArchInstruction *joint; /* Jointure entre deux lots */
+ off_t max_length; /* Taille des données à lire */
+ result = NULL;
+
+
+
+ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
+ last = make_vmpa(0, VMPA_NO_VIRTUAL);
+ symbols = g_binary_format_get_symbols(format, &sym_count);
+
+
+ //sym_count = 0;
+
+
+ for (i = 0; i < sym_count; i++)
+ {
+ switch (g_binary_symbol_get_target_type(symbols[i]))
+ {
+ case STP_DATA:
+ instr = g_binary_symbol_get_instruction(symbols[i]);
+ g_object_ref(G_OBJECT(instr));
+ border = g_arch_instruction_get_location2(instr, &length);
+
+ length = 4;
+
+
+ break;
+
+ }
+
+ /* Traiter la diff */
+
+ if (cmp_vmpa_by_phy(last, border) < 0)
+ {
+ joint = load_raw_binary(binary, last,
+ get_phy_addr(last) + compute_vmpa_diff(border, last),
+ statusbar, id);
+
+ ainstr_list_merge(&result, &joint);
+
+ }
+
+ /* Ajout des instructions déjà établies */
+
+ ainstr_list_merge(&result, &instr);
+
+ /* Marquage de la nouvelle dernière bordure */
+
+ copy_vmpa(last, border);
+
+ advance_vmpa(last, length);
+
+ printf("length :: %d\n", length);
+
+ }
+
+ /* Raccord final ? */
+
+ g_loaded_binary_get_data(binary, &max_length);
+
+ if (get_phy_addr(last) < max_length)
+ {
+ joint = load_raw_binary(binary, last, max_length, statusbar, id);
+ ainstr_list_merge(&result, &joint);
+ }
+
+
+
+
+ printf("COUNT :: %zu\n", sym_count);
+
+ //exit(0);
+
+
+ return result;
+
+
+
+}
+
+
+
diff --git a/src/analysis/disass/fetch.h b/src/analysis/disass/fetch.h
index ff62ce8..b9b3bb4 100644
--- a/src/analysis/disass/fetch.h
+++ b/src/analysis/disass/fetch.h
@@ -38,6 +38,12 @@ GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *bas
/* Procède au désassemblage basique d'un contenu binaire. */
+GArchInstruction *disassemble_binary_content(const GLoadedBinary *, GtkExtStatusBar *, bstatus_id_t);
+
+
+
+
+/* Procède au désassemblage basique d'un contenu binaire. */
GArchInstruction *disassemble_binary_parts(const GLoadedBinary *, GBinPart **, size_t, GtkExtStatusBar *, bstatus_id_t);