diff --git a/arch/X86/X86Disassembler.c b/arch/X86/X86Disassembler.c index c4282346..e04837fa 100644 --- a/arch/X86/X86Disassembler.c +++ b/arch/X86/X86Disassembler.c @@ -802,9 +802,7 @@ bool X86_getInstruction(csh ud, const uint8_t *code, size_t code_len, } } - if (insn.prefixPresent[0xf0] || insn.prefixPresent[0xf2] || - insn.prefixPresent[0xf3]) - instr->x86_lock_rep = true; + instr->x86_lock_rep = insn.x86_lock_rep; // save immediate size to print immediate properly instr->x86_imm_size = insn.immediateSize; diff --git a/arch/X86/X86DisassemblerDecoder.c b/arch/X86/X86DisassemblerDecoder.c index 68fbd414..72d347ef 100644 --- a/arch/X86/X86DisassemblerDecoder.c +++ b/arch/X86/X86DisassemblerDecoder.c @@ -531,6 +531,8 @@ static int readPrefixes(struct InternalInstruction* insn) dbgprintf(insn, "Found prefix 0x%hhx", byte); } + insn->x86_lock_rep = prefixGroups[0]; + insn->vectorExtensionType = TYPE_NO_VEX_XOP; if (byte == 0x62) { diff --git a/arch/X86/X86DisassemblerDecoder.h b/arch/X86/X86DisassemblerDecoder.h index 6387f896..7c44c9d5 100644 --- a/arch/X86/X86DisassemblerDecoder.h +++ b/arch/X86/X86DisassemblerDecoder.h @@ -635,6 +635,9 @@ typedef struct InternalInstruction { uint8_t firstByte; // save the first byte in stream uint8_t orgModRM; // save original modRM because we will modify modRM + // does this instruction contain LOC/REP/REPNE prefix? + bool x86_lock_rep; + /* The SIB byte, used for more complex 32- or 64-bit memory operands */ BOOL consumedSIB; uint8_t sib; diff --git a/arch/X86/X86Mapping.c b/arch/X86/X86Mapping.c index 7b59d10e..7ce3da2a 100644 --- a/arch/X86/X86Mapping.c +++ b/arch/X86/X86Mapping.c @@ -41723,8 +41723,8 @@ bool X86_lockrep(MCInst *MI, SStream *O) break; case 0xf2: #ifndef CAPSTONE_X86_REDUCE - if (MI->Opcode == X86_MULPDrr) { - MI->Opcode = X86_MULSDrr; + if (MCInst_getOpcode(MI) == X86_MULPDrr) { + MCInst_setOpcode(MI, X86_MULSDrr); #ifndef CAPSTONE_DIET SStream_concat(O, "mulsd\t"); #endif @@ -41742,8 +41742,8 @@ bool X86_lockrep(MCInst *MI, SStream *O) break; case 0xf3: #ifndef CAPSTONE_X86_REDUCE - if (MI->Opcode == X86_MULPDrr) { - MI->Opcode = X86_MULSSrr; + if (MCInst_getOpcode(MI) == X86_MULPDrr) { + MCInst_setOpcode(MI, X86_MULSSrr); #ifndef CAPSTONE_DIET SStream_concat(O, "mulss\t"); #endif