1use elf_loader::image::{SyntheticModule, SyntheticSymbol};
2use std::ffi::CStr;
3use windows_elf_loader::WinElfLoader;
4
5fn main() {
6 extern "sysv64" fn print(s: *const i8) {
7 let s = unsafe { CStr::from_ptr(s).to_str().unwrap() };
8 println!("{}", s);
9 }
10 let host = SyntheticModule::new(
12 "__host",
13 [SyntheticSymbol::function("print", print as *const ())],
14 );
15 let mut loader: WinElfLoader = WinElfLoader::new();
16 let liba = loader
18 .load_file(r".\crates\windows-elf-loader\example_dylib\liba.so")
19 .unwrap()
20 .relocator()
21 .scope([host])
22 .relocate()
23 .unwrap();
24 let f = unsafe { liba.get::<extern "sysv64" fn() -> i32>("a").unwrap() };
26 println!("{}", f());
27}