(dll_name: &[u8])
| 109 | } |
| 110 | |
| 111 | pub unsafe fn load_library(dll_name: &[u8]) -> Result<isize, String> { |
| 112 | use windows_sys::Win32::System::LibraryLoader::LoadLibraryA; |
| 113 | use rsl_macros::obfuscation_noise_macro; |
| 114 | use obfstr::obfstr; |
| 115 | |
| 116 | let name_str = String::from_utf8_lossy(dll_name); |
| 117 | let name_trimmed = name_str.trim_matches(char::from(0)); |
| 118 | let module_hash = sdbm_hash_lower(name_trimmed.as_bytes()); |
| 119 | |
| 120 | let dll = get_module_handle_custom_by_hash(module_hash); |
| 121 | if dll != 0 { |
| 122 | obfuscation_noise_macro!(); |
| 123 | #[cfg(feature = "debug")] |
| 124 | crate::utils::print_message(&format!("{} {}", obfstr!("Get module handle by custom GetModuleHandle:"), name_trimmed)); |
| 125 | Ok(dll) |
| 126 | } else { |
| 127 | let dll = LoadLibraryA(dll_name.as_ptr() as *const u8); |
| 128 | if dll == 0 { |
| 129 | Err(obfstr!("LoadLibraryA failed").to_string()) |
| 130 | } else { |
| 131 | obfuscation_noise_macro!(); |
| 132 | #[cfg(feature = "debug")] |
| 133 | crate::utils::print_message(&format!("{} {}", obfstr!("Module loaded by LoadLibraryA:"), name_trimmed)); |
| 134 | Ok(dll) |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | #[repr(C)] |
| 140 | struct IMAGE_DOS_HEADER { |
no test coverage detected