Matt Robinson : ntdll: Catch page fault in RtlWow64EnableFsRedirectionEx.

Alexandre Julliard julliard at winehq.org
Fri Oct 7 15:09:14 CDT 2016


Module: wine
Branch: stable
Commit: 36932d220f08c475819f6b189be4bdfe4bfda786
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=36932d220f08c475819f6b189be4bdfe4bfda786

Author: Matt Robinson <git at nerdoftheherd.com>
Date:   Sat Aug  6 23:00:21 2016 +0100

ntdll: Catch page fault in RtlWow64EnableFsRedirectionEx.

Signed-off-by: Matt Robinson <git at nerdoftheherd.com>
Signed-off-by: André Hentschel <nerv at dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 4a6bd3d2008f6ab4d91fcbeb6c410099932c97e7)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/ntdll/directory.c       | 13 +++++++++++--
 dlls/ntdll/tests/directory.c |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 0902759..49855dd 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -106,6 +106,7 @@
 #include "wine/list.h"
 #include "wine/library.h"
 #include "wine/debug.h"
+#include "wine/exception.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(file);
 
@@ -3242,9 +3243,17 @@ NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable )
 NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
 {
     if (!is_wow64) return STATUS_NOT_IMPLEMENTED;
-    if (((ULONG_PTR)old_value >> 16) == 0) return STATUS_ACCESS_VIOLATION;
 
-    *old_value = !ntdll_get_thread_data()->wow64_redir;
+    __TRY
+    {
+        *old_value = !ntdll_get_thread_data()->wow64_redir;
+    }
+    __EXCEPT_PAGE_FAULT
+    {
+        return STATUS_ACCESS_VIOLATION;
+    }
+    __ENDTRY
+
     ntdll_get_thread_data()->wow64_redir = !disable;
     return STATUS_SUCCESS;
 }
diff --git a/dlls/ntdll/tests/directory.c b/dlls/ntdll/tests/directory.c
index 7b1002a..ec170b2 100644
--- a/dlls/ntdll/tests/directory.c
+++ b/dlls/ntdll/tests/directory.c
@@ -444,6 +444,8 @@ static void test_redirection(void)
     ok( status == STATUS_ACCESS_VIOLATION, "RtlWow64EnableFsRedirectionEx failed with status %x\n", status );
     status = pRtlWow64EnableFsRedirectionEx( TRUE, (void*)1 );
     ok( status == STATUS_ACCESS_VIOLATION, "RtlWow64EnableFsRedirectionEx failed with status %x\n", status );
+    status = pRtlWow64EnableFsRedirectionEx( TRUE, (void*)0xDEADBEEF );
+    ok( status == STATUS_ACCESS_VIOLATION, "RtlWow64EnableFsRedirectionEx failed with status %x\n", status );
 
     status = pRtlWow64EnableFsRedirection( FALSE );
     ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );




More information about the wine-cvs mailing list