- Top level exception handler can't be UnhandledExceptionFilter by default, this leads to an infinite recursion if top level was not overriden.

- Add HardError raising to UnhandledExceptionFilter, by Dmitry Philippov.

svn path=/trunk/; revision=31356
This commit is contained in:
Aleksey Bragin 2007-12-20 15:41:24 +00:00
parent 55999c83fb
commit 21d4476bfc

View file

@ -15,7 +15,7 @@
#define NDEBUG
#include <debug.h>
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter = UnhandledExceptionFilter;
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter = NULL;
UINT
WINAPI
@ -213,6 +213,8 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
LONG RetValue;
HANDLE DebugPort = NULL;
NTSTATUS ErrCode;
ULONG ErrorParameters[4];
ULONG ErrorResponse;
if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
ExceptionInfo->ExceptionRecord->NumberParameters >= 2)
@ -227,7 +229,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
if (RetValue == EXCEPTION_CONTINUE_EXECUTION)
return EXCEPTION_CONTINUE_EXECUTION;
break;
case EXCEPTION_EXECUTE_FAULT:
case EXCEPTION_EXECUTE_FAULT:
/* FIXME */
break;
}
@ -255,7 +257,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
if (ret != EXCEPTION_CONTINUE_SEARCH)
return ret;
}
if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0)
{
#ifdef _X86_
@ -306,6 +308,34 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
#endif
}
/* Save exception code and address */
ErrorParameters[0] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionCode;
ErrorParameters[1] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionAddress;
if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION)
{
/* get the type of operation that caused the access violation */
ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[0];
}
else
{
ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[2];
}
/* Save faulting address */
ErrorParameters[3] = ExceptionInfo->ExceptionRecord->ExceptionInformation[1];
/* Raise the harderror */
ErrCode = NtRaiseHardError(STATUS_UNHANDLED_EXCEPTION | 0x10000000,
4, 0, ErrorParameters, OptionOkCancel, &ErrorResponse);
if (NT_SUCCESS(ErrCode) && (ErrorResponse == ResponseCancel))
{
/* FIXME: Check the result, if the "Cancel" button was
clicked run a debugger */
DPRINT1("Debugging is not implemented yet\n");
}
/*
* Returning EXCEPTION_EXECUTE_HANDLER means that the code in
* the __except block will be executed. Normally this will end up in a