pub struct HookWriter<'a, M: MemoryController, A: HookAssembler> { /* private fields */ }Implementations§
Source§impl HookWriter<'static, DefaultMemoryController, DefaultHookAssembler>
impl HookWriter<'static, DefaultMemoryController, DefaultHookAssembler>
Sourcepub const fn from_static() -> Self
pub const fn from_static() -> Self
Examples found in repository?
examples/write_hook_table.rs (line 27)
26fn main() {
27 let hook_writer = HookWriter::from_static();
28 let hook = unsafe {
29 hook_writer
30 .create_hook(
31 NonNull::new(add_two_numbers_together as *mut _).unwrap(),
32 NonNull::new(hook as *mut _).unwrap(),
33 )
34 .unwrap()
35 };
36
37 let HookData {
38 trampoline_data, ..
39 } = hook.data;
40
41 println!("about to run hook");
42
43 unsafe {
44 #[cfg(target_os = "linux")]
45 asm! {
46 "mov rdi, 6",
47 "mov rsi, 7",
48 "call {}",
49 in(reg)trampoline_data.as_ptr()
50 }
51 #[cfg(target_os = "windows")]
52 asm! {
53 "mov rcx, 6",
54 "mov rdx, 7",
55 "call {}",
56 in(reg)trampoline_data.as_ptr()
57 }
58 }
59}Source§impl<'a, M: MemoryController, A: HookAssembler> HookWriter<'a, M, A>
impl<'a, M: MemoryController, A: HookAssembler> HookWriter<'a, M, A>
pub const fn new(hook_heap: &'a HookHeap<M>, assembler: A) -> Self
pub unsafe fn create_hook_by_name( &self, module: Option<&CStr>, symbol: &CStr, destination: *mut u8, ) -> Result<Hook<'a, M>>
Sourcepub unsafe fn create_hook(
&self,
target: NonNull<c_void>,
destination: NonNull<c_void>,
) -> Result<Hook<'a, M>>
pub unsafe fn create_hook( &self, target: NonNull<c_void>, destination: NonNull<c_void>, ) -> Result<Hook<'a, M>>
Examples found in repository?
examples/write_hook_table.rs (lines 30-33)
26fn main() {
27 let hook_writer = HookWriter::from_static();
28 let hook = unsafe {
29 hook_writer
30 .create_hook(
31 NonNull::new(add_two_numbers_together as *mut _).unwrap(),
32 NonNull::new(hook as *mut _).unwrap(),
33 )
34 .unwrap()
35 };
36
37 let HookData {
38 trampoline_data, ..
39 } = hook.data;
40
41 println!("about to run hook");
42
43 unsafe {
44 #[cfg(target_os = "linux")]
45 asm! {
46 "mov rdi, 6",
47 "mov rsi, 7",
48 "call {}",
49 in(reg)trampoline_data.as_ptr()
50 }
51 #[cfg(target_os = "windows")]
52 asm! {
53 "mov rcx, 6",
54 "mov rdx, 7",
55 "call {}",
56 in(reg)trampoline_data.as_ptr()
57 }
58 }
59}pub unsafe fn write_hook_table( &self, target: NonNull<c_void>, destination_fn: NonNull<c_void>, ) -> Result<HookData<'a, M>>
Auto Trait Implementations§
impl<'a, M, A> Freeze for HookWriter<'a, M, A>where
A: Freeze,
impl<'a, M, A> RefUnwindSafe for HookWriter<'a, M, A>where
A: RefUnwindSafe,
M: RefUnwindSafe,
impl<'a, M, A> Send for HookWriter<'a, M, A>
impl<'a, M, A> Sync for HookWriter<'a, M, A>
impl<'a, M, A> Unpin for HookWriter<'a, M, A>where
A: Unpin,
impl<'a, M, A> UnsafeUnpin for HookWriter<'a, M, A>where
A: UnsafeUnpin,
impl<'a, M, A> UnwindSafe for HookWriter<'a, M, A>where
A: UnwindSafe,
M: RefUnwindSafe,
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