2019-11-10 18:47:35 -08:00
|
|
|
From 812de54c6fc8f93e8fda01f0802397b183adab59 Mon Sep 17 00:00:00 2001
|
2018-07-29 19:36:47 -07:00
|
|
|
From: Andrew Wesie <awesie@gmail.com>
|
|
|
|
Date: Fri, 27 Jul 2018 01:26:56 -0500
|
2019-11-06 19:47:17 -08:00
|
|
|
Subject: [PATCH] ntdll: Use NtContinue to continue execution after exceptions.
|
2018-07-29 19:36:47 -07:00
|
|
|
|
|
|
|
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.
|
|
|
|
---
|
2019-11-06 19:50:28 -08:00
|
|
|
dlls/ntdll/exception.c | 5 +++--
|
|
|
|
dlls/ntdll/signal_i386.c | 3 ++-
|
|
|
|
dlls/ntdll/signal_x86_64.c | 3 ++-
|
|
|
|
3 files changed, 7 insertions(+), 4 deletions(-)
|
2018-07-29 19:36:47 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c
|
2019-11-10 18:47:35 -08:00
|
|
|
index 3b85f1efa..bc972254f 100644
|
2018-07-29 19:36:47 -07:00
|
|
|
--- a/dlls/ntdll/exception.c
|
|
|
|
+++ b/dlls/ntdll/exception.c
|
2019-11-06 19:47:17 -08:00
|
|
|
@@ -671,8 +671,9 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
|
2018-07-29 19:36:47 -07:00
|
|
|
*/
|
|
|
|
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 );
|
|
|
|
+
|
|
|
|
+ return NtSetContextThread( GetCurrentThread(), context );
|
|
|
|
}
|
|
|
|
|
2019-08-19 15:39:18 -07:00
|
|
|
/*************************************************************
|
2018-07-29 19:36:47 -07:00
|
|
|
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
|
2019-11-10 18:47:35 -08:00
|
|
|
index e55164630..8fc885ed4 100644
|
2018-07-29 19:36:47 -07:00
|
|
|
--- a/dlls/ntdll/signal_i386.c
|
|
|
|
+++ b/dlls/ntdll/signal_i386.c
|
2019-11-06 19:47:17 -08:00
|
|
|
@@ -730,6 +730,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
|
2019-09-18 16:23:55 -07:00
|
|
|
return STATUS_UNHANDLED_EXCEPTION;
|
|
|
|
}
|
2018-07-29 19:36:47 -07:00
|
|
|
|
|
|
|
+NTSTATUS WINAPI __syscall_NtContinue( CONTEXT *context, BOOLEAN alert );
|
|
|
|
|
|
|
|
/*******************************************************************
|
2019-09-18 16:23:55 -07:00
|
|
|
* raise_exception
|
2019-11-06 19:47:17 -08:00
|
|
|
@@ -794,7 +795,7 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f
|
2019-09-18 16:23:55 -07:00
|
|
|
NtTerminateProcess( NtCurrentProcess(), rec->ExceptionCode );
|
2019-09-18 15:53:36 -07:00
|
|
|
}
|
2019-09-18 16:23:55 -07:00
|
|
|
done:
|
|
|
|
- return NtSetContextThread( GetCurrentThread(), context );
|
|
|
|
+ return __syscall_NtContinue( context, FALSE );
|
2018-07-29 19:36:47 -07:00
|
|
|
}
|
|
|
|
|
2019-09-18 15:53:36 -07:00
|
|
|
|
2019-11-06 19:50:28 -08:00
|
|
|
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
|
2019-11-10 18:47:35 -08:00
|
|
|
index e48529d73..0e74fda43 100644
|
2019-11-06 19:50:28 -08:00
|
|
|
--- a/dlls/ntdll/signal_x86_64.c
|
|
|
|
+++ b/dlls/ntdll/signal_x86_64.c
|
|
|
|
@@ -2520,6 +2520,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
|
|
|
|
return STATUS_UNHANDLED_EXCEPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
+NTSTATUS WINAPI __syscall_NtContinue( CONTEXT *context, BOOLEAN alert );
|
|
|
|
|
|
|
|
static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
|
|
|
|
{
|
|
|
|
@@ -2582,7 +2583,7 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
- return NtSetContextThread( GetCurrentThread(), context );
|
2019-11-10 18:47:35 -08:00
|
|
|
+ return __syscall_NtContinue( context, FALSE );
|
2019-11-06 19:50:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-29 19:36:47 -07:00
|
|
|
--
|
2019-09-18 16:23:55 -07:00
|
|
|
2.23.0
|
2018-07-29 19:36:47 -07:00
|
|
|
|