diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index 7dd65cdae8c..92c776d26b9 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -451,7 +451,15 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead, if (status != STATUS_PENDING && bytesRead) *bytesRead = io_status->Information; - if (status && status != STATUS_END_OF_FILE && status != STATUS_TIMEOUT) + if (status == STATUS_END_OF_FILE) + { + if (overlapped != NULL) + { + SetLastError( RtlNtStatusToDosError(status) ); + return FALSE; + } + } + else if (status && status != STATUS_TIMEOUT) { SetLastError( RtlNtStatusToDosError(status) ); return FALSE; diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 7b644d1a351..9d6819a9f65 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -2139,9 +2139,7 @@ todo_wine bytes = -1; SetLastError(0xdeadbeef); ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl); -todo_wine ok(!ret, "ReadFile should fail\n"); -todo_wine ok(GetLastError() == ERROR_HANDLE_EOF, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError()); ok(bytes == 0, "bytes %u\n", bytes); todo_wine @@ -2287,9 +2285,8 @@ todo_wine ovl.hEvent = 0; bytes = 0xdeadbeef; SetLastError(0xdeadbeef); - ret = ReadFile(hfile, buf, 0, &bytes, &ovl); /* ReadFile return value depends on Windows version and testing it is not practical */ - if (!ret) ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); + ReadFile(hfile, buf, 0, &bytes, &ovl); ok(bytes == 0, "bytes %u\n", bytes); todo_wine ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal); @@ -2372,10 +2369,8 @@ todo_wine bytes = 0xdeadbeef; SetLastError(0xdeadbeef); ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl); -todo_wine ok(!ret, "ReadFile should fail\n"); ret = GetLastError(); -todo_wine ok(ret == ERROR_IO_PENDING || ret == ERROR_HANDLE_EOF /* before Vista */, "expected ERROR_IO_PENDING or ERROR_HANDLE_EOF, got %d\n", ret); ok(bytes == 0, "bytes %u\n", bytes);