pub struct HookGuard<A: Architecture> { /* private fields */ }Expand description
RAII guard for an installed inline hook
when dropped, automatically restores the original function bytes
unless leak() was called.
Implementations§
Source§impl<A: Architecture> HookGuard<A>
impl<A: Architecture> HookGuard<A>
Sourcepub fn trampoline(&self) -> Option<usize>
pub fn trampoline(&self) -> Option<usize>
get the trampoline address (call this to invoke the original function)
returns None if no trampoline was allocated
Sourcepub fn original_bytes(&self) -> &[u8] ⓘ
pub fn original_bytes(&self) -> &[u8] ⓘ
get the original bytes that were overwritten
Sourcepub fn will_auto_restore(&self) -> bool
pub fn will_auto_restore(&self) -> bool
check if auto-restore is enabled
Sourcepub fn set_auto_restore(&mut self, restore: bool)
pub fn set_auto_restore(&mut self, restore: bool)
set whether to auto-restore on drop
Sourcepub fn leak(self)
pub fn leak(self)
disable auto-restore and keep the hook active permanently
consumes the guard without restoring the original function. the trampoline memory is leaked and remains valid.
Sourcepub fn restore(self) -> Result<()>
pub fn restore(self) -> Result<()>
manually restore the original function
consumes the guard and restores the hooked function to its original state.
Trait Implementations§
Source§impl<A: Architecture> Drop for HookGuard<A>
impl<A: Architecture> Drop for HookGuard<A>
impl<A: Architecture> Send for HookGuard<A>
impl<A: Architecture> Sync for HookGuard<A>
Auto Trait Implementations§
impl<A> Freeze for HookGuard<A>
impl<A> RefUnwindSafe for HookGuard<A>where
A: RefUnwindSafe,
impl<A> Unpin for HookGuard<A>where
A: Unpin,
impl<A> UnwindSafe for HookGuard<A>where
A: UnwindSafe,
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