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//! * `mips`: MIPS
15//! * `ppc`: PowerPC
16//! * `sparc`: SPARC
17//! * `sysz`: System z
18//! * `x86`: x86 family (includes 16, 32, and 64 bit modes)
19//! * `xcore`: XCore
20//!
21//! For each architecture, *at least* the following types are defined (replace `ARCH` with
22//! architecture names shown above):
23//!
24//! * `enum ARCH_insn`: instruction ids
25//! * `enum ARCH_insn_group`: architecture-specific group ids
26//! * `enum ARCH_op_type`: instruction operand types ids
27//! * `enum ARCH_reg`<sup>1</sup>: register ids
28//! * `struct ARCH_op_mem`: operand referring to memory
29//! * `struct cs_ARCH_op`: instruction operand
30//! * `struct cs_ARCH`: instruction
31//!
32//! **Note**: documentation for functions/types was taken directly from
33//! [Capstone C headers][capstone headers].
34//!
35//! [capstone headers]: https://github.com/capstone-rust/capstone-sys/blob/master/capstone/include/capstone.h
36//! <sup>1</sup>: Defined as a ["constified" enum modules](https://docs.rs/bindgen/0.30.0/bindgen/struct.Builder.html#method.constified_enum_module)
37//!               because discriminant values are not unique. Rust requires discriminant values to be unique.
38
39// Suppress errors from Capstone names
40#![allow(non_upper_case_globals)]
41#![allow(non_camel_case_types)]
42#![allow(non_snake_case)]
43#![allow(improper_ctypes)]
44#![no_std]
45
46extern crate libc;
47
48use libc::c_int;
49
50// Bindings should be copied here
51include!(concat!(env!("OUT_DIR"), "/capstone.rs"));
52include!(concat!(env!("OUT_DIR"), "/capstone_archs_impl.rs"));
53
54pub const CS_SUPPORT_DIET: c_int = (cs_arch::CS_ARCH_ALL as c_int) + 1;
55pub const CS_SUPPORT_X86_REDUCE: c_int = (cs_arch::CS_ARCH_ALL as c_int) + 2;
56
57include!(concat!(env!("CARGO_MANIFEST_DIR"), "/common.rs"));