From a8a944c22099194c6458698eadd58f343d69fd22 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Thu, 28 May 2020 11:14:45 +0300 Subject: [PATCH] ntdll: Keep the previous iteration of NonVolatileRegisters in call_function_handlers. Some language specific handlers, called by call_handler, can use the NonVolatileRegisters to restore the context before running code, and that assumes that NonVolatileRegisters contains the frame pointer as it was within the function (before unwinding). Signed-off-by: Martin Storsjo Signed-off-by: Alexandre Julliard --- dlls/ntdll/signal_arm64.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 2af1e238cea..e544a1c2a4c 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -849,14 +849,16 @@ static NTSTATUS call_function_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_con EXCEPTION_REGISTRATION_RECORD *teb_frame = NtCurrentTeb()->Tib.ExceptionList; UNWIND_HISTORY_TABLE table; DISPATCHER_CONTEXT dispatch; - CONTEXT context; + CONTEXT context, prev_context; NTSTATUS status; context = *orig_context; dispatch.TargetPc = 0; dispatch.ContextRecord = &context; dispatch.HistoryTable = &table; - dispatch.NonVolatileRegisters = (BYTE *)&context.u.s.X19; + prev_context = context; + dispatch.NonVolatileRegisters = (BYTE *)&prev_context.u.s.X19; + for (;;) { status = virtual_unwind( UNW_FLAG_EHANDLER, &dispatch, &context ); @@ -933,6 +935,7 @@ static NTSTATUS call_function_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_con } if (context.Sp == (ULONG64)NtCurrentTeb()->Tib.StackBase) break; + prev_context = context; } return STATUS_UNHANDLED_EXCEPTION; }