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

Method _ExitCommonDebuggers

AntiDebug/DebuggerDetections.cpp:259–305  ·  view source on GitHub ↗

_ExitCommonDebuggers - create remote thread on `ExitProcess` in any common debugger processes This can of course be bypassed with a simple process name change, preferrably we would use a combination of artifacts to find these processes */

Source from the content-addressed store, hash-verified

257 This can of course be bypassed with a simple process name change, preferrably we would use a combination of artifacts to find these processes
258*/
259DetectionFlags DebuggerDetections::_ExitCommonDebuggers()
260{
261 bool triedEndDebugger = false;
262
263 for (const std::wstring& debugger : this->CommonDebuggerProcesses)
264 {
265 std::list<DWORD> pids = Process::GetProcessIdsByName(debugger);
266
267 for (const auto pid : pids)
268 {
269 uintptr_t K32Base = (uintptr_t)GetModuleHandleW(L"kernel32.dll");
270
271 if (K32Base == NULL)
272 {
273 Logger::logf(Warning, "Failed to fetch kernel32.dll address @ _ExitCommonDebuggers ");
274 return EXECUTION_ERROR;
275 }
276
277 uintptr_t ExitProcessAddr = (uintptr_t)GetProcAddress((HMODULE)K32Base, "ExitProcess");
278
279 if (ExitProcessAddr == NULL)
280 {
281 Logger::logf(Warning, "Failed to fetch ExitProcess address @ _ExitCommonDebuggers ");
282 return EXECUTION_ERROR;
283 }
284
285 uintptr_t ExitProcessOffset = ExitProcessAddr - K32Base;
286
287 HANDLE remoteProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
288
289 if (remoteProcHandle)
290 {
291 uintptr_t FunctionAddr_ExitProcess = (uintptr_t)Process::GetRemoteModuleBaseAddress(pid, L"kernel32.dll") + ExitProcessOffset;
292 HANDLE RemoteThread = CreateRemoteThread(remoteProcHandle, 0, 0, (LPTHREAD_START_ROUTINE)FunctionAddr_ExitProcess, 0, 0, 0);
293 triedEndDebugger = true;
294 CloseHandle(remoteProcHandle);
295 Logger::logf(Info, "Created remote thread at %llX address", FunctionAddr_ExitProcess);
296 }
297 else
298 {
299 Logger::logf(Warning, "Failed to open process handle for pid %d @ _ExitCommonDebuggers", pid);
300 }
301 }
302 }
303
304 return (triedEndDebugger ? DEBUG_KNOWN_DEBUGGER_PROCESS : NONE);
305}
306

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected