ExRaiseStatus() is now fatal back again as SEH is not needed for valid ops
[reactos.git] / ntoskrnl / ke / catch.c
index 6bdda14..36a80ce 100644 (file)
@@ -28,7 +28,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <ddk/ntddk.h>
+#ifndef LIBCAPTIVE
 #include <reactos/bugcodes.h>
+#endif /* LIBCAPTIVE */
 #include <roscfg.h>
 #include <internal/ke.h>
 #include <internal/ldr.h>
@@ -52,12 +54,15 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
                    BOOLEAN SearchFrames)
 {
   EXCEPTION_DISPOSITION Value;
+#ifndef LIBCAPTIVE
   CONTEXT TContext;
+#endif /* LIBCAPTIVE */
 
   DPRINT("KiDispatchException() called\n");
 
   /* PCR->KeExceptionDispatchCount++; */
 
+#ifndef LIBCAPTIVE
   if (Context == NULL)
     {
       TContext.ContextFlags = CONTEXT_FULL;
@@ -70,6 +75,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
 
       Context = &TContext;
     }
+#endif /* LIBCAPTIVE */
 
 #if 0
   if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) 
@@ -79,6 +85,9 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
 #endif
   if (PreviousMode == UserMode)
     {
+#ifdef LIBCAPTIVE
+      KeBugCheck(0);
+#else /* !LIBCAPTIVE */
       if (SearchFrames)
        {
          PULONG Stack;
@@ -121,6 +130,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
       /* If that fails then bugcheck */
       DbgPrint("Could not terminate thread\n");
       KeBugCheck(KMODE_EXCEPTION_NOT_HANDLED);
+#endif /* LIBCAPTIVE */
     }
   else
     {
@@ -128,6 +138,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
 
       /* PreviousMode == KernelMode */
       
+#ifndef LIBCAPTIVE
       if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_GDB)
        {
          Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
@@ -138,6 +149,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
          Action = KdbEnterDebuggerException (ExceptionRecord, Context, Tf);
        }
 #endif /* KDBG */
+#endif /* LIBCAPTIVE */
       if (Action != kdHandleException)
        {
          Value = RtlpDispatchException (ExceptionRecord, Context);
@@ -149,16 +161,26 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
           */
          if (Value != ExceptionContinueExecution)
            {
+#ifndef LIBCAPTIVE
              KeBugCheck (KMODE_EXCEPTION_NOT_HANDLED);       
+#else /* !LIBCAPTIVE */
+             KeBugCheck (0);         
+#endif /* LIBCAPTIVE */
            }
        }
       else
         {
+#ifndef LIBCAPTIVE
           KeContextToTrapFrame (Context, KeGetCurrentThread()->TrapFrame);
+#else /* !LIBCAPTIVE */
+         KeBugCheck(0);
+#endif /* LIBCAPTIVE */
         }
     }
 }
 
+#ifndef LIBCAPTIVE
+
 VOID STDCALL
 ExRaiseAccessViolation (VOID)
 {
@@ -186,6 +208,7 @@ ExRaiseStatus (IN NTSTATUS Status)
   RtlRaiseException(&ExceptionRecord);
 }
 
+#endif /* LIBCAPTIVE */
 
 NTSTATUS STDCALL
 NtRaiseException (IN PEXCEPTION_RECORD ExceptionRecord,
@@ -195,7 +218,11 @@ NtRaiseException (IN PEXCEPTION_RECORD ExceptionRecord,
   KiDispatchException(ExceptionRecord,
                      Context,
                      PsGetCurrentThread()->Tcb.TrapFrame,
+#ifndef LIBCAPTIVE
                      ExGetPreviousMode(),
+#else /* !LIBCAPTIVE */
+                     KernelMode,
+#endif /* LIBCAPTIVE */
                      SearchFrames);
   return(STATUS_SUCCESS);
 }
@@ -204,7 +231,19 @@ NtRaiseException (IN PEXCEPTION_RECORD ExceptionRecord,
 VOID STDCALL
 RtlRaiseException(PEXCEPTION_RECORD ExceptionRecord)
 {
+#ifndef LIBCAPTIVE
   ZwRaiseException(ExceptionRecord, NULL, TRUE);
+#else /* !LIBCAPTIVE */
+CONTEXT *LocalContext;
+
+  /* Do not use local variable to benefit from ElectricFence boundary checks */
+  LocalContext=ExAllocatePool(PagedPool,sizeof(LocalContext->ContextFlags));
+  LocalContext->ContextFlags=0;
+
+  NtRaiseException(ExceptionRecord, LocalContext, TRUE);
+
+  ExFreePool(LocalContext);
+#endif /* LIBCAPTIVE */
 }
 
 /* EOF */