MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / getRunningGDPathWindows

Method getRunningGDPathWindows

Source/ResourcesLoadingLayer.cpp:163–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161
162
163std::string ResourcesLoadingLayer::getRunningGDPathWindows()
164{
165 DWORD aProcesses[1024], cbNeeded, cProcesses;
166 if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
167 {
168 return "";
169 }
170
171 cProcesses = cbNeeded / sizeof(DWORD);
172
173 for (unsigned int i = 0; i < cProcesses; i++)
174 {
175 if (DWORD processID = aProcesses[i]; processID != 0)
176 {
177 HANDLE processHandle = NULL;
178 TCHAR filename[MAX_PATH];
179 processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
180 if (processHandle != NULL)
181 {
182 if (GetModuleFileNameEx(processHandle, NULL, filename, MAX_PATH) != 0)
183 {
184 std::wstring str(filename);
185 if (str.find(L"GeometryDash.exe") != std::string::npos)
186 {
187 TerminateProcess(processHandle, 1); //doesnt seem to work?
188 CloseHandle(processHandle);
189 return { str.begin(), str.end() };
190 }
191 }
192 CloseHandle(processHandle);
193 }
194 }
195 }
196 return "";
197}
198
199#endif //#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32)
200

Callers

nothing calls this directly

Calls 2

beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected