MCPcopy Create free account
hub / github.com/Astronaut00/DoubleDataPointer / GetSystemModuleBase

Function GetSystemModuleBase

Driver/core.cpp:331–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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}

Callers 2

DriverEntryFunction · 0.85
FindBigPoolTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected