Updated ntdll-NtContinue patchset

This commit is contained in:
Alistair Leslie-Hughes 2018-07-30 12:36:47 +10:00
parent 00de4984f6
commit 1de1a96f1e
3 changed files with 71 additions and 3 deletions

View File

@ -0,0 +1,64 @@
From a5df41839d388e3bb0f8aefde70edcc8476429b2 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 664b620..236f600 100644
--- a/dlls/ntdll/exception.c
+++ b/dlls/ntdll/exception.c
@@ -311,8 +311,13 @@ ULONG WINAPI RtlRemoveVectoredExceptionHandler( PVOID handler )
*/
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 f0de17a..d1ae9b8 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -2605,6 +2605,7 @@ __ASM_STDCALL_FUNC( RtlUnwind, 16,
__ASM_CFI(".cfi_same_value %ebp\n\t")
"ret $16" ) /* actually never returns */
+NTSTATUS WINAPI __syscall_NtContinue( CONTEXT *context, BOOLEAN alert );
/*******************************************************************
* NtRaiseException (NTDLL.@)
@@ -2612,7 +2613,7 @@ __ASM_STDCALL_FUNC( RtlUnwind, 16,
NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
{
NTSTATUS status = raise_exception( rec, context, first_chance );
- if (status == STATUS_SUCCESS) NtSetContextThread( GetCurrentThread(), context );
+ if (status == STATUS_SUCCESS) __syscall_NtContinue(context, FALSE);
return status;
}
--
1.9.1

View File

@ -1 +1,2 @@
Fixes: [31910] Add stub for NtContinue
Fixes: [31910] Add stub for NtContinue
Fixes: [45327] Helps League of Legends anti-cheat engine.

View File

@ -5065,14 +5065,17 @@ fi
# |
# | This patchset fixes the following Wine bugs:
# | * [#31910] Add stub for NtContinue
# | * [#45327] Helps League of Legends anti-cheat engine.
# |
# | Modified files:
# | * dlls/ntdll/exception.c, dlls/ntdll/ntdll.spec
# | * dlls/ntdll/exception.c, dlls/ntdll/ntdll.spec, dlls/ntdll/signal_i386.c
# |
if test "$enable_ntdll_NtContinue" -eq 1; then
patch_apply ntdll-NtContinue/0001-ntdll-Add-stub-for-NtContinue.patch
patch_apply ntdll-NtContinue/0002-Use-NtContinue-to-continue-execution-after-exception.patch
(
printf '%s\n' '+ { "Michael Müller", "ntdll: Add stub for NtContinue.", 1 },';
printf '%s\n' '+ { "Andrew Wesie", "Use NtContinue to continue execution after exceptions.", 1 },';
) >> "$patchlist"
fi
@ -5112,7 +5115,7 @@ fi
# Patchset ntdll-NtQueryInformationProcess-ProcessCookie
# |
# | This patchset fixes the following Wine bugs:
# | * [#45327] Add RtlSetUnhandledExceptionFilter stub
# | * [#45327] Added support ProcessCookie in NtQueryInformationProcess
# |
# | Modified files:
# | * dlls/ntdll/process.c