Skip to main content

InstallerResultExt

Trait InstallerResultExt 

Source
pub trait InstallerResultExt: Sealed {
    // Required method
    unsafe fn retry_unchecked(self) -> Result<HookHandle, Error>;
}
Expand description

Extension trait for Result<HookHandle, Error>.

InstallerResultExt::retry_unchecked may be used when a function is not 16-byte aligned, which normally limits WinHook to only hooking the first 8 bytes of the prologue instead of 16.

InstallerResultExt::retry_unchecked is unsafe because it is NOT atomic. You must guarantee there is no possible data race (which would be Undefined Behavior).

Required Methods§

Source

unsafe fn retry_unchecked(self) -> Result<HookHandle, Error>

Opt-in to retry hooking unaligned functions in a non-atomic way.

§Examples
extern "C" fn meow() {
    println!("meow");
}

use winhook::{HookInstaller, InstallerResultExt};

let _handle = unsafe {
    HookInstaller::<unsafe extern "C" fn()>::for_function(meow)
        .enable(true)
        .install(|_| || println!("woof"))
        .retry_unchecked()
        .unwrap()
};
§Safety

Race conditions are UB. You must guarantee no concurrent modifications to the hooked function happen at the same time as this method runs.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl InstallerResultExt for Result<HookHandle, Error>

Implementors§