https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e6af7d9dfef7426e687fb…
commit e6af7d9dfef7426e687fb8436d630f0ecda3856b
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Fri Mar 2 07:48:34 2018 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Jun 5 13:52:42 2021 +0200
[RTL] Simplify RtlRaiseException
---
sdk/lib/rtl/amd64/except.c | 64 ++++++++++++++++------------------------------
1 file changed, 22 insertions(+), 42 deletions(-)
diff --git a/sdk/lib/rtl/amd64/except.c b/sdk/lib/rtl/amd64/except.c
index d93d77816e0..aebd525774b 100644
--- a/sdk/lib/rtl/amd64/except.c
+++ b/sdk/lib/rtl/amd64/except.c
@@ -19,57 +19,37 @@ RtlRaiseException(IN PEXCEPTION_RECORD ExceptionRecord)
{
CONTEXT Context;
NTSTATUS Status = STATUS_INVALID_DISPOSITION;
- ULONG64 ImageBase;
- PRUNTIME_FUNCTION FunctionEntry;
- PVOID HandlerData;
- ULONG64 EstablisherFrame;
- /* Capture the context */
+ /* Capture the current context */
RtlCaptureContext(&Context);
- /* Get the function entry for this function */
- FunctionEntry = RtlLookupFunctionEntry(Context.Rip,
- &ImageBase,
- NULL);
+ /* Fix up Context.Rip for the caller */
+ Context.Rip = (ULONG64)_ReturnAddress();
- /* Check if we found it */
- if (FunctionEntry)
+ /* Fix up Context.Rsp for the caller */
+ Context.Rsp = (ULONG64)_AddressOfReturnAddress() + 8;
+
+ /* Save the exception address */
+ ExceptionRecord->ExceptionAddress = (PVOID)Context.Rip;
+
+ /* Check if user mode debugger is active */
+ if (RtlpCheckForActiveDebugger())
+ {
+ /* Raise an exception immediately */
+ Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
+ }
+ else
{
- /* 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())
+ /* Dispatch the exception and check if we should continue */
+ if (!RtlDispatchException(ExceptionRecord, &Context))
{
- /* Raise an exception immediately */
- Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
+ /* Raise the exception */
+ Status = ZwRaiseException(ExceptionRecord, &Context, FALSE);
}
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);
- }
+ /* Continue, go back to previous context */
+ Status = ZwContinue(&Context, FALSE);
}
}