diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/dalvik/Makefile.am | 9 | ||||
| -rw-r--r-- | src/arch/dalvik/instruction.c | 97 | ||||
| -rw-r--r-- | src/arch/dalvik/instruction.h | 97 | ||||
| -rw-r--r-- | src/arch/dalvik/op_aget.c | 281 | ||||
| -rw-r--r-- | src/arch/dalvik/op_aput.c | 281 | ||||
| -rw-r--r-- | src/arch/dalvik/op_array.c | 65 | ||||
| -rw-r--r-- | src/arch/dalvik/op_check.c | 65 | ||||
| -rw-r--r-- | src/arch/dalvik/op_cmp.c | 209 | ||||
| -rw-r--r-- | src/arch/dalvik/op_const.c | 109 | ||||
| -rw-r--r-- | src/arch/dalvik/op_goto.c | 137 | ||||
| -rw-r--r-- | src/arch/dalvik/op_if.c | 461 | ||||
| -rw-r--r-- | src/arch/dalvik/op_move.c | 180 | ||||
| -rw-r--r-- | src/arch/dalvik/op_mul.c | 36 | ||||
| -rw-r--r-- | src/arch/dalvik/op_new.c | 36 | ||||
| -rw-r--r-- | src/arch/dalvik/op_ret.c | 72 | ||||
| -rw-r--r-- | src/arch/dalvik/op_sget.c | 146 | ||||
| -rw-r--r-- | src/arch/dalvik/op_sput.c | 281 | ||||
| -rw-r--r-- | src/arch/dalvik/op_to.c | 569 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes.h | 250 | ||||
| -rw-r--r-- | src/arch/dalvik/operand.c | 310 | ||||
| -rw-r--r-- | src/arch/dalvik/operand.h | 43 | ||||
| -rw-r--r-- | src/arch/dalvik/processor.c | 95 | ||||
| -rw-r--r-- | src/arch/x86/operand.c | 4 | ||||
| -rw-r--r-- | src/arch/x86/operand.h | 2 | ||||
| -rwxr-xr-x | src/common/endianness.c | 59 | 
25 files changed, 3835 insertions, 59 deletions
| diff --git a/src/arch/dalvik/Makefile.am b/src/arch/dalvik/Makefile.am index 942c2c3..595bc4f 100644 --- a/src/arch/dalvik/Makefile.am +++ b/src/arch/dalvik/Makefile.am @@ -4,9 +4,16 @@ noinst_LTLIBRARIES = libarchdalvik.la  libarchdalvik_la_SOURCES =				\  	instruction.h instruction.c			\  	op_add.c							\ +	op_aget.c							\  	op_and.c							\ +	op_aput.c							\ +	op_array.c							\ +	op_check.c							\ +	op_cmp.c							\  	op_const.c							\  	op_div.c							\ +	op_goto.c							\ +	op_if.c								\  	op_iget.c							\  	op_invoke.c							\  	op_iput.c							\ @@ -19,6 +26,8 @@ libarchdalvik_la_SOURCES =				\  	op_ret.c							\  	op_rsub.c							\  	op_sget.c							\ +	op_sput.c							\ +	op_to.c								\  	op_xor.c							\  	opcodes.h							\  	operand.h operand.c					\ diff --git a/src/arch/dalvik/instruction.c b/src/arch/dalvik/instruction.c index 165d4d2..17c19a4 100644 --- a/src/arch/dalvik/instruction.c +++ b/src/arch/dalvik/instruction.c @@ -69,25 +69,74 @@ typedef struct _dalvik_instruction  static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_NOP]                   = { 0x00, "nop" }, +    [DOP_MOVE]                  = { 0x01, "move" }, -    [DOP_MOVE_RESULT_OBJECT]    = { 0x0c, "move-result-object" }, +    [DOP_MOVE_OBJECT]           = { 0x07, "move-object" }, +    [DOP_MOVE_RESULT]           = { 0x0a, "move-result" }, +    [DOP_MOVE_RESULT_WIDE]      = { 0x0b, "move-result-wide" }, +    [DOP_MOVE_RESULT_OBJECT]    = { 0x0c, "move-result-object" }, +    [DOP_MOVE_EXCEPTION]        = { 0x0d, "move-exception" }, +    [DOP_RETURN_VOID]           = { 0x0e, "return-void" }, +    [DOP_RETURN]                = { 0x0f, "return" }, +    [DOP_RETURN_WIDE]           = { 0x10, "return-wide" }, +    [DOP_RETURN_OBJECT]         = { 0x11, "return-object" },      [DOP_CONST_4]               = { 0x12, "const/4" },      [DOP_CONST_16]              = { 0x13, "const/16" }, - - +    [DOP_CONST]                 = { 0x14, "const" },      [DOP_CONST_HIGH16]          = { 0x15, "const/high16" }, +    [DOP_CONST_WIDE_16]         = { 0x16, "const-wide/16" }, + +    [DOP_CONST_WIDE]            = { 0x18, "const-wide" },      [DOP_CONST_STRING]          = { 0x1a, "const-string" }, - -    [DOP_RETURN_VOID]           = { 0x0e, "return-void" }, -    [DOP_RETURN]                = { 0x0f, "return" }, +    [DOP_CHECK_CAST]            = { 0x1f, "check-cast" }, +    [DOP_ARRAY_LENGTH]          = { 0x21, "array-length" },      [DOP_NEW_INSTANCE]          = { 0x22, "new-instance" }, - - +    [DOP_NEW_ARRAY]             = { 0x23, "new-array" }, + +    [DOP_GOTO]                  = { 0x28, "goto" }, +    [DOP_GOTO_16]               = { 0x29, "goto/16" }, +    [DOP_GOTO_32]               = { 0x2a, "goto/32" }, + +    [DOP_CMPL_FLOAT]            = { 0x2d, "cmp-long" }, +    [DOP_CMPG_FLOAT]            = { 0x2e, "cmpg-float" }, +    [DOP_CMPL_DOUBLE]           = { 0x2f, "cmpl-double" }, +    [DOP_CMPG_DOUBLE]           = { 0x30, "cmpg-double" }, +    [DOP_CMP_LONG]              = { 0x31, "cmp-long" }, +    [DOP_IF_EQ]                 = { 0x32, "if-eq" }, +    [DOP_IF_EQZ]                = { 0x33, "if-eqz" }, +    [DOP_IF_GE]                 = { 0x34, "if-ge" }, +    [DOP_IF_GEZ]                = { 0x35, "if-gez" }, +    [DOP_IF_GT]                 = { 0x36, "if-gt" }, +    [DOP_IF_GTZ]                = { 0x37, "if-gtz" }, +    [DOP_IF_LE]                 = { 0x38, "if-le" }, +    [DOP_IF_LEZ]                = { 0x39, "if-lez" }, +    [DOP_IF_LT]                 = { 0x3a, "if-lt" }, +    [DOP_IF_LTZ]                = { 0x3b, "if-ltz" }, +    [DOP_IF_NE]                 = { 0x3c, "if-ne" }, +    [DOP_IF_NEZ]                = { 0x3d, "if-nez" }, + + + + +    [DOP_AGET]                  = { 0x44, "aget" }, +    [DOP_AGET_WIDE]             = { 0x45, "aget-wide" }, +    [DOP_AGET_OBJECT]           = { 0x46, "aget-object" }, +    [DOP_AGET_BOOLEAN]          = { 0x47, "aget-boolean" }, +    [DOP_AGET_BYTE]             = { 0x48, "aget-byte" }, +    [DOP_AGET_CHAR]             = { 0x49, "aget-char" }, +    [DOP_AGET_SHORT]            = { 0x4a, "aget-short" }, +    [DOP_APUT]                  = { 0x4b, "aput" }, +    [DOP_APUT_WIDE]             = { 0x4c, "aput-wide" }, +    [DOP_APUT_OBJECT]           = { 0x4d, "aput-object" }, +    [DOP_APUT_BOOLEAN]          = { 0x4e, "aput-boolean" }, +    [DOP_APUT_BYTE]             = { 0x4f, "aput-byte" }, +    [DOP_APUT_CHAR]             = { 0x50, "aput-char" }, +    [DOP_APUT_SHORT]            = { 0x51, "aput-short" },      [DOP_IGET]                  = { 0x52, "iget" },      [DOP_IGET_WIDE]             = { 0x53, "iget-wide" },      [DOP_IGET_OBJECT]           = { 0x54, "iget-object" }, @@ -105,17 +154,38 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_SGET]                  = { 0x60, "sget" },      [DOP_SGET_WIDE]             = { 0x61, "sget-wide" },      [DOP_SGET_OBJECT]           = { 0x62, "sget-object" }, - - - +    [DOP_SGET_BOOLEAN]          = { 0x63, "sget-boolean" }, +    [DOP_SGET_BYTE]             = { 0x64, "sget-byte" }, +    [DOP_SGET_CHAR]             = { 0x65, "sget-char" }, +    [DOP_SGET_SHORT]            = { 0x66, "sget-short" }, +    [DOP_SPUT]                  = { 0x67, "sput" }, +    [DOP_SPUT_WIDE]             = { 0x68, "sput-wide" }, +    [DOP_SPUT_OBJECT]           = { 0x69, "sput-object" }, +    [DOP_SPUT_BOOLEAN]          = { 0x6a, "sput-boolean" }, +    [DOP_SPUT_BYTE]             = { 0x6b, "sput-byte" }, +    [DOP_SPUT_CHAR]             = { 0x6c, "sput-char" }, +    [DOP_SPUT_SHORT]            = { 0x6d, "sput-short" },      [DOP_INVOKE_VIRTUAL]        = { 0x6e, "invoke-virtual" },      [DOP_INVOKE_SUPER]          = { 0x6f, "invoke-static" },      [DOP_INVOKE_DIRECT]         = { 0x70, "invoke-direct" },      [DOP_INVOKE_STATIC]         = { 0x71, "invoke-static" },      [DOP_INVOKE_INTERFACE]      = { 0x72, "invoke-interface" }, - - +    [DOP_TO_INT_LONG]           = { 0x81, "int-to-long" }, +    [DOP_TO_INT_FLOAT]          = { 0x82, "int-to-float" }, +    [DOP_TO_INT_DOUBLE]         = { 0x83, "int-to-double" }, +    [DOP_TO_LONG_INT]           = { 0x84, "long-to-int" }, +    [DOP_TO_LONG_FLOAT]         = { 0x85, "long-to-float" }, +    [DOP_TO_LONG_DOUBLE]        = { 0x86, "long-to-double" }, +    [DOP_TO_FLOAT_INT]          = { 0x87, "float-to-int" }, +    [DOP_TO_FLOAT_LONG]         = { 0x88, "float-to-long" }, +    [DOP_TO_FLOAT_DOUBLE]       = { 0x89, "float-to-double" }, +    [DOP_TO_DOUBLE_INT]         = { 0x8a, "double-to-int" }, +    [DOP_TO_DOUBLE_LONG]        = { 0x8b, "double-to-long" }, +    [DOP_TO_DOUBLE_FLOAT]       = { 0x8c, "double-to-float" }, +    [DOP_TO_INT_BYTE]           = { 0x8d, "int-to-byte" }, +    [DOP_TO_INT_CHAR]           = { 0x8e, "int-to-char" }, +    [DOP_TO_INT_SHORT]          = { 0x8f, "int-to-short" },      [DOP_ADD_INT]               = { 0x90, "add-int" },      [DOP_MUL_INT]               = { 0x92, "mul-int" }, @@ -136,6 +206,7 @@ static dalvik_instruction _instructions[DOP_COUNT] = {      [DOP_OR_INT_2ADDR]          = { 0xb6, "or-int/2addr" },      [DOP_XOR_INT_2ADDR]         = { 0xb7, "xor-int/2addr" }, +    [DOP_MUL_DOUBLE_2ADDR]      = { 0xcd, "mul-double/2addr" },      [DOP_ADD_INT_LIT16]         = { 0xd0, "add-int/lit16" },      [DOP_RSUB_INT]              = { 0xd1, "rsub-int" }, diff --git a/src/arch/dalvik/instruction.h b/src/arch/dalvik/instruction.h index 0c9c6e5..4a41668 100644 --- a/src/arch/dalvik/instruction.h +++ b/src/arch/dalvik/instruction.h @@ -33,26 +33,75 @@  typedef enum _DalvikOpcodes  {      DOP_NOP,                                /* nop (0x00)                  */ +    DOP_MOVE,                               /* move (0x01)                 */ +    DOP_MOVE_OBJECT,                        /* move-object (0x07)          */ +    DOP_MOVE_RESULT,                        /* move-result (0x0a)          */ +    DOP_MOVE_RESULT_WIDE,                   /* move-result-wide (0x0b)     */      DOP_MOVE_RESULT_OBJECT,                 /* move-result-object (0x0c)   */ - - +    DOP_MOVE_EXCEPTION,                     /* move-exception (0x0d)       */ +    DOP_RETURN_VOID,                        /* return-void (0x0e)          */ +    DOP_RETURN,                             /* return (0x0f)               */ +    DOP_RETURN_WIDE,                        /* return-wide (0x10)          */ +    DOP_RETURN_OBJECT,                      /* return-object (0x11)        */      DOP_CONST_4,                            /* const/4 (0x12)              */      DOP_CONST_16,                           /* const/16 (0x13)             */ - +    DOP_CONST,                              /* const (0x14)                */      DOP_CONST_HIGH16,                       /* const/high16 (0x15)         */ +    DOP_CONST_WIDE_16,                      /* const-wide/16 (0x16)        */ -    DOP_CONST_STRING,                       /* const-string (0x1a)         */ +    DOP_CONST_WIDE,                         /* const-wide (0x18)           */ +    DOP_CONST_STRING,                       /* const-string (0x1a)         */ -    DOP_RETURN_VOID,                        /* return-void (0x0e)          */ -    DOP_RETURN,                             /* return (0x0f)               */ +    DOP_CHECK_CAST,                         /* check-cast (0x1f)           */ +    DOP_ARRAY_LENGTH,                       /* array-length (0x21)         */      DOP_NEW_INSTANCE,                       /* new-instance (0x22)         */ - - +    DOP_NEW_ARRAY,                          /* new-array (0x23)            */ + + +    DOP_GOTO,                               /* goto (0x28)                 */ +    DOP_GOTO_16,                            /* goto/16 (0x29)              */ +    DOP_GOTO_32,                            /* goto/32 (0x2a)              */ + + +    DOP_CMPL_FLOAT,                         /* cmp-long (0x2d)             */ +    DOP_CMPG_FLOAT,                         /* cmpg-float (0x2e)           */ +    DOP_CMPL_DOUBLE,                        /* cmpl-double (0x2f)          */ +    DOP_CMPG_DOUBLE,                        /* cmpg-double (0x30)          */ +    DOP_CMP_LONG,                           /* cmp-long (0x31)             */ +    DOP_IF_EQ,                              /* if-eq (0x32)                */ +    DOP_IF_EQZ,                             /* if-eqz (0x33)               */ +    DOP_IF_GE,                              /* if-ge (0x34)                */ +    DOP_IF_GEZ,                             /* if-gez (0x35)               */ +    DOP_IF_GT,                              /* if-gt (0x33)                */ +    DOP_IF_GTZ,                             /* if-gtz (0x37)               */ +    DOP_IF_LE,                              /* if-le (0x38)                */ +    DOP_IF_LEZ,                             /* if-lez (0x39)               */ +    DOP_IF_LT,                              /* if-lt (0x3a)                */ +    DOP_IF_LTZ,                             /* if-ltz (0x3b)               */ +    DOP_IF_NE,                              /* if-ne (0x3c)                */ +    DOP_IF_NEZ,                             /* if-nez (0x3d)               */ + + + +    DOP_AGET,                               /* aget (0x44)                 */ +    DOP_AGET_WIDE,                          /* aget-wide (0x45)            */ +    DOP_AGET_OBJECT,                        /* aget-object (0x46)          */ +    DOP_AGET_BOOLEAN,                       /* aget-boolean (0x47)         */ +    DOP_AGET_BYTE,                          /* aget-byte (0x48)            */ +    DOP_AGET_CHAR,                          /* aget-char (0x49)            */ +    DOP_AGET_SHORT,                         /* aget-short (0x4a)           */ +    DOP_APUT,                               /* aput (0x4b)                 */ +    DOP_APUT_WIDE,                          /* aput-wide (0x4c)            */ +    DOP_APUT_OBJECT,                        /* aput-object (0x4d)          */ +    DOP_APUT_BOOLEAN,                       /* aput-boolean (0x4e)         */ +    DOP_APUT_BYTE,                          /* aput-byte (0x4f)            */ +    DOP_APUT_CHAR,                          /* aput-char (0x50)            */ +    DOP_APUT_SHORT,                         /* aput-short (0x51)           */      DOP_IGET,                               /* iget (0x52)                 */      DOP_IGET_WIDE,                          /* iget-wide (0x53)            */      DOP_IGET_OBJECT,                        /* iget-object (0x54)          */ @@ -70,14 +119,40 @@ typedef enum _DalvikOpcodes      DOP_SGET,                               /* sget (0x60)                 */      DOP_SGET_WIDE,                          /* sget-wide (0x61)            */      DOP_SGET_OBJECT,                        /* sget-object (0x62)          */ - - +    DOP_SGET_BOOLEAN,                       /* sget-boolean (0x63)         */ +    DOP_SGET_BYTE,                          /* sget-byte (0x64)            */ +    DOP_SGET_CHAR,                          /* sget-char (0x65)            */ +    DOP_SGET_SHORT,                         /* sget-short (0x66)           */ +    DOP_SPUT,                               /* sput (0x67)                 */ +    DOP_SPUT_WIDE,                          /* sput-wide (0x68)            */ +    DOP_SPUT_OBJECT,                        /* sput-object (0x69)          */ +    DOP_SPUT_BOOLEAN,                       /* sput-boolean (0x6a)         */ +    DOP_SPUT_BYTE,                          /* sput-byte (0x6b)            */ +    DOP_SPUT_CHAR,                          /* sput-char (0x6c)            */ +    DOP_SPUT_SHORT,                         /* sput-short (0x6d)           */      DOP_INVOKE_VIRTUAL,                     /* invoke-virtual (0x6e)       */      DOP_INVOKE_SUPER,                       /* invoke-super (0x6f)         */      DOP_INVOKE_DIRECT,                      /* invoke-direct (0x70)        */      DOP_INVOKE_STATIC,                      /* invoke-static (0x71)        */      DOP_INVOKE_INTERFACE,                   /* invoke-interface (0x72)     */ + + +    DOP_TO_INT_LONG,                        /* int-to-long (0x81)          */ +    DOP_TO_INT_FLOAT,                       /* int-to-float (0x82)         */ +    DOP_TO_INT_DOUBLE,                      /* int-to-double (0x83)        */ +    DOP_TO_LONG_INT,                        /* long-to-int (0x84)          */ +    DOP_TO_LONG_FLOAT,                      /* long-to-float (0x85)        */ +    DOP_TO_LONG_DOUBLE,                     /* long-to-double (0x86)       */ +    DOP_TO_FLOAT_INT,                       /* float-to-int (0x87)         */ +    DOP_TO_FLOAT_LONG,                      /* float-to-long (0x88)        */ +    DOP_TO_FLOAT_DOUBLE,                    /* float-to-double (0x89)      */ +    DOP_TO_DOUBLE_INT,                      /* double-to-int (0x8a)        */ +    DOP_TO_DOUBLE_LONG,                     /* double-to-long (0x8b)       */ +    DOP_TO_DOUBLE_FLOAT,                    /* double-to-float (0x8c)      */ +    DOP_TO_INT_BYTE,                        /* int-to-byte (0x8d)          */ +    DOP_TO_INT_CHAR,                        /* int-to-char (0x8e)          */ +    DOP_TO_INT_SHORT,                       /* int-to-short (0x8f)         */      DOP_ADD_INT,                            /* add-int (0x90)              */      DOP_MUL_INT,                            /* mul-int (0x92)              */ @@ -96,6 +171,8 @@ typedef enum _DalvikOpcodes      DOP_OR_INT_2ADDR,                       /* or-int/2addr (0xb6)         */      DOP_XOR_INT_2ADDR,                      /* xor-int/2addr (0xb7)        */ +    DOP_MUL_DOUBLE_2ADDR,                   /* mul-double/2addr (0xcd)     */ +      DOP_ADD_INT_LIT16,                      /* add-int/lit16 (0xd0)        */      DOP_RSUB_INT,                           /* rsub-int (0xd1)             */      DOP_MUL_INT_LIT16,                      /* mul-int/lit16 (0xd2)        */ diff --git a/src/arch/dalvik/op_aget.c b/src/arch/dalvik/op_aget.c new file mode 100644 index 0000000..25a4ab5 --- /dev/null +++ b/src/arch/dalvik/op_aget.c @@ -0,0 +1,281 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_aget.c - décodage des instructions manipulant des tableaux (chargement) + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget'.                       * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget-boolean'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget_boolean(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET_BOOLEAN); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget-byte'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget_byte(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET_BYTE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget-char'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget_char(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET_CHAR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget-object'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget_object(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET_OBJECT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget-short'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget_short(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET_SHORT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aget-wide'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aget_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_AGET_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_aput.c b/src/arch/dalvik/op_aput.c new file mode 100644 index 0000000..46e9b1a --- /dev/null +++ b/src/arch/dalvik/op_aput.c @@ -0,0 +1,281 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_aput.c - décodage des instructions manipulant des tableaux (enregistrement) + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput'.                       * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput-boolean'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput_boolean(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT_BOOLEAN); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput-byte'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput_byte(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT_BYTE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput-char'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput_char(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT_CHAR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput-object'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput_object(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT_OBJECT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput-short'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput_short(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT_SHORT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'aput-wide'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_aput_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_APUT_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_23X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_array.c b/src/arch/dalvik/op_array.c new file mode 100644 index 0000000..90c61e8 --- /dev/null +++ b/src/arch/dalvik/op_array.c @@ -0,0 +1,65 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_array.c - décodage de l'opération récupérant la longueur d'un tableau + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'array-length'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_array_length(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_ARRAY_LENGTH); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_check.c b/src/arch/dalvik/op_check.c new file mode 100644 index 0000000..64f2c12 --- /dev/null +++ b/src/arch/dalvik/op_check.c @@ -0,0 +1,65 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_check.c - décodage des vérifications de types + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'check-cast'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_check_cast(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CHECK_CAST); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_TYPE))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_cmp.c b/src/arch/dalvik/op_cmp.c new file mode 100644 index 0000000..0e51a40 --- /dev/null +++ b/src/arch/dalvik/op_cmp.c @@ -0,0 +1,209 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_cmp.c - décodage des instructions de comparaison + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'cmp-long'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_cmp_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CMP_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'cmpg-double'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_cmpg_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CMPG_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'cmpg-float'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_cmpg_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CMPG_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'cmpl-double'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_cmpl_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CMPL_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'cmpl-float'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_cmpl_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CMPL_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_const.c b/src/arch/dalvik/op_const.c index e8c720e..0dcc923 100644 --- a/src/arch/dalvik/op_const.c +++ b/src/arch/dalvik/op_const.c @@ -37,6 +37,42 @@  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'const'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_const(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CONST); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_31I)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             *  *  Description : Décode une instruction de type 'const/16'.                   *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -171,3 +207,76 @@ GArchInstruction *dalvik_read_instr_const_string(const bin_t *data, off_t *pos,      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'const-wide'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_const_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CONST_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_51L)) +    { +        printf("Errrrrrrro ------- with const-wide\n"); +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'const-wide/16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_const_wide_16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_CONST_WIDE_16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21S)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_goto.c b/src/arch/dalvik/op_goto.c new file mode 100644 index 0000000..0571d03 --- /dev/null +++ b/src/arch/dalvik/op_goto.c @@ -0,0 +1,137 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_goto.c - décodage des branchements inconditionnels + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'goto'.                       * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_goto(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_GOTO); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_10T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'goto/16'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_goto_16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_GOTO_16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_20T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'goto/32'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_goto_32(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_GOTO_32); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_30T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_if.c b/src/arch/dalvik/op_if.c new file mode 100644 index 0000000..781fb7c --- /dev/null +++ b/src/arch/dalvik/op_if.c @@ -0,0 +1,461 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_if.c - décodage des branchements conditionnels + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-eq'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_eq(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_EQ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-eqz'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_eqz(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_EQZ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-ge'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_ge(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_GE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-gez'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_gez(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_GEZ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-gt'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_gt(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_GT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-gtz'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_gtz(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_GTZ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-le'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_le(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_LE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-lez'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_lez(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_LEZ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-lt'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_lt(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_LT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-ltz'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_ltz(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_LTZ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-ne'.                      * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_ne(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_NE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'if-nez'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_if_nez(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_IF_NEZ); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21T, addr)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_move.c b/src/arch/dalvik/op_move.c index eb152a3..de4da28 100644 --- a/src/arch/dalvik/op_move.c +++ b/src/arch/dalvik/op_move.c @@ -37,6 +37,150 @@  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'move'.                       * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'move-exception'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_exception(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_EXCEPTION); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'move-object'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_object(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_OBJECT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'move-result'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_result(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_RESULT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             *  *  Description : Décode une instruction de type 'move-result-object'.         *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -63,3 +207,39 @@ GArchInstruction *dalvik_read_instr_move_result_object(const bin_t *data, off_t      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'move-result-wide'.           * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_move_result_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MOVE_RESULT_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_11X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_mul.c b/src/arch/dalvik/op_mul.c index bda96b0..ffe6009 100644 --- a/src/arch/dalvik/op_mul.c +++ b/src/arch/dalvik/op_mul.c @@ -37,6 +37,42 @@  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'mul-double/2addr'.           * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_mul_double_2addr(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_MUL_DOUBLE_2ADDR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             *  *  Description : Décode une instruction de type 'mul-int'.                    *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * diff --git a/src/arch/dalvik/op_new.c b/src/arch/dalvik/op_new.c index 709871c..3bddd58 100644 --- a/src/arch/dalvik/op_new.c +++ b/src/arch/dalvik/op_new.c @@ -37,6 +37,42 @@  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'new-array'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_new_array(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_NEW_ARRAY); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22C | 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.             * +*                                                                             *  *  Description : Décode une instruction de type 'new-instance'.               *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * diff --git a/src/arch/dalvik/op_ret.c b/src/arch/dalvik/op_ret.c index baba5e3..ea4b5e7 100644 --- a/src/arch/dalvik/op_ret.c +++ b/src/arch/dalvik/op_ret.c @@ -73,6 +73,42 @@ GArchInstruction *dalvik_read_instr_return(const bin_t *data, off_t *pos, off_t  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'return-object'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_return_object(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_RETURN_OBJECT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             *  *  Description : Décode une instruction de type 'return-void'.                *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -99,3 +135,39 @@ GArchInstruction *dalvik_read_instr_return_void(const bin_t *data, off_t *pos, o      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'return-wide'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_return_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_RETURN_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_11X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_sget.c b/src/arch/dalvik/op_sget.c index 6b44700..baee85e 100644 --- a/src/arch/dalvik/op_sget.c +++ b/src/arch/dalvik/op_sget.c @@ -1,6 +1,6 @@  /* OpenIDA - Outil d'analyse de fichiers binaires - * op_sget.c - décodage des chargements de champs statiques + * op_sget.c - décodage des instructions manipulant des champs statiques (chargement)   *   * Copyright (C) 2010 Cyrille Bagard   * @@ -73,6 +73,114 @@ GArchInstruction *dalvik_read_instr_sget(const bin_t *data, off_t *pos, off_t le  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'sget-boolean'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sget_boolean(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SGET_BOOLEAN); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sget-byte'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sget_byte(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SGET_BYTE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sget-char'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sget_char(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SGET_CHAR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             *  *  Description : Décode une instruction de type 'sget-object'.                *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -109,6 +217,42 @@ GArchInstruction *dalvik_read_instr_sget_object(const bin_t *data, off_t *pos, o  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'sget-short'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sget_short(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SGET_SHORT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             *  *  Description : Décode une instruction de type 'sget-wide'.                  *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * diff --git a/src/arch/dalvik/op_sput.c b/src/arch/dalvik/op_sput.c new file mode 100644 index 0000000..55cbcf8 --- /dev/null +++ b/src/arch/dalvik/op_sput.c @@ -0,0 +1,281 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_sput.c - décodage des instructions manipulant des champs statiques (enregistrement) + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput'.                       * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput-boolean'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput_boolean(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT_BOOLEAN); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput-byte'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput_byte(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT_BYTE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput-char'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput_char(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT_CHAR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput-object'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput_object(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT_OBJECT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput-short'.                 * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput_short(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT_SHORT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data = flux de données à analyser.                           * +*                pos  = position courante dans ce flux. [OUT]                 * +*                len  = taille totale des données à analyser.                 * +*                addr = adresse virtuelle de l'instruction.                   * +*                proc = architecture ciblée par le désassemblage.             * +*                                                                             * +*  Description : Décode une instruction de type 'sput-wide'.                  * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_sput_wide(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_SPUT_WIDE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_21C | DALVIK_OP_POOL(DPT_FIELD))) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_to.c b/src/arch/dalvik/op_to.c new file mode 100644 index 0000000..a7481b0 --- /dev/null +++ b/src/arch/dalvik/op_to.c @@ -0,0 +1,569 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_to.c - décodage des instructions de conversions forcées + * + * Copyright (C) 2010 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'int-to-byte'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_int_byte(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_INT_BYTE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'int-to-char'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_int_char(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_INT_CHAR); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'int-to-double'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_int_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_INT_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'int-to-float'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_int_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_INT_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'int-to-long'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_int_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_INT_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'int-to-short'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_int_short(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_INT_SHORT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'double-to-float'.            * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_double_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_DOUBLE_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'double-to-int'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_double_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_DOUBLE_INT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'double-to-long'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_double_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_DOUBLE_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'float-to-double'.            * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_float_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_FLOAT_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'float-to-int'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_float_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_FLOAT_INT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'float-to-long'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_float_long(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_FLOAT_LONG); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'long-to-double'.             * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_long_double(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_LONG_DOUBLE); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'long-to-float'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_long_float(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_LONG_FLOAT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, 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.             * +*                                                                             * +*  Description : Décode une instruction de type 'long-to-int'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_to_long_int(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GDalvikProcessor *proc) +{ +    GArchInstruction *result;               /* Instruction à retourner     */ +    SourceEndian endian;                    /* Boutisme lié au binaire     */ + +    result = g_dalvik_instruction_new(DOP_TO_LONG_INT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_12X)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/opcodes.h b/src/arch/dalvik/opcodes.h index fd9f0d4..2dbcdab 100644 --- a/src/arch/dalvik/opcodes.h +++ b/src/arch/dalvik/opcodes.h @@ -49,6 +49,29 @@ GArchInstruction *dalvik_read_instr_add_int_lit16(const bin_t *, off_t *, off_t, +/* Décode une instruction de type 'aget'. */ +GArchInstruction *dalvik_read_instr_aget(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aget-boolean'. */ +GArchInstruction *dalvik_read_instr_aget_boolean(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aget-byte'. */ +GArchInstruction *dalvik_read_instr_aget_byte(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aget-char'. */ +GArchInstruction *dalvik_read_instr_aget_char(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aget-object'. */ +GArchInstruction *dalvik_read_instr_aget_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aget-short'. */ +GArchInstruction *dalvik_read_instr_aget_short(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); + + +  /* 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 *); @@ -64,24 +87,86 @@ GArchInstruction *dalvik_read_instr_and_int_lit16(const bin_t *, off_t *, off_t, -/*  Décode une instruction de type 'const/16'. */ + + +/* Décode une instruction de type 'aput'. */ +GArchInstruction *dalvik_read_instr_aput(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aput-boolean'. */ +GArchInstruction *dalvik_read_instr_aput_boolean(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aput-byte'. */ +GArchInstruction *dalvik_read_instr_aput_byte(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aput-char'. */ +GArchInstruction *dalvik_read_instr_aput_char(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aput-object'. */ +GArchInstruction *dalvik_read_instr_aput_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'aput-short'. */ +GArchInstruction *dalvik_read_instr_aput_short(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); + + + + + +/* 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 *); + + +/* 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 *); + + +/* 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 *); + +/* Décode une instruction de type 'cmpg-double'. */ +GArchInstruction *dalvik_read_instr_cmpg_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'cmpg-float'. */ +GArchInstruction *dalvik_read_instr_cmpg_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'cmpl-double'. */ +GArchInstruction *dalvik_read_instr_cmpl_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); + + + + + +/* Décode une instruction de type 'const'. */ +GArchInstruction *dalvik_read_instr_const(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'const/16'. */  GArchInstruction *dalvik_read_instr_const_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); -/*  Décode une instruction de type 'const/4'. */ +/* Décode une instruction de type 'const/4'. */  GArchInstruction *dalvik_read_instr_const_4(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); -/*  Décode une instruction de type 'const/high16'. */ +/* Décode une instruction de type 'const/high16'. */  GArchInstruction *dalvik_read_instr_const_high16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); -/*  Décode une instruction de type 'const-string'. */ +/* Décode une instruction de type 'const-string'. */  GArchInstruction *dalvik_read_instr_const_string(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'const-wide'. */ +GArchInstruction *dalvik_read_instr_const_wide(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'const-wide/16'. */ +GArchInstruction *dalvik_read_instr_const_wide_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); @@ -99,6 +184,55 @@ GArchInstruction *dalvik_read_instr_div_int_lit16(const bin_t *, off_t *, off_t, +/* Décode une instruction de type 'goto'. */ +GArchInstruction *dalvik_read_instr_goto(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'goto/16'. */ +GArchInstruction *dalvik_read_instr_goto_16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); + + + +/* 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 *); + +/* Décode une instruction de type 'if-eqz'. */ +GArchInstruction *dalvik_read_instr_if_eqz(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-ge'. */ +GArchInstruction *dalvik_read_instr_if_ge(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-gez'. */ +GArchInstruction *dalvik_read_instr_if_gez(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-gt'. */ +GArchInstruction *dalvik_read_instr_if_gt(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-gtz'. */ +GArchInstruction *dalvik_read_instr_if_gtz(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-le'. */ +GArchInstruction *dalvik_read_instr_if_le(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-lez'. */ +GArchInstruction *dalvik_read_instr_if_lez(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-lt'. */ +GArchInstruction *dalvik_read_instr_if_lt(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-ltz'. */ +GArchInstruction *dalvik_read_instr_if_ltz(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'if-ne'. */ +GArchInstruction *dalvik_read_instr_if_ne(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); + + +  /* Décode une instruction de type 'iget'. */  GArchInstruction *dalvik_read_instr_iget(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); @@ -168,9 +302,27 @@ GArchInstruction *dalvik_read_instr_iput_wide(const bin_t *, off_t *, off_t, vmp +/* Décode une instruction de type 'move'. */ +GArchInstruction *dalvik_read_instr_move(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'move-exception'. */ +GArchInstruction *dalvik_read_instr_move_exception(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'move-object'. */ +GArchInstruction *dalvik_read_instr_move_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'move-result'. */ +GArchInstruction *dalvik_read_instr_move_result(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +  /* Décode une instruction de type 'move-result-object'. */  GArchInstruction *dalvik_read_instr_move_result_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* 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 *); + + +/* 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 *);  /* 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 *); @@ -186,6 +338,9 @@ GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *, off_t *, off_t, +/* 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 *); +  /* Décode une instruction de type 'new-instance'. */  GArchInstruction *dalvik_read_instr_new_instance(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); @@ -234,10 +389,14 @@ GArchInstruction *dalvik_read_instr_rsub_int_lit8(const bin_t *, off_t *, off_t,  /* Décode une instruction de type 'return'. */  GArchInstruction *dalvik_read_instr_return(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'return-object'. */ +GArchInstruction *dalvik_read_instr_return_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +  /* Décode une instruction de type 'return-void'. */  GArchInstruction *dalvik_read_instr_return_void(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); - +/* 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 *); @@ -246,12 +405,91 @@ GArchInstruction *dalvik_read_instr_return_void(const bin_t *, off_t *, off_t, v  /* Décode une instruction de type 'sget'. */  GArchInstruction *dalvik_read_instr_sget(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'sget-boolean'. */ +GArchInstruction *dalvik_read_instr_sget_boolean(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sget-byte'. */ +GArchInstruction *dalvik_read_instr_sget_byte(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sget-char'. */ +GArchInstruction *dalvik_read_instr_sget_char(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +  /* Décode une instruction de type 'sget-object'. */  GArchInstruction *dalvik_read_instr_sget_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); -/*  Décode une instruction de type 'sget-wide'. */ +/* Décode une instruction de type 'sget-short'. */ +GArchInstruction *dalvik_read_instr_sget_short(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); +/* Décode une instruction de type 'sput'. */ +GArchInstruction *dalvik_read_instr_sput(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sput-boolean'. */ +GArchInstruction *dalvik_read_instr_sput_boolean(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sput-byte'. */ +GArchInstruction *dalvik_read_instr_sput_byte(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sput-char'. */ +GArchInstruction *dalvik_read_instr_sput_char(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sput-object'. */ +GArchInstruction *dalvik_read_instr_sput_object(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'sput-short'. */ +GArchInstruction *dalvik_read_instr_sput_short(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); + + + +/* 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 *); + +/* Décode une instruction de type 'int-to-char'. */ +GArchInstruction *dalvik_read_instr_to_int_char(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'int-to-double'. */ +GArchInstruction *dalvik_read_instr_to_int_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'int-to-float'. */ +GArchInstruction *dalvik_read_instr_to_int_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'int-to-long'. */ +GArchInstruction *dalvik_read_instr_to_int_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'int-to-short'. */ +GArchInstruction *dalvik_read_instr_to_int_short(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'double-to-float'. */ +GArchInstruction *dalvik_read_instr_to_double_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'double-to-int'. */ +GArchInstruction *dalvik_read_instr_to_double_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'double-to-long'. */ +GArchInstruction *dalvik_read_instr_to_double_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'float-to-double'. */ +GArchInstruction *dalvik_read_instr_to_float_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'float-to-int'. */ +GArchInstruction *dalvik_read_instr_to_float_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'float-to-long'. */ +GArchInstruction *dalvik_read_instr_to_float_long(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'long-to-double'. */ +GArchInstruction *dalvik_read_instr_to_long_double(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'long-to-float'. */ +GArchInstruction *dalvik_read_instr_to_long_float(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* 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 *); diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index 184a6e6..07c0675 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -25,10 +25,10 @@  #include <malloc.h> +#include <stdarg.h>  #include "register.h" -#include "../immediate.h"  #include "../operand-int.h" @@ -168,6 +168,41 @@ static void g_dalvik_pool_operand_to_buffer(const GDalvikPoolOperand *, GBufferL +/* ---------------------- OPERANDES VISANT UNE ADRESSE DE CODE ---------------------- */ + + +/* Définition d'un opérande visant une adresse de code Dalvik (instance) */ +struct _GDalvikTargetOperand +{ +    GDalvikOperand parent;                  /* Instance parente            */ + +    GImmOperand *immediate;                 /* Adresse visée reconstituée  */ + +}; + + +/* Définition d'un opérande visant une adresse de code Dalvik (classe) */ +struct _GDalvikTargetOperandClass +{ +    GDalvikOperandClass parent;             /* Classe parente              */ + +}; + + +/* Initialise la classe des opérandes de ciblage de code Dalvik. */ +static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *); + +/* Initialise une instance d'opérande de ciblage de code Dalvik. */ +static void g_dalvik_target_operand_init(GDalvikTargetOperand *); + +/* Ajoute du texte simple à un fichier ouvert en écriture. */ +static void g_dalvik_target_operand_add_text(const GDalvikTargetOperand *, GRenderingOptions *, MainRendering, FILE *); + +/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ +static void g_dalvik_target_operand_to_buffer(const GDalvikTargetOperand *, GBufferLine *, GRenderingOptions *); + + +  /* ------------------------- AIDE A LA CREATION D'OPERANDES ------------------------- */ @@ -182,16 +217,21 @@ typedef enum _DalvikOperandID      DOI_IMMEDIATE_4,      DOI_IMMEDIATE_8,      DOI_IMMEDIATE_16, +    DOI_IMMEDIATE_32, +    DOI_IMMEDIATE_64,      DOI_IMMEDIATE_H16, -    DOI_POOL_CONST +    DOI_POOL_CONST, +    DOI_TARGET_8, +    DOI_TARGET_16, +    DOI_TARGET_32  } DalvikOperandID;  /* Procède à la lecture d'opérandes pour une instruction. */ -static bool dalvik_read_basic_operands(GArchInstruction *, const bin_t *, off_t *, off_t, bool *, SourceEndian, DalvikOperandType); +static bool dalvik_read_basic_operands(GArchInstruction *, const bin_t *, off_t *, off_t, bool *, SourceEndian, DalvikOperandType, va_list);  /* Procède à la lecture d'opérandes pour une instruction. */  static bool dalvik_read_fixed_operands(GArchInstruction *, const bin_t *, off_t *, off_t, bool *, SourceEndian, DalvikOperandType); @@ -828,8 +868,173 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand) +/* ---------------------------------------------------------------------------------- */ +/*                        OPERANDES VISANT UNE ADRESSE DE CODE                        */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini par la GLib pour un opérande de ciblage de code Dalvik. */ +G_DEFINE_TYPE(GDalvikTargetOperand, g_dalvik_target_operand, G_TYPE_DALVIK_OPERAND); + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : klass = classe à initialiser.                                * +*                                                                             * +*  Description : Initialise la classe des opérandes de ciblage de code Dalvik.* +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *klass) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = instance à initialiser.                            * +*                                                                             * +*  Description : Initialise une instance d'opérande de ciblage de code Dalvik.* +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_target_operand_init(GDalvikTargetOperand *operand) +{ +    GContentExporter *parent;               /* Instance parente            */ + +    parent = G_CONTENT_EXPORTER(operand); + +    parent->add_text = (add_text_fc)g_dalvik_target_operand_add_text; +    parent->export_buffer = (export_buffer_fc)g_dalvik_target_operand_to_buffer; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : data   = flux de données à analyser.                         * +*                pos    = position courante dans ce flux. [OUT]               * +*                len    = taille totale des données à analyser.               * +*                size   = taille de l'opérande.                               * +*                endian = ordre des bits dans la source.                      * +*                base   = adresse de référence pour le calcul.                * +*                                                                             * +*  Description : Crée un opérande visant un instruction Dalvik.               * +*                                                                             * +*  Retour      : Opérande mis en place.                                       * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchOperand *g_dalvik_target_operand_new(const bin_t *data, off_t *pos, off_t len, MemoryDataSize size, SourceEndian endian, vmpa_t base) +{ +    GDalvikTargetOperand *result;           /* Structure à retourner       */ +    off_t init_pos;                         /* Position avant lecture      */ +    int8_t val8;                            /* Valeur sur 8 bits           */ +    int16_t val16;                          /* Valeur sur 16 bits          */ +    int32_t val32;                          /* Valeur sur 32 bits          */ +    vmpa_t address;                         /* Adresse finale visée        */ + +    init_pos = *pos; + +    switch (size) +    { +        case MDS_8_BITS_SIGNED: +            read_s8(&val8, data, pos, len, endian); +            address = base + (*pos - init_pos) + val8; +            break; +        case MDS_16_BITS_SIGNED: +            read_s16(&val16, data, pos, len, endian); +            printf("ADDR :: 0x%08llx + (%d - %d) + 0x%08x\n", base, *pos, init_pos, val16); +            address = base + (*pos - init_pos) + val16; +            break; +        case MDS_32_BITS_SIGNED: +            read_s32(&val32, data, pos, len, endian); +            address = base + (*pos - init_pos) + val32; +            break; +        default: +            return NULL; +            break; +    } +    result = g_object_new(G_TYPE_DALVIK_TARGET_OPERAND, NULL); +    result->immediate = G_IMM_OPERAND(g_imm_operand_new_from_value(AOS_32_BITS/*FIXME*/, (uint32_t)address/* FIXME */)); +    return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand   = opérande à transcrire.                           * +*                options   = options de rendu.                                * +*                rendering = support effectif final des lignes de code.       * +*                stream    = flux ouvert en écriture.                         * +*                                                                             * +*  Description : Ajoute du texte simple à un fichier ouvert en écriture.      * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_target_operand_add_text(const GDalvikTargetOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) +{ +    g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->immediate), options, rendering, stream); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = opérande à transcrire.                             * +*                buffer  = espace où placer ledit contenu.                    * +*                options = options de rendu.                                  * +*                                                                             * +*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_dalvik_target_operand_to_buffer(const GDalvikTargetOperand *operand, GBufferLine *buffer, GRenderingOptions *options) +{ +    g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->immediate), buffer, options); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = opérande à traiter.                                * +*                                                                             * +*  Description : Fournit l'adresse représentée par une opérande Dalvik.       * +*                                                                             * +*  Retour      : Valeur portée par l'opérande.                                * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +const GImmOperand *g_dalvik_target_operand_get_value(const GDalvikTargetOperand *operand) +{ +    return operand->immediate; + +} @@ -847,6 +1052,7 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand)  *                low    = position éventuelle des 4 bits visés. [OUT]         *  *                endian = boutisme lié au binaire accompagnant.               *  *                model  = type d'opérandes attendues.                         * +*                ap     = éventuels arguments complémentaires.                *  *                                                                             *  *  Description : Procède à la lecture d'opérandes pour une instruction.       *  *                                                                             * @@ -856,7 +1062,7 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand)  *                                                                             *  ******************************************************************************/ -static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, off_t len, bool *low, SourceEndian endian, DalvikOperandType model) +static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, off_t len, bool *low, SourceEndian endian, DalvikOperandType model, va_list ap)  {      bool result;                            /* Bilan à retourner           */      DalvikOperandID *types;                 /* Liste des chargements       */ @@ -868,8 +1074,15 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat      /* Choix des opérandes à charger */ -    switch (model & ~DALVIK_OP_POOL_MASK) +    switch (model & ~DALVIK_OP_EXTRA_MASK)      { +        case DALVIK_OPT_10T: +            types = (DalvikOperandID []) { +                DOI_TARGET_8, +                DOI_INVALID +            }; +            break; +          case DALVIK_OPT_11N:              types = (DalvikOperandID []) {                  DOI_REGISTER_4, @@ -893,6 +1106,13 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat              };              break; +        case DALVIK_OPT_20T: +            types = (DalvikOperandID []) { +                DOI_TARGET_16, +                DOI_INVALID +            }; +            break; +          case DALVIK_OPT_21C:              types = (DalvikOperandID []) {                  DOI_REGISTER_8, @@ -917,6 +1137,14 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat              };              break; +        case DALVIK_OPT_21T: +            types = (DalvikOperandID []) { +                DOI_REGISTER_8, +                DOI_TARGET_16, +                DOI_INVALID +            }; +            break; +          case DALVIK_OPT_22B:              types = (DalvikOperandID []) {                  DOI_REGISTER_8, @@ -944,6 +1172,15 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat              };              break; +        case DALVIK_OPT_22T: +            types = (DalvikOperandID []) { +                DOI_REGISTER_4, +                DOI_REGISTER_4, +                DOI_TARGET_16, +                DOI_INVALID +            }; +            break; +          case DALVIK_OPT_23X:              types = (DalvikOperandID []) {                  DOI_REGISTER_8, @@ -953,6 +1190,29 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat              };              break; +        case DALVIK_OPT_30T: +            types = (DalvikOperandID []) { +                DOI_TARGET_32, +                DOI_INVALID +            }; +            break; + +        case DALVIK_OPT_31I: +            types = (DalvikOperandID []) { +                DOI_REGISTER_8, +                DOI_IMMEDIATE_32, +                DOI_INVALID +            }; +            break; + +        case DALVIK_OPT_51L: +            types = (DalvikOperandID []) { +                DOI_REGISTER_8, +                DOI_IMMEDIATE_64, +                DOI_INVALID +            }; +            break; +          default:              types = (DalvikOperandID []) {                  DOI_INVALID @@ -987,6 +1247,14 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat                  op = g_imm_operand_new_from_data(MDS_16_BITS, data, pos, len, endian);                  break; +            case DOI_IMMEDIATE_32: +                op = g_imm_operand_new_from_data(MDS_32_BITS, data, pos, len, endian); +                break; + +            case DOI_IMMEDIATE_64: +                op = g_imm_operand_new_from_data(MDS_64_BITS, data, pos, len, endian); +                break; +              case DOI_IMMEDIATE_H16:                  result = read_u16(&value16, data, pos, len, endian);                  if (result) @@ -997,6 +1265,18 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat                  op = g_dalvik_pool_operand_new(DALVIK_OP_GET_POOL(model), data, pos, len, MDS_16_BITS, endian);                  break; +            case DOI_TARGET_8: +                op = g_dalvik_target_operand_new(data, pos, len, MDS_8_BITS_SIGNED, endian, va_arg(ap, vmpa_t)); +                break; + +            case DOI_TARGET_16: +                op = g_dalvik_target_operand_new(data, pos, len, MDS_16_BITS_SIGNED, endian, va_arg(ap, vmpa_t)); +                break; + +            case DOI_TARGET_32: +                op = g_dalvik_target_operand_new(data, pos, len, MDS_32_BITS_SIGNED, endian, va_arg(ap, vmpa_t)); +                break; +              default:                  op = NULL;                  break; @@ -1058,6 +1338,7 @@ static bool dalvik_read_fixed_operands(GArchInstruction *instr, const bin_t *dat      if (0)      { +        /* FIXME */          if (target2 == NULL) goto err_target2;      } @@ -1136,7 +1417,7 @@ static bool dalvik_read_fixed_operands(GArchInstruction *instr, const bin_t *dat  *                                                                             *  ******************************************************************************/ -bool dalvik_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, off_t len, SourceEndian endian, DalvikOperandType model) +bool dalvik_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, off_t len, SourceEndian endian, DalvikOperandType model, ...)  {      bool result;                            /* Bilan à retourner           */ @@ -1145,6 +1426,8 @@ bool dalvik_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos      off_t old_pos; +    va_list ap;                             /* Arguments complémentaires   */ +      off_t length;      result = true; @@ -1157,19 +1440,28 @@ bool dalvik_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos -    switch (model & ~DALVIK_OP_POOL_MASK) +    switch (model & ~DALVIK_OP_EXTRA_MASK)      { -        case DALVIK_OPT_12X: +        case DALVIK_OPT_10T:          case DALVIK_OPT_11N:          case DALVIK_OPT_11X: +        case DALVIK_OPT_12X: +        case DALVIK_OPT_20T:          case DALVIK_OPT_21C:          case DALVIK_OPT_21H:          case DALVIK_OPT_21S: +        case DALVIK_OPT_21T:          case DALVIK_OPT_22B:          case DALVIK_OPT_22C:          case DALVIK_OPT_22S: +        case DALVIK_OPT_22T:          case DALVIK_OPT_23X: -            result = dalvik_read_basic_operands(instr, data, pos, len, &low, endian, model); +        case DALVIK_OPT_30T: +        case DALVIK_OPT_31I: +        case DALVIK_OPT_51L: +            va_start(ap, model); +            result = dalvik_read_basic_operands(instr, data, pos, len, &low, endian, model, ap); +            va_end(ap);              break;          case DALVIK_OPT_35C: diff --git a/src/arch/dalvik/operand.h b/src/arch/dalvik/operand.h index 2332cb3..452bb5e 100644 --- a/src/arch/dalvik/operand.h +++ b/src/arch/dalvik/operand.h @@ -25,6 +25,7 @@  #define _ARCH_DALVIK_OPERAND_H +#include "../immediate.h"  #include "../instruction.h"  #include "../../common/endianness.h" @@ -146,6 +147,31 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *); +/* ---------------------- OPERANDES VISANT UNE ADRESSE DE CODE ---------------------- */ + + +#define G_TYPE_DALVIK_TARGET_OPERAND                  g_dalvik_target_operand_get_type() +#define G_DALVIK_TARGET_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_target_operand_get_type(), GDalvikTargetOperand)) +#define G_IS_DALVIK_TARGET_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_target_operand_get_type())) +#define G_DALVIK_TARGET_OPERAND_GET_IFACE(inst)       (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_dalvik_target_operand_get_type(), GDalvikTargetOperandIface)) + + +/* Définition d'un opérande visant une adresse de code Dalvik (instance) */ +typedef struct _GDalvikTargetOperand GDalvikTargetOperand; + +/* Définition d'un opérande visant une adresse de code Dalvik (classe) */ +typedef struct _GDalvikTargetOperandClass GDalvikTargetOperandClass; + + +/* Indique le type défini par la GLib pour un opérande de ciblage de code Dalvik. */ +GType g_dalvik_target_operand_get_type(void); + +/* Crée un opérande visant un instruction Dalvik. */ +GArchOperand *g_dalvik_target_operand_new(const bin_t *, off_t *, off_t, MemoryDataSize, SourceEndian, vmpa_t); + +/* Fournit l'adresse représentée par une opérande Dalvik. */ +const GImmOperand *g_dalvik_target_operand_get_value(const GDalvikTargetOperand *); +  /* ------------------------- AIDE A LA CREATION D'OPERANDES ------------------------- */ @@ -170,6 +196,8 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *);  #define DALVIK_OP_POOL_OFF  20  #define DALVIK_OP_POOL_MASK 0x00f00000 +#define DALVIK_OP_EXTRA_MASK (DALVIK_OP_POOL_MASK) +  #define DALVIK_OP_LEN(l)        ((l) << DALVIK_OP_LEN_OFF)  #define DALVIK_OP_GET_LEN(v)    (((v) & DALVIK_OP_LEN_MASK) >> DALVIK_OP_LEN_OFF) @@ -183,6 +211,7 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *);  /* Types d'opérandes supportés */  typedef enum _DalvikOperandType  { +    DALVIK_OPT_10T      = DALVIK_OP_LEN(1) | DALVIK_OP_REG(0) | 'T',      DALVIK_OPT_10X      = DALVIK_OP_LEN(1) | DALVIK_OP_REG(0) | 'X',      DALVIK_OPT_11N      = DALVIK_OP_LEN(1) | DALVIK_OP_REG(1) | 'N', @@ -190,27 +219,33 @@ typedef enum _DalvikOperandType      DALVIK_OPT_12X      = DALVIK_OP_LEN(1) | DALVIK_OP_REG(2) | 'X', -    DALVIK_OPT_21C      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(1) | 'C', +    DALVIK_OPT_20T      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(0) | 'T', +    DALVIK_OPT_21C      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(1) | 'C',      DALVIK_OPT_21H      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(1) | 'H', -      DALVIK_OPT_21S      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(1) | 'S', +    DALVIK_OPT_21T      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(1) | 'T',      DALVIK_OPT_22B      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'B',      DALVIK_OPT_22C      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'C',      DALVIK_OPT_22S      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'S', +    DALVIK_OPT_22T      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(2) | 'T',      DALVIK_OPT_23X      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(3) | 'X', +    DALVIK_OPT_30T      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(0) | 'T', + +    DALVIK_OPT_31I      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(1) | 'I', -    DALVIK_OPT_35C      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(5) | 'C' +    DALVIK_OPT_35C      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(5) | 'C', +    DALVIK_OPT_51L      = DALVIK_OP_LEN(5) | DALVIK_OP_REG(1) | 'L'  } DalvikOperandType;  /* Procède à la lecture d'opérandes pour une instruction. */ -bool dalvik_read_operands(GArchInstruction *, const bin_t *, off_t *, off_t, SourceEndian, DalvikOperandType); +bool dalvik_read_operands(GArchInstruction *, const bin_t *, off_t *, off_t, SourceEndian, DalvikOperandType, ...); diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index e05d6d0..adfa2a3 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -152,28 +152,74 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc      static const dalvik_read_instr decodings[DOP_COUNT] = {          [DOP_NOP]                   = dalvik_read_instr_nop, +        [DOP_MOVE]                  = dalvik_read_instr_move, +        [DOP_MOVE_OBJECT]           = dalvik_read_instr_move_object, +        [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, - - +        [DOP_MOVE_EXCEPTION]        = dalvik_read_instr_move_exception, +        [DOP_RETURN_VOID]           = dalvik_read_instr_return_void, +        [DOP_RETURN]                = dalvik_read_instr_return, +        [DOP_RETURN_WIDE]           = dalvik_read_instr_return_wide, +        [DOP_RETURN_OBJECT]         = dalvik_read_instr_return_object,          [DOP_CONST_4]               = dalvik_read_instr_const_4,          [DOP_CONST_16]              = dalvik_read_instr_const_16, - - +        [DOP_CONST]                 = dalvik_read_instr_const,          [DOP_CONST_HIGH16]          = dalvik_read_instr_const_high16, +        [DOP_CONST_WIDE_16]         = dalvik_read_instr_const_wide_16, - -        [DOP_CONST_STRING]          = dalvik_read_instr_const_string, +        [DOP_CONST_WIDE]            = dalvik_read_instr_const_wide, +        [DOP_CONST_STRING]          = dalvik_read_instr_const_string, -        [DOP_RETURN_VOID]           = dalvik_read_instr_return_void, -        [DOP_RETURN]                = dalvik_read_instr_return, +        [DOP_CHECK_CAST]            = dalvik_read_instr_check_cast, +        [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_GOTO]                  = dalvik_read_instr_goto, +        [DOP_GOTO_16]               = dalvik_read_instr_goto_16, +        [DOP_GOTO_32]               = dalvik_read_instr_goto_32, + +        [DOP_CMPL_FLOAT]            = dalvik_read_instr_cmpl_float, +        [DOP_CMPG_FLOAT]            = dalvik_read_instr_cmpg_float, +        [DOP_CMPL_DOUBLE]           = dalvik_read_instr_cmpl_double, +        [DOP_CMPG_DOUBLE]           = dalvik_read_instr_cmpg_double, +        [DOP_CMP_LONG]              = dalvik_read_instr_cmp_long, +        [DOP_IF_EQ]                 = dalvik_read_instr_if_eq, +        [DOP_IF_EQZ]                = dalvik_read_instr_if_eqz, +        [DOP_IF_GE]                 = dalvik_read_instr_if_ge, +        [DOP_IF_GEZ]                = dalvik_read_instr_if_gez, +        [DOP_IF_GT]                 = dalvik_read_instr_if_gt, +        [DOP_IF_GTZ]                = dalvik_read_instr_if_gtz, +        [DOP_IF_LE]                 = dalvik_read_instr_if_le, +        [DOP_IF_LEZ]                = dalvik_read_instr_if_lez, +        [DOP_IF_LT]                 = dalvik_read_instr_if_lt, +        [DOP_IF_LTZ]                = dalvik_read_instr_if_ltz, +        [DOP_IF_NE]                 = dalvik_read_instr_if_ne, +        [DOP_IF_NEZ]                = dalvik_read_instr_if_nez, + + + + +        [DOP_AGET]                  = dalvik_read_instr_aget, +        [DOP_AGET_WIDE]             = dalvik_read_instr_aget_wide, +        [DOP_AGET_OBJECT]           = dalvik_read_instr_aget_object, +        [DOP_AGET_BOOLEAN]          = dalvik_read_instr_aget_boolean, +        [DOP_AGET_BYTE]             = dalvik_read_instr_aget_byte, +        [DOP_AGET_CHAR]             = dalvik_read_instr_aget_char, +        [DOP_AGET_SHORT]            = dalvik_read_instr_aget_short, +        [DOP_APUT]                  = dalvik_read_instr_aput, +        [DOP_APUT_WIDE]             = dalvik_read_instr_aput_wide, +        [DOP_APUT_OBJECT]           = dalvik_read_instr_aput_object, +        [DOP_APUT_BOOLEAN]          = dalvik_read_instr_aput_boolean, +        [DOP_APUT_BYTE]             = dalvik_read_instr_aput_byte, +        [DOP_APUT_CHAR]             = dalvik_read_instr_aput_char, +        [DOP_APUT_SHORT]            = dalvik_read_instr_aput_short,          [DOP_IGET]                  = dalvik_read_instr_iget,          [DOP_IGET_WIDE]             = dalvik_read_instr_iget_wide,          [DOP_IGET_OBJECT]           = dalvik_read_instr_iget_object, @@ -191,8 +237,17 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_SGET]                  = dalvik_read_instr_sget,          [DOP_SGET_WIDE]             = dalvik_read_instr_sget_wide,          [DOP_SGET_OBJECT]           = dalvik_read_instr_sget_object, - - +        [DOP_SGET_BOOLEAN]          = dalvik_read_instr_sget_boolean, +        [DOP_SGET_BYTE]             = dalvik_read_instr_sget_byte, +        [DOP_SGET_CHAR]             = dalvik_read_instr_sget_char, +        [DOP_SGET_SHORT]            = dalvik_read_instr_sget_short, +        [DOP_SPUT]                  = dalvik_read_instr_sput, +        [DOP_SPUT_WIDE]             = dalvik_read_instr_sput_wide, +        [DOP_SPUT_OBJECT]           = dalvik_read_instr_sput_object, +        [DOP_SPUT_BOOLEAN]          = dalvik_read_instr_sput_boolean, +        [DOP_SPUT_BYTE]             = dalvik_read_instr_sput_byte, +        [DOP_SPUT_CHAR]             = dalvik_read_instr_sput_char, +        [DOP_SPUT_SHORT]            = dalvik_read_instr_sput_short,          [DOP_INVOKE_VIRTUAL]        = dalvik_read_instr_invoke_virtual,          [DOP_INVOKE_SUPER]          = dalvik_read_instr_invoke_super,          [DOP_INVOKE_DIRECT]         = dalvik_read_instr_invoke_direct, @@ -200,6 +255,21 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_INVOKE_INTERFACE]      = dalvik_read_instr_invoke_interface, +        [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, +        [DOP_TO_LONG_INT]           = dalvik_read_instr_to_long_int, +        [DOP_TO_LONG_FLOAT]         = dalvik_read_instr_to_long_float, +        [DOP_TO_LONG_DOUBLE]        = dalvik_read_instr_to_long_double, +        [DOP_TO_FLOAT_INT]          = dalvik_read_instr_to_float_int, +        [DOP_TO_FLOAT_LONG]         = dalvik_read_instr_to_float_long, +        [DOP_TO_FLOAT_DOUBLE]       = dalvik_read_instr_to_float_double, +        [DOP_TO_DOUBLE_INT]         = dalvik_read_instr_to_double_int, +        [DOP_TO_DOUBLE_LONG]        = dalvik_read_instr_to_double_long, +        [DOP_TO_DOUBLE_FLOAT]       = dalvik_read_instr_to_double_float, +        [DOP_TO_INT_BYTE]           = dalvik_read_instr_to_int_byte, +        [DOP_TO_INT_CHAR]           = dalvik_read_instr_to_int_char, +        [DOP_TO_INT_SHORT]          = dalvik_read_instr_to_int_short,          [DOP_ADD_INT]               = dalvik_read_instr_add_int,          [DOP_MUL_INT]               = dalvik_read_instr_mul_int, @@ -219,6 +289,7 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_OR_INT_2ADDR]          = dalvik_read_instr_or_int_2addr,          [DOP_XOR_INT_2ADDR]         = dalvik_read_instr_xor_int_2addr, +        [DOP_MUL_DOUBLE_2ADDR]      = dalvik_read_instr_mul_double_2addr,          [DOP_ADD_INT_LIT16]         = dalvik_read_instr_add_int_lit16,          [DOP_RSUB_INT]              = dalvik_read_instr_rsub_int, diff --git a/src/arch/x86/operand.c b/src/arch/x86/operand.c index b3f0997..23b08c2 100644 --- a/src/arch/x86/operand.c +++ b/src/arch/x86/operand.c @@ -926,7 +926,7 @@ static void g_x86_relative_operand_init(GX86RelativeOperand *operand)  *                pos  = position courante dans ce flux. [OUT]                 *  *                len  = taille totale des données à analyser.                 *  *                size = taille de l'opérande, et donc du registre.            * -*                base = indice du premier registre.                           * +*                base = adresse de référence pour le calcul.                  *  *                                                                             *  *  Description : Crée un opérande X86 d'adresse relative.                     *  *                                                                             * @@ -1021,7 +1021,7 @@ static void g_x86_relative_operand_to_buffer(const GX86RelativeOperand *operand,  *                                                                             *  *  Paramètres  : operand = opérande à traiter.                                *  *                                                                             * -*  Description : Fournit l'adresse relative représentée par une opérande X86. * +*  Description : Fournit l'adresse représentée par une opérande X86.          *  *                                                                             *  *  Retour      : Valeur portée par l'opérande.                                *  *                                                                             * diff --git a/src/arch/x86/operand.h b/src/arch/x86/operand.h index 497f99a..f42b67d 100644 --- a/src/arch/x86/operand.h +++ b/src/arch/x86/operand.h @@ -140,7 +140,7 @@ GType g_x86_relative_operand_get_type(void);  /* Crée un opérande X86 d'adresse relative. */  GArchOperand *g_x86_relative_operand_new(const bin_t *, off_t *, off_t, AsmOperandSize, vmpa_t); -/* Fournit l'adresse relative représentée par une opérande X86. */ +/* Fournit l'adresse représentée par une opérande X86. */  const GImmOperand *g_x86_relative_operand_get_value(const GX86RelativeOperand *); diff --git a/src/common/endianness.c b/src/common/endianness.c index 3a2a653..5a14e1c 100755 --- a/src/common/endianness.c +++ b/src/common/endianness.c @@ -257,7 +257,64 @@ bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, Source  bool read_u64(uint64_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)  { +    if (*pos < 0) return false; +    if ((len - *pos) < 8) return false; + +    switch (endian) +    { +        case SRE_LITTLE: + +#if __BYTE_ORDER == __LITTLE_ENDIAN + +            *target = (uint64_t)data[*pos] | (uint64_t)data[*pos + 1] << 8; +            *target |= (uint64_t)data[*pos + 2] << 16 | (uint64_t)data[*pos + 3] << 24; +            *target |= (uint64_t)data[*pos + 4] << 32 | (uint64_t)data[*pos + 5] << 40; +            *target |= (uint64_t)data[*pos + 6] << 48 | (uint64_t)data[*pos + 7] << 56; + +#elif __BYTE_ORDER == __BIG_ENDIAN + +            *target = (uint64_t)data[*pos + 7] | (uint64_t)data[*pos + 6] << 8; +            *target |= (uint64_t)data[*pos + 5] << 16 | (uint64_t)data[*pos + 4] << 24; +            *target |= (uint64_t)data[*pos + 3] << 32 | (uint64_t)data[*pos + 2] << 40; +            *target |= (uint64_t)data[*pos + 1] << 48 | (uint64_t)data[*pos] << 56; + +#else + +#   error "TODO : PDP !" + +#endif + +            break; + +        case SRE_BIG: + +#if __BYTE_ORDER == __LITTLE_ENDIAN + +            *target = (uint64_t)data[*pos + 7] | (uint64_t)data[*pos + 6] << 8; +            *target |= (uint64_t)data[*pos + 5] << 16 | (uint64_t)data[*pos + 4] << 24; +            *target |= (uint64_t)data[*pos + 3] << 32 | (uint64_t)data[*pos + 2] << 40; +            *target |= (uint64_t)data[*pos + 1] << 48 | (uint64_t)data[*pos] << 56; + +#elif __BYTE_ORDER == __BIG_ENDIAN + +            *target = (uint64_t)data[*pos] | (uint64_t)data[*pos + 1] << 8; +            *target |= (uint64_t)data[*pos + 2] << 16 | (uint64_t)data[*pos + 3] << 24; +            *target |= (uint64_t)data[*pos + 4] << 32 | (uint64_t)data[*pos + 5] << 40; +            *target |= (uint64_t)data[*pos + 6] << 48 | (uint64_t)data[*pos + 7] << 56; + +#else + +#   error "TODO : PDP !" + +#endif + +            break; -    return false; + +    } + +    *pos += 8; + +    return true;  } | 
