diff --git a/cs.c b/cs.c index 2c02d9da8c..295d753787 100644 --- a/cs.c +++ b/cs.c @@ -1240,6 +1240,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64 handle->printer(&mci, &ss, handle->printer_info); fill_insn(handle, insn_cache, ss.buffer, &mci, handle->post_printer, buffer); + insn_cache->opcode = mci.Opcode; // adjust for pseudo opcode (X86) if (handle->arch == CS_ARCH_X86 && insn_cache->id != X86_INS_VCMP) @@ -1446,6 +1447,7 @@ bool CAPSTONE_API cs_disasm_iter(csh ud, const uint8_t **code, size_t *size, handle->printer(&mci, &ss, handle->printer_info); fill_insn(handle, insn, ss.buffer, &mci, handle->post_printer, *code); + insn->opcode = mci.Opcode; // adjust for pseudo opcode (X86) if (handle->arch == CS_ARCH_X86) diff --git a/include/capstone/capstone.h b/include/capstone/capstone.h index f40774d039..eccf0e8e0e 100644 --- a/include/capstone/capstone.h +++ b/include/capstone/capstone.h @@ -499,6 +499,9 @@ typedef struct cs_insn { /// NOTE 2: when in Skipdata mode, or when detail mode is OFF, even if this pointer /// is not NULL, its content is still irrelevant. cs_detail *detail; + + /// The internal opcode of this instruction + unsigned int opcode; } cs_insn;