MCPcopy Create free account
hub / github.com/Do0ks/GSpots / GetVersionFromProcessMemory

Function GetVersionFromProcessMemory

UEVersionScanner/UEVersionScanner.cpp:116–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116std::string GetVersionFromProcessMemory(HANDLE hProcess) {
117 HMODULE hMod;
118 DWORD cbNeeded;
119 if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
120 MODULEINFO modInfo = { 0 };
121 if (GetModuleInformation(hProcess, hMod, &modInfo, sizeof(modInfo))) {
122 std::vector<char> buffer(modInfo.SizeOfImage);
123 SIZE_T bytesRead;
124 if (ReadProcessMemory(hProcess, modInfo.lpBaseOfDll, buffer.data(), modInfo.SizeOfImage, &bytesRead)) {
125 std::vector<std::string> markers = { "Unreal Engine 4.", "Unreal Engine 5.", "FEngineVersion", "EngineVersion" };
126 for (const auto& marker : markers) {
127 size_t markerLen = marker.length();
128 for (size_t i = 0; i < buffer.size() - markerLen; i++) {
129 if (memcmp(buffer.data() + i, marker.c_str(), markerLen) == 0) {
130 std::string found(marker);
131 size_t maxExtra = 32;
132 size_t j = i + markerLen;
133 while (j < buffer.size() && (j - (i + markerLen)) < maxExtra && isprint(buffer[j])) {
134 found.push_back(buffer[j]);
135 j++;
136 }
137 return found;
138 }
139 }
140 }
141 }
142 }
143 }
144 return "";
145}
146
147bool IsProcessRunning(const std::string& exeName, DWORD& processID) {
148 HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

Callers 1

GetUnrealEngineVersionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected