mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-07-15 04:54:34 +00:00
Updated the Watchdog to build against Common
This commit is contained in:
parent
2ab5c13374
commit
ea2542532f
2 changed files with 15 additions and 15 deletions
|
|
@ -43,12 +43,12 @@
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>include;$(IncludePath)</IncludePath>
|
<IncludePath>include;..\..\..\CommonAPI\Common\include;$(IncludePath)</IncludePath>
|
||||||
<OutDir>$(SolutionDir)\Mods</OutDir>
|
<OutDir>$(SolutionDir)\Mods</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>include;$(IncludePath)</IncludePath>
|
<IncludePath>include;..\..\..\CommonAPI\Common\include;$(IncludePath)</IncludePath>
|
||||||
<OutDir>$(SolutionDir)\Mods</OutDir>
|
<OutDir>$(SolutionDir)\Mods</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;$(SolutionDir)\Common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;Dnsapi.lib;$(SolutionDir)\Common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
|
#include <LinkerAPI.h>
|
||||||
|
|
||||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||||
DWORD ul_reason_for_call,
|
DWORD ul_reason_for_call,
|
||||||
LPVOID lpReserved
|
LPVOID lpReserved
|
||||||
|
|
@ -22,9 +25,6 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
||||||
|
|
||||||
static bool sDogPetted = false;
|
static bool sDogPetted = false;
|
||||||
static DWORD mainthreadid=0;
|
static DWORD mainthreadid=0;
|
||||||
void (*Tprintf)(const char* fmt,...) =
|
|
||||||
(void (__cdecl *)(const char* fmt,...))
|
|
||||||
0x425F30;
|
|
||||||
DWORD WINAPI WatchDogThread(LPVOID lpParam)
|
DWORD WINAPI WatchDogThread(LPVOID lpParam)
|
||||||
{
|
{
|
||||||
time_t lastPet = time(0);
|
time_t lastPet = time(0);
|
||||||
|
|
@ -43,14 +43,14 @@ DWORD WINAPI WatchDogThread(LPVOID lpParam)
|
||||||
SuspendThread(mainThread);
|
SuspendThread(mainThread);
|
||||||
hamburger.ContextFlags=CONTEXT_FULL; // Make sure to select which parts of the context to dump
|
hamburger.ContextFlags=CONTEXT_FULL; // Make sure to select which parts of the context to dump
|
||||||
GetThreadContext(mainThread, &hamburger); // dog grabs hamburger;
|
GetThreadContext(mainThread, &hamburger); // dog grabs hamburger;
|
||||||
Tprintf ("Dog has grabbed the hamburger again\n");
|
Con::printf ("Dog has grabbed the hamburger again\n");
|
||||||
Tprintf ("Either grab Hamburger back and put dog back on leash, or let dog eat hamburger\n");
|
Con::printf ("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 ("the following text is from the Processor State\n");
|
||||||
FILE * wlog = fopen ("watchdog.log","a");
|
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);
|
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);
|
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);
|
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);
|
||||||
Tprintf ("Please press enter to try to continue\n or wait for 30 more seconds to kill T2 and write log\n");
|
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);
|
Sleep(30000);
|
||||||
if (_kbhit()) {
|
if (_kbhit()) {
|
||||||
sDogPetted=true;
|
sDogPetted=true;
|
||||||
|
|
@ -83,7 +83,7 @@ extern "C"
|
||||||
HANDLE thread = CreateThread(NULL, 0, WatchDogThread, NULL, 0, &threadID);
|
HANDLE thread = CreateThread(NULL, 0, WatchDogThread, NULL, 0, &threadID);
|
||||||
if (thread==NULL) {
|
if (thread==NULL) {
|
||||||
DWORD errorval = GetLastError();
|
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);
|
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&token);
|
||||||
|
|
||||||
|
|
@ -92,10 +92,10 @@ extern "C"
|
||||||
tokenpriv.Privileges[0].Luid = debugname;
|
tokenpriv.Privileges[0].Luid = debugname;
|
||||||
tokenpriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
tokenpriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
if(AdjustTokenPrivileges(token, FALSE, &tokenpriv, sizeof tokenpriv, NULL, NULL)) {
|
if(AdjustTokenPrivileges(token, FALSE, &tokenpriv, sizeof tokenpriv, NULL, NULL)) {
|
||||||
Tprintf ("watchdog should work now\n");
|
Con::printf ("watchdog should work now\n");
|
||||||
CloseHandle(token);
|
CloseHandle(token);
|
||||||
} else {
|
} 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…
Add table
Add a link
Reference in a new issue