wine-staging/patches/ntdll-NtContinue/0002-Use-NtContinue-to-continue-execution-after-exception.patch
2019-09-18 18:23:55 -05:00

65 lines
2.3 KiB
Diff

From be53833558c250e83e7a92f466c5d845bea4f0f1 Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Fri, 27 Jul 2018 01:26:56 -0500
Subject: [PATCH] Use NtContinue to continue execution after exceptions.
NtContinue is exported by ntdll and some programs expect it to be used to
restore the thread context after an exception handler returns
EXCEPTION_CONTINUE_EXECUTION. It must take a context as its first argument
and restore that context.
Current implementation is a simple wrapper around NtSetContextThread. It is
unlikely that it has the correct behavior if called by an external caller.
The __syscall_NtContinue wrapper is used so that it can be hooked by a
third-party.
---
dlls/ntdll/exception.c | 9 +++++++--
dlls/ntdll/signal_i386.c | 3 ++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c
index 3b85f1efa..411d2bf5b 100644
--- a/dlls/ntdll/exception.c
+++ b/dlls/ntdll/exception.c
@@ -671,8 +671,13 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
*/
NTSTATUS WINAPI NtContinue( CONTEXT *context, BOOLEAN alert )
{
- FIXME( "(%p, %d) stub!\n", context, alert );
- return STATUS_NOT_IMPLEMENTED;
+ TRACE( "(%p, %d) stub!\n", context, alert );
+
+ /* NtSetContextThread will not have the intended behavior for a partial context. */
+ if ((context->ContextFlags & CONTEXT_FULL) != CONTEXT_FULL)
+ return STATUS_NOT_IMPLEMENTED;
+
+ return NtSetContextThread( GetCurrentThread(), context );
}
/*************************************************************
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 746d77c75..6200721ca 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -727,6 +727,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
return STATUS_UNHANDLED_EXCEPTION;
}
+NTSTATUS WINAPI __syscall_NtContinue( CONTEXT *context, BOOLEAN alert );
/*******************************************************************
* raise_exception
@@ -791,7 +792,7 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f
NtTerminateProcess( NtCurrentProcess(), rec->ExceptionCode );
}
done:
- return NtSetContextThread( GetCurrentThread(), context );
+ return __syscall_NtContinue( context, FALSE );
}
--
2.23.0