Author: tkreuzer
Date: Sat Nov 7 16:26:12 2009
New Revision: 44001
URL:
http://svn.reactos.org/svn/reactos?rev=44001&view=rev
Log:
[RTL]
- Implement RtlRaiseException
Modified:
branches/ros-amd64-bringup/reactos/lib/rtl/amd64/unwind.c
branches/ros-amd64-bringup/reactos/lib/rtl/exception.c
Modified: branches/ros-amd64-bringup/reactos/lib/rtl/amd64/unwind.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/r…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/rtl/amd64/unwind.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/rtl/amd64/unwind.c [iso-8859-1] Sat Nov 7
16:26:12 2009
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * PURPOSE: Exception related functions
+ * PURPOSE: Unwinding related functions
* PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org)
*/
@@ -27,6 +27,11 @@
#define UWOP_SAVE_XMM128 8
#define UWOP_SAVE_XMM128_FAR 9
#define UWOP_PUSH_MACHFRAME 10
+
+#define UNW_FLAG_NHANDLER 0
+#define UNW_FLAG_EHANDLER 1
+#define UNW_FLAG_UHANDLER 2
+#define UNW_FLAG_CHAININFO 4
typedef unsigned char UBYTE;
@@ -611,3 +616,69 @@
return;
}
+
+// FIXME: move to different file
+VOID
+NTAPI
+RtlRaiseException(IN PEXCEPTION_RECORD ExceptionRecord)
+{
+ CONTEXT Context;
+ NTSTATUS Status;
+ ULONG64 ImageBase;
+ PRUNTIME_FUNCTION FunctionEntry;
+ PVOID HandlerData;
+ ULONG64 EstablisherFrame;
+
+ /* Capture the context */
+ RtlCaptureContext(&Context);
+
+ /* Get the function entry for this function */
+ FunctionEntry = RtlLookupFunctionEntry(Context.Rip,
+ &ImageBase,
+ NULL);
+
+ /* Check if we found it */
+ if (FunctionEntry)
+ {
+ /* Unwind to the caller of this function */
+ RtlVirtualUnwind(UNW_FLAG_NHANDLER,
+ ImageBase,
+ Context.Rip,
+ FunctionEntry,
+ &Context,
+ &HandlerData,
+ &EstablisherFrame,
+ NULL);
+
+ /* Save the exception address */
+ ExceptionRecord->ExceptionAddress = (PVOID)Context.Rip;
+
+ /* Write the context flag */
+ Context.ContextFlags = CONTEXT_FULL;
+
+ /* Check if user mode debugger is active */
+ if (RtlpCheckForActiveDebugger())
+ {
+ /* Raise an exception immediately */
+ Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
+ }
+ else
+ {
+ /* Dispatch the exception and check if we should continue */
+ if (!RtlDispatchException(ExceptionRecord, &Context))
+ {
+ /* Raise the exception */
+ Status = ZwRaiseException(ExceptionRecord, &Context, FALSE);
+ }
+ else
+ {
+ /* Continue, go back to previous context */
+ Status = ZwContinue(&Context, FALSE);
+ }
+ }
+ }
+
+ /* If we returned, raise a status */
+ RtlRaiseStatus(Status);
+}
+
Modified: branches/ros-amd64-bringup/reactos/lib/rtl/exception.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/r…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/rtl/exception.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/rtl/exception.c [iso-8859-1] Sat Nov 7
16:26:12 2009
@@ -17,7 +17,7 @@
/* FUNCTIONS ***************************************************************/
-#if !defined(_M_IX86)
+#if !defined(_M_IX86) && !defined(_M_AMD64)
/*
* @implemented
@@ -62,6 +62,10 @@
/* If we returned, raise a status */
RtlRaiseStatus(Status);
}
+
+#endif
+
+#if !defined(_M_IX86)
#ifdef _MSC_VER
#pragma warning(push)