[5/6] ntdll: Make NtReadFile always initialize a being returned IO_STATUS_BLOCK for regular files.

Dmitry Timoshkov dmitry at baikal.ru
Wed Aug 21 04:35:09 CDT 2013


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

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 5147ef5..8615d3a 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -597,8 +597,8 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
 
     if (!virtual_check_buffer_for_write( buffer, length ))
     {
-        status = STATUS_ACCESS_VIOLATION;
-        goto done;
+        if (needs_close) close( unix_handle );
+        return STATUS_ACCESS_VIOLATION;
     }
 
     if (type == FD_TYPE_FILE && offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */ )
@@ -748,6 +748,11 @@ err:
     }
     else
     {
+        if (type == FD_TYPE_FILE)
+        {
+            io_status->u.Status = status;
+            io_status->Information = total;
+        }
         TRACE("= 0x%08x\n", status);
         if (status != STATUS_PENDING && hEvent) NtResetEvent( hEvent, NULL );
     }
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 19e2f8a..7de3baf 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -836,9 +836,10 @@ todo_wine
     ResetEvent( event );
     status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL );
     ok( status == STATUS_END_OF_FILE, "wrong status %x\n", status );
-    todo_wine ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
-    todo_wine ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
-    todo_wine ok( is_signaled( event ), "event is not signaled\n" );
+    ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
+    ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
+todo_wine
+    ok( is_signaled( event ), "event is not signaled\n" );
     ok( !apc_count, "apc was called\n" );
     SleepEx( 1, TRUE ); /* alertable sleep */
     ok( !apc_count, "apc was called\n" );
@@ -2020,9 +2021,7 @@ static void test_read_write(void)
     iob.Information = -1;
     status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
     ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
 
     iob.Status = -1;
@@ -2030,9 +2029,7 @@ todo_wine
     offset.QuadPart = sizeof(contents);
     status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
     ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
 
     SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
@@ -2048,9 +2045,7 @@ todo_wine
     iob.Information = -1;
     status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
     ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
 
     iob.Status = -1;
-- 
1.8.3.4




More information about the wine-patches mailing list