capstone_sys/
lib.rs

1//! Low-level, unsafe Rust bindings for the [`Capstone`][capstone] disassembly library.
2//!
3//!
4//! We recommend against using this crate directly.
5//! Instead, consider using [capstone-rs], which provides a high-level, safe, "Rusty" interface.
6//!
7//! [capstone]: https://github.com/aquynh/capstone
8//! [capstone-rs]: https://github.com/capstone-rust/capstone-rs
9//!
10//! # Supported disassembly architectures
11//!
12//! * `arm`: ARM
13//! * `arm64`: ARM64 (also known as AArch64)
14//! * `bpf`: Berkeley Packet Filter
15//! * `evm`: Ethereum VM
16//! * `m680x`: M680X
17//! * `m68k`: M68K
18//! * `mips`: MIPS
19//! * `mos65xx`: MOS65XX
20//! * `ppc`: PowerPC
21//! * `riscv`: RISC-V
22//! * `sh`: SH
23//! * `sparc`: SPARC
24//! * `sysz`: System z
25//! * `tms320c64x`: TMS320C64X
26//! * `tricore`: TriCore
27//! * `wasm`: WebAssembly
28//! * `x86`: x86 family (includes 16, 32, and 64 bit modes)
29//! * `xcore`: XCore
30//!
31//! For each architecture, *at least* the following types are defined (replace `ARCH` with
32//! architecture names shown above):
33//!
34//! * `enum ARCH_insn`: instruction ids
35//! * `enum ARCH_insn_group`: architecture-specific group ids
36//! * `enum ARCH_op_type`: instruction operand types ids
37//! * `enum ARCH_reg`<sup>1</sup>: register ids
38//! * `struct ARCH_op_mem`: operand referring to memory
39//! * `struct cs_ARCH_op`: instruction operand
40//! * `struct cs_ARCH`: instruction
41//!
42//! **Note**: documentation for functions/types was taken directly from
43//! [Capstone C headers][capstone headers].
44//!
45//! [capstone headers]: https://github.com/capstone-rust/capstone-sys/blob/master/capstone/include/capstone.h
46//! <sup>1</sup>: Defined as a ["constified" enum modules](https://docs.rs/bindgen/0.30.0/bindgen/struct.Builder.html#method.constified_enum_module)
47//!               because discriminant values are not unique. Rust requires discriminant values to be unique.
48
49// Suppress errors from Capstone names
50#![allow(non_upper_case_globals)]
51#![allow(non_camel_case_types)]
52#![allow(non_snake_case)]
53#![allow(improper_ctypes)]
54#![no_std]
55
56use core::ffi::c_int;
57
58// Bindings should be copied here
59include!(concat!(env!("OUT_DIR"), "/capstone.rs"));
60include!(concat!(env!("OUT_DIR"), "/capstone_archs_impl.rs"));
61
62pub const CS_SUPPORT_DIET: c_int = (cs_arch::CS_ARCH_ALL as c_int) + 1;
63pub const CS_SUPPORT_X86_REDUCE: c_int = (cs_arch::CS_ARCH_ALL as c_int) + 2;
64
65include!(concat!(env!("CARGO_MANIFEST_DIR"), "/common.rs"));