From a1510eb4fc74f9e1f2f0c46468ebd0c860933afc Mon Sep 17 00:00:00 2001 From: Hirek Date: Wed, 11 Jun 2025 12:42:09 +0200 Subject: [PATCH] Change crashdump name logic --- EU07.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/EU07.cpp b/EU07.cpp index 5ac2fbc5..3a45df21 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -33,9 +33,29 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic); #ifdef WITHDUMPGEN +#include +#include +#include +#include +#include +#include + +#pragma comment(lib, "Dbghelp.lib") + LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo) { - HANDLE hFile = CreateFileA("crash.dmp", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + // Get current local time + SYSTEMTIME st; + GetLocalTime(&st); + + // Format: crash_YYYY-MM-DD_HH-MM-SS.dmp + std::ostringstream oss; + oss << "crash_" << std::setw(4) << std::setfill('0') << st.wYear << "-" << std::setw(2) << std::setfill('0') << st.wMonth << "-" << std::setw(2) << std::setfill('0') << st.wDay << "_" + << std::setw(2) << std::setfill('0') << st.wHour << "-" << std::setw(2) << std::setfill('0') << st.wMinute << "-" << std::setw(2) << std::setfill('0') << st.wSecond << ".dmp"; + + std::string filename = oss.str(); + + HANDLE hFile = CreateFileA(filename.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { MINIDUMP_EXCEPTION_INFORMATION dumpInfo; @@ -45,10 +65,11 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo) MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpWithDataSegs, &dumpInfo, nullptr, nullptr); CloseHandle(hFile); - } + } return EXCEPTION_EXECUTE_HANDLER; } + #endif