[ros-diffs] [fireball] 31356: - 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.

fireball at svn.reactos.org fireball at svn.reactos.org
Thu Dec 20 16:41:24 CET 2007


Author: fireball
Date: Thu Dec 20 18:41:24 2007
New Revision: 31356

URL: http://svn.reactos.org/svn/reactos?rev=31356&view=rev
Log:
- 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.

Modified:
    trunk/reactos/dll/win32/kernel32/except/except.c

Modified: trunk/reactos/dll/win32/kernel32/except/except.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/except/except.c?rev=31356&r1=31355&r2=31356&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/except/except.c (original)
+++ trunk/reactos/dll/win32/kernel32/except/except.c Thu Dec 20 18:41:24 2007
@@ -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 @@
    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 @@
          if (RetValue == EXCEPTION_CONTINUE_EXECUTION)
             return EXCEPTION_CONTINUE_EXECUTION;
          break;
-	  case EXCEPTION_EXECUTE_FAULT:
+      case EXCEPTION_EXECUTE_FAULT:
          /* FIXME */
          break;
       }
@@ -255,7 +257,7 @@
       if (ret != EXCEPTION_CONTINUE_SEARCH)
          return ret;
    }
-    
+
    if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0)
    {
 #ifdef _X86_
@@ -306,6 +308,34 @@
 #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




More information about the Ros-diffs mailing list