summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/pseudo/switch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/dalvik/pseudo/switch.c')
-rw-r--r--src/arch/dalvik/pseudo/switch.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/arch/dalvik/pseudo/switch.c b/src/arch/dalvik/pseudo/switch.c
index 169c5bf..1b41ba4 100644
--- a/src/arch/dalvik/pseudo/switch.c
+++ b/src/arch/dalvik/pseudo/switch.c
@@ -24,6 +24,7 @@
#include "switch.h"
+#include <assert.h>
#include <string.h>
@@ -94,7 +95,7 @@ static void g_dalvik_switch_instr_class_init(GDalvikSwitchInstrClass *klass)
instr = G_ARCH_INSTRUCTION_CLASS(klass);
- instr->print = (print_instruction_fc)g_dalvik_switch_instr_print;
+ //instr->print = (print_instruction_fc)g_dalvik_switch_instr_print;
}
@@ -113,6 +114,7 @@ static void g_dalvik_switch_instr_class_init(GDalvikSwitchInstrClass *klass)
static void g_dalvik_switch_instr_init(GDalvikSwitchInstr *instr)
{
+ G_DALVIK_INSTRUCTION(instr)->keyword = "##switch##";
}
@@ -157,11 +159,9 @@ static void g_dalvik_switch_instr_finalize(GDalvikSwitchInstr *instr)
/******************************************************************************
* *
-* Paramètres : data = flux de données à analyser. *
-* pos = position courante dans ce flux. [OUT] *
-* len = limite des données à analyser. *
-* addr = adresse virtuelle de l'instruction. *
-* proc = architecture ciblée par le désassemblage. *
+* Paramètres : ident = identifiant de l'instruction déjà lu. *
+* content = flux de données à analyser. *
+* pos = position courante dans ce flux. [OUT] *
* *
* Description : Crée une pesudo-instruction Dalvik de branchement. *
* *
@@ -171,28 +171,26 @@ static void g_dalvik_switch_instr_finalize(GDalvikSwitchInstr *instr)
* *
******************************************************************************/
-GArchInstruction *g_dalvik_switch_instr_new(const bin_t *data, off_t *pos, off_t end, vmpa_t addr, const GDalvikProcessor *proc)
+GArchInstruction *g_dalvik_switch_instr_new(uint16_t ident, const GBinContent *content, vmpa2t *pos)
{
- GDalvikSwitchInstr *result; /* Structure à retourner */
- uint16_t ident; /* Valeur lue dans le code */
+ GDalvikSwitchInstr *result; /* Structure à retourner */
+ phys_t consumed; /* Données consommées */
- result = g_object_new(G_TYPE_DALVIK_SWITCH_INSTR, NULL);
-
- if (!read_u16(&ident, data, pos, end, SRE_LITTLE))
- goto gdsin_bad;
+ assert(ident == DPO_PACKED_SWITCH || ident == DPO_SPARSE_SWITCH);
- if (ident != DPO_PACKED_SWITCH && ident != DPO_SPARSE_SWITCH)
- goto gdsin_bad;
+ result = g_object_new(G_TYPE_DALVIK_SWITCH_INSTR, NULL);
G_DALVIK_INSTRUCTION(result)->ptype = ident;
- if (!read_u16(&result->switch_size, data, pos, end, SRE_LITTLE))
+ if (!g_binary_content_read_u16(content, pos, SRE_LITTLE, &result->switch_size))
goto gdsin_bad;
if (ident != DPO_PACKED_SWITCH)
- *pos += (1 + result->switch_size) * sizeof(uint32_t);
+ consumed = (1 + result->switch_size) * sizeof(uint32_t);
else
- *pos += (2 * result->switch_size) * sizeof(uint32_t);
+ consumed = (2 * result->switch_size) * sizeof(uint32_t);
+
+ advance_vmpa(pos, consumed);
return G_ARCH_INSTRUCTION(result);
@@ -234,6 +232,7 @@ static void g_dalvik_switch_instr_print(const GDalvikSwitchInstr *instr, GCodeBu
line = NULL;
+ //line = g_code_buffer_prepare_new_line(buffer, &range);
#if 0
line = g_code_buffer_append_new_line(buffer, base->address);