diff options
Diffstat (limited to 'source/core/StarMiniDump_windows.cpp')
-rw-r--r-- | source/core/StarMiniDump_windows.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/core/StarMiniDump_windows.cpp b/source/core/StarMiniDump_windows.cpp new file mode 100644 index 0000000..368d67d --- /dev/null +++ b/source/core/StarMiniDump_windows.cpp @@ -0,0 +1,28 @@ +#include "StarMiniDump.hpp" +#include <windows.h> +#include "minidumpapiset.h" + +namespace Star { + DWORD WINAPI writeMiniDump(void* ExceptionInfo) { + auto hFile = CreateFileA("starbound.dmp", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if (hFile == INVALID_HANDLE_VALUE) + return 0; + MINIDUMP_EXCEPTION_INFORMATION dumpExceptionInfo{}; + dumpExceptionInfo.ThreadId = GetCurrentThreadId(); + dumpExceptionInfo.ExceptionPointers = (PEXCEPTION_POINTERS)ExceptionInfo; + dumpExceptionInfo.ClientPointers = FALSE; + MiniDumpWriteDump( + GetCurrentProcess(), + GetCurrentProcessId(), + hFile, + MiniDumpNormal, + &dumpExceptionInfo, + NULL, + NULL); + CloseHandle(hFile); + if (dumpExceptionInfo.ExceptionPointers->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) { + MessageBoxA(NULL, "Stack overflow encountered\nA minidump has been generated", NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND); + } + return 0; + }; +}
\ No newline at end of file |