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)
| 604 | /// if ret != 0 {println!("ntdll.dll base address is 0x{:X}.", addr); |
| 605 | /// ``` |
| 606 | pub 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 | /// |
no test coverage detected