/* OpenIDA - Outil d'analyse de fichiers binaires * instruction.h - prototypes pour la gestion des instructions de la VM Dalvik * * 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 . */ #ifndef _ARCH_DALVIK_INSTRUCTION_H #define _ARCH_DALVIK_INSTRUCTION_H #include "../instruction.h" /* Enumération de tous les opcodes */ 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_WIDE, /* const-wide (0x18) */ DOP_CONST_STRING, /* const-string (0x1a) */ 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_NE, /* if-ne (0x33) */ DOP_IF_LT, /* if-lt (0x34) */ DOP_IF_GE, /* if-ge (0x35) */ DOP_IF_GT, /* if-gt (0x36) */ DOP_IF_LE, /* if-le (0x37) */ DOP_IF_EQZ, /* if-eqz (0x38) */ DOP_IF_NEZ, /* if-nez (0x39) */ DOP_IF_LTZ, /* if-ltz (0x3a) */ DOP_IF_GEZ, /* if-gez (0x3b) */ DOP_IF_GTZ, /* if-gtz (0x3c) */ DOP_IF_LEZ, /* if-lez (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) */ DOP_IGET_BOOLEAN, /* iget-boolean (0x55) */ DOP_IGET_BYTE, /* iget-byte (0x56) */ DOP_IGET_CHAR, /* iget-char (0x57) */ DOP_IGET_SHORT, /* iget-short (0x58) */ DOP_IPUT, /* iput (0x59) */ DOP_IPUT_WIDE, /* iput-wide (0x5a) */ DOP_IPUT_OBJECT, /* iput-object (0x5b) */ DOP_IPUT_BOOLEAN, /* iput-boolean (0x5c) */ DOP_IPUT_BYTE, /* iput-byte (0x5d) */ DOP_IPUT_CHAR, /* iput-char (0x5e) */ DOP_IPUT_SHORT, /* iput-short (0x5f) */ 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_SUB_INT, /* sub-int (0x91) */ 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_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) */ 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 } DalvikOpcodes; #define G_TYPE_DALVIK_INSTRUCTION g_dalvik_instruction_get_type() #define G_DALVIK_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_instruction_get_type(), GDalvikInstruction)) #define G_IS_DALVIK_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_instruction_get_type())) #define G_DALVIK_INSTRUCTION_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_dalvik_instruction_get_type(), GDalvikInstructionIface)) /* Définition générique d'une instruction d'architecture Dalvik (instance) */ typedef struct _GDalvikInstruction GDalvikInstruction; /* Définition générique d'une instruction d'architecture Dalvik (classe) */ typedef struct _GDalvikInstructionClass GDalvikInstructionClass; /* Indique le type défini pour une instruction d'architecture Dalvik. */ GType g_dalvik_instruction_get_type(void); /* Crée une instruction pour l'architecture Dalvik. */ GArchInstruction *g_dalvik_instruction_new(DalvikOpcodes); /* Indique l'opcode associé à une instruction Dalvik. */ DalvikOpcodes g_dalvik_instruction_get_opcode(const GDalvikInstruction *); /* --------------------- AIDE A LA MISE EN PLACE D'INSTRUCTIONS --------------------- */ /* Recherche l'identifiant de la prochaine instruction. */ DalvikOpcodes dalvik_guess_next_instruction(const bin_t *, off_t, off_t); #endif /* _ARCH_DALVIK_INSTRUCTION_H */