summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/decomp/if.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/dalvik/decomp/if.c')
-rw-r--r--src/arch/dalvik/decomp/if.c66
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;
+
+}