• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:platforms

1 # Capstone-Engine API Documentation
4 | ------- | ----- |
8 [Capstone Engine](https://github.com/capstone-engine/capstone)是一个支持多种硬件架构的二进制反汇编引擎。
13 Capstone官网: http://www.capstone-engine.org
17 源码: https://github.com/capstone-engine/capstone.git
23 . <- 主要引擎core engine + README + 编译文档COMPILE.TXT 等
24 ├── arch <- 各语言反编译支持的代码实现
25 │   ├── AArch64 <- ARM64 (aka ARMv8) 引擎
26 │   ├── ARM <- ARM 引擎
27 │   ├── EVM <- Ethereum 引擎
28 │   ├── M680X <- M680X 引擎
29 │   ├── M68K <- M68K 引擎
30 | ├── MOS65XX <- MOS65XX 引擎
31 │   ├── Mips <- Mips 引擎
32 │   ├── PowerPC <- PowerPC 引擎
33 │   ├── Sparc <- Sparc 引擎
34 │   ├── SystemZ <- SystemZ 引擎
35 │   ├── TMS320C64x <- TMS320C64x 引擎
36 │   ├── X86 <- X86 引擎
37 │   └── XCore <- XCore 引擎
38 ├── bindings <- 绑定
39 │   ├── java <- Java 绑定 + 测试代码
40 │   ├── ocaml <- Ocaml 绑定 + 测试代码
41 │   ├── powershell <- powershell 绑定 + 测试代码
42 │   ├── python <- python 绑定 + 测试代码
43 │   └── vb6 <- vb6 绑定 + 测试代码
44 ├── contrib <- 社区代码
45 ├── cstool <- Cstool 检测工具源码
46 ├── docs <- 文档,主要是capstone的实现思路
47 ├── include <- C头文件
48 ├── msvc <- Microsoft Visual Studio 支持(Windows)
49 ├── packages <- Linux/OSX/BSD包
50 ├── suite <- 项目开发所需工具
51 ├── tests <- C语言测试用例
52 ├── windows <- Windows 支持(Windows内核驱动编译)
53 ├── windowsce <- Windows CE 支持
54 └── xcode <- Xcode 支持 (MacOSX 编译)
67 可以看到支持的所有语言都在这里了,如果都需要的话,直接编译就好了,只需要其中几种,则右键解决方案->属性->配置属性 如下
76 Win32: https://github.com/capstone-engine/capstone/releases/download/4.0.2/capstone-4.0.2-win32.zip
78 Win64: https://github.com/capstone-engine/capstone/releases/download/4.0.2/capstone-4.0.2-win64.zip
117 return -1;
120 count = cs_disasm(handle, (unsigned char*)CODE, sizeof(CODE) - 1, 0x1000, 0, &insn);
167 CS_ARCH_ARM = 0, ///< ARM 架构 (包括 Thumb, Thumb-2)
168 CS_ARCH_ARM64, ///< ARM-64, 也叫 AArch64
170 CS_ARCH_X86, ///< X86 架构 (包括 x86 & x86-64)
180 CS_ARCH_ALL = 0xFFFF, // All 架构 - for cs_support()
197 CS_MODE_LITTLE_ENDIAN = 0, ///< little-endian 模式 (default 模式)
198 CS_MODE_ARM = 0, ///< 32-bit ARM
199 CS_MODE_16 = 1 << 1, ///< 16-bit 模式 (X86)
200 CS_MODE_32 = 1 << 2, ///< 32-bit 模式 (X86)
201 CS_MODE_64 = 1 << 3, ///< 64-bit 模式 (X86, PPC)
202 CS_MODE_THUMB = 1 << 4, ///< ARM's Thumb 模式, 包括 Thumb-2
203 CS_MODE_MCLASS = 1 << 5, ///< ARM's Cortex-M 系列
212 CS_MODE_BOOKE = 1 << 6, ///< Book-E 模式 (PPC)
219 CS_MODE_BIG_ENDIAN = 1 << 31, ///< big-endian 模式
241 CS_MODE_MOS65XX_65816 = 1 << 4, ///< MOS65XXX WDC 65816, 8-bit m/x
242 CS_MODE_MOS65XX_65816_LONG_M = (1 << 5), ///< MOS65XXX WDC 65816, 16-bit m, 8-bit x
243 CS_MODE_MOS65XX_65816_LONG_X = (1 << 6), ///< MOS65XXX WDC 65816, 8-bit m, 16-bit x
325 CS_OPT_OFF = 0, ///< 关闭一个选项 - 默认为CS_OPT_DETAIL, CS_OPT_SKIPDATA, CS_OPT_UNSIGNED.
328 CS_OPT_SYNTAX_INTEL, ///< X86 Intel asm语法 - 默认开启 X86 (CS_OPT_SYNTAX).
471 cs_x86 x86; ///< X86 架构, 包括 16-bit, 32-bit & 64-bit 模式
732 cs_winkernel_malloc定义于\capstone-4.0.1\windows\winkernel_mm.c,
756 block->size = size;
758 return block->data;
830 current_size = CONTAINING_RECORD(ptr, CS_WINKERNEL_MEMBLOCK, data)->size;
894 // _vsnprintf()在字符串被截断时返回-1,在整个字符串被存储但“buffer”末尾没有“\0”时返回“count”。在这两种情况下,都需要手动添加空终止符。
895 if (result == -1 || (size_t)result == count) {
896 buffer[count - 1] = '\0';
899 if (result == -1) {
900 // 在返回-1时,函数必须获取并返回一些本来要写入的字符。因此,通过重试使用temp buffer进行相同的转换,这个缓冲区就可能足够大来完成格式化,并且获得很多本应写入的字符。
907 NT_ASSERT(result != -1);
981 struct platform platforms[2] = { //以默认描述符和自定义描述符两种方式建立一个数组
986 sizeof(X86_CODE32) - 1,
987 "X86 32 (Intel syntax) - Skip data",
993 sizeof(X86_CODE32) - 1,
994 "X86 32 (Intel syntax) - Skip data with custom mnemonic",
1010 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
1012 printf("Platform: %s\n", platforms[i].comment);
1013 err = cs_open(platforms[i].arch, platforms[i].mode, &handle); //错误检查
1019 if (platforms[i].opt_type)
1020 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
1024 cs_option(handle, platforms[i].opt_skipdata, platforms[i].skipdata);
1026 count = cs_disasm(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
1030 print_string_hex(platforms[i].code, platforms[i].size);
1039 printf("0x%" PRIx64 ":\n", insn[j - 1].address + insn[j - 1].size);
1046 printf("Platform: %s\n", platforms[i].comment);
1047 print_string_hex(platforms[i].code, platforms[i].size);
1112 ud->errnum = CS_ERR_OK;
1113 ud->arch = arch;
1114 ud->mode = mode;
1116 ud->detail = CS_OPT_OFF;
1119 ud->skipdata_setup.mnemonic = SKIPDATA_MNEM;
1121 err = cs_arch_init[ud->arch](ud);
1203 if (ud->printer_info)
1204 cs_mem_free(ud->printer_info);
1207 tmp = ud->mnem_list;
1209 next = tmp->next;
1214 cs_mem_free(ud->insn_cache);
1260 cs_mem_malloc = mem->malloc;
1261 cs_mem_calloc = mem->calloc;
1262 cs_mem_realloc = mem->realloc;
1263 cs_mem_free = mem->free;
1264 cs_vsnprintf = mem->vsnprintf;
1278 handle->imm_unsigned = (cs_opt_value)value;
1282 handle->detail = (cs_opt_value)value;
1286 handle->skipdata = (value == CS_OPT_ON);
1287 if (handle->skipdata) {
1288 if (handle->skipdata_size == 0) {
1289 handle->skipdata_size = skipdata_size(handle);
1296 handle->skipdata_setup = *((cs_opt_skipdata *)value);
1301 if (opt->id) {
1302 if (opt->mnemonic) {
1307 tmp = handle->mnem_list;
1309 if (tmp->insn.id == opt->id) {
1311 (void)strncpy(tmp->insn.mnemonic, opt->mnemonic, sizeof(tmp->insn.mnemonic) - 1);
1312 tmp->insn.mnemonic[sizeof(tmp->insn.mnemonic) - 1] = '\0';
1315 tmp = tmp->next;
1321 tmp->insn.id = opt->id;
1322 (void)strncpy(tmp->insn.mnemonic, opt->mnemonic, sizeof(tmp->insn.mnemonic) - 1);
1323 tmp->insn.mnemonic[sizeof(tmp->insn.mnemonic) - 1] = '\0';
1325 tmp->next = handle->mnem_list;
1326 handle->mnem_list = tmp;
1332 tmp = handle->mnem_list;
1335 if (tmp->insn.id == opt->id) {
1338 handle->mnem_list = tmp->next;
1340 prev->next = tmp->next;
1346 tmp = tmp->next;
1354 if (value & cs_arch_disallowed_mode_mask[handle->arch]) {
1360 return cs_arch_option[handle->arch](handle, type, value);
1387 return -1;
1390 count = cs_disasm(handle, (unsigned char*)CODE, sizeof(CODE) - 1, 0x1000, 0, &insn);
1450 return -1;
1537 return -1;
1604 // handle->errnum = CS_ERR_HANDLE;
1608 handle->errnum = CS_ERR_OK;
1611 if (handle->arch == CS_ARCH_ARM)
1612 handle->ITBlock.size = 0;
1628 handle->errnum = CS_ERR_MEM;
1640 if (handle->detail) {
1642 insn_cache->detail = cs_mem_malloc(sizeof(cs_detail));
1644 insn_cache->detail = NULL;
1647 // 为non-detailed模式保存所有信息
1649 mci.flat_insn->address = offset;
1652 mci.flat_insn->mnemonic[0] = '\0';
1653 mci.flat_insn->op_str[0] = '\0';
1656 r = handle->disasm(ud, buffer, size, &mci, &insn_size, offset, handle->getinsn_info);
1661 mci.flat_insn->size = insn_size;
1664 handle->insn_id(handle, insn_cache, mci.Opcode);
1666 handle->printer(&mci, &ss, handle->printer_info);
1667 fill_insn(handle, insn_cache, ss.buffer, &mci, handle->post_printer, buffer);
1670 if (handle->arch == CS_ARCH_X86)
1671 insn_cache->id += mci.popcode_adjust;
1678 if (handle->detail) {
1679 cs_mem_free(insn_cache->detail);
1682 if (!handle->skipdata || handle->skipdata_size > size)
1685 if (handle->skipdata_setup.callback) {
1686 skipdata_bytes = handle->skipdata_setup.callback(buffer_org, size_org,
1687 (size_t)(offset - offset_org), handle->skipdata_setup.user_data);
1694 skipdata_bytes = handle->skipdata_size;
1696 insn_cache->id = 0;
1697 insn_cache->address = offset;
1698 insn_cache->size = (uint16_t)skipdata_bytes;
1699 memcpy(insn_cache->bytes, buffer, skipdata_bytes);
1701 insn_cache->mnemonic[0] = '\0';
1702 insn_cache->op_str[0] = '\0';
1704 strncpy(insn_cache->mnemonic, handle->skipdata_setup.mnemonic,
1705 sizeof(insn_cache->mnemonic) - 1);
1706 skipdata_opstr(insn_cache->op_str, buffer, skipdata_bytes);
1708 insn_cache->detail = NULL;
1726 if (handle->detail) {
1729 cs_mem_free(insn_cache->detail);
1734 handle->errnum = CS_ERR_MEM;
1748 size -= next_offset;
1758 tmp = cs_mem_realloc(total, total_size - (cache_size - f) * sizeof(*insn_cache));
1761 if (handle->detail) {
1764 cs_mem_free(insn_cache->detail);
1770 handle->errnum = CS_ERR_MEM;
1807 return -1;
1810 …count = cs_disasm(handle, (unsigned char*)CODE, sizeof(CODE) - 1, 0x1000, 0, &insn); //所有指令,基址0x…
1870 …count = cs_disasm(handle, (unsigned char*)CODE, sizeof(CODE) - 1, 0x1000, 0, &insn); //计…
1906 handle->errnum = CS_ERR_MEM;
1909 if (handle->detail) {
1911 insn->detail = cs_mem_malloc(sizeof(cs_detail));
1912 if (insn->detail == NULL) { // insufficient memory
1914 handle->errnum = CS_ERR_MEM;
1918 insn->detail = NULL;
1974 handle->errnum = CS_ERR_OK;
1983 mci.flat_insn->address = *address;
1985 mci.flat_insn->mnemonic[0] = '\0';
1986 mci.flat_insn->op_str[0] = '\0';
1989 r = handle->disasm(ud, *code, *size, &mci, &insn_size, *address, handle->getinsn_info);
1994 mci.flat_insn->size = insn_size;
1997 handle->insn_id(handle, insn, mci.Opcode);
1999 handle->printer(&mci, &ss, handle->printer_info);
2001 fill_insn(handle, insn, ss.buffer, &mci, handle->post_printer, *code);
2004 if (handle->arch == CS_ARCH_X86)
2005 insn->id += mci.popcode_adjust;
2008 *size -= insn_size;
2014 if (!handle->skipdata || handle->skipdata_size > *size)
2017 if (handle->skipdata_setup.callback) {
2018 skipdata_bytes = handle->skipdata_setup.callback(*code, *size,
2019 0, handle->skipdata_setup.user_data);
2027 skipdata_bytes = handle->skipdata_size;
2030 insn->id = 0; // 此“数据”指令的ID无效
2031 insn->address = *address;
2032 insn->size = (uint16_t)skipdata_bytes;
2034 insn->mnemonic[0] = '\0';
2035 insn->op_str[0] = '\0';
2037 memcpy(insn->bytes, *code, skipdata_bytes);
2038 strncpy(insn->mnemonic, handle->skipdata_setup.mnemonic,
2039 sizeof(insn->mnemonic) - 1);
2040 skipdata_opstr(insn->op_str, *code, skipdata_bytes);
2044 *size -= skipdata_bytes;
2093 struct platform platforms[4] = { //架构及模式
2098 sizeof(X86_CODE32) - 1,
2105 sizeof(X86_CODE32) - 1,
2114 sizeof(X86_CODE32) - 1,
2121 sizeof(X86_CODE64) - 1,
2134 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
2136 printf("Platform: %s\n", platforms[i].comment);
2137 err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
2143 if (platforms[i].opt_type)
2144 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
2151 print_string_hex(platforms[i].code, platforms[i].size); //原机器码
2155 code = platforms[i].code;
2156 size = platforms[i].size;
2160 printf("0x%" PRIx64 ":\t%s\t\t%s // insn-ID: %u, insn-mnem: %s\n",
2161 insn->address, insn->mnemonic, insn->op_str,
2162 insn->id, cs_insn_name(handle, insn->id));
2165 detail = insn->detail;
2167 if (detail->regs_read_count > 0) {
2169 for (n = 0; n < detail->regs_read_count; n++) {
2170 printf("%s ", cs_reg_name(handle, detail->regs_read[n]));
2176 if (detail->regs_write_count > 0) {
2178 for (n = 0; n < detail->regs_write_count; n++) {
2179 printf("%s ", cs_reg_name(handle, detail->regs_write[n]));
2185 if (detail->groups_count > 0) {
2187 for (n = 0; n < detail->groups_count; n++) {
2188 printf("%s ", cs_group_name(handle, detail->groups[n]));
2240 if (!handle || handle->reg_name == NULL) {
2244 return handle->reg_name(ud, reg);
2270 return -1;
2310 if (!handle || handle->insn_name == NULL) {
2314 return handle->insn_name(ud, insn);
2358 struct platform platforms[] = {
2363 sizeof(X86_CODE64) - 1,
2377 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
2379 printf("Platform: %s\n", platforms[i].comment);
2380 err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
2386 if (platforms[i].opt_type)
2387 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
2393 print_string_hex(platforms[i].code, platforms[i].size);
2397 code = platforms[i].code;
2398 size = platforms[i].size;
2403 insn->address, insn->mnemonic, insn->op_str);
2404 printf(" instruction: %s", cs_insn_name(handle, insn->id)); //输出该行的操作指令
2455 在“diet”模式下,此API没有用,因为引擎不更新insn->groups数组
2475 if (!handle->detail) {
2476 handle->errnum = CS_ERR_DETAIL;
2480 if (!insn->id) {
2481 handle->errnum = CS_ERR_SKIPDATA;
2485 if (!insn->detail) {
2486 handle->errnum = CS_ERR_DETAIL;
2490 return arr_exist8(insn->detail->groups, insn->detail->groups_count, group_id);
2534 struct platform platforms[] = {
2539 sizeof(X86_CODE64) - 1,
2553 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
2555 printf("Platform: %s\n", platforms[i].comment);
2556 err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
2562 if (platforms[i].opt_type)
2563 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
2569 print_string_hex(platforms[i].code, platforms[i].size);
2573 code = platforms[i].code;
2574 size = platforms[i].size;
2579 insn->address, insn->mnemonic, insn->op_str);
2612 在“diet”模式下,此API没有用,因为引擎不更新insn->regs_read数组
2631 if (!handle->detail) {
2632 handle->errnum = CS_ERR_DETAIL;
2636 if (!insn->id) {
2637 handle->errnum = CS_ERR_SKIPDATA;
2641 if (!insn->detail) {
2642 handle->errnum = CS_ERR_DETAIL;
2646 return arr_exist(insn->detail->regs_read, insn->detail->regs_read_count, reg_id);
2662 在“diet”模式下,此API没有用,因为引擎不更新insn->regs_read数组
2681 if (!handle->detail) {
2682 handle->errnum = CS_ERR_DETAIL;
2686 if (!insn->id) {
2687 handle->errnum = CS_ERR_SKIPDATA;
2691 if (!insn->detail) {
2692 handle->errnum = CS_ERR_DETAIL;
2696 return arr_exist(insn->detail->regs_write, insn->detail->regs_write_count, reg_id);
2716 return: 指令insn中给定类型op_type的操作数的数量,返回-1表示查找失败。
2727 return -1;
2731 if (!handle->detail) {
2732 handle->errnum = CS_ERR_DETAIL;
2733 return -1;
2736 if (!insn->id) {
2737 handle->errnum = CS_ERR_SKIPDATA;
2738 return -1;
2741 if (!insn->detail) {
2742 handle->errnum = CS_ERR_DETAIL;
2743 return -1;
2746 handle->errnum = CS_ERR_OK;
2748 switch (handle->arch) {
2750 handle->errnum = CS_ERR_HANDLE;
2751 return -1;
2753 for (i = 0; i < insn->detail->arm.op_count; i++)
2754 if (insn->detail->arm.operands[i].type == (arm_op_type)op_type)
2758 for (i = 0; i < insn->detail->arm64.op_count; i++)
2759 if (insn->detail->arm64.operands[i].type == (arm64_op_type)op_type)
2763 for (i = 0; i < insn->detail->x86.op_count; i++)
2764 if (insn->detail->x86.operands[i].type == (x86_op_type)op_type)
2768 for (i = 0; i < insn->detail->mips.op_count; i++)
2769 if (insn->detail->mips.operands[i].type == (mips_op_type)op_type)
2773 for (i = 0; i < insn->detail->ppc.op_count; i++)
2774 if (insn->detail->ppc.operands[i].type == (ppc_op_type)op_type)
2778 for (i = 0; i < insn->detail->sparc.op_count; i++)
2779 if (insn->detail->sparc.operands[i].type == (sparc_op_type)op_type)
2783 for (i = 0; i < insn->detail->sysz.op_count; i++)
2784 if (insn->detail->sysz.operands[i].type == (sysz_op_type)op_type)
2788 for (i = 0; i < insn->detail->xcore.op_count; i++)
2789 if (insn->detail->xcore.operands[i].type == (xcore_op_type)op_type)
2793 for (i = 0; i < insn->detail->m68k.op_count; i++)
2794 if (insn->detail->m68k.operands[i].type == (m68k_op_type)op_type)
2798 for (i = 0; i < insn->detail->tms320c64x.op_count; i++)
2799 if (insn->detail->tms320c64x.operands[i].type == (tms320c64x_op_type)op_type)
2803 for (i = 0; i < insn->detail->m680x.op_count; i++)
2804 if (insn->detail->m680x.operands[i].type == (m680x_op_type)op_type)
2809 for (i = 0; i < insn->detail->evm.op_count; i++)
2810 if (insn->detail->evm.operands[i].type == (evm_op_type)op_type)
2869 struct platform platforms[] = {
2874 sizeof(X86_CODE64) - 1,
2888 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
2890 printf("Platform: %s\n", platforms[i].comment);
2891 err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
2897 if (platforms[i].opt_type)
2898 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
2904 print_string_hex(platforms[i].code, platforms[i].size);
2908 code = platforms[i].code;
2909 size = platforms[i].size;
2914 insn->address, insn->mnemonic, insn->op_str);
2952 return: 指令insn的`<arch>.operands[]`数组中给定类型op_type的操作数的索引,失败时返回-1。
2964 return -1;
2968 if (!handle->detail) {
2969 handle->errnum = CS_ERR_DETAIL;
2970 return -1;
2973 if (!insn->id) {
2974 handle->errnum = CS_ERR_SKIPDATA;
2975 return -1;
2978 if (!insn->detail) {
2979 handle->errnum = CS_ERR_DETAIL;
2980 return -1;
2983 handle->errnum = CS_ERR_OK;
2985 switch (handle->arch) {
2987 handle->errnum = CS_ERR_HANDLE;
2988 return -1;
2990 for (i = 0; i < insn->detail->arm.op_count; i++) {
2991 if (insn->detail->arm.operands[i].type == (arm_op_type)op_type)
2998 for (i = 0; i < insn->detail->arm64.op_count; i++) {
2999 if (insn->detail->arm64.operands[i].type == (arm64_op_type)op_type)
3006 for (i = 0; i < insn->detail->x86.op_count; i++) {
3007 if (insn->detail->x86.operands[i].type == (x86_op_type)op_type)
3014 for (i = 0; i < insn->detail->mips.op_count; i++) {
3015 if (insn->detail->mips.operands[i].type == (mips_op_type)op_type)
3022 for (i = 0; i < insn->detail->ppc.op_count; i++) {
3023 if (insn->detail->ppc.operands[i].type == (ppc_op_type)op_type)
3030 for (i = 0; i < insn->detail->sparc.op_count; i++) {
3031 if (insn->detail->sparc.operands[i].type == (sparc_op_type)op_type)
3038 for (i = 0; i < insn->detail->sysz.op_count; i++) {
3039 if (insn->detail->sysz.operands[i].type == (sysz_op_type)op_type)
3046 for (i = 0; i < insn->detail->xcore.op_count; i++) {
3047 if (insn->detail->xcore.operands[i].type == (xcore_op_type)op_type)
3054 for (i = 0; i < insn->detail->m68k.op_count; i++) {
3055 if (insn->detail->m68k.operands[i].type == (m68k_op_type)op_type)
3062 for (i = 0; i < insn->detail->tms320c64x.op_count; i++) {
3063 if (insn->detail->tms320c64x.operands[i].type == (tms320c64x_op_type)op_type)
3070 for (i = 0; i < insn->detail->m680x.op_count; i++) {
3071 if (insn->detail->m680x.operands[i].type == (m680x_op_type)op_type)
3079 return -1;
3120 struct platform platforms[] = {
3125 sizeof(X86_CODE64) - 1,
3143 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
3145 printf("Platform: %s\n", platforms[i].comment);
3146 err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
3152 if (platforms[i].opt_type)
3153 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
3158 x86 = &(insn->detail->x86);
3159 print_string_hex(platforms[i].code, platforms[i].size);
3163 code = platforms[i].code;
3164 size = platforms[i].size;
3169 insn->address, insn->mnemonic, insn->op_str);
3177 printf("\timms[%u]: 0x%" PRIx64 "\n", i, x86->operands[index].imm);
3178 if (x86->encoding.imm_offset != 0) {
3179 printf("\timm_offset: 0x%x\n", x86->encoding.imm_offset);
3181 if (x86->encoding.imm_size != 0) {
3182 printf("\timm_size: 0x%x\n", x86->encoding.imm_size);
3239 return -1;
3245 handle->errnum = CS_ERR_DIET;
3248 if (!handle->detail) {
3249 handle->errnum = CS_ERR_DETAIL;
3253 if (!insn->id) {
3254 handle->errnum = CS_ERR_SKIPDATA;
3258 if (!insn->detail) {
3259 handle->errnum = CS_ERR_DETAIL;
3263 if (handle->reg_access) {
3264 handle->reg_access(insn, regs_read, regs_read_count, regs_write, regs_write_count);
3267 handle->errnum = CS_ERR_ARCH;
3314 struct platform platforms[] = {
3319 sizeof(X86_CODE64) - 1,
3339 for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) {
3341 printf("Platform: %s\n", platforms[i].comment);
3342 err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
3348 if (platforms[i].opt_type)
3349 cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
3354 x86 = &(insn->detail->x86);
3355 print_string_hex(platforms[i].code, platforms[i].size);
3359 code = platforms[i].code;
3360 size = platforms[i].size;
3365 insn->address, insn->mnemonic, insn->op_str);