1use substrate;
2use std::ffi::c_void;
3
4static mut ORIGINAL: *mut c_void = std::ptr::null_mut();
5
6unsafe extern "C" fn my_hook() {
7 println!("Hook executed!");
8}
9
10fn main() {
11 println!("=== Multi-Architecture Hook Example ===\n");
12
13 #[cfg(target_arch = "x86_64")]
14 println!("Architecture: x86-64 (64-bit Intel/AMD)");
15
16 #[cfg(target_arch = "x86")]
17 println!("Architecture: x86 (32-bit Intel/AMD)");
18
19 #[cfg(target_arch = "arm")]
20 println!("Architecture: ARMv7 (32-bit ARM with Thumb)");
21
22 #[cfg(target_arch = "aarch64")]
23 println!("Architecture: ARM64/AArch64 (64-bit ARM)");
24
25 println!("\nThis example shows architecture-specific behavior.\n");
26
27 unsafe {
28 let target: *mut c_void = std::ptr::null_mut();
29
30 #[cfg(target_arch = "aarch64")]
31 {
32 println!("Using A64HookFunction for ARM64...");
33 substrate::A64HookFunction(
34 target,
35 my_hook as *mut c_void,
36 &mut ORIGINAL
37 );
38 }
39
40 #[cfg(not(target_arch = "aarch64"))]
41 {
42 println!("Using MSHookFunction...");
43 substrate::MSHookFunction(
44 target,
45 my_hook as *mut c_void,
46 &mut ORIGINAL
47 );
48 }
49
50 println!("Hook API called successfully!");
51 println!("\nNote: This example uses null pointers for demonstration.");
52 println!("In real usage, provide valid function addresses.");
53 }
54}