diff options
Diffstat (limited to 'src/arch/x86/op_and.c')
-rw-r--r-- | src/arch/x86/op_and.c | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/src/arch/x86/op_and.c b/src/arch/x86/op_and.c index bcea898..c923441 100644 --- a/src/arch/x86/op_and.c +++ b/src/arch/x86/op_and.c @@ -32,11 +32,11 @@ /****************************************************************************** * * -* Paramètres : data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* offset = adresse virtuelle de l'instruction. * -* proc = architecture ciblée par le désassemblage. * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse virtuelle de l'instruction. * +* proc = architecture ciblée par le désassemblage. * * * * Description : Décode une instruction de type 'and' (8 bits). * * * @@ -46,17 +46,43 @@ * * ******************************************************************************/ -asm_x86_instr *x86_read_instr_and_rm8_r8(const uint8_t *data, off_t *pos, off_t len, uint64_t offset, const asm_x86_processor *proc) +GArchInstruction *x86_read_instr_and_rm8_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) { - asm_x86_instr *result; /* Instruction à retourner */ + GArchInstruction *result; /* Instruction à retourner */ - result = (asm_x86_instr *)calloc(1, sizeof(asm_x86_instr)); + result = g_x86_instruction_new(XOP_AND_RM8_IMM8); - ASM_INSTRUCTION(result)->opcode = data[(*pos)++]; + if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_IMM8)) + { + /* TODO free(result);*/ + return NULL; + } + + return result; + +} + + +/****************************************************************************** +* * +* * +* Description : Décode une instruction de type 'and' (8 bits). * +* * +* Retour : Instruction mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *x86_read_instr_and_rm8_r8(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_AND_RM8_R8); if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM8, X86_OTP_R8)) { - free(result); + /* TODO free(result);*/ return NULL; } @@ -67,11 +93,11 @@ asm_x86_instr *x86_read_instr_and_rm8_r8(const uint8_t *data, off_t *pos, off_t /****************************************************************************** * * -* Paramètres : data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* offset = adresse virtuelle de l'instruction. * -* proc = architecture ciblée par le désassemblage. * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse virtuelle de l'instruction. * +* proc = architecture ciblée par le désassemblage. * * * * Description : Décode une instruction de type 'and' (16 ou 32 bits). * * * @@ -81,20 +107,18 @@ asm_x86_instr *x86_read_instr_and_rm8_r8(const uint8_t *data, off_t *pos, off_t * * ******************************************************************************/ -asm_x86_instr *x86_read_instr_and_rm1632_with_imm8(const uint8_t *data, off_t *pos, off_t len, uint64_t offset, const asm_x86_processor *proc) +GArchInstruction *x86_read_instr_and_rm1632_imm8(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) { - asm_x86_instr *result; /* Instruction à retourner */ + GArchInstruction *result; /* Instruction à retourner */ AsmOperandSize oprsize; /* Taille des opérandes */ - result = (asm_x86_instr *)calloc(1, sizeof(asm_x86_instr)); - - oprsize = switch_x86_operand_size_if_needed(proc, data, pos); + result = g_x86_instruction_new(XOP_AND_RM1632_IMM8); - ASM_INSTRUCTION(result)->opcode = data[(*pos)++]; + oprsize = g_x86_processor_get_operand_size(proc, prefix); if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_IMM8, oprsize)) { - free(result); + /* TODO free(result);*/ return NULL; } @@ -105,11 +129,11 @@ asm_x86_instr *x86_read_instr_and_rm1632_with_imm8(const uint8_t *data, off_t *p /****************************************************************************** * * -* Paramètres : data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* offset = adresse virtuelle de l'instruction. * -* proc = architecture ciblée par le désassemblage. * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse virtuelle de l'instruction. * +* proc = architecture ciblée par le désassemblage. * * * * Description : Décode une instruction de type 'and' (16 ou 32 bits). * * * @@ -119,20 +143,18 @@ asm_x86_instr *x86_read_instr_and_rm1632_with_imm8(const uint8_t *data, off_t *p * * ******************************************************************************/ -asm_x86_instr *x86_read_instr_and_rm1632_imm1632(const uint8_t *data, off_t *pos, off_t len, uint64_t offset, const asm_x86_processor *proc) +GArchInstruction *x86_read_instr_and_rm1632_imm1632(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, X86Prefix prefix, const GX86Processor *proc) { - asm_x86_instr *result; /* Instruction à retourner */ + GArchInstruction *result; /* Instruction à retourner */ AsmOperandSize oprsize; /* Taille des opérandes */ - result = (asm_x86_instr *)calloc(1, sizeof(asm_x86_instr)); - - oprsize = switch_x86_operand_size_if_needed(proc, data, pos); + result = g_x86_instruction_new(XOP_AND_RM1632_IMM8); - ASM_INSTRUCTION(result)->opcode = data[(*pos)++]; + oprsize = g_x86_processor_get_operand_size(proc, prefix); if (!x86_read_two_operands(result, data, pos, len, X86_OTP_RM1632, X86_OTP_IMM1632, oprsize)) { - free(result); + /* TODO free(result);*/ return NULL; } |