9 #include <capstone/capstone.h>
106 if (
c >=
'0' &&
c <=
'9') {
110 if (
c >=
'a' &&
c <=
'f') {
126 if (strlen(
code) == 0)
130 if (result !=
NULL) {
131 while (
code[
i] !=
'\0') {
135 result[j] = high + low;
150 printf(
"Syntax: %s [-d|-s|-u|-v] <arch+mode> <assembly-hexstring> [start-address-in-hex-format]\n",
prog);
151 printf(
"\nThe following <arch+mode> options are supported:\n");
154 printf(
" x16: 16-bit mode (X86)\n");
155 printf(
" x32: 32-bit mode (X86)\n");
156 printf(
" x64: 64-bit mode (X86)\n");
157 printf(
" x16att: 16-bit mode (X86) syntax-att\n");
158 printf(
" x32att: 32-bit mode (X86) syntax-att\n");
159 printf(
" x64att: 64-bit mode (X86) syntax-att\n");
164 printf(
" armbe: arm + big endian\n");
165 printf(
" thumb: thumb mode\n");
166 printf(
" thumbbe: thumb + big endian\n");
167 printf(
" cortexm: thumb + cortex-m extensions\n");
168 printf(
" armv8: arm v8\n");
169 printf(
" thumbv8: thumb v8\n");
173 printf(
" arm64: aarch64 mode\n");
174 printf(
" arm64be: aarch64 + big endian\n");
178 printf(
" mips: mips32 + little endian\n");
179 printf(
" mipsbe: mips32 + big endian\n");
180 printf(
" mips64: mips64 + little endian\n");
181 printf(
" mips64be: mips64 + big endian\n");
185 printf(
" ppc32: ppc32 + little endian\n");
186 printf(
" ppc32be: ppc32 + big endian\n");
187 printf(
" ppc32qpx: ppc32 + qpx + little endian\n");
188 printf(
" ppc32beqpx: ppc32 + qpx + big endian\n");
189 printf(
" ppc64: ppc64 + little endian\n");
190 printf(
" ppc64be: ppc64 + big endian\n");
191 printf(
" ppc64qpx: ppc64 + qpx + little endian\n");
192 printf(
" ppc64beqpx: ppc64 + qpx + big endian\n");
196 printf(
" sparc: sparc\n");
200 printf(
" systemz: systemz (s390x)\n");
204 printf(
" xcore: xcore\n");
208 printf(
" m68k: m68k + big endian\n");
209 printf(
" m68k40: m68k_040\n");
213 printf(
" tms320c64x: TMS320C64x\n");
217 printf(
" m6800: M6800/2\n");
218 printf(
" m6801: M6801/3\n");
219 printf(
" m6805: M6805\n");
220 printf(
" m6808: M68HC08\n");
221 printf(
" m6809: M6809\n");
222 printf(
" m6811: M68HC11\n");
223 printf(
" cpu12: M68HC12/HCS12\n");
224 printf(
" hd6301: HD6301/3\n");
225 printf(
" hd6309: HD6309\n");
226 printf(
" hcs08: HCS08\n");
230 printf(
" evm: Ethereum Virtual Machine\n");
233 printf(
"\nExtra options:\n");
234 printf(
" -d show detailed information of the instructions\n");
235 printf(
" -s decode in SKIPDATA mode\n");
236 printf(
" -u show immediates as unsigned\n");
237 printf(
" -v show version & Capstone core build info\n\n");
284 if (ins->detail->groups_count) {
288 for(j = 0; j < ins->detail->groups_count; j++) {
309 bool detail_flag =
false;
310 bool unsigned_flag =
false;
320 unsigned_flag =
true;
328 printf(
"Capstone build: ");
396 args_left = argc -
optind;
397 if (args_left < 2 || args_left > 3) {
409 if (args_left == 3) {
411 address = strtoull(
src, &temp, 16);
412 if (temp ==
src || *temp !=
'\0' || errno ==
ERANGE) {
413 printf(
"ERROR: invalid address argument, quit!\n");
424 if (strstr (
mode,
"att")) {
437 printf(
"ERROR: Invalid <arch+mode>: \"%s\", quit!\n",
mode);
443 printf(
"ERROR: Failed on cs_open(), quit!\n");
464 for (j = 0; j < insn[
i].size; j++) {
472 for (; j < 16; j++) {
490 printf(
"ERROR: invalid assembly code\n");
static mcore_handle handle
cs_arch
Architecture type.
@ CS_ARCH_ARM64
ARM-64, also called AArch64.
@ CS_ARCH_SPARC
Sparc architecture.
@ CS_ARCH_XCORE
XCore architecture.
@ CS_ARCH_M68K
68K architecture
@ CS_ARCH_X86
X86 architecture (including x86 & x86-64)
@ CS_ARCH_M680X
680X architecture
@ CS_ARCH_ARM
ARM architecture (including Thumb, Thumb-2)
@ CS_ARCH_MIPS
Mips architecture.
@ CS_ARCH_SYSZ
SystemZ architecture.
@ CS_ARCH_TMS320C64X
TMS320C64x architecture.
@ CS_ARCH_EVM
Ethereum architecture.
@ CS_ARCH_PPC
PowerPC architecture.
#define CS_SUPPORT_X86_REDUCE
@ CS_MODE_M680X_6811
M680X Motorola/Freescale/NXP 68HC11 mode.
@ CS_MODE_M680X_6805
M680X Motorola/Freescale 6805 mode.
@ CS_MODE_MCLASS
ARM's Cortex-M series.
@ CS_MODE_M680X_HCS08
M680X Freescale/NXP HCS08 mode.
@ CS_MODE_64
64-bit mode (X86, PPC)
@ CS_MODE_M68K_040
M68K 68040 mode.
@ CS_MODE_MIPS64
Mips64 ISA (Mips)
@ CS_MODE_M680X_6309
M680X Hitachi 6309 mode.
@ CS_MODE_32
32-bit mode (X86)
@ CS_MODE_V8
ARMv8 A32 encodings for ARM.
@ CS_MODE_MICRO
MicroMips mode (MIPS)
@ CS_MODE_M680X_CPU12
used on M68HC12/HCS12
@ CS_MODE_M680X_6301
M680X Hitachi 6301,6303 mode.
@ CS_MODE_MIPS32
Mips32 ISA (Mips)
@ CS_MODE_MIPS32R6
Mips32r6 ISA.
@ CS_MODE_M680X_6801
M680X Motorola 6801,6803 mode.
@ CS_MODE_BIG_ENDIAN
big-endian mode
@ CS_MODE_16
16-bit mode (X86)
@ CS_MODE_V9
SparcV9 mode (Sparc)
@ CS_MODE_THUMB
ARM's Thumb mode, including Thumb-2.
@ CS_MODE_M680X_6800
M680X Motorola 6800,6802 mode.
@ CS_MODE_M680X_6808
M680X Motorola/Freescale/NXP 68HC08 mode.
@ CS_MODE_QPX
Quad Processing eXtensions mode (PPC)
@ CS_MODE_LITTLE_ENDIAN
little-endian mode (default mode)
@ CS_MODE_M680X_6809
M680X Motorola 6809 mode.
@ CS_OPT_UNSIGNED
print immediate operands in unsigned form
@ CS_OPT_DETAIL
Break down instruction structure into details.
@ CS_OPT_SYNTAX
Assembly output syntax.
@ CS_OPT_SKIPDATA
Skip data when disassembling. Then engine is in SKIPDATA mode.
@ CS_OPT_SYNTAX_ATT
X86 ATT asm syntax (CS_OPT_SYNTAX).
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
CAPSTONE_EXPORT bool CAPSTONE_API cs_support(int query)
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 const char *CAPSTONE_API cs_group_name(csh ud, unsigned int group)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
CAPSTONE_EXPORT const char *CAPSTONE_API cs_insn_name(csh ud, unsigned int insn)
CAPSTONE_EXPORT void CAPSTONE_API cs_free(cs_insn *insn, size_t count)
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
RZ_API void Ht_() free(HtName_(Ht) *ht)
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv