diff options
Diffstat (limited to 'src/arch/dalvik/pseudo')
-rw-r--r-- | src/arch/dalvik/pseudo/fill.c | 32 | ||||
-rw-r--r-- | src/arch/dalvik/pseudo/fill.h | 2 | ||||
-rw-r--r-- | src/arch/dalvik/pseudo/switch.c | 35 | ||||
-rw-r--r-- | src/arch/dalvik/pseudo/switch.h | 2 |
4 files changed, 36 insertions, 35 deletions
diff --git a/src/arch/dalvik/pseudo/fill.c b/src/arch/dalvik/pseudo/fill.c index acb8551..2656dab 100644 --- a/src/arch/dalvik/pseudo/fill.c +++ b/src/arch/dalvik/pseudo/fill.c @@ -24,6 +24,7 @@ #include "fill.h" +#include <assert.h> #include <string.h> @@ -95,7 +96,7 @@ static void g_dalvik_fill_instr_class_init(GDalvikFillInstrClass *klass) instr = G_ARCH_INSTRUCTION_CLASS(klass); - instr->print = (print_instruction_fc)g_dalvik_fill_instr_print; + //instr->print = (print_instruction_fc)g_dalvik_fill_instr_print; } @@ -114,6 +115,7 @@ static void g_dalvik_fill_instr_class_init(GDalvikFillInstrClass *klass) static void g_dalvik_fill_instr_init(GDalvikFillInstr *instr) { + G_DALVIK_INSTRUCTION(instr)->keyword = "##fill-array##"; } @@ -158,11 +160,9 @@ static void g_dalvik_fill_instr_finalize(GDalvikFillInstr *instr) /****************************************************************************** * * -* Paramètres : data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* end = 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 remplissage. * * * @@ -172,24 +172,26 @@ static void g_dalvik_fill_instr_finalize(GDalvikFillInstr *instr) * * ******************************************************************************/ -GArchInstruction *g_dalvik_fill_instr_new(const bin_t *data, off_t *pos, off_t end, vmpa_t addr, const GDalvikProcessor *proc) +GArchInstruction *g_dalvik_fill_instr_new(uint16_t ident, const GBinContent *content, vmpa2t *pos) { GDalvikFillInstr *result; /* Structure à retourner */ - uint16_t ident; /* Valeur lue dans le code */ + phys_t consumed; /* Données consommées */ - result = g_object_new(G_TYPE_DALVIK_FILL_INSTR, NULL); + assert(ident == DPO_FILL_ARRAY_DATA); - if (!read_u16(&ident, data, pos, end, SRE_LITTLE)) - goto gdfin_bad; + result = g_object_new(G_TYPE_DALVIK_FILL_INSTR, NULL); - G_DALVIK_INSTRUCTION(result)->ptype = DPO_FILL_ARRAY_DATA; + G_DALVIK_INSTRUCTION(result)->ptype = ident; - if (!read_u16(&result->array_width, data, pos, end, SRE_LITTLE)) + if (!g_binary_content_read_u16(content, pos, SRE_LITTLE, &result->array_width)) goto gdfin_bad; - if (!read_u32(&result->array_size, data, pos, end, SRE_LITTLE)) + + if (!g_binary_content_read_u32(content, pos, SRE_LITTLE, &result->array_size)) goto gdfin_bad; - *pos += result->array_width * result->array_size; + consumed = result->array_width * result->array_size; + + advance_vmpa(pos, consumed); return G_ARCH_INSTRUCTION(result); diff --git a/src/arch/dalvik/pseudo/fill.h b/src/arch/dalvik/pseudo/fill.h index 041cdaa..aeb04b8 100644 --- a/src/arch/dalvik/pseudo/fill.h +++ b/src/arch/dalvik/pseudo/fill.h @@ -50,7 +50,7 @@ typedef struct _GDalvikFillInstrClass GDalvikFillInstrClass; GType g_dalvik_fill_instr_get_type(void); /* Crée une pesudo-instruction Dalvik de remplissage. */ -GArchInstruction *g_dalvik_fill_instr_new(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +GArchInstruction *g_dalvik_fill_instr_new(uint16_t, const GBinContent *, vmpa2t *); 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); diff --git a/src/arch/dalvik/pseudo/switch.h b/src/arch/dalvik/pseudo/switch.h index cdb4b92..02d61d0 100644 --- a/src/arch/dalvik/pseudo/switch.h +++ b/src/arch/dalvik/pseudo/switch.h @@ -50,7 +50,7 @@ typedef struct _GDalvikSwitchInstrClass GDalvikSwitchInstrClass; GType g_dalvik_switch_instr_get_type(void); /* Crée une pesudo-instruction Dalvik de branchement. */ -GArchInstruction *g_dalvik_switch_instr_new(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +GArchInstruction *g_dalvik_switch_instr_new(uint16_t, const GBinContent *, vmpa2t *); |