HookBuilder

Struct HookBuilder 

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

type-state hook builder

ensures hook creation follows the correct sequence: Uninitialized -> TargetSet -> DetourSet -> TrampolineAllocated -> TrampolineBuilt -> Ready

Implementations§

Source§

impl<A: Architecture> HookBuilder<A, Uninitialized>

Source

pub fn new() -> Self

create a new hook builder

Source

pub fn target(self, addr: usize) -> Result<HookBuilder<A, TargetSet>>

set the target function address

Source§

impl<A: Architecture> HookBuilder<A, TargetSet>

Source

pub fn get_target(&self) -> usize

get the target address

Source

pub fn detour(self, addr: usize) -> Result<HookBuilder<A, DetourSet>>

set the detour function address

Source§

impl<A: Architecture> HookBuilder<A, DetourSet>

Source

pub fn get_target(&self) -> usize

get the target address

Source

pub fn get_detour(&self) -> usize

get the detour address

Source

pub fn allocate_trampoline(self) -> Result<HookBuilder<A, TrampolineAllocated>>

analyze target and allocate trampoline

Source§

impl<A: Architecture> HookBuilder<A, TrampolineAllocated>

Source

pub fn get_target(&self) -> usize

get the target address

Source

pub fn prologue_size(&self) -> usize

get prologue size

Source

pub fn build_trampoline(self) -> Result<HookBuilder<A, TrampolineBuilt>>

build the trampoline

Source§

impl<A: Architecture> HookBuilder<A, TrampolineBuilt>

Source

pub fn get_target(&self) -> usize

get the target address

Source

pub fn trampoline(&self) -> usize

get the trampoline address

Source

pub fn prepare(self) -> Result<HookBuilder<A, Ready>>

generate hook stub and prepare for installation

Source§

impl<A: Architecture> HookBuilder<A, Ready>

Source

pub fn get_target(&self) -> usize

get the target address

Source

pub fn trampoline(&self) -> usize

get the trampoline address

Source

pub fn install(self) -> Result<HookGuard<A>>

install the hook

Trait Implementations§

Source§

impl<A: Architecture> Default for HookBuilder<A, Uninitialized>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<A, S> Freeze for HookBuilder<A, S>

§

impl<A, S> RefUnwindSafe for HookBuilder<A, S>

§

impl<A, S> Send for HookBuilder<A, S>
where A: Send, S: Send,

§

impl<A, S> Sync for HookBuilder<A, S>
where A: Sync, S: Sync,

§

impl<A, S> Unpin for HookBuilder<A, S>
where A: Unpin, S: Unpin,

§

impl<A, S> UnwindSafe for HookBuilder<A, S>
where A: UnwindSafe, S: 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.