Skip to content

Commit 743a2a4

Browse files
jj16791FinnWilkinson
authored andcommitted
Added support for exposing opcode in disassembled object
1 parent b4fde98 commit 743a2a4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

cs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64
11901190

11911191
handle->printer(&mci, &ss, handle->printer_info);
11921192
fill_insn(handle, insn_cache, ss.buffer, &mci, handle->post_printer, buffer);
1193+
insn_cache->opcode = mci.Opcode;
11931194

11941195
// adjust for pseudo opcode (X86)
11951196
if (handle->arch == CS_ARCH_X86)
@@ -1396,6 +1397,7 @@ bool CAPSTONE_API cs_disasm_iter(csh ud, const uint8_t **code, size_t *size,
13961397
handle->printer(&mci, &ss, handle->printer_info);
13971398

13981399
fill_insn(handle, insn, ss.buffer, &mci, handle->post_printer, *code);
1400+
insn->opcode = mci.Opcode;
13991401

14001402
// adjust for pseudo opcode (X86)
14011403
if (handle->arch == CS_ARCH_X86)

include/capstone/capstone.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ typedef struct cs_insn {
473473
/// NOTE 2: when in Skipdata mode, or when detail mode is OFF, even if this pointer
474474
/// is not NULL, its content is still irrelevant.
475475
cs_detail *detail;
476+
477+
/// The internal opcode of this instruction
478+
unsigned int opcode;
476479
} cs_insn;
477480

478481

0 commit comments

Comments
 (0)