summaryrefslogtreecommitdiff
path: root/src/analysis/decomp/decompiler.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-11-11 01:22:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-11-11 01:22:43 (GMT)
commitb33a52031c0d44a79604bc8d9036c30bffd020cb (patch)
treec825e3330684ca57f7c423328cd116b2d6ec0f6a /src/analysis/decomp/decompiler.c
parent828124e38d266e382bb1477ef51c9fac8e81c591 (diff)
Built some expressions for the decompilation tree.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@190 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/decomp/decompiler.c')
-rw-r--r--src/analysis/decomp/decompiler.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c
index 284d3e1..9e8ec38 100644
--- a/src/analysis/decomp/decompiler.c
+++ b/src/analysis/decomp/decompiler.c
@@ -34,12 +34,16 @@
#include "../../decomp/output.h"
#include "../../decomp/lang/java.h" /* FIXME : remme ! */
+#include "../../format/format.h"
/* Construit la description d'introduction de la décompilation. */
static void build_decomp_prologue(GCodeBuffer *, const char *);
+/* S'assure de la transcription de routines en expressions. */
+static void prepare_all_routines_for_decomp(const GOpenidaBinary *, const char *);
+
/******************************************************************************
@@ -108,6 +112,59 @@ static void build_decomp_prologue(GCodeBuffer *buffer, const char *filename)
* Paramètres : binary = représentation de binaire chargé. *
* filename = nom du fichier source à cibler. *
* *
+* Description : S'assure de la transcription de routines en expressions. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void prepare_all_routines_for_decomp(const GOpenidaBinary *binary, const char *filename)
+{
+ GExeFormat *format; /* Format du binaire fourni */
+
+ GBinRoutine **routines;
+ size_t count;
+
+ size_t i;
+
+ GDecInstruction *instr;
+
+ format = g_openida_binary_get_format(binary);
+
+
+ routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &count);
+
+
+
+ for (i = 0; i < count; i++)
+ {
+ //printf(" -- %s --\n", g_binary_routine_get_name(routines[i]));
+
+ if (strcmp("cryptself", g_binary_routine_get_name(routines[i])) == 0)
+ {
+
+ printf("...\n");
+
+ instr = g_binary_format_decompile_routine(G_BIN_FORMAT(format), routines[i]);
+
+ }
+
+
+ }
+
+
+
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = représentation de binaire chargé. *
+* filename = nom du fichier source à cibler. *
+* *
* Description : Procède à la décompilation des routines d'un fichier donné. *
* *
* Retour : Tampon de code mis en place. *
@@ -119,6 +176,7 @@ static void build_decomp_prologue(GCodeBuffer *buffer, const char *filename)
GCodeBuffer *decompile_all_from_file(const GOpenidaBinary *binary, const char *filename)
{
GCodeBuffer *result; /* Tampon constitué à renvoyer */
+ GExeFormat *format; /* Format du binaire fourni */
result = g_code_buffer_new();
@@ -126,6 +184,14 @@ GCodeBuffer *decompile_all_from_file(const GOpenidaBinary *binary, const char *f
build_decomp_prologue(result, filename);
+ prepare_all_routines_for_decomp(binary, filename);
+
+
+
+
+ format = g_openida_binary_get_format(binary);
+ g_binary_format_decompile(G_BIN_FORMAT(format), result);
+
return result;
}