Minidump shit.
This commit is contained in:
parent
558fc7fd39
commit
b58e62e5e4
@ -28,6 +28,7 @@ namespace Components
|
||||
Loader::Register(new UIScript());
|
||||
Loader::Register(new Dedicated());
|
||||
Loader::Register(new Discovery());
|
||||
Loader::Register(new Exception());
|
||||
Loader::Register(new FastFiles());
|
||||
Loader::Register(new Materials());
|
||||
Loader::Register(new FileSystem());
|
||||
|
@ -40,6 +40,7 @@ namespace Components
|
||||
#include "Modules\UIScript.hpp"
|
||||
#include "Modules\Dedicated.hpp"
|
||||
#include "Modules\Discovery.hpp"
|
||||
#include "Modules\Exception.hpp"
|
||||
#include "Modules\FastFiles.hpp"
|
||||
#include "Modules\Materials.hpp"
|
||||
#include "Modules\Singleton.hpp"
|
||||
|
56
src/Components/Modules/Exception.cpp
Normal file
56
src/Components/Modules/Exception.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "STDInclude.hpp"
|
||||
#include "..\..\Utils\Versioning.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);
|
||||
strftime(filename, sizeof(filename) - 1, "iw4m-" VERSION_STR "-%Y%m%d%H%M%S.dmp", ltime);
|
||||
|
||||
HANDLE hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
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()
|
||||
{
|
||||
Utils::Hook::Set(0x6D70AC, Exception::SetUnhandledExceptionFilterStub);
|
||||
SetUnhandledExceptionFilter(&Exception::ExceptionFilter);
|
||||
}
|
||||
}
|
13
src/Components/Modules/Exception.hpp
Normal file
13
src/Components/Modules/Exception.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Components
|
||||
{
|
||||
class Exception : public Component
|
||||
{
|
||||
public:
|
||||
Exception();
|
||||
const char* GetName() { return "Exception"; };
|
||||
|
||||
private:
|
||||
static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo);
|
||||
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user