summaryrefslogtreecommitdiff
path: root/src/format
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/format
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/format')
-rw-r--r--src/format/dex/class.c80
-rw-r--r--src/format/dex/class.h3
-rwxr-xr-xsrc/format/dex/dex.c7
-rw-r--r--src/format/dex/method.c18
-rw-r--r--src/format/dex/method.h5
-rw-r--r--src/format/format.c8
-rw-r--r--src/format/format.h1
7 files changed, 112 insertions, 10 deletions
diff --git a/src/format/dex/class.c b/src/format/dex/class.c
index 8182987..710b023 100644
--- a/src/format/dex/class.c
+++ b/src/format/dex/class.c
@@ -307,14 +307,90 @@ const char *g_dex_class_get_source_file(const GDexClass *class, const GDexFormat
{
const char *result; /* Trouvaille à renvoyer */
- result = get_string_from_dex_pool(format,
- class->definition.source_file_idx);
+ result = get_string_from_dex_pool(format, class->definition.source_file_idx);
return result;
}
+/******************************************************************************
+* *
+* Paramètres : class = informations chargées à consulter. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* format = informations chargées à consulter. *
+* *
+* Description : Procède à la décompilation complète d'une classe donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_dex_class_decompile(const GDexClass *class, GLangOutput *lang, GCodeBuffer *buffer, const GDexFormat *format)
+{
+
+
+ GOpenidaType *type;
+
+
+ size_t i; /* Boucle de parcours */
+
+
+ /*
+GBufferLine *line, GLangOutput *output)
+
+ for (i = 0; i < block->count; i++)
+ {
+ if (i > 0)
+ line = g_code_buffer_append_new_line(buffer);
+
+*/
+
+
+
+ type = get_type_from_dex_pool(format, class->definition.class_idx);
+
+ //g_buffer_line_insert_text(line, BLC_ASSEMBLY, "{", 3, RTT_SIGNS);
+
+ printf("Output :: %s\n", _g_openida_type_to_string(type, true));
+
+
+
+ g_lang_output_start_class(lang, buffer, type);
+
+
+
+ for (i = 0; i < class->vmethods_count; i++)
+ {
+ g_dex_method_decompile(class->virtual_methods[i], lang, buffer);
+ g_code_buffer_append_new_line(buffer);
+ }
+
+ for (i = 0; i < class->dmethods_count; i++)
+ {
+ g_dex_method_decompile(class->direct_methods[i], lang, buffer);
+ g_code_buffer_append_new_line(buffer);
+ }
+
+
+
+
+
+
+
+
+ g_lang_output_end_class(lang, buffer);
+
+
+
+
+
+
+}
+
diff --git a/src/format/dex/class.h b/src/format/dex/class.h
index b9dfed1..f4d5cb0 100644
--- a/src/format/dex/class.h
+++ b/src/format/dex/class.h
@@ -29,6 +29,7 @@
#include "dex.h"
+#include "../../decomp/output.h"
@@ -58,6 +59,8 @@ GBinPart **g_dex_class_get_parts(const GDexClass *, GBinPart **, size_t *);
/* Retrouve si possible le nom du fichier source d'une classe. */
const char *g_dex_class_get_source_file(const GDexClass *, const GDexFormat *);
+/* Procède à la décompilation complète d'une classe donnée. */
+void g_dex_class_decompile(const GDexClass *, GLangOutput *, GCodeBuffer *, const GDexFormat *);
diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c
index 25482af..174bd2b 100755
--- a/src/format/dex/dex.c
+++ b/src/format/dex/dex.c
@@ -260,15 +260,20 @@ static void g_dex_format_find_all_sources(GDexFormat *format)
static void g_dex_format_decompile(const GDexFormat *format, GCodeBuffer *buffer, const char *filename)
{
+ GLangOutput *lang; /* Langage de sortie */
size_t i; /* Boucle de parcours */
const char *source; /* Fichier source trouvé */
+ lang = g_java_output_new();
+
for (i = 0; i < format->classes_count; i++)
{
source = g_dex_class_get_source_file(format->classes[i], format);
if (source == NULL || strcmp(source, filename) != 0) continue;
- printf("SRC :: '%s'\n", source);
+ g_dex_class_decompile(format->classes[i], lang, buffer, format);
+
+
#if 0
GOpenidaType *get_type_from_dex_pool(const GDexFormat *format, uint16_t index)
diff --git a/src/format/dex/method.c b/src/format/dex/method.c
index 9bac013..b9023d8 100644
--- a/src/format/dex/method.c
+++ b/src/format/dex/method.c
@@ -221,4 +221,22 @@ GBinPart *g_dex_method_as_part(const GDexMethod *method)
}
+/******************************************************************************
+* *
+* Paramètres : method = informations chargées à consulter. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* *
+* Description : Procède à la décompilation complète d'une routine donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+void g_dex_method_decompile(const GDexMethod *method, GLangOutput *lang, GCodeBuffer *buffer)
+{
+ g_binary_routine_print_code(method->routine, lang, buffer, true);
+
+}
diff --git a/src/format/dex/method.h b/src/format/dex/method.h
index 0f5a465..79dbd7e 100644
--- a/src/format/dex/method.h
+++ b/src/format/dex/method.h
@@ -62,9 +62,8 @@ GBinRoutine *g_dex_method_get_routine(const GDexMethod *);
/* Fournit la zone binaire correspondant à la méthode. */
GBinPart *g_dex_method_as_part(const GDexMethod *);
-
-
-
+/* Procède à la décompilation complète d'une routine donnée. */
+void g_dex_method_decompile(const GDexMethod *, GLangOutput *, GCodeBuffer *);
diff --git a/src/format/format.c b/src/format/format.c
index c104649..053a7aa 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -297,7 +297,7 @@ GDecInstruction *g_binary_format_decompile_routine(const GBinFormat *format, GBi
printf("max :: 0x%08llx\n", max);
- max = 0x00000a98ll; /* FIXME !!!! */
+ //max = 0x00000a98ll; /* FIXME !!!! */
ctx = g_dec_context_new();
g_object_set_data(G_OBJECT(ctx), "format", format);
@@ -394,14 +394,16 @@ void g_binary_format_decompile(const GBinFormat *format, GCodeBuffer *buffer, co
{
//printf(" -- %s --\n", g_binary_routine_get_name(routines[i]));
- if (strcmp("cryptself", g_binary_routine_get_name(routines[i])) == 0)
+ //if (strcmp("cryptself", g_binary_routine_get_name(routines[i])) == 0)
{
printf("...\n");
instr = g_binary_routine_get_decomp_instructions(routines[i]);
- g_dec_instruction_print(instr, buffer, NULL, g_java_output_new());
+ if (instr == NULL) continue;
+
+ //g_dec_instruction_print(instr, buffer, NULL, g_java_output_new());
diff --git a/src/format/format.h b/src/format/format.h
index 90aabbc..dd05dd2 100644
--- a/src/format/format.h
+++ b/src/format/format.h
@@ -33,7 +33,6 @@
#include "symbol.h"
#include "../analysis/routine.h"
#include "../decomp/instruction.h"
-#include "../decomp/output.h"