MCPcopy Create free account
hub / github.com/Kudaes/Split / load_library_a

Function load_library_a

dinvoke/src/lib.rs:606–624  ·  view source on GitHub ↗

Loads and retrieves a module's base address by dynamically calling LoadLibraryA. It will return either the module's base address or an Err with a descriptive error message. # Examples ``` let ret = dinvoke::load_library_a("ntdll.dll"); if ret != 0 {println!("ntdll.dll base address is 0x{:X}.", addr); ```

(module: &str)

Source from the content-addressed store, hash-verified

604/// if ret != 0 {println!("ntdll.dll base address is 0x{:X}.", addr);
605/// ```
606pub fn load_library_a(module: &str) -> i64 {
607
608 unsafe
609 {
610 let ret: Option<HINSTANCE>;
611 let func_ptr: data::LoadLibraryA;
612 let name = CString::new(module.to_string()).expect("CString::new failed");
613 let function_name = PSTR{0: name.as_ptr() as *mut u8};
614 let module_base_address = get_module_base_address(&lc!("kernel32.dll"));
615 dynamic_invoke!(module_base_address,&lc!("LoadLibraryA"),func_ptr,ret,function_name);
616
617 match ret {
618 Some(x) => return x.0 as i64,
619 None => return 0,
620 }
621
622 }
623
624}
625
626/// Closes a HANDLE object.
627///

Callers 1

get_forward_addressFunction · 0.85

Calls 1

get_module_base_addressFunction · 0.85

Tested by

no test coverage detected