Go to the documentation of this file.
186 cs_regs regs_read, regs_write;
187 uint8_t regs_read_count, regs_write_count;
190 if (ins->detail == NULL)
193 x86 = &(ins->detail->x86);
201 printf(
"\taddr_size: %u\n",
x86->addr_size);
203 if (
x86->encoding.modrm_offset != 0) {
204 printf(
"\tmodrm_offset: 0x%x\n",
x86->encoding.modrm_offset);
207 printf(
"\tdisp: 0x%" PRIx64
"\n",
x86->disp);
208 if (
x86->encoding.disp_offset != 0) {
209 printf(
"\tdisp_offset: 0x%x\n",
x86->encoding.disp_offset);
212 if (
x86->encoding.disp_size != 0) {
213 printf(
"\tdisp_size: 0x%x\n",
x86->encoding.disp_size);
223 if (
x86->sib_scale != 0)
224 printf(
"\t\tsib_scale: %d\n",
x86->sib_scale);
259 if (
x86->encoding.imm_offset != 0) {
260 printf(
"\timm_offset: 0x%x\n",
x86->encoding.imm_offset);
263 if (
x86->encoding.imm_size != 0) {
264 printf(
"\timm_size: 0x%x\n",
x86->encoding.imm_size);
270 printf(
"\top_count: %u\n",
x86->op_count);
273 for (
i = 0;
i <
x86->op_count;
i++) {
276 switch((
int)
op->type) {
281 printf(
"\t\toperands[%u].type: IMM = 0x%" PRIx64
"\n",
i,
op->imm);
284 printf(
"\t\toperands[%u].type: MEM\n",
i);
291 if (
op->mem.scale != 1)
292 printf(
"\t\t\toperands[%u].mem.scale: %u\n",
i,
op->mem.scale);
293 if (
op->mem.disp != 0)
294 printf(
"\t\t\toperands[%u].mem.disp: 0x%" PRIx64
"\n",
i,
op->mem.disp);
302 printf(
"\t\toperands[%u].avx_bcast: %u\n",
i,
op->avx_bcast);
305 if (
op->avx_zero_opmask !=
false)
306 printf(
"\t\toperands[%u].avx_zero_opmask: TRUE\n",
i);
308 printf(
"\t\toperands[%u].size: %u\n",
i,
op->size);
314 printf(
"\t\toperands[%u].access: READ\n",
i);
317 printf(
"\t\toperands[%u].access: WRITE\n",
i);
320 printf(
"\t\toperands[%u].access: READ | WRITE\n",
i);
327 regs_read, ®s_read_count,
328 regs_write, ®s_write_count)) {
329 if (regs_read_count) {
330 printf(
"\tRegisters read:");
331 for(
i = 0;
i < regs_read_count;
i++) {
337 if (regs_write_count) {
338 printf(
"\tRegisters modified:");
339 for(
i = 0;
i < regs_write_count;
i++) {
346 if (
x86->eflags ||
x86->fpu_flags) {
347 for(
i = 0;
i < ins->detail->groups_count;
i++) {
350 for(
i = 0;
i <= 63;
i++)
359 if (
i == ins->detail->groups_count) {
361 for(
i = 0;
i <= 63;
i++)
382 #define X86_CODE64 "\x55\x48\x8b\x05\xb8\x13\x00\x00\xe9\xea\xbe\xad\xde\xff\x25\x23\x01\x00\x00\xe8\xdf\xbe\xad\xde\x74\xff"
385 #define X86_CODE16 "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00\x8d\x87\x89\x67\x00\x00\xb4\xc6\x66\xe9\xb8\x00\x00\x00\x67\xff\xa0\x23\x01\x00\x00\x66\xe8\xcb\x00\x00\x00\x74\xfc"
386 #define X86_CODE32 "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00\x8d\x87\x89\x67\x00\x00\xb4\xc6\xe9\xea\xbe\xad\xde\xff\xa0\x23\x01\x00\x00\xe8\xdf\xbe\xad\xde\x74\xff"
407 "X86 16bit (Intel syntax)"
414 "X86 32 (AT&T syntax)",
423 "X86 32 (Intel syntax)"
430 "X86 64 (Intel syntax)"
442 printf(
"Failed on cs_open() with error returned: %u\n",
err);
455 printf(
"****************\n");
460 for (j = 0; j <
count; j++) {
461 printf(
"0x%" PRIx64
":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
464 printf(
"0x%" PRIx64
":\n", insn[j-1].address + insn[j-1].
size);
469 printf(
"****************\n");
472 printf(
"ERROR: Failed to disasm given code!\n");
#define X86_EFLAGS_RESET_DF
#define X86_EFLAGS_UNDEFINED_AF
#define X86_EFLAGS_SET_IF
#define X86_EFLAGS_PRIOR_ZF
CAPSTONE_EXPORT int CAPSTONE_API cs_op_index(csh ud, const cs_insn *insn, unsigned int op_type, unsigned int post)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close(csh *handle)
#define X86_EFLAGS_UNDEFINED_PF
#define X86_FPU_FLAGS_SET_C3
cs_opt_type
Runtime option for the disassembled engine.
@ CS_OPT_SYNTAX
Assembly output syntax.
@ CS_MODE_32
32-bit mode (X86)
#define X86_FPU_FLAGS_MODIFY_C1
CAPSTONE_EXPORT size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn **insn)
@ X86_OP_IMM
= CS_OP_IMM (Immediate operand).
#define X86_EFLAGS_UNDEFINED_OF
#define X86_EFLAGS_MODIFY_PF
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
#define X86_EFLAGS_RESET_AF
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
#define X86_EFLAGS_MODIFY_ZF
#define X86_EFLAGS_PRIOR_AF
static const char * get_eflag_name(uint64_t flag)
cs_arch
Architecture type.
#define X86_FPU_FLAGS_TEST_C0
#define X86_EFLAGS_PRIOR_IF
#define X86_FPU_FLAGS_SET_C0
#define X86_FPU_FLAGS_SET_C2
@ X86_XOP_CC_INVALID
Uninitialized.
@ CS_OPT_DETAIL
Break down instruction structure into details.
static void print_insn_detail(csh ud, cs_mode mode, cs_insn *ins)
@ CS_MODE_16
16-bit mode (X86)
@ CS_AC_READ
Operand read from memory or register.
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_regs_access(csh ud, const cs_insn *insn, cs_regs regs_read, uint8_t *regs_read_count, cs_regs regs_write, uint8_t *regs_write_count)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
static const char * get_fpu_flag_name(uint64_t flag)
#define X86_EFLAGS_RESET_OF
#define X86_EFLAGS_PRIOR_NT
#define X86_EFLAGS_RESET_CF
#define X86_EFLAGS_PRIOR_OF
#define X86_EFLAGS_TEST_DF
CAPSTONE_EXPORT int CAPSTONE_API cs_op_count(csh ud, const cs_insn *insn, unsigned int op_type)
#define X86_EFLAGS_PRIOR_PF
#define X86_FPU_FLAGS_TEST_C2
#define X86_EFLAGS_TEST_OF
#define X86_EFLAGS_PRIOR_TF
#define X86_FPU_FLAGS_UNDEFINED_C0
#define X86_EFLAGS_TEST_NT
cs_opt_value
Runtime option value (associated with option type above)
#define X86_EFLAGS_MODIFY_CF
#define X86_EFLAGS_RESET_NT
const CAPSTONE_EXPORT char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
@ CS_ARCH_X86
X86 architecture (including x86 & x86-64)
unsigned __int64 uint64_t
#define X86_FPU_FLAGS_UNDEFINED_C1
#define X86_FPU_FLAGS_MODIFY_C3
#define X86_EFLAGS_PRIOR_CF
#define X86_EFLAGS_SET_CF
@ CS_OPT_SYNTAX_ATT
X86 ATT asm syntax (CS_OPT_SYNTAX).
#define X86_EFLAGS_PRIOR_DF
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
#define X86_EFLAGS_PRIOR_SF
@ X86_OP_MEM
= CS_OP_MEM (Memory operand).
@ X86_SSE_CC_INVALID
Uninitialized.
#define X86_EFLAGS_MODIFY_NT
#define X86_EFLAGS_TEST_PF
#define X86_EFLAGS_RESET_TF
#define X86_EFLAGS_UNDEFINED_SF
#define X86_EFLAGS_TEST_SF
#define X86_EFLAGS_MODIFY_OF
#define X86_FPU_FLAGS_MODIFY_C2
#define X86_EFLAGS_MODIFY_RF
#define X86_EFLAGS_MODIFY_SF
#define X86_EFLAGS_MODIFY_TF
#define X86_EFLAGS_MODIFY_AF
#define X86_EFLAGS_RESET_IF
@ CS_MODE_64
64-bit mode (X86, PPC)
#define X86_FPU_FLAGS_MODIFY_C0
#define X86_EFLAGS_TEST_ZF
#define X86_EFLAGS_MODIFY_DF
#define X86_EFLAGS_UNDEFINED_ZF
#define X86_FPU_FLAGS_RESET_C1
#define X86_FPU_FLAGS_SET_C1
#define X86_FPU_FLAGS_RESET_C3
static void print_string_hex(const char *comment, unsigned char *str, size_t len)
#define X86_EFLAGS_UNDEFINED_CF
#define X86_FPU_FLAGS_UNDEFINED_C3
#define X86_EFLAGS_MODIFY_IF
#define X86_FPU_FLAGS_RESET_C2
CAPSTONE_EXPORT void CAPSTONE_API cs_free(cs_insn *insn, size_t count)
#define X86_FPU_FLAGS_TEST_C1
#define X86_EFLAGS_TEST_CF
#define X86_FPU_FLAGS_UNDEFINED_C2
#define X86_EFLAGS_RESET_SF
@ X86_AVX_BCAST_INVALID
Uninitialized.
#define X86_FPU_FLAGS_TEST_C3
struct platform platforms[]
@ X86_AVX_CC_INVALID
Uninitialized.
#define X86_EFLAGS_RESET_PF
@ X86_AVX_RM_INVALID
Uninitialized.
#define X86_EFLAGS_SET_DF
@ X86_OP_REG
= CS_OP_REG (Register operand).
@ CS_AC_WRITE
Operand write to memory or register.
#define X86_FPU_FLAGS_RESET_C0
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:32