7 #include <capstone/platform.h>
8 #include <capstone/capstone.h>
36 cs_regs regs_read, regs_write;
37 unsigned char regs_read_count, regs_write_count;
41 if (ins->detail ==
NULL)
44 arm64 = &(ins->detail->arm64);
48 for (
i = 0;
i <
arm64->op_count;
i++) {
60 #if defined(_KERNEL_MODE)
62 printf(
"\t\toperands[%u].type: FP = <float_point_unsupported>\n",
i);
64 printf(
"\t\toperands[%u].type: FP = %f\n",
i,
op->fp);
68 printf(
"\t\toperands[%u].type: MEM\n",
i);
73 if (
op->mem.disp != 0)
74 printf(
"\t\t\toperands[%u].mem.disp: 0x%x\n",
i,
op->mem.disp);
78 printf(
"\t\toperands[%u].type: C-IMM = %u\n",
i, (
int)
op->imm);
81 printf(
"\t\toperands[%u].type: REG_MRS = 0x%x\n",
i,
op->reg);
84 printf(
"\t\toperands[%u].type: REG_MSR = 0x%x\n",
i,
op->reg);
87 printf(
"\t\toperands[%u].type: PSTATE = 0x%x\n",
i,
op->pstate);
90 printf(
"\t\toperands[%u].type: SYS = 0x%x\n",
i,
op->sys);
93 printf(
"\t\toperands[%u].type: PREFETCH = 0x%x\n",
i,
op->prefetch);
96 printf(
"\t\toperands[%u].type: BARRIER = 0x%x\n",
i,
op->barrier);
105 printf(
"\t\toperands[%u].access: READ\n",
i);
108 printf(
"\t\toperands[%u].access: WRITE\n",
i);
111 printf(
"\t\toperands[%u].access: READ | WRITE\n",
i);
117 printf(
"\t\t\tShift: type = %u, value = %u\n",
118 op->shift.type,
op->shift.value);
124 printf(
"\t\t\tVector Arrangement Specifier: 0x%x\n",
op->vas);
127 printf(
"\t\t\tVector Element Size Specifier: %u\n",
op->vess);
129 if (
op->vector_index != -1)
130 printf(
"\t\t\tVector Index: %u\n",
op->vector_index);
133 if (
arm64->update_flags)
134 printf(
"\tUpdate-flags: True\n");
136 if (
arm64->writeback)
137 printf(
"\tWrite-back: True\n");
144 regs_read, ®s_read_count,
145 regs_write, ®s_write_count)) {
146 if (regs_read_count) {
147 printf(
"\tRegisters read:");
148 for(
i = 0;
i < regs_read_count;
i++) {
154 if (regs_write_count) {
155 printf(
"\tRegisters modified:");
156 for(
i = 0;
i < regs_write_count;
i++) {
168 #define ARM64_CODE "\x09\x00\x38\xd5\xbf\x40\x00\xd5\x0c\x05\x13\xd5\x20\x50\x02\x0e\x20\xe4\x3d\x0f\x00\x18\xa0\x5f\xa2\x00\xae\x9e\x9f\x37\x03\xd5\xbf\x33\x03\xd5\xdf\x3f\x03\xd5\x21\x7c\x02\x9b\x21\x7c\x00\x53\x00\x40\x21\x4b\xe1\x0b\x40\xb9\x20\x04\x81\xda\x20\x08\x02\x8b\x10\x5b\xe8\x3c"
188 printf(
"Failed on cs_open() with error returned: %u\n",
err);
198 printf(
"****************\n");
203 for (j = 0; j <
count; j++) {
212 printf(
"****************\n");
215 printf(
"ERROR: Failed to disasm given code!\n");
@ ARM64_OP_FP
= CS_OP_FP (Floating-Point operand).
@ ARM64_OP_PSTATE
PState operand.
@ ARM64_OP_BARRIER
Memory barrier operand (ISB/DMB/DSB instructions).
@ ARM64_OP_REG
= CS_OP_REG (Register operand).
@ ARM64_OP_PREFETCH
Prefetch operand (PRFM).
@ ARM64_OP_MEM
= CS_OP_MEM (Memory operand).
@ ARM64_OP_SYS
SYS operand for IC/DC/AT/TLBI instructions.
@ ARM64_OP_REG_MRS
MRS register operand.
@ ARM64_OP_CIMM
C-Immediate.
@ ARM64_OP_IMM
= CS_OP_IMM (Immediate operand).
@ ARM64_OP_REG_MSR
MSR register operand.
cs_arch
Architecture type.
@ CS_ARCH_ARM64
ARM-64, also called AArch64.
@ CS_OPT_DETAIL
Break down instruction structure into details.
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
@ CS_AC_READ
Operand read from memory or register.
@ CS_AC_WRITE
Operand write to 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 size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn **insn)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
CAPSTONE_EXPORT void CAPSTONE_API cs_free(cs_insn *insn, size_t count)
CAPSTONE_EXPORT const char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close(csh *handle)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
struct platform platforms[]
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause access
static void print_string_hex(const char *comment, unsigned char *str, size_t len)
static void print_insn_detail(cs_insn *ins)