(module_hash: u32)
| 79 | } |
| 80 | |
| 81 | unsafe fn get_module_handle_custom_by_hash(module_hash: u32) -> isize { |
| 82 | let peb = get_peb(); |
| 83 | if peb.is_null() || (*peb).Ldr.is_null() { |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | let ldr = &*(*peb).Ldr; |
| 88 | let head = &ldr.InLoadOrderModuleList as *const LIST_ENTRY; |
| 89 | let mut current = (*head).Flink; |
| 90 | |
| 91 | while current != head as *mut LIST_ENTRY { |
| 92 | let entry = current as *mut LDR_DATA_TABLE_ENTRY; |
| 93 | |
| 94 | let base_dll_name = &(*entry).BaseDllName; |
| 95 | if !base_dll_name.Buffer.is_null() { |
| 96 | let len = base_dll_name.Length as usize / 2; |
| 97 | let slice = std::slice::from_raw_parts(base_dll_name.Buffer, len); |
| 98 | let dll_name_w = String::from_utf16_lossy(slice); |
| 99 | |
| 100 | if sdbm_hash_lower(dll_name_w.as_bytes()) == module_hash { |
| 101 | return (*entry).DllBase as isize; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | current = (*current).Flink; |
| 106 | } |
| 107 | |
| 108 | 0 |
| 109 | } |
| 110 | |
| 111 | pub unsafe fn load_library(dll_name: &[u8]) -> Result<isize, String> { |
| 112 | use windows_sys::Win32::System::LibraryLoader::LoadLibraryA; |
no test coverage detected