diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2011-10-05 19:34:00 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2011-10-05 19:34:00 (GMT) |
commit | e8d2795d9ec2c8845641863fc42ce39f9e92906b (patch) | |
tree | 722b96e48843335f45735a5d01a8dcf0114c870d /src/arch/dalvik | |
parent | 02cb3aa4e7b18b644b034a5c659c332becf99c9b (diff) |
Supported a few more Dalvik opcodes.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@211 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik')
-rw-r--r-- | src/arch/dalvik/instruction.c | 4 | ||||
-rw-r--r-- | src/arch/dalvik/instruction.h | 2 | ||||
-rw-r--r-- | src/arch/dalvik/op_array.c | 36 | ||||
-rw-r--r-- | src/arch/dalvik/op_move.c | 36 | ||||
-rw-r--r-- | src/arch/dalvik/opcodes.h | 6 | ||||
-rw-r--r-- | src/arch/dalvik/operand.c | 23 | ||||
-rw-r--r-- | src/arch/dalvik/operand.h | 2 | ||||
-rw-r--r-- | src/arch/dalvik/processor.c | 3 |
8 files changed, 112 insertions, 0 deletions
diff --git a/src/arch/dalvik/instruction.c b/src/arch/dalvik/instruction.c index 051bbe2..4595193 100644 --- a/src/arch/dalvik/instruction.c +++ b/src/arch/dalvik/instruction.c @@ -73,6 +73,7 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_NOP] = { 0x00, "nop" }, [DOP_MOVE] = { 0x01, "move" }, + [DOP_MOVE_FROM_16] = { 0x02, "move/from16" }, [DOP_MOVE_OBJECT] = { 0x07, "move-object" }, @@ -101,6 +102,9 @@ static dalvik_instruction _instructions[DOP_COUNT] = { [DOP_NEW_INSTANCE] = { 0x22, "new-instance" }, [DOP_NEW_ARRAY] = { 0x23, "new-array" }, + + [DOP_FILL_ARRAY_DATA] = { 0x26, "fill-array-data" }, + [DOP_GOTO] = { 0x28, "goto" }, [DOP_GOTO_16] = { 0x29, "goto/16" }, [DOP_GOTO_32] = { 0x2a, "goto/32" }, diff --git a/src/arch/dalvik/instruction.h b/src/arch/dalvik/instruction.h index 8eaed17..c359c66 100644 --- a/src/arch/dalvik/instruction.h +++ b/src/arch/dalvik/instruction.h @@ -34,6 +34,7 @@ typedef enum _DalvikOpcodes { DOP_NOP, /* nop (0x00) */ DOP_MOVE, /* move (0x01) */ + DOP_MOVE_FROM_16, /* move/from16 (0x02) */ DOP_MOVE_OBJECT, /* move-object (0x07) */ @@ -62,6 +63,7 @@ typedef enum _DalvikOpcodes DOP_NEW_INSTANCE, /* new-instance (0x22) */ DOP_NEW_ARRAY, /* new-array (0x23) */ + DOP_FILL_ARRAY_DATA, /* fill-array-data (0x26) */ DOP_GOTO, /* goto (0x28) */ DOP_GOTO_16, /* goto/16 (0x29) */ diff --git a/src/arch/dalvik/op_array.c b/src/arch/dalvik/op_array.c index 90c61e8..3eecc85 100644 --- a/src/arch/dalvik/op_array.c +++ b/src/arch/dalvik/op_array.c @@ -63,3 +63,39 @@ GArchInstruction *dalvik_read_instr_array_length(const bin_t *data, off_t *pos, return result; } + + +/****************************************************************************** +* * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse virtuelle de l'instruction. * +* proc = architecture ciblée par le désassemblage. * +* * +* Description : Décode une instruction de type 'fill-array-data'. * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_fill_array_data(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + SourceEndian endian; /* Boutisme lié au binaire */ + + result = g_dalvik_instruction_new(DOP_FILL_ARRAY_DATA); + + endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + + if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_31T)) + { + g_object_unref(G_OBJECT(result)); + return NULL; + } + + return result; + +} diff --git a/src/arch/dalvik/op_move.c b/src/arch/dalvik/op_move.c index de4da28..0462fdb 100644 --- a/src/arch/dalvik/op_move.c +++ b/src/arch/dalvik/op_move.c @@ -109,6 +109,42 @@ GArchInstruction *dalvik_read_instr_move_exception(const bin_t *data, off_t *pos * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'move/from16'. * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_from_16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + SourceEndian endian; /* Boutisme lié au binaire */ + + result = g_dalvik_instruction_new(DOP_MOVE_FROM_16); + + endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + + if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22X)) + { + g_object_unref(G_OBJECT(result)); + return NULL; + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse virtuelle de l'instruction. * +* proc = architecture ciblée par le désassemblage. * +* * * Description : Décode une instruction de type 'move-object'. * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/dalvik/opcodes.h b/src/arch/dalvik/opcodes.h index 7d4b42e..d8d3616 100644 --- a/src/arch/dalvik/opcodes.h +++ b/src/arch/dalvik/opcodes.h @@ -183,6 +183,9 @@ GArchInstruction *dalvik_read_instr_div_int_lit8(const bin_t *, off_t *, off_t, GArchInstruction *dalvik_read_instr_div_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'fill-array-data'. */ +GArchInstruction *dalvik_read_instr_fill_array_data(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + /* Décode une instruction de type 'goto'. */ GArchInstruction *dalvik_read_instr_goto(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); @@ -308,6 +311,9 @@ GArchInstruction *dalvik_read_instr_move(const bin_t *, off_t *, off_t, vmpa_t, /* Décode une instruction de type 'move-exception'. */ GArchInstruction *dalvik_read_instr_move_exception(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'move/from16'. */ +GArchInstruction *dalvik_read_instr_move_from_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + /* Décode une instruction de type 'move-object'. */ GArchInstruction *dalvik_read_instr_move_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index f6392b3..7c245d8 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -36,6 +36,7 @@ typedef enum _DalvikOperandID DOI_REGISTER_4, DOI_REGISTER_8, + DOI_REGISTER_16, DOI_IMMEDIATE_4, DOI_IMMEDIATE_8, @@ -199,6 +200,14 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat }; break; + case DALVIK_OPT_22X: + types = (DalvikOperandID []) { + DOI_REGISTER_8, + DOI_REGISTER_16, + DOI_INVALID + }; + break; + case DALVIK_OPT_23X: types = (DalvikOperandID []) { DOI_REGISTER_8, @@ -223,6 +232,14 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat }; break; + case DALVIK_OPT_31T: + types = (DalvikOperandID []) { + DOI_REGISTER_8, + DOI_TARGET_32, + DOI_INVALID + }; + break; + case DALVIK_OPT_51L: types = (DalvikOperandID []) { DOI_REGISTER_8, @@ -253,6 +270,10 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat op = g_dalvik_register_operand_new(data, pos, len, NULL, MDS_8_BITS, endian); break; + case DOI_REGISTER_16: + op = g_dalvik_register_operand_new(data, pos, len, NULL, MDS_16_BITS, endian); + break; + case DOI_IMMEDIATE_4: op = _g_imm_operand_new_from_data(MDS_4_BITS, data, pos, len, low, endian); break; @@ -474,9 +495,11 @@ bool dalvik_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos case DALVIK_OPT_22C: case DALVIK_OPT_22S: case DALVIK_OPT_22T: + case DALVIK_OPT_22X: case DALVIK_OPT_23X: case DALVIK_OPT_30T: case DALVIK_OPT_31I: + case DALVIK_OPT_31T: case DALVIK_OPT_51L: va_start(ap, model); result = dalvik_read_basic_operands(instr, data, pos, len, &low, endian, model, ap); diff --git a/src/arch/dalvik/operand.h b/src/arch/dalvik/operand.h index a596225..636d7ec 100644 --- a/src/arch/dalvik/operand.h +++ b/src/arch/dalvik/operand.h @@ -86,12 +86,14 @@ typedef enum _DalvikOperandType DALVIK_OPT_22C = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'C', DALVIK_OPT_22S = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'S', DALVIK_OPT_22T = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'T', + DALVIK_OPT_22X = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'X', DALVIK_OPT_23X = DALVIK_OP_LEN(2) | DALVIK_OP_REG(3) | 'X', DALVIK_OPT_30T = DALVIK_OP_LEN(3) | DALVIK_OP_REG(0) | 'T', DALVIK_OPT_31I = DALVIK_OP_LEN(3) | DALVIK_OP_REG(1) | 'I', + DALVIK_OPT_31T = DALVIK_OP_LEN(3) | DALVIK_OP_REG(1) | 'T', DALVIK_OPT_35C = DALVIK_OP_LEN(3) | DALVIK_OP_REG(5) | 'C', diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index 379fc98..4fd8a2f 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -154,6 +154,7 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc [DOP_NOP] = dalvik_read_instr_nop, [DOP_MOVE] = dalvik_read_instr_move, + [DOP_MOVE_FROM_16] = dalvik_read_instr_move_from_16, [DOP_MOVE_OBJECT] = dalvik_read_instr_move_object, @@ -182,6 +183,8 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc [DOP_NEW_INSTANCE] = dalvik_read_instr_new_instance, [DOP_NEW_ARRAY] = dalvik_read_instr_new_array, + [DOP_FILL_ARRAY_DATA] = dalvik_read_instr_fill_array_data, + [DOP_GOTO] = dalvik_read_instr_goto, [DOP_GOTO_16] = dalvik_read_instr_goto_16, [DOP_GOTO_32] = dalvik_read_instr_goto_32, |