pub struct MacroHook(/* private fields */);Methods from Deref<Target = Hook<'static>>§
Sourcepub unsafe fn apply_hook(&mut self) -> Result<()>
pub unsafe fn apply_hook(&mut self) -> Result<()>
Examples found in repository?
examples/hook_puts.rs (line 28)
24fn main() {
25 let mut hook = unsafe { Hook::by_name(None, c"puts", hooked_puts as *mut u8).unwrap() };
26
27 unsafe {
28 hook.apply_hook().unwrap();
29 }
30
31 #[cfg(target_os = "linux")]
32 unsafe {
33 libc::puts(c"Am i hooked?".as_ptr());
34 }
35}More examples
examples/hook_msgboxa.rs (line 55)
42fn main() {
43 let mut hook = unsafe {
44 Hook::by_name(
45 Some(c"user32.dll"),
46 c"MessageBoxA",
47 hook_destination as *mut _,
48 )
49 .unwrap()
50 };
51
52 println!("Applying hook");
53
54 unsafe {
55 hook.apply_hook().unwrap();
56 MessageBoxA(
57 std::ptr::null_mut(),
58 c"Am i hooked?".as_ptr(),
59 c"hooked-rs".as_ptr(),
60 0,
61 );
62 }
63
64 unsafe {
65 hook.remove_hook().unwrap();
66 MessageBoxA(
67 std::ptr::null_mut(),
68 c"Not hooked anymore".as_ptr(),
69 c"hooked-rs".as_ptr(),
70 0,
71 );
72 }
73}Sourcepub unsafe fn remove_hook(&mut self) -> Result<()>
pub unsafe fn remove_hook(&mut self) -> Result<()>
Examples found in repository?
examples/hook_msgboxa.rs (line 65)
42fn main() {
43 let mut hook = unsafe {
44 Hook::by_name(
45 Some(c"user32.dll"),
46 c"MessageBoxA",
47 hook_destination as *mut _,
48 )
49 .unwrap()
50 };
51
52 println!("Applying hook");
53
54 unsafe {
55 hook.apply_hook().unwrap();
56 MessageBoxA(
57 std::ptr::null_mut(),
58 c"Am i hooked?".as_ptr(),
59 c"hooked-rs".as_ptr(),
60 0,
61 );
62 }
63
64 unsafe {
65 hook.remove_hook().unwrap();
66 MessageBoxA(
67 std::ptr::null_mut(),
68 c"Not hooked anymore".as_ptr(),
69 c"hooked-rs".as_ptr(),
70 0,
71 );
72 }
73}Trait Implementations§
impl Send for MacroHook
impl Sync for MacroHook
Auto Trait Implementations§
impl Freeze for MacroHook
impl RefUnwindSafe for MacroHook
impl Unpin for MacroHook
impl UnsafeUnpin for MacroHook
impl UnwindSafe for MacroHook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more