update for HEAD-2003091401
[reactos.git] / ntoskrnl / ke / i386 / exp.c
index ccf8d7d..40cd51b 100644 (file)
  * PROJECT:              ReactOS kernel
  * FILE:                 ntoskrnl/ke/i386/exp.c
  * PURPOSE:              Handling exceptions
- * PROGRAMMER:           David Welch (welch@cwcom.net)
+ * PROGRAMMERS:          David Welch (welch@cwcom.net)
+ *                       Skywing (skywing@valhallalegends.com)
  * REVISION HISTORY:
  *              ??/??/??: Created
+ *              09/12/03: KeRaiseUserException added (Skywing).
  */
 
 /* INCLUDES *****************************************************************/
 
-#include <ddk/ntddk.h>
 #include <roscfg.h>
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <internal/ke.h>
 #include <internal/i386/segment.h>
@@ -40,6 +42,7 @@
 #include <ntdll/ldr.h>
 #include <internal/safe.h>
 #include <internal/kd.h>
+#include <internal/ldr.h>
 
 #define NDEBUG
 #include <internal/debug.h>
@@ -181,8 +184,9 @@ KiKernelTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2)
       Er.NumberParameters = 0;
     }
 
-  Er.ExceptionFlags = (STATUS_SINGLE_STEP == (NTSTATUS) Er.ExceptionCode || STATUS_BREAKPOINT == (NTSTATUS) Er.ExceptionCode ?
-                       0 : EXCEPTION_NONCONTINUABLE);
+  Er.ExceptionFlags = ((NTSTATUS) STATUS_SINGLE_STEP == (NTSTATUS) Er.ExceptionCode
+    || (NTSTATUS) STATUS_BREAKPOINT == (NTSTATUS) Er.ExceptionCode) ?
+    EXCEPTION_NONCONTINUABLE : 0;
 
   KiDispatchException(&Er, 0, Tf, KernelMode, TRUE);
 
@@ -644,3 +648,19 @@ KeInitExceptions(VOID)
    set_system_call_gate(0x2d,(int)interrupt_handler2d);
    set_system_call_gate(0x2e,(int)interrupt_handler2e);
 }
+
+/*
+ * @implemented
+ */
+
+VOID STDCALL
+KeRaiseUserException(IN NTSTATUS ExceptionCode)
+{
+   /* FIXME: This needs SEH */
+
+   PKTHREAD Thread = KeGetCurrentThread();
+
+   ProbeForWrite(&Thread->Teb->ExceptionCode, sizeof(NTSTATUS), sizeof(NTSTATUS)); /* NT doesn't check this -- bad? */
+   Thread->TrapFrame->Eip = (ULONG_PTR)LdrpGetSystemDllRaiseExceptionDispatcher();
+   Thread->Teb->ExceptionCode = ExceptionCode;
+}