diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index 86e5431d6e3..a0cd5f9ad33 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -577,8 +577,8 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite, status = piosb->u.Status; } - if (status != STATUS_PENDING && bytesWritten) - *bytesWritten = piosb->Information; + if (bytesWritten) + *bytesWritten = overlapped && status ? 0 : piosb->Information; if (status && status != STATUS_TIMEOUT) { diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index c4beb196e4e..e0b8713bb13 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -2767,7 +2767,7 @@ static void _overlapped_write_async(unsigned line, HANDLE writer, void *buf, DWO overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); res = WriteFile(writer, buf, size, &written_bytes, overlapped); ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%u)\n", res, GetLastError()); - todo_wine ok_(__FILE__,line)(!written_bytes, "written_bytes = %u\n", written_bytes); + ok_(__FILE__,line)(!written_bytes, "written_bytes = %u\n", written_bytes); _test_not_signaled(line, overlapped->hEvent); }