| 161 | |
| 162 | |
| 163 | std::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 | |