From 2ab5c13374e0ee5c0ae817f5d2f93907f47439d1 Mon Sep 17 00:00:00 2001 From: Calvin Balke Date: Sun, 28 Jun 2015 18:40:59 -0700 Subject: [PATCH] Fixed GetThreadContext and removed a few things Also added a keyboard buffer character remover, so if you press enter and Tribes 2 doesn't take a character it won't get stuck in an infinite loop. --- Mod Sources/Watchdog/Watchdog/source/dllmain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mod Sources/Watchdog/Watchdog/source/dllmain.cpp b/Mod Sources/Watchdog/Watchdog/source/dllmain.cpp index bf6b1c7..2c71d33 100644 --- a/Mod Sources/Watchdog/Watchdog/source/dllmain.cpp +++ b/Mod Sources/Watchdog/Watchdog/source/dllmain.cpp @@ -40,8 +40,8 @@ DWORD WINAPI WatchDogThread(LPVOID lpParam) if (!sDogPetted && seconds > 8) // Wait 8 seconds to be safe #endif { - Tprintf ("Dog has grabbed the hamburger\n"); SuspendThread(mainThread); + hamburger.ContextFlags=CONTEXT_FULL; // Make sure to select which parts of the context to dump GetThreadContext(mainThread, &hamburger); // dog grabs hamburger; Tprintf ("Dog has grabbed the hamburger again\n"); Tprintf ("Either grab Hamburger back and put dog back on leash, or let dog eat hamburger\n"); @@ -54,6 +54,7 @@ DWORD WINAPI WatchDogThread(LPVOID lpParam) Sleep(30000); if (_kbhit()) { sDogPetted=true; + _getch(); // make sure to clean the keyboard buffer ResumeThread(mainThread); } else { CloseHandle(mainThread); @@ -84,7 +85,7 @@ extern "C" DWORD errorval = GetLastError(); Tprintf ("Error %08X, watchdog is not running properly\n",errorval); } - OpenThreadToken(thread,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,false, &token); + OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&token); LookupPrivilegeValue(NULL,SE_DEBUG_NAME, &debugname); tokenpriv.PrivilegeCount = 1; @@ -105,4 +106,3 @@ extern "C" } } -