Francois Gouget : kernel32: Fix writing to a pipe in WriteConsoleW().
Alexandre Julliard
julliard at winehq.org
Thu Aug 4 12:22:10 CDT 2011
Module: wine
Branch: master
Commit: 66395882f8b6f8f8b9ebf9b48ab36ac39da04dec
URL: http://source.winehq.org/git/wine.git/?a=commit;h=66395882f8b6f8f8b9ebf9b48ab36ac39da04dec
Author: Francois Gouget <fgouget at free.fr>
Date: Wed Aug 3 18:07:09 2011 +0200
kernel32: Fix writing to a pipe in WriteConsoleW().
---
dlls/kernel32/console.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index d28c153..bab2322 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -45,6 +45,7 @@
# include <sys/poll.h>
#endif
+#define NONAMELESSUNION
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@@ -2361,7 +2362,9 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber
{
char* ptr;
unsigned len;
- BOOL ret;
+ HANDLE hFile;
+ NTSTATUS status;
+ IO_STATUS_BLOCK iosb;
close(fd);
/* FIXME: mode ENABLED_OUTPUT is not processed (or actually we rely on underlying Unix/TTY fd
@@ -2372,17 +2375,28 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber
return FALSE;
WideCharToMultiByte(CP_UNIXCP, 0, lpBuffer, nNumberOfCharsToWrite, ptr, len, NULL, NULL);
- ret = WriteFile(wine_server_ptr_handle(console_handle_unmap(hConsoleOutput)),
- ptr, len, lpNumberOfCharsWritten, NULL);
- if (ret && lpNumberOfCharsWritten)
+ hFile = wine_server_ptr_handle(console_handle_unmap(hConsoleOutput));
+ status = NtWriteFile(hFile, NULL, NULL, NULL, &iosb, ptr, len, 0, NULL);
+ if (status == STATUS_PENDING)
{
- if (*lpNumberOfCharsWritten == len)
+ WaitForSingleObject(hFile, INFINITE);
+ status = iosb.u.Status;
+ }
+
+ if (status != STATUS_PENDING && lpNumberOfCharsWritten)
+ {
+ if (iosb.Information == len)
*lpNumberOfCharsWritten = nNumberOfCharsToWrite;
else
FIXME("Conversion not supported yet\n");
}
HeapFree(GetProcessHeap(), 0, ptr);
- return ret;
+ if (status != STATUS_SUCCESS)
+ {
+ SetLastError(RtlNtStatusToDosError(status));
+ return FALSE;
+ }
+ return TRUE;
}
if (!GetConsoleMode(hConsoleOutput, &mode) || !GetConsoleScreenBufferInfo(hConsoleOutput, &csbi))
More information about the wine-cvs
mailing list