Zebediah Figura : ntdll: Do not fill the IOSB if a device IRP failed synchronously.

Alexandre Julliard julliard at winehq.org
Tue Sep 14 16:00:13 CDT 2021


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Tue Sep 14 01:02:44 2021 -0500

ntdll: Do not fill the IOSB if a device IRP failed synchronously.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/volume.c       | 16 ++++++++--------
 dlls/ntdll/unix/server.c           |  1 +
 dlls/ntoskrnl.exe/tests/ntoskrnl.c | 28 ++++++++++++++--------------
 server/async.c                     | 10 +++++++++-
 4 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index cb35de6add1..723dfabb817 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -1641,8 +1641,8 @@ static void test_mountmgr_query_points(void)
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, NULL, 0, NULL, 0 );
     ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    todo_wine ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
-    todo_wine ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
+    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     memset( input, 0, sizeof(*input) );
 
@@ -1651,16 +1651,16 @@ static void test_mountmgr_query_points(void)
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input) - 1, NULL, 0 );
     ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    todo_wine ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
-    todo_wine ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
+    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     io.Status = 0xdeadf00d;
     io.Information = 0xdeadf00d;
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input), NULL, 0 );
     ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    todo_wine ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
-    todo_wine ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
+    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     io.Status = 0xdeadf00d;
     io.Information = 0xdeadf00d;
@@ -1668,8 +1668,8 @@ static void test_mountmgr_query_points(void)
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input), output, sizeof(*output) - 1 );
     ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    todo_wine ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
-    todo_wine ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
+    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
     ok(output->Size == 0xcccccccc, "got size %u\n", output->Size);
     ok(output->NumberOfMountPoints == 0xcccccccc, "got count %u\n", output->NumberOfMountPoints);
 
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index d0cfd4cd46c..08733fba710 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -385,6 +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;
+            /* the server will pass us NULL if a call failed synchronously */
             set_async_iosb( call->async_io.sb, result->async_io.status, info );
         }
         break;
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index bd34e37e176..edc4a607225 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -690,8 +690,8 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
     ok(ret == expect_status, "got %#x\n", ret);
     if (NT_ERROR(params->iosb_status))
     {
-        todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
-        todo_wine ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
+        ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
+        ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
     }
     else
     {
@@ -726,8 +726,8 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
             "got %#x\n", ret);
     if (!params->pending && NT_ERROR(params->iosb_status))
     {
-        todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
-        todo_wine ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
+        ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
+        ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
         ret = WaitForSingleObject(event, 0);
         ok(ret == WAIT_TIMEOUT, "got %d\n", ret);
     }
@@ -778,8 +778,8 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
             "got %#x\n", ret);
     if (!params->pending && NT_ERROR(params->iosb_status))
     {
-        todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
-        todo_wine ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
+        ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
+        ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
         ret = WaitForSingleObject(event, 0);
         ok(ret == WAIT_TIMEOUT, "got %d\n", ret);
     }
@@ -810,8 +810,8 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
             "got %#x\n", ret);
     if (!params->pending && NT_ERROR(params->iosb_status))
     {
-        todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
-        todo_wine ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
+        ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
+        ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
         ret = WaitForSingleObject(file, 0);
         ok(ret == WAIT_TIMEOUT, "got %d\n", ret);
     }
@@ -846,8 +846,8 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
                 "got %#x\n", ret);
         if (!params->pending && NT_ERROR(params->iosb_status))
         {
-            todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
-            todo_wine ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
+            ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
+            ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
             ret = WaitForSingleObject(event, 0);
             ok(ret == WAIT_TIMEOUT, "got %d\n", ret);
         }
@@ -915,8 +915,8 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params)
     ok(ret == params->ret_status, "got %#x\n", ret);
     if (!params->pending && NT_ERROR(params->iosb_status))
     {
-        todo_wine ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
-        todo_wine ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
+        ok(io.Status == 0xdeadf00d, "got %#x\n", io.Status);
+        ok(io.Information == 0xdeadf00d, "got size %Iu\n", io.Information);
     }
     else
     {
@@ -1151,8 +1151,8 @@ static void test_blocking_irp(void)
     io.Information = 0xdeadf00d;
     status = NtQueryVolumeInformationFile(file, &io, buffer, sizeof(buffer), FileFsFullSizeInformation);
     ok(status == STATUS_DEVICE_NOT_READY, "got %#x\n", status);
-    todo_wine ok(io.Status == 0xdeadf00d, "got iosb status %#x\n", io.Status);
-    todo_wine ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
+    ok(io.Status == 0xdeadf00d, "got iosb status %#x\n", io.Status);
+    ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     CloseHandle(file);
 
diff --git a/server/async.c b/server/async.c
index bdc7620e9a1..1a564ff1a69 100644
--- a/server/async.c
+++ b/server/async.c
@@ -184,9 +184,17 @@ void async_terminate( struct async *async, unsigned int status )
         memset( &data, 0, sizeof(data) );
         data.type            = APC_ASYNC_IO;
         data.async_io.user   = async->data.user;
-        data.async_io.sb     = async->data.iosb;
         data.async_io.result = iosb ? iosb->result : 0;
 
+        /* this can happen if the initial status was unknown (i.e. for device
+         * files). the client should not fill the IOSB in this case; pass it as
+         * NULL to communicate that.
+         * note that we check the IOSB status and not the initial status */
+        if (NT_ERROR( status ) && (!is_fd_overlapped( async->fd ) || !async->pending))
+            data.async_io.sb = 0;
+        else
+            data.async_io.sb = async->data.iosb;
+
         /* if there is output data, the client needs to make an extra request
          * to retrieve it; use STATUS_ALERTED to signal this case */
         if (iosb && iosb->out_data)




More information about the wine-cvs mailing list