summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-12-21 00:51:14 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-12-21 00:51:14 (GMT)
commitdbec8e8af5f296f0b95cd9c07e7d96b1a4277137 (patch)
tree4c5a9307bc4f0c168911e86459de5a51baaac226 /src/analysis
parent56deaf395c65658102ef0111cfc072d65335331a (diff)
Redefined all existing kinds of Dalvik operands in a proper way.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@203 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/disass/disassembler.c14
-rw-r--r--src/analysis/disass/output.c39
-rw-r--r--src/analysis/disass/output.h2
3 files changed, 44 insertions, 11 deletions
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 4004de9..283914e 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -58,7 +58,7 @@ typedef struct _GDelayedDisassembly
GDelayedWork parent; /* A laisser en premier */
const GOpenidaBinary *binary; /* Destinataire final */
- const GBinFormat *format; /* Format du binaire représenté*/
+ const GExeFormat *format; /* Format du binaire représenté*/
GBinPart **parts; /* Parties binaires à traiter */
size_t count; /* Nombre de ces parties */
@@ -169,7 +169,7 @@ static GDelayedDisassembly *g_delayed_disassembly_new(const GOpenidaBinary *bina
result = g_object_new(G_TYPE_DELAYED_DISASSEMBLY, NULL);
result->binary = binary;
- result->format = G_BIN_FORMAT(g_openida_binary_get_format(binary));
+ result->format = g_openida_binary_get_format(binary);
result->parts = parts;
result->count = count;
@@ -200,8 +200,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
size_t routines_count; /* Nombre de ces routines */
guint id; /* Identifiant de statut */
- routines = g_binary_format_get_routines(disass->format, &routines_count);
- qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare);
+ routines = g_binary_format_get_routines(G_BIN_FORMAT(disass->format), &routines_count);
/* Première étape */
@@ -224,6 +223,8 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
id = gtk_extended_status_bar_push(statusbar, _("Finding remaining limits..."), true);
+ qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare);
+
limit_all_routines(disass->lines, routines, routines_count, statusbar, id);
gtk_extended_status_bar_remove(statusbar, id);
@@ -232,7 +233,10 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta
id = gtk_extended_status_bar_push(statusbar, _("Printing disassembled code..."), true);
- print_disassembled_instructions(disass->buffer, disass->instrs, routines, routines_count);
+ qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare);
+
+ print_disassembled_instructions(disass->buffer, disass->format, disass->instrs,
+ routines, routines_count);
gtk_extended_status_bar_remove(statusbar, id);
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 9c4ba2f..0209a97 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -24,7 +24,9 @@
#include "output.h"
+#include "../../arch/processor.h"
#include "../../decomp/lang/asm.h"
+#include "../../format/format.h"
@@ -43,17 +45,44 @@
* *
******************************************************************************/
-void print_disassembled_instructions(GCodeBuffer *buffer, const GArchInstruction *instrs, const GBinRoutine **routines, size_t count)
+void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, const GArchInstruction *instrs, const GBinRoutine **routines, size_t count)
{
+ GLangOutput *output; /* Modèle de sortie adéquat */
+ GArchProcessor *proc; /* Architecture du binaire */
+ MemoryDataSize msize; /* Taille du bus d'adresses */
+ const bin_t *content; /* Contenu binaire global */
+ const GArchInstruction *iter; /* Boucle de parcours #1 */
+ size_t i; /* Boucle de parcours #2 */
+ vmpa_t iaddr; /* Adresse d'instruction */
+ vmpa_t raddr; /* Adresse de routine */
- /*
- for (iter = disass->instrs;
+ output = g_asm_output_new();
+
+ proc = get_arch_processor_from_format(format);
+ msize = g_arch_processor_get_memory_size(proc);
+
+ content = g_binary_format_get_content(G_BIN_FORMAT(format), NULL);
+
+ for (iter = instrs, i = 0;
iter != NULL;
- iter = g_arch_instruction_get_next_iter(disass->instrs, iter, VMPA_MAX))
+ iter = g_arch_instruction_get_next_iter(instrs, iter, VMPA_MAX))
{
+ /* Ajout des prototypes de fonction */
+ for (; i < count; i++)
+ {
+ g_arch_instruction_get_location(iter, NULL, NULL, &iaddr);
+ raddr = g_binary_routine_get_address(routines[i]);
+
+ if (raddr > iaddr) break;
+ g_binary_routine_print_code(routines[i], output, buffer, false);
+
+ }
+
+ g_arch_instruction_print(iter, buffer, msize, content, ASX_INTEL);
}
- */
+
+ g_object_unref(G_OBJECT(output));
}
diff --git a/src/analysis/disass/output.h b/src/analysis/disass/output.h
index f6c56f3..40e7536 100644
--- a/src/analysis/disass/output.h
+++ b/src/analysis/disass/output.h
@@ -32,7 +32,7 @@
/* Transcrit du code désassemblé en texte humainement lisible. */
-void print_disassembled_instructions(GCodeBuffer *, const GArchInstruction *, const GBinRoutine **, size_t);
+void print_disassembled_instructions(GCodeBuffer *, const GExeFormat *, const GArchInstruction *, const GBinRoutine **, size_t);