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/aget.c14
-rw-r--r--src/arch/dalvik/decomp/aput.c8
-rw-r--r--src/arch/dalvik/decomp/arithm.c34
-rw-r--r--src/arch/dalvik/decomp/array.c20
-rw-r--r--src/arch/dalvik/decomp/const.c6
-rw-r--r--src/arch/dalvik/decomp/if.c6
-rw-r--r--src/arch/dalvik/decomp/iget.c10
-rw-r--r--src/arch/dalvik/decomp/invoke.c8
-rw-r--r--src/arch/dalvik/decomp/iput.c4
-rw-r--r--src/arch/dalvik/decomp/move.c18
-rw-r--r--src/arch/dalvik/decomp/new.c8
-rw-r--r--src/arch/dalvik/decomp/ret.c4
12 files changed, 65 insertions, 75 deletions
diff --git a/src/arch/dalvik/decomp/aget.c b/src/arch/dalvik/decomp/aget.c
index 41b7e34..0fa66eb 100644
--- a/src/arch/dalvik/decomp/aget.c
+++ b/src/arch/dalvik/decomp/aget.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* aget.c - décompilation des instructions manipulant des tableaux (chargement)
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -46,19 +46,19 @@ GDecInstruction *dalvik_decomp_instr_aget(const GArchInstruction *instr, GDecCon
{
GDecInstruction *result; /* Instruction à retourner */
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 *content; /* Contenu de cellule visé */
GDecInstruction *access; /* Représentation de l'accès */
- operand = g_arch_instruction_get_operand(instr, 0);
- content = g_dec_context_convert_register(ctx, operand);
-
operand = g_arch_instruction_get_operand(instr, 1);
- array = g_dec_context_convert_register(ctx, operand);
+ array = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 2);
- index = g_dec_context_convert_register(ctx, operand);
+ index = g_dec_context_convert_register(ctx, operand, false);
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ content = g_dec_context_convert_register(ctx, operand, true);
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));
diff --git a/src/arch/dalvik/decomp/aput.c b/src/arch/dalvik/decomp/aput.c
index 8d86789..41bd89f 100644
--- a/src/arch/dalvik/decomp/aput.c
+++ b/src/arch/dalvik/decomp/aput.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* aput.c - décompilation des instructions manipulant des tableaux (enregistrement)
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -52,13 +52,13 @@ GDecInstruction *dalvik_decomp_instr_aput(const GArchInstruction *instr, GDecCon
GDecInstruction *access; /* Représentation de l'accès */
operand = g_arch_instruction_get_operand(instr, 0);
- content = g_dec_context_convert_register(ctx, operand);
+ content = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 1);
- array = g_dec_context_convert_register(ctx, operand);
+ array = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 2);
- index = g_dec_context_convert_register(ctx, operand);
+ index = g_dec_context_convert_register(ctx, operand, false);
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));
diff --git a/src/arch/dalvik/decomp/arithm.c b/src/arch/dalvik/decomp/arithm.c
index 257c59a..a217adf 100644
--- a/src/arch/dalvik/decomp/arithm.c
+++ b/src/arch/dalvik/decomp/arithm.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* arithm.c - décompilation des opérations arithmétiques
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -49,9 +49,9 @@ GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecC
GDecInstruction *result; /* Instruction à retourner */
ArithmOperationType type; /* Type d'opération menée */
GArchOperand *operand; /* Opérande de l'instruction */
- GDecInstruction *dest; /* Enregistrement du résultat */
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)))
@@ -85,14 +85,14 @@ GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecC
break;
}
- operand = g_arch_instruction_get_operand(instr, 0);
- dest = g_dec_context_convert_register(ctx, operand);
-
operand = g_arch_instruction_get_operand(instr, 1);
- op1 = g_dec_context_convert_register(ctx, operand);
+ op1 = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 2);
- op2 = g_dec_context_convert_register(ctx, operand);
+ op2 = g_dec_context_convert_register(ctx, operand, false);
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand, true);
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));
@@ -120,8 +120,8 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr,
GDecInstruction *result; /* Instruction à retourner */
ArithmOperationType type; /* Type d'opération menée */
GArchOperand *operand; /* Opérande de l'instruction */
- GDecInstruction *dest; /* Enregistrement du résultat */
GDecInstruction *op1; /* Premier 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)))
@@ -153,11 +153,11 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr,
break;
}
- operand = g_arch_instruction_get_operand(instr, 0);
- dest = g_dec_context_convert_register(ctx, operand);
-
operand = g_arch_instruction_get_operand(instr, 1);
- op1 = g_dec_context_convert_register(ctx, operand);
+ op1 = g_dec_context_convert_register(ctx, operand, false);
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand, true);
arithm = g_arithm_expression_new(G_DEC_EXPRESSION(dest), type, G_DEC_EXPRESSION(op1));
result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm));
@@ -185,9 +185,9 @@ GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, G
GDecInstruction *result; /* Instruction à retourner */
ArithmOperationType type; /* Type d'opération menée */
GArchOperand *operand; /* Opérande de l'instruction */
- GDecInstruction *dest; /* Enregistrement du résultat */
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)))
@@ -225,15 +225,15 @@ GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, G
break;
}
- operand = g_arch_instruction_get_operand(instr, 0);
- dest = g_dec_context_convert_register(ctx, operand);
-
operand = g_arch_instruction_get_operand(instr, 1);
- op1 = g_dec_context_convert_register(ctx, operand);
+ op1 = g_dec_context_convert_register(ctx, operand, false);
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);
+
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));
diff --git a/src/arch/dalvik/decomp/array.c b/src/arch/dalvik/decomp/array.c
index a841986..3422461 100644
--- a/src/arch/dalvik/decomp/array.c
+++ b/src/arch/dalvik/decomp/array.c
@@ -2,7 +2,7 @@
/* OpenIDA - 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-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -45,29 +45,19 @@
GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *instr, GDecContext *ctx)
{
GDecInstruction *result; /* Instruction à retourner */
-
-
GArchOperand *operand; /* Opérande de l'instruction */
GDecInstruction *reg; /* Pseudo-registre redéfini */
GDecInstruction *len; /* Enregistrement de taille */
-
-
- result = NULL;
-
-
- //printf("PAssaage !\n");
-
-
+ GDecInstruction *dest; /* Destination de la création */
operand = g_arch_instruction_get_operand(instr, 1);
- reg = g_dec_context_convert_register(ctx, operand);
+ reg = g_dec_context_convert_register(ctx, operand, false);
len = g_dalvik_alength_new(G_DEC_EXPRESSION(reg));
operand = g_arch_instruction_get_operand(instr, 0);
- reg = g_dec_context_convert_register(ctx, operand);
-
+ dest = g_dec_context_convert_register(ctx, operand, true);
- result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(len));
+ 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
index dce6b35..2e63b36 100644
--- a/src/arch/dalvik/decomp/const.c
+++ b/src/arch/dalvik/decomp/const.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* const.c - décompilation des chargements de constantes
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -52,7 +52,7 @@ GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecCo
GDecInstruction *imm; /* Valeur immédiate décompilée */
operand = g_arch_instruction_get_operand(instr, 0);
- reg = g_dec_context_convert_register(ctx, operand);
+ reg = g_dec_context_convert_register(ctx, operand, true);
operand = g_arch_instruction_get_operand(instr, 1);
imm = g_imm_expression_new(G_IMM_OPERAND(operand));
@@ -88,7 +88,7 @@ GDecInstruction *dalvik_decomp_instr_const_str(const GArchInstruction *instr, GD
GDecInstruction *str; /* Chaîne décompilée */
operand = g_arch_instruction_get_operand(instr, 0);
- reg = g_dec_context_convert_register(ctx, operand);
+ reg = g_dec_context_convert_register(ctx, operand, true);
operand = g_arch_instruction_get_operand(instr, 1);
index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
diff --git a/src/arch/dalvik/decomp/if.c b/src/arch/dalvik/decomp/if.c
index 1a8663c..43406c7 100644
--- a/src/arch/dalvik/decomp/if.c
+++ b/src/arch/dalvik/decomp/if.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* array.c - décompilation des branchements conditionnels
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -79,10 +79,10 @@ GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecConte
}
operand = g_arch_instruction_get_operand(instr, 0);
- op1 = g_dec_context_convert_register(ctx, operand);
+ op1 = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 1);
- op2 = g_dec_context_convert_register(ctx, operand);
+ op2 = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 2);
jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand);*/
diff --git a/src/arch/dalvik/decomp/iget.c b/src/arch/dalvik/decomp/iget.c
index 8b8f9f0..931438c 100644
--- a/src/arch/dalvik/decomp/iget.c
+++ b/src/arch/dalvik/decomp/iget.c
@@ -48,19 +48,16 @@ GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecCon
{
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 *dest; /* Registre de destination */
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);
+ src = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 2);
index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
@@ -70,6 +67,9 @@ GDecInstruction *dalvik_decomp_instr_iget(const GArchInstruction *instr, GDecCon
field = g_pseudo_register_new();
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);
+
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));
diff --git a/src/arch/dalvik/decomp/invoke.c b/src/arch/dalvik/decomp/invoke.c
index a8772cd..c3650b4 100644
--- a/src/arch/dalvik/decomp/invoke.c
+++ b/src/arch/dalvik/decomp/invoke.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* invoke.c - décompilation des appels de méthode
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -128,7 +128,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_direct(const GArchInstruction *instr
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);
+ reg = g_dec_context_convert_register(ctx, arg, false);
g_routine_call_add_arg(G_ROUTINE_CALL(result), reg);
@@ -188,7 +188,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst
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);
+ reg = g_dec_context_convert_register(ctx, arg, false);
g_routine_call_add_arg(G_ROUTINE_CALL(call), reg);
@@ -197,7 +197,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst
/* 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);
+ reg = g_dec_context_convert_register(ctx, arg, false);
result = g_access_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(call));
diff --git a/src/arch/dalvik/decomp/iput.c b/src/arch/dalvik/decomp/iput.c
index 4db4770..002bdd4 100644
--- a/src/arch/dalvik/decomp/iput.c
+++ b/src/arch/dalvik/decomp/iput.c
@@ -57,10 +57,10 @@ GDecInstruction *dalvik_decomp_instr_iput(const GArchInstruction *instr, GDecCon
GDecInstruction *access; /* Représentation de l'accès */
operand = g_arch_instruction_get_operand(instr, 0);
- src = g_dec_context_convert_register(ctx, operand);
+ src = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 1);
- dest = g_dec_context_convert_register(ctx, operand);
+ dest = g_dec_context_convert_register(ctx, operand, false);
operand = g_arch_instruction_get_operand(instr, 2);
index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
diff --git a/src/arch/dalvik/decomp/move.c b/src/arch/dalvik/decomp/move.c
index 798b6b0..f700737 100644
--- a/src/arch/dalvik/decomp/move.c
+++ b/src/arch/dalvik/decomp/move.c
@@ -45,14 +45,14 @@ GDecInstruction *dalvik_decomp_instr_move_object(const GArchInstruction *instr,
{
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);
+ GDecInstruction *dest; /* Registre de destination */
operand = g_arch_instruction_get_operand(instr, 1);
- src = g_dec_context_convert_register(ctx, operand);
+ src = g_dec_context_convert_register(ctx, operand, false);
+
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand, true);
result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(src));
@@ -79,19 +79,19 @@ GDecInstruction *dalvik_decomp_instr_move_result(const GArchInstruction *instr,
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 */
+ GDecInstruction *dest; /* Registre de destination */
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);
+ operand = g_arch_instruction_get_operand(instr, 0);
+ dest = g_dec_context_convert_register(ctx, operand, true);
+
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
index 1c4c06e..65da469 100644
--- a/src/arch/dalvik/decomp/new.c
+++ b/src/arch/dalvik/decomp/new.c
@@ -47,15 +47,12 @@ GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr,
{
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);
+ GDecInstruction *dest; /* Registre de destination */
operand = g_arch_instruction_get_operand(instr, 1);
index = g_dalvik_pool_operand_get_index(G_DALVIK_POOL_OPERAND(operand));
@@ -65,6 +62,9 @@ GDecInstruction *dalvik_decomp_instr_new_instance(const GArchInstruction *instr,
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);
+
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
index 3717529..b7c5414 100644
--- a/src/arch/dalvik/decomp/ret.c
+++ b/src/arch/dalvik/decomp/ret.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* ret.c - décompilation des ordres de retour
*
- * Copyright (C) 2010-2011 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -48,7 +48,7 @@ GDecInstruction *dalvik_decomp_instr_return(const GArchInstruction *instr, GDecC
GDecInstruction *reg; /* Pseudo-registre redéfini */
operand = g_arch_instruction_get_operand(instr, 0);
- reg = g_dec_context_convert_register(ctx, operand);
+ reg = g_dec_context_convert_register(ctx, operand, false);
result = g_return_expression_new(G_DEC_EXPRESSION(reg));