Skip to main content

idakit_sys/
lib.rs

1//! <p align="center">
2//!   <a href="https://github.com/Xevion/idakit/actions/workflows/ci.yml"><img src="https://github.com/Xevion/idakit/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
3//!   <a href="https://crates.io/crates/idakit-sys"><img src="https://img.shields.io/crates/v/idakit-sys.svg" alt="crates.io"></a>
4//!   <a href="https://docs.rs/idakit-sys"><img src="https://img.shields.io/docsrs/idakit-sys" alt="docs.rs"></a>
5//!   <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
6//!   <img src="https://img.shields.io/badge/MSRV-1.88-blue.svg" alt="MSRV">
7//! </p>
8//!
9//! Raw FFI bindings to IDA's idalib runtime and the idakit C++ facade.
10//!
11//! `idakit-sys` is the unsafe foundation under [`idakit`](https://docs.rs/idakit), which most users
12//! want instead: it wraps these bindings in a safe, idiomatic API. Reach here directly only to call
13//! a raw symbol the higher layer does not yet expose.
14//!
15//! # Surface
16//!
17//! The declarations are split into per-domain source modules (`runtime`, `bytes`, `function_flags`,
18//! `instruction`, `bridge_visitors`, ...) that mirror the facade's translation units, but every item
19//! is re-exported flat at the crate root, so the public surface is a single namespace
20//! (`idakit_sys::guarded_open`, `idakit_sys::CtreeVisitor`), not a module hierarchy. Three kinds
21//! of item live here:
22//!
23//! - **Raw C bindings**: `extern "C"` declarations of the facade's own functions (`guarded_open`,
24//!   `get_bytes_into`, ...) sharing the flat namespace with the idalib/IDA symbols they sit beside
25//!   (`open_database`, `set_name`), plus the `#[repr(C)]` structs and sentinel constants they
26//!   exchange.
27//! - **`cxx` bridges**: the spec-generated bridge (from the `idakit-sys-codegen` engine) and its
28//!   hand-written companions, returning structured values, owning handles as `UniquePtr<T>`, or
29//!   driving a walk through an opaque visitor ([`CtreeVisitor`], [`TypeWalkVisitor`]).
30//! - **A typed flag layer**: the one deliberate exception to "raw declarations only". OR-able bit
31//!   masks that also cross as FFI fields become `bitflags` types ([`SegmentPermissions`], [`FlowFlags`],
32//!   [`FrameVarFlags`], [`FlowChartFlags`], [`BinSearchFlags`]), and closed return-code sets become
33//!   validated `num_enum` enums ([`SigWriteCode`], [`TypeApplyCode`]); both stay sound at the
34//!   boundary and spare every caller a hand-rolled bit test. Safe idiomatic wrappers still belong in
35//!   [`idakit`](https://docs.rs/idakit).
36//!
37//! # SDK-name aliases
38//!
39//! Every binding carries `#[doc(alias)]` tags for its IDA SDK spelling, so a rustdoc search
40//! resolves a name like `SEGPERM_READ`, `FC_NOEXT`, or `open_database` to the binding. Aliases
41//! are per crate: `idakit_sys` carries the raw-binding and SDK names, [`idakit`](https://docs.rs/idakit)
42//! carries the idiomatic wrappers.
43//!
44//! # Buffer conventions
45//!
46//! Functions that accept `(*mut c_char, cap: usize)` copy the value into the
47//! caller-supplied buffer and NUL-terminate within `cap` bytes. The return value
48//! is the full source length, which may exceed `cap` when the output was
49//! truncated. A negative return value means the query failed (missing symbol,
50//! null handle, etc.).
51//!
52//! # Owned handles
53//!
54//! Opaque owned handles cross as cxx `UniquePtr<T>` (`CompiledBinpat`, `CFunc`, `TInfo`), freed by
55//! cxx's deleter on drop. Any handle still passed as a raw `*mut c_void` is paired with an explicit
56//! dispose call; using one after disposal is undefined behaviour.
57//!
58//! # License
59//!
60//! MIT. The IDA SDK and runtime are proprietary to Hex-Rays; these bindings link against your own
61//! install and redistribute none of it.
62
63/// IDA's effective address (`ea_t`), compiled `__EA64__`.
64pub type Address = u64;
65/// The invalid-address sentinel (`BADADDR`); every `Address`-returning facade call uses it for
66/// "no address".
67pub const BADADDR: Address = u64::MAX;
68
69mod bridge_cfunc;
70mod bridge_gen;
71mod bridge_probe;
72mod bridge_probe_ext;
73mod bridge_qvec;
74mod bridge_visitors;
75mod bytes;
76mod cfg_flags;
77mod frame_flags;
78mod function_flags;
79mod instruction;
80mod name;
81mod name_flags;
82mod netnode;
83mod runtime;
84mod segment_flags;
85mod strings;
86mod ty_build;
87
88#[doc(hidden)]
89pub use bridge_cfunc::*;
90pub use bridge_gen::*;
91#[doc(hidden)]
92pub use bridge_probe::*;
93#[doc(hidden)]
94pub use bridge_probe_ext::*;
95#[doc(hidden)]
96pub use bridge_qvec::*;
97pub use bridge_visitors::*;
98pub use bytes::*;
99pub use cfg_flags::*;
100pub use frame_flags::*;
101pub use function_flags::*;
102pub use instruction::*;
103pub use name::*;
104pub use name_flags::*;
105pub use netnode::*;
106pub use runtime::*;
107pub use segment_flags::*;
108pub use strings::*;
109pub use ty_build::*;