MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / FillModuleList

Method FillModuleList

Process/Process.cpp:493–539  ·  view source on GitHub ↗

FillModuleList - fills the `ModuleList` class member with a list of module information returns true on success */

Source from the content-addressed store, hash-verified

491 returns true on success
492*/
493bool Process::FillModuleList()
494{
495 HMODULE hModules[512];
496 DWORD cbNeeded = 0;
497
498 if (EnumProcessModules(GetCurrentProcess(), hModules, sizeof(hModules), &cbNeeded))
499 {
500 Logger::logf(Err, "EnumProcessModules failed @ Process::FillModuleList");
501 return false;
502 }
503
504 if (this->ModuleList.size() >= (cbNeeded / sizeof(HMODULE))) //already filled previously?
505 return false;
506
507 for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
508 {
509 ProcessData::MODULE_DATA module;
510
511 TCHAR szModuleName[MAX_PATH];
512 MODULEINFO moduleInfo;
513
514 if (!GetModuleFileNameEx(GetCurrentProcess(), hModules[i], szModuleName, sizeof(szModuleName) / sizeof(TCHAR)))
515 {
516 Logger::logf(Warning, "GetModuleFileNameEx failed @ Process::FillModuleList: Error %d", GetLastError());
517 continue;
518 }
519
520 module.name = wstring(szModuleName);
521
522 module.hModule = hModules[i];
523
524 if (GetModuleInformation(GetCurrentProcess(), hModules[i], &moduleInfo, sizeof(moduleInfo)))
525 {
526 module.dllInfo.lpBaseOfDll = moduleInfo.lpBaseOfDll;
527 module.dllInfo.SizeOfImage = moduleInfo.SizeOfImage;
528 }
529 else
530 {
531 Logger::logf(Err, "Unable to parse module information @ Process::FillModuleList");
532 return false;
533 }
534
535 this->ModuleList.push_back(module);
536 }
537
538 return true;
539}
540
541/*
542 ModifyTLSCallbackPtr - changes the program TLS callback at runtime by modifying the data directory ptr (IMAGE_DIRECTORY_ENTRY_TLS)

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected