diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2011-10-12 13:31:00 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2011-10-12 13:31:00 (GMT) |
commit | 044b4d6d7ba4de50cd4d05b92621900e929e2231 (patch) | |
tree | 70167cbd5c90d0f8b2fc967add38272d21de1e4f /src/arch/dalvik/processor.c | |
parent | e8d2795d9ec2c8845641863fc42ce39f9e92906b (diff) |
Processed skipped instructions and used contexts.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@212 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik/processor.c')
-rw-r--r-- | src/arch/dalvik/processor.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index 4fd8a2f..2f56f87 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -24,8 +24,10 @@ #include "processor.h" +#include "context.h" #include "instruction.h" #include "opcodes.h" +#include "specins.h" #include "../processor-int.h" @@ -52,8 +54,11 @@ static void g_dalvik_processor_class_init(GDalvikProcessorClass *); /* Initialise une instance de processeur de VM Dalvik. */ static void g_dalvik_processor_init(GDalvikProcessor *); +/* Fournit un contexte pour l'exécution du processeur Dalvik. */ +static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *); + /* Décode une instruction dans un flux de données. */ -static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProcessor *, const bin_t *, off_t *, off_t, vmpa_t); +static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProcessor *, GDalvikContext *, const bin_t *, off_t *, off_t, vmpa_t); /* Indique le type défini par la GLib pour le processeur DALVIK. */ @@ -101,6 +106,7 @@ static void g_dalvik_processor_init(GDalvikProcessor *proc) parent->memsize = MDS_32_BITS; parent->inssize = MDS_16_BITS; + parent->get_ctx = (get_processor_context_fc)g_dalvik_processor_get_context; parent->decode = (decode_instruction_fc)g_dalvik_processor_decode_instruction; } @@ -131,7 +137,27 @@ GArchProcessor *g_dalvik_processor_new(void) /****************************************************************************** * * +* Paramètres : proc = architecture, spectatrice ici. * +* * +* Description : Fournit un contexte pour l'exécution du processeur Dalvik. * +* * +* Retour : Contexte mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GDalvikContext *g_dalvik_processor_get_context(const GDalvikProcessor *proc) +{ + return g_dalvik_context_new(); + +} + + +/****************************************************************************** +* * * Paramètres : proc = architecture visée par la procédure. * +* ctx = contexte lié à l'exécution du processeur. * * data = flux de données à analyser. * * pos = position courante dans ce flux. [OUT] * * len = taille totale des données à analyser. * @@ -145,7 +171,7 @@ GArchProcessor *g_dalvik_processor_new(void) * * ******************************************************************************/ -static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProcessor *proc, const bin_t *data, off_t *pos, off_t len, vmpa_t addr) +static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProcessor *proc, GDalvikContext *ctx, const bin_t *data, off_t *pos, off_t len, vmpa_t addr) { GArchInstruction *result; /* Instruction à renvoyer */ DalvikOpcodes id; /* Identifiant d'instruction */ @@ -315,6 +341,16 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc }; + /* Continuité d'une zone spéciale... */ + if (g_dalvik_context_have_to_skip(ctx, addr)) + return SKIPPED_INSTR; + + /* Début d'une nouvelle zone spéciale... */ + if (g_dalvik_guess_special_instruction(ctx, data, *pos, len, addr)) + return SKIPPED_INSTR; + + /* Ou instruction classique */ + id = dalvik_guess_next_instruction(data, *pos, len); if (id != DOP_COUNT) (*pos)++; |