Commit 49d0e64f authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

kernel32: The return and last error values set by ReadFile on EOF depend on…

kernel32: The return and last error values set by ReadFile on EOF depend on whether overlapped pointer was passed in.
parent fa2ca8f6
...@@ -451,7 +451,15 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead, ...@@ -451,7 +451,15 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
if (status != STATUS_PENDING && bytesRead) if (status != STATUS_PENDING && bytesRead)
*bytesRead = io_status->Information; *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) ); SetLastError( RtlNtStatusToDosError(status) );
return FALSE; return FALSE;
......
...@@ -2139,9 +2139,7 @@ todo_wine ...@@ -2139,9 +2139,7 @@ todo_wine
bytes = -1; bytes = -1;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl); ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
todo_wine
ok(!ret, "ReadFile should fail\n"); ok(!ret, "ReadFile should fail\n");
todo_wine
ok(GetLastError() == ERROR_HANDLE_EOF, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError()); ok(GetLastError() == ERROR_HANDLE_EOF, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes); ok(bytes == 0, "bytes %u\n", bytes);
todo_wine todo_wine
...@@ -2287,9 +2285,8 @@ todo_wine ...@@ -2287,9 +2285,8 @@ todo_wine
ovl.hEvent = 0; ovl.hEvent = 0;
bytes = 0xdeadbeef; bytes = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, 0, &bytes, &ovl);
/* ReadFile return value depends on Windows version and testing it is not practical */ /* 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); ok(bytes == 0, "bytes %u\n", bytes);
todo_wine todo_wine
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal); ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
...@@ -2372,10 +2369,8 @@ todo_wine ...@@ -2372,10 +2369,8 @@ todo_wine
bytes = 0xdeadbeef; bytes = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl); ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
todo_wine
ok(!ret, "ReadFile should fail\n"); ok(!ret, "ReadFile should fail\n");
ret = GetLastError(); 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(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); ok(bytes == 0, "bytes %u\n", bytes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment