summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/decomp
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/dalvik/decomp')
-rw-r--r--src/arch/dalvik/decomp/Makefile.am4
-rw-r--r--src/arch/dalvik/decomp/array.c2
-rw-r--r--src/arch/dalvik/decomp/const.c43
-rw-r--r--src/arch/dalvik/decomp/iget.c78
-rw-r--r--src/arch/dalvik/decomp/invoke.c164
-rw-r--r--src/arch/dalvik/decomp/iput.c78
-rw-r--r--src/arch/dalvik/decomp/move.c99
-rw-r--r--src/arch/dalvik/decomp/new.c72
-rw-r--r--src/arch/dalvik/decomp/translate.h21
9 files changed, 502 insertions, 59 deletions
diff --git a/src/arch/dalvik/decomp/Makefile.am b/src/arch/dalvik/decomp/Makefile.am
index fef68f6..7a7f068 100644
--- a/src/arch/dalvik/decomp/Makefile.am
+++ b/src/arch/dalvik/decomp/Makefile.am
@@ -8,7 +8,11 @@ libarchdalvikdecomp_la_SOURCES = \
array.c \
const.c \
if.c \
+ iget.c \
invoke.c \
+ iput.c \
+ move.c \
+ new.c \
ret.c \
translate.h
diff --git a/src/arch/dalvik/decomp/array.c b/src/arch/dalvik/decomp/array.c
index c5db396..a841986 100644
--- a/src/arch/dalvik/decomp/array.c
+++ b/src/arch/dalvik/decomp/array.c
@@ -55,7 +55,7 @@ GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *instr,
result = NULL;
- printf("PAssaage !\n");
+ //printf("PAssaage !\n");
diff --git a/src/arch/dalvik/decomp/const.c b/src/arch/dalvik/decomp/const.c
index 54b6403..dce6b35 100644
--- a/src/arch/dalvik/decomp/const.c
+++ b/src/arch/dalvik/decomp/const.c
@@ -24,8 +24,10 @@
#include "translate.h"
+#include "../operands/pool.h"
#include "../../../decomp/expr/assign.h"
#include "../../../decomp/expr/immediate.h"
+#include "../../../decomp/expr/text.h"
@@ -60,3 +62,44 @@ GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecCo
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 */
+ GArchOperand *operand; /* Opérande de l'instruction */
+ GDecInstruction *reg; /* Pseudo-registre redéfini */
+ uint32_t index; /* Indice de la chaîne */
+ GDexFormat *format; /* Accès aux constantes */
+ const char *value; /* Chaîne de caractères */
+ GDecInstruction *str; /* Chaîne décompilée */
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ reg = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 1);
+ index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
+
+ format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
+ value = get_string_from_dex_pool(format, index);
+
+ 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/iget.c b/src/arch/dalvik/decomp/iget.c
new file mode 100644
index 0000000..8b8f9f0
--- /dev/null
+++ b/src/arch/dalvik/decomp/iget.c
@@ -0,0 +1,78 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * iget.c - décompilation des instructions manipulant des champs d'instance (chargement)
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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 */
+ 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 */
+ GDexFormat *format; /* Accès aux constantes */
+ GDecInstruction *field; /* Champ concerné par l'opérat°*/
+ GBinVariable *var; /* Variable / champ accédé */
+ GDecInstruction *access; /* Représentation de l'accès */
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 1);
+ src = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 2);
+ index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
+ format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
+ var = get_field_from_dex_pool(format, index);
+
+ field = g_pseudo_register_new();
+ g_pseudo_register_set_variable(G_PSEUDO_REGISTER(field), var);
+
+ 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
index 7360659..a8772cd 100644
--- a/src/arch/dalvik/decomp/invoke.c
+++ b/src/arch/dalvik/decomp/invoke.c
@@ -24,8 +24,12 @@
#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"
@@ -38,7 +42,7 @@
* Paramètres : instr = instruction d'origine à convertir. *
* ctx = contexte de la phase de décompilation. *
* *
-* Description : Décompile une instruction de type 'invoke-virtual'. *
+* Description : Décompile une instruction de type 'invoke-direct'. *
* *
* Retour : Instruction mise en place ou NULL. *
* *
@@ -46,112 +50,156 @@
* *
******************************************************************************/
-GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *instr, GDecContext *ctx)
+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 *op; /* Opérande de l'instruction */
+ GArchOperand *operand; /* Opérande de l'instruction */
uint32_t index; /* Indice de l'élément visé */
GDexFormat *format; /* Accès aux constantes */
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° */
+ size_t i; /* Boucle de parcours #2 */
+ GArchOperand *arg; /* Argument brut de l'appel */
+ GDecInstruction *reg; /* Argument converti */
- const char *string; /* Chaîne à afficher */
- GOpenidaType *type; /* Type quelconque */
- char *tmp; /* Chaîne à afficher & libérer */
+ result = NULL;
+ iter = NULL;
+ list = g_dec_context_get_decomp_instrs(ctx);
+ if (list == NULL) return NULL;
+ /* Récupération de la méthode */
- GArchOperand *operand; /* Opérande de l'instruction */
- GDecInstruction *reg; /* Pseudo-registre redéfini */
- GDecInstruction *imm; /* Valeur immédiate décompilée */
+ count = g_arch_instruction_count_operands(instr);
+ operand = g_arch_instruction_get_operand(instr, count - 1);
- GArchInstruction *iter; /* Boucle de parcours */
- vmpa_t max; /* Limite à ne pas dépasser */
+ index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
+ format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
+ routine = get_routine_from_dex_pool(format, index);
+ if (routine == NULL) return NULL;
- result = NULL;
+ /* Détermination de la routine-cible exacte */
+ name = g_binary_routine_get_name(routine);
- printf("PAssaage !\n");
+ 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;
- /* Récupération de la méthode */
+ }
- count = g_arch_instruction_count_operands(instr);
- op = g_arch_instruction_get_operand(instr, count - 1);
+ if (iter == NULL) return NULL;
- index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(op));
+ result = src;
- printf("POOL ?? %d -> %d\n", G_IS_DALVIK_POOL_OPERAND(op), index);
+ g_dec_instruction_delete(&list, iter);
+ g_dec_context_set_decomp_instrs(ctx, list);
- format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
- routine = get_routine_from_dex_pool(format, index);
- if (routine == NULL) return NULL;
+ }
+ /* Ajout des arguments */
-#if 0
- if (operand->cache.method == NULL)
- g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY,
- "<bad_method_index>", 18, RTT_VAR_NAME);
+ operand = g_arch_instruction_get_operand(instr, 0);
+ count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand));
- else
- {
- tmp = g_binary_routine_to_string(operand->cache.method);
+ 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);
- g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY,
- tmp, strlen(tmp), RTT_VAR_NAME);
+ g_routine_call_add_arg(G_ROUTINE_CALL(result), reg);
- free(tmp);
+ }
+ return (iter != NULL ? iter : result);
-#endif
+}
- result = g_routine_call_new(routine, true);
- //GDecInstruction *g_routine_call_new(GBinRoutine *routine, bool is_object)
- /*
- operand = g_arch_instruction_get_operand(instr, 1);
- reg = g_dec_context_convert_register(ctx, operand);
+/******************************************************************************
+* *
+* 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 : - *
+* *
+******************************************************************************/
- operand = g_arch_instruction_get_operand(instr, 1);
- imm = g_imm_expression_new(G_IMM_OPERAND(operand));
+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é */
+ GDexFormat *format; /* Accès aux constantes */
+ GBinRoutine *routine; /* Routine visée par l'appel */
+ GDecInstruction *call; /* Représentation de l'appel */
+ size_t i; /* Boucle de parcours #2 */
+ GArchOperand *arg; /* Argument brut de l'appel */
+ GDecInstruction *reg; /* Argument converti */
- result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(imm));
- */
+ 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));
+ format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
+ routine = get_routine_from_dex_pool(format, index);
+ if (routine == NULL) return NULL;
- /* Récupération d'un résultat ? */
+ call = g_routine_call_new(routine);
- iter = instr;
- max = g_dec_context_get_max_address(ctx);
+ /* Ajout des arguments */
- iter = g_arch_instruction_get_next_iter(instr, iter, max);
+ operand = g_arch_instruction_get_operand(instr, 0);
+ count = g_dalvik_args_count(G_DALVIK_ARGS_OPERAND(operand));
- if (iter != NULL)
- switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(iter)))
- {
- case DOP_MOVE_RESULT:
+ 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);
- operand = g_arch_instruction_get_operand(iter, 0);
- reg = g_dec_context_convert_register(ctx, operand);
+ g_routine_call_add_arg(G_ROUTINE_CALL(call), reg);
- result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(result));
+ }
- break;
+ /* Appel depuis le propriétaire */
- default:
- break;
+ arg = g_dalvik_args_operand_get(G_DALVIK_ARGS_OPERAND(operand), 0);
+ reg = g_dec_context_convert_register(ctx, arg);
- }
+ 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
new file mode 100644
index 0000000..4db4770
--- /dev/null
+++ b/src/arch/dalvik/decomp/iput.c
@@ -0,0 +1,78 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * iput.c - décompilation des instructions manipulant des champs d'instance (déchargement)
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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 */
+ 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 */
+ GDexFormat *format; /* Accès aux constantes */
+ GDecInstruction *field; /* Champ concerné par l'opérat°*/
+ GBinVariable *var; /* Variable / champ accédé */
+ GDecInstruction *access; /* Représentation de l'accès */
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ src = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 1);
+ dest = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 2);
+ index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
+ format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
+ var = get_field_from_dex_pool(format, index);
+
+ field = g_pseudo_register_new();
+ 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
new file mode 100644
index 0000000..798b6b0
--- /dev/null
+++ b/src/arch/dalvik/decomp/move.c
@@ -0,0 +1,99 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * move.c - décompilation des opérations de déplacement
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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-object'. *
+* *
+* Retour : Instruction mise en place ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDecInstruction *dalvik_decomp_instr_move_object(const GArchInstruction *instr, GDecContext *ctx)
+{
+ GDecInstruction *result; /* Instruction à retourner */
+ GArchOperand *operand; /* Opérande de l'instruction */
+ GDecInstruction *dest; /* Registre de destination */
+ GDecInstruction *src; /* Registre de l'object */
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 1);
+ src = g_dec_context_convert_register(ctx, operand);
+
+ 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 */
+ GArchOperand *operand; /* Opérande de l'instruction */
+ GDecInstruction *dest; /* Registre de destination */
+ GDecInstruction *last; /* Instruction précédante */
+
+ list = g_dec_context_get_decomp_instrs(ctx);
+ if (list == NULL) return NULL;
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand);
+
+ last = g_dec_instruction_get_last(list);
+ g_dec_instruction_delete(&list, last);
+ g_dec_context_set_decomp_instrs(ctx, list);
+
+ 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
new file mode 100644
index 0000000..1c4c06e
--- /dev/null
+++ b/src/arch/dalvik/decomp/new.c
@@ -0,0 +1,72 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * new.c - décompilation des créations de nouvelles instances
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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 */
+ GArchOperand *operand; /* Opérande de l'instruction */
+ GDecInstruction *dest; /* Registre de destination */
+ uint32_t index; /* Indice dans la table */
+ GDexFormat *format; /* Accès aux constantes */
+ GOpenidaType *type; /* Type concerné par l'opérat° */
+ GBinRoutine *constructor; /* Constructeur reconstruit */
+ GDecInstruction *call; /* Appel au constructeur */
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand);
+
+ operand = g_arch_instruction_get_operand(instr, 1);
+ index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
+ format = G_DEX_FORMAT(g_object_get_data(G_OBJECT(ctx), "format"));
+ type = get_type_from_dex_pool(format, index);
+
+ constructor = g_binary_routine_new_constructor(type);
+ call = g_routine_call_new(constructor);
+
+ result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(call));
+
+ return result;
+
+}
diff --git a/src/arch/dalvik/decomp/translate.h b/src/arch/dalvik/decomp/translate.h
index 11b11f7..7779ab7 100644
--- a/src/arch/dalvik/decomp/translate.h
+++ b/src/arch/dalvik/decomp/translate.h
@@ -41,9 +41,30 @@ GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *, GDec
/* 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-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-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 *);