mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-01-19 18:14:44 +00:00
Updated the Watchdog to build against Common
This commit is contained in:
parent
2ab5c13374
commit
ea2542532f
|
|
@ -43,12 +43,12 @@
|
|||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>include;..\..\..\CommonAPI\Common\include;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(SolutionDir)\Mods</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>include;..\..\..\CommonAPI\Common\include;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(SolutionDir)\Mods</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;$(SolutionDir)\Common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;$(SolutionDir)\Common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include <LinkerAPI.h>
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
|
|
@ -22,9 +25,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
|
||||
static bool sDogPetted = false;
|
||||
static DWORD mainthreadid=0;
|
||||
void (*Tprintf)(const char* fmt,...) =
|
||||
(void (__cdecl *)(const char* fmt,...))
|
||||
0x425F30;
|
||||
DWORD WINAPI WatchDogThread(LPVOID lpParam)
|
||||
{
|
||||
time_t lastPet = time(0);
|
||||
|
|
@ -43,14 +43,14 @@ DWORD WINAPI WatchDogThread(LPVOID lpParam)
|
|||
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");
|
||||
Tprintf ("the following text is from the Processor State\n");
|
||||
Con::printf ("Dog has grabbed the hamburger again\n");
|
||||
Con::printf ("Either grab Hamburger back and put dog back on leash, or let dog eat hamburger\n");
|
||||
Con::printf ("the following text is from the Processor State\n");
|
||||
FILE * wlog = fopen ("watchdog.log","a");
|
||||
fprintf (wlog,"EIP: %08X EAX: %08X EBX: %08X ECX: %08X \nEDX: %08X ESI: %08X EDI: %08X\nEBP:%08X ESP:%08X\n", hamburger.Eip, hamburger.Eax, hamburger.Ebx, hamburger.Ecx, hamburger.Edx, hamburger.Esi, hamburger.Edi, hamburger.Ebp, hamburger.Esp);
|
||||
fclose (wlog);
|
||||
Tprintf ("EIP: %08X EAX: %08X EBX: %08X ECX: %08X \nEDX: %08X ESI: %08X EDI: %08X\nEBP:%08X ESP:%08X\n", hamburger.Eip, hamburger.Eax, hamburger.Ebx, hamburger.Ecx, hamburger.Edx, hamburger.Esi, hamburger.Edi, hamburger.Ebp, hamburger.Esp);
|
||||
Tprintf ("Please press enter to try to continue\n or wait for 30 more seconds to kill T2 and write log\n");
|
||||
Con::printf ("EIP: %08X EAX: %08X EBX: %08X ECX: %08X \nEDX: %08X ESI: %08X EDI: %08X\nEBP:%08X ESP:%08X\n", hamburger.Eip, hamburger.Eax, hamburger.Ebx, hamburger.Ecx, hamburger.Edx, hamburger.Esi, hamburger.Edi, hamburger.Ebp, hamburger.Esp);
|
||||
Con::printf ("Please press enter to try to continue\n or wait for 30 more seconds to kill T2 and write log\n");
|
||||
Sleep(30000);
|
||||
if (_kbhit()) {
|
||||
sDogPetted=true;
|
||||
|
|
@ -83,7 +83,7 @@ extern "C"
|
|||
HANDLE thread = CreateThread(NULL, 0, WatchDogThread, NULL, 0, &threadID);
|
||||
if (thread==NULL) {
|
||||
DWORD errorval = GetLastError();
|
||||
Tprintf ("Error %08X, watchdog is not running properly\n",errorval);
|
||||
Con::printf ("Error %08X, watchdog is not running properly\n",errorval);
|
||||
}
|
||||
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&token);
|
||||
|
||||
|
|
@ -92,10 +92,10 @@ extern "C"
|
|||
tokenpriv.Privileges[0].Luid = debugname;
|
||||
tokenpriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
if(AdjustTokenPrivileges(token, FALSE, &tokenpriv, sizeof tokenpriv, NULL, NULL)) {
|
||||
Tprintf ("watchdog should work now\n");
|
||||
Con::printf ("watchdog should work now\n");
|
||||
CloseHandle(token);
|
||||
} else {
|
||||
Tprintf ("Error, watchdog won't operate fully, WatchDog needs Admin Privileges for Debug\n");
|
||||
Con::printf ("Error, watchdog won't operate fully, WatchDog needs Admin Privileges for Debug\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue