pub struct InlineHook<F: FnPtr> { /* private fields */ }Available on crate feature
inline only.Expand description
Implementations§
Source§impl<F: FnPtr> InlineHook<F>
impl<F: FnPtr> InlineHook<F>
Sourcepub fn with_enabled(target: F, detour: F, enable: bool) -> Result<Self, HRESULT>
pub fn with_enabled(target: F, detour: F, enable: bool) -> Result<Self, HRESULT>
Creates a new InlineHookGuard and immediately applies the hook.
§Arguments
enable: Whether to enable the hook immediately (true = enable, false = disable)target: Pointer to the target function to hookdetour: Pointer to the detour/hooked function
§Returns
Ok(InlineHookGuard)if hook creation succeedsHRESULTerror if hook creation fails
Sourcepub fn new_enabled(target: F, detour: F) -> Result<Self, HRESULT>
pub fn new_enabled(target: F, detour: F) -> Result<Self, HRESULT>
Sourcepub fn set_enabled(&mut self, enable: bool) -> HRESULT
pub fn set_enabled(&mut self, enable: bool) -> HRESULT
Sourcepub fn enable(&mut self) -> HRESULT
pub fn enable(&mut self) -> HRESULT
Enables the hook.
§Returns
Ok(())if the hook is enabled successfully (or already enabled)HRESULTerror if enabling fails
Sourcepub fn disable(&mut self) -> HRESULT
pub fn disable(&mut self) -> HRESULT
Disables the hook.
§Returns
Ok(())if the hook is disabled successfully (or not enabled)HRESULTerror if disabling fails
Sourcepub fn toggle(&mut self) -> HRESULT
pub fn toggle(&mut self) -> HRESULT
Toggles the hook state (enabled -> disabled, disabled -> enabled).
§Returns
Ok(())if toggle succeedsHRESULTerror if toggle fails
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if the hook is currently enabled.
Sourcepub fn is_target(&self, other: F) -> bool
pub fn is_target(&self, other: F) -> bool
Returns true if other is the same target function as this hook.
This is mainly for avoiding the warning if not using std::ptr::fn_addr_eq().
Sourcepub const fn detour(&self) -> F
pub const fn detour(&self) -> F
Returns the detour function that will be called when the hook is active.
Sourcepub const fn trampoline(&self) -> F
pub const fn trampoline(&self) -> F
Returns the trampoline function holding the original target implementation.
When the hook is enabled, calling target() redirects to detour(),
while trampoline() provides access to the original target functionality.
pub unsafe fn cast<F2: FnPtr>(&self) -> &InlineHook<F2>
pub unsafe fn cast_mut<F2: FnPtr>(&mut self) -> &mut InlineHook<F2>
pub unsafe fn cast_into<F2: FnPtr>(self) -> InlineHook<F2>
pub unsafe fn into_type_erased(self) -> InlineHook<fn()>
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for InlineHook<F>where
F: Freeze,
impl<F> RefUnwindSafe for InlineHook<F>
impl<F> Send for InlineHook<F>
impl<F> Sync for InlineHook<F>
impl<F> Unpin for InlineHook<F>
impl<F> UnsafeUnpin for InlineHook<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for InlineHook<F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more