diff options
author | grbr404 <166065505+grbr404@users.noreply.github.com> | 2025-05-09 17:57:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-09 17:57:28 +0200 |
commit | 682267e765f6d7c8314e31056e68c498819d524c (patch) | |
tree | 2e160bda754116278090542714d7978d9e588d97 /source/core/StarMiniDump_windows.cpp | |
parent | 3fc211bcb8dcddd90d50b081553750573bddea7d (diff) | |
parent | 3a54621bd8a55b672ba986f02ab094bfb4ba6faf (diff) |
Merge branch 'OpenStarbound:main' into main
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 |