MCPcopy Create free account
hub / github.com/bumptop/BumpTop / TopLevelFilter

Function TopLevelFilter

trunk/win/Source/BT_WindowsOS.cpp:359–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359LONG WINAPI TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionInfo)
360{
361 LONG retval = EXCEPTION_CONTINUE_SEARCH;
362 HWND hParent = NULL;
363 HMODULE hDll = NULL;
364 QString dumpFileName;
365 QString errorMessage;
366 MINIDUMPWRITEDUMP pDump;
367 bool readyToEmail = false;
368 bool restartBumpTop = true;
369
370 if (winOS->getRegistryDwordValue("ShutdownIncomplete"))
371 {
372 // if the previous shutdown was unsuccessful (due to an error) and
373 // we've likely already shown the error dialog, so just let the user know
374 // and shut down
375 ::MessageBox(GetForegroundWindow(), (LPCWSTR)QT_TRANSLATE_NOOP("WindowsOSStrings", "BumpTop has crashed.\n\n"
376 "You can find the Bump.dump file associated with the crash in the BumpTop folder in your Application Data directory.").utf16(),
377 (LPCWSTR)QT_TRANSLATE_NOOP("WindowsOSStrings", "Crash").utf16(), MB_ICONERROR);
378 winOS->setRegistryDwordValue("ShutdownIncomplete", 0);
379 return 0;
380 }
381
382 if (!GLOBAL(checked))
383 {
384 GLOBAL(checked) = true;
385 winOS->SetConditionalFlag(ThreadSafeProcessing, true);
386
387 dumpFileName = native(QFileInfo(winOS->GetDataDirectory(), "Bump.dmp"));
388
389 // Load the Debug Help library to help us with a stack trace
390 hDll = LoadLibrary(L"DBGHELP.DLL");
391
392 if (hDll)
393 {
394 // Get the address of the MiniDumpWriteDump() function inside the library
395 pDump = (MINIDUMPWRITEDUMP) GetProcAddress(hDll, "MiniDumpWriteDump");
396
397 if (pDump)
398 {
399 // create the file
400 HANDLE hFile = CreateFile((LPCWSTR) dumpFileName.utf16(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
401 if (hFile != INVALID_HANDLE_VALUE)
402 {
403 _MINIDUMP_EXCEPTION_INFORMATION ExInfo = {0};
404
405 ExInfo.ThreadId = GetCurrentThreadId();
406 ExInfo.ExceptionPointers = pExceptionInfo;
407 ExInfo.ClientPointers = NULL;
408
409 if (GLOBAL(generateFullDump))
410 {
411 QString fullDumpPath = native(winOS->GetDataDirectory() / "fullBumpDump.dmp");
412 HANDLE fullDumpFile = CreateFile((LPCWSTR)fullDumpPath.utf16(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
413 if (INVALID_HANDLE_VALUE != fullDumpFile)
414 if (pDump(GetCurrentProcess(), GetCurrentProcessId(), fullDumpFile, MINIDUMP_TYPE(MiniDumpWithFullMemory | MiniDumpIgnoreInaccessibleMemory), &ExInfo, NULL, NULL))
415 LOG("Full crash dump written to " + fullDumpPath);
416 }

Callers 2

WinMainFunction · 0.85
GlobalWndProcFunction · 0.85

Calls 15

QFileInfoClass · 0.85
LoadLibraryFunction · 0.85
getRegistryDwordValueMethod · 0.80
setRegistryDwordValueMethod · 0.80
SetConditionalFlagMethod · 0.80
GetDataDirectoryMethod · 0.80
clearStateMethod · 0.80
setPromptMethod · 0.80
promptDialogMethod · 0.80
setCaptionMethod · 0.80
loadStatsMethod · 0.80
saveStatsMethod · 0.80

Tested by

no test coverage detected