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

Method HasExportedFunction

Process/Process.cpp:50–88  ·  view source on GitHub ↗

HasExportedFunction checks a loaded module if it's exported `functionName`. Useful for anti-VEH debuggers, since these generally inject themselves into the process and export initialization routines returns true if `dllName` has `functionName` exported. */

Source from the content-addressed store, hash-verified

48 returns true if `dllName` has `functionName` exported.
49*/
50bool Process::HasExportedFunction(__in const string dllName, __in const string functionName)
51{
52 DWORD* dNameRVAs(0); //addresses of export names
53 _IMAGE_EXPORT_DIRECTORY* ImageExportDirectory;
54 unsigned long cDirSize;
55 _LOADED_IMAGE LoadedImage;
56 string sName;
57
58 bool bFound = false;
59
60 if (MapAndLoad(dllName.c_str(), NULL, &LoadedImage, TRUE, TRUE))
61 {
62 ImageExportDirectory = (_IMAGE_EXPORT_DIRECTORY*)ImageDirectoryEntryToData(LoadedImage.MappedAddress, false, IMAGE_DIRECTORY_ENTRY_EXPORT, &cDirSize);
63
64 if (ImageExportDirectory != NULL)
65 {
66 //load list of function names from DLL, the third parameter is an RVA to the data we want
67 dNameRVAs = (DWORD*)ImageRvaToVa(LoadedImage.FileHeader, LoadedImage.MappedAddress, ImageExportDirectory->AddressOfNames, NULL);
68
69 for (size_t i = 0; i < ImageExportDirectory->NumberOfNames; i++)
70 {
71 //get RVA
72 sName = (char*)ImageRvaToVa(LoadedImage.FileHeader, LoadedImage.MappedAddress, dNameRVAs[i], NULL);
73
74 if (strcmp(functionName.c_str(), sName.c_str()) == 0)
75 bFound = true;
76 }
77 }
78 else
79 Logger::log(Err, " ImageExportDirectory was NULL @ Process::HasExportedFunction");
80
81 UnMapAndLoad(&LoadedImage);
82 }
83 else
84 Logger::logf(Err, "MapAndLoad failed: %d @ Process::HasExportedFunction \n", GetLastError());
85
86
87 return bFound;
88}
89
90/*
91 GetSections - gathers a list of ProcessData::Section* from the current process

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected