- Fix a bug in KiRaiseException from 42923 -- a _SEH2_LEAVE wasn't converted to _SEH2...
[reactos.git] / reactos / ntoskrnl / ke / except.c
index b994d07..7a7713b 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);
@@ -95,15 +95,13 @@ KiRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
     CONTEXT LocalContext;
     EXCEPTION_RECORD LocalExceptionRecord;
     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 +110,13 @@ 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_YIELD(return STATUS_INVALID_PARAMETER);
             }
 
             /* Probe the entire parameters now*/
@@ -136,14 +133,17 @@ KiRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
             /* Update the parameter count */
             ExceptionRecord->NumberParameters = ParameterCount;
         }
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+        {
+            /* Don't fail silently */
+            DPRINT1("KiRaiseException: Failed to Probe\n");
+            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,
@@ -160,8 +160,8 @@ KiRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
                         PreviousMode,
                         SearchFrames);
 
-    /* Return the status */
-    return Status;
+    /* We are done */
+    return STATUS_SUCCESS;
 }
 
 /* EOF */