ntdll: Catch exceptions when accessing the application provided pointer

André Hentschel nerv at dawncrow.de
Thu Dec 22 11:42:18 CST 2011


Fixes the UpdateInstaller.exe from "WSUS Offline Update 7.2 - Generator" (wsusoffline.net) with a wow64 setup
see also http://trac.wsusoffline.net/trac.fcgi/browser/trunk/client/UpdateInstaller.au3
---
 dlls/ntdll/directory.c       |   11 ++++++++++-
 dlls/ntdll/tests/directory.c |    5 +++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 65c8b8f..da01239 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -79,6 +79,7 @@
 #include "winternl.h"
 #include "ddk/wdm.h"
 #include "ntdll_misc.h"
+#include "wine/exception.h"
 #include "wine/unicode.h"
 #include "wine/server.h"
 #include "wine/list.h"
@@ -3006,7 +3007,15 @@ NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable )
 NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
 {
     if (!is_wow64) return STATUS_NOT_IMPLEMENTED;
-    *old_value = !ntdll_get_thread_data()->wow64_redir;
+    __TRY
+    {
+        *old_value = !ntdll_get_thread_data()->wow64_redir;
+    }
+    __EXCEPT_ALL
+    {
+        return GetExceptionCode();
+    }
+    __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 c74bf34..d773263 100644
--- a/dlls/ntdll/tests/directory.c
+++ b/dlls/ntdll/tests/directory.c
@@ -287,6 +287,11 @@ static void test_redirection(void)
     ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
     ok( !cur, "RtlWow64EnableFsRedirectionEx got %u\n", cur );
 
+    status = pRtlWow64EnableFsRedirectionEx( TRUE, NULL );
+    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 );
     status = pRtlWow64EnableFsRedirectionEx( FALSE, &cur );
-- 

Best Regards, André Hentschel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Nachrichtenteil als Anhang
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20111222/8a9a840a/attachment.ksh>


More information about the wine-patches mailing list