void ExceptionToDebug(struct _EXCEPTION_POINTERS *lpExceptionInfo) { string description = ""; string exceptionname = ""; switch(lpExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION : exceptionname = "EXCEPTION_ACCESS_VIOLATION"; description = "The thread tried to read from or write to a virtual address for which it does not have the appropriate access."; break; case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: description = "The thread tried to access an array element that is out of bounds and the underlying hardware supports bounds checking."; exceptionname = "EXCEPTION_ARRAY_BOUNDS_EXCEEDED"; break; case EXCEPTION_BREAKPOINT : description = "A breakpoint was encountered. "; exceptionname = "EXCEPTION_BREAKPOINT"; break; case EXCEPTION_DATATYPE_MISALIGNMENT : description = "The thread tried to read or write data that is misaligned on hardware that does not provide alignment. For example, 16-bit values must be aligned on 2-byte boundaries; 32-bit values on 4-byte boundaries, and so on. "; exceptionname = "EXCEPTION_DATATYPE_MISALIGNMENT"; break; case EXCEPTION_FLT_DENORMAL_OPERAND : description = "One of the operands in a floating-point operation is denormal. A denormal value is one that is too small to represent as a standard floating-point value. "; exceptionname = "EXCEPTION_FLT_DENORMAL_OPERAND"; break; case EXCEPTION_FLT_DIVIDE_BY_ZERO : description = "The thread tried to divide a floating-point value by a floating-point divisor of zero. "; exceptionname = "EXCEPTION_FLT_DIVIDE_BY_ZERO"; break; case EXCEPTION_FLT_INEXACT_RESULT : description="The result of a floating-point operation cannot be represented exactly as a decimal fraction. "; exceptionname ="EXCEPTION_FLT_INEXACT_RESULT"; break; case EXCEPTION_FLT_INVALID_OPERATION : description = "This exception represents any floating-point exception not included in this list. "; exceptionname = "EXCEPTION_FLT_INVALID_OPERATION"; break; case EXCEPTION_FLT_OVERFLOW : description = "The exponent of a floating-point operation is greater than the magnitude allowed by the corresponding type. "; exceptionname = "EXCEPTION_FLT_OVERFLOW"; break; case EXCEPTION_FLT_STACK_CHECK: description = "The stack overflowed or underflowed as the result of a floating-point operation. "; exceptionname = "EXCEPTION_FLT_STACK_CHECK"; break; case EXCEPTION_FLT_UNDERFLOW : description = "The exponent of a floating-point operation is less than the magnitude allowed by the corresponding type. "; exceptionname = "EXCEPTION_FLT_UNDERFLOW"; break; case EXCEPTION_GUARD_PAGE : description = "The thread attempted to read from or write to a guard page. "; exceptionname= "EXCEPTION_GUARD_PAGE"; break; case EXCEPTION_ILLEGAL_INSTRUCTION : description="The thread tried to execute an invalid instruction. "; exceptionname = "EXCEPTION_ILLEGAL_INSTRUCTION"; break; case EXCEPTION_IN_PAGE_ERROR: description= "The thread tried to access a page that was not present, and the system was unable to load the page. "; exceptionname = "EXCEPTION_IN_PAGE_ERROR"; break; case EXCEPTION_INT_DIVIDE_BY_ZERO : description = "The thread tried to divide an integer value by an integer divisor of zero. "; exceptionname = "EXCEPTION_INT_DIVIDE_BY_ZERO"; break; case EXCEPTION_INT_OVERFLOW : description = "The result of an integer operation caused a carry out of the most significant bit of the result. "; exceptionname = "EXCEPTION_INT_OVERFLOW"; break; case EXCEPTION_INVALID_DISPOSITION: description = "An exception handler returned an invalid disposition to the exception dispatcher. Programmers using a high-level language such as C should never encounter this exception. "; exceptionname = "EXCEPTION_INVALID_DISPOSITION"; break; case EXCEPTION_INVALID_HANDLE: description = "The thread tried to perform an operation using an invalid handle. "; exceptionname = "EXCEPTION_INVALID_HANDLE"; break; case EXCEPTION_NONCONTINUABLE_EXCEPTION : description = "The thread tried to continue execution after a noncontinuable exception occurred. "; exceptionname = "EXCEPTION_NONCONTINUABLE_EXCEPTION"; break; case EXCEPTION_PRIV_INSTRUCTION : description = "The thread tried to execute a privileged instruction. "; exceptionname = "EXCEPTION_PRIV_INSTRUCTION"; break; case EXCEPTION_SINGLE_STEP : description = "A trace trap or other single-instruction mechanism signaled that one instruction has been executed. "; exceptionname = "EXCEPTION_SINGLE_STEP"; break; case EXCEPTION_STACK_OVERFLOW : description = "A stack overflow occurred. "; exceptionname = "EXCEPTION_STACK_OVERFLOW"; break; default : description ="Unknow Exception"; exceptionname = "Unknow Exception"; break; } DebugMsg("Debug",exceptionname.c_str()); DebugMsg("Debug",description.c_str()); } LONG WINAPI UnHandleExceptionFilter(struct _EXCEPTION_POINTERS *lpExceptionInfo) { DebugMsg("Debug","Unhandled exception occured..."); ExceptionToDebug(lpExceptionInfo); XOVERLAPPED overlapped; MESSAGEBOX_RESULT mbresult; HANDLE hEvent = WSACreateEvent(); memset(&overlapped,0,sizeof(overlapped)); overlapped.hEvent = hEvent; memset(&mbresult,0,sizeof(mbresult)); LPCWSTR btnOptions[3] = {L"Restart FSD", L"Go back to NXE",L"Try to continue..."}; XShowMessageBoxUI(0,L"FSD CRASH",L"Freestyle Dash crashed, what would you like to do?",3,btnOptions,0,XMB_ERRORICON,&mbresult,&overlapped); WaitForSingleObject( hEvent, 20000 ); WSAResetEvent( hEvent); if(mbresult.dwButtonPressed == 0) { DebugMsg("Debug","Restart pressed"); Restart(); } else { if(mbresult.dwButtonPressed == 1) { BackToNXE(); } else { if(mbresult.dwButtonPressed == 2) { } } } return EXCEPTION_CONTINUE_EXECUTION; }