| 329 | } |
| 330 | |
| 331 | PVOID GetSystemModuleBase(LPCSTR moduleName) { |
| 332 | |
| 333 | PVOID moduleBase = NULL; |
| 334 | ULONG info = 0; |
| 335 | |
| 336 | NTSTATUS status = ZwQuerySystemInformation(SystemModuleInformation, 0, info, &info); |
| 337 | |
| 338 | if (!info) { |
| 339 | return moduleBase; |
| 340 | } |
| 341 | |
| 342 | PRTL_PROCESS_MODULES modules = (PRTL_PROCESS_MODULES)ExAllocatePoolWithTag(NonPagedPool, info, 0x89109929301); |
| 343 | |
| 344 | status = ZwQuerySystemInformation(SystemModuleInformation, modules, info, &info); |
| 345 | |
| 346 | if (!NT_SUCCESS(status)) { |
| 347 | return moduleBase; |
| 348 | } |
| 349 | |
| 350 | PRTL_PROCESS_MODULE_INFORMATION module = modules->Modules; |
| 351 | |
| 352 | |
| 353 | if (modules->NumberOfModules > 0) { |
| 354 | |
| 355 | if (!moduleName) { |
| 356 | moduleBase = modules->Modules[0].ImageBase; |
| 357 | } |
| 358 | else { |
| 359 | |
| 360 | for (auto i = 0; i < modules->NumberOfModules; i++) { |
| 361 | printf("module[i].FullPathName: %s", module[i].FullPathName); |
| 362 | if (!strcmp((CHAR*)module[i].FullPathName, moduleName)) { |
| 363 | moduleBase = module[i].ImageBase; |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | if (modules) { |
| 370 | ExFreePoolWithTag(modules, 0x89109929301); |
| 371 | } |
| 372 | |
| 373 | return moduleBase; |
| 374 | } |
| 375 | |
| 376 | } |
no outgoing calls
no test coverage detected