diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-11-28 09:43:50 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-11-28 09:43:50 (GMT) |
commit | f95598b68b98f6eda701f8f02bc09cb13f65fc72 (patch) | |
tree | eefee33963448a1ce53a7eb80dacabbcdce8fc21 /src/arch/dalvik/decomp/if.c | |
parent | fbb4b6f53d2189ba9f61c1fd149534d8aef82dcd (diff) |
Followed the excution flow to decompile instructions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@293 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik/decomp/if.c')
-rw-r--r-- | src/arch/dalvik/decomp/if.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/arch/dalvik/decomp/if.c b/src/arch/dalvik/decomp/if.c index 43406c7..b274ead 100644 --- a/src/arch/dalvik/decomp/if.c +++ b/src/arch/dalvik/decomp/if.c @@ -93,3 +93,69 @@ GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecConte return result; } + + + +/****************************************************************************** +* * +* Paramètres : instr = instruction d'origine à convertir. * +* ctx = contexte de la phase de décompilation. * +* * +* Description : Décompile une instruction de comparaison d'opérandes. * +* * +* 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 */ + 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 *cond; /* Comparaison à restituer */ + + 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; + } + + operand = g_arch_instruction_get_operand(instr, 0); + op1 = g_dec_context_convert_register(ctx, operand, false); + + operand = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, (unsigned int)0); + op2 = g_imm_expression_new(operand); + + operand = g_arch_instruction_get_operand(instr, 2); + jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand);*/ + + cond = g_cond_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2)); + result = g_ite_instruction_new(G_DEC_EXPRESSION(cond), jmp, jmp); + + return result; + +} |