diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/dalvik/dop_arithm.c | 71 | ||||
-rw-r--r-- | src/arch/dalvik/instruction.c | 16 | ||||
-rw-r--r-- | src/arch/dalvik/translate.h | 3 |
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'. */ |