[2/2] kernel32: The return and last error values set by ReadFile on EOF depend on whether overlapped pointer was passed in.
Dmitry Timoshkov
dmitry at baikal.ru
Thu Oct 10 23:39:44 CDT 2013
---
dlls/kernel32/file.c | 10 +++++++++-
dlls/ntdll/tests/file.c | 7 +------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index 7dd65cd..92c776d 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 7b644d1..9d6819a 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);
--
1.8.3.4
More information about the wine-patches
mailing list