Skip to main content

Hook

Struct Hook 

Source
pub struct Hook { /* private fields */ }
Expand description

Represents an installed hook

Implementations§

Source§

impl Hook

Source

pub fn trampoline(&self) -> usize

Returns the address of the trampoline

§Returns
  • usize - The memory address of the trampoline
Source

pub unsafe fn trampoline_as<F>(&self) -> F
where F: Copy,

Returns the trampoline as a function pointer of the specified type

§Type Parameters
  • F - The function pointer type
§Returns
  • F - The trampoline cast to the function pointer type
Source

pub fn remove(self)

Removes the hook, restoring the original code

Source

pub unsafe fn call_original<T, F, R>(&self, callback: F) -> R
where T: Copy, F: FnOnce(T) -> R,

Calls the original function (via trampoline)

§Type Parameters
  • T - The function pointer type for the trampoline
  • F - The callback closure type
  • R - The return type
§Arguments
  • callback - A closure that takes the trampoline and returns a result
§Returns
  • R - The result of the callback
Source

pub fn verify_integrity(&self) -> bool

Verifies that the hook has not been tampered with

§Returns
  • bool - true if the hook is intact, false if it has been modified
Source

pub fn target(&self) -> usize

Returns the target address where the hook is installed

Auto Trait Implementations§

§

impl Freeze for Hook

§

impl RefUnwindSafe for Hook

§

impl Send for Hook

§

impl Sync for Hook

§

impl Unpin for Hook

§

impl UnsafeUnpin for Hook

§

impl UnwindSafe for Hook

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.