blob: c49465e845675604cd878cb305bbf56999e0fd9b [file] [log] [blame]
Nguyen Anh Quynhae3649f2014-01-02 13:15:07 +08001#ifndef CAPSTONE_ENGINE_H
2#define CAPSTONE_ENGINE_H
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08003
Nguyen Anh Quynh7751fbe2014-04-28 11:23:14 +08004/* Capstone Disassembly Engine */
5/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08006
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include <stdint.h>
Nguyen Anh Quynhedeeb042014-01-15 20:44:03 +080012#include <stdio.h>
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080013#include <stdarg.h>
Nguyen Anh Quynhf1851802013-12-21 12:16:47 +080014#include <stdlib.h>
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080015
Nguyen Anh Quynh171eb752014-05-15 21:01:08 +080016#include "platform.h"
17
Alex Ionescu46018db2014-01-22 09:45:00 -080018#ifdef _MSC_VER
hlide993f3622014-10-05 18:14:40 +020019 #pragma warning(disable:4201)
20 #pragma warning(disable:4100)
21 #ifdef CAPSTONE_SHARED
22 #define CAPSTONE_EXPORT __declspec(dllexport)
23 #else // defined(CAPSTONE_STATIC)
24 #define CAPSTONE_EXPORT
25 #endif
Ali Rizvi-Santiago10053ba2014-06-03 21:04:23 +000026#else
hlide993f3622014-10-05 18:14:40 +020027 #define CAPSTONE_EXPORT
Alex Ionescu46018db2014-01-22 09:45:00 -080028#endif
29
Nguyen Anh Quynh0beb0d42014-08-27 22:55:29 +080030#ifdef __GNUC__
31#define CAPSTONE_DEPRECATED __attribute__((deprecated))
32#elif defined(_MSC_VER)
33#define CAPSTONE_DEPRECATED __declspec(deprecated)
34#else
35#pragma message("WARNING: You need to implement CAPSTONE_DEPRECATED for this compiler")
36#define CAPSTONE_DEPRECATED
37#endif
38
Nguyen Anh Quynhbb64b0b2013-12-10 07:56:17 +080039// Capstone API version
Nguyen Anh Quynhfd0f7982014-08-13 14:15:27 +080040#define CS_API_MAJOR 3
41#define CS_API_MINOR 0
Nguyen Anh Quynhbb64b0b2013-12-10 07:56:17 +080042
Nguyen Anh Quynh2296d5e2013-12-22 21:01:17 +080043// Macro to create combined version which can be compared to
Nguyen Anh Quynhb90cb992013-12-28 13:59:09 +080044// result of cs_version() API.
Nguyen Anh Quynh2296d5e2013-12-22 21:01:17 +080045#define CS_MAKE_VERSION(major, minor) ((major << 8) + minor)
46
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080047// Handle using with all API
Nguyen Anh Quynhb42a6572013-11-29 17:40:07 +080048typedef size_t csh;
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080049
50// Architecture type
51typedef enum cs_arch {
52 CS_ARCH_ARM = 0, // ARM architecture (including Thumb, Thumb-2)
53 CS_ARCH_ARM64, // ARM-64, also called AArch64
54 CS_ARCH_MIPS, // Mips architecture
55 CS_ARCH_X86, // X86 architecture (including x86 & x86-64)
Nguyen Anh Quynh42c6b1a2013-12-30 00:15:25 +080056 CS_ARCH_PPC, // PowerPC architecture
Nguyen Anh Quynh05e27132014-03-10 11:58:57 +080057 CS_ARCH_SPARC, // Sparc architecture
Nguyen Anh Quynh48a14ca2014-03-23 08:35:45 +080058 CS_ARCH_SYSZ, // SystemZ architecture
Nguyen Anh Quynhc80d8402014-05-26 23:02:48 +080059 CS_ARCH_XCORE, // XCore architecture
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080060 CS_ARCH_MAX,
Nguyen Anh Quynh39a42ed2013-12-22 10:40:58 +080061 CS_ARCH_ALL = 0xFFFF,
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080062} cs_arch;
63
Nguyen Anh Quynh95181482014-03-25 23:20:41 +080064// Support value to verify diet mode of the engine.
65// If cs_support(CS_SUPPORT_DIET) return True, the engine was compiled
66// in diet mode.
Nguyen Anh Quynh492b8ed2014-02-25 08:14:15 +080067#define CS_SUPPORT_DIET (CS_ARCH_ALL + 1)
Nguyen Anh Quynhb2870e42014-02-22 23:41:16 +080068
Nguyen Anh Quynh6d3c7112014-03-27 15:38:23 +080069// Support value to verify X86 reduce mode of the engine.
Nguyen Anh Quynh59b54892014-03-27 10:54:44 +080070// If cs_support(CS_SUPPORT_X86_REDUCE) return True, the engine was compiled
Nguyen Anh Quynh6d3c7112014-03-27 15:38:23 +080071// in X86 reduce mode.
Nguyen Anh Quynh59b54892014-03-27 10:54:44 +080072#define CS_SUPPORT_X86_REDUCE (CS_ARCH_ALL + 2)
Nguyen Anh Quynh95181482014-03-25 23:20:41 +080073
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080074// Mode type
75typedef enum cs_mode {
76 CS_MODE_LITTLE_ENDIAN = 0, // little endian mode (default mode)
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080077 CS_MODE_ARM = 0, // 32-bit ARM
78 CS_MODE_16 = 1 << 1, // 16-bit mode
79 CS_MODE_32 = 1 << 2, // 32-bit mode
80 CS_MODE_64 = 1 << 3, // 64-bit mode
81 CS_MODE_THUMB = 1 << 4, // ARM's Thumb mode, including Thumb-2
Nguyen Anh Quynh7c089fd2014-08-13 23:08:40 +080082 CS_MODE_MCLASS = 1 << 5, // ARM's Cortex-M series
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080083 CS_MODE_MICRO = 1 << 4, // MicroMips mode (MIPS architecture)
Jay Oster79e253c2014-10-12 16:03:12 -070084 CS_MODE_MIPS3 = 1 << 5, // Mips III ISA
85 CS_MODE_MIPS32R6 = 1 << 6, // Mips32r6 ISA
86 CS_MODE_MIPSGP64 = 1 << 7, // General Purpose Registers are 64-bit wide (MIPS arch)
Nguyen Anh Quynh05e27132014-03-10 11:58:57 +080087 CS_MODE_V9 = 1 << 4, // SparcV9 mode (Sparc architecture)
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080088 CS_MODE_BIG_ENDIAN = 1 << 31 // big endian mode
89} cs_mode;
90
Nguyen Anh Quynha8eb7a52014-01-11 12:55:31 +080091typedef void* (*cs_malloc_t)(size_t size);
92typedef void* (*cs_calloc_t)(size_t nmemb, size_t size);
93typedef void* (*cs_realloc_t)(void *ptr, size_t size);
94typedef void (*cs_free_t)(void *ptr);
Nguyen Anh Quynhbdd1e342014-01-16 12:34:06 +080095typedef int (*cs_vsnprintf_t)(char *str, size_t size, const char *format, va_list ap);
Nguyen Anh Quynhedeeb042014-01-15 20:44:03 +080096
Nguyen Anh Quynh24bf0d92014-01-05 11:19:04 +080097
Nguyen Anh Quynh56aba592014-01-15 21:24:28 +080098// User-defined dynamic memory related functions: malloc/calloc/realloc/free/vsnprintf()
99// By default, Capstone uses system's malloc(), calloc(), realloc(), free() & vsnprintf().
Nguyen Anh Quynh24bf0d92014-01-05 11:19:04 +0800100typedef struct cs_opt_mem {
Nguyen Anh Quynha8eb7a52014-01-11 12:55:31 +0800101 cs_malloc_t malloc;
102 cs_calloc_t calloc;
103 cs_realloc_t realloc;
104 cs_free_t free;
Nguyen Anh Quynhedeeb042014-01-15 20:44:03 +0800105 cs_vsnprintf_t vsnprintf;
Nguyen Anh Quynh24bf0d92014-01-05 11:19:04 +0800106} cs_opt_mem;
107
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800108// Runtime option for the disassembled engine
Nguyen Anh Quynhb8ce68e2013-12-03 23:45:08 +0800109typedef enum cs_opt_type {
Nguyen Anh Quynh4d70daf2013-12-05 09:50:50 +0800110 CS_OPT_SYNTAX = 1, // Asssembly output syntax
Nguyen Anh Quynha209e672013-12-14 00:23:41 +0800111 CS_OPT_DETAIL, // Break down instruction structure into details
Nguyen Anh Quynh1bdb23a2013-12-20 00:04:26 +0800112 CS_OPT_MODE, // Change engine's mode at run-time
Nguyen Anh Quynh56aba592014-01-15 21:24:28 +0800113 CS_OPT_MEM, // User-defined dynamic memory related functions
Nguyen Anh Quynh11ec8812014-04-10 17:20:01 +0800114 CS_OPT_SKIPDATA, // Skip data when disassembling. Then engine is in SKIPDATA mode.
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800115 CS_OPT_SKIPDATA_SETUP, // Setup user-defined function for SKIPDATA option
Nguyen Anh Quynhb8ce68e2013-12-03 23:45:08 +0800116} cs_opt_type;
117
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800118// Runtime option value (associated with option type above)
Nguyen Anh Quynhb8ce68e2013-12-03 23:45:08 +0800119typedef enum cs_opt_value {
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800120 CS_OPT_OFF = 0, // Turn OFF an option - default option of CS_OPT_DETAIL, CS_OPT_SKIPDATA.
121 CS_OPT_ON = 3, // Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
Nguyen Anh Quynh42c6b1a2013-12-30 00:15:25 +0800122 CS_OPT_SYNTAX_DEFAULT = 0, // Default asm syntax (CS_OPT_SYNTAX).
123 CS_OPT_SYNTAX_INTEL, // X86 Intel asm syntax - default on X86 (CS_OPT_SYNTAX).
Nguyen Anh Quynhc263d352014-01-07 23:50:02 +0800124 CS_OPT_SYNTAX_ATT, // X86 ATT asm syntax (CS_OPT_SYNTAX).
Nguyen Anh Quynh2ff665a2014-03-11 00:18:50 +0800125 CS_OPT_SYNTAX_NOREGNAME, // Prints register name with only number (CS_OPT_SYNTAX)
Nguyen Anh Quynhb8ce68e2013-12-03 23:45:08 +0800126} cs_opt_value;
Nguyen Anh Quynh01aba002013-12-03 21:00:09 +0800127
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800128/*
Nguyen Anh Quynhff2939a2014-10-12 10:43:02 +0800129 User-defined callback function for SKIPDATA option.
130 See tests/test_skipdata.c for sample code demonstrating this API.
131
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800132 @code: the input buffer containing code to be disassembled.
133 This is the same buffer passed to cs_disasm().
134 @code_size: size (in bytes) of the above @code buffer.
135 @offset: the position of the currently-examining byte in the input
136 buffer @code mentioned above.
137 @user_data: user-data passed to cs_option() via @user_data field in
138 cs_opt_skipdata struct below.
139
140 @return: return number of bytes to skip, or 0 to immediately stop disassembling.
141*/
Nguyen Anh Quynh43efc452014-10-11 00:38:30 +0800142typedef size_t (*cs_skipdata_cb_t)(const uint8_t *code, size_t code_size, size_t offset, void *user_data);
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800143
Nguyen Anh Quynh11ec8812014-04-10 17:20:01 +0800144// User-customized setup for SKIPDATA option
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800145typedef struct cs_opt_skipdata {
146 // Capstone considers data to skip as special "instructions".
147 // User can specify the string for this instruction's "mnemonic" here.
Nguyen Anh Quynh2c425fc2014-09-07 09:46:54 +0800148 // By default (if @mnemonic is NULL), Capstone use ".byte".
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800149 const char *mnemonic;
Nguyen Anh Quynha89383e2014-04-10 11:53:46 +0800150
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800151 // User-defined callback function to be called when Capstone hits data.
Nguyen Anh Quynha89383e2014-04-10 11:53:46 +0800152 // If the returned value from this callback is positive (>0), Capstone
153 // will skip exactly that number of bytes & continue. Otherwise, if
154 // the callback returns 0, Capstone stops disassembling and returns
Nguyen Anh Quynh0beb0d42014-08-27 22:55:29 +0800155 // immediately from cs_disasm()
Nguyen Anh Quynha89383e2014-04-10 11:53:46 +0800156 // NOTE: if this callback pointer is NULL, Capstone would skip a number
157 // of bytes depending on architectures, as following:
158 // Arm: 2 bytes (Thumb mode) or 4 bytes.
159 // Arm64: 4 bytes.
160 // Mips: 4 bytes.
Nguyen Anh Quynh3d5b6f32014-04-11 09:53:53 +0800161 // PowerPC: 4 bytes.
Nguyen Anh Quynha89383e2014-04-10 11:53:46 +0800162 // Sparc: 4 bytes.
163 // SystemZ: 2 bytes.
164 // X86: 1 bytes.
Nguyen Anh Quynhc80d8402014-05-26 23:02:48 +0800165 // XCore: 2 bytes.
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800166 cs_skipdata_cb_t callback; // default value is NULL
Nguyen Anh Quynha89383e2014-04-10 11:53:46 +0800167
Nguyen Anh Quynhd3ffe372014-04-09 23:49:30 +0800168 // User-defined data to be passed to @callback function pointer.
169 void *user_data;
170} cs_opt_skipdata;
171
Nguyen Anh Quynh01aba002013-12-03 21:00:09 +0800172
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800173#include "arm.h"
174#include "arm64.h"
175#include "mips.h"
Nguyen Anh Quynh42c6b1a2013-12-30 00:15:25 +0800176#include "ppc.h"
Nguyen Anh Quynh05e27132014-03-10 11:58:57 +0800177#include "sparc.h"
Nguyen Anh Quynh48a14ca2014-03-23 08:35:45 +0800178#include "systemz.h"
179#include "x86.h"
Nguyen Anh Quynhc80d8402014-05-26 23:02:48 +0800180#include "xcore.h"
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800181
Nguyen Anh Quynh4fe224b2013-12-24 16:49:36 +0800182// NOTE: All information in cs_detail is only available when CS_OPT_DETAIL = CS_OPT_ON
183typedef struct cs_detail {
184 uint8_t regs_read[12]; // list of implicit registers read by this insn
185 uint8_t regs_read_count; // number of implicit registers read by this insn
186
187 uint8_t regs_write[20]; // list of implicit registers modified by this insn
188 uint8_t regs_write_count; // number of implicit registers modified by this insn
189
190 uint8_t groups[8]; // list of group this instruction belong to
191 uint8_t groups_count; // number of groups this insn belongs to
192
193 // Architecture-specific instruction info
194 union {
195 cs_x86 x86; // X86 architecture, including 16-bit, 32-bit & 64-bit mode
196 cs_arm64 arm64; // ARM64 architecture (aka AArch64)
197 cs_arm arm; // ARM architecture (including Thumb/Thumb2)
198 cs_mips mips; // MIPS architecture
Nguyen Anh Quynh42c6b1a2013-12-30 00:15:25 +0800199 cs_ppc ppc; // PowerPC architecture
Nguyen Anh Quynh05e27132014-03-10 11:58:57 +0800200 cs_sparc sparc; // Sparc architecture
Nguyen Anh Quynh48a14ca2014-03-23 08:35:45 +0800201 cs_sysz sysz; // SystemZ architecture
Nguyen Anh Quynhc80d8402014-05-26 23:02:48 +0800202 cs_xcore xcore; // XCore architecture
Nguyen Anh Quynh4fe224b2013-12-24 16:49:36 +0800203 };
204} cs_detail;
205
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800206// Detail information of disassembled instruction
207typedef struct cs_insn {
208 // Instruction ID
209 // Find the instruction id from header file of corresponding architecture,
210 // such as arm.h for ARM, x86.h for X86, etc...
Nguyen Anh Quynh46a5afd2013-12-14 11:52:06 +0800211 // This information is available even when CS_OPT_DETAIL = CS_OPT_OFF
Nguyen Anh Quynhfb429b12014-10-12 15:29:12 +0800212 // NOTE: in Skipdata mode, "data" instruction has 0 for this id field.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800213 unsigned int id;
214
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800215 // Address (EIP) of this instruction
Nguyen Anh Quynh46a5afd2013-12-14 11:52:06 +0800216 // This information is available even when CS_OPT_DETAIL = CS_OPT_OFF
Nguyen Anh Quynhf2a649e2013-12-03 12:21:01 +0800217 uint64_t address;
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800218
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800219 // Size of this instruction
Nguyen Anh Quynh46a5afd2013-12-14 11:52:06 +0800220 // This information is available even when CS_OPT_DETAIL = CS_OPT_OFF
Nguyen Anh Quynh8f13f3c2013-12-04 22:57:04 +0800221 uint16_t size;
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800222 // Machine bytes of this instruction, with number of bytes indicated by @size above
Nguyen Anh Quynh46a5afd2013-12-14 11:52:06 +0800223 // This information is available even when CS_OPT_DETAIL = CS_OPT_OFF
pancakef0e4eed2013-12-11 22:14:42 +0100224 uint8_t bytes[16];
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800225
226 // Ascii text of instruction mnemonic
Nguyen Anh Quynh46a5afd2013-12-14 11:52:06 +0800227 // This information is available even when CS_OPT_DETAIL = CS_OPT_OFF
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800228 char mnemonic[32];
Nguyen Anh Quynhcf89cf62014-01-06 09:08:35 +0800229
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800230 // Ascii text of instruction operands
Nguyen Anh Quynh46a5afd2013-12-14 11:52:06 +0800231 // This information is available even when CS_OPT_DETAIL = CS_OPT_OFF
Nguyen Anh Quynh0636f682014-01-15 17:51:08 +0800232 char op_str[160];
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800233
Nguyen Anh Quynh4fe224b2013-12-24 16:49:36 +0800234 // Pointer to cs_detail.
Nguyen Anh Quynh801ce2b2014-10-12 10:36:57 +0800235 // NOTE: detail pointer is only valid when both requirements below are met:
Nguyen Anh Quynh11ec8812014-04-10 17:20:01 +0800236 // (1) CS_OP_DETAIL = CS_OPT_ON
Nguyen Anh Quynh801ce2b2014-10-12 10:36:57 +0800237 // (2) Engine is not in Skipdata mode (CS_OP_SKIPDATA option set to CS_OPT_ON)
Nguyen Anh Quynh2c8b2622014-10-12 20:23:08 +0800238 //
239 // NOTE 2: when in Skipdata mode, or when detail mode is OFF, even if this pointer
240 // is not NULL, its content is still irrelevant.
Nguyen Anh Quynh4fe224b2013-12-24 16:49:36 +0800241 cs_detail *detail;
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800242} cs_insn;
243
Nguyen Anh Quynhbb546032013-12-05 18:29:51 +0800244
245// Calculate the offset of a disassembled instruction in its buffer, given its position
246// in its array of disassembled insn
Nguyen Anh Quynha2369022013-12-05 20:21:09 +0800247// NOTE: this macro works with position (>=1), not index
248#define CS_INSN_OFFSET(insns, post) (insns[post - 1].address - insns[0].address)
Nguyen Anh Quynhbb546032013-12-05 18:29:51 +0800249
250
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800251// All type of errors encountered by Capstone API.
252// These are values returned by cs_errno()
253typedef enum cs_err {
Nguyen Anh Quynh11ec8812014-04-10 17:20:01 +0800254 CS_ERR_OK = 0, // No error: everything was fine
Nguyen Anh Quynhc41da152014-10-15 16:31:35 +0800255 CS_ERR_MEM, // Out-Of-Memory error: cs_open(), cs_disasm(), cs_disasm_iter()
Nguyen Anh Quynh11ec8812014-04-10 17:20:01 +0800256 CS_ERR_ARCH, // Unsupported architecture: cs_open()
257 CS_ERR_HANDLE, // Invalid handle: cs_op_count(), cs_op_index()
258 CS_ERR_CSH, // Invalid csh argument: cs_close(), cs_errno(), cs_option()
259 CS_ERR_MODE, // Invalid/unsupported mode: cs_open()
260 CS_ERR_OPTION, // Invalid/unsupported option: cs_option()
261 CS_ERR_DETAIL, // Information is unavailable because detail option is OFF
Nguyen Anh Quynhc52352d2014-01-06 09:06:30 +0800262 CS_ERR_MEMSETUP, // Dynamic memory management uninitialized (see CS_OPT_MEM)
Nguyen Anh Quynh11ec8812014-04-10 17:20:01 +0800263 CS_ERR_VERSION, // Unsupported version (bindings)
264 CS_ERR_DIET, // Access irrelevant data in "diet" engine
265 CS_ERR_SKIPDATA, // Access irrelevant data for "data" instruction in SKIPDATA mode
Nguyen Anh Quynh66382942014-08-20 14:02:14 +0800266 CS_ERR_X86_ATT, // X86 AT&T syntax is unsupported (opt-out at compile time)
267 CS_ERR_X86_INTEL, // X86 Intel syntax is unsupported (opt-out at compile time)
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800268} cs_err;
269
Nguyen Anh Quynhb8806782013-12-22 15:20:07 +0800270/*
Nguyen Anh Quynhb8806782013-12-22 15:20:07 +0800271 Return combined API version & major and minor version numbers.
Nguyen Anh Quynh36df4bb2013-12-10 13:31:20 +0800272
Nguyen Anh Quynhb8806782013-12-22 15:20:07 +0800273 @major: major number of API version
274 @minor: minor number of API version
Nguyen Anh Quynh36df4bb2013-12-10 13:31:20 +0800275
Nguyen Anh Quynhb90cb992013-12-28 13:59:09 +0800276 @return hexical number as (major << 8 | minor), which encodes both
hlide993f3622014-10-05 18:14:40 +0200277 major & minor versions.
278 NOTE: This returned value can be compared with version number made
Nguyen Anh Quynhb90cb992013-12-28 13:59:09 +0800279 with macro CS_MAKE_VERSION
Nguyen Anh Quynh39a42ed2013-12-22 10:40:58 +0800280
281 For example, second API version would return 1 in @major, and 1 in @minor
282 The return value would be 0x0101
Nguyen Anh Quynh08777472013-12-22 14:16:28 +0800283
284 NOTE: if you only care about returned value, but not major and minor values,
Nguyen Anh Quynhb90cb992013-12-28 13:59:09 +0800285 set both @major & @minor arguments to NULL.
Nguyen Anh Quynh36df4bb2013-12-10 13:31:20 +0800286*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800287CAPSTONE_EXPORT
Nguyen Anh Quynhb90cb992013-12-28 13:59:09 +0800288unsigned int cs_version(int *major, int *minor);
Nguyen Anh Quynh39a42ed2013-12-22 10:40:58 +0800289
290
291/*
Nguyen Anh Quynhb2870e42014-02-22 23:41:16 +0800292 This API can be used to either ask for archs supported by this library,
Nguyen Anh Quynhc70adc32014-02-23 00:03:46 +0800293 or check to see if the library was compile with 'diet' option (or called
294 in 'diet' mode).
Nguyen Anh Quynh39a42ed2013-12-22 10:40:58 +0800295
Nguyen Anh Quynhb2870e42014-02-22 23:41:16 +0800296 To check if a particular arch is supported by this library, set @query to
297 arch mode (CS_ARCH_* value).
298 To verify if this library supports all the archs, use CS_ARCH_ALL.
Nguyen Anh Quynh39a42ed2013-12-22 10:40:58 +0800299
Nguyen Anh Quynhb2870e42014-02-22 23:41:16 +0800300 To check if this library is in 'diet' mode, set @query to CS_SUPPORT_DIET.
Nguyen Anh Quynhb2870e42014-02-22 23:41:16 +0800301
Nguyen Anh Quynh544e0ff2014-02-23 20:24:47 +0800302 @return True if this library supports the given arch, or in 'diet' mode.
Nguyen Anh Quynh39a42ed2013-12-22 10:40:58 +0800303*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800304CAPSTONE_EXPORT
Nguyen Anh Quynhb2870e42014-02-22 23:41:16 +0800305bool cs_support(int query);
Nguyen Anh Quynh36df4bb2013-12-10 13:31:20 +0800306
307/*
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800308 Initialize CS handle: this must be done before any usage of CS.
309
310 @arch: architecture type (CS_ARCH_*)
311 @mode: hardware mode. This is combined of CS_MODE_*
312 @handle: pointer to handle, which will be updated at return time
313
314 @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum
315 for detailed error).
316*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800317CAPSTONE_EXPORT
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800318cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle);
319
320/*
321 Close CS handle: MUST do to release the handle when it is not used anymore.
Nguyen Anh Quynhb2654062014-01-03 17:08:58 +0800322 NOTE: this must be only called when there is no longer usage of Capstone,
323 not even access to cs_insn array. The reason is the this API releases some
324 cached memory, thus access to any Capstone API after cs_close() might crash
325 your application.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800326
Nguyen Anh Quynhc8e07852014-02-28 09:38:11 +0800327 In fact,this API invalidate @handle by ZERO out its value (i.e *handle = 0).
328
Nguyen Anh Quynh226d7dc2014-02-27 22:20:39 +0800329 @handle: pointer to a handle returned by cs_open()
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800330
331 @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum
332 for detailed error).
333*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800334CAPSTONE_EXPORT
Nguyen Anh Quynh226d7dc2014-02-27 22:20:39 +0800335cs_err cs_close(csh *handle);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800336
337/*
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800338 Set option for disassembling engine at runtime
Nguyen Anh Quynh01aba002013-12-03 21:00:09 +0800339
340 @handle: handle returned by cs_open()
Nguyen Anh Quynhb8ce68e2013-12-03 23:45:08 +0800341 @type: type of option to be set
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800342 @value: option value corresponding with @type
Nguyen Anh Quynh01aba002013-12-03 21:00:09 +0800343
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800344 @return: CS_ERR_OK on success, or other value on failure.
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800345 Refer to cs_err enum for detailed error.
Nguyen Anh Quynha60ed8b2014-01-05 23:52:30 +0800346
347 NOTE: in the case of CS_OPT_MEM, handle's value can be anything,
348 so that cs_option(handle, CS_OPT_MEM, value) can (i.e must) be called
349 even before cs_open()
Nguyen Anh Quynh01aba002013-12-03 21:00:09 +0800350*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800351CAPSTONE_EXPORT
Nguyen Anh Quynhda8adad2013-12-04 09:44:07 +0800352cs_err cs_option(csh handle, cs_opt_type type, size_t value);
Nguyen Anh Quynh01aba002013-12-03 21:00:09 +0800353
354/*
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800355 Report the last error number when some API function fail.
356 Like glibc's errno, cs_errno might not retain its old value once accessed.
357
358 @handle: handle returned by cs_open()
359
360 @return: error code of cs_err enum type (CS_ERR_*, see above)
361*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800362CAPSTONE_EXPORT
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800363cs_err cs_errno(csh handle);
364
Nguyen Anh Quynh34f96382014-01-03 22:49:07 +0800365
366/*
367 Return a string describing given error code.
368
369 @code: error code (see CS_ERR_* above)
370
371 @return: returns a pointer to a string that describes the error code
hlide993f3622014-10-05 18:14:40 +0200372 passed in the argument @code
Nguyen Anh Quynh34f96382014-01-03 22:49:07 +0800373*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800374CAPSTONE_EXPORT
Nguyen Anh Quynh34f96382014-01-03 22:49:07 +0800375const char *cs_strerror(cs_err code);
376
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800377/*
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800378 Disassemble binary code, given the code buffer, size, address and number
379 of instructions to be decoded.
380 This API dynamicly allocate memory to contain disassembled instruction.
381 Resulted instructions will be put into @*insn
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800382
383 NOTE 1: this API will automatically determine memory needed to contain
384 output disassembled instructions in @insn.
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800385 NOTE 2: caller must free the allocated memory itself to avoid memory leaking.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800386
387 @handle: handle returned by cs_open()
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800388 @code: buffer containing raw binary code to be disassembled.
389 @code_size: size of the above code buffer.
390 @address: address of the first instruction in given raw code buffer.
391 @insn: array of instructions filled in by this API.
hlide993f3622014-10-05 18:14:40 +0200392 NOTE: @insn will be allocated by this function, and should be freed
Nguyen Anh Quynh79976c12013-12-04 23:03:13 +0800393 with cs_free() API.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800394 @count: number of instrutions to be disassembled, or 0 to get all of them
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800395
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800396 @return: the number of succesfully disassembled instructions,
397 or 0 if this function failed to disassemble the given code
Nguyen Anh Quynh029df202013-12-03 11:36:54 +0800398
399 On failure, call cs_errno() for error code.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800400*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800401CAPSTONE_EXPORT
Nguyen Anh Quynh0beb0d42014-08-27 22:55:29 +0800402size_t cs_disasm(csh handle,
pancakef0e4eed2013-12-11 22:14:42 +0100403 const uint8_t *code, size_t code_size,
Nguyen Anh Quynh612b5d22013-12-03 12:23:09 +0800404 uint64_t address,
Nguyen Anh Quynhb42a6572013-11-29 17:40:07 +0800405 size_t count,
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800406 cs_insn **insn);
407
Nguyen Anh Quynhaa58f7f2014-09-25 16:56:31 +0800408/*
409 Deprecated function - to be retired in the next version!
Nguyen Anh Quynh0beb0d42014-08-27 22:55:29 +0800410 Use cs_disasm() instead of cs_disasm_ex()
411*/
412CAPSTONE_EXPORT
413CAPSTONE_DEPRECATED
414size_t cs_disasm_ex(csh handle,
415 const uint8_t *code, size_t code_size,
416 uint64_t address,
417 size_t count,
418 cs_insn **insn);
Nguyen Anh Quynhaa58f7f2014-09-25 16:56:31 +0800419
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800420/*
Nguyen Anh Quynh542a5402014-10-11 13:12:15 +0800421 Free memory allocated by cs_malloc() or cs_disasm() (argument @insn)
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800422
Nguyen Anh Quynh542a5402014-10-11 13:12:15 +0800423 @insn: pointer returned by @insn argument in cs_disasm() or cs_malloc()
424 @count: number of cs_insn structures returned by cs_disasm(), or 1
425 to free memory allocated by cs_malloc().
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800426*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800427CAPSTONE_EXPORT
Nguyen Anh Quynh4fe224b2013-12-24 16:49:36 +0800428void cs_free(cs_insn *insn, size_t count);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800429
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800430
431/*
432 Allocate memory for 1 instruction to be used by cs_disasm_iter().
433
434 @handle: handle returned by cs_open()
435
Nguyen Anh Quynh5cb3d642014-10-11 01:32:39 +0800436 NOTE: when no longer in use, you can reclaim the memory allocated for
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800437 this instruction with cs_free(insn, 1)
438*/
hlide993f3622014-10-05 18:14:40 +0200439CAPSTONE_EXPORT
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800440cs_insn *cs_malloc(csh handle);
441
442/*
Nguyen Anh Quynh5cb3d642014-10-11 01:32:39 +0800443 Fast API to disassemble binary code, given the code buffer, size, address
444 and number of instructions to be decoded.
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800445 This API put the resulted instruction into a given cache in @insn.
Nguyen Anh Quynhff2939a2014-10-12 10:43:02 +0800446 See tests/test_iter.c for sample code demonstrating this API.
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800447
448 NOTE 1: this API will update @code, @size & @address to point to the next
Nguyen Anh Quynh5cb3d642014-10-11 01:32:39 +0800449 instruction in the input buffer. Therefore, it is covenient to use
450 cs_disasm_iter() inside a loop to quickly iterate all the instructions.
451 While decoding one instruction at a time can also be achieved with
452 cs_disasm(count=1), some benchmarks shown that cs_disasm_iter() can be 30%
453 faster on random input.
454
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800455 NOTE 2: the cache in @insn can be created with cs_malloc() API.
456
457 @handle: handle returned by cs_open()
458 @code: buffer containing raw binary code to be disassembled
459 @code_size: size of above code
460 @address: address of the first insn in given raw code buffer
461 @insn: pointer to instruction to be filled in by this API.
462
463 @return: true if this API successfully decode 1 instruction,
464 or false otherwise.
465
466 On failure, call cs_errno() for error code.
467*/
468CAPSTONE_EXPORT
469bool cs_disasm_iter(csh handle,
hlide993f3622014-10-05 18:14:40 +0200470 const uint8_t **code, size_t *size,
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800471 uint64_t *address, cs_insn *insn);
hlide993f3622014-10-05 18:14:40 +0200472
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800473/*
Nguyen Anh Quynh650f96c2014-07-08 08:59:27 +0800474 Return friendly name of regiser in a string.
Nguyen Anh Quynhc70adc32014-02-23 00:03:46 +0800475 Find the instruction id from header file of corresponding architecture (arm.h for ARM,
476 x86.h for X86, ...)
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800477
Nguyen Anh Quynh544e0ff2014-02-23 20:24:47 +0800478 WARN: when in 'diet' mode, this API is irrelevant because engine does not
Nguyen Anh Quynhfc83a432014-02-22 23:26:27 +0800479 store register name.
480
Nguyen Anh Quynh3640f3c2013-12-01 00:26:27 +0800481 @handle: handle returned by cs_open()
Nguyen Anh Quynh650f96c2014-07-08 08:59:27 +0800482 @reg_id: register id
Nguyen Anh Quynh0a2eca72014-10-11 00:36:16 +0800483
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800484 @return: string name of the register, or NULL if @reg_id is invalid.
485*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800486CAPSTONE_EXPORT
pancakef0e4eed2013-12-11 22:14:42 +0100487const char *cs_reg_name(csh handle, unsigned int reg_id);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800488
489/*
Nguyen Anh Quynh650f96c2014-07-08 08:59:27 +0800490 Return friendly name of an instruction in a string.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800491 Find the instruction id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
492
Nguyen Anh Quynh544e0ff2014-02-23 20:24:47 +0800493 WARN: when in 'diet' mode, this API is irrelevant because the engine does not
Nguyen Anh Quynhfc83a432014-02-22 23:26:27 +0800494 store instruction name.
495
Nguyen Anh Quynh3640f3c2013-12-01 00:26:27 +0800496 @handle: handle returned by cs_open()
Nguyen Anh Quynh650f96c2014-07-08 08:59:27 +0800497 @insn_id: instruction id
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800498
499 @return: string name of the instruction, or NULL if @insn_id is invalid.
500*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800501CAPSTONE_EXPORT
pancakef0e4eed2013-12-11 22:14:42 +0100502const char *cs_insn_name(csh handle, unsigned int insn_id);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800503
504/*
Nguyen Anh Quynh650f96c2014-07-08 08:59:27 +0800505 Return friendly name of a group id (that an instruction can belong to)
506 Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
507
508 WARN: when in 'diet' mode, this API is irrelevant because the engine does not
509 store group name.
510
511 @handle: handle returned by cs_open()
512 @group_id: group id
513
514 @return: string name of the group, or NULL if @group_id is invalid.
515*/
516CAPSTONE_EXPORT
Nguyen Anh Quynhaa58f7f2014-09-25 16:56:31 +0800517const char *cs_group_name(csh handle, unsigned int group_id);
Nguyen Anh Quynh650f96c2014-07-08 08:59:27 +0800518
519/*
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800520 Check if a disassembled instruction belong to a particular group.
521 Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
522 Internally, this simply verifies if @group_id matches any member of insn->groups array.
523
Nguyen Anh Quynh544e0ff2014-02-23 20:24:47 +0800524 NOTE: this API is only valid when detail option is ON (which is OFF by default).
525
526 WARN: when in 'diet' mode, this API is irrelevant because the engine does not
Nguyen Anh Quynhfc83a432014-02-22 23:26:27 +0800527 update @groups array.
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800528
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800529 @handle: handle returned by cs_open()
Nguyen Anh Quynhc41da152014-10-15 16:31:35 +0800530 @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800531 @group_id: group that you want to check if this instruction belong to.
532
533 @return: true if this instruction indeed belongs to aboved group, or false otherwise.
534*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800535CAPSTONE_EXPORT
obs876b6b62014-08-21 00:57:04 +0200536bool cs_insn_group(csh handle, const cs_insn *insn, unsigned int group_id);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800537
538/*
539 Check if a disassembled instruction IMPLICITLY used a particular register.
540 Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
541 Internally, this simply verifies if @reg_id matches any member of insn->regs_read array.
542
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800543 NOTE: this API is only valid when detail option is ON (which is OFF by default)
Nguyen Anh Quynh544e0ff2014-02-23 20:24:47 +0800544
545 WARN: when in 'diet' mode, this API is irrelevant because the engine does not
Nguyen Anh Quynhfc83a432014-02-22 23:26:27 +0800546 update @regs_read array.
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800547
Nguyen Anh Quynhc41da152014-10-15 16:31:35 +0800548 @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800549 @reg_id: register that you want to check if this instruction used it.
550
551 @return: true if this instruction indeed implicitly used aboved register, or false otherwise.
552*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800553CAPSTONE_EXPORT
obs876b6b62014-08-21 00:57:04 +0200554bool cs_reg_read(csh handle, const cs_insn *insn, unsigned int reg_id);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800555
556/*
557 Check if a disassembled instruction IMPLICITLY modified a particular register.
558 Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
559 Internally, this simply verifies if @reg_id matches any member of insn->regs_write array.
560
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800561 NOTE: this API is only valid when detail option is ON (which is OFF by default)
Nguyen Anh Quynh544e0ff2014-02-23 20:24:47 +0800562
563 WARN: when in 'diet' mode, this API is irrelevant because the engine does not
Nguyen Anh Quynhfc83a432014-02-22 23:26:27 +0800564 update @regs_write array.
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800565
Nguyen Anh Quynhc41da152014-10-15 16:31:35 +0800566 @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800567 @reg_id: register that you want to check if this instruction modified it.
568
569 @return: true if this instruction indeed implicitly modified aboved register, or false otherwise.
570*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800571CAPSTONE_EXPORT
obs876b6b62014-08-21 00:57:04 +0200572bool cs_reg_write(csh handle, const cs_insn *insn, unsigned int reg_id);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800573
574/*
575 Count the number of operands of a given type.
576 Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
577
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800578 NOTE: this API is only valid when detail option is ON (which is OFF by default)
579
Nguyen Anh Quynh3640f3c2013-12-01 00:26:27 +0800580 @handle: handle returned by cs_open()
Nguyen Anh Quynhc41da152014-10-15 16:31:35 +0800581 @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800582 @op_type: Operand type to be found.
583
584 @return: number of operands of given type @op_type in instruction @insn,
585 or -1 on failure.
586*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800587CAPSTONE_EXPORT
obs876b6b62014-08-21 00:57:04 +0200588int cs_op_count(csh handle, const cs_insn *insn, unsigned int op_type);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800589
590/*
Nguyen Anh Quynh4c0ed0b2014-06-03 15:06:20 +0700591 Retrieve the position of operand of given type in <arch>.operands[] array.
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800592 Later, the operand can be accessed using the returned position.
593 Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
594
Nguyen Anh Quynh2f05ab22014-01-15 11:07:28 +0800595 NOTE: this API is only valid when detail option is ON (which is OFF by default)
596
Nguyen Anh Quynh3640f3c2013-12-01 00:26:27 +0800597 @handle: handle returned by cs_open()
Nguyen Anh Quynhc41da152014-10-15 16:31:35 +0800598 @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800599 @op_type: Operand type to be found.
600 @position: position of the operand to be found. This must be in the range
601 [1, cs_op_count(handle, insn, op_type)]
602
Nguyen Anh Quynh4c0ed0b2014-06-03 15:06:20 +0700603 @return: index of operand of given type @op_type in <arch>.operands[] array
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800604 in instruction @insn, or -1 on failure.
605*/
Nguyen Anh Quynh07c36932014-06-03 18:33:15 +0800606CAPSTONE_EXPORT
obs876b6b62014-08-21 00:57:04 +0200607int cs_op_index(csh handle, const cs_insn *insn, unsigned int op_type,
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800608 unsigned int position);
609
610#ifdef __cplusplus
611}
612#endif
613
614#endif