summaryrefslogtreecommitdiff
path: root/plugins/androhelpers
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-31 21:29:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-31 21:29:49 (GMT)
commit0936f64aac6a4fa9ebc08962bc9cac663f210c00 (patch)
treee888b4d7b547680bb26082913216bc637073e734 /plugins/androhelpers
parentb6341581220e92114b0838a15a1c1cec1078efc2 (diff)
Saved the first steps of switch instructions decompilation.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@335 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/androhelpers')
-rw-r--r--plugins/androhelpers/switch.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/plugins/androhelpers/switch.c b/plugins/androhelpers/switch.c
index 9e6f306..0a1e488 100644
--- a/plugins/androhelpers/switch.c
+++ b/plugins/androhelpers/switch.c
@@ -27,6 +27,7 @@
#include <string.h>
+#include <arch/immediate.h>
#include <arch/dalvik/instruction.h>
#include <arch/dalvik/instruction-def.h>
#include <arch/dalvik/operands/target.h>
@@ -139,6 +140,8 @@ static void link_all_switch_cases(GArchInstruction *instr, const dex_switch *dsw
uint32_t *targets; /* Cibles relatives à corriger */
uint16_t i; /* Boucle de parcours */
GArchInstruction *next; /* Instruction suivante */
+ uint32_t value; /* Valeur à indiquer */
+ GArchOperand *imm; /* Forme de la valeur reconnue */
/* Valeurs définies */
@@ -155,7 +158,16 @@ static void link_all_switch_cases(GArchInstruction *instr, const dex_switch *dsw
next = g_arch_instruction_find_by_address(instrs, (vmpa_t)targets[i], true);
if (next != NULL)
- g_arch_instruction_link_with(instr, next, ILT_CASE_JUMP);
+ {
+ if (dswitch->packed.ident == DPO_PACKED_SWITCH)
+ value = dswitch->packed.first_key + i;
+ else
+ value = dswitch->sparse.keys[i];
+
+ imm = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, value);
+ g_arch_instruction_link_with(instr, next, ILT_CASE_JUMP, imm);
+
+ }
}
@@ -164,7 +176,7 @@ static void link_all_switch_cases(GArchInstruction *instr, const dex_switch *dsw
next = g_arch_instruction_get_next_iter(instrs, instr, end);
if (next != NULL)
- g_arch_instruction_link_with(instr, next, ILT_CASE_JUMP);
+ g_arch_instruction_link_with(instr, next, ILT_CASE_JUMP, NULL);
}