diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/dalvik/instruction-def.h | 103 | ||||
| -rw-r--r-- | src/arch/dalvik/instruction.c | 111 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/Makefile.am | 5 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/and.c | 74 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/array.c | 74 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/div.c | 185 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/instanceof.c | 66 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/monitor.c | 103 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/move.c | 148 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/mul.c | 44 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/neg.c | 177 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/not.c | 103 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/opcodes.h | 164 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/or.c | 74 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/rem.c | 222 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/sub.c | 24 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/throw.c | 66 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes/xor.c | 74 | ||||
| -rw-r--r-- | src/arch/dalvik/operand.c | 9 | ||||
| -rw-r--r-- | src/arch/dalvik/operand.h | 2 | ||||
| -rw-r--r-- | src/arch/dalvik/processor.c | 77 | 
21 files changed, 1707 insertions, 198 deletions
diff --git a/src/arch/dalvik/instruction-def.h b/src/arch/dalvik/instruction-def.h index 3959d87..6f52cf2 100644 --- a/src/arch/dalvik/instruction-def.h +++ b/src/arch/dalvik/instruction-def.h @@ -32,12 +32,13 @@ typedef enum _DalvikOpcodes      DOP_NOP,                                /* nop (0x00)                  */      DOP_MOVE,                               /* move (0x01)                 */      DOP_MOVE_FROM_16,                       /* move/from16 (0x02)          */ - +    DOP_MOVE_16,                            /* move/16 (0x03)              */ +    DOP_MOVE_WIDE,                          /* move-wide (0x04)            */      DOP_MOVE_WIDE_FROM_16,                  /* move-wide/from16 (0x05)     */ - +    DOP_MOVE_WIDE_16,                       /* move-wide/16 (0x06)         */      DOP_MOVE_OBJECT,                        /* move-object (0x07)          */      DOP_MOVE_OBJECT_FROM_16,                /* move-object/from16 (0x08)   */ - +    DOP_MOVE_OBJECT_16,                     /* move-object/16 (0x09)       */      DOP_MOVE_RESULT,                        /* move-result (0x0a)          */      DOP_MOVE_RESULT_WIDE,                   /* move-result-wide (0x0b)     */      DOP_MOVE_RESULT_OBJECT,                 /* move-result-object (0x0c)   */ @@ -57,16 +58,17 @@ typedef enum _DalvikOpcodes      DOP_CONST_STRING,                       /* const-string (0x1a)         */      DOP_CONST_STRING_JUMBO,                 /* const-string/jumbo (0x1b)   */      DOP_CONST_CLASS,                        /* const-class (0x1c)          */ - - +    DOP_MONITOR_ENTER,                      /* monitor-enter (0x1d)        */ +    DOP_MONITOR_EXIT,                       /* monitor-exit (0x1e)         */      DOP_CHECK_CAST,                         /* check-cast (0x1f)           */ - +    DOP_INSTANCE_OF,                        /* instance-of (0x20)          */      DOP_ARRAY_LENGTH,                       /* array-length (0x21)         */      DOP_NEW_INSTANCE,                       /* new-instance (0x22)         */      DOP_NEW_ARRAY,                          /* new-array (0x23)            */ - +    DOP_FILLED_NEW_ARRAY,                   /* filled-new-array (0x24)     */ +    DOP_FILLED_NEW_ARRAY_RANGE,             /* filled-new-array/range(0x25)*/      DOP_FILL_ARRAY_DATA,                    /* fill-array-data (0x26)      */ - +    DOP_THROW,                              /* throw (0x27)                */      DOP_GOTO,                               /* goto (0x28)                 */      DOP_GOTO_16,                            /* goto/16 (0x29)              */      DOP_GOTO_32,                            /* goto/32 (0x2a)              */ @@ -89,9 +91,12 @@ typedef enum _DalvikOpcodes      DOP_IF_GEZ,                             /* if-gez (0x3b)               */      DOP_IF_GTZ,                             /* if-gtz (0x3c)               */      DOP_IF_LEZ,                             /* if-lez (0x3d)               */ - - - +    DOP_UNUSED_3E,                          /* -unused- (0x3e)             */ +    DOP_UNUSED_3F,                          /* -unused- (0x3f)             */ +    DOP_UNUSED_40,                          /* -unused- (0x40)             */ +    DOP_UNUSED_41,                          /* -unused- (0x41)             */ +    DOP_UNUSED_42,                          /* -unused- (0x42)             */ +    DOP_UNUSED_43,                          /* -unused- (0x43)             */      DOP_AGET,                               /* aget (0x44)                 */      DOP_AGET_WIDE,                          /* aget-wide (0x45)            */      DOP_AGET_OBJECT,                        /* aget-object (0x46)          */ @@ -139,13 +144,20 @@ typedef enum _DalvikOpcodes      DOP_INVOKE_DIRECT,                      /* invoke-direct (0x70)        */      DOP_INVOKE_STATIC,                      /* invoke-static (0x71)        */      DOP_INVOKE_INTERFACE,                   /* invoke-interface (0x72)     */ - +    DOP_UNUSED_73,                          /* -unused- (0x73)             */      DOP_INVOKE_VIRTUAL_RANGE,               /* invoke-virtual/range (0x74) */      DOP_INVOKE_SUPER_RANGE,                 /* invoke-super/range (0x75)   */      DOP_INVOKE_DIRECT_RANGE,                /* invoke-direct/range (0x76)  */      DOP_INVOKE_STATIC_RANGE,                /* invoke-static/range (0x77)  */      DOP_INVOKE_INTERFACE_RANGE,             /* invoke-interface/rg. (0x78) */ - +    DOP_UNUSED_79,                          /* -unused- (0x79)             */ +    DOP_UNUSED_7A,                          /* -unused- (0x7a)             */ +    DOP_NEG_INT,                            /* neg-int (0x7b)              */ +    DOP_NOT_INT,                            /* not-int (0x7c)              */ +    DOP_NEG_LONG,                           /* neg-long (0x7d)             */ +    DOP_NOT_LONG,                           /* not-long (0x7e)             */ +    DOP_NEG_FLOAT,                          /* neg-float (0x7f)            */ +    DOP_NEG_DOUBLE,                         /* neg-double (0x80)           */      DOP_TO_INT_LONG,                        /* int-to-long (0x81)          */      DOP_TO_INT_FLOAT,                       /* int-to-float (0x82)         */      DOP_TO_INT_DOUBLE,                      /* int-to-double (0x83)        */ @@ -172,27 +184,27 @@ typedef enum _DalvikOpcodes      DOP_SHL_INT,                            /* shl-int (0x98)              */      DOP_SHR_INT,                            /* shr-int (0x99)              */      DOP_USHR_INT,                           /* ushr-int (0x9a)             */ - -      DOP_ADD_LONG,                           /* add-long (0x9b)             */      DOP_SUB_LONG,                           /* sub-long (0x9c)             */      DOP_MUL_LONG,                           /* mul-long (0x9d)             */      DOP_DIV_LONG,                           /* div-long (0x9e)             */ - - +    DOP_REM_LONG,                           /* rem-long (0x9f)             */ +    DOP_AND_LONG,                           /* and-long (0xa0)             */ +    DOP_OR_LONG,                            /* or-long (0xa1)              */ +    DOP_XOR_LONG,                           /* xor-long (0xa2)             */      DOP_SHL_LONG,                           /* shl-long (0xa3)             */      DOP_SHR_LONG,                           /* shr-long (0xa4)             */      DOP_USHR_LONG,                          /* ushr-long (0xa5)            */      DOP_ADD_FLOAT,                          /* add-float (0xa6)            */      DOP_SUB_FLOAT,                          /* sub-float (0xa7)            */      DOP_MUL_FLOAT,                          /* mul-float (0xa8)            */ - - +    DOP_DIV_FLOAT,                          /* mul-float (0xa9)            */ +    DOP_REM_FLOAT,                          /* mul-float (0xaa)            */      DOP_ADD_DOUBLE,                         /* add-double (0xab)           */ -    DOP_SUB_DOUBLE,                         /* add-double (0xac)           */ -    DOP_MUL_DOUBLE,                         /* add-double (0xad)           */ - - +    DOP_SUB_DOUBLE,                         /* sub-double (0xac)           */ +    DOP_MUL_DOUBLE,                         /* mul-double (0xad)           */ +    DOP_DIV_DOUBLE,                         /* div-double (0xae)           */ +    DOP_REM_DOUBLE,                         /* rem-double (0xaf)           */      DOP_ADD_INT_2ADDR,                      /* add-int/2addr (0xb0)        */      DOP_SUB_INT_2ADDR,                      /* add-int/2addr (0xb1)        */      DOP_MUL_INT_2ADDR,                      /* mul-int/2addr (0xb2)        */ @@ -207,22 +219,24 @@ typedef enum _DalvikOpcodes      DOP_ADD_LONG_2ADDR,                     /* add-long/2addr (0xbb)       */      DOP_SUB_LONG_2ADDR,                     /* sub-long/2addr (0xbc)       */      DOP_MUL_LONG_2ADDR,                     /* mul-long/2addr (0xbd)       */ - - +    DOP_DIV_LONG_2ADDR,                     /* div-long/2addr (0xbe)       */ +    DOP_REM_LONG_2ADDR,                     /* rem-long/2addr (0xbf)       */ +    DOP_AND_LONG_2ADDR,                     /* and-long/2addr (0xc0)       */ +    DOP_OR_LONG_2ADDR,                      /* or-long/2addr (0xc1)        */ +    DOP_XOR_LONG_2ADDR,                     /* xor-long/2addr (0xc2)       */      DOP_SHL_LONG_2ADDR,                     /* shl-long/2addr (0xc3)       */      DOP_SHR_LONG_2ADDR,                     /* shr-long/2addr (0xc4)       */      DOP_USHR_LONG_2ADDR,                    /* ushr-long/2addr (0xc5)      */ -      DOP_ADD_FLOAT_2ADDR,                    /* add-float/2addr (0xc6)      */      DOP_SUB_FLOAT_2ADDR,                    /* sub-float/2addr (0xc7)      */      DOP_MUL_FLOAT_2ADDR,                    /* mul-float/2addr (0xc8)      */ - +    DOP_DIV_FLOAT_2ADDR,                    /* div-float/2addr (0xc9)      */ +    DOP_REM_FLOAT_2ADDR,                    /* rem-float/2addr (0xca)      */      DOP_ADD_DOUBLE_2ADDR,                   /* add-double/2addr (0xcb)     */      DOP_SUB_DOUBLE_2ADDR,                   /* sub-double/2addr (0xcc)     */      DOP_MUL_DOUBLE_2ADDR,                   /* mul-double/2addr (0xcd)     */ - - - +    DOP_DIV_DOUBLE_2ADDR,                   /* div-double/2addr (0xce)     */ +    DOP_REM_DOUBLE_2ADDR,                   /* rem-double/2addr (0xcf)     */      DOP_ADD_INT_LIT16,                      /* add-int/lit16 (0xd0)        */      DOP_RSUB_INT,                           /* rsub-int (0xd1)             */      DOP_MUL_INT_LIT16,                      /* mul-int/lit16 (0xd2)        */ @@ -242,6 +256,35 @@ typedef enum _DalvikOpcodes      DOP_SHL_INT_LIT8,                       /* shl-int/lit8 (0xe0)         */      DOP_SHR_INT_LIT8,                       /* shr-int/lit8 (0xe1)         */      DOP_USHR_INT_LIT8,                      /* ushr-int/lit8 (0xe2)        */ +    DOP_UNUSED_E3,                          /* -unused- (0xe3)             */ +    DOP_UNUSED_E4,                          /* -unused- (0xe4)             */ +    DOP_UNUSED_E5,                          /* -unused- (0xe5)             */ +    DOP_UNUSED_E6,                          /* -unused- (0xe6)             */ +    DOP_UNUSED_E7,                          /* -unused- (0xe7)             */ +    DOP_UNUSED_E8,                          /* -unused- (0xe8)             */ +    DOP_UNUSED_E9,                          /* -unused- (0xe9)             */ +    DOP_UNUSED_EA,                          /* -unused- (0xea)             */ +    DOP_UNUSED_EB,                          /* -unused- (0xeb)             */ +    DOP_UNUSED_EC,                          /* -unused- (0xec)             */ +    DOP_UNUSED_ED,                          /* -unused- (0xed)             */ +    DOP_UNUSED_EE,                          /* -unused- (0xee)             */ +    DOP_UNUSED_EF,                          /* -unused- (0xef)             */ +    DOP_UNUSED_F0,                          /* -unused- (0xf0)             */ +    DOP_UNUSED_F1,                          /* -unused- (0xf1)             */ +    DOP_UNUSED_F2,                          /* -unused- (0xf2)             */ +    DOP_UNUSED_F3,                          /* -unused- (0xf3)             */ +    DOP_UNUSED_F4,                          /* -unused- (0xf4)             */ +    DOP_UNUSED_F5,                          /* -unused- (0xf5)             */ +    DOP_UNUSED_F6,                          /* -unused- (0xf6)             */ +    DOP_UNUSED_F7,                          /* -unused- (0xf7)             */ +    DOP_UNUSED_F8,                          /* -unused- (0xf8)             */ +    DOP_UNUSED_F9,                          /* -unused- (0xf9)             */ +    DOP_UNUSED_FA,                          /* -unused- (0xfa)             */ +    DOP_UNUSED_FB,                          /* -unused- (0xfb)             */ +    DOP_UNUSED_FC,                          /* -unused- (0xfc)             */ +    DOP_UNUSED_FD,                          /* -unused- (0xfd)             */ +    DOP_UNUSED_FE,                          /* -unused- (0xfe)             */ +    DOP_UNUSED_FF,                          /* -unused- (0xff)             */      DOP_COUNT diff --git a/src/arch/dalvik/instruction.c b/src/arch/dalvik/instruction.c index 416a699..a1f29bc 100644 --- a/src/arch/dalvik/instruction.c +++ b/src/arch/dalvik/instruction.c @@ -59,14 +59,13 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_NOP]                   = { 0x00, "nop",                NULL },      [DOP_MOVE]                  = { 0x01, "move" },      [DOP_MOVE_FROM_16]          = { 0x02, "move/from16" }, - - +    [DOP_MOVE_16]               = { 0x03, "move/16" }, +    [DOP_MOVE_WIDE]             = { 0x04, "move-wide" },      [DOP_MOVE_WIDE_FROM_16]     = { 0x05, "move-wide/from16" }, - - +    [DOP_MOVE_WIDE_16]          = { 0x06, "move-wide/16" },      [DOP_MOVE_OBJECT]           = { 0x07, "move-object",        dalvik_decomp_instr_move_object },      [DOP_MOVE_OBJECT_FROM_16]   = { 0x08, "move-object/from16" }, - +    [DOP_MOVE_OBJECT_16]        = { 0x09, "move-object/16" },      [DOP_MOVE_RESULT]           = { 0x0a, "move-result",        dalvik_decomp_instr_move_result },      [DOP_MOVE_RESULT_WIDE]      = { 0x0b, "move-result-wide",   dalvik_decomp_instr_move_result },      [DOP_MOVE_RESULT_OBJECT]    = { 0x0c, "move-result-object", dalvik_decomp_instr_move_result }, @@ -86,17 +85,17 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_CONST_STRING]          = { 0x1a, "const-string",       dalvik_decomp_instr_const_str },      [DOP_CONST_STRING_JUMBO]    = { 0x1b, "const-string/jumbo" },      [DOP_CONST_CLASS]           = { 0x1c, "const-class" }, - +    [DOP_MONITOR_ENTER]         = { 0x1d, "monitor-enter" }, +    [DOP_MONITOR_EXIT]          = { 0x1e, "monitor-exit" },      [DOP_CHECK_CAST]            = { 0x1f, "check-cast" }, - - +    [DOP_INSTANCE_OF]           = { 0x20, "instance-of" },      [DOP_ARRAY_LENGTH]          = { 0x21, "array-length",       dalvik_decomp_instr_array_length },      [DOP_NEW_INSTANCE]          = { 0x22, "new-instance",       dalvik_decomp_instr_new_instance },      [DOP_NEW_ARRAY]             = { 0x23, "new-array" }, - - +    [DOP_FILLED_NEW_ARRAY]      = { 0x24, "fill-new-array" }, +    [DOP_FILLED_NEW_ARRAY_RANGE]= { 0x25, "fill-new-array/range" },      [DOP_FILL_ARRAY_DATA]       = { 0x26, "fill-array-data" }, - +    [DOP_THROW]                 = { 0x27, "throw" },      [DOP_GOTO]                  = { 0x28, "goto" },      [DOP_GOTO_16]               = { 0x29, "goto/16" },      [DOP_GOTO_32]               = { 0x2a, "goto/32" }, @@ -119,9 +118,12 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_IF_GEZ]                = { 0x3b, "if-gez" },      [DOP_IF_GTZ]                = { 0x3c, "if-gtz" },      [DOP_IF_LEZ]                = { 0x3d, "if-lez" }, - - - +    [DOP_UNUSED_3E]             = { 0x3e, NULL /* unused */ }, +    [DOP_UNUSED_3F]             = { 0x3f, NULL /* unused */ }, +    [DOP_UNUSED_40]             = { 0x40, NULL /* unused */ }, +    [DOP_UNUSED_41]             = { 0x41, NULL /* unused */ }, +    [DOP_UNUSED_42]             = { 0x42, NULL /* unused */ }, +    [DOP_UNUSED_43]             = { 0x43, NULL /* unused */ },      [DOP_AGET]                  = { 0x44, "aget" },      [DOP_AGET_WIDE]             = { 0x45, "aget-wide" },      [DOP_AGET_OBJECT]           = { 0x46, "aget-object" }, @@ -169,15 +171,20 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_INVOKE_DIRECT]         = { 0x70, "invoke-direct",      dalvik_decomp_instr_invoke_direct },      [DOP_INVOKE_STATIC]         = { 0x71, "invoke-static" },      [DOP_INVOKE_INTERFACE]      = { 0x72, "invoke-interface" }, - +    [DOP_UNUSED_73]             = { 0x73, NULL /* unused */ },      [DOP_INVOKE_VIRTUAL_RANGE]  = { 0x74, "invoke-virtual/range" },      [DOP_INVOKE_SUPER_RANGE]    = { 0x75, "invoke-static/range" },      [DOP_INVOKE_DIRECT_RANGE]   = { 0x76, "invoke-direct/range" },      [DOP_INVOKE_STATIC_RANGE]   = { 0x77, "invoke-static/range" },      [DOP_INVOKE_INTERFACE_RANGE]= { 0x78, "invoke-interface/range" }, - - - +    [DOP_UNUSED_79]             = { 0x79, NULL /* unused */ }, +    [DOP_UNUSED_7A]             = { 0x7a, NULL /* unused */ }, +    [DOP_NEG_INT]               = { 0x7b, "neg-int" }, +    [DOP_NOT_INT]               = { 0x7c, "not-int" }, +    [DOP_NEG_LONG]              = { 0x7d, "neg-long" }, +    [DOP_NOT_LONG]              = { 0x7e, "not-long" }, +    [DOP_NEG_FLOAT]             = { 0x7f, "neg-float" }, +    [DOP_NEG_DOUBLE]            = { 0x80, "neg-double" },      [DOP_TO_INT_LONG]           = { 0x81, "int-to-long" },      [DOP_TO_INT_FLOAT]          = { 0x82, "int-to-float" },      [DOP_TO_INT_DOUBLE]         = { 0x83, "int-to-double" }, @@ -204,23 +211,27 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_SHL_INT]               = { 0x98, "shl-int" },      [DOP_SHR_INT]               = { 0x99, "shr-int" },      [DOP_USHR_INT]              = { 0x9a, "ushr-int" }, - -      [DOP_ADD_LONG]              = { 0x9b, "add-long" },      [DOP_SUB_LONG]              = { 0x9c, "sub-long" },      [DOP_MUL_LONG]              = { 0x9d, "mul-long" },      [DOP_DIV_LONG]              = { 0x9e, "div-long" }, - - +    [DOP_REM_LONG]              = { 0x9f, "rem-long" }, +    [DOP_AND_LONG]              = { 0xa0, "and-long" }, +    [DOP_OR_LONG]               = { 0xa1, "or-long" }, +    [DOP_XOR_LONG]              = { 0xa2, "xor-long" },      [DOP_SHL_LONG]              = { 0xa3, "shl-long" },      [DOP_SHR_LONG]              = { 0xa4, "shr-long" },      [DOP_USHR_LONG]             = { 0xa5, "ushr-long" },      [DOP_ADD_FLOAT]             = { 0xa6, "add-float" }, - - +    [DOP_SUB_FLOAT]             = { 0xa7, "sub-float" }, +    [DOP_MUL_FLOAT]             = { 0xa8, "mul-float" }, +    [DOP_DIV_FLOAT]             = { 0xa9, "div-float" }, +    [DOP_REM_FLOAT]             = { 0xaa, "rem-float" },      [DOP_ADD_DOUBLE]            = { 0xab, "add-double" }, - - +    [DOP_SUB_DOUBLE]            = { 0xac, "sub-double" }, +    [DOP_MUL_DOUBLE]            = { 0xad, "mul-double" }, +    [DOP_DIV_DOUBLE]            = { 0xae, "div-double" }, +    [DOP_REM_DOUBLE]            = { 0xaf, "rem-double" },      [DOP_ADD_INT_2ADDR]         = { 0xb0, "add-int/2addr",      dalvik_decomp_instr_arithm_2addr },      [DOP_SUB_INT_2ADDR]         = { 0xb1, "sub-int/2addr",      dalvik_decomp_instr_arithm_2addr },      [DOP_MUL_INT_2ADDR]         = { 0xb2, "mul-int/2addr",      dalvik_decomp_instr_arithm_2addr }, @@ -235,18 +246,24 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_ADD_LONG_2ADDR]        = { 0xbb, "add-long/2addr",     dalvik_decomp_instr_arithm_2addr },      [DOP_SUB_LONG_2ADDR]        = { 0xbc, "sub-long/2addr",     dalvik_decomp_instr_arithm_2addr },      [DOP_MUL_LONG_2ADDR]        = { 0xbd, "mul-long/2addr",     dalvik_decomp_instr_arithm_2addr }, - +    [DOP_DIV_LONG_2ADDR]        = { 0xbe, "div-long/2addr",     dalvik_decomp_instr_arithm_2addr }, +    [DOP_REM_LONG_2ADDR]        = { 0xbf, "rem-long/2addr",     dalvik_decomp_instr_arithm_2addr }, +    [DOP_AND_LONG_2ADDR]        = { 0xc0, "and-long/2addr",     dalvik_decomp_instr_arithm_2addr }, +    [DOP_OR_LONG_2ADDR]         = { 0xc1, "or-long/2addr",      dalvik_decomp_instr_arithm_2addr }, +    [DOP_XOR_LONG_2ADDR]        = { 0xc2, "xor-long/2addr",     dalvik_decomp_instr_arithm_2addr },      [DOP_SHL_LONG_2ADDR]        = { 0xc3, "shl-long/2addr",     dalvik_decomp_instr_arithm_2addr },      [DOP_SHR_LONG_2ADDR]        = { 0xc4, "shr-long/2addr",     dalvik_decomp_instr_arithm_2addr },      [DOP_USHR_LONG_2ADDR]       = { 0xc5, "ushr-long/2addr",    dalvik_decomp_instr_arithm_2addr },      [DOP_ADD_FLOAT_2ADDR]       = { 0xc6, "add-float/2addr",    dalvik_decomp_instr_arithm_2addr },      [DOP_SUB_FLOAT_2ADDR]       = { 0xc7, "sub-float/2addr",    dalvik_decomp_instr_arithm_2addr },      [DOP_MUL_FLOAT_2ADDR]       = { 0xc8, "mul-float/2addr",    dalvik_decomp_instr_arithm_2addr }, - +    [DOP_DIV_FLOAT_2ADDR]       = { 0xc9, "div-float/2addr",    dalvik_decomp_instr_arithm_2addr }, +    [DOP_REM_FLOAT_2ADDR]       = { 0xca, "rem-float/2addr",    dalvik_decomp_instr_arithm_2addr },      [DOP_ADD_DOUBLE_2ADDR]      = { 0xcb, "add-double/2addr",   dalvik_decomp_instr_arithm_2addr },      [DOP_SUB_DOUBLE_2ADDR]      = { 0xcc, "sub-double/2addr",   dalvik_decomp_instr_arithm_2addr },      [DOP_MUL_DOUBLE_2ADDR]      = { 0xcd, "mul-double/2addr",   dalvik_decomp_instr_arithm_2addr }, - +    [DOP_DIV_DOUBLE_2ADDR]      = { 0xce, "div-double/2addr",   dalvik_decomp_instr_arithm_2addr }, +    [DOP_REM_DOUBLE_2ADDR]      = { 0xcf, "rem-double/2addr",   dalvik_decomp_instr_arithm_2addr },      [DOP_ADD_INT_LIT16]         = { 0xd0, "add-int/lit16",      dalvik_decomp_instr_arithm_lit },      [DOP_RSUB_INT]              = { 0xd1, "rsub-int" },      [DOP_MUL_INT_LIT16]         = { 0xd2, "mul-int/lit16",      dalvik_decomp_instr_arithm_lit }, @@ -265,8 +282,36 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_XOR_INT_LIT8]          = { 0xdf, "xor-int/lit8",       dalvik_decomp_instr_arithm_lit },      [DOP_SHL_INT_LIT8]          = { 0xe0, "shl-int/lit8" },      [DOP_SHR_INT_LIT8]          = { 0xe1, "shr-int/lit8" }, -    [DOP_USHR_INT_LIT8]         = { 0xe2, "ushr-int/lit8" } - +    [DOP_USHR_INT_LIT8]         = { 0xe2, "ushr-int/lit8" }, +    [DOP_UNUSED_E3]             = { 0xe3, NULL /* unused */ }, +    [DOP_UNUSED_E4]             = { 0xe4, NULL /* unused */ }, +    [DOP_UNUSED_E5]             = { 0xe5, NULL /* unused */ }, +    [DOP_UNUSED_E6]             = { 0xe6, NULL /* unused */ }, +    [DOP_UNUSED_E7]             = { 0xe7, NULL /* unused */ }, +    [DOP_UNUSED_E8]             = { 0xe8, NULL /* unused */ }, +    [DOP_UNUSED_E9]             = { 0xe9, NULL /* unused */ }, +    [DOP_UNUSED_EA]             = { 0xea, NULL /* unused */ }, +    [DOP_UNUSED_EB]             = { 0xeb, NULL /* unused */ }, +    [DOP_UNUSED_EC]             = { 0xec, NULL /* unused */ }, +    [DOP_UNUSED_ED]             = { 0xed, NULL /* unused */ }, +    [DOP_UNUSED_EE]             = { 0xee, NULL /* unused */ }, +    [DOP_UNUSED_EF]             = { 0xef, NULL /* unused */ }, +    [DOP_UNUSED_F0]             = { 0xf0, NULL /* unused */ }, +    [DOP_UNUSED_F1]             = { 0xf1, NULL /* unused */ }, +    [DOP_UNUSED_F2]             = { 0xf2, NULL /* unused */ }, +    [DOP_UNUSED_F3]             = { 0xf3, NULL /* unused */ }, +    [DOP_UNUSED_F4]             = { 0xf4, NULL /* unused */ }, +    [DOP_UNUSED_F5]             = { 0xf5, NULL /* unused */ }, +    [DOP_UNUSED_F6]             = { 0xf6, NULL /* unused */ }, +    [DOP_UNUSED_F7]             = { 0xf7, NULL /* unused */ }, +    [DOP_UNUSED_F8]             = { 0xf8, NULL /* unused */ }, +    [DOP_UNUSED_F9]             = { 0xf9, NULL /* unused */ }, +    [DOP_UNUSED_FA]             = { 0xfa, NULL /* unused */ }, +    [DOP_UNUSED_FB]             = { 0xfb, NULL /* unused */ }, +    [DOP_UNUSED_FC]             = { 0xfc, NULL /* unused */ }, +    [DOP_UNUSED_FD]             = { 0xfd, NULL /* unused */ }, +    [DOP_UNUSED_FE]             = { 0xfe, NULL /* unused */ }, +    [DOP_UNUSED_FF]             = { 0xff, NULL /* unused */ }  }; @@ -412,6 +457,10 @@ DalvikOpcodes dalvik_guess_next_instruction(const bin_t *data, off_t pos, off_t      } +    /* Si l'instruction est marquée comme non utilisée... */ +    if (_instructions[result].keyword == NULL) +        result = DOP_COUNT; +      return result;  } diff --git a/src/arch/dalvik/opcodes/Makefile.am b/src/arch/dalvik/opcodes/Makefile.am index 5e2432a..08de704 100644 --- a/src/arch/dalvik/opcodes/Makefile.am +++ b/src/arch/dalvik/opcodes/Makefile.am @@ -14,12 +14,16 @@ libarchdalvikopcodes_la_SOURCES =		\  	goto.c								\  	if.c								\  	iget.c								\ +	instanceof.c						\  	invoke.c							\  	iput.c								\ +	monitor.c							\  	move.c								\  	mul.c								\ +	neg.c								\  	new.c								\  	nop.c								\ +	not.c								\  	opcodes.h							\  	or.c								\  	rem.c								\ @@ -31,6 +35,7 @@ libarchdalvikopcodes_la_SOURCES =		\  	sput.c								\  	sub.c								\  	switch.c							\ +	throw.c								\  	to.c								\  	ushr.c								\  	xor.c diff --git a/src/arch/dalvik/opcodes/and.c b/src/arch/dalvik/opcodes/and.c index eb22536..859fbe3 100644 --- a/src/arch/dalvik/opcodes/and.c +++ b/src/arch/dalvik/opcodes/and.c @@ -175,3 +175,77 @@ GArchInstruction *dalvik_read_instr_and_int_lit16(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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'and-long'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_and_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AND_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'and-long/2addr'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_and_long_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AND_LONG_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/array.c b/src/arch/dalvik/opcodes/array.c index 4abfabb..9223e47 100644 --- a/src/arch/dalvik/opcodes/array.c +++ b/src/arch/dalvik/opcodes/array.c @@ -101,3 +101,77 @@ GArchInstruction *dalvik_read_instr_fill_array_data(const bin_t *data, off_t *po      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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'filled-new-array'.           * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_filled_new_array(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_FILLED_NEW_ARRAY); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_35C | DALVIK_OP_POOL(DPT_TYPE))) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'filled-new-array/range'.     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_filled_new_array_range(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_FILLED_NEW_ARRAY_RANGE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_3RC | DALVIK_OP_POOL(DPT_TYPE))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/div.c b/src/arch/dalvik/opcodes/div.c index 9b67764..8732fd0 100644 --- a/src/arch/dalvik/opcodes/div.c +++ b/src/arch/dalvik/opcodes/div.c @@ -38,6 +38,154 @@  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * +*  Description : Décode une instruction de type 'div-double'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_DIV_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'div-double/2addr'.           * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_double_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_DIV_DOUBLE_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'div-float'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_DIV_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'div-float/2addr'.            * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_float_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_DIV_FLOAT_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             *  *  Description : Décode une instruction de type 'div-int'.                    *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -212,3 +360,40 @@ GArchInstruction *dalvik_read_instr_div_long(const bin_t *data, off_t *pos, off_      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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'div-long/2addr'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_long_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_DIV_LONG_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/instanceof.c b/src/arch/dalvik/opcodes/instanceof.c new file mode 100644 index 0000000..9797b57 --- /dev/null +++ b/src/arch/dalvik/opcodes/instanceof.c @@ -0,0 +1,66 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * instanceof.c - décodage des opérations d'interrogation sur une instance + * + * Copyright (C) 2012 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "opcodes.h" + + +#include "../instruction.h" +#include "../operand.h" + + + +/****************************************************************************** +*                                                                             * +*  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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'instance-of'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_instance_of(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_INSTANCE_OF); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_22C | DALVIK_OP_POOL(DPT_TYPE))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/monitor.c b/src/arch/dalvik/opcodes/monitor.c new file mode 100644 index 0000000..347e771 --- /dev/null +++ b/src/arch/dalvik/opcodes/monitor.c @@ -0,0 +1,103 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * monitor.c - décodage des opérations de débogage + * + * Copyright (C) 2012 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "opcodes.h" + + +#include "../instruction.h" +#include "../operand.h" + + + +/****************************************************************************** +*                                                                             * +*  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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'monitor-enter'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_monitor_enter(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MONITOR_ENTER); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_11X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'monitor-exit'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_monitor_exit(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MONITOR_EXIT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_11X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/move.c b/src/arch/dalvik/opcodes/move.c index e6e1e6e..3daeab0 100644 --- a/src/arch/dalvik/opcodes/move.c +++ b/src/arch/dalvik/opcodes/move.c @@ -112,6 +112,43 @@ GArchInstruction *dalvik_read_instr_move_exception(const bin_t *data, off_t *pos  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * +*  Description : Décode une instruction de type 'move/16'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_32X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             *  *  Description : Décode une instruction de type 'move/from16'.                *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -186,6 +223,43 @@ GArchInstruction *dalvik_read_instr_move_object(const bin_t *data, off_t *pos, o  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * +*  Description : Décode une instruction de type 'move-object/16'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_object_16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_OBJECT_16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_32X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             *  *  Description : Décode une instruction de type 'move-object/from16'.         *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -334,6 +408,80 @@ GArchInstruction *dalvik_read_instr_move_result_wide(const bin_t *data, off_t *p  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * +*  Description : Décode une instruction de type 'move-wide'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'move-wide/16'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_wide_16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_WIDE_16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_32X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             *  *  Description : Décode une instruction de type 'move-wide/from16'.           *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * diff --git a/src/arch/dalvik/opcodes/mul.c b/src/arch/dalvik/opcodes/mul.c index aeddd14..959b859 100644 --- a/src/arch/dalvik/opcodes/mul.c +++ b/src/arch/dalvik/opcodes/mul.c @@ -112,7 +112,7 @@ GArchInstruction *dalvik_read_instr_mul_double_2addr(const bin_t *data, off_t *p  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'mul-int'.                    * +*  Description : Décode une instruction de type 'mul-float'.                  *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -120,12 +120,12 @@ GArchInstruction *dalvik_read_instr_mul_double_2addr(const bin_t *data, off_t *p  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_mul_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_mul_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_MUL_INT); +    result = g_dalvik_instruction_new(DOP_MUL_FLOAT);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); @@ -149,7 +149,7 @@ GArchInstruction *dalvik_read_instr_mul_int(const bin_t *data, off_t *pos, off_t  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'mul-int/2addr'.              * +*  Description : Décode une instruction de type 'mul-float/2addr'.            *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -157,12 +157,12 @@ GArchInstruction *dalvik_read_instr_mul_int(const bin_t *data, off_t *pos, off_t  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_mul_int_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_mul_float_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_MUL_INT_2ADDR); +    result = g_dalvik_instruction_new(DOP_MUL_FLOAT_2ADDR);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); @@ -186,7 +186,7 @@ GArchInstruction *dalvik_read_instr_mul_int_2addr(const bin_t *data, off_t *pos,  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'mul-int/lit8'.               * +*  Description : Décode une instruction de type 'mul-int'.                    *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -194,16 +194,16 @@ GArchInstruction *dalvik_read_instr_mul_int_2addr(const bin_t *data, off_t *pos,  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_mul_int_lit8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_mul_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_MUL_INT_LIT8); +    result = g_dalvik_instruction_new(DOP_MUL_INT);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); -    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_22B)) +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X))      {          g_object_unref(G_OBJECT(result));          return NULL; @@ -223,7 +223,7 @@ GArchInstruction *dalvik_read_instr_mul_int_lit8(const bin_t *data, off_t *pos,  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'mul-int/lit16'.              * +*  Description : Décode une instruction de type 'mul-int/2addr'.              *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -231,16 +231,16 @@ GArchInstruction *dalvik_read_instr_mul_int_lit8(const bin_t *data, off_t *pos,  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_mul_int_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_MUL_INT_LIT16); +    result = g_dalvik_instruction_new(DOP_MUL_INT_2ADDR);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); -    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_22S)) +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X))      {          g_object_unref(G_OBJECT(result));          return NULL; @@ -260,7 +260,7 @@ GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *data, off_t *pos,  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'mul-float'.                  * +*  Description : Décode une instruction de type 'mul-int/lit8'.               *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -268,16 +268,16 @@ GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *data, off_t *pos,  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_mul_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_mul_int_lit8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_MUL_FLOAT); +    result = g_dalvik_instruction_new(DOP_MUL_INT_LIT8);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); -    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_22B))      {          g_object_unref(G_OBJECT(result));          return NULL; @@ -297,7 +297,7 @@ GArchInstruction *dalvik_read_instr_mul_float(const bin_t *data, off_t *pos, off  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'mul-float/2addr'.            * +*  Description : Décode une instruction de type 'mul-int/lit16'.              *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -305,16 +305,16 @@ GArchInstruction *dalvik_read_instr_mul_float(const bin_t *data, off_t *pos, off  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_mul_float_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_MUL_FLOAT_2ADDR); +    result = g_dalvik_instruction_new(DOP_MUL_INT_LIT16);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); -    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_22S))      {          g_object_unref(G_OBJECT(result));          return NULL; diff --git a/src/arch/dalvik/opcodes/neg.c b/src/arch/dalvik/opcodes/neg.c new file mode 100644 index 0000000..ce96a68 --- /dev/null +++ b/src/arch/dalvik/opcodes/neg.c @@ -0,0 +1,177 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * neg.c - décodage des instructions de négations + * + * Copyright (C) 2012 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "opcodes.h" + + +#include "../instruction.h" +#include "../operand.h" + + + +/****************************************************************************** +*                                                                             * +*  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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'neg-double'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_neg_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NEG_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'neg-float'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_neg_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NEG_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'neg-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_neg_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NEG_INT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'neg-long'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_neg_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NEG_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/not.c b/src/arch/dalvik/opcodes/not.c new file mode 100644 index 0000000..2bbb61a --- /dev/null +++ b/src/arch/dalvik/opcodes/not.c @@ -0,0 +1,103 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * not.c - décodage des instructions de négations booléennes + * + * Copyright (C) 2012 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "opcodes.h" + + +#include "../instruction.h" +#include "../operand.h" + + + +/****************************************************************************** +*                                                                             * +*  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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'not-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_not_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NOT_INT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'not-long'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_not_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NOT_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/opcodes.h b/src/arch/dalvik/opcodes/opcodes.h index 5a6d157..bed6879 100644 --- a/src/arch/dalvik/opcodes/opcodes.h +++ b/src/arch/dalvik/opcodes/opcodes.h @@ -34,8 +34,6 @@  /* Prototype de décodage d'une instruction Dalvik. */  typedef GArchInstruction * (* dalvik_read_instr) (const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -  /* Décode une instruction de type 'add-double'. */  GArchInstruction *dalvik_read_instr_add_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -66,7 +64,6 @@ GArchInstruction *dalvik_read_instr_add_long(const bin_t *, off_t *, off_t, vmpa  /* Décode une instruction de type 'add-long/2addr'. */  GArchInstruction *dalvik_read_instr_add_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'aget'. */  GArchInstruction *dalvik_read_instr_aget(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -88,9 +85,6 @@ GArchInstruction *dalvik_read_instr_aget_short(const bin_t *, off_t *, off_t, vm  /* Décode une instruction de type 'aget-wide'. */  GArchInstruction *dalvik_read_instr_aget_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - -  /* Décode une instruction de type 'and-int'. */  GArchInstruction *dalvik_read_instr_and_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -103,9 +97,11 @@ GArchInstruction *dalvik_read_instr_and_int_lit8(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'and-int/lit16'. */  GArchInstruction *dalvik_read_instr_and_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'and-long'. */ +GArchInstruction *dalvik_read_instr_and_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - +/* Décode une instruction de type 'and-long/2addr'. */ +GArchInstruction *dalvik_read_instr_and_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'aput'. */  GArchInstruction *dalvik_read_instr_aput(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -128,18 +124,12 @@ GArchInstruction *dalvik_read_instr_aput_short(const bin_t *, off_t *, off_t, vm  /* Décode une instruction de type 'aput-wide'. */  GArchInstruction *dalvik_read_instr_aput_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - - -  /* Décode une instruction de type 'array-length'. */  GArchInstruction *dalvik_read_instr_array_length(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'check-cast'. */  GArchInstruction *dalvik_read_instr_check_cast(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'cmp-long'. */  GArchInstruction *dalvik_read_instr_cmp_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -155,10 +145,6 @@ GArchInstruction *dalvik_read_instr_cmpl_double(const bin_t *, off_t *, off_t, v  /* Décode une instruction de type 'cmpl-float'. */  GArchInstruction *dalvik_read_instr_cmpl_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - - -  /* Décode une instruction de type 'const'. */  GArchInstruction *dalvik_read_instr_const(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -192,7 +178,17 @@ GArchInstruction *dalvik_read_instr_const_wide_32(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'const-wide/high16'. */  GArchInstruction *dalvik_read_instr_const_wide_high16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'div-double'. */ +GArchInstruction *dalvik_read_instr_div_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'div-double/2addr'. */ +GArchInstruction *dalvik_read_instr_div_double_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'div-float'. */ +GArchInstruction *dalvik_read_instr_div_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'div-float/2addr'. */ +GArchInstruction *dalvik_read_instr_div_float_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'div-int'. */  GArchInstruction *dalvik_read_instr_div_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -209,10 +205,17 @@ GArchInstruction *dalvik_read_instr_div_int_lit16(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'div-long'. */  GArchInstruction *dalvik_read_instr_div_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'div-long/2addr'. */ +GArchInstruction *dalvik_read_instr_div_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* 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 *, const GDexFormat *); +/* Décode une instruction de type 'filled-new-array'. */ +GArchInstruction *dalvik_read_instr_filled_new_array(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'filled-new-array/range'. */ +GArchInstruction *dalvik_read_instr_filled_new_array_range(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'goto'. */  GArchInstruction *dalvik_read_instr_goto(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -223,8 +226,6 @@ GArchInstruction *dalvik_read_instr_goto_16(const bin_t *, off_t *, off_t, vmpa_  /* Décode une instruction de type 'goto/32'. */  GArchInstruction *dalvik_read_instr_goto_32(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -  /* Décode une instruction de type 'if-eq'. */  GArchInstruction *dalvik_read_instr_if_eq(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -261,9 +262,6 @@ GArchInstruction *dalvik_read_instr_if_ne(const bin_t *, off_t *, off_t, vmpa_t,  /* Décode une instruction de type 'if-nez'. */  GArchInstruction *dalvik_read_instr_if_nez(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - -  /* Décode une instruction de type 'iget'. */  GArchInstruction *dalvik_read_instr_iget(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -285,9 +283,8 @@ GArchInstruction *dalvik_read_instr_iget_short(const bin_t *, off_t *, off_t, vm  /* Décode une instruction de type 'iget-wide'. */  GArchInstruction *dalvik_read_instr_iget_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - - +/* Décode une instruction de type 'instance-of'. */ +GArchInstruction *dalvik_read_instr_instance_of(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'invoke-direct'. */  GArchInstruction *dalvik_read_instr_invoke_direct(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -319,9 +316,6 @@ GArchInstruction *dalvik_read_instr_invoke_virtual(const bin_t *, off_t *, off_t  /* Décode une instruction de type 'invoke-virtual/range'. */  GArchInstruction *dalvik_read_instr_invoke_virtual_range(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - -  /* Décode une instruction de type 'iput'. */  GArchInstruction *dalvik_read_instr_iput(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -343,9 +337,11 @@ GArchInstruction *dalvik_read_instr_iput_short(const bin_t *, off_t *, off_t, vm  /* Décode une instruction de type 'iput-wide'. */  GArchInstruction *dalvik_read_instr_iput_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'monitor-enter'. */ +GArchInstruction *dalvik_read_instr_monitor_enter(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - +/* Décode une instruction de type 'monitor-exit'. */ +GArchInstruction *dalvik_read_instr_monitor_exit(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'move'. */  GArchInstruction *dalvik_read_instr_move(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -353,12 +349,18 @@ 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 *, const GDexFormat *); +/* Décode une instruction de type 'move/16'. */ +GArchInstruction *dalvik_read_instr_move_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +  /* 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 *, const GDexFormat *);  /* 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 *, const GDexFormat *); +/* Décode une instruction de type 'move-object/16'. */ +GArchInstruction *dalvik_read_instr_move_object_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +  /* Décode une instruction de type 'move-object/from16'. */  GArchInstruction *dalvik_read_instr_move_object_from_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -371,16 +373,27 @@ GArchInstruction *dalvik_read_instr_move_result_object(const bin_t *, off_t *, o  /* Décode une instruction de type 'move-result-wide'. */  GArchInstruction *dalvik_read_instr_move_result_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'move-wide'. */ +GArchInstruction *dalvik_read_instr_move_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'move-wide/16'. */ +GArchInstruction *dalvik_read_instr_move_wide_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +  /* Décode une instruction de type 'move-wide/from16'. */  GArchInstruction *dalvik_read_instr_move_wide_from_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'mul-double'. */  GArchInstruction *dalvik_read_instr_mul_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'mul-double/2addr'. */  GArchInstruction *dalvik_read_instr_mul_double_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'mul-float'. */ +GArchInstruction *dalvik_read_instr_mul_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'mul-float/2addr'. */ +GArchInstruction *dalvik_read_instr_mul_float_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +  /* Décode une instruction de type 'mul-int'. */  GArchInstruction *dalvik_read_instr_mul_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -393,19 +406,23 @@ GArchInstruction *dalvik_read_instr_mul_int_lit8(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'mul-int/lit16'. */  GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -/* Décode une instruction de type 'mul-float'. */ -GArchInstruction *dalvik_read_instr_mul_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -/* Décode une instruction de type 'mul-float/2addr'. */ -GArchInstruction *dalvik_read_instr_mul_float_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'mul-long'. */  GArchInstruction *dalvik_read_instr_mul_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'mul-long/2addr'. */  GArchInstruction *dalvik_read_instr_mul_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'neg-double'. */ +GArchInstruction *dalvik_read_instr_neg_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'neg-float'. */ +GArchInstruction *dalvik_read_instr_neg_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'neg-int'. */ +GArchInstruction *dalvik_read_instr_neg_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'neg-long'. */ +GArchInstruction *dalvik_read_instr_neg_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'new-array'. */  GArchInstruction *dalvik_read_instr_new_array(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -416,8 +433,11 @@ GArchInstruction *dalvik_read_instr_new_instance(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'nop'. */  GArchInstruction *dalvik_read_instr_nop(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'not-int'. */ +GArchInstruction *dalvik_read_instr_not_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - +/* Décode une instruction de type 'not-long'. */ +GArchInstruction *dalvik_read_instr_not_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'or-int'. */  GArchInstruction *dalvik_read_instr_or_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -431,10 +451,26 @@ GArchInstruction *dalvik_read_instr_or_int_lit8(const bin_t *, off_t *, off_t, v  /* Décode une instruction de type 'or-int/lit16'. */  GArchInstruction *dalvik_read_instr_or_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'or-long'. */ +GArchInstruction *dalvik_read_instr_or_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'or-long/2addr'. */ +GArchInstruction *dalvik_read_instr_or_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'packed-switch'. */  GArchInstruction *dalvik_read_instr_packed_switch(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'rem-double'. */ +GArchInstruction *dalvik_read_instr_rem_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'rem-double/2addr'. */ +GArchInstruction *dalvik_read_instr_rem_double_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'rem-float'. */ +GArchInstruction *dalvik_read_instr_rem_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'rem-float/2addr'. */ +GArchInstruction *dalvik_read_instr_rem_float_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'rem-int'. */  GArchInstruction *dalvik_read_instr_rem_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -448,6 +484,11 @@ GArchInstruction *dalvik_read_instr_rem_int_lit8(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'rem-int/lit16'. */  GArchInstruction *dalvik_read_instr_rem_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'rem-long'. */ +GArchInstruction *dalvik_read_instr_rem_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'rem-long/2addr'. */ +GArchInstruction *dalvik_read_instr_rem_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'rsub-int'. */  GArchInstruction *dalvik_read_instr_rsub_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -455,9 +496,6 @@ GArchInstruction *dalvik_read_instr_rsub_int(const bin_t *, off_t *, off_t, vmpa  /* Décode une instruction de type 'rsub-int/lit8'. */  GArchInstruction *dalvik_read_instr_rsub_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - -  /* Décode une instruction de type 'return'. */  GArchInstruction *dalvik_read_instr_return(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -470,10 +508,6 @@ GArchInstruction *dalvik_read_instr_return_void(const bin_t *, off_t *, off_t, v  /* Décode une instruction de type 'return-wide'. */  GArchInstruction *dalvik_read_instr_return_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - - -  /* Décode une instruction de type 'sget'. */  GArchInstruction *dalvik_read_instr_sget(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -495,7 +529,6 @@ GArchInstruction *dalvik_read_instr_sget_short(const bin_t *, off_t *, off_t, vm  /* Décode une instruction de type 'sget-wide'. */  GArchInstruction *dalvik_read_instr_sget_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'shl-int'. */  GArchInstruction *dalvik_read_instr_shl_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -526,13 +559,9 @@ GArchInstruction *dalvik_read_instr_shr_long(const bin_t *, off_t *, off_t, vmpa  /* Décode une instruction de type 'shr-long/2addr'. */  GArchInstruction *dalvik_read_instr_shr_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -  /* Décode une instruction de type 'sparse-switch'. */  GArchInstruction *dalvik_read_instr_sparse_switch(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -  /* Décode une instruction de type 'sput'. */  GArchInstruction *dalvik_read_instr_sput(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -554,36 +583,30 @@ GArchInstruction *dalvik_read_instr_sput_short(const bin_t *, off_t *, off_t, vm  /* Décode une instruction de type 'sput-wide'. */  GArchInstruction *dalvik_read_instr_sput_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -  /* Décode une instruction de type 'sub-double'. */  GArchInstruction *dalvik_read_instr_sub_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'sub-double/2addr'. */  GArchInstruction *dalvik_read_instr_sub_double_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -/* Décode une instruction de type 'sub-int'. */ -GArchInstruction *dalvik_read_instr_sub_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - -/* Décode une instruction de type 'sub-int/2addr'. */ -GArchInstruction *dalvik_read_instr_sub_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); -  /* Décode une instruction de type 'sub-float'. */  GArchInstruction *dalvik_read_instr_sub_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'sub-float/2addr'. */  GArchInstruction *dalvik_read_instr_sub_float_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'sub-int'. */ +GArchInstruction *dalvik_read_instr_sub_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); + +/* Décode une instruction de type 'sub-int/2addr'. */ +GArchInstruction *dalvik_read_instr_sub_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +  /* Décode une instruction de type 'sub-long'. */  GArchInstruction *dalvik_read_instr_sub_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'sub-long/2addr'. */  GArchInstruction *dalvik_read_instr_sub_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - - -  /* Décode une instruction de type 'int-to-byte'. */  GArchInstruction *dalvik_read_instr_to_int_byte(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -629,8 +652,8 @@ GArchInstruction *dalvik_read_instr_to_long_float(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'long-to-int'. */  GArchInstruction *dalvik_read_instr_to_long_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - +/* Décode une instruction de type 'throw'. */ +GArchInstruction *dalvik_read_instr_throw(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *);  /* Décode une instruction de type 'ushr-int'. */  GArchInstruction *dalvik_read_instr_ushr_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -647,12 +670,6 @@ GArchInstruction *dalvik_read_instr_ushr_long(const bin_t *, off_t *, off_t, vmp  /* Décode une instruction de type 'ushr-long/2addr'. */  GArchInstruction *dalvik_read_instr_ushr_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - - - - - -  /* Décode une instruction de type 'xor-int'. */  GArchInstruction *dalvik_read_instr_xor_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); @@ -665,8 +682,11 @@ GArchInstruction *dalvik_read_instr_xor_int_lit8(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'xor-int/lit16'. */  GArchInstruction *dalvik_read_instr_xor_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); +/* Décode une instruction de type 'xor-long'. */ +GArchInstruction *dalvik_read_instr_xor_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); - +/* Décode une instruction de type 'xor-long/2addr'. */ +GArchInstruction *dalvik_read_instr_xor_long_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *, const GDexFormat *); diff --git a/src/arch/dalvik/opcodes/or.c b/src/arch/dalvik/opcodes/or.c index 0089190..6e57ef1 100644 --- a/src/arch/dalvik/opcodes/or.c +++ b/src/arch/dalvik/opcodes/or.c @@ -175,3 +175,77 @@ GArchInstruction *dalvik_read_instr_or_int_lit16(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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'or-long'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_or_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_OR_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'or-long/2addr'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_or_long_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_OR_LONG_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/rem.c b/src/arch/dalvik/opcodes/rem.c index fb73e50..687b651 100644 --- a/src/arch/dalvik/opcodes/rem.c +++ b/src/arch/dalvik/opcodes/rem.c @@ -38,6 +38,154 @@  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * +*  Description : Décode une instruction de type 'rem-double'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_REM_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'rem-double/2addr'.           * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_double_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_REM_DOUBLE_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'rem-float'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_REM_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'rem-float/2addr'.            * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_float_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_REM_FLOAT_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             *  *  Description : Décode une instruction de type 'rem-int'.                    *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -175,3 +323,77 @@ GArchInstruction *dalvik_read_instr_rem_int_lit16(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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'rem-long'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_REM_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'rem-long/2addr'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_long_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_REM_LONG_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/sub.c b/src/arch/dalvik/opcodes/sub.c index c35b9fd..42eef73 100644 --- a/src/arch/dalvik/opcodes/sub.c +++ b/src/arch/dalvik/opcodes/sub.c @@ -112,7 +112,7 @@ GArchInstruction *dalvik_read_instr_sub_double_2addr(const bin_t *data, off_t *p  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'sub-int'.                    * +*  Description : Décode une instruction de type 'sub-float'.                  *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -120,12 +120,12 @@ GArchInstruction *dalvik_read_instr_sub_double_2addr(const bin_t *data, off_t *p  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_sub_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_sub_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_SUB_INT); +    result = g_dalvik_instruction_new(DOP_SUB_FLOAT);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); @@ -149,7 +149,7 @@ GArchInstruction *dalvik_read_instr_sub_int(const bin_t *data, off_t *pos, off_t  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'sub-int/2addr'.              * +*  Description : Décode une instruction de type 'sub-float/2addr'.            *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -157,12 +157,12 @@ GArchInstruction *dalvik_read_instr_sub_int(const bin_t *data, off_t *pos, off_t  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_sub_int_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_sub_float_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_SUB_INT_2ADDR); +    result = g_dalvik_instruction_new(DOP_SUB_FLOAT_2ADDR);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); @@ -186,7 +186,7 @@ GArchInstruction *dalvik_read_instr_sub_int_2addr(const bin_t *data, off_t *pos,  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'sub-float'.                  * +*  Description : Décode une instruction de type 'sub-int'.                    *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -194,12 +194,12 @@ GArchInstruction *dalvik_read_instr_sub_int_2addr(const bin_t *data, off_t *pos,  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_sub_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_sub_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_SUB_FLOAT); +    result = g_dalvik_instruction_new(DOP_SUB_INT);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); @@ -223,7 +223,7 @@ GArchInstruction *dalvik_read_instr_sub_float(const bin_t *data, off_t *pos, off  *                proc = architecture ciblée par le désassemblage.             *  *                fmt  = format du fichier contenant le code.                  *  *                                                                             * -*  Description : Décode une instruction de type 'sub-float/2addr'.            * +*  Description : Décode une instruction de type 'sub-int/2addr'.              *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           *  *                                                                             * @@ -231,12 +231,12 @@ GArchInstruction *dalvik_read_instr_sub_float(const bin_t *data, off_t *pos, off  *                                                                             *  ******************************************************************************/ -GArchInstruction *dalvik_read_instr_sub_float_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +GArchInstruction *dalvik_read_instr_sub_int_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt)  {      GArchInstruction *result;               /* Instruction à retourner     */      SourceEndian endian;                    /* Boutisme lié au binaire     */ -    result = g_dalvik_instruction_new(DOP_SUB_FLOAT_2ADDR); +    result = g_dalvik_instruction_new(DOP_SUB_INT_2ADDR);      endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); diff --git a/src/arch/dalvik/opcodes/throw.c b/src/arch/dalvik/opcodes/throw.c new file mode 100644 index 0000000..64b2bbd --- /dev/null +++ b/src/arch/dalvik/opcodes/throw.c @@ -0,0 +1,66 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * monitor.c - décodage des opérations d'envoi d'exceptions + * + * Copyright (C) 2012 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "opcodes.h" + + +#include "../instruction.h" +#include "../operand.h" + + + +/****************************************************************************** +*                                                                             * +*  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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'throw'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_throw(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_THROW); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_11X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes/xor.c b/src/arch/dalvik/opcodes/xor.c index 52b0b0f..40c5ef9 100644 --- a/src/arch/dalvik/opcodes/xor.c +++ b/src/arch/dalvik/opcodes/xor.c @@ -175,3 +175,77 @@ GArchInstruction *dalvik_read_instr_xor_int_lit16(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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'xor-long'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_xor_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_XOR_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        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.             * +*                fmt  = format du fichier contenant le code.                  * +*                                                                             * +*  Description : Décode une instruction de type 'xor-long/2addr'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_xor_long_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc, const GDexFormat *fmt) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_XOR_LONG_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, fmt, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index a48a5ce..1bc9d4a 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -253,6 +253,14 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const GDexFormat              };              break; +        case DALVIK_OPT_32X: +            types = (DalvikOperandID []) { +                DOI_REGISTER_16, +                DOI_REGISTER_16, +                DOI_INVALID +            }; +            break; +          case DALVIK_OPT_51L:              types = (DalvikOperandID []) {                  DOI_REGISTER_8, @@ -591,6 +599,7 @@ bool dalvik_read_operands(GArchInstruction *instr, const GDexFormat *format, con          case DALVIK_OPT_31C:          case DALVIK_OPT_31I:          case DALVIK_OPT_31T: +        case DALVIK_OPT_32X:          case DALVIK_OPT_51L:              va_start(ap, model);              result = dalvik_read_basic_operands(instr, format, data, pos, len, &low, endian, model, ap); diff --git a/src/arch/dalvik/operand.h b/src/arch/dalvik/operand.h index fd95b52..9b4a289 100644 --- a/src/arch/dalvik/operand.h +++ b/src/arch/dalvik/operand.h @@ -98,6 +98,8 @@ typedef enum _DalvikOperandType      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_32X      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(2) | 'X', +      DALVIK_OPT_35C      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(5) | 'C',      DALVIK_OPT_3RC      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(DALVIK_OP_REG_RANGE) | 'C', diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index fbba5e2..be1e2e5 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -261,13 +261,13 @@ 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_16]               = dalvik_read_instr_move_16, +        [DOP_MOVE_WIDE]             = dalvik_read_instr_move_wide,          [DOP_MOVE_WIDE_FROM_16]     = dalvik_read_instr_move_wide_from_16, - +        [DOP_MOVE_WIDE_16]          = dalvik_read_instr_move_wide_16,          [DOP_MOVE_OBJECT]           = dalvik_read_instr_move_object,          [DOP_MOVE_OBJECT_FROM_16]   = dalvik_read_instr_move_object_from_16, - +        [DOP_MOVE_OBJECT_16]        = dalvik_read_instr_move_object_16,          [DOP_MOVE_RESULT]           = dalvik_read_instr_move_result,          [DOP_MOVE_RESULT_WIDE]      = dalvik_read_instr_move_result_wide,          [DOP_MOVE_RESULT_OBJECT]    = dalvik_read_instr_move_result_object, @@ -287,15 +287,17 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_CONST_STRING]          = dalvik_read_instr_const_string,          [DOP_CONST_STRING_JUMBO]    = dalvik_read_instr_const_string_jumbo,          [DOP_CONST_CLASS]           = dalvik_read_instr_const_class, - +        [DOP_MONITOR_ENTER]         = dalvik_read_instr_monitor_enter, +        [DOP_MONITOR_EXIT]          = dalvik_read_instr_monitor_exit,          [DOP_CHECK_CAST]            = dalvik_read_instr_check_cast, - +        [DOP_INSTANCE_OF]           = dalvik_read_instr_instance_of,          [DOP_ARRAY_LENGTH]          = dalvik_read_instr_array_length,          [DOP_NEW_INSTANCE]          = dalvik_read_instr_new_instance,          [DOP_NEW_ARRAY]             = dalvik_read_instr_new_array, - +        [DOP_FILLED_NEW_ARRAY]      = dalvik_read_instr_filled_new_array, +        [DOP_FILLED_NEW_ARRAY_RANGE]= dalvik_read_instr_filled_new_array_range,          [DOP_FILL_ARRAY_DATA]       = dalvik_read_instr_fill_array_data, - +        [DOP_THROW]                 = dalvik_read_instr_throw,          [DOP_GOTO]                  = dalvik_read_instr_goto,          [DOP_GOTO_16]               = dalvik_read_instr_goto_16,          [DOP_GOTO_32]               = dalvik_read_instr_goto_32, @@ -318,10 +320,6 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_IF_GEZ]                = dalvik_read_instr_if_gez,          [DOP_IF_GTZ]                = dalvik_read_instr_if_gtz,          [DOP_IF_LEZ]                = dalvik_read_instr_if_lez, - - - -          [DOP_AGET]                  = dalvik_read_instr_aget,          [DOP_AGET_WIDE]             = dalvik_read_instr_aget_wide,          [DOP_AGET_OBJECT]           = dalvik_read_instr_aget_object, @@ -374,8 +372,12 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_INVOKE_DIRECT_RANGE]   = dalvik_read_instr_invoke_direct_range,          [DOP_INVOKE_STATIC_RANGE]   = dalvik_read_instr_invoke_static_range,          [DOP_INVOKE_INTERFACE_RANGE]= dalvik_read_instr_invoke_interface_range, - - +        [DOP_NEG_INT]               = dalvik_read_instr_neg_int, +        [DOP_NOT_INT]               = dalvik_read_instr_not_int, +        [DOP_NEG_LONG]              = dalvik_read_instr_neg_long, +        [DOP_NOT_LONG]              = dalvik_read_instr_not_long, +        [DOP_NEG_FLOAT]             = dalvik_read_instr_neg_float, +        [DOP_NEG_DOUBLE]            = dalvik_read_instr_neg_double,          [DOP_TO_INT_LONG]           = dalvik_read_instr_to_int_long,          [DOP_TO_INT_FLOAT]          = dalvik_read_instr_to_int_float,          [DOP_TO_INT_DOUBLE]         = dalvik_read_instr_to_int_double, @@ -402,19 +404,27 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_SHL_INT]               = dalvik_read_instr_shl_int,          [DOP_SHR_INT]               = dalvik_read_instr_shr_int,          [DOP_USHR_INT]              = dalvik_read_instr_ushr_int, - - -        [DOP_ADD_LONG]               = dalvik_read_instr_add_long, -        [DOP_SUB_LONG]               = dalvik_read_instr_sub_long, -        [DOP_MUL_LONG]               = dalvik_read_instr_mul_long, -        [DOP_DIV_LONG]               = dalvik_read_instr_div_long, - - -        [DOP_SHL_LONG]               = dalvik_read_instr_shl_long, -        [DOP_SHR_LONG]               = dalvik_read_instr_shr_long, -        [DOP_USHR_LONG]              = dalvik_read_instr_ushr_long, - - +        [DOP_ADD_LONG]              = dalvik_read_instr_add_long, +        [DOP_SUB_LONG]              = dalvik_read_instr_sub_long, +        [DOP_MUL_LONG]              = dalvik_read_instr_mul_long, +        [DOP_DIV_LONG]              = dalvik_read_instr_div_long, +        [DOP_REM_LONG]              = dalvik_read_instr_rem_long, +        [DOP_AND_LONG]              = dalvik_read_instr_and_long, +        [DOP_OR_LONG]               = dalvik_read_instr_or_long, +        [DOP_XOR_LONG]              = dalvik_read_instr_xor_long, +        [DOP_SHL_LONG]              = dalvik_read_instr_shl_long, +        [DOP_SHR_LONG]              = dalvik_read_instr_shr_long, +        [DOP_USHR_LONG]             = dalvik_read_instr_ushr_long, +        [DOP_ADD_FLOAT]             = dalvik_read_instr_add_float, +        [DOP_SUB_FLOAT]             = dalvik_read_instr_sub_float, +        [DOP_MUL_FLOAT]             = dalvik_read_instr_mul_float, +        [DOP_DIV_FLOAT]             = dalvik_read_instr_div_float, +        [DOP_REM_FLOAT]             = dalvik_read_instr_rem_float, +        [DOP_ADD_DOUBLE]            = dalvik_read_instr_add_double, +        [DOP_SUB_DOUBLE]            = dalvik_read_instr_sub_double, +        [DOP_MUL_DOUBLE]            = dalvik_read_instr_mul_double, +        [DOP_DIV_DOUBLE]            = dalvik_read_instr_div_double, +        [DOP_REM_DOUBLE]            = dalvik_read_instr_rem_double,          [DOP_ADD_INT_2ADDR]         = dalvik_read_instr_add_int_2addr,          [DOP_SUB_INT_2ADDR]         = dalvik_read_instr_sub_int_2addr,          [DOP_MUL_INT_2ADDR]         = dalvik_read_instr_mul_int_2addr, @@ -429,19 +439,24 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_ADD_LONG_2ADDR]        = dalvik_read_instr_add_long_2addr,          [DOP_SUB_LONG_2ADDR]        = dalvik_read_instr_sub_long_2addr,          [DOP_MUL_LONG_2ADDR]        = dalvik_read_instr_mul_long_2addr, - +        [DOP_DIV_LONG_2ADDR]        = dalvik_read_instr_div_long_2addr, +        [DOP_REM_LONG_2ADDR]        = dalvik_read_instr_rem_long_2addr, +        [DOP_AND_LONG_2ADDR]        = dalvik_read_instr_and_long_2addr, +        [DOP_OR_LONG_2ADDR]         = dalvik_read_instr_or_long_2addr, +        [DOP_XOR_LONG_2ADDR]        = dalvik_read_instr_xor_long_2addr,          [DOP_SHL_LONG_2ADDR]        = dalvik_read_instr_shl_long_2addr,          [DOP_SHR_LONG_2ADDR]        = dalvik_read_instr_shr_long_2addr,          [DOP_USHR_LONG_2ADDR]       = dalvik_read_instr_ushr_long_2addr, -          [DOP_ADD_FLOAT_2ADDR]       = dalvik_read_instr_add_float_2addr,          [DOP_SUB_FLOAT_2ADDR]       = dalvik_read_instr_sub_float_2addr,          [DOP_MUL_FLOAT_2ADDR]       = dalvik_read_instr_mul_float_2addr, - +        [DOP_DIV_FLOAT_2ADDR]       = dalvik_read_instr_div_float_2addr, +        [DOP_REM_FLOAT_2ADDR]       = dalvik_read_instr_rem_float_2addr,          [DOP_ADD_DOUBLE_2ADDR]      = dalvik_read_instr_add_double_2addr,          [DOP_SUB_DOUBLE_2ADDR]      = dalvik_read_instr_sub_double_2addr,          [DOP_MUL_DOUBLE_2ADDR]      = dalvik_read_instr_mul_double_2addr, - +        [DOP_DIV_DOUBLE_2ADDR]      = dalvik_read_instr_div_double_2addr, +        [DOP_REM_DOUBLE_2ADDR]      = dalvik_read_instr_rem_double_2addr,          [DOP_ADD_INT_LIT16]         = dalvik_read_instr_add_int_lit16,          [DOP_RSUB_INT]              = dalvik_read_instr_rsub_int,          [DOP_MUL_INT_LIT16]         = dalvik_read_instr_mul_int_lit16,  | 
