Skip to content

Commit

Permalink
docs: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darfink committed Jun 9, 2019
1 parent 073e0e7 commit 1ba909e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/detours/raw.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand Down
6 changes: 3 additions & 3 deletions src/detours/statik.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ use crate::{GenericDetour, Function};
/// ```
///
/// To define a static detour, use the [static_detour](./macro.static_detour.html) macro.
///
///
/// # Example
///
/// ```rust
/// use std::error::Error;
/// use detour::static_detour;
///
/// static_detour! {
/// static Test: /* extern "X" */ fn(i32) -> i32;
/// static Test: fn(i32) -> i32;
/// }
///
/// fn add5(val: i32) -> i32 {
Expand Down Expand Up @@ -111,7 +111,7 @@ impl<T: Function> StaticDetour<T> {
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<C>(&self, closure: C)
where
C: Fn<T::Arguments, Output = T::Output> + Send + 'static,
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::fmt;
/// The result of a detour operation.
pub type Result<T> = ::std::result::Result<T, Error>;

/// A representation of all possible errors.
#[derive(Debug)]
pub enum Error {
/// The address for the target and detour are identical
Expand Down
17 changes: 7 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,25 +29,22 @@
//!
//! - [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
//! enforced when invoking the original target.
//!
//! - [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
//!
Expand Down
12 changes: 7 additions & 5 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -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];
/// }
/// ```
///
Expand All @@ -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() { }
/// ```
Expand Down

0 comments on commit 1ba909e

Please sign in to comment.