summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-12-02 00:59:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-12-02 00:59:53 (GMT)
commit957f50b657456c4c7da2778197c144548eded8cd (patch)
tree9aea0e8ffb4dc62b23fd324b55910916cef95167 /src/analysis
parentf2d479c16a427696790441fa1459e7194f49bb6a (diff)
Improved the rendering of decompiled Dex code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@196 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/decomp/decompiler.c4
-rw-r--r--src/analysis/routine.c61
-rw-r--r--src/analysis/routine.h3
-rw-r--r--src/analysis/type.h2
4 files changed, 67 insertions, 3 deletions
diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c
index faa2f00..c446c0e 100644
--- a/src/analysis/decomp/decompiler.c
+++ b/src/analysis/decomp/decompiler.c
@@ -140,9 +140,9 @@ static void prepare_all_routines_for_decomp(const GOpenidaBinary *binary, const
for (i = 0; i < count; i++)
{
- //printf(" -- %s --\n", g_binary_routine_get_name(routines[i]));
+ printf(" -- %s --\n", g_binary_routine_get_name(routines[i]));
- if (strcmp("cryptself", g_binary_routine_get_name(routines[i])) == 0)
+ //if (strcmp("fib2", g_binary_routine_get_name(routines[i])) == 0)
{
printf("...\n");
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index ad82407..fd3d206 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -857,3 +857,64 @@ void g_binary_routine_set_decomp_instructions(GBinRoutine *routine, GDecInstruct
routine->dinstr = instr;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à mettre à jour. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* body = indique le type d'impression attendu. *
+* *
+* Description : Procède à l'impression de la décompilation d'une routine. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_routine_print_code(const GBinRoutine *routine, GLangOutput *lang, GCodeBuffer *buffer, bool body)
+{
+ GBufferLine *line; /* Adresse d'une ligne nouvelle*/
+ const char *name; /* Nom humain de la routine */
+ size_t len; /* Taille de ce nom */
+
+ /* Type de retour */
+
+ line = g_lang_output_start_routine_prototype(lang, buffer, routine->ret_type);
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
+
+ /* Nom de la routine */
+
+ name = g_binary_routine_get_name(routine);
+ if (name != NULL) len = strlen(name);
+ else
+ {
+ name = "???";
+ len = 3;
+ }
+
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, name, len, RTT_RAW);
+
+
+
+
+ /* Corps de la routine ? */
+
+ if (!body)
+ g_lang_output_end_routine_prototype(lang, buffer, line);
+
+ else
+ {
+ g_lang_output_start_routine_body(lang, buffer, line);
+
+ if (routine->dinstr != NULL)
+ g_dec_instruction_print(routine->dinstr, buffer, NULL, lang);
+
+ g_lang_output_end_routine_body(lang, buffer);
+
+ }
+
+}
diff --git a/src/analysis/routine.h b/src/analysis/routine.h
index 47de5bd..c58925c 100644
--- a/src/analysis/routine.h
+++ b/src/analysis/routine.h
@@ -156,6 +156,9 @@ GDecInstruction *g_binary_routine_get_decomp_instructions(const GBinRoutine *);
/* Définit les instructions décompilées de la routine. */
void g_binary_routine_set_decomp_instructions(GBinRoutine *, GDecInstruction *);
+/* Procède à l'impression de la décompilation d'une routine. */
+void g_binary_routine_print_code(const GBinRoutine *, GLangOutput *, GCodeBuffer *, bool);
+
#endif /* _ANALYSIS_ROUTINE_H */
diff --git a/src/analysis/type.h b/src/analysis/type.h
index 77f3ace..45d0b82 100644
--- a/src/analysis/type.h
+++ b/src/analysis/type.h
@@ -27,10 +27,10 @@
#include <glib.h>
#include <glib-object.h>
+#include <stdbool.h>
#include "../arch/archbase.h"
-#include "../arch/processor.h"