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.
This commit is contained in:
Calvin Balke 2015-06-28 18:40:59 -07:00
parent 0da786a426
commit 2ab5c13374

View file

@ -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"
}
}