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

Method RandomizeModuleName

Core/Preventions.cpp:8–39  ·  view source on GitHub ↗

RandomizeModuleName - Changes the program's main module name (in memory) to a random string returns true on success */

Source from the content-addressed store, hash-verified

6 returns true on success
7*/
8bool Preventions::RandomizeModuleName()
9{
10 bool success = false;
11
12 int moduleNameSize = (int)wcslen(_MAIN_MODULE_NAME_W);
13
14 if (moduleNameSize == 0) //this will only hit if _MAIN_MODULE_NAME_W definition is set to an empty string
15 {
16 Logger::logf(Err, "string length of definition _MAIN_MODULE_NAME_W was 0 @ Preventions::RandomizeModuleName");
17 return false;
18 }
19
20 wstring newModuleName = Utility::GenerateRandomWString(moduleNameSize); //intentionally set to -2 to trip up external programs like CE from enumerating dlls & symbols
21
22 if (Process::ChangeModuleName(_MAIN_MODULE_NAME_W, newModuleName)) //in addition to changing export function names, we can also modify the names of loaded modules/libraries.
23 {
24 success = true;
25
26 Process::SetExecutableModuleName(newModuleName);
27
28 ProcessData::MODULE_DATA mod = Process::GetModuleInfo(newModuleName.c_str());
29
30 if (mod.hModule != 0)
31 {
32 this->integrityChecker->AddToWhitelist(mod);
33 }
34
35 Logger::logfw(Info, L"Changed module name to: %s\n", newModuleName.c_str());
36 }
37
38 return success;
39}
40
41/*
42 DeployBarrier - Launches various attack prevention techniques

Callers

nothing calls this directly

Calls 1

AddToWhitelistMethod · 0.80

Tested by

no test coverage detected