/* Chrysalide - Outil d'analyse de fichiers binaires
* instruction.c - gestion des instructions de l'architecture x86
*
* Copyright (C) 2009-2012 Cyrille Bagard
*
* This file is part of Chrysalide.
*
* 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 .
*/
#include "instruction.h"
#include
#include "operand.h"
#include "../instruction-int.h"
#include "../../common/extstr.h"
/* Définition générique d'une instruction d'architecture x86 (instance) */
struct _GX86Instruction
{
GArchInstruction parent; /* A laisser en premier */
X86Opcodes type; /* Position dans la liste */
X86Prefix prefixes; /* Préfixes finalement trouvés */
char *cached_text; /* Nom construit à conserver */
};
/* Définition générique d'une instruction d'architecture x86 (classe) */
struct _GX86InstructionClass
{
GArchInstructionClass parent; /* A laisser en premier */
};
/* Initialise la classe des instructions pour x86. */
static void g_x86_instruction_class_init(GX86InstructionClass *);
/* Initialise une instance d'opérande d'architecture x86. */
static void g_x86_instruction_init(GX86Instruction *);
/* --------------------- AIDE A LA MISE EN PLACE D'INSTRUCTIONS --------------------- */
/* Répertoire de toutes les instructions x86 */
typedef struct _x86_instruction
{
bool care_of_data; /* Devinette = repas ? */
bin_t opcode; /* Opcode de l'instruction */
bin_t op_extension; /* Extension de l'opcode */
const char *keyword; /* Mot clef de la commande */
X86Prefix prefix; /* Eventuel(s) préfixe(s) */
} x86_instruction;
#define OPCODE_EXT(eop) ((eop) & 0x38)
#define IDX_TO_EXT(idx) (idx == -1 ? 0xff : idx << 3)
static x86_instruction _instructions[XOP_COUNT] = {
/* Instructions avec opcode sur un octet */
[XOP_ADD_RM8_R8] = { false, 0x00, IDX_TO_EXT(-1), "add", XPX_NONE },
[XOP_ADD_RM1632_R1632] = { false, 0x01, IDX_TO_EXT(-1), "add", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ADD_R8_RM8] = { false, 0x02, IDX_TO_EXT(-1), "add", XPX_NONE },
[XOP_ADD_R1632_RM1632] = { false, 0x03, IDX_TO_EXT(-1), "add", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ADD_AL_IMM8] = { false, 0x04, IDX_TO_EXT(-1), "add", XPX_NONE },
[XOP_ADD_E_AX_IMM1632] = { false, 0x05, IDX_TO_EXT(-1), "add", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_OR_RM8_R8] = { false, 0x08, IDX_TO_EXT(-1), "or", XPX_NONE },
[XOP_OR_RM1632_R1632] = { false, 0x09, IDX_TO_EXT(-1), "or", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_OR_R8_RM8] = { false, 0x0a, IDX_TO_EXT(-1), "or", XPX_NONE },
[XOP_OR_R1632_RM1632] = { false, 0x0b, IDX_TO_EXT(-1), "or", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_OR_AL_IMM8] = { false, 0x0c, IDX_TO_EXT(-1), "or", XPX_NONE },
[XOP_ADC_RM8_R8] = { false, 0x10, IDX_TO_EXT(-1), "adc", XPX_NONE },
[XOP_SBB_RM1632_R1632] = { false, 0x19, IDX_TO_EXT(-1), "sbb", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_AND_RM8_R8] = { false, 0x20, IDX_TO_EXT(-1), "and", XPX_NONE },
[XOP_AND_RM1632_R1632] = { false, 0x21, IDX_TO_EXT(-1), "and", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_AND_AL_IMM8] = { false, 0x24, IDX_TO_EXT(-1), "and", XPX_NONE },
[XOP_AND_E_AX_IMM1632] = { false, 0x25, IDX_TO_EXT(-1), "and", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SUB_RM1632_R1632] = { false, 0x29, IDX_TO_EXT(-1), "sub", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SUB_R8_RM8] = { false, 0x2a, IDX_TO_EXT(-1), "sub", XPX_NONE },
[XOP_SUB_R1632_RM1632] = { false, 0x2b, IDX_TO_EXT(-1), "sub", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SUB_AL_IMM8] = { false, 0x2c, IDX_TO_EXT(-1), "sub", XPX_NONE },
[XOP_SUB_E_AX_IMM1632] = { false, 0x2d, IDX_TO_EXT(-1), "sub", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XOR_RM8_R8] = { false, 0x30, IDX_TO_EXT(-1), "xor", XPX_NONE},
[XOP_XOR_RM1632_R1632] = { false, 0x31, IDX_TO_EXT(-1), "xor", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XOR_R8_RM8] = { false, 0x32, IDX_TO_EXT(-1), "xor", XPX_NONE},
[XOP_XOR_R1632_RM1632] = { false, 0x33, IDX_TO_EXT(-1), "xor", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XOR_AL_IMM8] = { false, 0x34, IDX_TO_EXT(-1), "xor", XPX_NONE },
[XOP_XOR_E_AX_IMM1632] = { false, 0x35, IDX_TO_EXT(-1), "xor", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CMP_RM8_R8] = { false, 0x38, IDX_TO_EXT(-1), "cmp", XPX_NONE },
[XOP_CMP_RM1632_R1632] = { false, 0x39, IDX_TO_EXT(-1), "cmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CMP_R8_RM8] = { false, 0x3a, IDX_TO_EXT(-1), "cmp", XPX_NONE },
[XOP_CMP_R1632_RM1632] = { false, 0x3b, IDX_TO_EXT(-1), "cmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CMP_AL_IMM8] = { false, 0x3c, IDX_TO_EXT(-1), "cmp", XPX_NONE },
[XOP_CMP_E_AX_IMM1632] = { false, 0x3d, IDX_TO_EXT(-1), "cmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_AX] = { true, 0x40, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_CX] = { true, 0x41, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_DX] = { true, 0x42, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_BX] = { true, 0x43, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_SP] = { true, 0x44, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_BP] = { true, 0x45, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_SI] = { true, 0x46, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_INC_E_DI] = { true, 0x47, IDX_TO_EXT(-1), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_AX] = { true, 0x48, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_CX] = { true, 0x49, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_DX] = { true, 0x4a, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_BX] = { true, 0x4b, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_SP] = { true, 0x4c, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_BP] = { true, 0x4d, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_SI] = { true, 0x4e, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_E_DI] = { true, 0x4f, IDX_TO_EXT(-1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_AX] = { true, 0x50, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_CX] = { true, 0x51, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_DX] = { true, 0x52, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_BX] = { true, 0x53, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_SP] = { true, 0x54, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_BP] = { true, 0x55, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_SI] = { true, 0x56, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_E_DI] = { true, 0x57, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_AX] = { true, 0x58, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_CX] = { true, 0x59, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_DX] = { true, 0x5a, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_BX] = { true, 0x5b, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_SP] = { true, 0x5c, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_BP] = { true, 0x5d, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_SI] = { true, 0x5e, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POP_E_DI] = { true, 0x5f, IDX_TO_EXT(-1), "pop", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_POPA] = { false, 0x61, IDX_TO_EXT(-1), "popa", XPX_NONE },
[XOP_ARPL_RM16_R16] = { false, 0x63, IDX_TO_EXT(-1), "arpl", XPX_NONE },
[XOP_PUSH_IMM1632] = { false, 0x68, IDX_TO_EXT(-1), "push", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_IMUL_R1632_RM1632_IMM1632] = { false, 0x69, IDX_TO_EXT(-1), "imul", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_IMUL_RM1632_IMM8] = { false, 0x6b, IDX_TO_EXT(-1), "imul", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JO_REL8] = { false, 0x70, IDX_TO_EXT(-1), "jo", XPX_NONE },
[XOP_JNO_REL8] = { false, 0x71, IDX_TO_EXT(-1), "jno", XPX_NONE },
[XOP_JB_REL8] = { false, 0x72, IDX_TO_EXT(-1), "jb", XPX_NONE },
[XOP_JNB_REL8] = { false, 0x73, IDX_TO_EXT(-1), "jnb", XPX_NONE },
[XOP_JE_REL8] = { false, 0x74, IDX_TO_EXT(-1), "je", XPX_NONE },
[XOP_JNE_REL8] = { false, 0x75, IDX_TO_EXT(-1), "jne", XPX_NONE },
[XOP_JNA_REL8] = { false, 0x76, IDX_TO_EXT(-1), "jna", XPX_NONE },
[XOP_JA_REL8] = { false, 0x77, IDX_TO_EXT(-1), "ja", XPX_NONE },
[XOP_JS_REL8] = { false, 0x78, IDX_TO_EXT(-1), "js", XPX_NONE },
[XOP_JNS_REL8] = { false, 0x79, IDX_TO_EXT(-1), "jns", XPX_NONE },
[XOP_JP_REL8] = { false, 0x7a, IDX_TO_EXT(-1), "jp", XPX_NONE },
[XOP_JNP_REL8] = { false, 0x7b, IDX_TO_EXT(-1), "jnp", XPX_NONE },
[XOP_JL_REL8] = { false, 0x7c, IDX_TO_EXT(-1), "jl", XPX_NONE },
[XOP_JNL_REL8] = { false, 0x7d, IDX_TO_EXT(-1), "jnl", XPX_NONE },
[XOP_JNG_REL8] = { false, 0x7e, IDX_TO_EXT(-1), "jng", XPX_NONE },
[XOP_JG_REL8] = { false, 0x7f, IDX_TO_EXT(-1), "jg", XPX_NONE },
[XOP_ADD_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(0), "add", XPX_NONE },
[XOP_OR_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(1), "or", XPX_NONE },
[XOP_ADC_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(2), "adc", XPX_NONE },
[XOP_SBB_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(3), "sbb", XPX_NONE },
[XOP_AND_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(4), "and", XPX_NONE },
[XOP_SUB_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(5), "sub", XPX_NONE },
[XOP_XOR_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(6), "xor", XPX_NONE },
[XOP_CMP_RM8_IMM8] = { false, 0x80, IDX_TO_EXT(7), "cmp", XPX_NONE },
[XOP_ADD_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(0), "add", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_OR_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(0), "add", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ADC_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(2), "adc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SBB_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(3), "sbb", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_AND_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(4), "and", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SUB_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(5), "sub", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XOR_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(6), "xor", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CMP_RM1632_IMM1632] = { false, 0x81, IDX_TO_EXT(7), "cmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ADD_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(0), "add", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_OR_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(1), "or", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ADC_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(2), "adc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SBB_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(3), "sbb", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_AND_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(4), "and", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SUB_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(5), "sub", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XOR_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(6), "xor", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CMP_RM1632_IMM8] = { false, 0x83, IDX_TO_EXT(7), "cmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_TEST_RM8_R8] = { false, 0x84, IDX_TO_EXT(-1), "test", XPX_NONE },
[XOP_TEST_RM1632_R1632] = { false, 0x85, IDX_TO_EXT(-1), "test", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_RM8_R8] = { false, 0x88, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_RM1632_R1632] = { false, 0x89, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_R1632_RM1632] = { false, 0x8b, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_LEA_R1632_M] = { false, 0x8d, IDX_TO_EXT(-1), "lea", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_NOP] = { false, 0x90, IDX_TO_EXT(-1), "nop", XPX_NONE },
[XOP_XCHG_R1632_E_AX] = { true, 0x90, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_CX] = { true, 0x91, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_DX] = { true, 0x92, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_BX] = { true, 0x93, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_SP] = { true, 0x94, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_BP] = { true, 0x95, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_SI] = { true, 0x96, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_XCHG_R1632_E_DI] = { true, 0x97, IDX_TO_EXT(-1), "xchg", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_AL_MOFFS8] = { false, 0xa0, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_E_AX_MOFFS1632] = { false, 0xa1, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_MOFFS8_AL] = { false, 0xa2, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_MOFFS1632_E_AX] = { false, 0xa3, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOVS_M1632_M1632] = { false, 0xa5, IDX_TO_EXT(-1), "movs", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CMPS_M8_M8] = { false, 0xa6, IDX_TO_EXT(-1), "cmps", XPX_NONE },
[XOP_TEST_AL_IMM8] = { false, 0xa8, IDX_TO_EXT(-1), "test", XPX_NONE },
[XOP_TEST_E_AX_IMM1632] = { false, 0xa9, IDX_TO_EXT(-1), "test", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_STOS_M1632_E_AX] = { false, 0xab, IDX_TO_EXT(-1), "stos", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SCAS_AL_M8] = { false, 0xae, IDX_TO_EXT(-1), "scas", XPX_NONE },
[XOP_MOV_AL_IMM8] = { true, 0xb0, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_CL_IMM8] = { true, 0xb1, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_DL_IMM8] = { true, 0xb2, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_BL_IMM8] = { true, 0xb3, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_AH_IMM8] = { true, 0xb4, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_CH_IMM8] = { true, 0xb5, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_DH_IMM8] = { true, 0xb6, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_BH_IMM8] = { true, 0xb7, IDX_TO_EXT(-1), "mov", XPX_NONE },
[XOP_MOV_E_AX_IMM1632] = { true, 0xb8, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_CX_IMM1632] = { true, 0xb9, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_DX_IMM1632] = { true, 0xba, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_BX_IMM1632] = { true, 0xbb, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_SP_IMM1632] = { true, 0xbc, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_BP_IMM1632] = { true, 0xbd, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_SI_IMM1632] = { true, 0xbe, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOV_E_DI_IMM1632] = { true, 0xbf, IDX_TO_EXT(-1), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ROL_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(0), "rol", XPX_NONE },
[XOP_ROR_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(1), "ror", XPX_NONE },
[XOP_RCL_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(2), "rcl", XPX_NONE },
[XOP_RCR_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(3), "rcr", XPX_NONE },
[XOP_SHL_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(4), "shl", XPX_NONE },
[XOP_SHR_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(5), "shr", XPX_NONE },
[XOP_SAL_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(6), "sal", XPX_NONE },
[XOP_SAR_RM8_IMM8] = { false, 0xc0, IDX_TO_EXT(7), "sar", XPX_NONE },
[XOP_ROL_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(0), "rol", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ROR_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(1), "ror", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RCL_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(2), "rcl", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RCR_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(3), "rcr", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SHL_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(4), "shl", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SHR_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(5), "shr", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SAL_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(6), "sal", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SAR_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(7), "sar", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RETN_IMM16] = { false, 0xc2, IDX_TO_EXT(-1), "retn", XPX_NONE },
[XOP_RETN] = { false, 0xc3, IDX_TO_EXT(-1), "ret", XPX_NONE },
[XOP_MOV_RM8_IMM8] = { false, 0xc6, IDX_TO_EXT(0), "mov", XPX_NONE },
[XOP_MOV_RM1632_IMM1632] = { false, 0xc7, IDX_TO_EXT(0), "mov", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_LEAVE] = { false, 0xc9, IDX_TO_EXT(-1), "leave", XPX_NONE },
[XOP_RETF_IMM16] = { false, 0xca, IDX_TO_EXT(-1), "retf", XPX_NONE },
[XOP_RETF] = { false, 0xcb, IDX_TO_EXT(-1), "ret", XPX_NONE },
[XOP_INT_3] = { false, 0xcc, IDX_TO_EXT(-1), "int", XPX_NONE },
[XOP_INT] = { false, 0xcd, IDX_TO_EXT(-1), "int", XPX_NONE },
[XOP_ROL_RM8_1] = { false, 0xd0, IDX_TO_EXT(0), "rol", XPX_NONE },
[XOP_ROR_RM8_1] = { false, 0xd0, IDX_TO_EXT(1), "ror", XPX_NONE },
[XOP_RCL_RM8_1] = { false, 0xd0, IDX_TO_EXT(2), "rcl", XPX_NONE },
[XOP_RCR_RM8_1] = { false, 0xd0, IDX_TO_EXT(3), "rcr", XPX_NONE },
[XOP_SHL_RM8_1] = { false, 0xd0, IDX_TO_EXT(4), "shl", XPX_NONE },
[XOP_SHR_RM8_1] = { false, 0xd0, IDX_TO_EXT(5), "shr", XPX_NONE },
[XOP_SAL_RM8_1] = { false, 0xd0, IDX_TO_EXT(6), "sal", XPX_NONE },
[XOP_SAR_RM8_1] = { false, 0xd0, IDX_TO_EXT(7), "sar", XPX_NONE },
[XOP_ROL_RM1632_1] = { false, 0xd1, IDX_TO_EXT(0), "rol", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ROR_RM1632_1] = { false, 0xd1, IDX_TO_EXT(1), "ror", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RCL_RM1632_1] = { false, 0xd1, IDX_TO_EXT(2), "rcl", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RCR_RM1632_1] = { false, 0xd1, IDX_TO_EXT(3), "rcr", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SHL_RM1632_1] = { false, 0xd1, IDX_TO_EXT(4), "shl", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SHR_RM1632_1] = { false, 0xd1, IDX_TO_EXT(5), "shr", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SAL_RM1632_1] = { false, 0xd1, IDX_TO_EXT(6), "sal", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SAR_RM1632_1] = { false, 0xd1, IDX_TO_EXT(7), "sar", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ROL_RM8_CL] = { false, 0xd2, IDX_TO_EXT(0), "rol", XPX_NONE },
[XOP_ROR_RM8_CL] = { false, 0xd2, IDX_TO_EXT(1), "ror", XPX_NONE },
[XOP_RCL_RM8_CL] = { false, 0xd2, IDX_TO_EXT(2), "rcl", XPX_NONE },
[XOP_RCR_RM8_CL] = { false, 0xd2, IDX_TO_EXT(3), "rcr", XPX_NONE },
[XOP_SHL_RM8_CL] = { false, 0xd2, IDX_TO_EXT(4), "shl", XPX_NONE },
[XOP_SHR_RM8_CL] = { false, 0xd2, IDX_TO_EXT(5), "shr", XPX_NONE },
[XOP_SAL_RM8_CL] = { false, 0xd2, IDX_TO_EXT(6), "sal", XPX_NONE },
[XOP_SAR_RM8_CL] = { false, 0xd2, IDX_TO_EXT(7), "sar", XPX_NONE },
[XOP_ROL_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(0), "rol", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_ROR_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(1), "ror", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RCL_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(2), "rcl", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_RCR_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(3), "rcr", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SHL_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(4), "shl", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SHR_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(5), "shr", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SAL_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(6), "sal", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SAR_RM1632_CL] = { false, 0xd3, IDX_TO_EXT(7), "sar", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CALL_REL1632] = { false, 0xe8, IDX_TO_EXT(-1), "call", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JMP_REL1632] = { false, 0xe9, IDX_TO_EXT(-1), "jmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JMP_REL8] = { false, 0xeb, IDX_TO_EXT(-1), "jmp", XPX_NONE },
[XOP_HLT] = { false, 0xf4, IDX_TO_EXT(-1), "hlt", XPX_NONE },
[XOP_TEST_RM8_IMM8] = { false, 0xf6, IDX_TO_EXT(0), "test", XPX_NONE },
[XOP_TEST_RM8_IMM8_BIS] = { false, 0xf6, IDX_TO_EXT(1), "test", XPX_NONE },
[XOP_NOT_RM8] = { false, 0xf6, IDX_TO_EXT(2), "not", XPX_NONE },
[XOP_TEST_RM1632_IMM1632] = { false, 0xf7, IDX_TO_EXT(0), "test", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_TEST_RM1632_IMM1632_BIS] = { false, 0xf7, IDX_TO_EXT(1), "test", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_NOT_RM1632] = { false, 0xf7, IDX_TO_EXT(2), "not", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_IMUL_RM1632] = { false, 0xf7, IDX_TO_EXT(5), "imul", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CLD] = { false, 0xfc, IDX_TO_EXT(-1), "cld", XPX_NONE },
[XOP_INC_RM8] = { false, 0xfe, IDX_TO_EXT(0), "inc", XPX_NONE },
[XOP_DEC_RM8] = { false, 0xfe, IDX_TO_EXT(1), "dec", XPX_NONE },
[XOP_INC_RM1632] = { false, 0xff, IDX_TO_EXT(0), "inc", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_DEC_RM1632] = { false, 0xff, IDX_TO_EXT(1), "dec", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_CALL_RM1632] = { false, 0xff, IDX_TO_EXT(2), "call", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JMP_RM1632] = { false, 0xff, IDX_TO_EXT(4), "jmp", XPX_OPERAND_SIZE_OVERRIDE },
[XOP_PUSH_RM1632] = { false, 0xff, IDX_TO_EXT(6), "push", XPX_OPERAND_SIZE_OVERRIDE },
/* Instructions avec opcode sur deux octets */
[XOP_JO_REL1632] = { false, 0x80, IDX_TO_EXT(-1), "jo", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNO_REL1632] = { false, 0x81, IDX_TO_EXT(-1), "jno", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JB_REL1632] = { false, 0x82, IDX_TO_EXT(-1), "jb", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNB_REL1632] = { false, 0x83, IDX_TO_EXT(-1), "jnb", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JE_REL1632] = { false, 0x84, IDX_TO_EXT(-1), "je", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNE_REL1632] = { false, 0x85, IDX_TO_EXT(-1), "jne", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNA_REL1632] = { false, 0x86, IDX_TO_EXT(-1), "jna", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JA_REL1632] = { false, 0x87, IDX_TO_EXT(-1), "ja", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JS_REL1632] = { false, 0x88, IDX_TO_EXT(-1), "js", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNS_REL1632] = { false, 0x89, IDX_TO_EXT(-1), "jns", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JP_REL1632] = { false, 0x8a, IDX_TO_EXT(-1), "jp", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNP_REL1632] = { false, 0x8b, IDX_TO_EXT(-1), "jnp", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JL_REL1632] = { false, 0x8c, IDX_TO_EXT(-1), "jl", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNL_REL1632] = { false, 0x8d, IDX_TO_EXT(-1), "jnl", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JNG_REL1632] = { false, 0x8e, IDX_TO_EXT(-1), "jng", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_JG_REL1632] = { false, 0x8f, IDX_TO_EXT(-1), "jg", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_SETO_RM8] = { false, 0x90, IDX_TO_EXT(-1), "seto", XPX_TWO_BYTES },
[XOP_SETNO_RM8] = { false, 0x91, IDX_TO_EXT(-1), "setno", XPX_TWO_BYTES },
[XOP_SETB_RM8] = { false, 0x92, IDX_TO_EXT(-1), "setn", XPX_TWO_BYTES },
[XOP_SETNB_RM8] = { false, 0x93, IDX_TO_EXT(-1), "setnb", XPX_TWO_BYTES },
[XOP_SETE_RM8] = { false, 0x94, IDX_TO_EXT(-1), "sete", XPX_TWO_BYTES },
[XOP_SETNE_RM8] = { false, 0x95, IDX_TO_EXT(-1), "setne", XPX_TWO_BYTES },
[XOP_SETNA_RM8] = { false, 0x96, IDX_TO_EXT(-1), "setna", XPX_TWO_BYTES },
[XOP_SETA_RM8] = { false, 0x97, IDX_TO_EXT(-1), "seta", XPX_TWO_BYTES },
[XOP_SETS_RM8] = { false, 0x98, IDX_TO_EXT(-1), "sets", XPX_TWO_BYTES },
[XOP_SETNS_RM8] = { false, 0x99, IDX_TO_EXT(-1), "setns", XPX_TWO_BYTES },
[XOP_SETP_RM8] = { false, 0x9a, IDX_TO_EXT(-1), "setp", XPX_TWO_BYTES },
[XOP_SETNP_RM8] = { false, 0x9b, IDX_TO_EXT(-1), "setnp", XPX_TWO_BYTES },
[XOP_SETL_RM8] = { false, 0x9c, IDX_TO_EXT(-1), "setl", XPX_TWO_BYTES },
[XOP_SETNL_RM8] = { false, 0x9d, IDX_TO_EXT(-1), "setnl", XPX_TWO_BYTES },
[XOP_SETNG_RM8] = { false, 0x9e, IDX_TO_EXT(-1), "setng", XPX_TWO_BYTES },
[XOP_SETG_RM8] = { false, 0x9f, IDX_TO_EXT(-1), "setg", XPX_TWO_BYTES },
[XOP_MOVZX_R1632_RM8] = { false, 0xb6, IDX_TO_EXT(-1), "movzx", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOVZX_R1632_RM16] = { false, 0xb7, IDX_TO_EXT(-1), "movzx", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOVSX_R1632_RM8] = { false, 0xbe, IDX_TO_EXT(-1), "movsx", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE },
[XOP_MOVSX_R1632_RM1632] = { false, 0xbf, IDX_TO_EXT(-1), "movsx", XPX_TWO_BYTES | XPX_OPERAND_SIZE_OVERRIDE }
};
/* Traduit une instruction en version humainement lisible. */
static const char *x86_get_instruction_text(GX86Instruction *, const GExeFormat *, AsmSyntax);
/* Informe sur une éventuelle référence à une autre instruction. */
static InstructionLinkType x86_get_instruction_link(const GX86Instruction *, vmpa_t *);
/* Indique si l'instruction correspond à un retour de fonction. */
static bool x86_instruction_is_return(const GX86Instruction *);
/* Indique le type défini pour une instruction d'architecture x86. */
G_DEFINE_TYPE(GX86Instruction, g_x86_instruction, G_TYPE_ARCH_INSTRUCTION);
/******************************************************************************
* *
* Paramètres : klass = classe à initialiser. *
* *
* Description : Initialise la classe des instructions pour x86. *
* *
* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
static void g_x86_instruction_class_init(GX86InstructionClass *klass)
{
}
/******************************************************************************
* *
* Paramètres : instr = instance à initialiser. *
* *
* Description : Initialise une instance d'instruction d'architecture x86. *
* *
* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
static void g_x86_instruction_init(GX86Instruction *instr)
{
GArchInstruction *parent; /* Instance parente */
parent = G_ARCH_INSTRUCTION(instr);
//parent->get_text = (get_instruction_text_fc)x86_get_instruction_text;
parent->get_link = (get_instruction_link_fc)x86_get_instruction_link;
parent->is_return = (is_instruction_return_fc)x86_instruction_is_return;
}
/******************************************************************************
* *
* Paramètres : type = type d'instruction à représenter. *
* *
* Description : Crée une instruction pour l'architecture x86. *
* *
* Retour : Architecture mise en place. *
* *
* Remarques : - *
* *
******************************************************************************/
GArchInstruction *g_x86_instruction_new(X86Opcodes type)
{
GArchInstruction *result; /* Structure à retourner */
result = g_object_new(G_TYPE_X86_INSTRUCTION, NULL);
G_X86_INSTRUCTION(result)->type = type;
return result;
}
/******************************************************************************
* *
* Paramètres : instr = instruction à consulter. *
* *
* Description : Fournit l'identifiant de l'opcode représenté. *
* *
* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
X86Opcodes g_x86_instruction_get_opcode(const GX86Instruction *instr)
{
return instr->type;
}
/******************************************************************************
* *
* Paramètres : instr = instruction à venir compléter. *
* prefixes = listes des préfixes rencontrés. *
* *
* Description : Attache à une instructions ses préfixes associés. *
* *
* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
void g_x86_instruction_set_prefixes(GX86Instruction *instr, X86Prefix prefixes)
{
instr->prefixes = prefixes;
}
/* ---------------------------------------------------------------------------------- */
/* AIDE A LA MISE EN PLACE D'INSTRUCTIONS */
/* ---------------------------------------------------------------------------------- */
/******************************************************************************
* *
* Paramètres : data = flux de données à analyser. *
* pos = position courante dans ce flux. *
* len = taille totale des données à analyser. *
* prefix = éventuel(s) préfixe(s) remarqué(s). [OUT] *
* care = la lecture de l'instr. veut-elle les opcodes ? [OUT]*
* *
* Description : Recherche l'identifiant de la prochaine instruction. *
* *
* Retour : Identifiant de la prochaine instruction à tenter de charger. *
* *
* Remarques : - *
* *
******************************************************************************/
X86Opcodes x86_guess_next_instruction(const bin_t *data, off_t pos, off_t len, X86Prefix *prefix, bool *care)
{
X86Opcodes result; /* Identifiant à retourner */
X86Prefix extra; /* Préfixes n'intervenant pas */
bin_t opcode; /* Opcode à trouver */
extra = XPX_NONE;
*prefix = XPX_NONE;
while (pos < len)
switch (data[pos])
{
case 0x0f:
pos++;
*prefix |= XPX_TWO_BYTES;
break;
case 0x66:
pos++;
*prefix |= XPX_OPERAND_SIZE_OVERRIDE;
break;
case 0xf2:
pos++;
extra |= XPX_REPEAT_STR_OPERATION_F2;
break;
case 0xf3:
pos++;
extra |= XPX_REPEAT_STR_OPERATION_F3;
break;
default:
goto xgni_look_for;
break;
}
xgni_look_for:
if (pos == len) return XOP_COUNT;
opcode = data[pos];
for (result = 0; result < XOP_COUNT; result++)
{
/* TODO : à intégrer dans la liste */
if (_instructions[result].prefix & XPX_TWO_BYTES)
{
if ((_instructions[result].prefix & *prefix) != (*prefix | XPX_TWO_BYTES)) continue;
}
else if ((_instructions[result].prefix & *prefix) != *prefix) continue;
if (_instructions[result].opcode != opcode) continue;
if (_instructions[result].op_extension != IDX_TO_EXT(-1))
{
if ((pos + 1) == len) continue;
if (_instructions[result].op_extension != OPCODE_EXT(data[pos + 1])) continue;
}
*prefix |= extra;
*care = _instructions[result].care_of_data;
break;
}
return result;
}
/******************************************************************************
* *
* Paramètres : instr = instruction à traiter. *
* format = format du binaire manipulé. *
* syntax = type de représentation demandée. *
* *
* Description : Traduit une instruction en version humainement lisible. *
* *
* Retour : Chaîne de caractères à libérer de la mémoire. *
* *
* Remarques : - *
* *
******************************************************************************/
static const char *x86_get_instruction_text(GX86Instruction *instr, const GExeFormat *format, AsmSyntax syntax)
{
char *result; /* Chaîne nouvelle à renvoyer */
const char *prefix; /* Préfixe à ajouter */
if (instr->cached_text != NULL)
return instr->cached_text;
result = strdup(_instructions[instr->type].keyword);
/**
* Eventuelle répétion de l'instruction.
* cf. "Repeat String Operation Prefix" (Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 2B)
* cf. http://www.intel.com/software/products/documentation/vlin/mergedprojects/analyzer_ec/mergedprojects/reference_olh/mergedProjects/instructions/instruct32_hh/vc276.htm
*/
if (instr->prefixes & (XPX_REPEAT_STR_OPERATION_F2 | XPX_REPEAT_STR_OPERATION_F3))
{
prefix = NULL;
if (instr->prefixes & XPX_REPEAT_STR_OPERATION_F2)
switch (instr->type)
{
case XOP_CMPS_M8_M8:
prefix = "repnz ";
break;
case XOP_SCAS_AL_M8:
prefix = "repnz ";
break;
default:
prefix = NULL;
break;
}
else if (instr->prefixes & XPX_REPEAT_STR_OPERATION_F3)
switch (instr->type)
{
case XOP_CMPS_M8_M8:
prefix = "repz ";
break;
case XOP_SCAS_AL_M8:
prefix = "repz ";
break;
default:
prefix = NULL;
break;
}
if (prefix != NULL)
result = strprep(result, prefix);
}
instr->cached_text = result;
return result;
}
/******************************************************************************
* *
* Paramètres : instr = instruction à consulter. *
* addr = eventuelle adresse associée à faire connaître. [OUT] *
* *
* Description : Informe sur une éventuelle référence à une autre instruction.*
* *
* Retour : Type de lien trouvé ou ILT_NONE si aucun. *
* *
* Remarques : - *
* *
******************************************************************************/
static InstructionLinkType x86_get_instruction_link(const GX86Instruction *instr, vmpa_t *addr)
{
InstructionLinkType result; /* Type de lien à retourner */
const GX86RelativeOperand *relative; /* Adresse relative */
switch (instr->type)
{
case XOP_JA_REL1632:
relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP_IF_TRUE;
else result = ILT_NONE;
break;
case XOP_JO_REL8:
case XOP_JNO_REL8:
case XOP_JB_REL8:
case XOP_JNB_REL8:
case XOP_JE_REL8:
case XOP_JNE_REL8:
case XOP_JNA_REL8:
case XOP_JA_REL8:
case XOP_JS_REL8:
case XOP_JNS_REL8:
case XOP_JP_REL8:
case XOP_JNP_REL8:
case XOP_JL_REL8:
case XOP_JNL_REL8:
case XOP_JNG_REL8:
case XOP_JG_REL8:
relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP_IF_TRUE;
else result = ILT_NONE;
break;
case XOP_CALL_REL1632:
relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_CALL;
else result = ILT_NONE;
break;
case XOP_JMP_REL1632:
relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP;
else result = ILT_NONE;
break;
case XOP_JMP_REL8:
relative = G_X86_RELATIVE_OPERAND(g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0));
if (g_imm_operand_to_vmpa_t(g_x86_relative_operand_get_value(relative), addr)) result = ILT_JUMP;
else result = ILT_NONE;
break;
default:
result = ILT_NONE;
break;
}
return result;
}
/******************************************************************************
* *
* Paramètres : instr = instruction à consulter. *
* *
* Description : Indique si l'instruction correspond à un retour de fonction. *
* *
* Retour : true si l'instruction est un 'return' quelconque ou false. *
* *
* Remarques : - *
* *
******************************************************************************/
static bool x86_instruction_is_return(const GX86Instruction *instr)
{
return false;/* FIXME (instr->type == XOP_RET);*/
}