예제 #1
0
/**
 * Shows the "assertion failed" dialog box, and gives the user several options
 * for how to continue. Once chosen, this method will also execute that action
 * for the user (such as saving the dialog window) before continuing
 *
 * \return             True if the user wants to start debugging, or false
 *                     if they selected the option to quit
 */
bool AssertionDialog::Show() const
{
    AssertionDialog::EUserAction userAction;
    bool shouldStartDebugging = false;

    // Keep the dialog window up until the user has successfully saved the report, or chosen another action.
    bool keepGoing = true;

    while (keepGoing)
    {
        userAction = ShowDialog();

        if (userAction == EUSERACTION_SAVE)
        {
            keepGoing = (!SaveCrashDump());
        }
        else if (userAction == EUSERACTION_DEBUG)
        {
            keepGoing = false;
            shouldStartDebugging = true;
        }
        else
        {
            keepGoing = false;
        }
    }

    // Let the caller know if the user wanted to start the debugger
    return shouldStartDebugging;
}
LONG _stdcall TopLevelFilter( _EXCEPTION_POINTERS *pExceptionInfo )
{
	if (pExceptionInfo->ExceptionRecord->ExceptionCode==EXCEPTION_STACK_OVERFLOW)
	{
		// start a new thread to get a fresh stack (hoping there is enough stack left for CreateThread)
		HANDLE thread=CreateThread(NULL,0,SaveCrashDump,pExceptionInfo,0,NULL);
		WaitForSingleObject(thread,INFINITE);
		CloseHandle(thread);
	}
	else
		SaveCrashDump(pExceptionInfo);
	return EXCEPTION_CONTINUE_SEARCH;
}