[Wine-patches] [eter-2.1 6/6] kernel32: Implement SetNamedPipeHandleState.
Dmitry Timoshkov
dtimoshkov на etersoft.ru
Пн Июн 26 12:24:35 MSK 2017
Based on a patch by Adam Martinson.
---
dlls/kernel32/sync.c | 35 ++++++++++++++++++++++++++++-------
dlls/kernel32/tests/pipe.c | 10 +---------
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 40a14d93e8..8779a6a305 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -1774,9 +1774,34 @@ BOOL WINAPI SetNamedPipeHandleState(
{
/* should be a fixme, but this function is called a lot by the RPC
* runtime, and it slows down InstallShield a fair bit. */
- WARN("stub: %p %p/%d %p %p\n",
+ WARN("semi-stub: %p %p/%d %p %p\n",
hNamedPipe, lpMode, lpMode ? *lpMode : 0, lpMaxCollectionCount, lpCollectDataTimeout);
- return FALSE;
+
+ if (lpMode)
+ {
+ FILE_PIPE_INFORMATION fpi;
+ IO_STATUS_BLOCK iosb;
+ NTSTATUS status;
+
+ if (*lpMode & ~(PIPE_READMODE_MESSAGE | PIPE_NOWAIT))
+ status = STATUS_INVALID_PARAMETER;
+ else
+ {
+ fpi.CompletionMode = (*lpMode & PIPE_NOWAIT) ?
+ FILE_PIPE_COMPLETE_OPERATION : FILE_PIPE_QUEUE_OPERATION;
+ fpi.ReadMode = (*lpMode & PIPE_READMODE_MESSAGE) ?
+ FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
+ status = NtSetInformationFile(hNamedPipe, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
+ }
+
+ if (status)
+ {
+ SetLastError( RtlNtStatusToDosError(status) );
+ return FALSE;
+ }
+ }
+
+ return TRUE;
}
/***********************************************************************
@@ -1838,15 +1863,11 @@ BOOL WINAPI CallNamedPipeW(
mode = PIPE_READMODE_MESSAGE;
ret = SetNamedPipeHandleState(pipe, &mode, NULL, NULL);
-
- /* Currently SetNamedPipeHandleState() is a stub returning FALSE */
- if (ret) FIXME("Now that SetNamedPipeHandleState() is more than a stub, please update CallNamedPipeW\n");
- /*
if (!ret)
{
CloseHandle(pipe);
return FALSE;
- }*/
+ }
ret = TransactNamedPipe(pipe, lpInput, lpInputSize, lpOutput, lpOutputSize, lpBytesRead, NULL);
CloseHandle(pipe);
diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 923c0e7adc..1b525994ba 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -228,9 +228,7 @@ static void test_CreateNamedPipe(int pipemode)
ok(!SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
}
else {
- todo_wine {
- ok(SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
- }
+ ok(SetNamedPipeHandleState(hFile, &lpmode, NULL, NULL), "Change mode\n");
memset(ibuf, 0, sizeof(ibuf));
ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile5a\n");
@@ -1680,7 +1678,6 @@ static void test_NamedPipeHandleState(void)
state = PIPE_READMODE_MESSAGE;
SetLastError(0xdeadbeef);
ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
- todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
@@ -1690,13 +1687,11 @@ static void test_NamedPipeHandleState(void)
state = PIPE_READMODE_BYTE;
ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
- todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
/* A byte-mode pipe client can't be changed to message mode, either. */
state = PIPE_READMODE_MESSAGE;
SetLastError(0xdeadbeef);
ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
- todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
@@ -1728,7 +1723,6 @@ static void test_NamedPipeHandleState(void)
*/
state = PIPE_READMODE_BYTE;
ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
- todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
client = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0, NULL,
@@ -1737,13 +1731,11 @@ static void test_NamedPipeHandleState(void)
state = PIPE_READMODE_MESSAGE;
ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
- todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
/* A message-mode pipe client can also be changed to byte mode.
*/
state = PIPE_READMODE_BYTE;
ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
- todo_wine
ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
CloseHandle(client);
--
2.13.1
--
Dmitry.
Подробная информация о списке рассылки Wine-patches