2016-01-08 14:10:35 -05:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
|
|
|
// Stuff causes warnings
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable: 4091)
|
|
|
|
#include <dbghelp.h>
|
|
|
|
#pragma comment(lib, "dbghelp.lib")
|
|
|
|
#pragma warning(pop)
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo)
|
|
|
|
{
|
|
|
|
char filename[MAX_PATH];
|
|
|
|
__time64_t time;
|
|
|
|
tm* ltime;
|
|
|
|
|
|
|
|
_time64(&time);
|
|
|
|
ltime = _localtime64(&time);
|
2016-01-10 09:48:49 -05:00
|
|
|
strftime(filename, sizeof(filename) - 1, "iw4x-" VERSION_STR "-%Y%m%d%H%M%S.dmp", ltime);
|
2016-01-08 14:10:35 -05:00
|
|
|
|
2016-03-09 19:52:40 -05:00
|
|
|
HANDLE hFile = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
2016-01-08 14:10:35 -05:00
|
|
|
|
|
|
|
if (hFile && hFile != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
MINIDUMP_EXCEPTION_INFORMATION ex = { GetCurrentThreadId(),ExceptionInfo, FALSE };
|
|
|
|
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ex, NULL, NULL);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW)
|
|
|
|
{
|
|
|
|
Logger::Error("Termination because of a stack overflow.\n");
|
|
|
|
TerminateProcess(GetCurrentProcess(), EXCEPTION_STACK_OVERFLOW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Logger::Error("Fatal error (0x%08x) at 0x%08x.", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI Exception::SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
|
|
|
|
{
|
|
|
|
SetUnhandledExceptionFilter(&Exception::ExceptionFilter);
|
|
|
|
return lpTopLevelExceptionFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::Exception()
|
|
|
|
{
|
2016-01-16 09:03:09 -05:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Display DEBUG branding, so we know we're on a debug build
|
|
|
|
Renderer::OnFrame([] ()
|
|
|
|
{
|
2016-01-20 19:01:22 -05:00
|
|
|
Game::Font* font = Game::R_RegisterFont("fonts/normalFont");
|
2016-01-16 09:03:09 -05:00
|
|
|
float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
2016-01-27 18:32:46 -05:00
|
|
|
|
2016-02-05 12:13:34 -05:00
|
|
|
// Change the color when attaching a debugger
|
2016-01-27 18:32:46 -05:00
|
|
|
if (IsDebuggerPresent())
|
|
|
|
{
|
2016-02-05 12:13:34 -05:00
|
|
|
color[0] = 0.6588f;
|
|
|
|
color[1] = 1.0000f;
|
|
|
|
color[2] = 0.0000f;
|
2016-01-27 18:32:46 -05:00
|
|
|
}
|
|
|
|
|
2016-02-05 12:13:34 -05:00
|
|
|
Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED);
|
2016-01-16 09:03:09 -05:00
|
|
|
});
|
|
|
|
#else
|
2016-03-11 15:53:23 -05:00
|
|
|
Utils::Hook::Set(0x6D70AC, Exception::SetUnhandledExceptionFilterStub);
|
|
|
|
SetUnhandledExceptionFilter(&Exception::ExceptionFilter);
|
2016-01-15 16:51:47 -05:00
|
|
|
#endif
|
|
|
|
|
2016-01-15 17:00:42 -05:00
|
|
|
Command::Add("mapTest", [] (Command::Params params)
|
2016-01-15 16:51:47 -05:00
|
|
|
{
|
|
|
|
std::string command;
|
2016-01-16 14:18:27 -05:00
|
|
|
|
|
|
|
int max = (params.Length() >= 2 ? atoi(params[1]) : 16), current = 0;
|
|
|
|
|
|
|
|
for (int i =0;;)
|
2016-01-15 16:51:47 -05:00
|
|
|
{
|
2016-01-24 06:19:34 -05:00
|
|
|
char* mapname = reinterpret_cast<char*>(0x7471D0) + 40 * i;
|
2016-01-16 14:18:27 -05:00
|
|
|
if (!*mapname)
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2016-01-15 16:51:47 -05:00
|
|
|
|
2016-01-16 14:18:27 -05:00
|
|
|
if(!(i % 2)) command.append(Utils::VA("wait 250;disconnect;wait 750;", mapname)); // Test a disconnect
|
2016-01-16 17:48:52 -05:00
|
|
|
else command.append(Utils::VA("wait 500;", mapname)); // Test direct map switch
|
2016-01-15 16:51:47 -05:00
|
|
|
command.append(Utils::VA("map %s;", mapname));
|
2016-01-16 14:18:27 -05:00
|
|
|
|
|
|
|
i++, current++;
|
|
|
|
|
|
|
|
if (current >= max) break;
|
2016-01-15 16:51:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Command::Execute(command, false);
|
|
|
|
});
|
2016-01-08 14:10:35 -05:00
|
|
|
}
|
|
|
|
}
|