HookChain

Struct HookChain 

Source
pub struct HookChain<A: Architecture> { /* private fields */ }
Expand description

hook chain for multiple hooks on one target

manages a chain of hooks on a single function. hooks are called in priority order (lower priority first). each hook receives a trampoline to call the next hook in the chain.

Implementations§

Source§

impl<A: Architecture> HookChain<A>

Source

pub fn new(target: usize) -> Result<Self>

create a new hook chain on target function

this analyzes the target but does not install any hooks yet.

Source

pub fn add(&mut self, detour: usize, priority: i32) -> Result<usize>

add a hook to the chain

returns the trampoline address for calling the next hook in chain. lower priority values are called first.

Source

pub fn remove(&mut self, detour: usize) -> Result<bool>

remove a hook from the chain by detour address

returns true if the hook was found and removed.

Source

pub fn original(&self) -> Option<usize>

get the trampoline for calling the original function

this is the trampoline of the last entry in the chain.

Source

pub fn len(&self) -> usize

get number of hooks in the chain

Source

pub fn is_empty(&self) -> bool

check if chain is empty

Source

pub fn target(&self) -> usize

get target address

Source

pub fn restore(self) -> Result<()>

restore original function and drop all hooks

Trait Implementations§

Source§

impl<A: Architecture> Drop for HookChain<A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<A> Freeze for HookChain<A>

§

impl<A> RefUnwindSafe for HookChain<A>
where A: RefUnwindSafe,

§

impl<A> Send for HookChain<A>
where A: Send,

§

impl<A> Sync for HookChain<A>
where A: Sync,

§

impl<A> Unpin for HookChain<A>
where A: Unpin,

§

impl<A> UnwindSafe for HookChain<A>
where A: UnwindSafe,

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.