summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-12-08 23:16:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-12-08 23:16:43 (GMT)
commit78b82a19a4f45cfd57f3cea7faf34968f86fb160 (patch)
tree1daeab3ea56e492a1ac5031259d567677cf1f0ba /src/arch
parent6ea8a46069a8b2c6d2fbf007496d0616f544d8d4 (diff)
Decompiled a few more arithmetic Dex opcodes.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@199 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/dalvik/dop_arithm.c71
-rw-r--r--src/arch/dalvik/instruction.c16
-rw-r--r--src/arch/dalvik/translate.h3
3 files changed, 82 insertions, 8 deletions
diff --git a/src/arch/dalvik/dop_arithm.c b/src/arch/dalvik/dop_arithm.c
index 7657f99..ace8724 100644
--- a/src/arch/dalvik/dop_arithm.c
+++ b/src/arch/dalvik/dop_arithm.c
@@ -44,6 +44,77 @@
* *
******************************************************************************/
+GDecInstruction *dalvik_decomp_instr_arithm(const GArchInstruction *instr, GDecContext *ctx)
+{
+ 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 *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;
+ }
+
+ 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);
+
+ operand = g_arch_instruction_get_operand(instr, 2);
+ op2 = g_dec_context_convert_register(ctx, operand);
+
+ 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 */
diff --git a/src/arch/dalvik/instruction.c b/src/arch/dalvik/instruction.c
index ca48fe2..d23bbe5 100644
--- a/src/arch/dalvik/instruction.c
+++ b/src/arch/dalvik/instruction.c
@@ -188,14 +188,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" },
- [DOP_SUB_INT] = { 0x91, "sub-int" },
- [DOP_MUL_INT] = { 0x92, "mul-int" },
- [DOP_DIV_INT] = { 0x93, "div-int" },
- [DOP_REM_INT] = { 0x94, "rem-int" },
- [DOP_AND_INT] = { 0x95, "and-int" },
- [DOP_OR_INT] = { 0x96, "or-int" },
- [DOP_XOR_INT] = { 0x97, "xor-int" },
+ [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_2ADDR] = { 0xb0, "add-int/2addr", dalvik_decomp_instr_arithm_2addr },
diff --git a/src/arch/dalvik/translate.h b/src/arch/dalvik/translate.h
index 0f408e6..350dff8 100644
--- a/src/arch/dalvik/translate.h
+++ b/src/arch/dalvik/translate.h
@@ -52,6 +52,9 @@ GDecInstruction *dalvik_decomp_instr_return_void(const GArchInstruction *, GDecC
/* 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'. */