MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RecordExceptionInfo

Function RecordExceptionInfo

ddebug/windebug.cpp:328–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326
327#pragma comment(lib, "DbgHelp.lib")
328long WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data) {
329 static bool BeenHere = false;
330 if (BeenHere) // Going recursive! That must mean this routine crashed!
331 return EXCEPTION_CONTINUE_SEARCH;
332 BeenHere = true;
333
334 SetMessageBoxTitle("Unexpected error");
335
336 std::error_code ec;
337 const std::filesystem::path dumFilePath = std::filesystem::temp_directory_path(ec) / "d3-crash.dmp";
338 if (ec) {
339 OutrageMessageBox("Could not find temporary directory to write crash dump file into: %s", ec.message().c_str());
340 exit(1);
341 }
342
343 HANDLE hDumpFile = CreateFile(dumFilePath.u8string().c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, 0);
344 if (hDumpFile == INVALID_HANDLE_VALUE) {
345 OutrageMessageBox("Could not create crash dump file, error code: %x", GetLastError());
346 exit(1);
347 }
348
349 MINIDUMP_EXCEPTION_INFORMATION exceptInfo;
350 exceptInfo.ThreadId = GetCurrentThreadId();
351 exceptInfo.ExceptionPointers = data;
352 exceptInfo.ClientPointers = TRUE;
353
354 if (MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &exceptInfo, nullptr, nullptr)) {
355 OutrageMessageBox("Crash dump file written to: %s\nYou can attach it to a bug report.", dumFilePath.u8string().c_str());
356 } else {
357 OutrageMessageBox("Could not write crash dump file, error code: %x", GetLastError());
358 exit(1);
359 }
360
361 BeenHere = false;
362
363 return Debug_break ? EXCEPTION_CONTINUE_SEARCH : EXCEPTION_EXECUTE_HANDLER;
364}

Callers

nothing calls this directly

Calls 2

SetMessageBoxTitleFunction · 0.85
OutrageMessageBoxFunction · 0.85

Tested by

no test coverage detected