From 8cb4553165a3e4389d884956ee26a279e04b49d5 Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Sat, 21 Dec 2024 13:24:20 -0500 Subject: [PATCH] Silence Win7 Error --- cockatrice/src/main.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index ff14565f9..8bfe4f4bd 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -62,12 +62,20 @@ static void CockatriceLogger(QtMsgType type, const QMessageLogContext &ctx, cons } #ifdef Q_OS_WIN +// clang-format off #include #include -#pragma comment(lib, "DbgHelp.lib") // Link the DbgHelp library +#include +#pragma comment(lib, "DbgHelp.lib") // Link the DbgHelp library +// clang-format on -LONG WINAPI CockatriceUnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) { - HANDLE hDumpFile = CreateFile(L"CockatriceCrashDump.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +LONG WINAPI CockatriceUnhandledExceptionFilter(EXCEPTION_POINTERS *pExceptionPointers) +{ + const auto fileNameString = "cockatrice.crash." + std::to_string(std::time(0)) + ".dmp"; + const auto fileNameWString = std::wstring(fileNameString.begin(), fileNameString.end()); + + HANDLE hDumpFile = + CreateFile(fileNameWString.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hDumpFile != INVALID_HANDLE_VALUE) { MINIDUMP_EXCEPTION_INFORMATION dumpInfo; @@ -75,7 +83,8 @@ LONG WINAPI CockatriceUnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionPoi dumpInfo.ThreadId = GetCurrentThreadId(); dumpInfo.ClientPointers = TRUE; - MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpWithFullMemory, &dumpInfo, NULL, NULL); + MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpWithFullMemory, &dumpInfo, + NULL, NULL); CloseHandle(hDumpFile); }