- Use _SEH2_YIELD when returning from an exception instead of returning outside the...
[reactos.git] / reactos / ntoskrnl / ke / except.c
index b994d07..fd4ba95 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <ntoskrnl.h>
 #define NDEBUG
-#include <internal/debug.h>
+#include <debug.h>
 
 /* FUNCTIONS *****************************************************************/
 
@@ -49,7 +49,7 @@ KiContinue(IN PCONTEXT Context,
     if (KeGetCurrentIrql() < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
 
     /* Set up SEH to validate the context */
-    _SEH_TRY
+    _SEH2_TRY
     {
         /* Check the previous mode */
         if (PreviousMode != KernelMode)
@@ -69,12 +69,12 @@ KiContinue(IN PCONTEXT Context,
                                  KernelMode);
         }
     }
-    _SEH_HANDLE
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {
         /* Save the exception code */
-        Status = _SEH_GetExceptionCode();
+        Status = _SEH2_GetExceptionCode();
     }
-    _SEH_END;
+    _SEH2_END;
 
     /* Lower the IRQL if needed */
     if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql);
@@ -97,13 +97,12 @@ KiRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
     ULONG ParameterCount, Size;
     NTSTATUS Status = STATUS_SUCCESS;
 
-    /* Set up SEH */
-    _SEH_TRY
+    /* Check if we need to probe */
+    if (PreviousMode != KernelMode)
     {
-        /* Check the previous mode */
-        if (PreviousMode != KernelMode)
+        /* Set up SEH */
+        _SEH2_TRY
         {
-#if 0
             /* Probe the context */
             ProbeForRead(Context, sizeof(CONTEXT), sizeof(ULONG));
 
@@ -112,14 +111,14 @@ KiRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
                          FIELD_OFFSET(EXCEPTION_RECORD, NumberParameters) +
                          sizeof(ULONG),
                          sizeof(ULONG));
-#endif
+
             /* Validate the maximum parameters */
             if ((ParameterCount = ExceptionRecord->NumberParameters) >
                 EXCEPTION_MAXIMUM_PARAMETERS)
             {
                 /* Too large */
                 Status = STATUS_INVALID_PARAMETER;
-                _SEH_LEAVE;
+                _SEH2_LEAVE;
             }
 
             /* Probe the entire parameters now*/
@@ -136,14 +135,15 @@ KiRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
             /* Update the parameter count */
             ExceptionRecord->NumberParameters = ParameterCount;
         }
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+        {
+            DbgBreakPoint();
+
+            /* Return the exception code */
+            _SEH2_YIELD(return _SEH2_GetExceptionCode());
+        }
+        _SEH2_END;
     }
-    _SEH_HANDLE
-    {
-        /* Get the exception code */
-        Status = _SEH_GetExceptionCode();
-    }
-    _SEH_END;
-    if (!NT_SUCCESS(Status)) return Status;
 
     /* Convert the context record */
     KeContextToTrapFrame(Context,