Alexandre Julliard : ntdll: Set the I/O status block through the 32-bit pointer for Wow64 processes.

Alexandre Julliard julliard at winehq.org
Thu Aug 5 16:13:39 CDT 2021


Module: wine
Branch: master
Commit: 61b123fae960766df8f51cff8be195e6755429c3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=61b123fae960766df8f51cff8be195e6755429c3

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Aug  5 19:36:28 2021 +0200

ntdll: Set the I/O status block through the 32-bit pointer for Wow64 processes.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/file.c         |  6 +++---
 dlls/ntdll/unix/process.c      |  2 +-
 dlls/ntdll/unix/serial.c       | 20 ++++++--------------
 dlls/ntdll/unix/server.c       |  4 +---
 dlls/ntdll/unix/unix_private.h | 34 ++++++++++++++++++++++++++++++++++
 5 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 1d720c863f4..712f94ec43f 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -1966,7 +1966,7 @@ static NTSTATUS get_mountmgr_fs_info( HANDLE handle, int fd, struct mountmgr_uni
     OBJECT_ATTRIBUTES attr;
     UNICODE_STRING string;
     char *unix_name;
-    IO_STATUS_BLOCK io;
+    IO_STATUS_BLOCK io = {0};
     HANDLE mountmgr;
     NTSTATUS status;
     int letter;
@@ -4937,7 +4937,7 @@ static NTSTATUS get_io_timeouts( HANDLE handle, enum server_fd_type type, ULONG
     {
         /* GetCommTimeouts */
         SERIAL_TIMEOUTS st;
-        IO_STATUS_BLOCK io;
+        IO_STATUS_BLOCK io = {0};
 
         status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io,
                                         IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, &st, sizeof(st) );
@@ -5024,7 +5024,7 @@ static NTSTATUS get_io_avail_mode( HANDLE handle, enum server_fd_type type, BOOL
     {
         /* GetCommTimeouts */
         SERIAL_TIMEOUTS st;
-        IO_STATUS_BLOCK io;
+        IO_STATUS_BLOCK io = {0};
 
         status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io,
                                         IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, &st, sizeof(st) );
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index e76e49ca69d..d7f3edf4330 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -407,7 +407,7 @@ static void set_stdio_fd( int stdin_fd, int stdout_fd )
  */
 static BOOL is_unix_console_handle( HANDLE handle )
 {
-    IO_STATUS_BLOCK io;
+    IO_STATUS_BLOCK io = {0};
     return !NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, IOCTL_CONDRV_IS_UNIX,
                                    NULL, 0, NULL, 0 );
 }
diff --git a/dlls/ntdll/unix/serial.c b/dlls/ntdll/unix/serial.c
index 9454185e172..ab2ef9330a5 100644
--- a/dlls/ntdll/unix/serial.c
+++ b/dlls/ntdll/unix/serial.c
@@ -841,7 +841,7 @@ typedef struct async_commio
 {
     HANDLE              hDevice;
     DWORD*              events;
-    IO_STATUS_BLOCK*    iosb;
+    client_ptr_t        iosb;
     HANDLE              hEvent;
     DWORD               evtmask;
     DWORD               cookie;
@@ -995,23 +995,15 @@ static void CALLBACK wait_for_event(LPVOID arg)
         }
         if (needs_close) close( fd );
     }
-    if (commio->iosb)
-    {
-        if (*commio->events)
-        {
-            commio->iosb->u.Status = STATUS_SUCCESS;
-            commio->iosb->Information = sizeof(DWORD);
-        }
-        else
-            commio->iosb->u.Status = STATUS_CANCELLED;
-    }
+    if (*commio->events) set_async_iosb( commio->iosb, STATUS_SUCCESS, sizeof(DWORD) );
+    else set_async_iosb( commio->iosb, STATUS_CANCELLED, 0 );
     stop_waiting(commio->hDevice);
     if (commio->hEvent) NtSetEvent(commio->hEvent, NULL);
     free( commio );
     NtTerminateThread( GetCurrentThread(), 0 );
 }
 
-static NTSTATUS wait_on(HANDLE hDevice, int fd, HANDLE hEvent, PIO_STATUS_BLOCK piosb, DWORD* events)
+static NTSTATUS wait_on(HANDLE hDevice, int fd, HANDLE hEvent, client_ptr_t iosb_ptr, DWORD* events)
 {
     async_commio*       commio;
     NTSTATUS            status;
@@ -1025,7 +1017,7 @@ static NTSTATUS wait_on(HANDLE hDevice, int fd, HANDLE hEvent, PIO_STATUS_BLOCK
 
     commio->hDevice = hDevice;
     commio->events  = events;
-    commio->iosb    = piosb;
+    commio->iosb    = iosb_ptr;
     commio->hEvent  = hEvent;
     commio->pending_write = 0;
     status = get_wait_mask(commio->hDevice, &commio->evtmask, &commio->cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL, TRUE);
@@ -1315,7 +1307,7 @@ static NTSTATUS io_control( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, vo
     case IOCTL_SERIAL_WAIT_ON_MASK:
         if (out_buffer && out_size == sizeof(DWORD))
         {
-            if (!(status = wait_on(device, fd, event, io, out_buffer)))
+            if (!(status = wait_on(device, fd, event, iosb_client_ptr(io), out_buffer)))
                 sz = sizeof(DWORD);
         }
         else
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 2ec70db9390..986eb6c3250 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -377,7 +377,6 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
         break;
     case APC_ASYNC_IO:
     {
-        IO_STATUS_BLOCK *iosb = wine_server_get_ptr( call->async_io.sb );
         struct async_fileio *user = wine_server_get_ptr( call->async_io.user );
         ULONG_PTR info = 0;
 
@@ -386,8 +385,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
         if (result->async_io.status != STATUS_PENDING)
         {
             result->async_io.total = info;
-            iosb->Status = result->async_io.status;
-            iosb->Information = info;
+            set_async_iosb( call->async_io.sb, result->async_io.status, info );
         }
         break;
     }
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index c4af5831cdb..61c290c156d 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -354,8 +354,42 @@ static inline NTSTATUS wait_async( HANDLE handle, BOOL alertable )
     return NtWaitForSingleObject( handle, alertable, NULL );
 }
 
+static inline void set_async_iosb( client_ptr_t iosb, NTSTATUS status, ULONG_PTR info )
+{
+    if (!iosb) return;
+#ifdef _WIN64
+    if (NtCurrentTeb()->WowTebOffset)
+    {
+        struct iosb32
+        {
+            NTSTATUS Status;
+            ULONG    Information;
+        } *io = wine_server_get_ptr( iosb );
+        io->Status = status;
+        io->Information = info;
+    }
+    else
+#endif
+    {
+        IO_STATUS_BLOCK *io = wine_server_get_ptr( iosb );
+#ifdef NONAMELESSUNION
+        io->u.Status = status;
+#else
+        io->Status = status;
+#endif
+        io->Information = info;
+    }
+}
+
 static inline client_ptr_t iosb_client_ptr( IO_STATUS_BLOCK *io )
 {
+#ifdef _WIN64
+#ifdef NONAMELESSUNION
+    if (io && NtCurrentTeb()->WowTebOffset) return wine_server_client_ptr( io->u.Pointer );
+#else
+    if (io && NtCurrentTeb()->WowTebOffset) return wine_server_client_ptr( io->Pointer );
+#endif
+#endif
     return wine_server_client_ptr( io );
 }
 




More information about the wine-cvs mailing list