summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-02-24 11:09:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-02-24 11:09:36 (GMT)
commit02c2cf555953f335a825e34c869c9999668fd42c (patch)
tree59395c04d509f9fae8314d311f6ab90e163df45d /src/arch
parent34e1a14aced520ba06ee1b81cfd7710e97c1643f (diff)
Refined comparisons decompilation and fixed some bugs.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@340 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/dalvik/decomp/if.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/arch/dalvik/decomp/if.c b/src/arch/dalvik/decomp/if.c
index f7591b9..c82413d 100644
--- a/src/arch/dalvik/decomp/if.c
+++ b/src/arch/dalvik/decomp/if.c
@@ -25,6 +25,7 @@
#include "../instruction.h"
+#include "../../../decomp/expr/comp.h"
#include "../../../decomp/expr/cond.h"
#include "../../../decomp/expr/immediate.h"
#include "../../../decomp/instr/ite.h"
@@ -53,7 +54,8 @@ GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecConte
GDecInstruction *op1; /* Premier opérande utilisé */
GDecInstruction *op2; /* Second opérande utilisé */
vmpa_t jmp; /* Adresse de saut */
- GDecInstruction *cond; /* Comparaison à restituer */
+ GDecInstruction *comp; /* Comparaison à restituer */
+ GDecInstruction *cond; /* Transformation en condition */
switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr)))
{
@@ -91,8 +93,9 @@ GDecInstruction *dalvik_decomp_instr_if(const GArchInstruction *instr, GDecConte
operand = g_arch_instruction_get_operand(instr, 2);
jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand, addr);*/
- 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);
+ comp = g_comp_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2));
+ cond = g_cond_expression_new(comp);
+ result = g_ite_instruction_new(cond, jmp, jmp);
return result;
@@ -122,26 +125,27 @@ GDecInstruction *dalvik_decomp_instr_if_zero(const GArchInstruction *instr, GDec
GDecInstruction *op1; /* Premier opérande utilisé */
GDecInstruction *op2; /* Second opérande utilisé */
vmpa_t jmp; /* Adresse de saut */
- GDecInstruction *cond; /* Comparaison à restituer */
+ GDecInstruction *comp; /* Comparaison à restituer */
+ GDecInstruction *cond; /* Transformation en condition */
switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr)))
{
- case DOP_IF_EQ:
+ case DOP_IF_EQZ:
sign = CST_EQ;
break;
- case DOP_IF_NE:
+ case DOP_IF_NEZ:
sign = CST_NE;
break;
- case DOP_IF_LT:
+ case DOP_IF_LTZ:
sign = CST_LT;
break;
- case DOP_IF_GE:
+ case DOP_IF_GEZ:
sign = CST_GE;
break;
- case DOP_IF_GT:
+ case DOP_IF_GTZ:
sign = CST_GT;
break;
- case DOP_IF_LE:
+ case DOP_IF_LEZ:
sign = CST_LE;
break;
default:
@@ -160,8 +164,9 @@ GDecInstruction *dalvik_decomp_instr_if_zero(const GArchInstruction *instr, GDec
operand = g_arch_instruction_get_operand(instr, 2);
jmp = 0x1234ull;/*g_dec_context_convert_register(ctx, operand, addr);*/
- 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);
+ comp = g_comp_expression_new(G_DEC_EXPRESSION(op1), sign, G_DEC_EXPRESSION(op2));
+ cond = g_cond_expression_new(comp);
+ result = g_ite_instruction_new(cond, jmp, jmp);
return result;