update for HEAD-2003091401
[reactos.git] / lib / ntdll / rtl / exception.c
index a68f50a..2dcca6a 100644 (file)
@@ -4,7 +4,10 @@
  * PROJECT:           ReactOS kernel
  * PURPOSE:           User-mode exception support
  * FILE:              lib/ntdll/rtl/exception.c
- * PROGRAMER:         David Welch <welch@cwcom.net>
+ * PROGRAMERS:        David Welch <welch@cwcom.net>
+ *                    Skywing <skywing@valhallalegends.com>
+ * UPDATES:           Skywing, 09/11/2003: Implemented RtlRaiseException and
+ *                    KiUserRaiseExceptionDispatcher.
  */
 
 /* INCLUDES *****************************************************************/
@@ -12,6 +15,7 @@
 #include <ddk/ntddk.h>
 #include <windows.h>
 #include <string.h>
+#include <napi/teb.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -55,10 +59,43 @@ KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
   RtlRaiseException(&NestedExceptionRecord);
 }
 
+/* implemented in except.s */
+VOID
+RtlpCaptureContext(PCONTEXT Context);
+
+/*
+ * @implemented
+ */
 VOID STDCALL
 RtlRaiseException(PEXCEPTION_RECORD ExceptionRecord)
 {
-  DPRINT("RtlRaiseException()\n");
+  CONTEXT Context;
+  NTSTATUS Status;
+
+  RtlpCaptureContext(&Context);
+
+  ExceptionRecord->ExceptionAddress = (PVOID)(*(((PULONG)Context.Ebp)+1));
+  Context.ContextFlags = CONTEXT_FULL;
+
+  Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
+  RtlRaiseException(ExceptionRecord);
+  RtlRaiseStatus(Status); /* If we get to this point, something is seriously wrong... */
+}
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+KiRaiseUserExceptionDispatcher(VOID)
+{
+  EXCEPTION_RECORD ExceptionRecord;
+
+  ExceptionRecord.ExceptionCode = ((PTEB)NtCurrentTeb())->ExceptionCode;
+  ExceptionRecord.ExceptionFlags = 0;
+  ExceptionRecord.ExceptionRecord = NULL;
+  ExceptionRecord.NumberParameters = 0;
+
+  RtlRaiseException(&ExceptionRecord);
 }
 
 VOID STDCALL
@@ -70,6 +107,6 @@ RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
   ExitStatus = (NTSTATUS) (StartAddress)(Parameter);
 
   NtTerminateProcess(NtCurrentProcess(), ExitStatus);
- }
+}
 
 /* EOF */