diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/dalvik/Makefile.am | 6 | ||||
| -rw-r--r-- | src/arch/dalvik/instruction.c | 36 | ||||
| -rw-r--r-- | src/arch/dalvik/instruction.h | 33 | ||||
| -rw-r--r-- | src/arch/dalvik/op_add.c | 108 | ||||
| -rw-r--r-- | src/arch/dalvik/op_and.c | 173 | ||||
| -rw-r--r-- | src/arch/dalvik/op_div.c | 173 | ||||
| -rw-r--r-- | src/arch/dalvik/op_mul.c | 108 | ||||
| -rw-r--r-- | src/arch/dalvik/op_or.c | 173 | ||||
| -rw-r--r-- | src/arch/dalvik/op_rem.c | 173 | ||||
| -rw-r--r-- | src/arch/dalvik/op_rsub.c | 101 | ||||
| -rw-r--r-- | src/arch/dalvik/op_xor.c | 173 | ||||
| -rw-r--r-- | src/arch/dalvik/opcodes.h | 98 | ||||
| -rw-r--r-- | src/arch/dalvik/operand.c | 34 | ||||
| -rw-r--r-- | src/arch/dalvik/operand.h | 3 | ||||
| -rw-r--r-- | src/arch/dalvik/processor.c | 36 | 
15 files changed, 1416 insertions, 12 deletions
diff --git a/src/arch/dalvik/Makefile.am b/src/arch/dalvik/Makefile.am index c8c0145..942c2c3 100644 --- a/src/arch/dalvik/Makefile.am +++ b/src/arch/dalvik/Makefile.am @@ -4,7 +4,9 @@ noinst_LTLIBRARIES = libarchdalvik.la  libarchdalvik_la_SOURCES =				\  	instruction.h instruction.c			\  	op_add.c							\ +	op_and.c							\  	op_const.c							\ +	op_div.c							\  	op_iget.c							\  	op_invoke.c							\  	op_iput.c							\ @@ -12,8 +14,12 @@ libarchdalvik_la_SOURCES =				\  	op_mul.c							\  	op_new.c							\  	op_nop.c							\ +	op_or.c								\ +	op_rem.c							\  	op_ret.c							\ +	op_rsub.c							\  	op_sget.c							\ +	op_xor.c							\  	opcodes.h							\  	operand.h operand.c					\  	processor.h processor.c				\ diff --git a/src/arch/dalvik/instruction.c b/src/arch/dalvik/instruction.c index f485cec..165d4d2 100644 --- a/src/arch/dalvik/instruction.c +++ b/src/arch/dalvik/instruction.c @@ -116,11 +116,43 @@ static dalvik_instruction _instructions[DOP_COUNT] = { -    [DOP_MUL_INT_2ADDR]         = { 0xb2, "mul-int/2addr" }, +    [DOP_ADD_INT]               = { 0x90, "add-int" }, + +    [DOP_MUL_INT]               = { 0x92, "mul-int" }, +    [DOP_DIV_INT]               = { 0x93, "div-int" }, +    [DOP_REM_INT]               = { 0x94, "rem-int" }, +    [DOP_AND_INT]               = { 0x95, "and-int" }, +    [DOP_OR_INT]                = { 0x96, "or-int" }, +    [DOP_XOR_INT]               = { 0x97, "xor-int" }, +    [DOP_ADD_INT_2ADDR]         = { 0xb0, "add-int/2addr" }, -    [DOP_ADD_INT_LIT8]          = { 0xd8, "add-int/lit8" } + +    [DOP_MUL_INT_2ADDR]         = { 0xb2, "mul-int/2addr" }, +    [DOP_DIV_INT_2ADDR]         = { 0xb3, "div-int/2addr" }, +    [DOP_REM_INT_2ADDR]         = { 0xb4, "rem-int/2addr" }, +    [DOP_AND_INT_2ADDR]         = { 0xb5, "and-int/2addr" }, +    [DOP_OR_INT_2ADDR]          = { 0xb6, "or-int/2addr" }, +    [DOP_XOR_INT_2ADDR]         = { 0xb7, "xor-int/2addr" }, + + +    [DOP_ADD_INT_LIT16]         = { 0xd0, "add-int/lit16" }, +    [DOP_RSUB_INT]              = { 0xd1, "rsub-int" }, +    [DOP_MUL_INT_LIT16]         = { 0xd2, "mul-int/lit16" }, +    [DOP_DIV_INT_LIT16]         = { 0xd3, "div-int/lit16" }, +    [DOP_REM_INT_LIT16]         = { 0xd4, "rem-int/lit16" }, +    [DOP_AND_INT_LIT16]         = { 0xd5, "and-int/lit16" }, +    [DOP_OR_INT_LIT16]          = { 0xd6, "or-int/lit16" }, +    [DOP_XOR_INT_LIT16]         = { 0xd7, "xor-int/lit16" }, +    [DOP_ADD_INT_LIT8]          = { 0xd8, "add-int/lit8" }, +    [DOP_RSUB_INT_LIT8]         = { 0xd9, "rsub-int/lit8" }, +    [DOP_MUL_INT_LIT8]          = { 0xda, "mul-int/lit8" }, +    [DOP_DIV_INT_LIT8]          = { 0xdb, "div-int/lit8" }, +    [DOP_REM_INT_LIT8]          = { 0xdc, "rem-int/lit8" }, +    [DOP_AND_INT_LIT8]          = { 0xdd, "and-int/lit8" }, +    [DOP_OR_INT_LIT8]           = { 0xde, "or-int/lit8" }, +    [DOP_XOR_INT_LIT8]          = { 0xdf, "xor-int/lit8" }  }; diff --git a/src/arch/dalvik/instruction.h b/src/arch/dalvik/instruction.h index e5a3e69..0c9c6e5 100644 --- a/src/arch/dalvik/instruction.h +++ b/src/arch/dalvik/instruction.h @@ -78,9 +78,40 @@ typedef enum _DalvikOpcodes      DOP_INVOKE_STATIC,                      /* invoke-static (0x71)        */      DOP_INVOKE_INTERFACE,                   /* invoke-interface (0x72)     */ -    DOP_MUL_INT_2ADDR,                      /* mul-int/2addr (0xb2)        */ +    DOP_ADD_INT,                            /* add-int (0x90)              */ + +    DOP_MUL_INT,                            /* mul-int (0x92)              */ +    DOP_DIV_INT,                            /* div-int (0x93)              */ +    DOP_REM_INT,                            /* rem-int (0x94)              */ +    DOP_AND_INT,                            /* and-int (0x95)              */ +    DOP_OR_INT,                             /* or-int (0x96)               */ +    DOP_XOR_INT,                            /* xor-int (0x97)              */ +    DOP_ADD_INT_2ADDR,                      /* add-int/2addr (0xb0)        */ + +    DOP_MUL_INT_2ADDR,                      /* mul-int/2addr (0xb2)        */ +    DOP_DIV_INT_2ADDR,                      /* div-int/2addr (0xb3)        */ +    DOP_REM_INT_2ADDR,                      /* rem-int/2addr (0xb4)        */ +    DOP_AND_INT_2ADDR,                      /* and-int/2addr (0xb5)        */ +    DOP_OR_INT_2ADDR,                       /* or-int/2addr (0xb6)         */ +    DOP_XOR_INT_2ADDR,                      /* xor-int/2addr (0xb7)        */ + +    DOP_ADD_INT_LIT16,                      /* add-int/lit16 (0xd0)        */ +    DOP_RSUB_INT,                           /* rsub-int (0xd1)             */ +    DOP_MUL_INT_LIT16,                      /* mul-int/lit16 (0xd2)        */ +    DOP_DIV_INT_LIT16,                      /* div-int/lit16 (0xd3)        */ +    DOP_REM_INT_LIT16,                      /* rem-int/lit16 (0xd4)        */ +    DOP_AND_INT_LIT16,                      /* and-int/lit16 (0xd5)        */ +    DOP_OR_INT_LIT16,                       /* or-int/lit16 (0xd6)         */ +    DOP_XOR_INT_LIT16,                      /* xor-int/lit16 (0xd7)        */      DOP_ADD_INT_LIT8,                       /* add-int/lit8 (0xd8)         */ +    DOP_RSUB_INT_LIT8,                      /* rsub-int/lit8 (0xd9)        */ +    DOP_MUL_INT_LIT8,                       /* mul-int/lit8 (0xda)         */ +    DOP_DIV_INT_LIT8,                       /* div-int/lit8 (0xdb)         */ +    DOP_REM_INT_LIT8,                       /* rem-int/lit8 (0xdc)         */ +    DOP_AND_INT_LIT8,                       /* and-int/lit8 (0xdd)         */ +    DOP_OR_INT_LIT8,                        /* or-int/lit8 (0xde)          */ +    DOP_XOR_INT_LIT8,                       /* xor-int/lit8 (0xdf)         */      DOP_COUNT diff --git a/src/arch/dalvik/op_add.c b/src/arch/dalvik/op_add.c index 92ba818..64dab5f 100644 --- a/src/arch/dalvik/op_add.c +++ b/src/arch/dalvik/op_add.c @@ -37,6 +37,78 @@  *                addr = adresse virtuelle de l'instruction.                   *  *                proc = architecture ciblée par le désassemblage.             *  *                                                                             * +*  Description : Décode une instruction de type 'add-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_add_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_ADD_INT); + +    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 'add-int/2addr'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_add_int_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_ADD_INT_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 'add-int/lit8'.               *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -63,3 +135,39 @@ GArchInstruction *dalvik_read_instr_add_int_lit8(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 'add-int/lit16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_add_int_lit16(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_ADD_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_and.c b/src/arch/dalvik/op_and.c new file mode 100644 index 0000000..d86866d --- /dev/null +++ b/src/arch/dalvik/op_and.c @@ -0,0 +1,173 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_and.c - décodage des opérations de ET logiques + * + * 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 'and-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_and_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_AND_INT); + +    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 'and-int/2addr'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_and_int_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_AND_INT_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 'and-int/lit8'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_and_int_lit8(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_AND_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        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 'and-int/lit16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_and_int_lit16(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_AND_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_div.c b/src/arch/dalvik/op_div.c new file mode 100644 index 0000000..c4d9b87 --- /dev/null +++ b/src/arch/dalvik/op_div.c @@ -0,0 +1,173 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_div.c - décodage des opérations de divisions + * + * 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 'div-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_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_DIV_INT); + +    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 'div-int/2addr'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_int_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_DIV_INT_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 'div-int/lit8'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_int_lit8(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_DIV_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        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 'div-int/lit16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_div_int_lit16(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_DIV_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        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 1e2b584..bda96b0 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-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_mul_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_MUL_INT); + +    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 'mul-int/2addr'.              *  *                                                                             *  *  Retour      : Instruction mise en place ou NULL.                           * @@ -63,3 +99,75 @@ GArchInstruction *dalvik_read_instr_mul_int_2addr(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 'mul-int/lit8'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_mul_int_lit8(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_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        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/lit16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_mul_int_lit16(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_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_or.c b/src/arch/dalvik/op_or.c new file mode 100644 index 0000000..f78b7fb --- /dev/null +++ b/src/arch/dalvik/op_or.c @@ -0,0 +1,173 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_or.c - décodage des opérations de OU logiques + * + * 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 'or-int'.                     * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_or_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_OR_INT); + +    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 'or-int/2addr'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_or_int_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_OR_INT_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 'or-int/lit8'.                * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_or_int_lit8(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_OR_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        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 'or-int/lit16'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_or_int_lit16(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_OR_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_rem.c b/src/arch/dalvik/op_rem.c new file mode 100644 index 0000000..17dbfb8 --- /dev/null +++ b/src/arch/dalvik/op_rem.c @@ -0,0 +1,173 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_rem.c - décodage des opérations de restes de division + * + * 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 'rem-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_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_REM_INT); + +    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 'rem-int/2addr'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_int_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_REM_INT_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 'rem-int/lit8'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_int_lit8(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_REM_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        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 'rem-int/lit16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rem_int_lit16(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_REM_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_rsub.c b/src/arch/dalvik/op_rsub.c new file mode 100644 index 0000000..45b885e --- /dev/null +++ b/src/arch/dalvik/op_rsub.c @@ -0,0 +1,101 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_rsub.c - décodage des opérations de soustractions inverses + * + * 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 'rsub-int'.                   * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rsub_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_RSUB_INT); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        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 'rsub-int/lit8'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_rsub_int_lit8(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_RSUB_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +    return result; + +} diff --git a/src/arch/dalvik/op_xor.c b/src/arch/dalvik/op_xor.c new file mode 100644 index 0000000..8f4570a --- /dev/null +++ b/src/arch/dalvik/op_xor.c @@ -0,0 +1,173 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * op_xor.c - décodage des opérations de OU exclusifs et logiques + * + * 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 'xor-int'.                    * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_xor_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_XOR_INT); + +    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 'xor-int/2addr'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_xor_int_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_XOR_INT_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 'xor-int/lit8'.               * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_xor_int_lit8(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_XOR_INT_LIT8); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22B)) +    { +        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 'xor-int/lit16'.              * +*                                                                             * +*  Retour      : Instruction mise en place ou NULL.                           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchInstruction *dalvik_read_instr_xor_int_lit16(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_XOR_INT_LIT16); + +    endian = g_arch_processor_get_endianness(G_ARCH_PROCESSOR(proc)); + +    if (!dalvik_read_operands(result, data, pos, len, endian, DALVIK_OPT_22S)) +    { +        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 2389270..fd9f0d4 100644 --- a/src/arch/dalvik/opcodes.h +++ b/src/arch/dalvik/opcodes.h @@ -35,9 +35,33 @@ typedef GArchInstruction * (* dalvik_read_instr) (const bin_t *, off_t *, off_t, +/* Décode une instruction de type 'add-int'. */ +GArchInstruction *dalvik_read_instr_add_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'add-int/2addr'. */ +GArchInstruction *dalvik_read_instr_add_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +  /* Décode une instruction de type 'add-int/lit8'. */  GArchInstruction *dalvik_read_instr_add_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'add-int/lit16'. */ +GArchInstruction *dalvik_read_instr_add_int_lit16(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 *); + +/* Décode une instruction de type 'and-int/2addr'. */ +GArchInstruction *dalvik_read_instr_and_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'and-int/lit8'. */ +GArchInstruction *dalvik_read_instr_and_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'and-int/lit16'. */ +GArchInstruction *dalvik_read_instr_and_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +  /*  Décode une instruction de type 'const/16'. */ @@ -61,6 +85,19 @@ GArchInstruction *dalvik_read_instr_const_string(const bin_t *, off_t *, off_t, +/* Décode une instruction de type 'div-int'. */ +GArchInstruction *dalvik_read_instr_div_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'div-int/2addr'. */ +GArchInstruction *dalvik_read_instr_div_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'div-int/lit8'. */ +GArchInstruction *dalvik_read_instr_div_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'div-int/lit16'. */ +GArchInstruction *dalvik_read_instr_div_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +  /* Décode une instruction de type 'iget'. */ @@ -135,9 +172,19 @@ GArchInstruction *dalvik_read_instr_iput_wide(const bin_t *, off_t *, off_t, vmp  GArchInstruction *dalvik_read_instr_move_result_object(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 *); +  /* Décode une instruction de type 'mul-int/2addr'. */  GArchInstruction *dalvik_read_instr_mul_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); +/* Décode une instruction de type 'mul-int/lit8'. */ +GArchInstruction *dalvik_read_instr_mul_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'mul-int/lit16'. */ +GArchInstruction *dalvik_read_instr_mul_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +  /* 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 *); @@ -146,6 +193,44 @@ GArchInstruction *dalvik_read_instr_new_instance(const bin_t *, off_t *, off_t,  GArchInstruction *dalvik_read_instr_nop(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + + +/* Décode une instruction de type 'or-int'. */ +GArchInstruction *dalvik_read_instr_or_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'or-int/2addr'. */ +GArchInstruction *dalvik_read_instr_or_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'or-int/lit8'. */ +GArchInstruction *dalvik_read_instr_or_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'or-int/lit16'. */ +GArchInstruction *dalvik_read_instr_or_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + + + +/* Décode une instruction de type 'rem-int'. */ +GArchInstruction *dalvik_read_instr_rem_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'rem-int/2addr'. */ +GArchInstruction *dalvik_read_instr_rem_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'rem-int/lit8'. */ +GArchInstruction *dalvik_read_instr_rem_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'rem-int/lit16'. */ +GArchInstruction *dalvik_read_instr_rem_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + + +/* Décode une instruction de type 'rsub-int'. */ +GArchInstruction *dalvik_read_instr_rsub_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'rsub-int/lit8'. */ +GArchInstruction *dalvik_read_instr_rsub_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + + + +  /* Décode une instruction de type 'return'. */  GArchInstruction *dalvik_read_instr_return(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); @@ -171,6 +256,19 @@ GArchInstruction *dalvik_read_instr_sget_wide(const bin_t *, off_t *, off_t, vmp +/* Décode une instruction de type 'xor-int'. */ +GArchInstruction *dalvik_read_instr_xor_int(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'xor-int/2addr'. */ +GArchInstruction *dalvik_read_instr_xor_int_2addr(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'xor-int/lit8'. */ +GArchInstruction *dalvik_read_instr_xor_int_lit8(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + +/* Décode une instruction de type 'xor-int/lit16'. */ +GArchInstruction *dalvik_read_instr_xor_int_lit16(const bin_t *, off_t *, off_t, vmpa_t, const GDalvikProcessor *); + + diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index 7e8bf43..184a6e6 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -870,25 +870,25 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat      switch (model & ~DALVIK_OP_POOL_MASK)      { -        case DALVIK_OPT_12X: +        case DALVIK_OPT_11N:              types = (DalvikOperandID []) {                  DOI_REGISTER_4, -                DOI_REGISTER_4, +                DOI_IMMEDIATE_4,                  DOI_INVALID              };              break; -        case DALVIK_OPT_11N: +        case DALVIK_OPT_11X:              types = (DalvikOperandID []) { -                DOI_REGISTER_4, -                DOI_IMMEDIATE_4, +                DOI_REGISTER_8,                  DOI_INVALID              };              break; -        case DALVIK_OPT_11X: +        case DALVIK_OPT_12X:              types = (DalvikOperandID []) { -                DOI_REGISTER_8, +                DOI_REGISTER_4, +                DOI_REGISTER_4,                  DOI_INVALID              };              break; @@ -935,6 +935,24 @@ static bool dalvik_read_basic_operands(GArchInstruction *instr, const bin_t *dat              };              break; +        case DALVIK_OPT_22S: +            types = (DalvikOperandID []) { +                DOI_REGISTER_4, +                DOI_REGISTER_4, +                DOI_IMMEDIATE_16, +                DOI_INVALID +            }; +            break; + +        case DALVIK_OPT_23X: +            types = (DalvikOperandID []) { +                DOI_REGISTER_8, +                DOI_REGISTER_8, +                DOI_REGISTER_8, +                DOI_INVALID +            }; +            break; +          default:              types = (DalvikOperandID []) {                  DOI_INVALID @@ -1149,6 +1167,8 @@ bool dalvik_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos          case DALVIK_OPT_21S:          case DALVIK_OPT_22B:          case DALVIK_OPT_22C: +        case DALVIK_OPT_22S: +        case DALVIK_OPT_23X:              result = dalvik_read_basic_operands(instr, data, pos, len, &low, endian, model);              break; diff --git a/src/arch/dalvik/operand.h b/src/arch/dalvik/operand.h index fd26e96..2332cb3 100644 --- a/src/arch/dalvik/operand.h +++ b/src/arch/dalvik/operand.h @@ -198,6 +198,9 @@ typedef enum _DalvikOperandType      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_23X      = DALVIK_OP_LEN(2) | DALVIK_OP_REG(3) | 'X',      DALVIK_OPT_35C      = DALVIK_OP_LEN(3) | DALVIK_OP_REG(5) | 'C' diff --git a/src/arch/dalvik/processor.c b/src/arch/dalvik/processor.c index 1e54146..e05d6d0 100644 --- a/src/arch/dalvik/processor.c +++ b/src/arch/dalvik/processor.c @@ -200,10 +200,42 @@ static GArchInstruction *g_dalvik_processor_decode_instruction(const GDalvikProc          [DOP_INVOKE_INTERFACE]      = dalvik_read_instr_invoke_interface, -        [DOP_MUL_INT_2ADDR]         = dalvik_read_instr_mul_int_2addr, +        [DOP_ADD_INT]               = dalvik_read_instr_add_int, + +        [DOP_MUL_INT]               = dalvik_read_instr_mul_int, +        [DOP_DIV_INT]               = dalvik_read_instr_div_int, +        [DOP_REM_INT]               = dalvik_read_instr_rem_int, +        [DOP_AND_INT]               = dalvik_read_instr_and_int, +        [DOP_OR_INT]                = dalvik_read_instr_or_int, +        [DOP_XOR_INT]               = dalvik_read_instr_xor_int, -        [DOP_ADD_INT_LIT8]          = dalvik_read_instr_add_int_lit8 +        [DOP_ADD_INT_2ADDR]         = dalvik_read_instr_add_int_2addr, + +        [DOP_MUL_INT_2ADDR]         = dalvik_read_instr_mul_int_2addr, +        [DOP_DIV_INT_2ADDR]         = dalvik_read_instr_div_int_2addr, +        [DOP_REM_INT_2ADDR]         = dalvik_read_instr_rem_int_2addr, +        [DOP_AND_INT_2ADDR]         = dalvik_read_instr_and_int_2addr, +        [DOP_OR_INT_2ADDR]          = dalvik_read_instr_or_int_2addr, +        [DOP_XOR_INT_2ADDR]         = dalvik_read_instr_xor_int_2addr, + + +        [DOP_ADD_INT_LIT16]         = dalvik_read_instr_add_int_lit16, +        [DOP_RSUB_INT]              = dalvik_read_instr_rsub_int, +        [DOP_MUL_INT_LIT16]         = dalvik_read_instr_mul_int_lit16, +        [DOP_DIV_INT_LIT16]         = dalvik_read_instr_div_int_lit16, +        [DOP_REM_INT_LIT16]         = dalvik_read_instr_rem_int_lit16, +        [DOP_AND_INT_LIT16]         = dalvik_read_instr_and_int_lit16, +        [DOP_OR_INT_LIT16]          = dalvik_read_instr_or_int_lit16, +        [DOP_XOR_INT_LIT16]         = dalvik_read_instr_xor_int_lit16, +        [DOP_ADD_INT_LIT8]          = dalvik_read_instr_add_int_lit8, +        [DOP_RSUB_INT_LIT8]         = dalvik_read_instr_rsub_int_lit8, +        [DOP_MUL_INT_LIT8]          = dalvik_read_instr_mul_int_lit8, +        [DOP_DIV_INT_LIT8]          = dalvik_read_instr_div_int_lit8, +        [DOP_REM_INT_LIT8]          = dalvik_read_instr_rem_int_lit8, +        [DOP_AND_INT_LIT8]          = dalvik_read_instr_and_int_lit8, +        [DOP_OR_INT_LIT8]           = dalvik_read_instr_or_int_lit8, +        [DOP_XOR_INT_LIT8]          = dalvik_read_instr_xor_int_lit8      };  | 
