diff --git a/src/detours/raw.rs b/src/detours/raw.rs index 418ce4b3..fbda3021 100644 --- a/src/detours/raw.rs +++ b/src/detours/raw.rs @@ -1,7 +1,7 @@ use crate::arch::Detour; use crate::error::Result; -/// A type-less wrapper around [Detour](./struct.Detour.html). +/// A raw detour. /// /// # Example /// diff --git a/src/detours/statik.rs b/src/detours/statik.rs index 0556e126..62a1601f 100644 --- a/src/detours/statik.rs +++ b/src/detours/statik.rs @@ -16,7 +16,7 @@ use crate::{GenericDetour, Function}; /// ``` /// /// To define a static detour, use the [static_detour](./macro.static_detour.html) macro. -/// +/// /// # Example /// /// ```rust @@ -24,7 +24,7 @@ use crate::{GenericDetour, Function}; /// use detour::static_detour; /// /// static_detour! { -/// static Test: /* extern "X" */ fn(i32) -> i32; +/// static Test: fn(i32) -> i32; /// } /// /// fn add5(val: i32) -> i32 { @@ -111,7 +111,7 @@ impl StaticDetour { unsafe { self.detour.load(Ordering::SeqCst).as_ref() }.map(|detour| detour.is_enabled()).unwrap_or(false) } - /// Changes the detour, regardless of whether the target is hooked or not. + /// Changes the detour, regardless of whether the hook is enabled or not. pub fn set_detour(&self, closure: C) where C: Fn + Send + 'static, diff --git a/src/error.rs b/src/error.rs index b627a778..56196cbb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,6 +6,7 @@ use std::fmt; /// The result of a detour operation. pub type Result = ::std::result::Result; +/// A representation of all possible errors. #[derive(Debug)] pub enum Error { /// The address for the target and detour are identical diff --git a/src/lib.rs b/src/lib.rs index 9deac024..1dd582df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ //! - Relative branches. //! - RIP relative operands. //! - Detects NOP-padding. -//! - Relay for large offsets (>2GB) +//! - Relay for large offsets (>2GB). //! - Supports hot patching. //! //! ## Detours @@ -29,7 +29,7 @@ //! //! - [Static](./struct.StaticDetour.html): A static & type-safe interface. //! Thanks to its static nature it can accept a closure as its detour, but is -//! limited to only one active detour at a time. +//! required to be statically defined at compile time. //! //! - [Generic](./struct.GenericDetour.html): A type-safe interface — the same //! prototype is enforced for both the target and the detour. It is also @@ -37,17 +37,14 @@ //! //! - [Raw](./struct.RawDetour.html): The underlying building block that the //! others types abstract upon. It has no type-safety and interacts with raw -//! pointers. It should be avoided unless the types used aren't known until -//! runtime. -//! -//! All detours dereferences to the [Detour](./struct.Detour.html) interface, -//! which exposes several methods, and enforces `Send + Sync`. +//! pointers. It should be avoided unless any types are references, or not +//! known until runtime. //! //! ## Features //! -//! - **nightly**: Enabled by default. Required for the static detours, due to -//! usage of *const_fn* & *unboxed_closures*. The feature also enables a more -//! extensive test suite. +//! - **nightly**: Enabled by default. Required for static detours, due to +//! usage of *const_fn* & *unboxed_closures*. +//! The feature also enables a more extensive test suite. //! //! ## Platforms //! diff --git a/src/macros.rs b/src/macros.rs index adacdf9f..6f50ff50 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,16 +1,15 @@ /// A macro for defining static, type-safe detours. /// /// This macro defines one or more [StaticDetour](./struct.StaticDetour.html)s. -/// Functions with references are not supported. /// /// # Syntax /// /// ```ignore /// static_detour! { -/// [pub] static NAME_1: [extern ["type"]] fn([argument]...) -> [ret]; -/// [pub] static NAME_2: [extern ["type"]] fn([argument]...) -> [ret]; +/// [pub] static NAME_1: [unsafe] [extern ["cc"]] fn([argument]...) [-> ret]; +/// [pub] static NAME_2: [unsafe] [extern ["cc"]] fn([argument]...) [-> ret]; /// ... -/// [pub] static NAME_N: [extern ["type"]] fn([argument]...) -> [ret]; +/// [pub] static NAME_N: [unsafe] [extern ["cc"]] fn([argument]...) [-> ret]; /// } /// ``` /// @@ -19,8 +18,11 @@ /// ```rust /// # use detour::static_detour; /// static_detour! { +/// // The simplest detour /// static Foo: fn(); -/// pub static PubFoo: extern "C" fn(i32) -> i32; +/// +/// // An unsafe public detour with a different calling convention +/// pub static PubFoo: unsafe extern "C" fn(i32) -> i32; /// } /// # fn main() { } /// ```