Commit 66395882 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

kernel32: Fix writing to a pipe in WriteConsoleW().

parent 322049ce
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
# include <sys/poll.h> # include <sys/poll.h>
#endif #endif
#define NONAMELESSUNION
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"
...@@ -2361,7 +2362,9 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber ...@@ -2361,7 +2362,9 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber
{ {
char* ptr; char* ptr;
unsigned len; unsigned len;
BOOL ret; HANDLE hFile;
NTSTATUS status;
IO_STATUS_BLOCK iosb;
close(fd); close(fd);
/* FIXME: mode ENABLED_OUTPUT is not processed (or actually we rely on underlying Unix/TTY 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 ...@@ -2372,17 +2375,28 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber
return FALSE; return FALSE;
WideCharToMultiByte(CP_UNIXCP, 0, lpBuffer, nNumberOfCharsToWrite, ptr, len, NULL, NULL); WideCharToMultiByte(CP_UNIXCP, 0, lpBuffer, nNumberOfCharsToWrite, ptr, len, NULL, NULL);
ret = WriteFile(wine_server_ptr_handle(console_handle_unmap(hConsoleOutput)), hFile = wine_server_ptr_handle(console_handle_unmap(hConsoleOutput));
ptr, len, lpNumberOfCharsWritten, NULL); status = NtWriteFile(hFile, NULL, NULL, NULL, &iosb, ptr, len, 0, NULL);
if (ret && lpNumberOfCharsWritten) 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; *lpNumberOfCharsWritten = nNumberOfCharsToWrite;
else else
FIXME("Conversion not supported yet\n"); FIXME("Conversion not supported yet\n");
} }
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
return ret; if (status != STATUS_SUCCESS)
{
SetLastError(RtlNtStatusToDosError(status));
return FALSE;
}
return TRUE;
} }
if (!GetConsoleMode(hConsoleOutput, &mode) || !GetConsoleScreenBufferInfo(hConsoleOutput, &csbi)) if (!GetConsoleMode(hConsoleOutput, &mode) || !GetConsoleScreenBufferInfo(hConsoleOutput, &csbi))
......
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