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
impl HookEngine
Sourcepub fn empty() -> HookEngine
pub fn empty() -> HookEngine
Creates an empty HookEngine object
Source§impl HookEngine
impl HookEngine
Sourcepub fn new(process: HANDLE) -> Self
pub fn new(process: HANDLE) -> Self
Creates a new HookEngine object with the specified process handle
Sourcepub fn register_module(&mut self, name: &str, base: usize)
pub fn register_module(&mut self, name: &str, base: usize)
Registers a module to hook given its name and base address
Sourcepub unsafe fn dispatch(
&mut self,
thread: HANDLE,
) -> CradleResult<DispatchResult>
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
Sourcepub unsafe fn dispatch_single_step(
&mut self,
thread: HANDLE,
) -> CradleResult<DispatchResult>
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
Sourcepub unsafe fn hook_export(
&mut self,
module: &str,
export: &str,
handler: HookHandler,
) -> CradleResult
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
Sourcepub unsafe fn unhook(&mut self, addr: usize) -> CradleResult
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
Sourcepub unsafe fn unhook_all(&mut self) -> CradleResult
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
Sourcepub fn hooked_count(&self) -> usize
pub fn hooked_count(&self) -> usize
Returns the amount of breakpoints are currently installed