wraith/manipulation/inline_hook/asm/mod.rs
1//! Assembly instruction encoding and decoding utilities
2//!
3//! This module provides low-level instruction encoding primitives used
4//! by the hooking framework for generating hook stubs and trampolines.
5//!
6//! # iced-x86 Integration
7//!
8//! When the `inline-hook` feature is enabled, this module uses iced-x86
9//! for comprehensive instruction decoding and relocation. This provides:
10//!
11//! - Full x86/x64 instruction set support
12//! - Proper handling of all relative addressing modes
13//! - RIP-relative memory operand relocation
14//! - Short-to-long jump expansion
15//! - Conditional branch handling
16//!
17//! # Example
18//!
19//! ```ignore
20//! use wraith::manipulation::inline_hook::asm::{
21//! iced_decoder::{InstructionDecoder, decode_one},
22//! iced_relocator::{InstructionRelocator, relocate_one},
23//! };
24//!
25//! // decode an instruction
26//! let decoded = decode_one(0x1000, &[0xE9, 0x00, 0x01, 0x00, 0x00]).unwrap();
27//! println!("Length: {}, Relative: {}", decoded.length, decoded.is_relative);
28//!
29//! // relocate an instruction
30//! let result = relocate_one(&[0xE9, 0x00, 0x01, 0x00, 0x00], 0x1000, 0x2000);
31//! assert!(result.success);
32//! ```
33
34pub mod decoder;
35pub mod encoder;
36pub mod iced_decoder;
37pub mod iced_relocator;
38
39pub use decoder::{decode_instruction, InstructionInfo};
40pub use encoder::Encoder;
41
42// re-export iced-x86 based types for convenience
43pub use iced_decoder::{
44 DecodedInstruction, InstructionDecoder,
45 decode_one, find_instruction_boundary, uses_relative_addressing,
46};
47pub use iced_relocator::{
48 RelocationResult, InstructionRelocator,
49 relocate_one, relocate_block, instruction_needs_relocation,
50};