-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
88 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
|
||
|
||
void initialize_crash_handler(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "../../low_level/crash_handler.h" | ||
|
||
#include <Windows.h> | ||
#include <DbgHelp.h> | ||
|
||
#include "log.h" | ||
#include "../../low_level/filesystem.h" | ||
|
||
|
||
BOOL WINAPI mini_dump_callback(void* currentModule, const PMINIDUMP_CALLBACK_INPUT input, PMINIDUMP_CALLBACK_OUTPUT output) | ||
{ | ||
if (input->CallbackType == IncludeModuleCallback) | ||
{ | ||
logger.Log(ELogLevel::INFO, input->IncludeModule.BaseOfImage, reinterpret_cast<unsigned long long>(currentModule), output->ModuleWriteFlags); | ||
if (input->IncludeModule.BaseOfImage != reinterpret_cast<unsigned long long>(currentModule)) | ||
{ | ||
output->ModuleWriteFlags = ModuleWriteModule | ModuleWriteCvRecord | ModuleWriteTlsData; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
|
||
long WINAPI on_exception(EXCEPTION_POINTERS* exceptions) | ||
{ | ||
constexpr int flags = | ||
MiniDumpNormal | | ||
MiniDumpWithDataSegs | | ||
#ifdef _DEBUG | ||
MiniDumpWithFullMemory | | ||
#endif | ||
MiniDumpWithHandleData | | ||
MiniDumpWithUnloadedModules | | ||
MiniDumpWithIndirectlyReferencedMemory | | ||
MiniDumpWithProcessThreadData | | ||
MiniDumpWithCodeSegs; | ||
|
||
MINIDUMP_EXCEPTION_INFORMATION exceptionInfo{ GetCurrentThreadId(), exceptions, false }; | ||
MINIDUMP_CALLBACK_INFORMATION callbackInfo{ mini_dump_callback, GetModuleHandle(nullptr) }; | ||
const std::filesystem::path& path = get_crash_file_path(); | ||
const HANDLE file = CreateFileW(path.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); | ||
|
||
logger.Log(reinterpret_cast<unsigned long long>(GetModuleHandle(nullptr))); | ||
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, static_cast<MINIDUMP_TYPE>(flags), &exceptionInfo, nullptr, &callbackInfo); | ||
|
||
return EXCEPTION_CONTINUE_SEARCH; | ||
} | ||
|
||
|
||
void initialize_crash_handler() | ||
{ | ||
SetUnhandledExceptionFilter(on_exception); | ||
unsigned long minimumStackSize = 1024 * 17; | ||
SetThreadStackGuarantee(&minimumStackSize); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters