From 3a54621bd8a55b672ba986f02ab094bfb4ba6faf Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 7 May 2025 04:49:52 +1000 Subject: add world.template, world.setTemplate --- source/core/StarMiniDump_windows.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 source/core/StarMiniDump_windows.cpp (limited to 'source/core/StarMiniDump_windows.cpp') 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 +#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 -- cgit v1.2.3