From c0831e2a8d16d65e8f31e52a63b703086609d8dd Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 18 Aug 2010 23:20:47 +0000 Subject: Supported several extra x86 instructions. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@182 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 24 +++++++ src/arch/x86/instruction.c | 55 ++++++++++++--- src/arch/x86/instruction.h | 53 ++++++++++++-- src/arch/x86/op_cmp.c | 38 ++++++++++ src/arch/x86/op_movzx.c | 36 ++++++++++ src/arch/x86/op_rcl.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ src/arch/x86/op_rcr.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ src/arch/x86/op_ret.c | 103 ++++++++++++++++++++++++++- src/arch/x86/op_rol.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ src/arch/x86/op_ror.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ src/arch/x86/op_sar.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ src/arch/x86/op_shl.c | 135 +++++++++++++++++++++++++++++++++++ src/arch/x86/op_shr.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ src/arch/x86/opcodes.h | 142 ++++++++++++++++++++++++++++++++++++- src/arch/x86/operand.c | 12 ++++ src/arch/x86/operand.h | 15 ++-- src/arch/x86/processor.c | 46 +++++++++++- 17 files changed, 1660 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14d0af8..53706d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +10-08-19 Cyrille Bagard + + * src/arch/x86/instruction.c: + * src/arch/x86/instruction.h: + * src/arch/x86/op_cmp.c: + * src/arch/x86/opcodes.h: + Support several extra x86 instructions. + + * src/arch/x86/operand.c: + * src/arch/x86/operand.h: + Support three extra x86 operands. + + * src/arch/x86/op_movzx.c: + * src/arch/x86/op_rcl.c: + * src/arch/x86/op_rcr.c: + * src/arch/x86/op_ret.c: + * src/arch/x86/op_rol.c: + * src/arch/x86/op_ror.c: + * src/arch/x86/op_sar.c: + * src/arch/x86/op_shl.c: + * src/arch/x86/op_shr.c: + * src/arch/x86/processor.c: + Support several extra x86 instructions. + 10-08-17 Cyrille Bagard * src/arch/x86/instruction.c: diff --git a/src/arch/x86/instruction.c b/src/arch/x86/instruction.c index af1d25e..f5901ef 100644 --- a/src/arch/x86/instruction.c +++ b/src/arch/x86/instruction.c @@ -137,7 +137,7 @@ static x86_instruction _instructions[XOP_COUNT] = { [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 }, @@ -291,9 +291,14 @@ static x86_instruction _instructions[XOP_COUNT] = { [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 }, @@ -304,7 +309,8 @@ static x86_instruction _instructions[XOP_COUNT] = { [XOP_SAR_RM1632_IMM8] = { false, 0xc1, IDX_TO_EXT(7), "sar", XPX_OPERAND_SIZE_OVERRIDE }, - [XOP_RET] = { false, 0xc3, IDX_TO_EXT(-1), "ret", XPX_NONE }, + [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 }, @@ -313,13 +319,44 @@ static x86_instruction _instructions[XOP_COUNT] = { [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 }, @@ -394,6 +431,8 @@ static x86_instruction _instructions[XOP_COUNT] = { [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 } @@ -779,6 +818,6 @@ static InstructionLinkType x86_get_instruction_link(const GX86Instruction *instr static bool x86_instruction_is_return(const GX86Instruction *instr) { - return (instr->type == XOP_RET); + return false;/* FIXME (instr->type == XOP_RET);*/ } diff --git a/src/arch/x86/instruction.h b/src/arch/x86/instruction.h index bd57ff6..001233e 100644 --- a/src/arch/x86/instruction.h +++ b/src/arch/x86/instruction.h @@ -78,7 +78,7 @@ typedef enum _X86Opcodes XOP_CMP_RM8_R8, /* cmp (0x38) */ XOP_CMP_RM1632_R1632, /* cmp ([0x66] 0x39) */ - + XOP_CMP_R8_RM8, /* cmp (0x3a) */ XOP_CMP_R1632_RM1632, /* cmp ([0x66] 0x3b) */ XOP_CMP_AL_IMM8, /* cmp (0x3c) */ XOP_CMP_E_AX_IMM1632, /* cmp ([0x66] 0x3d) */ @@ -232,8 +232,14 @@ typedef enum _X86Opcodes XOP_MOV_E_BP_IMM1632, /* mov ([0x66] 0xbd) */ XOP_MOV_E_SI_IMM1632, /* mov ([0x66] 0xbe) */ XOP_MOV_E_DI_IMM1632, /* mov ([0x66] 0xbf) */ - - + XOP_ROL_RM8_IMM8, /* rol (0xc0 0) */ + XOP_ROR_RM8_IMM8, /* ror (0xc0 1) */ + XOP_RCL_RM8_IMM8, /* rcl (0xc0 2) */ + XOP_RCR_RM8_IMM8, /* rcr (0xc0 3) */ + XOP_SHL_RM8_IMM8, /* shl (0xc0 4) */ + XOP_SHR_RM8_IMM8, /* shr (0xc0 5) */ + XOP_SAL_RM8_IMM8, /* sal (0xc0 6) */ + XOP_SAR_RM8_IMM8, /* sar (0xc0 7) */ XOP_ROL_RM1632_IMM8, /* rol ([0x66] 0xc1 0) */ XOP_ROR_RM1632_IMM8, /* ror ([0x66] 0xc1 1) */ XOP_RCL_RM1632_IMM8, /* rcl ([0x66] 0xc1 2) */ @@ -244,17 +250,52 @@ typedef enum _X86Opcodes XOP_SAR_RM1632_IMM8, /* sar ([0x66] 0xc1 7) */ - XOP_RET, /* ret (0xc3) */ + XOP_RETN_IMM16, /* retn (0xc2) */ + XOP_RETN, /* ret (0xc3) */ XOP_MOV_RM8_IMM8, /* mov (0xc6 0) */ XOP_MOV_RM1632_IMM1632, /* mov ([0x66] 0xc7 0) */ XOP_LEAVE, /* leave (0xc9) */ - + XOP_RETF_IMM16, /* retn (0xca) */ + XOP_RETF, /* ret (0xcb) */ XOP_INT_3, /* int 3 (0xcc) */ XOP_INT, /* int (0xcd) */ + + XOP_ROL_RM8_1, /* rol (0xd0 0) */ + XOP_ROR_RM8_1, /* ror (0xd0 1) */ + XOP_RCL_RM8_1, /* rcl (0xd0 2) */ + XOP_RCR_RM8_1, /* rcr (0xd0 3) */ + XOP_SHL_RM8_1, /* shl (0xd0 4) */ + XOP_SHR_RM8_1, /* shr (0xd0 5) */ + XOP_SAL_RM8_1, /* sal (0xd0 6) */ + XOP_SAR_RM8_1, /* sar (0xd0 7) */ + XOP_ROL_RM1632_1, /* rol ([0x66] 0xd1 0) */ + XOP_ROR_RM1632_1, /* ror ([0x66] 0xd1 1) */ + XOP_RCL_RM1632_1, /* rcl ([0x66] 0xd1 2) */ + XOP_RCR_RM1632_1, /* rcr ([0x66] 0xd1 3) */ + XOP_SHL_RM1632_1, /* shl ([0x66] 0xd1 4) */ + XOP_SHR_RM1632_1, /* shr ([0x66] 0xd1 5) */ + XOP_SAL_RM1632_1, /* sal ([0x66] 0xd1 6) */ + XOP_SAR_RM1632_1, /* sar ([0x66] 0xd1 7) */ + XOP_ROL_RM8_CL, /* rol (0xd2 0) */ + XOP_ROR_RM8_CL, /* ror (0xd2 1) */ + XOP_RCL_RM8_CL, /* rcl (0xd2 2) */ + XOP_RCR_RM8_CL, /* rcr (0xd2 3) */ + XOP_SHL_RM8_CL, /* shl (0xd2 4) */ + XOP_SHR_RM8_CL, /* shr (0xd2 5) */ + XOP_SAL_RM8_CL, /* sal (0xd2 6) */ + XOP_SAR_RM8_CL, /* sar (0xd2 7) */ + XOP_ROL_RM1632_CL, /* rol ([0x66] 0xd3 0) */ + XOP_ROR_RM1632_CL, /* ror ([0x66] 0xd3 1) */ + XOP_RCL_RM1632_CL, /* rcl ([0x66] 0xd3 2) */ + XOP_RCR_RM1632_CL, /* rcr ([0x66] 0xd3 3) */ XOP_SHL_RM1632_CL, /* shl ([0x66] 0xd3 4) */ + XOP_SHR_RM1632_CL, /* shr ([0x66] 0xd3 5) */ + XOP_SAL_RM1632_CL, /* sal ([0x66] 0xd3 6) */ + XOP_SAR_RM1632_CL, /* sar ([0x66] 0xd3 7) */ + XOP_CALL_REL1632, /* call ([0x66] 0xe8) */ XOP_JMP_REL1632, /* jmp ([0x66] 0xe9) */ @@ -321,6 +362,8 @@ typedef enum _X86Opcodes XOP_MOVZX_R1632_RM8, /* movzx ([0x66] 0x0f 0xb6) */ + XOP_MOVZX_R1632_RM16, /* movzx ([0x66] 0x0f 0xb7) */ + XOP_MOVSX_R1632_RM8, /* movsx ([0x66] 0x0f 0xbe) */ XOP_MOVSX_R1632_RM1632, /* movsx ([0x66] 0x0f 0xbf) */ diff --git a/src/arch/x86/op_cmp.c b/src/arch/x86/op_cmp.c index 7972fd9..c503b02 100644 --- a/src/arch/x86/op_cmp.c +++ b/src/arch/x86/op_cmp.c @@ -107,6 +107,39 @@ GArchInstruction *x86_read_instr_cmp_e_ax_imm1632(const bin_t *data, off_t *pos, * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'cmp' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_cmp_r8_rm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_CMP_R8_RM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_R8, X86_OTP_RM8)) + { + /* TODO free(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 'cmp' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * @@ -170,6 +203,11 @@ GArchInstruction *x86_read_instr_cmp_rm8_imm8(const bin_t *data, off_t *pos, off /****************************************************************************** * * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse virtuelle de l'instruction. * +* proc = architecture ciblée par le désassemblage. * * * * Description : Décode une instruction de type 'cmp' (8 bits). * * * diff --git a/src/arch/x86/op_movzx.c b/src/arch/x86/op_movzx.c index 917399a..e25ca85 100644 --- a/src/arch/x86/op_movzx.c +++ b/src/arch/x86/op_movzx.c @@ -64,3 +64,39 @@ GArchInstruction *x86_read_instr_movzx_r1632_rm8(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 'movzx' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_movzx_r1632_rm16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_MOVZX_R1632_RM16); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_R1632, X86_OTP_RM16, oprsize)) + { + /* TODO free(result);*/ + return NULL; + } + + return result; + +} diff --git a/src/arch/x86/op_rcl.c b/src/arch/x86/op_rcl.c index 52709a4..03e920e 100644 --- a/src/arch/x86/op_rcl.c +++ b/src/arch/x86/op_rcl.c @@ -38,6 +38,177 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'rcl' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcl_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RCL_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'rcl' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcl_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RCL_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'rcl' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcl_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RCL_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'rcl' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcl_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_RCL_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'rcl' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcl_rm1632_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_RCL_RM1632_CL); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_CL, oprsize)) + { + /* TODO free(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 'rcl' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/op_rcr.c b/src/arch/x86/op_rcr.c index 0047203..cd2c42d 100644 --- a/src/arch/x86/op_rcr.c +++ b/src/arch/x86/op_rcr.c @@ -38,6 +38,177 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'rcr' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcr_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RCR_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'rcr' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcr_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RCR_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'rcr' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcr_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RCR_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'rcr' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcr_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_RCR_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'rcr' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rcr_rm1632_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_RCR_RM1632_CL); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_CL, oprsize)) + { + /* TODO free(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 'rcr' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/op_ret.c b/src/arch/x86/op_ret.c index fcb4d6d..4e2f26b 100644 --- a/src/arch/x86/op_ret.c +++ b/src/arch/x86/op_ret.c @@ -26,6 +26,7 @@ #include "../instruction-int.h" #include "opcodes.h" +#include "operand.h" @@ -38,7 +39,7 @@ * prefix = éventuel(s) préfixe(s) remarqué(s). * * proc = architecture ciblée par le désassemblage. * * * -* Description : Décode une instruction de type 'ret'. * +* Description : Décode une instruction de type 'retf'. * * * * Retour : Instruction mise en place ou NULL. * * * @@ -46,11 +47,107 @@ * * ******************************************************************************/ -GArchInstruction *x86_read_instr_ret(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +GArchInstruction *x86_read_instr_retf(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) { GArchInstruction *result; /* Instruction à retourner */ - result = g_x86_instruction_new(XOP_RET); + result = g_x86_instruction_new(XOP_RETF); + + 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. * +* prefix = éventuel(s) préfixe(s) remarqué(s). * +* proc = architecture ciblée par le désassemblage. * +* * +* Description : Décode une instruction de type 'retf' (16 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_retf_imm16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RETF_IMM16); + + if (!x86_read_one_operand(result, data, pos, len, X86_OTP_IMM16)) + { + 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. * +* prefix = éventuel(s) préfixe(s) remarqué(s). * +* proc = architecture ciblée par le désassemblage. * +* * +* Description : Décode une instruction de type 'retn'. * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_retn(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RETN); + + 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. * +* prefix = éventuel(s) préfixe(s) remarqué(s). * +* proc = architecture ciblée par le désassemblage. * +* * +* Description : Décode une instruction de type 'retn' (16 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_retn_imm16(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_RETN_IMM16); + + if (!x86_read_one_operand(result, data, pos, len, X86_OTP_IMM16)) + { + g_object_unref(G_OBJECT(result)); + return NULL; + } return result; diff --git a/src/arch/x86/op_rol.c b/src/arch/x86/op_rol.c index a0c5738..e322e9f 100644 --- a/src/arch/x86/op_rol.c +++ b/src/arch/x86/op_rol.c @@ -38,6 +38,177 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'rol' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rol_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_ROL_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'rol' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rol_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_ROL_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'rol' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rol_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_ROL_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'rol' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rol_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_ROL_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'rol' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_rol_rm1632_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_ROL_RM1632_CL); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_CL, oprsize)) + { + /* TODO free(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 'rol' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/op_ror.c b/src/arch/x86/op_ror.c index b77a010..55d350a 100644 --- a/src/arch/x86/op_ror.c +++ b/src/arch/x86/op_ror.c @@ -38,6 +38,177 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'ror' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_ror_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_ROR_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'ror' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_ror_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_ROR_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'ror' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_ror_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_ROR_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'ror' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_ror_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_ROR_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'ror' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_ror_rm1632_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_ROR_RM1632_CL); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_CL, oprsize)) + { + /* TODO free(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 'ror' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/op_sar.c b/src/arch/x86/op_sar.c index dc2cd7d..924a5be 100644 --- a/src/arch/x86/op_sar.c +++ b/src/arch/x86/op_sar.c @@ -38,6 +38,177 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'sar' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_sar_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SAR_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'sar' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_sar_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SAR_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'sar' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_sar_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SAR_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'sar' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_sar_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_SAR_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'sar' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_sar_rm1632_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_SAR_RM1632_CL); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_CL, oprsize)) + { + /* TODO free(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 'sar' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/op_shl.c b/src/arch/x86/op_shl.c index 19d3ed3..62f4adf 100644 --- a/src/arch/x86/op_shl.c +++ b/src/arch/x86/op_shl.c @@ -38,6 +38,141 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'shl' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shl_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SHL_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'shl' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shl_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SHL_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'shl' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shl_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SHL_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'shl' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shl_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_SHL_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'shl' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/op_shr.c b/src/arch/x86/op_shr.c index ba75534..612df13 100644 --- a/src/arch/x86/op_shr.c +++ b/src/arch/x86/op_shr.c @@ -38,6 +38,177 @@ * addr = adresse virtuelle de l'instruction. * * proc = architecture ciblée par le désassemblage. * * * +* Description : Décode une instruction de type 'shr' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shr_rm8_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SHR_RM8_1); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_ONE)) + { + /* TODO free(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 'shr' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shr_rm8_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SHR_RM8_CL); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_CL)) + { + /* TODO free(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 'shr' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shr_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + + result = g_x86_instruction_new(XOP_SHR_RM8_IMM8); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(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 'shr' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shr_rm1632_1(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_SHR_RM1632_1); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_ONE, oprsize)) + { + /* TODO free(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 'shr' (16 ou 32 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_shr_rm1632_cl(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + MemoryDataSize oprsize; /* Taille des opérandes */ + + result = g_x86_instruction_new(XOP_SHR_RM1632_CL); + + oprsize = g_x86_processor_get_operand_size(proc, prefix); + + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_CL, oprsize)) + { + /* TODO free(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 'shr' (16 ou 32 bits). * * * * Retour : Instruction mise en place ou NULL. * diff --git a/src/arch/x86/opcodes.h b/src/arch/x86/opcodes.h index 19af64b..b1f9232 100644 --- a/src/arch/x86/opcodes.h +++ b/src/arch/x86/opcodes.h @@ -113,6 +113,9 @@ GArchInstruction *x86_read_instr_cmp_al_imm8(const bin_t *, off_t *, off_t, vmpa /* Décode une instruction de type 'cmp' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_cmp_e_ax_imm1632(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'cmp' (8 bits). */ +GArchInstruction *x86_read_instr_cmp_r8_rm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'cmp' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_cmp_r1632_rm1632(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); @@ -326,6 +329,9 @@ GArchInstruction *x86_read_instr_movsx_r1632_rm1632(const bin_t *, off_t *, off_ /* Décode une instruction de type 'movzx' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_movzx_r1632_rm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'movzx' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_movzx_r1632_rm16(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'nop'. */ GArchInstruction *x86_read_instr_nop(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); @@ -374,24 +380,129 @@ GArchInstruction *x86_read_instr_push_r1632(const bin_t *, off_t *, off_t, vmpa_ /* Décode une instruction de type 'push' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_push_rm1632(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'rcl' (8 bits). */ +GArchInstruction *x86_read_instr_rcl_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcl' (8 bits). */ +GArchInstruction *x86_read_instr_rcl_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcl' (8 bits). */ +GArchInstruction *x86_read_instr_rcl_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcl' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_rcl_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcl' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_rcl_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'rcl' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_rcl_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'rcr' (8 bits). */ +GArchInstruction *x86_read_instr_rcr_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcr' (8 bits). */ +GArchInstruction *x86_read_instr_rcr_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcr' (8 bits). */ +GArchInstruction *x86_read_instr_rcr_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcr' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_rcr_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rcr' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_rcr_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'rcr' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_rcr_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); -/* Décode une instruction de type 'ret'. */ -GArchInstruction *x86_read_instr_ret(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'retf'. */ +GArchInstruction *x86_read_instr_retf(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'retf' (16 bits). */ +GArchInstruction *x86_read_instr_retf_imm16(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'retn'. */ +GArchInstruction *x86_read_instr_retn(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'retn' (16 bits). */ +GArchInstruction *x86_read_instr_retn_imm16(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rol' (8 bits). */ +GArchInstruction *x86_read_instr_rol_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rol' (8 bits). */ +GArchInstruction *x86_read_instr_rol_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rol' (8 bits). */ +GArchInstruction *x86_read_instr_rol_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rol' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_rol_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'rol' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_rol_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); /* Décode une instruction de type 'rol' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_rol_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'ror' (8 bits). */ +GArchInstruction *x86_read_instr_ror_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'ror' (8 bits). */ +GArchInstruction *x86_read_instr_ror_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'ror' (8 bits). */ +GArchInstruction *x86_read_instr_ror_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'ror' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_ror_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'ror' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_ror_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'ror' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_ror_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'sal' (8 bits). */ +#define x86_read_instr_sal_rm8_1 x86_read_instr_shl_rm8_1 + +/* Décode une instruction de type 'sal' (8 bits). */ +#define x86_read_instr_sal_rm8_cl x86_read_instr_shl_rm8_cl + +/* Décode une instruction de type 'sal' (8 bits). */ +#define x86_read_instr_sal_rm8_imm8 x86_read_instr_shl_rm8_imm8 + +/* Décode une instruction de type 'sal' (16 ou 32 bits). */ +#define x86_read_instr_sal_rm1632_1 x86_read_instr_shl_rm1632_1 + +/* Décode une instruction de type 'sal' (16 ou 32 bits). */ +#define x86_read_instr_sal_rm1632_cl x86_read_instr_shl_rm1632_cl + +/* Décode une instruction de type 'sal' (16 ou 32 bits). */ +#define x86_read_instr_sal_rm1632_1 x86_read_instr_shl_rm1632_1 + +/* Décode une instruction de type 'sal' (16 ou 32 bits). */ +#define x86_read_instr_sal_rm1632_cl x86_read_instr_shl_rm1632_cl + /* Décode une instruction de type 'sal' (16 ou 32 bits). */ #define x86_read_instr_sal_rm1632_imm8 x86_read_instr_shl_rm1632_imm8 +/* Décode une instruction de type 'sar' (8 bits). */ +GArchInstruction *x86_read_instr_sar_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'sar' (8 bits). */ +GArchInstruction *x86_read_instr_sar_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'sar' (8 bits). */ +GArchInstruction *x86_read_instr_sar_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'sar' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_sar_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'sar' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_sar_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'sar' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_sar_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); @@ -458,12 +569,39 @@ GArchInstruction *x86_read_instr_setp_rm8(const bin_t *, off_t *, off_t, vmpa_t, /* Décode une instruction de type 'sets' (8 bits). */ GArchInstruction *x86_read_instr_sets_rm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'shl' (8 bits). */ +GArchInstruction *x86_read_instr_shl_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shl' (8 bits). */ +GArchInstruction *x86_read_instr_shl_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shl' (8 bits). */ +GArchInstruction *x86_read_instr_shl_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shl' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_shl_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'shl' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_shl_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); /* Décode une instruction de type 'shl' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_shl_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); +/* Décode une instruction de type 'shr' (8 bits). */ +GArchInstruction *x86_read_instr_shr_rm8_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shr' (8 bits). */ +GArchInstruction *x86_read_instr_shr_rm8_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shr' (8 bits). */ +GArchInstruction *x86_read_instr_shr_rm8_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shr' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_shr_rm1632_1(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + +/* Décode une instruction de type 'shr' (16 ou 32 bits). */ +GArchInstruction *x86_read_instr_shr_rm1632_cl(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); + /* Décode une instruction de type 'shr' (16 ou 32 bits). */ GArchInstruction *x86_read_instr_shr_rm1632_imm8(const bin_t *, off_t *, off_t, vmpa_t, X86Prefix, const GX86Processor *); diff --git a/src/arch/x86/operand.c b/src/arch/x86/operand.c index 420ceec..bf7010c 100644 --- a/src/arch/x86/operand.c +++ b/src/arch/x86/operand.c @@ -1425,6 +1425,10 @@ bool _x86_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, op = g_imm_operand_new_from_data(MDS_8_BITS, data, &op_pos[i], len, SRE_LITTLE /* FIXME */); break; + case X86_OTP_IMM16: + op = g_imm_operand_new_from_data(MDS_16_BITS, data, &op_pos[i], len, SRE_LITTLE /* FIXME */); + break; + case X86_OTP_IMM1632: if (oprsize == MDS_UNDEFINED) oprsize = va_arg(ap, MemoryDataSize); op = g_imm_operand_new_from_data(oprsize == MDS_32_BITS ? MDS_32_BITS : MDS_16_BITS, data, &op_pos[i], len, SRE_LITTLE /* FIXME */); @@ -1474,6 +1478,10 @@ bool _x86_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, op = g_x86_mod_rm_operand_new(data, &op_pos[i], len, MDS_8_BITS); break; + case X86_OTP_RM16: + op = g_x86_mod_rm_operand_new(data, &op_pos[i], len, MDS_16_BITS); + break; + case X86_OTP_RM1632: if (oprsize == MDS_UNDEFINED) oprsize = va_arg(ap, MemoryDataSize); op = g_x86_mod_rm_operand_new(data, &op_pos[i], len, oprsize); @@ -1497,6 +1505,10 @@ bool _x86_read_operands(GArchInstruction *instr, const bin_t *data, off_t *pos, op = g_x86_data_operand_new(oprsize == MDS_32_BITS ? MDS_32_BITS : MDS_16_BITS, false); break; + case X86_OTP_ONE: + op = g_imm_operand_new_from_value(MDS_8_BITS, 1); + break; + case X86_OTP_CL: op = g_x86_register_operand_new_from_index(0x01, MDS_8_BITS); break; diff --git a/src/arch/x86/operand.h b/src/arch/x86/operand.h index 93fac2d..12bd371 100644 --- a/src/arch/x86/operand.h +++ b/src/arch/x86/operand.h @@ -214,11 +214,12 @@ typedef enum _X86OperandType X86_OTP_NONE = 0, /* Aucun opérande de prévu */ X86_OTP_IMM8 = X86_OTP_IMM(1), /* Valeur immédiate sur 8 bits */ - X86_OTP_IMM1632 = X86_OTP_IMM(2), /* Valeur immédiate sur 16/32b */ - X86_OTP_MOFFS8 = X86_OTP_IMM(3), /* Décallage immédiat 8 bits */ - X86_OTP_MOFFS1632 = X86_OTP_IMM(4), /* Décallage immédiat 16/32b */ - X86_OTP_REL8 = X86_OTP_IMM(5), /* Adresse relative 8 bits */ - X86_OTP_REL1632 = X86_OTP_IMM(6), /* Adresse relative 16/32 bits */ + X86_OTP_IMM16 = X86_OTP_IMM(2), /* Valeur immédiate sur 16b */ + X86_OTP_IMM1632 = X86_OTP_IMM(3), /* Valeur immédiate sur 16/32b */ + X86_OTP_MOFFS8 = X86_OTP_IMM(4), /* Décallage immédiat 8 bits */ + X86_OTP_MOFFS1632 = X86_OTP_IMM(5), /* Décallage immédiat 16/32b */ + X86_OTP_REL8 = X86_OTP_IMM(6), /* Adresse relative 8 bits */ + X86_OTP_REL1632 = X86_OTP_IMM(7), /* Adresse relative 16/32 bits */ X86_OTP_R8 = X86_OTP_REG(1), /* Registre 8 bits */ X86_OTP_R1632 = X86_OTP_REG(2), /* Registre 16 ou 32 bits */ @@ -226,13 +227,15 @@ typedef enum _X86OperandType X86_OTP_OP_R1632 = X86_OTP_REG(4), /* Registre 16 ou 32 bits */ X86_OTP_RM8 = X86_OTP_RM(1), /* Registre 8 bits ou mémoire */ - X86_OTP_RM1632 = X86_OTP_RM(2), /* Registre 16/32b ou mémoire */ + X86_OTP_RM16 = X86_OTP_RM(2), /* Registre 16 bits ou mémoire */ + X86_OTP_RM1632 = X86_OTP_RM(3), /* Registre 16/32b ou mémoire */ X86_OTP_DST_8 = X86_OTP_DATA(1), /* Emplacement sur 8 bits */ X86_OTP_DST_1632 = X86_OTP_DATA(2), /* Emplacement sur 16/32 bits */ X86_OTP_SRC_8 = X86_OTP_DATA(3), /* Emplacement sur 8 bits */ X86_OTP_SRC_1632 = X86_OTP_DATA(4), /* Emplacement sur 16/32 bits */ + X86_OTP_ONE = 0x0ffc, /* Valeur immédiate "1" */ X86_OTP_CL = 0x0ffd, /* Registre cl */ X86_OTP_AL = 0x0ffe, /* Registre al */ X86_OTP_E_AX = 0x0fff /* Registre eax ou ax */ diff --git a/src/arch/x86/processor.c b/src/arch/x86/processor.c index 7048890..beddda6 100644 --- a/src/arch/x86/processor.c +++ b/src/arch/x86/processor.c @@ -214,6 +214,7 @@ static GArchInstruction *g_x86_processor_decode_instruction(const GX86Processor [XOP_XOR_E_AX_IMM1632] = x86_read_instr_xor_e_ax_imm1632, [XOP_CMP_RM8_R8] = x86_read_instr_cmp_rm8_r8, [XOP_CMP_RM1632_R1632] = x86_read_instr_cmp_rm1632_r1632, + [XOP_CMP_R8_RM8] = x86_read_instr_cmp_r8_rm8, [XOP_CMP_R1632_RM1632] = x86_read_instr_cmp_r1632_rm1632, [XOP_CMP_AL_IMM8] = x86_read_instr_cmp_al_imm8, [XOP_CMP_E_AX_IMM1632] = x86_read_instr_cmp_e_ax_imm1632, @@ -335,6 +336,14 @@ static GArchInstruction *g_x86_processor_decode_instruction(const GX86Processor [XOP_MOV_E_BP_IMM1632] = x86_read_instr_mov_r1632_imm1632, [XOP_MOV_E_SI_IMM1632] = x86_read_instr_mov_r1632_imm1632, [XOP_MOV_E_DI_IMM1632] = x86_read_instr_mov_r1632_imm1632, + [XOP_ROL_RM8_IMM8] = x86_read_instr_rol_rm8_imm8, + [XOP_ROR_RM8_IMM8] = x86_read_instr_ror_rm8_imm8, + [XOP_RCL_RM8_IMM8] = x86_read_instr_rcl_rm8_imm8, + [XOP_RCR_RM8_IMM8] = x86_read_instr_rcr_rm8_imm8, + [XOP_SHL_RM8_IMM8] = x86_read_instr_shl_rm8_imm8, + [XOP_SHR_RM8_IMM8] = x86_read_instr_shr_rm8_imm8, + [XOP_SAL_RM8_IMM8] = x86_read_instr_sal_rm8_imm8, + [XOP_SAR_RM8_IMM8] = x86_read_instr_sar_rm8_imm8, [XOP_ROL_RM1632_IMM8] = x86_read_instr_rol_rm1632_imm8, [XOP_ROR_RM1632_IMM8] = x86_read_instr_ror_rm1632_imm8, [XOP_RCL_RM1632_IMM8] = x86_read_instr_rcl_rm1632_imm8, @@ -343,13 +352,47 @@ static GArchInstruction *g_x86_processor_decode_instruction(const GX86Processor [XOP_SHR_RM1632_IMM8] = x86_read_instr_shr_rm1632_imm8, [XOP_SAL_RM1632_IMM8] = x86_read_instr_sal_rm1632_imm8, [XOP_SAR_RM1632_IMM8] = x86_read_instr_sar_rm1632_imm8, - [XOP_RET] = x86_read_instr_ret, + [XOP_RETN_IMM16] = x86_read_instr_retn_imm16, + [XOP_RETN] = x86_read_instr_retn, [XOP_MOV_RM8_IMM8] = x86_read_instr_mov_rm8_imm8, [XOP_MOV_RM1632_IMM1632] = x86_read_instr_mov_rm1632_imm1632, [XOP_LEAVE] = x86_read_instr_leave, + [XOP_RETF_IMM16] = x86_read_instr_retf_imm16, + [XOP_RETF] = x86_read_instr_retf, [XOP_INT_3] = x86_read_instr_int_3, [XOP_INT] = x86_read_instr_int_imm8, + [XOP_ROL_RM8_1] = x86_read_instr_rol_rm8_1, + [XOP_ROR_RM8_1] = x86_read_instr_ror_rm8_1, + [XOP_RCL_RM8_1] = x86_read_instr_rcl_rm8_1, + [XOP_RCR_RM8_1] = x86_read_instr_rcr_rm8_1, + [XOP_SHL_RM8_1] = x86_read_instr_shl_rm8_1, + [XOP_SHR_RM8_1] = x86_read_instr_shr_rm8_1, + [XOP_SAL_RM8_1] = x86_read_instr_sal_rm8_1, + [XOP_SAR_RM8_1] = x86_read_instr_sar_rm8_1, + [XOP_ROL_RM1632_1] = x86_read_instr_rol_rm1632_1, + [XOP_ROR_RM1632_1] = x86_read_instr_ror_rm1632_1, + [XOP_RCL_RM1632_1] = x86_read_instr_rcl_rm1632_1, + [XOP_RCR_RM1632_1] = x86_read_instr_rcr_rm1632_1, + [XOP_SHL_RM1632_1] = x86_read_instr_shl_rm1632_1, + [XOP_SHR_RM1632_1] = x86_read_instr_shr_rm1632_1, + [XOP_SAL_RM1632_1] = x86_read_instr_sal_rm1632_1, + [XOP_SAR_RM1632_1] = x86_read_instr_sar_rm1632_1, + [XOP_ROL_RM8_CL] = x86_read_instr_rol_rm8_cl, + [XOP_ROR_RM8_CL] = x86_read_instr_ror_rm8_cl, + [XOP_RCL_RM8_CL] = x86_read_instr_rcl_rm8_cl, + [XOP_RCR_RM8_CL] = x86_read_instr_rcr_rm8_cl, + [XOP_SHL_RM8_CL] = x86_read_instr_shl_rm8_cl, + [XOP_SHR_RM8_CL] = x86_read_instr_shr_rm8_cl, + [XOP_SAL_RM8_CL] = x86_read_instr_sal_rm8_cl, + [XOP_SAR_RM8_CL] = x86_read_instr_sar_rm8_cl, + [XOP_ROL_RM1632_CL] = x86_read_instr_rol_rm1632_cl, + [XOP_ROR_RM1632_CL] = x86_read_instr_ror_rm1632_cl, + [XOP_RCL_RM1632_CL] = x86_read_instr_rcl_rm1632_cl, + [XOP_RCR_RM1632_CL] = x86_read_instr_rcr_rm1632_cl, [XOP_SHL_RM1632_CL] = x86_read_instr_shl_rm1632_cl, + [XOP_SHR_RM1632_CL] = x86_read_instr_shr_rm1632_cl, + [XOP_SAL_RM1632_CL] = x86_read_instr_sal_rm1632_cl, + [XOP_SAR_RM1632_CL] = x86_read_instr_sar_rm1632_cl, [XOP_CALL_REL1632] = x86_read_instr_call_rel1632, [XOP_JMP_REL1632] = x86_read_instr_jmp_rel1632, [XOP_JMP_REL8] = x86_read_instr_jmp_rel8, @@ -405,6 +448,7 @@ static GArchInstruction *g_x86_processor_decode_instruction(const GX86Processor [XOP_SETNG_RM8] = x86_read_instr_setng_rm8, [XOP_SETG_RM8] = x86_read_instr_setg_rm8, [XOP_MOVZX_R1632_RM8] = x86_read_instr_movzx_r1632_rm8, + [XOP_MOVZX_R1632_RM16] = x86_read_instr_movzx_r1632_rm16, [XOP_MOVSX_R1632_RM8] = x86_read_instr_movsx_r1632_rm8, [XOP_MOVSX_R1632_RM1632] = x86_read_instr_movsx_r1632_rm1632 -- cgit v0.11.2-87-g4458