- Get handling of unhandled exceptions working again.

svn path=/trunk/; revision=12079
This commit is contained in:
Filip Navara 2004-12-13 13:32:24 +00:00
parent 56a8abdfa4
commit b2a1d58158
4 changed files with 76 additions and 45 deletions

View file

@ -1,4 +1,4 @@
/* $Id: except.c,v 1.20 2004/12/12 23:03:56 weiden Exp $
/* $Id: except.c,v 1.21 2004/12/13 13:32:23 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -88,10 +88,11 @@ _dump_context(PCONTEXT pc)
LONG STDCALL
UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
#if 0
DWORD RetValue;
#endif
HANDLE DebugPort = NULL;
NTSTATUS ErrCode;
static int RecursionTrap = 3;
#if 0
if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
@ -104,36 +105,23 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
}
#endif
if (RecursionTrap > 0)
/* Is there a debugger running ? */
ErrCode = NtQueryInformationProcess(NtCurrentProcess(), ProcessDebugPort,
&DebugPort, sizeof(HANDLE), NULL);
if (!NT_SUCCESS(ErrCode) && ErrCode != STATUS_NOT_IMPLEMENTED)
{
/* Is there a debugger running ? */
ErrCode = NtQueryInformationProcess(NtCurrentProcess(), ProcessDebugPort,
&DebugPort, sizeof(HANDLE), NULL);
if (!NT_SUCCESS(ErrCode) && ErrCode != STATUS_NOT_IMPLEMENTED)
{
SetLastErrorByStatus(ErrCode);
return EXCEPTION_EXECUTE_HANDLER;
}
if (DebugPort)
{
/* Pass the exception to debugger. */
DPRINT("Passing exception to debugger\n");
return EXCEPTION_CONTINUE_SEARCH;
}
/* Run unhandled exception handler. */
if (GlobalTopLevelExceptionFilter != NULL)
{
RetValue = GlobalTopLevelExceptionFilter(ExceptionInfo);
if (RetValue == EXCEPTION_EXECUTE_HANDLER)
return EXCEPTION_EXECUTE_HANDLER;
if (RetValue == EXCEPTION_CONTINUE_EXECUTION)
return EXCEPTION_CONTINUE_EXECUTION;
}
SetLastErrorByStatus(ErrCode);
return EXCEPTION_EXECUTE_HANDLER;
}
if (RecursionTrap-- > 0 && (GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0)
if (DebugPort)
{
/* Pass the exception to debugger. */
DPRINT("Passing exception to debugger\n");
return EXCEPTION_CONTINUE_SEARCH;
}
if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0)
{
#ifdef _X86_
PULONG Frame;

View file

@ -43,6 +43,8 @@ extern CRITICAL_SECTION DllLock;
extern UNICODE_STRING DllDirectory;
extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
/* FUNCTION PROTOTYPES *******************************************************/
BOOL STDCALL IsConsoleHandle(HANDLE Handle);

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.89 2004/11/21 21:09:42 weiden Exp $
/* $Id: create.c,v 1.90 2004/12/13 13:32:24 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -12,6 +12,7 @@
/* INCLUDES ****************************************************************/
#include <k32.h>
#include <pseh/framebased.h>
#define NDEBUG
#include "../include/debug.h"
@ -291,19 +292,29 @@ _except_handler(EXCEPTION_RECORD *ExceptionRecord,
{
EXCEPTION_POINTERS ExceptionInfo;
EXCEPTION_DISPOSITION ExceptionDisposition;
ExceptionInfo.ExceptionRecord = ExceptionRecord;
ExceptionInfo.ContextRecord = ContextRecord;
ExceptionDisposition = UnhandledExceptionFilter(&ExceptionInfo);
if (ExceptionDisposition == EXCEPTION_EXECUTE_HANDLER)
if (GlobalTopLevelExceptionFilter != NULL)
{
/* FIXME */
#if 0
if (_BaseRunningInServerProcess)
ExitThread(ExceptionRecord->ExceptionCode);
else
#endif
ExitProcess(ExceptionRecord->ExceptionCode);
_SEH_TRY
{
ExceptionDisposition = GlobalTopLevelExceptionFilter(&ExceptionInfo);
}
_SEH_HANDLE
{
ExceptionDisposition = UnhandledExceptionFilter(&ExceptionInfo);
}
_SEH_END;
}
else
{
ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER;
}
if (ExceptionDisposition == EXCEPTION_EXECUTE_HANDLER)
ExitProcess(ExceptionRecord->ExceptionCode);
/* translate EXCEPTION_XXX defines into EXCEPTION_DISPOSITION enum values */
if (ExceptionDisposition == EXCEPTION_CONTINUE_EXECUTION)
@ -327,6 +338,8 @@ BaseProcessStart(LPTHREAD_START_ROUTINE lpStartAddress,
{
uExitCode = (lpStartAddress)((PVOID)lpParameter);
} __except1
ExitProcess(uExitCode);
}

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.58 2004/12/09 19:11:07 weiden Exp $
/* $Id: thread.c,v 1.59 2004/12/13 13:32:24 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -14,6 +14,7 @@
/* INCLUDES ******************************************************************/
#include <k32.h>
#include <pseh/framebased.h>
#define NDEBUG
#include "../include/debug.h"
@ -28,10 +29,39 @@ _except_handler(EXCEPTION_RECORD *ExceptionRecord,
CONTEXT *ContextRecord,
void * DispatcherContext)
{
ExitThread(0);
EXCEPTION_POINTERS ExceptionInfo;
EXCEPTION_DISPOSITION ExceptionDisposition;
/* We should not get to here */
return(ExceptionContinueSearch);
ExceptionInfo.ExceptionRecord = ExceptionRecord;
ExceptionInfo.ContextRecord = ContextRecord;
if (GlobalTopLevelExceptionFilter != NULL)
{
_SEH_TRY
{
ExceptionDisposition = GlobalTopLevelExceptionFilter(&ExceptionInfo);
}
_SEH_HANDLE
{
ExceptionDisposition = UnhandledExceptionFilter(&ExceptionInfo);
}
_SEH_END;
}
else
{
ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER;
}
if (ExceptionDisposition == EXCEPTION_EXECUTE_HANDLER)
ExitThread(ExceptionRecord->ExceptionCode);
/* translate EXCEPTION_XXX defines into EXCEPTION_DISPOSITION enum values */
if (ExceptionDisposition == EXCEPTION_CONTINUE_EXECUTION)
return ExceptionContinueExecution;
else if (ExceptionDisposition == EXCEPTION_CONTINUE_SEARCH)
return ExceptionContinueSearch;
return -1; /* unknown return from UnhandledExceptionFilter */
}
@ -50,8 +80,6 @@ ThreadStartup
uExitCode = (lpStartAddress)(lpParameter);
}
__except1
{
}
ExitThread(uExitCode);
}