Struct minhook::StaticHook
[−]
[src]
pub struct StaticHook<T: Function> { // some fields omitted }
A hook with a static lifetime.
This hook can only be constructed using the static_hooks!
macro. It has one of the
following forms:
#[ATTR]* pub? impl HOOK_VAR_NAME for PATH::TO::TARGET: FN_TYPE; #[ATTR]* pub? impl HOOK_VAR_NAME for "FUNCTION" in "MODULE": FN_TYPE;
Before accessing this hook it is required to call initialize()
. Accessing the hook
before initializing or trying to initialize the hook more than once will result in a panic.
Methods
impl<T: Function> StaticHook<T>
[src]
fn trampoline(&self) -> T
Returns a reference to the trampoline function.
unsafe fn initialize<F>(&self, closure: F) -> Result<()> where F: Fn<T::Args, Output=T::Output> + Sync + 'static
Initialize and install the underlying hook using a detour closure.
Panics
Panics if the hook was already initialized.
Safety
See documentation for Hook::create()
and
Hook::create_api()
Methods from Deref<Target=Hook<T>>
fn trampoline(&self) -> T::Unsafe
Returns a pointer to the trampoline function.
Calling the returned function is unsafe because it will point to invalid memory after the hook is destroyed.
fn enable(&self) -> Result<()>
Enables this hook.
Consider using a HookQueue
if you want to enable/disable a large amount of hooks at once.
fn disable(&self) -> Result<()>
Disables this hook.
Consider using a HookQueue
if you want to enable/disable a large amount of hooks at once.