Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/ntdll/tests/pipe.c | 95 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+)
diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c index 4eb957b1c2a..d122c63ca9c 100644 --- a/dlls/ntdll/tests/pipe.c +++ b/dlls/ntdll/tests/pipe.c @@ -2402,6 +2402,100 @@ static void test_security_info(void) HeapFree(GetProcessHeap(), 0, local_sid); }
+static void test_empty_name(void) +{ + HANDLE hdirectory, hpipe, hwrite, handle; + OBJECT_ATTRIBUTES attr; + LARGE_INTEGER timeout; + UNICODE_STRING name; + IO_STATUS_BLOCK io; + DWORD data, length; + NTSTATUS status; + BOOL ret; + + hpipe = hwrite = NULL; + + attr.Length = sizeof(attr); + attr.Attributes = 0x40; /* case insensitive */ + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + + pRtlInitUnicodeString(&name, u"\Device\NamedPipe"); + attr.RootDirectory = 0; + attr.ObjectName = &name; + + status = NtCreateFile(&hdirectory, GENERIC_READ | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, NULL, 0 ); + ok(!status, "Got unexpected status %#x.\n", status); + + name.Buffer = NULL; + name.Length = 0; + name.MaximumLength = 0; + attr.RootDirectory = hdirectory; + + timeout.QuadPart = -(LONG64)10000000; + status = pNtCreateNamedPipeFile(&hpipe, GENERIC_READ | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE, &attr, + &io, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_CREATE, FILE_SYNCHRONOUS_IO_NONALERT, + 0, 0, 0, 3, 4096, 4096, &timeout); + todo_wine ok(status == STATUS_OBJECT_NAME_INVALID, "Got unexpected status %#x.\n", status); + + CloseHandle(hdirectory); + + pRtlInitUnicodeString(&name, u"\Device\NamedPipe\"); + attr.RootDirectory = 0; + attr.ObjectName = &name; + + status = NtCreateFile(&hdirectory, GENERIC_READ | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, NULL, 0 ); + ok(!status, "Got unexpected status %#x.\n", status); + + name.Buffer = NULL; + name.Length = 0; + name.MaximumLength = 0; + attr.RootDirectory = hdirectory; + + status = pNtCreateNamedPipeFile(&hpipe, GENERIC_READ | SYNCHRONIZE, &attr, + &io, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_CREATE, FILE_SYNCHRONOUS_IO_NONALERT, + 0, 0, 0, 3, 4096, 4096, &timeout); + todo_wine ok(!status, "Got unexpected status %#x.\n", status); + + status = pNtCreateNamedPipeFile(&handle, GENERIC_READ | SYNCHRONIZE, &attr, + &io, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, + 0, 0, 0, 1, 4096, 4096, &timeout); + todo_wine ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "Got unexpected status %#x.\n", status); + + attr.RootDirectory = hpipe; + status = NtCreateFile(&hwrite, GENERIC_WRITE | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); + todo_wine ok(!status, "Got unexpected status %#x.\n", status); + + attr.RootDirectory = hpipe; + status = NtCreateFile(&handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, + FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); + todo_wine ok(status == STATUS_PIPE_NOT_AVAILABLE, "Got unexpected status %#x.\n", status); + + attr.RootDirectory = hpipe; + status = NtCreateFile(&handle, GENERIC_WRITE | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); + todo_wine ok(status == STATUS_PIPE_NOT_AVAILABLE, "Got unexpected status %#x.\n", status); + + data = 0xdeadbeef; + ret = WriteFile(hwrite, &data, sizeof(data), &length, NULL); + todo_wine ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + todo_wine ok(length == sizeof(data), "Got unexpected length %#x.\n"); + + data = 0; + ret = ReadFile(hpipe, &data, sizeof(data), &length, NULL); + todo_wine ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + todo_wine ok(length == sizeof(data), "Got unexpected length %#x.\n"); + todo_wine ok(data == 0xdeadbeef, "Got unexpected data %#x.\n", data); + + CloseHandle(hwrite); + CloseHandle(hpipe); + CloseHandle(hdirectory); +} + START_TEST(pipe) { if (!init_func_ptrs()) @@ -2455,6 +2549,7 @@ START_TEST(pipe) test_volume_info(); test_file_info(); test_security_info(); + test_empty_name();
pipe_for_each_state(create_pipe_server, connect_pipe, test_pipe_state); pipe_for_each_state(create_pipe_server, connect_and_write_pipe, test_pipe_with_data_state);
Paul Gofman pgofman@codeweavers.com wrote:
- attr.Attributes = 0x40; /* case insensitive */
There should be a symbolic name for this.
- pRtlInitUnicodeString(&name, u"\Device\NamedPipe");
This is not portable, please use L"" form instead.