Skip to main content

HookEngine

Struct HookEngine 

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

The core hooking engine Responsible for dispatching, registering, and removing hooks from the target process

Implementations§

Source§

impl HookEngine

Source

pub fn empty() -> HookEngine

Creates an empty HookEngine object

Source§

impl HookEngine

Source

pub fn new(process: HANDLE) -> Self

Creates a new HookEngine object with the specified process handle

Source

pub fn register_module(&mut self, name: &str, base: usize)

Registers a module to hook given its name and base address

Source

pub unsafe fn dispatch( &mut self, thread: HANDLE, ) -> CradleResult<DispatchResult>

Dispatches a hook on the given handle

§Safety

Calls get_thread_context to get the current registers. This function is unsafe and users should be aware of it

Source

pub unsafe fn dispatch_single_step( &mut self, thread: HANDLE, ) -> CradleResult<DispatchResult>

Dispatches a single breakpoint by writing it to the process

§Safety

Calls WriteProcessMemory under the hood (via FFI). This may be unsafe

Source

pub unsafe fn hook_export( &mut self, module: &str, export: &str, handler: HookHandler, ) -> CradleResult

Attempts to hook an exported function in the specified module Will return an error if a hook is already installed there

§Safety

Reads and writes data to the process’ memory, which is unsafe and should be treated as such

Source

pub unsafe fn unhook(&mut self, addr: usize) -> CradleResult

Attempts to unhook the breakpoint at the given address

§Safety

Calls WriteProcessMemory under the hood (via FFI). This may be unsafe

Source

pub unsafe fn unhook_all(&mut self) -> CradleResult

Attempts to unhook all existing hooks

§Safety

Calls self.unhook(addr) on each hook. This function is unsafe

Source

pub fn hooked_count(&self) -> usize

Returns the amount of breakpoints are currently installed

Trait Implementations§

Auto Trait Implementations§

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.