Skip to main content

InlineHooksBuilder

Struct InlineHooksBuilder 

Source
pub struct InlineHooksBuilder<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> InlineHooksBuilder<'a>

Source

pub fn new(lib_name: &'a str) -> Self

Source

pub fn hook_install<F: Copy>(self, symbol: &str, detour: F) -> Self

Source

pub fn hook_install_alias<F: Copy>( self, symbol: &str, alias: &str, detour: F, ) -> Self

Source

pub fn hook<F: Copy>(self, symbol: &str, detour: F) -> Self

Source

pub fn hook_alias<F: Copy>(self, symbol: &str, alias: &str, detour: F) -> Self

Examples found in repository?
examples/inline_hooks_builder.rs (lines 15-20)
10fn main() -> dobby_rs_framework::Result<()> {
11    // EN/CN: Keep this example tiny: install, then uninstall.
12
13    #[cfg(unix)]
14    let builder: InlineHooksBuilder<'_> = inline_hooks(common::DEMO_LIB)
15        .hook_alias(
16            "puts",
17            "puts",
18            common::detours::unix::detour_puts
19                as unsafe extern "C" fn(*const core::ffi::c_char) -> core::ffi::c_int,
20        )
21        .extra_action_fn(|m| common::resolve_and_print(m, "puts"));
22    #[cfg(unix)]
23    let mut session: HookSession = unsafe { builder.install()? };
24
25    #[cfg(windows)]
26    let builder: InlineHooksBuilder<'_> = inline_hooks(common::DEMO_LIB)
27        .hook_alias(
28            "GetTickCount",
29            "GetTickCount",
30            common::detours::windows::detour_get_tick_count as unsafe extern "system" fn() -> u32,
31        )
32        .extra_action_fn(|m| common::resolve_and_print(m, "GetTickCount"));
33    #[cfg(windows)]
34    let mut session: HookSession = unsafe { builder.install()? };
35
36    unsafe { session.unhook_all()? };
37    Ok(())
38}
Source

pub fn extra_action<F>(self, action: F) -> Self
where F: Fn(&ModuleHandle) -> Result<()> + Send + Sync + 'a,

Source

pub fn extra_action_fn(self, action: fn(&ModuleHandle) -> Result<()>) -> Self

Examples found in repository?
examples/inline_hooks_builder.rs (line 21)
10fn main() -> dobby_rs_framework::Result<()> {
11    // EN/CN: Keep this example tiny: install, then uninstall.
12
13    #[cfg(unix)]
14    let builder: InlineHooksBuilder<'_> = inline_hooks(common::DEMO_LIB)
15        .hook_alias(
16            "puts",
17            "puts",
18            common::detours::unix::detour_puts
19                as unsafe extern "C" fn(*const core::ffi::c_char) -> core::ffi::c_int,
20        )
21        .extra_action_fn(|m| common::resolve_and_print(m, "puts"));
22    #[cfg(unix)]
23    let mut session: HookSession = unsafe { builder.install()? };
24
25    #[cfg(windows)]
26    let builder: InlineHooksBuilder<'_> = inline_hooks(common::DEMO_LIB)
27        .hook_alias(
28            "GetTickCount",
29            "GetTickCount",
30            common::detours::windows::detour_get_tick_count as unsafe extern "system" fn() -> u32,
31        )
32        .extra_action_fn(|m| common::resolve_and_print(m, "GetTickCount"));
33    #[cfg(windows)]
34    let mut session: HookSession = unsafe { builder.install()? };
35
36    unsafe { session.unhook_all()? };
37    Ok(())
38}
Source

pub unsafe fn install(self) -> Result<HookSession>

Examples found in repository?
examples/inline_hooks_builder.rs (line 23)
10fn main() -> dobby_rs_framework::Result<()> {
11    // EN/CN: Keep this example tiny: install, then uninstall.
12
13    #[cfg(unix)]
14    let builder: InlineHooksBuilder<'_> = inline_hooks(common::DEMO_LIB)
15        .hook_alias(
16            "puts",
17            "puts",
18            common::detours::unix::detour_puts
19                as unsafe extern "C" fn(*const core::ffi::c_char) -> core::ffi::c_int,
20        )
21        .extra_action_fn(|m| common::resolve_and_print(m, "puts"));
22    #[cfg(unix)]
23    let mut session: HookSession = unsafe { builder.install()? };
24
25    #[cfg(windows)]
26    let builder: InlineHooksBuilder<'_> = inline_hooks(common::DEMO_LIB)
27        .hook_alias(
28            "GetTickCount",
29            "GetTickCount",
30            common::detours::windows::detour_get_tick_count as unsafe extern "system" fn() -> u32,
31        )
32        .extra_action_fn(|m| common::resolve_and_print(m, "GetTickCount"));
33    #[cfg(windows)]
34    let mut session: HookSession = unsafe { builder.install()? };
35
36    unsafe { session.unhook_all()? };
37    Ok(())
38}

Auto Trait Implementations§

§

impl<'a> Freeze for InlineHooksBuilder<'a>

§

impl<'a> !RefUnwindSafe for InlineHooksBuilder<'a>

§

impl<'a> !Send for InlineHooksBuilder<'a>

§

impl<'a> !Sync for InlineHooksBuilder<'a>

§

impl<'a> Unpin for InlineHooksBuilder<'a>

§

impl<'a> UnsafeUnpin for InlineHooksBuilder<'a>

§

impl<'a> !UnwindSafe for InlineHooksBuilder<'a>

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.