diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-12 18:38:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-12 18:38:53 (GMT) |
commit | 3754a5e3edeea98ce426b65772708ae91b291c1f (patch) | |
tree | e292aa254f59e61f6f9672b826f08be6f428ffdd /src/arch/dalvik | |
parent | dcc0438ff24efd5958b8d46940eb395ff2b7ed77 (diff) |
Removed most of the code related to non-working decompilation.
Diffstat (limited to 'src/arch/dalvik')
-rw-r--r-- | src/arch/dalvik/Makefile.am | 3 | ||||
-rw-r--r-- | src/arch/dalvik/context.c | 6 | ||||
-rw-r--r-- | src/arch/dalvik/context.h | 3 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/Makefile.am | 27 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/aget.c | 71 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/aput.c | 71 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/arithm.c | 253 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/array.c | 67 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/const.c | 110 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/if.c | 173 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/iget.c | 79 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/invoke.c | 271 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/iput.c | 79 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/move.c | 141 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/new.c | 73 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/ret.c | 84 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/switch.c | 62 | ||||
-rw-r--r-- | src/arch/dalvik/decomp/translate.h | 101 | ||||
-rw-r--r-- | src/arch/dalvik/instruction.c | 187 | ||||
-rw-r--r-- | src/arch/dalvik/processor.c | 7 |
20 files changed, 105 insertions, 1763 deletions
diff --git a/src/arch/dalvik/Makefile.am b/src/arch/dalvik/Makefile.am index b97e7d8..d994242 100644 --- a/src/arch/dalvik/Makefile.am +++ b/src/arch/dalvik/Makefile.am @@ -16,7 +16,6 @@ libarchdalvik_la_SOURCES = \ register.h register.c libarchdalvik_la_LIBADD = \ - decomp/libarchdalvikdecomp.la \ opcodes/libarchdalvikopcodes.la \ operands/libarchdalvikoperands.la \ pseudo/libarchdalvikpseudo.la @@ -29,4 +28,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = decomp opdefs opcodes operands pseudo +SUBDIRS = opdefs opcodes operands pseudo diff --git a/src/arch/dalvik/context.c b/src/arch/dalvik/context.c index b293d08..3b79ffa 100644 --- a/src/arch/dalvik/context.c +++ b/src/arch/dalvik/context.c @@ -34,8 +34,6 @@ #include "../raw.h" #include "../../analysis/contents/restricted.h" #include "../../common/sort.h" -#include "../../decomp/context-int.h" -#include "../../decomp/expr/pseudo.h" #include "../../format/dex/dex-int.h" @@ -89,6 +87,7 @@ static void g_dalvik_context_finalize(GDalvikContext *); /* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ +#if 0 /* Définition d'un contexte pour décompilation Dalkvik (instance) */ struct _GDalvikDContext { @@ -130,6 +129,7 @@ static void g_dalvik_context_spread_allocated_shared_reg(GDalvikDContext *, GDal /* Convertit un registre machine en un pseudo-registre. */ static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *, GDalvikRegisterOperand *, bool, vmpa_t); +#endif @@ -423,6 +423,7 @@ GArchInstruction *g_dalvik_context_get_raw_data(GDalvikContext *ctx, const GBinC /* ---------------------------------------------------------------------------------- */ +#if 0 /* Indique le type définit par la GLib pour le contexte de décompilation Dalkvik. */ G_DEFINE_TYPE(GDalvikDContext, g_dalvik_dcontext, G_TYPE_DEC_CONTEXT); @@ -739,3 +740,4 @@ static GDecInstruction *g_dalvik_dcontext_convert_register(GDalvikDContext *ctx, return result; } +#endif diff --git a/src/arch/dalvik/context.h b/src/arch/dalvik/context.h index 42399b5..7449219 100644 --- a/src/arch/dalvik/context.h +++ b/src/arch/dalvik/context.h @@ -31,7 +31,6 @@ #include "instruction.h" #include "../archbase.h" -#include "../../decomp/context.h" @@ -73,6 +72,7 @@ GArchInstruction *g_dalvik_context_get_raw_data(GDalvikContext *, const GBinCont /* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ +#if 0 #define G_TYPE_DALVIK_DCONTEXT g_dalvik_dcontext_get_type() #define G_DALVIK_DCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_dcontext_get_type(), GDalvikDContext)) #define G_IS_DALVIK_DCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_dcontext_get_type())) @@ -93,6 +93,7 @@ GType g_dalvik_dcontext_get_type(void); /* Crée un contexte pour la décompilation Dalvik. */ GDalvikDContext *g_dalvik_dcontext_new(void); +#endif diff --git a/src/arch/dalvik/decomp/Makefile.am b/src/arch/dalvik/decomp/Makefile.am deleted file mode 100644 index 053bf4c..0000000 --- a/src/arch/dalvik/decomp/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ - -noinst_LTLIBRARIES = libarchdalvikdecomp.la - -libarchdalvikdecomp_la_SOURCES = \ - aget.c \ - aput.c \ - arithm.c \ - array.c \ - const.c \ - if.c \ - iget.c \ - invoke.c \ - iput.c \ - move.c \ - new.c \ - ret.c \ - switch.c \ - translate.h - -libarchdalvikdecomp_la_LIBADD = - -libarchdalvikdecomp_la_CFLAGS = $(AM_CFLAGS) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/src/arch/dalvik/decomp/aget.c b/src/arch/dalvik/decomp/aget.c deleted file mode 100644 index 19d62a8..0000000 --- a/src/arch/dalvik/decomp/aget.c +++ /dev/null @@ -1,71 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * aget.c - décompilation des instructions manipulant des tableaux (chargement) - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../decomp/expr/array.h" -#include "../../../decomp/expr/assign.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'aget'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_aget(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *array; /* Tableau accédé */ - GDecInstruction *index; /* Indice de cellule considérée*/ - GDecInstruction *content; /* Contenu de cellule visé */ - GDecInstruction *access; /* Représentation de l'accès */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - array = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - index = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 0); - content = g_dec_context_convert_register(ctx, operand, true, addr); - - access = g_array_access_new(G_DEC_EXPRESSION(array), G_DEC_EXPRESSION(index)); - result = g_assign_expression_new(G_DEC_EXPRESSION(content), G_DEC_EXPRESSION(access)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/aput.c b/src/arch/dalvik/decomp/aput.c deleted file mode 100644 index b62736e..0000000 --- a/src/arch/dalvik/decomp/aput.c +++ /dev/null @@ -1,71 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * aput.c - décompilation des instructions manipulant des tableaux (enregistrement) - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../decomp/expr/array.h" -#include "../../../decomp/expr/assign.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'aput'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_aput(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *content; /* Contenu de cellule visé */ - GDecInstruction *array; /* Tableau accédé */ - GDecInstruction *index; /* Indice de cellule considérée*/ - GDecInstruction *access; /* Représentation de l'accès */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - content = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 1); - array = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - index = g_dec_context_convert_register(ctx, operand, false, addr); - - access = g_array_access_new(G_DEC_EXPRESSION(array), G_DEC_EXPRESSION(index)); - result = g_assign_expression_new(G_DEC_EXPRESSION(access), G_DEC_EXPRESSION(content)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/arithm.c b/src/arch/dalvik/decomp/arithm.c deleted file mode 100644 index 32e105e..0000000 --- a/src/arch/dalvik/decomp/arithm.c +++ /dev/null @@ -1,253 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * arithm.c - décompilation des opérations arithmétiques - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../instruction.h" -#include "../../../decomp/expr/arithm.h" -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/immediate.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'opérations arithmétiques'.* -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - ArithmOperationType type; /* Type d'opération menée */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *op1; /* Premier opérande utilisé */ - GDecInstruction *op2; /* Second opérande utilisé */ - GDecInstruction *dest; /* Enregistrement du résultat */ - GDecInstruction *arithm; /* Opération arithmétique */ - - switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) - { - case DOP_ADD_INT: - type = AOT_ADD; - break; - case DOP_SUB_INT: - type = AOT_SUB; - break; - case DOP_MUL_INT: - type = AOT_MUL; - break; - case DOP_DIV_INT: - type = AOT_DIV; - break; - case DOP_REM_INT: - type = AOT_REM; - break; - case DOP_AND_INT: - type = AOT_AND; - break; - case DOP_OR_INT: - type = AOT_OR; - break; - case DOP_XOR_INT: - type = AOT_XOR; - break; - default: - type = AOT_COUNT; - break; - } - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - op1 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - op2 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2)); - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'opérations arithmétiques'.* -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - ArithmOperationType type; /* Type d'opération menée */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *op1; /* Premier opérande utilisé */ - GDecInstruction *op2; /* Second opérande utilisé */ - GDecInstruction *dest; /* Enregistrement du résultat */ - GDecInstruction *arithm; /* Opération arithmétique */ - - switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) - { - case DOP_ADD_INT_2ADDR: - type = AOT_ADD; - break; - case DOP_MUL_INT_2ADDR: - case DOP_MUL_DOUBLE_2ADDR: - type = AOT_MUL; - break; - case DOP_DIV_INT_2ADDR: - type = AOT_DIV; - break; - case DOP_REM_INT_2ADDR: - type = AOT_REM; - break; - case DOP_AND_INT_2ADDR: - type = AOT_AND; - break; - case DOP_OR_INT_2ADDR: - type = AOT_OR; - break; - case DOP_XOR_INT_2ADDR: - type = AOT_XOR; - break; - default: - type = AOT_COUNT; - break; - } - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - op2 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 0); - op1 = g_dec_context_convert_register(ctx, operand, false, addr); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2)); - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'opérations arithmétiques'.* -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - ArithmOperationType type; /* Type d'opération menée */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *op1; /* Premier opérande utilisé */ - GDecInstruction *op2; /* Second opérande utilisé */ - GDecInstruction *dest; /* Enregistrement du résultat */ - GDecInstruction *arithm; /* Opération arithmétique */ - - switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) - { - case DOP_ADD_INT_LIT8: - case DOP_ADD_INT_LIT16: - type = AOT_ADD; - break; - case DOP_MUL_INT_LIT8: - case DOP_MUL_INT_LIT16: - type = AOT_MUL; - break; - case DOP_DIV_INT_LIT8: - case DOP_DIV_INT_LIT16: - type = AOT_DIV; - break; - case DOP_REM_INT_LIT8: - case DOP_REM_INT_LIT16: - type = AOT_REM; - break; - case DOP_AND_INT_LIT8: - case DOP_AND_INT_LIT16: - type = AOT_AND; - break; - case DOP_OR_INT_LIT8: - case DOP_OR_INT_LIT16: - type = AOT_OR; - break; - case DOP_XOR_INT_LIT8: - case DOP_XOR_INT_LIT16: - type = AOT_XOR; - break; - default: - type = AOT_COUNT; - break; - } - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - op1 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - op2 = g_imm_expression_new(G_IMM_OPERAND(operand)); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2)); - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/array.c b/src/arch/dalvik/decomp/array.c deleted file mode 100644 index 2cb9808..0000000 --- a/src/arch/dalvik/decomp/array.c +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * array.c - décompilation de l'opération récupérant la longueur d'un tableau - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/dalvik/array.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'array-length'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *reg; /* Pseudo-registre redéfini */ - GDecInstruction *len; /* Enregistrement de taille */ - GDecInstruction *dest; /* Destination de la création */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - reg = g_dec_context_convert_register(ctx, operand, false, addr); - len = g_dalvik_alength_new(G_DEC_EXPRESSION(reg)); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(len)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/const.c b/src/arch/dalvik/decomp/const.c deleted file mode 100644 index 29cd29d..0000000 --- a/src/arch/dalvik/decomp/const.c +++ /dev/null @@ -1,110 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * const.c - décompilation des chargements de constantes - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../operands/pool.h" -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/immediate.h" -#include "../../../decomp/expr/text.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'const'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *reg; /* Pseudo-registre redéfini */ - GDecInstruction *imm; /* Valeur immédiate décompilée */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - reg = g_dec_context_convert_register(ctx, operand, true, addr); - - operand = g_arch_instruction_get_operand(instr, 1); - imm = g_imm_expression_new(G_IMM_OPERAND(operand)); - - result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(imm)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'const-string'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *reg; /* Pseudo-registre redéfini */ - uint32_t index; /* Indice de la chaîne */ - const char *value; /* Chaîne de caractères */ - GDecInstruction *str; /* Chaîne décompilée */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - reg = g_dec_context_convert_register(ctx, operand, true, addr); - - operand = g_arch_instruction_get_operand(instr, 1); - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - - value = get_string_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - if (value == NULL) return NULL; - - str = g_str_expression_new(value); - - result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(str)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/if.c b/src/arch/dalvik/decomp/if.c deleted file mode 100644 index 7e17b8d..0000000 --- a/src/arch/dalvik/decomp/if.c +++ /dev/null @@ -1,173 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * if.c - décompilation des branchements conditionnels - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../instruction.h" -#include "../../../decomp/expr/comp.h" -#include "../../../decomp/expr/cond.h" -#include "../../../decomp/expr/immediate.h" -#include "../../../decomp/instr/ite.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de branchement conditionnel. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - CompSignType sign; /* Type d'opération menée */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *op1; /* Premier opérande utilisé */ - GDecInstruction *op2; /* Second opérande utilisé */ - vmpa_t jmp; /* Adresse de saut */ - GDecInstruction *comp; /* Comparaison à restituer */ - GDecInstruction *cond; /* Transformation en condition */ - - switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) - { - case DOP_IF_EQ: - sign = CST_EQ; - break; - case DOP_IF_NE: - sign = CST_NE; - break; - case DOP_IF_LT: - sign = CST_LT; - break; - case DOP_IF_GE: - sign = CST_GE; - break; - case DOP_IF_GT: - sign = CST_GT; - break; - case DOP_IF_LE: - sign = CST_LE; - break; - default: - sign = CST_COUNT; - break; - } - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - op1 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 1); - op2 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand, addr);*/ - - comp = g_comp_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2)); - cond = g_cond_expression_new(comp); - result = g_ite_instruction_new(cond, jmp, jmp); - - return result; - -} - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de branchement conditionnel. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_if_zero(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - CompSignType sign; /* Type d'opération menée */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *op1; /* Premier opérande utilisé */ - GDecInstruction *op2; /* Second opérande utilisé */ - vmpa_t jmp; /* Adresse de saut */ - GDecInstruction *comp; /* Comparaison à restituer */ - GDecInstruction *cond; /* Transformation en condition */ - - switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr))) - { - case DOP_IF_EQZ: - sign = CST_EQ; - break; - case DOP_IF_NEZ: - sign = CST_NE; - break; - case DOP_IF_LTZ: - sign = CST_LT; - break; - case DOP_IF_GEZ: - sign = CST_GE; - break; - case DOP_IF_GTZ: - sign = CST_GT; - break; - case DOP_IF_LEZ: - sign = CST_LE; - break; - default: - sign = CST_COUNT; - break; - } - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - op1 = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, (unsigned int)0); - op2 = g_imm_expression_new(G_IMM_OPERAND(operand)); - - operand = g_arch_instruction_get_operand(instr, 2); - jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand, addr);*/ - - comp = g_comp_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2)); - cond = g_cond_expression_new(comp); - result = g_ite_instruction_new(cond, jmp, jmp); - - return result; - -} diff --git a/src/arch/dalvik/decomp/iget.c b/src/arch/dalvik/decomp/iget.c deleted file mode 100644 index 3fbaa7c..0000000 --- a/src/arch/dalvik/decomp/iget.c +++ /dev/null @@ -1,79 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * iget.c - décompilation des instructions manipulant des champs d'instance (chargement) - * - * Copyright (C) 2012-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../arch/dalvik/operands/pool.h" -#include "../../../decomp/expr/access.h" -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/pseudo.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'iget'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *src; /* Registre de l'object */ - uint32_t index; /* Indice dans la table */ - GDecInstruction *field; /* Champ concerné par l'opérat°*/ - GBinVariable *var; /* Variable / champ accédé */ - GDecInstruction *dest; /* Registre de destination */ - GDecInstruction *access; /* Représentation de l'accès */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - src = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - var = get_field_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - - field = g_pseudo_register_new(PRU_FIXED); - g_pseudo_register_set_variable(G_PSEUDO_REGISTER(field), var); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - access = g_access_expression_new(G_DEC_EXPRESSION(src), G_DEC_EXPRESSION(field)); - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(access)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/invoke.c b/src/arch/dalvik/decomp/invoke.c deleted file mode 100644 index e747ac2..0000000 --- a/src/arch/dalvik/decomp/invoke.c +++ /dev/null @@ -1,271 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * invoke.c - décompilation des appels de méthode - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include <string.h> - - -#include "../instruction.h" -#include "../operand.h" -#include "../../../decomp/expr/access.h" -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/call.h" -#include "../../../format/dex/pool.h" - - -#define get_routine_from_dex_pool(p, i) NULL - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'invoke-direct'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - GDecInstruction *iter; /* Boucle de parcours #1 */ - GDecInstruction *list; /* Instructions décompilées */ - size_t count; /* Quantité d'opérandes */ - GArchOperand *operand; /* Opérande de l'instruction */ - uint32_t index; /* Indice de l'élément visé */ - GBinRoutine *routine; /* Routine visée par l'appel */ - const char *name; /* Chaîne à afficher */ - GDecInstruction *src; /* Source de l'assignation */ - GDecInstruction *dest; /* Destination de l'assignat° */ - vmpa_t addr; /* Adresse de l'instruction */ - size_t i; /* Boucle de parcours #2 */ - GArchOperand *arg; /* Argument brut de l'appel */ - GDecInstruction *reg; /* Argument converti */ - - result = NULL; - iter = NULL; - - list = g_dec_context_get_decomp_instrs(ctx); - if (list == NULL) return NULL; - - /* Récupération de la méthode */ - - count = g_arch_instruction_count_operands(instr); - operand = g_arch_instruction_get_operand(instr, count - 1); - - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - - routine = get_routine_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - if (routine == NULL) return NULL; - - /* Détermination de la routine-cible exacte */ - - name = g_binary_routine_get_name(routine); - - if (strcmp(name, "<init>") != 0) - result = g_routine_call_new(routine); - - else - { - src = NULL; /* Pour gcc... */ - - for (iter = g_dec_instruction_get_last(list); - iter != NULL; - iter = g_dec_instruction_get_prev_iter(list, iter)) - { - if (!G_IS_ASSIGN_EXPRESSION(iter)) continue; - - src = g_assign_expression_get_src(G_ASSIGN_EXPRESSION(iter)); - if (!G_IS_ROUTINE_CALL(src)) continue; - - dest = g_assign_expression_get_dest(G_ASSIGN_EXPRESSION(iter)); - /* TODO : vérifier aussi la concordance des registres src && instr */ - - break; - - } - - if (iter == NULL) return NULL; - - result = src; - - g_dec_instruction_delete(&list, iter); - g_dec_context_set_decomp_instrs(ctx, list); - - } - - /* Ajout des arguments */ - - operand = g_arch_instruction_get_operand(instr, 0); - count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand)); - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - for (i = 1; i < count; i++) - { - arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), i); - reg = g_dec_context_convert_register(ctx, arg, false, addr); - - g_routine_call_add_arg(G_ROUTINE_CALL(result), reg); - - } - - return (iter != NULL ? iter : result); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'invoke-static'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_invoke_static(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - size_t count; /* Quantité d'opérandes */ - GArchOperand *operand; /* Opérande de l'instruction */ - uint32_t index; /* Indice de l'élément visé */ - GBinRoutine *routine; /* Routine visée par l'appel */ - GDecInstruction *call; /* Représentation de l'appel */ - vmpa_t addr; /* Adresse de l'instruction */ - size_t i; /* Boucle de parcours #2 */ - GArchOperand *arg; /* Argument brut de l'appel */ - GDecInstruction *reg; /* Argument converti */ - - result = NULL; - - /* Récupération de la méthode */ - - count = g_arch_instruction_count_operands(instr); - operand = g_arch_instruction_get_operand(instr, count - 1); - - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - - routine = get_routine_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - if (routine == NULL) return NULL; - - call = g_routine_call_new(routine); - - /* Ajout des arguments */ - - operand = g_arch_instruction_get_operand(instr, 0); - count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand)); - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - for (i = 0; i < count; i++) - { - arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), i); - reg = g_dec_context_convert_register(ctx, arg, false, addr); - - g_routine_call_add_arg(G_ROUTINE_CALL(call), reg); - - } - - return call; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'invoke-virtual'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - size_t count; /* Quantité d'opérandes */ - GArchOperand *operand; /* Opérande de l'instruction */ - uint32_t index; /* Indice de l'élément visé */ - GBinRoutine *routine; /* Routine visée par l'appel */ - GDecInstruction *call; /* Représentation de l'appel */ - vmpa_t addr; /* Adresse de l'instruction */ - size_t i; /* Boucle de parcours #2 */ - GArchOperand *arg; /* Argument brut de l'appel */ - GDecInstruction *reg; /* Argument converti */ - - result = NULL; - - /* Récupération de la méthode */ - - count = g_arch_instruction_count_operands(instr); - operand = g_arch_instruction_get_operand(instr, count - 1); - - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - - routine = get_routine_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - if (routine == NULL) return NULL; - - call = g_routine_call_new(routine); - - /* Ajout des arguments */ - - operand = g_arch_instruction_get_operand(instr, 0); - count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand)); - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - for (i = 1; i < count; i++) - { - arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), i); - reg = g_dec_context_convert_register(ctx, arg, false, addr); - - g_routine_call_add_arg(G_ROUTINE_CALL(call), reg); - - } - - /* Appel depuis le propriétaire */ - - arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), 0); - reg = g_dec_context_convert_register(ctx, arg, false, addr); - - result = g_access_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(call)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/iput.c b/src/arch/dalvik/decomp/iput.c deleted file mode 100644 index e55c7bc..0000000 --- a/src/arch/dalvik/decomp/iput.c +++ /dev/null @@ -1,79 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * iput.c - décompilation des instructions manipulant des champs d'instance (déchargement) - * - * Copyright (C) 2012-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../arch/dalvik/operands/pool.h" -#include "../../../decomp/expr/access.h" -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/pseudo.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'iput'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *dest; /* Registre de destination */ - GDecInstruction *src; /* Registre de l'object */ - uint32_t index; /* Indice dans la table */ - GDecInstruction *field; /* Champ concerné par l'opérat°*/ - GBinVariable *var; /* Variable / champ accédé */ - GDecInstruction *access; /* Représentation de l'accès */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - src = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 1); - dest = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 2); - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - var = get_field_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - - field = g_pseudo_register_new(PRU_FIXED); - g_pseudo_register_set_variable(G_PSEUDO_REGISTER(field), var); - - access = g_access_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(field)); - result = g_assign_expression_new(G_DEC_EXPRESSION(access), G_DEC_EXPRESSION(src)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/move.c b/src/arch/dalvik/decomp/move.c deleted file mode 100644 index b147daf..0000000 --- a/src/arch/dalvik/decomp/move.c +++ /dev/null @@ -1,141 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * move.c - décompilation des opérations de déplacement - * - * Copyright (C) 2012-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../decomp/expr/assign.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'move'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_move(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *src; /* Registre de l'object */ - GDecInstruction *dest; /* Registre de destination */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - src = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(src)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'move-object'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_move_object(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *src; /* Registre de l'object */ - GDecInstruction *dest; /* Registre de destination */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - src = g_dec_context_convert_register(ctx, operand, false, addr); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(src)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'move-result'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_move_result(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - GDecInstruction *list; /* Instructions décompilées */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *last; /* Instruction précédante */ - GDecInstruction *dest; /* Registre de destination */ - - list = g_dec_context_get_decomp_instrs(ctx); - if (list == NULL) return NULL; - - last = g_dec_instruction_get_last(list); - g_dec_instruction_delete(&list, last); - g_dec_context_set_decomp_instrs(ctx, list); - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(last)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/new.c b/src/arch/dalvik/decomp/new.c deleted file mode 100644 index ef143ff..0000000 --- a/src/arch/dalvik/decomp/new.c +++ /dev/null @@ -1,73 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * new.c - décompilation des créations de nouvelles instances - * - * Copyright (C) 2012-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../arch/dalvik/operands/pool.h" -#include "../../../decomp/expr/assign.h" -#include "../../../decomp/expr/call.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'new-instance'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - uint32_t index; /* Indice dans la table */ - GDataType *type; /* Type concerné par l'opérat° */ - GBinRoutine *constructor; /* Constructeur reconstruit */ - GDecInstruction *call; /* Appel au constructeur */ - GDecInstruction *dest; /* Registre de destination */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 1); - index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand)); - type = get_type_from_dex_pool(G_DEX_FORMAT(g_dec_context_get_format(ctx)), index); - - constructor = g_binary_routine_new_constructor(type); - call = g_routine_call_new(constructor); - - operand = g_arch_instruction_get_operand(instr, 0); - dest = g_dec_context_convert_register(ctx, operand, true, addr); - - result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(call)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/ret.c b/src/arch/dalvik/decomp/ret.c deleted file mode 100644 index ab2f299..0000000 --- a/src/arch/dalvik/decomp/ret.c +++ /dev/null @@ -1,84 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ret.c - décompilation des ordres de retour - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - -#include "../../../decomp/expr/return.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'return'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_return(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *reg; /* Pseudo-registre redéfini */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - reg = g_dec_context_convert_register(ctx, operand, false, addr); - - result = g_return_expression_new(G_DEC_EXPRESSION(reg)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction de type 'return-void'. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_return_void(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - - result = g_return_expression_new(NULL); - - return result; - -} diff --git a/src/arch/dalvik/decomp/switch.c b/src/arch/dalvik/decomp/switch.c deleted file mode 100644 index 25501da..0000000 --- a/src/arch/dalvik/decomp/switch.c +++ /dev/null @@ -1,62 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * switch.c - décompilation des aiguillages multiples du flot d'exécution - * - * Copyright (C) 2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "translate.h" - - - -#include "../instruction.h" -#include "../../../decomp/instr/switch.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'origine à convertir. * -* ctx = contexte de la phase de décompilation. * -* * -* Description : Décompile une instruction d'aiguillages multiples du flux. * -* * -* Retour : Instruction mise en place ou NULL. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GDecInstruction *dalvik_decomp_instr_switch(const GArchInstruction *instr, GDecContext *ctx) -{ - GDecInstruction *result; /* Instruction à retourner */ - vmpa_t addr; /* Adresse de l'instruction */ - GArchOperand *operand; /* Opérande de l'instruction */ - GDecInstruction *val; /* Valeur décidant du flot */ - - g_arch_instruction_get_location(instr, NULL, NULL, &addr); - - operand = g_arch_instruction_get_operand(instr, 0); - val = g_dec_context_convert_register(ctx, operand, false, addr); - - result = g_switch_instruction_new(G_DEC_EXPRESSION(val)); - - return result; - -} diff --git a/src/arch/dalvik/decomp/translate.h b/src/arch/dalvik/decomp/translate.h deleted file mode 100644 index ff55a39..0000000 --- a/src/arch/dalvik/decomp/translate.h +++ /dev/null @@ -1,101 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * translate.h - prototypes pour les environnements de traduction d'instructions Dalvik - * - * Copyright (C) 2010-2013 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _ANALYSIS_DECOMP_RTL_DALVIK_TRANSLATE_H -#define _ANALYSIS_DECOMP_RTL_DALVIK_TRANSLATE_H - - -#include "../../translate.h" - - - -/* Décompile une instruction de type 'aget'. */ -GDecInstruction *dalvik_decomp_instr_aget(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'aput'. */ -GDecInstruction *dalvik_decomp_instr_aput(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'array-length'. */ -GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'const'. */ -GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'const-string'. */ -GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'iget'. */ -GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'invoke-direct'. */ -GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'invoke-static'. */ -GDecInstruction *dalvik_decomp_instr_invoke_static(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'invoke-virtual'. */ -GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'iput'. */ -GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'move'. */ -GDecInstruction *dalvik_decomp_instr_move(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'move-object'. */ -GDecInstruction *dalvik_decomp_instr_move_object(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'move-result'. */ -GDecInstruction *dalvik_decomp_instr_move_result(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'new-instance'. */ -GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'return'. */ -GDecInstruction *dalvik_decomp_instr_return(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'return-void'. */ -GDecInstruction *dalvik_decomp_instr_return_void(const GArchInstruction *, GDecContext *); - - -/* Décompile une instruction de type 'opérations arithmétiques'. */ -GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'opérations arithmétiques'. */ -GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de type 'opérations arithmétiques'. */ -GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de branchement conditionnel. */ -GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction de branchement conditionnel. */ -GDecInstruction *dalvik_decomp_instr_if_zero(const GArchInstruction *, GDecContext *); - -/* Décompile une instruction d'aiguillages multiples du flux. */ -GDecInstruction *dalvik_decomp_instr_switch(const GArchInstruction *, GDecContext *); - - - -#endif /* _ANALYSIS_DECOMP_RTL_DALVIK_TRANSLATE_H */ diff --git a/src/arch/dalvik/instruction.c b/src/arch/dalvik/instruction.c index e3ece11..cc1cab2 100644 --- a/src/arch/dalvik/instruction.c +++ b/src/arch/dalvik/instruction.c @@ -28,7 +28,6 @@ #include "instruction-int.h" -#include "decomp/translate.h" #include "operands/register.h" #include "../instruction-int.h" #include "../register-int.h" @@ -65,7 +64,8 @@ typedef struct _dalvik_instruction const char *keyword; /* Mot clef de la commande */ - decomp_instr_fc decomp; /* Procédure de décompilation */ + void *ptr; + //decomp_instr_fc decomp; /* Procédure de décompilation */ } dalvik_instruction; @@ -73,40 +73,40 @@ typedef struct _dalvik_instruction static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_NOP] = { 0x00, "nop", NULL }, - [DOP_MOVE] = { 0x01, "move", dalvik_decomp_instr_move }, + [DOP_MOVE] = { 0x01, "move", NULL }, [DOP_MOVE_FROM_16] = { 0x02, "move/from16" }, [DOP_MOVE_16] = { 0x03, "move/16" }, [DOP_MOVE_WIDE] = { 0x04, "move-wide" }, [DOP_MOVE_WIDE_FROM_16] = { 0x05, "move-wide/from16" }, [DOP_MOVE_WIDE_16] = { 0x06, "move-wide/16" }, - [DOP_MOVE_OBJECT] = { 0x07, "move-object", dalvik_decomp_instr_move_object }, + [DOP_MOVE_OBJECT] = { 0x07, "move-object", NULL }, [DOP_MOVE_OBJECT_FROM_16] = { 0x08, "move-object/from16" }, [DOP_MOVE_OBJECT_16] = { 0x09, "move-object/16" }, - [DOP_MOVE_RESULT] = { 0x0a, "move-result", dalvik_decomp_instr_move_result }, - [DOP_MOVE_RESULT_WIDE] = { 0x0b, "move-result-wide", dalvik_decomp_instr_move_result }, - [DOP_MOVE_RESULT_OBJECT] = { 0x0c, "move-result-object", dalvik_decomp_instr_move_result }, + [DOP_MOVE_RESULT] = { 0x0a, "move-result", NULL }, + [DOP_MOVE_RESULT_WIDE] = { 0x0b, "move-result-wide", NULL }, + [DOP_MOVE_RESULT_OBJECT] = { 0x0c, "move-result-object", NULL }, [DOP_MOVE_EXCEPTION] = { 0x0d, "move-exception" }, - [DOP_RETURN_VOID] = { 0x0e, "return-void", dalvik_decomp_instr_return_void }, - [DOP_RETURN] = { 0x0f, "return", dalvik_decomp_instr_return }, - [DOP_RETURN_WIDE] = { 0x10, "return-wide", dalvik_decomp_instr_return }, - [DOP_RETURN_OBJECT] = { 0x11, "return-object", dalvik_decomp_instr_return }, - [DOP_CONST_4] = { 0x12, "const/4", dalvik_decomp_instr_const }, - [DOP_CONST_16] = { 0x13, "const/16", dalvik_decomp_instr_const }, + [DOP_RETURN_VOID] = { 0x0e, "return-void", NULL }, + [DOP_RETURN] = { 0x0f, "return", NULL }, + [DOP_RETURN_WIDE] = { 0x10, "return-wide", NULL }, + [DOP_RETURN_OBJECT] = { 0x11, "return-object", NULL }, + [DOP_CONST_4] = { 0x12, "const/4", NULL }, + [DOP_CONST_16] = { 0x13, "const/16", NULL }, [DOP_CONST] = { 0x14, "const" }, [DOP_CONST_HIGH16] = { 0x15, "const/high16" }, [DOP_CONST_WIDE_16] = { 0x16, "const-wide/16" }, [DOP_CONST_WIDE_32] = { 0x17, "const-wide/32" }, [DOP_CONST_WIDE] = { 0x18, "const-wide" }, [DOP_CONST_WIDE_HIGH16] = { 0x19, "const-wide/high16" }, - [DOP_CONST_STRING] = { 0x1a, "const-string", dalvik_decomp_instr_const_str }, + [DOP_CONST_STRING] = { 0x1a, "const-string", NULL }, [DOP_CONST_STRING_JUMBO] = { 0x1b, "const-string/jumbo" }, [DOP_CONST_CLASS] = { 0x1c, "const-class" }, [DOP_MONITOR_ENTER] = { 0x1d, "monitor-enter" }, [DOP_MONITOR_EXIT] = { 0x1e, "monitor-exit" }, [DOP_CHECK_CAST] = { 0x1f, "check-cast" }, [DOP_INSTANCE_OF] = { 0x20, "instance-of" }, - [DOP_ARRAY_LENGTH] = { 0x21, "array-length", dalvik_decomp_instr_array_length }, - [DOP_NEW_INSTANCE] = { 0x22, "new-instance", dalvik_decomp_instr_new_instance }, + [DOP_ARRAY_LENGTH] = { 0x21, "array-length", NULL }, + [DOP_NEW_INSTANCE] = { 0x22, "new-instance", NULL }, [DOP_NEW_ARRAY] = { 0x23, "new-array" }, [DOP_FILLED_NEW_ARRAY] = { 0x24, "fill-new-array" }, [DOP_FILLED_NEW_ARRAY_RANGE]= { 0x25, "fill-new-array/range" }, @@ -115,25 +115,25 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_GOTO] = { 0x28, "goto" }, [DOP_GOTO_16] = { 0x29, "goto/16" }, [DOP_GOTO_32] = { 0x2a, "goto/32" }, - [DOP_PACKED_SWITCH] = { 0x2b, "packed-switch", dalvik_decomp_instr_switch }, - [DOP_SPARSE_SWITCH] = { 0x2c, "sparse-switch", dalvik_decomp_instr_switch }, + [DOP_PACKED_SWITCH] = { 0x2b, "packed-switch", NULL }, + [DOP_SPARSE_SWITCH] = { 0x2c, "sparse-switch", NULL }, [DOP_CMPL_FLOAT] = { 0x2d, "cmp-long" }, [DOP_CMPG_FLOAT] = { 0x2e, "cmpg-float" }, [DOP_CMPL_DOUBLE] = { 0x2f, "cmpl-double" }, [DOP_CMPG_DOUBLE] = { 0x30, "cmpg-double" }, [DOP_CMP_LONG] = { 0x31, "cmp-long" }, - [DOP_IF_EQ] = { 0x32, "if-eq", dalvik_decomp_instr_if }, - [DOP_IF_NE] = { 0x33, "if-ne", dalvik_decomp_instr_if }, - [DOP_IF_LT] = { 0x34, "if-lt", dalvik_decomp_instr_if }, - [DOP_IF_GE] = { 0x35, "if-ge", dalvik_decomp_instr_if }, - [DOP_IF_GT] = { 0x36, "if-gt", dalvik_decomp_instr_if }, - [DOP_IF_LE] = { 0x37, "if-le", dalvik_decomp_instr_if }, - [DOP_IF_EQZ] = { 0x38, "if-eqz", dalvik_decomp_instr_if_zero }, - [DOP_IF_NEZ] = { 0x39, "if-nez", dalvik_decomp_instr_if_zero }, - [DOP_IF_LTZ] = { 0x3a, "if-ltz", dalvik_decomp_instr_if_zero }, - [DOP_IF_GEZ] = { 0x3b, "if-gez", dalvik_decomp_instr_if_zero }, - [DOP_IF_GTZ] = { 0x3c, "if-gtz", dalvik_decomp_instr_if_zero }, - [DOP_IF_LEZ] = { 0x3d, "if-lez", dalvik_decomp_instr_if_zero }, + [DOP_IF_EQ] = { 0x32, "if-eq", NULL }, + [DOP_IF_NE] = { 0x33, "if-ne", NULL }, + [DOP_IF_LT] = { 0x34, "if-lt", NULL }, + [DOP_IF_GE] = { 0x35, "if-ge", NULL }, + [DOP_IF_GT] = { 0x36, "if-gt", NULL }, + [DOP_IF_LE] = { 0x37, "if-le", NULL }, + [DOP_IF_EQZ] = { 0x38, "if-eqz", NULL }, + [DOP_IF_NEZ] = { 0x39, "if-nez", NULL }, + [DOP_IF_LTZ] = { 0x3a, "if-ltz", NULL }, + [DOP_IF_GEZ] = { 0x3b, "if-gez", NULL }, + [DOP_IF_GTZ] = { 0x3c, "if-gtz", NULL }, + [DOP_IF_LEZ] = { 0x3d, "if-lez", NULL }, [DOP_UNUSED_3E] = { 0x3e, NULL /* unused */ }, [DOP_UNUSED_3F] = { 0x3f, NULL /* unused */ }, [DOP_UNUSED_40] = { 0x40, NULL /* unused */ }, @@ -144,24 +144,24 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_AGET_WIDE] = { 0x45, "aget-wide" }, [DOP_AGET_OBJECT] = { 0x46, "aget-object" }, [DOP_AGET_BOOLEAN] = { 0x47, "aget-boolean" }, - [DOP_AGET_BYTE] = { 0x48, "aget-byte", dalvik_decomp_instr_aget }, + [DOP_AGET_BYTE] = { 0x48, "aget-byte", NULL }, [DOP_AGET_CHAR] = { 0x49, "aget-char" }, [DOP_AGET_SHORT] = { 0x4a, "aget-short" }, [DOP_APUT] = { 0x4b, "aput" }, [DOP_APUT_WIDE] = { 0x4c, "aput-wide" }, [DOP_APUT_OBJECT] = { 0x4d, "aput-object" }, [DOP_APUT_BOOLEAN] = { 0x4e, "aput-boolean" }, - [DOP_APUT_BYTE] = { 0x4f, "aput-byte", dalvik_decomp_instr_aput }, + [DOP_APUT_BYTE] = { 0x4f, "aput-byte", NULL }, [DOP_APUT_CHAR] = { 0x50, "aput-char" }, [DOP_APUT_SHORT] = { 0x51, "aput-short" }, - [DOP_IGET] = { 0x52, "iget", dalvik_decomp_instr_iget }, + [DOP_IGET] = { 0x52, "iget", NULL }, [DOP_IGET_WIDE] = { 0x53, "iget-wide" }, [DOP_IGET_OBJECT] = { 0x54, "iget-object" }, [DOP_IGET_BOOLEAN] = { 0x55, "iget-boolean" }, [DOP_IGET_BYTE] = { 0x56, "iget-byte" }, [DOP_IGET_CHAR] = { 0x57, "iget-char" }, [DOP_IGET_SHORT] = { 0x58, "iget-short" }, - [DOP_IPUT] = { 0x59, "iput", dalvik_decomp_instr_iput }, + [DOP_IPUT] = { 0x59, "iput", NULL }, [DOP_IPUT_WIDE] = { 0x5a, "iput-wide" }, [DOP_IPUT_OBJECT] = { 0x5b, "iput-object" }, [DOP_IPUT_BOOLEAN] = { 0x5c, "iput-boolean" }, @@ -182,10 +182,10 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_SPUT_BYTE] = { 0x6b, "sput-byte" }, [DOP_SPUT_CHAR] = { 0x6c, "sput-char" }, [DOP_SPUT_SHORT] = { 0x6d, "sput-short" }, - [DOP_INVOKE_VIRTUAL] = { 0x6e, "invoke-virtual", dalvik_decomp_instr_invoke_virtual }, + [DOP_INVOKE_VIRTUAL] = { 0x6e, "invoke-virtual", NULL }, [DOP_INVOKE_SUPER] = { 0x6f, "invoke-static" }, - [DOP_INVOKE_DIRECT] = { 0x70, "invoke-direct", dalvik_decomp_instr_invoke_direct }, - [DOP_INVOKE_STATIC] = { 0x71, "invoke-static", dalvik_decomp_instr_invoke_static }, + [DOP_INVOKE_DIRECT] = { 0x70, "invoke-direct", NULL }, + [DOP_INVOKE_STATIC] = { 0x71, "invoke-static", NULL }, [DOP_INVOKE_INTERFACE] = { 0x72, "invoke-interface" }, [DOP_UNUSED_73] = { 0x73, NULL /* unused */ }, [DOP_INVOKE_VIRTUAL_RANGE] = { 0x74, "invoke-virtual/range" }, @@ -216,14 +216,14 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_TO_INT_BYTE] = { 0x8d, "int-to-byte" }, [DOP_TO_INT_CHAR] = { 0x8e, "int-to-char" }, [DOP_TO_INT_SHORT] = { 0x8f, "int-to-short" }, - [DOP_ADD_INT] = { 0x90, "add-int", dalvik_decomp_instr_arithm }, - [DOP_SUB_INT] = { 0x91, "sub-int", dalvik_decomp_instr_arithm }, - [DOP_MUL_INT] = { 0x92, "mul-int", dalvik_decomp_instr_arithm }, - [DOP_DIV_INT] = { 0x93, "div-int", dalvik_decomp_instr_arithm }, - [DOP_REM_INT] = { 0x94, "rem-int", dalvik_decomp_instr_arithm }, - [DOP_AND_INT] = { 0x95, "and-int", dalvik_decomp_instr_arithm }, - [DOP_OR_INT] = { 0x96, "or-int", dalvik_decomp_instr_arithm }, - [DOP_XOR_INT] = { 0x97, "xor-int", dalvik_decomp_instr_arithm }, + [DOP_ADD_INT] = { 0x90, "add-int", NULL }, + [DOP_SUB_INT] = { 0x91, "sub-int", NULL }, + [DOP_MUL_INT] = { 0x92, "mul-int", NULL }, + [DOP_DIV_INT] = { 0x93, "div-int", NULL }, + [DOP_REM_INT] = { 0x94, "rem-int", NULL }, + [DOP_AND_INT] = { 0x95, "and-int", NULL }, + [DOP_OR_INT] = { 0x96, "or-int", NULL }, + [DOP_XOR_INT] = { 0x97, "xor-int", NULL }, [DOP_SHL_INT] = { 0x98, "shl-int" }, [DOP_SHR_INT] = { 0x99, "shr-int" }, [DOP_USHR_INT] = { 0x9a, "ushr-int" }, @@ -248,54 +248,54 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_MUL_DOUBLE] = { 0xad, "mul-double" }, [DOP_DIV_DOUBLE] = { 0xae, "div-double" }, [DOP_REM_DOUBLE] = { 0xaf, "rem-double" }, - [DOP_ADD_INT_2ADDR] = { 0xb0, "add-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SUB_INT_2ADDR] = { 0xb1, "sub-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_MUL_INT_2ADDR] = { 0xb2, "mul-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_DIV_INT_2ADDR] = { 0xb3, "div-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_REM_INT_2ADDR] = { 0xb4, "rem-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_AND_INT_2ADDR] = { 0xb5, "and-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_OR_INT_2ADDR] = { 0xb6, "or-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_XOR_INT_2ADDR] = { 0xb7, "xor-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SHL_INT_2ADDR] = { 0xb8, "shl-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SHR_INT_2ADDR] = { 0xb9, "shr-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_USHR_INT_2ADDR] = { 0xba, "ushr-int/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_ADD_LONG_2ADDR] = { 0xbb, "add-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SUB_LONG_2ADDR] = { 0xbc, "sub-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_MUL_LONG_2ADDR] = { 0xbd, "mul-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_DIV_LONG_2ADDR] = { 0xbe, "div-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_REM_LONG_2ADDR] = { 0xbf, "rem-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_AND_LONG_2ADDR] = { 0xc0, "and-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_OR_LONG_2ADDR] = { 0xc1, "or-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_XOR_LONG_2ADDR] = { 0xc2, "xor-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SHL_LONG_2ADDR] = { 0xc3, "shl-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SHR_LONG_2ADDR] = { 0xc4, "shr-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_USHR_LONG_2ADDR] = { 0xc5, "ushr-long/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_ADD_FLOAT_2ADDR] = { 0xc6, "add-float/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SUB_FLOAT_2ADDR] = { 0xc7, "sub-float/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_MUL_FLOAT_2ADDR] = { 0xc8, "mul-float/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_DIV_FLOAT_2ADDR] = { 0xc9, "div-float/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_REM_FLOAT_2ADDR] = { 0xca, "rem-float/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_ADD_DOUBLE_2ADDR] = { 0xcb, "add-double/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_SUB_DOUBLE_2ADDR] = { 0xcc, "sub-double/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_MUL_DOUBLE_2ADDR] = { 0xcd, "mul-double/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_DIV_DOUBLE_2ADDR] = { 0xce, "div-double/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_REM_DOUBLE_2ADDR] = { 0xcf, "rem-double/2addr", dalvik_decomp_instr_arithm_2addr }, - [DOP_ADD_INT_LIT16] = { 0xd0, "add-int/lit16", dalvik_decomp_instr_arithm_lit }, + [DOP_ADD_INT_2ADDR] = { 0xb0, "add-int/2addr", NULL }, + [DOP_SUB_INT_2ADDR] = { 0xb1, "sub-int/2addr", NULL }, + [DOP_MUL_INT_2ADDR] = { 0xb2, "mul-int/2addr", NULL }, + [DOP_DIV_INT_2ADDR] = { 0xb3, "div-int/2addr", NULL }, + [DOP_REM_INT_2ADDR] = { 0xb4, "rem-int/2addr", NULL }, + [DOP_AND_INT_2ADDR] = { 0xb5, "and-int/2addr", NULL }, + [DOP_OR_INT_2ADDR] = { 0xb6, "or-int/2addr", NULL }, + [DOP_XOR_INT_2ADDR] = { 0xb7, "xor-int/2addr", NULL }, + [DOP_SHL_INT_2ADDR] = { 0xb8, "shl-int/2addr", NULL }, + [DOP_SHR_INT_2ADDR] = { 0xb9, "shr-int/2addr", NULL }, + [DOP_USHR_INT_2ADDR] = { 0xba, "ushr-int/2addr", NULL }, + [DOP_ADD_LONG_2ADDR] = { 0xbb, "add-long/2addr", NULL }, + [DOP_SUB_LONG_2ADDR] = { 0xbc, "sub-long/2addr", NULL }, + [DOP_MUL_LONG_2ADDR] = { 0xbd, "mul-long/2addr", NULL }, + [DOP_DIV_LONG_2ADDR] = { 0xbe, "div-long/2addr", NULL }, + [DOP_REM_LONG_2ADDR] = { 0xbf, "rem-long/2addr", NULL }, + [DOP_AND_LONG_2ADDR] = { 0xc0, "and-long/2addr", NULL }, + [DOP_OR_LONG_2ADDR] = { 0xc1, "or-long/2addr", NULL }, + [DOP_XOR_LONG_2ADDR] = { 0xc2, "xor-long/2addr", NULL }, + [DOP_SHL_LONG_2ADDR] = { 0xc3, "shl-long/2addr", NULL }, + [DOP_SHR_LONG_2ADDR] = { 0xc4, "shr-long/2addr", NULL }, + [DOP_USHR_LONG_2ADDR] = { 0xc5, "ushr-long/2addr", NULL }, + [DOP_ADD_FLOAT_2ADDR] = { 0xc6, "add-float/2addr", NULL }, + [DOP_SUB_FLOAT_2ADDR] = { 0xc7, "sub-float/2addr", NULL }, + [DOP_MUL_FLOAT_2ADDR] = { 0xc8, "mul-float/2addr", NULL }, + [DOP_DIV_FLOAT_2ADDR] = { 0xc9, "div-float/2addr", NULL }, + [DOP_REM_FLOAT_2ADDR] = { 0xca, "rem-float/2addr", NULL }, + [DOP_ADD_DOUBLE_2ADDR] = { 0xcb, "add-double/2addr", NULL }, + [DOP_SUB_DOUBLE_2ADDR] = { 0xcc, "sub-double/2addr", NULL }, + [DOP_MUL_DOUBLE_2ADDR] = { 0xcd, "mul-double/2addr", NULL }, + [DOP_DIV_DOUBLE_2ADDR] = { 0xce, "div-double/2addr", NULL }, + [DOP_REM_DOUBLE_2ADDR] = { 0xcf, "rem-double/2addr", NULL }, + [DOP_ADD_INT_LIT16] = { 0xd0, "add-int/lit16", NULL }, [DOP_RSUB_INT] = { 0xd1, "rsub-int" }, - [DOP_MUL_INT_LIT16] = { 0xd2, "mul-int/lit16", dalvik_decomp_instr_arithm_lit }, - [DOP_DIV_INT_LIT16] = { 0xd3, "div-int/lit16", dalvik_decomp_instr_arithm_lit }, - [DOP_REM_INT_LIT16] = { 0xd4, "rem-int/lit16", dalvik_decomp_instr_arithm_lit }, - [DOP_AND_INT_LIT16] = { 0xd5, "and-int/lit16", dalvik_decomp_instr_arithm_lit }, - [DOP_OR_INT_LIT16] = { 0xd6, "or-int/lit16", dalvik_decomp_instr_arithm_lit }, - [DOP_XOR_INT_LIT16] = { 0xd7, "xor-int/lit16", dalvik_decomp_instr_arithm_lit }, - [DOP_ADD_INT_LIT8] = { 0xd8, "add-int/lit8", dalvik_decomp_instr_arithm_lit }, + [DOP_MUL_INT_LIT16] = { 0xd2, "mul-int/lit16", NULL }, + [DOP_DIV_INT_LIT16] = { 0xd3, "div-int/lit16", NULL }, + [DOP_REM_INT_LIT16] = { 0xd4, "rem-int/lit16", NULL }, + [DOP_AND_INT_LIT16] = { 0xd5, "and-int/lit16", NULL }, + [DOP_OR_INT_LIT16] = { 0xd6, "or-int/lit16", NULL }, + [DOP_XOR_INT_LIT16] = { 0xd7, "xor-int/lit16", NULL }, + [DOP_ADD_INT_LIT8] = { 0xd8, "add-int/lit8", NULL }, [DOP_RSUB_INT_LIT8] = { 0xd9, "rsub-int/lit8" }, - [DOP_MUL_INT_LIT8] = { 0xda, "mul-int/lit8", dalvik_decomp_instr_arithm_lit }, - [DOP_DIV_INT_LIT8] = { 0xdb, "div-int/lit8", dalvik_decomp_instr_arithm_lit }, - [DOP_REM_INT_LIT8] = { 0xdc, "rem-int/lit8", dalvik_decomp_instr_arithm_lit }, - [DOP_AND_INT_LIT8] = { 0xdd, "and-int/lit8", dalvik_decomp_instr_arithm_lit }, - [DOP_OR_INT_LIT8] = { 0xde, "or-int/lit8", dalvik_decomp_instr_arithm_lit }, - [DOP_XOR_INT_LIT8] = { 0xdf, "xor-int/lit8", dalvik_decomp_instr_arithm_lit }, + [DOP_MUL_INT_LIT8] = { 0xda, "mul-int/lit8", NULL }, + [DOP_DIV_INT_LIT8] = { 0xdb, "div-int/lit8", NULL }, + [DOP_REM_INT_LIT8] = { 0xdc, "rem-int/lit8", NULL }, + [DOP_AND_INT_LIT8] = { 0xdd, "and-int/lit8", NULL }, + [DOP_OR_INT_LIT8] = { 0xde, "or-int/lit8", NULL }, + [DOP_XOR_INT_LIT8] = { 0xdf, "xor-int/lit8", NULL }, [DOP_SHL_INT_LIT8] = { 0xe0, "shl-int/lit8" }, [DOP_SHR_INT_LIT8] = { 0xe1, "shr-int/lit8" }, [DOP_USHR_INT_LIT8] = { 0xe2, "ushr-int/lit8" }, @@ -336,7 +336,7 @@ static dalvik_instruction _instructions[DOP_COUNT] = { static const char *dalvik_instruction_get_keyword(const GDalvikInstruction *, AsmSyntax); /* Décompile une instruction de la machine virtuelle Dalvik. */ -GDecInstruction *dalvik_instruction_decompile(const GDalvikInstruction *, GDecContext *); +//GDecInstruction *dalvik_instruction_decompile(const GDalvikInstruction *, GDecContext *); @@ -592,7 +592,7 @@ static const char *dalvik_instruction_get_keyword(const GDalvikInstruction *inst * Remarques : - * * * ******************************************************************************/ - +#if 0 GDecInstruction *dalvik_instruction_decompile(const GDalvikInstruction *instr, GDecContext *ctx) { GDecInstruction *result; /* Instruction à retourner */ @@ -606,3 +606,4 @@ GDecInstruction *dalvik_instruction_decompile(const GDalvikInstruction *instr, G return result; } +#endif diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index d08d0b2..a7a95c3 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -69,7 +69,7 @@ static void g_dalvik_processor_finalize(GDalvikProcessor *); static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *); /* Fournit un contexte pour la décompilation Dalvik. */ -static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *); +//static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *); /* Décode une instruction dans un flux de données. */ static GArchInstruction *g_dalvik_processor_disassemble(const GArchProcessor *, GDalvikContext *, const GBinContent *, vmpa2t *, GExeFormat *); @@ -136,7 +136,7 @@ static void g_dalvik_processor_init(GDalvikProcessor *proc) parent->inssize = MDS_16_BITS; parent->get_ctx = (get_processor_context_fc)g_dalvik_processor_get_context; - parent->get_dec_ctx = (get_decomp_context_fc)g_dalvik_processor_get_decomp_context; + //parent->get_dec_ctx = (get_decomp_context_fc)g_dalvik_processor_get_decomp_context; } @@ -232,12 +232,13 @@ static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *pr * Remarques : - * * * ******************************************************************************/ - +#if 0 static GDalvikDContext *g_dalvik_processor_get_decomp_context(const GDalvikProcessor *proc) { return g_dalvik_dcontext_new(); } +#endif /****************************************************************************** |