hooking 0.8.0

cross platform detour / hooking library in rust
Documentation
use thiserror::Error;

/// Result alias for memory operations.
pub type Result<T> = std::result::Result<T, MemoryError>;

/// Something went wrong allocating, mapping, querying, or protecting memory.
#[derive(Debug, Error)]
pub enum MemoryError {
    /// A mutex guarding arena or alias state was poisoned by a panic.
    #[error("A lock was poisoned by a panic while it was held")]
    PoisonedLock,

    /// The platform page size could not be determined.
    #[error("Failed to retrieve page size")]
    NoPageSize,

    /// A request for fresh pages from the OS failed.
    #[error("Failed to allocate page memory")]
    CantAllocate,

    /// Setting up the two views (read/write and read/execute) of dual-mapped
    /// memory failed.
    #[error("Failed to map dual-view memory")]
    CantMapMemory,

    /// The current protection of the page at this address could not be read.
    #[error("Failed to query memory protection. Address: {0:x}")]
    CantQueryProtection(usize),

    /// The protection of the page at this address could not be changed.
    #[error("Failed to set memroy protection. Address: {0:x}")]
    CantSetMemoryProtection(usize),

    /// An allocation asked for more memory than is available.
    #[error("Not enough memory left in heap. Needs: {needs} | Has: {has}")]
    NoMemory {
        /// Bytes requested.
        needs: usize,
        /// Bytes available.
        has: usize,
    },

    /// No loaded module with this name could be found.
    #[error("Cant find module with name {0}")]
    CantFindModule(String),

    /// No symbol with this name could be found in the target module.
    #[error("Cant find symbol with name {0}")]
    CantFindSymbol(String),

    /// An address falls outside any region this code can act on.
    #[error("Address is not usable for this situation")]
    BadAdress(*const std::ffi::c_void),
}