Martin Storsjo : ntdll: Implement RtlRaiseException in assembly to fix continuing from exceptions.

Alexandre Julliard julliard at winehq.org
Thu May 28 17:11:10 CDT 2020


Module: wine
Branch: master
Commit: e0c8c4c3cd2fc5db5da7cd7b5889ac306db356c3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e0c8c4c3cd2fc5db5da7cd7b5889ac306db356c3

Author: Martin Storsjo <martin at martin.st>
Date:   Thu May 28 11:14:47 2020 +0300

ntdll: Implement RtlRaiseException in assembly to fix continuing from exceptions.

If the handlers returned ExceptionContinueExecution and we restore
the stored context, make sure it's a context that ends up returning
from the RtlRaiseException function.

This matches how it's done on x86_64.

Signed-off-by: Martin Storsjo <martin at martin.st>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/signal_arm64.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
index 8e7296d207..7488b90d63 100644
--- a/dlls/ntdll/signal_arm64.c
+++ b/dlls/ntdll/signal_arm64.c
@@ -2097,14 +2097,29 @@ NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL
 /***********************************************************************
  *		RtlRaiseException (NTDLL.@)
  */
-void WINAPI RtlRaiseException( EXCEPTION_RECORD *rec )
-{
-    CONTEXT context;
-
-    RtlCaptureContext( &context );
-    rec->ExceptionAddress = (LPVOID)context.Pc;
-    RtlRaiseStatus( NtRaiseException( rec, &context, TRUE ));
-}
+__ASM_STDCALL_FUNC( RtlRaiseException, 4,
+                   "sub sp, sp, #0x3b0\n\t" /* 0x390 (context) + 0x20 */
+                   "stp x29, x30, [sp]\n\t"
+                   __ASM_CFI(".cfi_def_cfa x29, 944\n\t")
+                   __ASM_CFI(".cfi_offset x30, -936\n\t")
+                   __ASM_CFI(".cfi_offset x29, -944\n\t")
+                   "mov x29, sp\n\t"
+                   "str x0,  [sp, #0x10]\n\t"
+                   "add x0,  sp, #0x20\n\t"
+                   "bl " __ASM_NAME("RtlCaptureContext") "\n\t"
+                   "add x1,  sp, #0x20\n\t"      /* context pointer */
+                   "add x2,  sp, #0x3b0\n\t"     /* orig stack pointer */
+                   "str x2,  [x1, #0x100]\n\t"   /* context->Sp */
+                   "ldr x0,  [sp, #0x10]\n\t"    /* original first parameter */
+                   "str x0,  [x1, #0x08]\n\t"    /* context->X0 */
+                   "ldp x4, x5, [sp]\n\t"        /* frame pointer, return address */
+                   "stp x4, x5, [x1, #0xf0]\n\t" /* context->Fp, Lr */
+                   "str  x5, [x1, #0x108]\n\t"   /* context->Pc */
+                   "str  x5, [x1, #0x108]\n\t"   /* context->Pc */
+                   "str  x5, [x0, #0x10]\n\t"    /* rec->ExceptionAddress */
+                   "mov  x2, #1\n\t"
+                   "bl " __ASM_NAME("NtRaiseException") "\n\t"
+                   "bl " __ASM_NAME("RtlRaiseStatus") /* does not return */ );
 
 /*************************************************************************
  *             RtlCaptureStackBackTrace (NTDLL.@)




More information about the wine-cvs mailing list