ReactOS 0.4.17-dev-37-g0bfb40d
pipe.c
Go to the documentation of this file.
1/* Unit test suite for Ntdll NamedPipe API functions
2 *
3 * Copyright 2011 Bernhard Loos
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdio.h>
21#include <stdarg.h>
22
23#include "ntstatus.h"
24#define WIN32_NO_STATUS
25#include "windef.h"
26#include "winbase.h"
27#include "winuser.h"
28#include "winreg.h"
29#include "winnls.h"
30#include "wine/test.h"
31#include "winternl.h"
32#include "winioctl.h"
33#ifdef __REACTOS__
34/* Wine's headers aren't compatible */
35#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
36#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
37 (DWORD)((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
38)
39
40/* This isn't in the Windows SDK */
41#define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
42#endif
43
44#ifndef __WINE_WINTERNL_H
45
46typedef struct {
50
51typedef struct {
63
70
71#ifndef FILE_SYNCHRONOUS_IO_ALERT
72#define FILE_SYNCHRONOUS_IO_ALERT 0x10
73#endif
74
75#ifndef FILE_SYNCHRONOUS_IO_NONALERT
76#define FILE_SYNCHRONOUS_IO_NONALERT 0x20
77#endif
78
79#ifndef FSCTL_PIPE_LISTEN
80#define FSCTL_PIPE_LISTEN CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
81#endif
82
83#ifndef FSCTL_PIPE_WAIT
84#define FSCTL_PIPE_WAIT CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
85#endif
86#endif
87
89static BOOL (WINAPI *pIsWow64Process)(HANDLE, BOOL *);
90
92static NTSTATUS (WINAPI *pNtCreateDirectoryObject)(HANDLE *, ACCESS_MASK, OBJECT_ATTRIBUTES *);
93static NTSTATUS (WINAPI *pNtCreateNamedPipeFile) (PHANDLE handle, ULONG access,
101static NTSTATUS (WINAPI *pNtQueryObject)(HANDLE, OBJECT_INFORMATION_CLASS, void *, ULONG, ULONG *);
105static NTSTATUS (WINAPI *pNtCancelIoFileEx) (HANDLE hFile, IO_STATUS_BLOCK *iosb, IO_STATUS_BLOCK *io_status);
106static NTSTATUS (WINAPI *pNtCancelSynchronousIoFile) (HANDLE hFile, IO_STATUS_BLOCK *iosb, IO_STATUS_BLOCK *io_status);
108static void (WINAPI *pRtlInitUnicodeString) (PUNICODE_STRING target, PCWSTR source);
109
110static HANDLE (WINAPI *pOpenThread)(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId);
111static DWORD (WINAPI *pQueueUserAPC)(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData);
112
113
115{
116 HMODULE module = GetModuleHandleA("ntdll.dll");
117
118#define loadfunc(name) if (!(p##name = (void *)GetProcAddress(module, #name))) { \
119 trace("GetProcAddress(%s) failed\n", #name); \
120 return FALSE; \
121 }
122
131#ifndef __REACTOS__
133#endif
136
137 /* not fatal */
138 pNtCancelIoFileEx = (void *)GetProcAddress(module, "NtCancelIoFileEx");
139 module = GetModuleHandleA("kernel32.dll");
140 pOpenThread = (void *)GetProcAddress(module, "OpenThread");
141 pQueueUserAPC = (void *)GetProcAddress(module, "QueueUserAPC");
142 pIsWow64Process = (void *)GetProcAddress(module, "IsWow64Process");
143#ifdef __REACTOS__
144 pNtCancelSynchronousIoFile = (void *)GetProcAddress(module, "NtCancelSynchronousIoFile");
145#endif
146 return TRUE;
147}
148
149static HANDLE create_process(const char *arg)
150{
151 STARTUPINFOA si = { 0 };
153 char cmdline[MAX_PATH];
154 char **argv;
155 BOOL ret;
156
157 si.cb = sizeof(si);
159 sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
161 ok(ret, "got %lu.\n", GetLastError());
163 ok(ret, "got %lu.\n", GetLastError());
164 return pi.hProcess;
165}
166
167static inline BOOL is_signaled( HANDLE obj )
168{
169 return WaitForSingleObject( obj, 0 ) == WAIT_OBJECT_0;
170}
171
172#define test_file_access(a,b) _test_file_access(__LINE__,a,b)
173static void _test_file_access(unsigned line, HANDLE handle, DWORD expected_access)
174{
178
179 memset(&info, 0x11, sizeof(info));
181 ok_(__FILE__,line)(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
182 ok_(__FILE__,line)(info.AccessFlags == expected_access, "got access %08lx expected %08lx\n",
183 info.AccessFlags, expected_access);
184}
185
186static const WCHAR testpipe[] = { '\\', '\\', '.', '\\', 'p', 'i', 'p', 'e', '\\',
187 't', 'e', 's', 't', 'p', 'i', 'p', 'e', 0 };
188static const WCHAR testpipe_nt[] = { '\\', '?', '?', '\\', 'p', 'i', 'p', 'e', '\\',
189 't', 'e', 's', 't', 'p', 'i', 'p', 'e', 0 };
190
192{
198
199 pRtlInitUnicodeString(&name, testpipe_nt);
200
201 attr.Length = sizeof(attr);
202 attr.RootDirectory = 0;
203 attr.ObjectName = &name;
204 attr.Attributes = OBJ_CASE_INSENSITIVE;
205 attr.SecurityDescriptor = NULL;
206 attr.SecurityQualityOfService = NULL;
207
208 timeout.QuadPart = -100000000;
209
210 res = pNtCreateNamedPipeFile(handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE | access, &attr, &iosb, sharing,
211 FILE_CREATE, options, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
212 return res;
213}
214
217{
219}
220
222{
223 int dummy;
224
226
227 return pNtFsControlFile(hPipe, hEvent, use_apc ? &ioapc: NULL, use_apc ? &dummy: NULL, iosb, FSCTL_PIPE_LISTEN, 0, 0, 0, 0);
228}
229
231{
236 FILE_PIPE_WAIT_FOR_BUFFER *pipe_wait;
237 ULONG pipe_wait_size;
238
239 pipe_wait_size = offsetof(FILE_PIPE_WAIT_FOR_BUFFER, Name[0]) + name->Length;
240 pipe_wait = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pipe_wait_size);
241 if (!pipe_wait) return STATUS_NO_MEMORY;
242
243 pipe_wait->TimeoutSpecified = !!timeout;
244 pipe_wait->NameLength = name->Length;
245 if (timeout) pipe_wait->Timeout = *timeout;
246 memcpy(pipe_wait->Name, name->Buffer, name->Length);
247
250 if (status != STATUS_SUCCESS)
251 {
252 ok(0, "NtCreateEvent failure: %#lx\n", status);
253 HeapFree(GetProcessHeap(), 0, pipe_wait);
254 return status;
255 }
256
257 memset(&iosb, 0, sizeof(iosb));
258 iosb.Status = STATUS_PENDING;
259 status = pNtFsControlFile(handle, event, NULL, NULL, &iosb, FSCTL_PIPE_WAIT,
260 pipe_wait, pipe_wait_size, NULL, 0);
261 if (status == STATUS_PENDING)
262 {
264 status = iosb.Status;
265 }
266
267 NtClose(event);
268 HeapFree(GetProcessHeap(), 0, pipe_wait);
269 return status;
270}
271
272static void test_create_invalid(void)
273{
279 HANDLE handle, handle2;
281
282 pRtlInitUnicodeString(&name, testpipe_nt);
283
284 attr.Length = sizeof(attr);
285 attr.RootDirectory = 0;
286 attr.ObjectName = &name;
287 attr.Attributes = OBJ_CASE_INSENSITIVE;
288 attr.SecurityDescriptor = NULL;
289 attr.SecurityQualityOfService = NULL;
290
291 timeout.QuadPart = -100000000;
292
293/* create a pipe with FILE_OVERWRITE */
294 res = pNtCreateNamedPipeFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ, 4 /*FILE_OVERWRITE*/,
295 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
296 ok(res == STATUS_INVALID_PARAMETER, "NtCreateNamedPipeFile returned %lx\n", res);
297 if (!res)
299
300/* create a pipe with FILE_OVERWRITE_IF */
301 res = pNtCreateNamedPipeFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ, 5 /*FILE_OVERWRITE_IF*/,
302 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
303 ok(res == STATUS_INVALID_PARAMETER, "NtCreateNamedPipeFile returned %lx\n", res);
304 if (!res)
306
307/* create a pipe with sharing = 0 */
308 res = pNtCreateNamedPipeFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, 0, 2 /*FILE_CREATE*/,
309 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
310 ok(res == STATUS_INVALID_PARAMETER, "NtCreateNamedPipeFile returned %lx\n", res);
311 if (!res)
313
314/* create a pipe without r/w access */
315 res = pNtCreateNamedPipeFile(&handle, SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /*FILE_CREATE*/,
316 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
317 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
318
319 res = pNtQueryInformationFile(handle, &iosb, &info, sizeof(info), FilePipeLocalInformation);
320 ok(res == STATUS_ACCESS_DENIED, "NtQueryInformationFile returned %lx\n", res);
321
322/* test FILE_CREATE creation disposition */
323 res = pNtCreateNamedPipeFile(&handle2, SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /*FILE_CREATE*/,
324 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
325 ok(res == STATUS_ACCESS_DENIED, "NtCreateNamedPipeFile returned %lx\n", res);
326 if (!res)
327 CloseHandle(handle2);
328
330}
331
332static void test_create(void)
333{
334 HANDLE hserver;
336 int j, k;
340
343 static const DWORD pipe_config[]= { 1, 0, 2 };
344
345 for (j = 0; j < ARRAY_SIZE(sharing); j++) {
346 for (k = 0; k < ARRAY_SIZE(access); k++) {
347 HANDLE hclient;
348 BOOL should_succeed = TRUE;
349
350 res = create_pipe(&hserver, 0, sharing[j], 0);
351 if (res) {
352 ok(0, "NtCreateNamedPipeFile returned %lx, sharing: %lx\n", res, sharing[j]);
353 continue;
354 }
355
356 res = listen_pipe(hserver, hEvent, &iosb, FALSE);
357 ok(res == STATUS_PENDING, "NtFsControlFile returned %lx\n", res);
358
359 res = pNtQueryInformationFile(hserver, &iosb, &info, sizeof(info), FilePipeLocalInformation);
360 ok(!res, "NtQueryInformationFile for server returned %lx, sharing: %lx\n", res, sharing[j]);
361 ok(info.NamedPipeConfiguration == pipe_config[j], "wrong duplex status for pipe: %ld, expected %ld\n",
362 info.NamedPipeConfiguration, pipe_config[j]);
363
364 hclient = CreateFileW(testpipe, access[k], 0, 0, OPEN_EXISTING, 0, 0);
365 if (hclient != INVALID_HANDLE_VALUE) {
366 res = pNtQueryInformationFile(hclient, &iosb, &info, sizeof(info), FilePipeLocalInformation);
367 ok(!res, "NtQueryInformationFile for client returned %lx, access: %lx, sharing: %lx\n",
368 res, access[k], sharing[j]);
369 ok(info.NamedPipeConfiguration == pipe_config[j], "wrong duplex status for pipe: %ld, expected %ld\n",
370 info.NamedPipeConfiguration, pipe_config[j]);
371
372 res = listen_pipe(hclient, hEvent, &iosb, FALSE);
373 ok(res == STATUS_ILLEGAL_FUNCTION, "expected STATUS_ILLEGAL_FUNCTION, got %lx\n", res);
374 CloseHandle(hclient);
375 }
376
377 if (access[k] & GENERIC_WRITE)
378 should_succeed &= !!(sharing[j] & FILE_SHARE_WRITE);
379 if (access[k] & GENERIC_READ)
380 should_succeed &= !!(sharing[j] & FILE_SHARE_READ);
381
382 if (should_succeed)
383 ok(hclient != INVALID_HANDLE_VALUE, "CreateFile failed for sharing %lx, access: %lx, GetLastError: %ld\n",
385 else
386 ok(hclient == INVALID_HANDLE_VALUE, "CreateFile succeeded for sharing %lx, access: %lx\n", sharing[j], access[k]);
387
388 CloseHandle(hserver);
389 }
390 }
392}
393
394static void test_overlapped(void)
395{
398 HANDLE hPipe;
399 HANDLE hClient;
401
403 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %lx\n", GetLastError());
404
405 res = create_pipe(&hPipe, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
406 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
407
408 memset(&iosb, 0x55, sizeof(iosb));
409 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
410 ok(res == STATUS_PENDING, "NtFsControlFile returned %lx\n", res);
411 ok(iosb.Status == 0x55555555, "iosb.Status got changed to %lx\n", iosb.Status);
412
414 ok(hClient != INVALID_HANDLE_VALUE, "can't open pipe, GetLastError: %lx\n", GetLastError());
415
416 ok(iosb.Status == 0, "Wrong iostatus %lx\n", iosb.Status);
417 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
418
419 ok(!ioapc_called, "IOAPC ran too early\n");
420
421 SleepEx(0, TRUE); /* alertable wait state */
422
423 ok(ioapc_called, "IOAPC didn't run\n");
424
425 CloseHandle(hPipe);
426 CloseHandle(hClient);
427
428 res = create_pipe(&hPipe, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
429 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
430
432 ok(hClient != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_PIPE_BUSY) /* > Win 8 */,
433 "can't open pipe, GetLastError: %lx\n", GetLastError());
434
435 if (hClient != INVALID_HANDLE_VALUE)
436 {
438 memset(&iosb, 0x55, sizeof(iosb));
439 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
440 ok(res == STATUS_PIPE_CONNECTED, "NtFsControlFile returned %lx\n", res);
441 ok(iosb.Status == 0x55555555, "iosb.Status got changed to %lx\n", iosb.Status);
442 ok(!is_signaled(hEvent), "hEvent not signaled\n");
443
444 CloseHandle(hClient);
445 }
446
447 CloseHandle(hPipe);
449}
450
452static void CALLBACK userapc(ULONG_PTR dwParam)
453{
455}
456
458static DWORD WINAPI thread(PVOID main_thread)
459{
460 HANDLE h;
461
462 Sleep(400);
463
464 if (main_thread) {
465 DWORD ret;
467 ret = pQueueUserAPC(&userapc, main_thread, 0);
468 ok(ret, "can't queue user apc, GetLastError: %lx\n", GetLastError());
469 CloseHandle(main_thread);
470 }
471
472 Sleep(400);
473
475
476 if (h != INVALID_HANDLE_VALUE) {
478 Sleep(100);
479 CloseHandle(h);
480 } else
482
483 return 0;
484}
485
486static void test_alertable(void)
487{
490 HANDLE hPipe;
493 DWORD ret;
494
495 memset(&iosb, 0x55, sizeof(iosb));
496
498 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %lx\n", GetLastError());
499
501 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
502
503/* queue an user apc before calling listen */
505 ret = pQueueUserAPC(&userapc, GetCurrentThread(), 0);
506 ok(ret, "can't queue user apc, GetLastError: %lx\n", GetLastError());
507
508 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
509 todo_wine ok(res == STATUS_CANCELLED, "NtFsControlFile returned %lx\n", res);
510
511 ok(userapc_called, "user apc didn't run\n");
512 ok(iosb.Status == 0x55555555 || iosb.Status == STATUS_CANCELLED, "iosb.Status got changed to %lx\n", iosb.Status);
513 ok(WaitForSingleObjectEx(hEvent, 0, TRUE) == (iosb.Status == STATUS_CANCELLED ? 0 : WAIT_TIMEOUT), "hEvent signaled\n");
514 ok(!ioapc_called, "IOAPC ran\n");
515
516/* queue an user apc from a different thread */
518 ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %lx\n", GetLastError());
519
520 /* wine_todo: the earlier NtFsControlFile call gets cancelled after the pipe gets set into listen state
521 instead of before, so this NtFsControlFile will fail STATUS_INVALID_HANDLE */
522 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
523 todo_wine ok(res == STATUS_CANCELLED, "NtFsControlFile returned %lx\n", res);
524
525 ok(userapc_called, "user apc didn't run\n");
526 ok(iosb.Status == 0x55555555 || iosb.Status == STATUS_CANCELLED, "iosb.Status got changed to %lx\n", iosb.Status);
527 ok(WaitForSingleObjectEx(hEvent, 0, TRUE) == (iosb.Status == STATUS_CANCELLED ? 0 : WAIT_TIMEOUT), "hEvent signaled\n");
528 ok(!ioapc_called, "IOAPC ran\n");
529
531
532 SleepEx(0, TRUE); /* get rid of the userapc, if NtFsControlFile failed */
533
534 ok(open_succeeded, "couldn't open client side pipe\n");
535
537 DisconnectNamedPipe(hPipe);
538
539/* finally try without an apc */
540 hThread = CreateThread(NULL, 0, &thread, 0, 0, 0);
541 ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %lx\n", GetLastError());
542
543 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
544 ok(!res, "NtFsControlFile returned %lx\n", res);
545
546 ok(open_succeeded, "couldn't open client side pipe\n");
547 ok(!iosb.Status, "Wrong iostatus %lx\n", iosb.Status);
548 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
549
553 CloseHandle(hPipe);
554}
555
556static void test_nonalertable(void)
557{
560 HANDLE hPipe;
563 DWORD ret;
564
565 memset(&iosb, 0x55, sizeof(iosb));
566
568 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %lx\n", GetLastError());
569
571 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
572
573 hThread = CreateThread(NULL, 0, &thread, 0, 0, 0);
574 ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %lx\n", GetLastError());
575
577 ret = pQueueUserAPC(&userapc, GetCurrentThread(), 0);
578 ok(ret, "can't queue user apc, GetLastError: %lx\n", GetLastError());
579
580 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
581 ok(!res, "NtFsControlFile returned %lx\n", res);
582
583 ok(open_succeeded, "couldn't open client side pipe\n");
584 ok(!iosb.Status, "Wrong iostatus %lx\n", iosb.Status);
585 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
586
587 ok(!ioapc_called, "IOAPC ran too early\n");
588 ok(!userapc_called, "user apc ran too early\n");
589
590 SleepEx(0, TRUE); /* alertable wait state */
591
592 ok(ioapc_called, "IOAPC didn't run\n");
593 ok(userapc_called, "user apc didn't run\n");
594
598 CloseHandle(hPipe);
599}
600
601static void test_cancelio(void)
602{
604 IO_STATUS_BLOCK cancel_sb;
606 HANDLE hPipe;
608
610 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %lx\n", GetLastError());
611
612 res = create_pipe(&hPipe, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
613 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
614
615 memset(&iosb, 0x55, sizeof(iosb));
616
617 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
618 ok(res == STATUS_PENDING, "NtFsControlFile returned %lx\n", res);
619
620 res = pNtCancelIoFile(hPipe, &cancel_sb);
621 ok(!res, "NtCancelIoFile returned %lx\n", res);
622
623 ok(iosb.Status == STATUS_CANCELLED, "Wrong iostatus %lx\n", iosb.Status);
624 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
625
626 ok(!ioapc_called, "IOAPC ran too early\n");
627
628 SleepEx(0, TRUE); /* alertable wait state */
629
630 ok(ioapc_called, "IOAPC didn't run\n");
631
632 res = pNtCancelIoFile(hPipe, &cancel_sb);
633 ok(!res, "NtCancelIoFile returned %lx\n", res);
634 ok(iosb.Status == STATUS_CANCELLED, "Wrong iostatus %lx\n", iosb.Status);
635
636 CloseHandle(hPipe);
637
638 if (pNtCancelIoFileEx)
639 {
640 res = create_pipe(&hPipe, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
641 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
642
643 memset(&iosb, 0x55, sizeof(iosb));
644 res = listen_pipe(hPipe, hEvent, &iosb, FALSE);
645 ok(res == STATUS_PENDING, "NtFsControlFile returned %lx\n", res);
646
647 res = pNtCancelIoFileEx(hPipe, &iosb, &cancel_sb);
648 ok(!res, "NtCancelIoFileEx returned %lx\n", res);
649
650 ok(iosb.Status == STATUS_CANCELLED, "Wrong iostatus %lx\n", iosb.Status);
651 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
652
653 iosb.Status = 0xdeadbeef;
654 res = pNtCancelIoFileEx(hPipe, NULL, &cancel_sb);
655 ok(res == STATUS_NOT_FOUND, "NtCancelIoFileEx returned %lx\n", res);
656 ok(iosb.Status == 0xdeadbeef, "Wrong iostatus %lx\n", iosb.Status);
657
658 CloseHandle(hPipe);
659 }
660 else
661 win_skip("NtCancelIoFileEx not available\n");
662
664}
665
667{
670};
671
673{
676
677 res = listen_pipe(ctx->pipe, NULL, &ctx->iosb, FALSE);
678 ok(res == STATUS_CANCELLED, "NtFsControlFile returned %lx\n", res);
679 return 0;
680}
681
683{
684 DWORD ret;
691
692#ifdef __REACTOS__
693 if (pNtCancelSynchronousIoFile == NULL)
694 {
695 win_skip("NtCancelSynchronousIoFile not available\n");
696 return;
697 }
698#endif // __REACTOS__
699
700 /* bogus values */
701 res = pNtCancelSynchronousIoFile((HANDLE)0xdeadbeef, NULL, &iosb);
702 ok(res == STATUS_INVALID_HANDLE, "NtCancelSynchronousIoFile returned %lx\n", res);
703 res = pNtCancelSynchronousIoFile(GetCurrentThread(), NULL, NULL);
704 ok(res == STATUS_ACCESS_VIOLATION, "NtCancelSynchronousIoFile returned %lx\n", res);
705 res = pNtCancelSynchronousIoFile(GetCurrentThread(), NULL, (IO_STATUS_BLOCK*)0xdeadbeef);
706 ok(res == STATUS_ACCESS_VIOLATION, "NtCancelSynchronousIoFile returned %lx\n", res);
707 memset(&iosb, 0x55, sizeof(iosb));
708 res = pNtCancelSynchronousIoFile(GetCurrentThread(), (IO_STATUS_BLOCK*)0xdeadbeef, &iosb);
710 "NtCancelSynchronousIoFile returned %lx\n", res);
712 {
713 ok(iosb.Status == STATUS_NOT_FOUND, "iosb.Status got changed to %lx\n", iosb.Status);
714 ok(iosb.Information == 0, "iosb.Information got changed to %Iu\n", iosb.Information);
715 }
716
717 /* synchronous i/o */
719 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
720
721 /* NULL io */
722 ctx.iosb.Status = 0xdeadbabe;
723 ctx.iosb.Information = 0xdeadbeef;
725 /* wait for I/O to start, which transitions the pipe handle from signaled to nonsignaled state. */
726 while ((ret = WaitForSingleObject(ctx.pipe, 0)) == WAIT_OBJECT_0) Sleep(1);
727 ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu (error %lu)\n", ret, GetLastError());
728 memset(&iosb, 0x55, sizeof(iosb));
729 res = pNtCancelSynchronousIoFile(thread, NULL, &iosb);
730 ok(res == STATUS_SUCCESS, "Failed to cancel I/O\n");
731 ok(iosb.Status == STATUS_SUCCESS, "iosb.Status got changed to %lx\n", iosb.Status);
732 ok(iosb.Information == 0, "iosb.Information got changed to %Iu\n", iosb.Information);
734 ok(ret == WAIT_OBJECT_0, "wait returned %lx\n", ret);
736 CloseHandle(ctx.pipe);
737 ok(ctx.iosb.Status == 0xdeadbabe || ctx.iosb.Status == STATUS_CANCELLED, "wrong status %lx\n", ctx.iosb.Status);
738 ok(ctx.iosb.Information == (ctx.iosb.Status == STATUS_CANCELLED ? 0 : 0xdeadbeef), "wrong info %Iu\n", ctx.iosb.Information);
739
740 /* specified io */
742 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
743
744 ctx.iosb.Status = 0xdeadbabe;
745 ctx.iosb.Information = 0xdeadbeef;
747 /* wait for I/O to start, which transitions the pipe handle from signaled to nonsignaled state. */
748 while ((ret = WaitForSingleObject(ctx.pipe, 0)) == WAIT_OBJECT_0) Sleep(1);
749 ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu (error %lu)\n", ret, GetLastError());
750 memset(&iosb, 0x55, sizeof(iosb));
751 res = pNtCancelSynchronousIoFile(thread, &iosb, &iosb);
752 ok(res == STATUS_NOT_FOUND, "NtCancelSynchronousIoFile returned %lx\n", res);
753 res = pNtCancelSynchronousIoFile(NULL, &ctx.iosb, &iosb);
754 ok(res == STATUS_INVALID_HANDLE, "NtCancelSynchronousIoFile returned %lx\n", res);
755 res = pNtCancelSynchronousIoFile(thread, &ctx.iosb, &iosb);
757 "Failed to cancel I/O\n");
758 ok(iosb.Status == STATUS_SUCCESS || broken(is_wow64 && iosb.Status == STATUS_NOT_FOUND),
759 "iosb.Status got changed to %lx\n", iosb.Status);
760 ok(iosb.Information == 0, "iosb.Information got changed to %Iu\n", iosb.Information);
761 if (res == STATUS_NOT_FOUND)
762 {
763 res = pNtCancelSynchronousIoFile(thread, NULL, &iosb);
764 ok(res == STATUS_SUCCESS, "Failed to cancel I/O\n");
765 ok(iosb.Status == STATUS_SUCCESS, "iosb.Status got changed to %lx\n", iosb.Status);
766 }
768 ok(ret == WAIT_OBJECT_0, "wait returned %lx\n", ret);
770 CloseHandle(ctx.pipe);
771 ok(ctx.iosb.Status == 0xdeadbabe || ctx.iosb.Status == STATUS_CANCELLED, "wrong status %lx\n", ctx.iosb.Status);
772 ok(ctx.iosb.Information == (ctx.iosb.Status == STATUS_CANCELLED ? 0 : 0xdeadbeef), "wrong info %Iu\n", ctx.iosb.Information);
773
774 /* asynchronous i/o */
775 ctx.iosb.Status = 0xdeadbabe;
776 ctx.iosb.Information = 0xdeadbeef;
777 res = create_pipe(&ctx.pipe, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
778 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
779 event = CreateEventW(NULL, TRUE, FALSE, NULL);
780 ok(event != INVALID_HANDLE_VALUE, "Can't create event, GetLastError: %lx\n", GetLastError());
781 res = listen_pipe(ctx.pipe, event, &ctx.iosb, FALSE);
782 ok(res == STATUS_PENDING, "NtFsControlFile returned %lx\n", res);
783 memset(&iosb, 0x55, sizeof(iosb));
784 res = pNtCancelSynchronousIoFile(GetCurrentThread(), NULL, &iosb);
785 ok(res == STATUS_NOT_FOUND, "NtCancelSynchronousIoFile returned %lx\n", res);
786 ok(iosb.Status == STATUS_NOT_FOUND, "iosb.Status got changed to %lx\n", iosb.Status);
787 ok(iosb.Information == 0, "iosb.Information got changed to %Iu\n", iosb.Information);
788 memset(&iosb, 0x55, sizeof(iosb));
789 res = pNtCancelSynchronousIoFile(GetCurrentThread(), &ctx.iosb, &iosb);
790 ok(res == STATUS_NOT_FOUND, "NtCancelSynchronousIoFile returned %lx\n", res);
791 ok(iosb.Status == STATUS_NOT_FOUND, "iosb.Status got changed to %lx\n", iosb.Status);
792 ok(iosb.Information == 0, "iosb.Information got changed to %Iu\n", iosb.Information);
794 ok(ret == WAIT_TIMEOUT, "wait returned %lx\n", ret);
797 ok(client != INVALID_HANDLE_VALUE, "can't open pipe: %lu\n", GetLastError());
799 ok(ret == WAIT_OBJECT_0, "wait returned %lx\n", ret);
800 CloseHandle(ctx.pipe);
803}
804
806{
811 {
812 memset(&fpi, 0x55, sizeof(fpi));
813 res = pNtQueryInformationFile(handle, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
814 ok_(__FILE__, line)(!res, "NtQueryInformationFile returned %lx\n", res);
815 ok_(__FILE__, line)(fpi.ReadMode == read, "Unexpected ReadMode, expected %lx, got %lx\n",
816 read, fpi.ReadMode);
817 ok_(__FILE__, line)(fpi.CompletionMode == completion, "Unexpected CompletionMode, expected %lx, got %lx\n",
819 }
820}
821#define check_pipe_handle_state(handle, r, c) _check_pipe_handle_state(__LINE__, handle, r, c)
822
823static void test_filepipeinfo(void)
824{
830 HANDLE hServer, hClient;
833
834 pRtlInitUnicodeString(&name, testpipe_nt);
835
836 attr.Length = sizeof(attr);
837 attr.RootDirectory = 0;
838 attr.ObjectName = &name;
839 attr.Attributes = OBJ_CASE_INSENSITIVE;
840 attr.SecurityDescriptor = NULL;
841 attr.SecurityQualityOfService = NULL;
842
843 timeout.QuadPart = -100000000;
844
845 /* test with INVALID_HANDLE_VALUE */
846 res = pNtQueryInformationFile(INVALID_HANDLE_VALUE, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
847 ok(res == STATUS_OBJECT_TYPE_MISMATCH, "NtQueryInformationFile returned %lx\n", res);
848
849 fpi.ReadMode = 0;
850 fpi.CompletionMode = 0;
851 res = pNtSetInformationFile(INVALID_HANDLE_VALUE, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
852 ok(res == STATUS_OBJECT_TYPE_MISMATCH, "NtSetInformationFile returned %lx\n", res);
853
854 /* server end with read-only attributes */
855 res = pNtCreateNamedPipeFile(&hServer, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb,
856 FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /* FILE_CREATE */,
857 0, 0, 0, 1, 0xFFFFFFFF, 500, 500, &timeout);
858 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
859
860 check_pipe_handle_state(hServer, 0, 1);
861
863 ok(hClient != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_PIPE_BUSY) /* > Win 8 */,
864 "can't open pipe, GetLastError: %lx\n", GetLastError());
865
866 check_pipe_handle_state(hServer, 0, 1);
867 check_pipe_handle_state(hClient, 0, 0);
868
869 fpi.ReadMode = 0;
870 fpi.CompletionMode = 0;
871 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
872 ok(res == STATUS_ACCESS_DENIED, "NtSetInformationFile returned %lx\n", res);
873
874 check_pipe_handle_state(hServer, 0, 1);
875 check_pipe_handle_state(hClient, 0, 0);
876
877 fpi.ReadMode = 1; /* invalid on a byte stream pipe */
878 fpi.CompletionMode = 1;
879 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
880 ok(res == STATUS_ACCESS_DENIED, "NtSetInformationFile returned %lx\n", res);
881
882 check_pipe_handle_state(hServer, 0, 1);
883 check_pipe_handle_state(hClient, 0, 0);
884
885 if (hClient != INVALID_HANDLE_VALUE)
886 {
887 fpi.ReadMode = 1; /* invalid on a byte stream pipe */
888 fpi.CompletionMode = 1;
889 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
890 ok(res == STATUS_INVALID_PARAMETER, "NtSetInformationFile returned %lx\n", res);
891 }
892
893 check_pipe_handle_state(hServer, 0, 1);
894 check_pipe_handle_state(hClient, 0, 0);
895
896 if (hClient != INVALID_HANDLE_VALUE)
897 {
898 fpi.ReadMode = 0;
899 fpi.CompletionMode = 1;
900 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
901 ok(!res, "NtSetInformationFile returned %lx\n", res);
902 }
903
904 check_pipe_handle_state(hServer, 0, 1);
905 check_pipe_handle_state(hClient, 0, 1);
906
907 if (hClient != INVALID_HANDLE_VALUE)
908 {
909 fpi.ReadMode = 0;
910 fpi.CompletionMode = 2; /* not in range 0-1 */
911 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
912 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %lx\n", res);
913
914 fpi.ReadMode = 2; /* not in range 0-1 */
915 fpi.CompletionMode = 0;
916 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
917 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %lx\n", res);
918 }
919
920 CloseHandle(hClient);
921
922 check_pipe_handle_state(hServer, 0, 1);
923
924 fpi.ReadMode = 0;
925 fpi.CompletionMode = 0;
926 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
927 ok(res == STATUS_ACCESS_DENIED, "NtSetInformationFile returned %lx\n", res);
928
929 CloseHandle(hServer);
930
931 /* message mode server with read/write attributes */
932 res = pNtCreateNamedPipeFile(&hServer, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb,
933 FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /* FILE_CREATE */,
934 0, 1, 1, 0, 0xFFFFFFFF, 500, 500, &timeout);
935 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
936
937 check_pipe_handle_state(hServer, 1, 0);
938
940 ok(hClient != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_PIPE_BUSY) /* > Win 8 */,
941 "can't open pipe, GetLastError: %lx\n", GetLastError());
942
943 check_pipe_handle_state(hServer, 1, 0);
944 check_pipe_handle_state(hClient, 0, 0);
945
946 if (hClient != INVALID_HANDLE_VALUE)
947 {
948 fpi.ReadMode = 1;
949 fpi.CompletionMode = 1;
950 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
951 ok(!res, "NtSetInformationFile returned %lx\n", res);
952 }
953
954 check_pipe_handle_state(hServer, 1, 0);
955 check_pipe_handle_state(hClient, 1, 1);
956
957 fpi.ReadMode = 0;
958 fpi.CompletionMode = 1;
959 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
960 ok(!res, "NtSetInformationFile returned %lx\n", res);
961
962 check_pipe_handle_state(hServer, 0, 1);
963 check_pipe_handle_state(hClient, 1, 1);
964
965 if (hClient != INVALID_HANDLE_VALUE)
966 {
967 fpi.ReadMode = 0;
968 fpi.CompletionMode = 2; /* not in range 0-1 */
969 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
970 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %lx\n", res);
971
972 fpi.ReadMode = 2; /* not in range 0-1 */
973 fpi.CompletionMode = 0;
974 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
975 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %lx\n", res);
976 }
977
978 CloseHandle(hClient);
979
980 check_pipe_handle_state(hServer, 0, 1);
981
982 fpi.ReadMode = 1;
983 fpi.CompletionMode = 0;
984 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), FilePipeInformation);
985 ok(!res, "NtSetInformationFile returned %lx\n", res);
986
987 check_pipe_handle_state(hServer, 1, 0);
988
989 CloseHandle(hServer);
990
991 res = pNtCreateNamedPipeFile(&hServer,
994 0, 1, 1, 0, 0xFFFFFFFF, 500, 500, &timeout);
995 ok(!res, "NtCreateNamedPipeFile returned %lx\n", res);
996
997 res = NtCreateFile(&hClient, SYNCHRONIZE, &attr, &iosb, NULL, 0,
999 ok(!res, "NtCreateFile returned %lx\n", res);
1000
1001 test_file_access(hClient, SYNCHRONIZE);
1002
1003 res = pNtQueryInformationFile(hClient, &iosb, &local_info, sizeof(local_info),
1006 "NtQueryInformationFile(FilePipeLocalInformation) returned: %lx\n", res);
1007
1008 res = pNtQueryInformationFile(hClient, &iosb, &local_info, sizeof(local_info),
1011 "NtQueryInformationFile(FilePipeInformation) returned: %lx\n", res);
1012
1013 res = pNtQueryInformationFile(hClient, &iosb, &local_info, sizeof(local_info),
1015 ok(res == STATUS_SUCCESS, "NtQueryInformationFile(FileNameInformation) returned: %lx\n", res);
1016
1017 CloseHandle(hClient);
1018 CloseHandle(hServer);
1019}
1020
1022{
1023 int *count = arg;
1024 (*count)++;
1025 ok( !reserved, "reserved is not 0: %lx\n", reserved );
1026}
1027
1029{
1032 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
1034
1035 memset(&iosb, 0x55, sizeof(iosb));
1037 ok(!status || status == STATUS_PENDING, "NtFsControlFile failed: %lx\n", status);
1038 ok(!iosb.Status, "iosb.Status = %lx\n", iosb.Status);
1039 ok(buf.ReadDataAvailable == 1, "ReadDataAvailable = %lu\n", buf.ReadDataAvailable);
1040
1042 memset(&iosb, 0x55, sizeof(iosb));
1044 ok(!status || status == STATUS_PENDING, "NtFsControlFile failed: %lx\n", status);
1045 ok(buf.ReadDataAvailable == 1, "ReadDataAvailable = %lu\n", buf.ReadDataAvailable);
1046 ok(!iosb.Status, "iosb.Status = %lx\n", iosb.Status);
1047 ok(is_signaled(event), "event is not signaled\n");
1048
1050}
1051
1052#define PIPENAME "\\\\.\\pipe\\ntdll_tests_pipe.c"
1053
1055{
1057
1060 ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
1061
1066 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError());
1067
1069 {
1071 ok(SetNamedPipeHandleState(client, &read_mode, NULL, NULL), "Change mode\n");
1072 }
1073
1075 {
1076 *read = server;
1077 *write = client;
1078 }
1079 else
1080 {
1081 *read = client;
1082 *write = server;
1083 }
1084 return TRUE;
1085}
1086
1087static void read_pipe_test(ULONG pipe_flags, ULONG pipe_type)
1088{
1089 IO_STATUS_BLOCK iosb, iosb2;
1091 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
1092 int apc_count = 0;
1093 char buffer[128];
1094 DWORD written;
1095 BOOL ret;
1097
1098 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1099
1100 /* try read with no data */
1101 iosb.Status = 0xdeadbabe;
1102 iosb.Information = 0xdeadbeef;
1103 ok( is_signaled( read ), "read handle is not signaled\n" );
1105 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1106 ok( !is_signaled( read ), "read handle is signaled\n" );
1107 ok( !is_signaled( event ), "event is signaled\n" );
1108 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1109 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1110 ok( !apc_count, "apc was called\n" );
1111 ret = WriteFile( write, buffer, 1, &written, NULL );
1112 ok(ret && written == 1, "WriteFile error %ld\n", GetLastError());
1113 /* iosb updated here by async i/o */
1114 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1115 ok( iosb.Information == 1, "wrong info %Iu\n", iosb.Information );
1116 ok( !is_signaled( read ), "read handle is signaled\n" );
1117 ok( is_signaled( event ), "event is not signaled\n" );
1118 ok( !apc_count, "apc was called\n" );
1119 apc_count = 0;
1120 SleepEx( 1, FALSE ); /* non-alertable sleep */
1121 ok( !apc_count, "apc was called\n" );
1122 SleepEx( 1, TRUE ); /* alertable sleep */
1123 ok( apc_count == 1, "apc not called\n" );
1124
1125 /* with no event, the pipe handle itself gets signaled */
1126 apc_count = 0;
1127 iosb.Status = 0xdeadbabe;
1128 iosb.Information = 0xdeadbeef;
1129 ok( !is_signaled( read ), "read handle is signaled\n" );
1130 status = NtReadFile( read, 0, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
1131 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1132 ok( !is_signaled( read ), "read handle is signaled\n" );
1133 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1134 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1135 ok( !apc_count, "apc was called\n" );
1136 ret = WriteFile( write, buffer, 1, &written, NULL );
1137 ok(ret && written == 1, "WriteFile error %ld\n", GetLastError());
1138 /* iosb updated here by async i/o */
1139 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1140 ok( iosb.Information == 1, "wrong info %Iu\n", iosb.Information );
1141 ok( is_signaled( read ), "read handle is not signaled\n" );
1142 ok( !apc_count, "apc was called\n" );
1143 apc_count = 0;
1144 SleepEx( 1, FALSE ); /* non-alertable sleep */
1145 ok( !apc_count, "apc was called\n" );
1146 SleepEx( 1, TRUE ); /* alertable sleep */
1147 ok( apc_count == 1, "apc not called\n" );
1148
1149 /* now read with data ready */
1150 apc_count = 0;
1151 iosb.Status = 0xdeadbabe;
1152 iosb.Information = 0xdeadbeef;
1153 ResetEvent( event );
1154 ret = WriteFile( write, buffer, 1, &written, NULL );
1155 ok(ret && written == 1, "WriteFile error %ld\n", GetLastError());
1156
1157 test_peek(read);
1158
1160 ok( status == STATUS_SUCCESS, "wrong status %lx\n", status );
1161 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1162 ok( iosb.Information == 1, "wrong info %Iu\n", iosb.Information );
1163 ok( is_signaled( event ), "event is not signaled\n" );
1164 ok( !apc_count, "apc was called\n" );
1165 SleepEx( 1, FALSE ); /* non-alertable sleep */
1166 ok( !apc_count, "apc was called\n" );
1167 SleepEx( 1, TRUE ); /* alertable sleep */
1168 ok( apc_count == 1, "apc not called\n" );
1169
1170 /* now partial read with data ready */
1171 apc_count = 0;
1172 iosb.Status = 0xdeadbabe;
1173 iosb.Information = 0xdeadbeef;
1174 ResetEvent( event );
1175 ret = WriteFile( write, buffer, 2, &written, NULL );
1176 ok(ret && written == 2, "WriteFile error %ld\n", GetLastError());
1177
1178 memset( &iosb, 0xcc, sizeof(iosb) );
1182 {
1184 "FSCTL_PIPE_PEEK returned %lx\n", status );
1185 ok( iosb.Status == STATUS_BUFFER_OVERFLOW, "wrong status %lx\n", iosb.Status );
1186 }
1187 else
1188 {
1189 ok( !status || status == STATUS_PENDING, "FSCTL_PIPE_PEEK returned %lx\n", status );
1190 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1191 }
1192 ok( iosb.Information == FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[1]),
1193 "wrong info %Iu\n", iosb.Information );
1194
1197 {
1198 ok( status == STATUS_BUFFER_OVERFLOW, "wrong status %lx\n", status );
1199 ok( iosb.Status == STATUS_BUFFER_OVERFLOW, "wrong status %lx\n", iosb.Status );
1200 }
1201 else
1202 {
1203 ok( status == STATUS_SUCCESS, "wrong status %lx\n", status );
1204 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1205 }
1206 ok( iosb.Information == 1, "wrong info %Iu\n", iosb.Information );
1207 ok( is_signaled( event ), "event is not signaled\n" );
1208 ok( !apc_count, "apc was called\n" );
1209 SleepEx( 1, FALSE ); /* non-alertable sleep */
1210 ok( !apc_count, "apc was called\n" );
1211 SleepEx( 1, TRUE ); /* alertable sleep */
1212 ok( apc_count == 1, "apc not called\n" );
1213 apc_count = 0;
1215 ok( status == STATUS_SUCCESS, "wrong status %lx\n", status );
1216 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1217 ok( iosb.Information == 1, "wrong info %Iu\n", iosb.Information );
1218 ok( is_signaled( event ), "event is not signaled\n" );
1219 ok( !apc_count, "apc was called\n" );
1220 SleepEx( 1, FALSE ); /* non-alertable sleep */
1221 ok( !apc_count, "apc was called\n" );
1222 SleepEx( 1, TRUE ); /* alertable sleep */
1223 ok( apc_count == 1, "apc not called\n" );
1224
1225 /* try read with no data */
1226 apc_count = 0;
1227 iosb.Status = 0xdeadbabe;
1228 iosb.Information = 0xdeadbeef;
1229 ok( is_signaled( event ), "event is not signaled\n" ); /* check that read resets the event */
1231 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1232 ok( !is_signaled( event ), "event is signaled\n" );
1233 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1234 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1235 ok( !apc_count, "apc was called\n" );
1236 ret = WriteFile( write, buffer, 1, &written, NULL );
1237 ok(ret && written == 1, "WriteFile error %ld\n", GetLastError());
1238 /* partial read is good enough */
1239 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1240 ok( is_signaled( event ), "event is not signaled\n" );
1241 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1242 ok( iosb.Information == 1, "wrong info %Iu\n", iosb.Information );
1243 ok( !apc_count, "apc was called\n" );
1244 SleepEx( 1, TRUE ); /* alertable sleep */
1245 ok( apc_count == 1, "apc was not called\n" );
1246
1247 /* read from disconnected pipe */
1248 apc_count = 0;
1249 iosb.Status = 0xdeadbabe;
1250 iosb.Information = 0xdeadbeef;
1251 CloseHandle( write );
1253 ok( status == STATUS_PIPE_BROKEN, "wrong status %lx\n", status );
1254 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1255 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1256 ok( !is_signaled( event ), "event is signaled\n" );
1257 ok( !apc_count, "apc was called\n" );
1258 SleepEx( 1, TRUE ); /* alertable sleep */
1259 ok( !apc_count, "apc was called\n" );
1260 CloseHandle( read );
1261
1262 /* read from disconnected pipe, with invalid event handle */
1263 apc_count = 0;
1264 iosb.Status = 0xdeadbabe;
1265 iosb.Information = 0xdeadbeef;
1266 status = NtReadFile( read, (HANDLE)0xdeadbeef, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
1267 ok( status == STATUS_INVALID_HANDLE, "wrong status %lx\n", status );
1268 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1269 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1270 ok( !apc_count, "apc was called\n" );
1271 SleepEx( 1, TRUE ); /* alertable sleep */
1272 ok( !apc_count, "apc was called\n" );
1273 CloseHandle( read );
1274
1275 /* read from closed handle */
1276 apc_count = 0;
1277 iosb.Status = 0xdeadbabe;
1278 iosb.Information = 0xdeadbeef;
1279 SetEvent( event );
1281 ok( status == STATUS_INVALID_HANDLE, "wrong status %lx\n", status );
1282 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1283 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1284 ok( is_signaled( event ), "event is not signaled\n" ); /* not reset on invalid handle */
1285 ok( !apc_count, "apc was called\n" );
1286 SleepEx( 1, TRUE ); /* alertable sleep */
1287 ok( !apc_count, "apc was called\n" );
1288
1289 /* disconnect while async read is in progress */
1290 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1291 apc_count = 0;
1292 iosb.Status = 0xdeadbabe;
1293 iosb.Information = 0xdeadbeef;
1295 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1296 ok( !is_signaled( event ), "event is signaled\n" );
1297 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1298 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1299 ok( !apc_count, "apc was called\n" );
1300 CloseHandle( write );
1301 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1302 ok( iosb.Status == STATUS_PIPE_BROKEN, "wrong status %lx\n", iosb.Status );
1303 ok( iosb.Information == 0, "wrong info %Iu\n", iosb.Information );
1304 ok( is_signaled( event ), "event is not signaled\n" );
1305 ok( !apc_count, "apc was called\n" );
1306 SleepEx( 1, TRUE ); /* alertable sleep */
1307 ok( apc_count == 1, "apc was not called\n" );
1308 CloseHandle( read );
1309
1310 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1312 ok(ret, "Failed to duplicate handle: %ld\n", GetLastError());
1313
1314 apc_count = 0;
1315 iosb.Status = 0xdeadbabe;
1316 iosb.Information = 0xdeadbeef;
1318 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1319 ok( !is_signaled( event ), "event is signaled\n" );
1320 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1321 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1322 ok( !apc_count, "apc was called\n" );
1323 /* Cancel by other handle */
1324 status = pNtCancelIoFile( read, &iosb2 );
1325 ok(status == STATUS_SUCCESS, "failed to cancel by different handle: %lx\n", status);
1326 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1327 ok( iosb.Status == STATUS_CANCELLED, "wrong status %lx\n", iosb.Status );
1328 ok( iosb.Information == 0, "wrong info %Iu\n", iosb.Information );
1329 ok( is_signaled( event ), "event is not signaled\n" );
1330 ok( !apc_count, "apc was called\n" );
1331 SleepEx( 1, TRUE ); /* alertable sleep */
1332 ok( apc_count == 1, "apc was not called\n" );
1333
1334 apc_count = 0;
1335 iosb.Status = 0xdeadbabe;
1336 iosb.Information = 0xdeadbeef;
1338 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1339 ok( !is_signaled( event ), "event is signaled\n" );
1340 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1341 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1342 ok( !apc_count, "apc was called\n" );
1343 /* Close queued handle */
1344 CloseHandle( read );
1345 SleepEx( 1, TRUE ); /* alertable sleep */
1346 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1347 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1348 status = pNtCancelIoFile( read, &iosb2 );
1349 ok(status == STATUS_INVALID_HANDLE, "cancelled by closed handle?\n");
1350 status = pNtCancelIoFile( handle, &iosb2 );
1351 ok(status == STATUS_SUCCESS, "failed to cancel: %lx\n", status);
1352 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1353 ok( iosb.Status == STATUS_CANCELLED, "wrong status %lx\n", iosb.Status );
1354 ok( iosb.Information == 0, "wrong info %Iu\n", iosb.Information );
1355 ok( is_signaled( event ), "event is not signaled\n" );
1356 ok( !apc_count, "apc was called\n" );
1357 SleepEx( 1, TRUE ); /* alertable sleep */
1358 ok( apc_count == 1, "apc was not called\n" );
1360 CloseHandle( write );
1361
1362 if (pNtCancelIoFileEx)
1363 {
1364 /* Basic Cancel Ex */
1365 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1366
1367 apc_count = 0;
1368 iosb.Status = 0xdeadbabe;
1369 iosb.Information = 0xdeadbeef;
1371 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1372 ok( !is_signaled( event ), "event is signaled\n" );
1373 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1374 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1375 ok( !apc_count, "apc was called\n" );
1376 status = pNtCancelIoFileEx( read, &iosb, &iosb2 );
1377 ok(status == STATUS_SUCCESS, "Failed to cancel I/O\n");
1378 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1379 ok( iosb.Status == STATUS_CANCELLED, "wrong status %lx\n", iosb.Status );
1380 ok( iosb.Information == 0, "wrong info %Iu\n", iosb.Information );
1381 ok( is_signaled( event ), "event is not signaled\n" );
1382 ok( !apc_count, "apc was called\n" );
1383 SleepEx( 1, TRUE ); /* alertable sleep */
1384 ok( apc_count == 1, "apc was not called\n" );
1385
1386 /* Duplicate iosb */
1387 apc_count = 0;
1388 iosb.Status = 0xdeadbabe;
1389 iosb.Information = 0xdeadbeef;
1391 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1392 ok( !is_signaled( event ), "event is signaled\n" );
1393 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1394 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1395 ok( !apc_count, "apc was called\n" );
1397 ok( status == STATUS_PENDING, "wrong status %lx\n", status );
1398 ok( !is_signaled( event ), "event is signaled\n" );
1399 ok( iosb.Status == 0xdeadbabe, "wrong status %lx\n", iosb.Status );
1400 ok( iosb.Information == 0xdeadbeef, "wrong info %Iu\n", iosb.Information );
1401 ok( !apc_count, "apc was called\n" );
1402 status = pNtCancelIoFileEx( read, &iosb, &iosb2 );
1403 ok(status == STATUS_SUCCESS, "Failed to cancel I/O\n");
1404 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1405 ok( iosb.Status == STATUS_CANCELLED, "wrong status %lx\n", iosb.Status );
1406 ok( iosb.Information == 0, "wrong info %Iu\n", iosb.Information );
1407 ok( is_signaled( event ), "event is not signaled\n" );
1408 ok( !apc_count, "apc was called\n" );
1409 SleepEx( 1, TRUE ); /* alertable sleep */
1410 ok( apc_count == 2, "apc was not called\n" );
1411
1412 CloseHandle( read );
1413 CloseHandle( write );
1414 }
1415 else
1416 win_skip("NtCancelIoFileEx not available\n");
1417
1419}
1420
1421static void test_transceive(void)
1422{
1424 HANDLE caller, callee;
1425 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
1426 char buffer[128];
1427 DWORD written;
1428 BOOL ret;
1430
1432 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 4096 )) return;
1433
1435 (BYTE*)"test", 4, buffer, sizeof(buffer) );
1436 ok( status == STATUS_PENDING, "NtFsControlFile(FSCTL_PIPE_TRANSCEIVE) returned %lx\n", status);
1437 ok( !is_signaled( event ), "event is signaled\n" );
1438
1439 ret = WriteFile( callee, buffer, 2, &written, NULL );
1440 ok(ret && written == 2, "WriteFile error %ld\n", GetLastError());
1441
1442 ok( iosb.Status == 0, "wrong status %lx\n", iosb.Status );
1443 ok( iosb.Information == 2, "wrong info %Iu\n", iosb.Information );
1444 ok( is_signaled( event ), "event is not signaled\n" );
1445
1446 CloseHandle( caller );
1447 CloseHandle( callee );
1448}
1449
1450#define test_no_queued_completion(a) _test_no_queued_completion(__LINE__,a)
1452{
1453 OVERLAPPED *pov;
1454 DWORD num_bytes;
1455 ULONG_PTR key;
1456 BOOL ret;
1457
1458 pov = (void *)0xdeadbeef;
1459 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 10);
1460 ok_(__FILE__,line)(!ret && GetLastError() == WAIT_TIMEOUT,
1461 "GetQueuedCompletionStatus returned %x(%lu)\n", ret, GetLastError());
1462}
1463
1464#define test_queued_completion(a,b,c,d) _test_queued_completion(__LINE__,a,b,c,d)
1466 NTSTATUS expected_status, ULONG expected_information)
1467{
1468 LARGE_INTEGER timeout = {{0}};
1469 ULONG_PTR value = 0xdeadbeef;
1471 ULONG_PTR key;
1473
1474 status = pNtRemoveIoCompletion(port, &key, &value, &iosb, &timeout);
1475 ok_(__FILE__,line)(status == STATUS_SUCCESS, "NtRemoveIoCompletion returned %lx\n", status);
1476 ok_(__FILE__,line)(value == (ULONG_PTR)io, "value = %Ix\n", value);
1477 ok_(__FILE__,line)(io->Status == expected_status, "Status = %lx\n", io->Status);
1478 ok_(__FILE__,line)(io->Information == expected_information,
1479 "Information = %Iu\n", io->Information);
1480}
1481
1482static void test_completion(void)
1483{
1484 static const char buf[] = "testdata";
1486 FILE_PIPE_PEEK_BUFFER peek_buf;
1487 char read_buf[16];
1489 OVERLAPPED ov;
1492 DWORD num_bytes;
1493 BOOL ret;
1494
1497
1498 status = pNtQueryInformationFile(pipe, &io, &info, sizeof(info),
1501 "status = %lx\n", status);
1502 if (status)
1503 {
1504 win_skip("FileIoCompletionNotificationInformation not supported\n");
1507 return;
1508 }
1509
1510 memset(&ov, 0, sizeof(ov));
1512 ok(ov.hEvent != INVALID_HANDLE_VALUE, "CreateEvent failed, error %lu\n", GetLastError());
1513
1514 port = CreateIoCompletionPort(client, NULL, 0xdeadbeef, 0);
1515 ok(port != NULL, "CreateIoCompletionPort failed, error %lu\n", GetLastError());
1516
1517 ret = WriteFile(client, buf, sizeof(buf), &num_bytes, &ov);
1518 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1519 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %lu\n", num_bytes);
1521
1523 NULL, 0, &peek_buf, sizeof(peek_buf));
1524 ok(status == STATUS_PENDING || status == STATUS_SUCCESS, "FSCTL_PIPE_PEEK returned %lx\n", status);
1526
1528 status = pNtSetInformationFile(client, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
1529 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
1530
1531 ret = WriteFile(client, buf, sizeof(buf), &num_bytes, &ov);
1532 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1533 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %lu\n", num_bytes);
1535
1536 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, &ov);
1537 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1538 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %lu\n", num_bytes);
1539
1541 ok(status == STATUS_BUFFER_OVERFLOW || status == STATUS_PENDING, "status = %lx\n", status);
1542 ok(io.Status == STATUS_BUFFER_OVERFLOW, "Status = %lx\n", io.Status);
1543 ok(io.Information == 1, "Information = %Iu\n", io.Information);
1544 if(status == STATUS_PENDING) /* win8+ */
1546 else
1548
1550 ok(status == STATUS_SUCCESS, "status = %lx\n", status);
1551 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1552 ok(io.Information == sizeof(buf)-1, "Information = %Iu\n", io.Information);
1554
1556 NULL, 0, &peek_buf, sizeof(peek_buf));
1557 ok(status == STATUS_PENDING || status == STATUS_SUCCESS, "FSCTL_PIPE_PEEK returned %lx\n", status);
1558 if(status == STATUS_PENDING) /* win8+ */
1560 else
1562
1563 memset(&io, 0xcc, sizeof(io));
1564 status = NtReadFile(client, ov.hEvent, NULL, &io, &io, read_buf, sizeof(read_buf), NULL, NULL);
1565 ok(status == STATUS_PENDING, "status = %lx\n", status);
1566 ok(!is_signaled(ov.hEvent), "event is signtaled\n");
1568
1569 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1570 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1572
1573 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1574 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1576 NULL, 0, &peek_buf, sizeof(peek_buf));
1578 "FSCTL_PIPE_PEEK returned %lx\n", status);
1579 if(status == STATUS_PENDING) /* win8+ */
1581 else
1583
1584 CloseHandle(ov.hEvent);
1588
1589 event = CreateEventW(NULL, TRUE, TRUE, NULL);
1592
1593 ok(is_signaled(client), "client is not signaled\n");
1594
1595 /* no event, APC nor completion: only signals on handle */
1596 memset(&io, 0xcc, sizeof(io));
1598 ok(status == STATUS_PENDING, "status = %lx\n", status);
1599 ok(!is_signaled(client), "client is signaled\n");
1600
1601 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1602 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1603 ok(is_signaled(client), "client is signaled\n");
1604 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1605 ok(io.Information == sizeof(buf), "Information = %Iu\n", io.Information);
1606
1607 /* event with no APC nor completion: signals only event */
1608 memset(&io, 0xcc, sizeof(io));
1610 ok(status == STATUS_PENDING, "status = %lx\n", status);
1611 ok(!is_signaled(client), "client is signaled\n");
1612 ok(!is_signaled(event), "event is signaled\n");
1613
1614 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1615 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1616 ok(!is_signaled(client), "client is signaled\n");
1617 ok(is_signaled(event), "event is not signaled\n");
1618 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1619 ok(io.Information == sizeof(buf), "Information = %Iu\n", io.Information);
1620
1621 /* APC with no event: handle is signaled */
1623 memset(&io, 0xcc, sizeof(io));
1625 ok(status == STATUS_PENDING, "status = %lx\n", status);
1626 ok(!is_signaled(client), "client is signaled\n");
1627
1628 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1629 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1630 ok(is_signaled(client), "client is signaled\n");
1631 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1632 ok(io.Information == sizeof(buf), "Information = %Iu\n", io.Information);
1633
1634 ok(!ioapc_called, "ioapc called\n");
1635 SleepEx(0, TRUE);
1636 ok(ioapc_called, "ioapc not called\n");
1637
1638 /* completion with no completion port: handle signaled */
1639 memset(&io, 0xcc, sizeof(io));
1641 ok(status == STATUS_PENDING, "status = %lx\n", status);
1642 ok(!is_signaled(client), "client is signaled\n");
1643
1644 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1645 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1646 ok(is_signaled(client), "client is not signaled\n");
1647
1648 port = CreateIoCompletionPort(client, NULL, 0xdeadbeef, 0);
1649 ok(port != NULL, "CreateIoCompletionPort failed, error %lu\n", GetLastError());
1650
1651 /* skipping completion on success: handle is signaled */
1653 status = pNtSetInformationFile(client, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
1654 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
1655 ok(is_signaled(client), "client is not signaled\n");
1656
1657 memset(&io, 0xcc, sizeof(io));
1659 ok(status == STATUS_PENDING, "status = %lx\n", status);
1660 ok(!is_signaled(client), "client is signaled\n");
1661
1662 ret = WriteFile(client, buf, 1, &num_bytes, NULL);
1663 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1664 ok(is_signaled(client), "client is not signaled\n");
1665
1666 /* skipping set event on handle: handle is never signaled */
1668 status = pNtSetInformationFile(client, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
1669 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
1670 ok(!is_signaled(client), "client is not signaled\n");
1671
1672 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1673 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1674 ok(!is_signaled(client), "client is signaled\n");
1676
1677 memset(&io, 0xcc, sizeof(io));
1679 ok(status == STATUS_PENDING, "status = %lx\n", status);
1680 ok(!is_signaled(client), "client is signaled\n");
1681
1682 ret = WriteFile(client, buf, 1, &num_bytes, NULL);
1683 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1684 ok(!is_signaled(client), "client is signaled\n");
1685
1686 ret = WriteFile(pipe, buf, sizeof(buf), &num_bytes, NULL);
1687 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1688 ok(!is_signaled(client), "client is signaled\n");
1689
1693}
1694
1696{
1699 enum {
1707};
1708
1710{
1711 struct blocking_thread_args *ctx = arg;
1712 static const char buf[] = "testdata";
1713 char read_buf[32];
1714 DWORD res, num_bytes;
1715 BOOL ret;
1716
1717 for (;;)
1718 {
1719 res = WaitForSingleObject(ctx->wait, 10000);
1720 ok(res == WAIT_OBJECT_0, "wait returned %lx\n", res);
1721 if (res != WAIT_OBJECT_0) break;
1722 switch(ctx->cmd) {
1724 Sleep(100);
1725 if(ctx->event)
1726 ok(!is_signaled(ctx->event), "event is signaled\n");
1727 ok(!ioapc_called, "ioapc called\n");
1728 ok(!is_signaled(ctx->client), "client is signaled\n");
1729 ok(is_signaled(ctx->pipe), "pipe is not signaled\n");
1730 ret = WriteFile(ctx->pipe, buf, 1, &num_bytes, NULL);
1731 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1732 ok(is_signaled(ctx->pipe), "pipe is not signaled\n");
1733 break;
1735 Sleep(100);
1736 if(ctx->event)
1737 ok(!is_signaled(ctx->event), "event is signaled\n");
1738 ok(!ioapc_called, "ioapc called\n");
1739 ok(!is_signaled(ctx->client), "client is signaled\n");
1740 ok(is_signaled(ctx->pipe), "pipe is not signaled\n");
1741 ret = ReadFile(ctx->pipe, read_buf, 1, &num_bytes, NULL);
1742 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1743 ok(is_signaled(ctx->pipe), "pipe is not signaled\n");
1744 break;
1746 return 0;
1747 default:
1748 ok(0, "unvalid command\n");
1749 }
1750 SetEvent(ctx->done);
1751 }
1752
1753 return 1;
1754}
1755
1757{
1761 char read_buf[16];
1762 HANDLE thread;
1765 DWORD res, num_bytes;
1766 BOOL ret;
1767
1768 ctx.wait = CreateEventW(NULL, FALSE, FALSE, NULL);
1769 ctx.done = CreateEventW(NULL, FALSE, FALSE, NULL);
1771 ok(thread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %lx\n", GetLastError());
1772
1774 options);
1775 ok(status == STATUS_SUCCESS, "NtCreateNamedPipeFile returned %lx\n", status);
1776
1777 pRtlInitUnicodeString(&name, testpipe_nt);
1778 attr.Length = sizeof(attr);
1779 attr.RootDirectory = 0;
1780 attr.ObjectName = &name;
1781 attr.Attributes = OBJ_CASE_INSENSITIVE;
1782 attr.SecurityDescriptor = NULL;
1783 attr.SecurityQualityOfService = NULL;
1786 options, NULL, 0 );
1787 ok(status == STATUS_SUCCESS, "NtCreateFile returned %lx\n", status);
1788
1789 ok(is_signaled(ctx.client), "client is not signaled\n");
1790 ok(is_signaled(ctx.pipe), "pipe is not signaled\n");
1791
1792 /* blocking read with no event nor APC */
1794 memset(&io, 0xff, sizeof(io));
1796 ctx.event = NULL;
1797 SetEvent(ctx.wait);
1798 status = NtReadFile(ctx.client, NULL, NULL, NULL, &io, read_buf, sizeof(read_buf), NULL, NULL);
1799 ok(status == STATUS_SUCCESS, "status = %lx\n", status);
1800 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1801 ok(io.Information == 1, "Information = %Iu\n", io.Information);
1802 ok(is_signaled(ctx.client), "client is not signaled\n");
1803
1804 res = WaitForSingleObject(ctx.done, 10000);
1805 ok(res == WAIT_OBJECT_0, "wait returned %lx\n", res);
1806
1807 /* blocking read with event and APC */
1809 memset(&io, 0xff, sizeof(io));
1811 ctx.event = CreateEventW(NULL, TRUE, TRUE, NULL);
1812 SetEvent(ctx.wait);
1813 status = NtReadFile(ctx.client, ctx.event, ioapc, &io, &io, read_buf,
1814 sizeof(read_buf), NULL, NULL);
1815 ok(status == STATUS_SUCCESS, "status = %lx\n", status);
1816 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1817 ok(io.Information == 1, "Information = %Iu\n", io.Information);
1818 ok(is_signaled(ctx.event), "event is not signaled\n");
1819 todo_wine
1820 ok(is_signaled(ctx.client), "client is not signaled\n");
1821
1823 ok(!ioapc_called, "ioapc called\n");
1824 SleepEx(0, TRUE); /* alertable wait state */
1825 ok(ioapc_called, "ioapc not called\n");
1826
1827 res = WaitForSingleObject(ctx.done, 10000);
1828 ok(res == WAIT_OBJECT_0, "wait returned %lx\n", res);
1830 CloseHandle(ctx.event);
1831 ctx.event = NULL;
1832
1833 /* blocking flush */
1834 ret = WriteFile(ctx.client, read_buf, 1, &num_bytes, NULL);
1835 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1836
1838 memset(&io, 0xff, sizeof(io));
1840 SetEvent(ctx.wait);
1841 status = NtFlushBuffersFile(ctx.client, &io);
1842 ok(status == STATUS_SUCCESS, "status = %lx\n", status);
1843 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1844 ok(io.Information == 0, "Information = %Iu\n", io.Information);
1845 ok(is_signaled(ctx.client), "client is not signaled\n");
1846
1847 res = WaitForSingleObject(ctx.done, 10000);
1848 ok(res == WAIT_OBJECT_0, "wait returned %lx\n", res);
1849
1850 CloseHandle(ctx.pipe);
1851 CloseHandle(ctx.client);
1852
1853 /* flush is blocking even in overlapped mode */
1856
1857 ok(is_signaled(ctx.client), "client is not signaled\n");
1858
1859 ret = WriteFile(ctx.client, read_buf, 1, &num_bytes, NULL);
1860 ok(ret, "WriteFile failed, error %lu\n", GetLastError());
1861
1862 ok(is_signaled(ctx.client), "client is not signaled\n");
1863
1865 memset(&io, 0xff, sizeof(io));
1867 SetEvent(ctx.wait);
1868 status = NtFlushBuffersFile(ctx.client, &io);
1869 ok(status == STATUS_SUCCESS, "status = %lx\n", status);
1870 ok(io.Status == STATUS_SUCCESS, "Status = %lx\n", io.Status);
1871 ok(io.Information == 0, "Information = %Iu\n", io.Information);
1872 /* client signaling is inconsistent in this case */
1873
1874 res = WaitForSingleObject(ctx.done, 10000);
1875 ok(res == WAIT_OBJECT_0, "wait returned %lx\n", res);
1876
1877 CloseHandle(ctx.pipe);
1878 CloseHandle(ctx.client);
1879
1881 SetEvent(ctx.wait);
1882 res = WaitForSingleObject(thread, 10000);
1883 ok(res == WAIT_OBJECT_0, "wait returned %lx\n", res);
1884
1885 CloseHandle(ctx.wait);
1886 CloseHandle(ctx.done);
1888}
1889
1890static void test_volume_info(void)
1891{
1894 HANDLE read, write;
1895 char buffer[128];
1897
1899 PIPE_TYPE_MESSAGE, 4096 )) return;
1900
1901 memset( buffer, 0xaa, sizeof(buffer) );
1902 memset( &iosb, 0xaa, sizeof(iosb) );
1903 status = pNtQueryVolumeInformationFile( read, &iosb, buffer, sizeof(buffer), FileFsDeviceInformation );
1904 ok( status == STATUS_SUCCESS, "NtQueryVolumeInformationFile failed: %lx\n", status );
1905 ok( iosb.Status == STATUS_SUCCESS, "got status %#lx\n", iosb.Status );
1906 ok( iosb.Information == sizeof(*device_info), "Information = %Iu\n", iosb.Information );
1908 ok( device_info->DeviceType == FILE_DEVICE_NAMED_PIPE, "DeviceType = %lu\n", device_info->DeviceType );
1910 "Characteristics = %lx\n", device_info->Characteristics );
1911
1912 memset( buffer, 0xaa, sizeof(buffer) );
1913 memset( &iosb, 0xaa, sizeof(iosb) );
1914 status = pNtQueryVolumeInformationFile( write, &iosb, buffer, sizeof(buffer), FileFsDeviceInformation );
1915 ok( status == STATUS_SUCCESS, "NtQueryVolumeInformationFile failed: %lx\n", status );
1916 ok( iosb.Status == STATUS_SUCCESS, "got status %#lx\n", iosb.Status );
1917 ok( iosb.Information == sizeof(*device_info), "Information = %Iu\n", iosb.Information );
1919 ok( device_info->DeviceType == FILE_DEVICE_NAMED_PIPE, "DeviceType = %lu\n", device_info->DeviceType );
1921 "Characteristics = %lx\n", device_info->Characteristics );
1922
1923 CloseHandle( read );
1924 CloseHandle( write );
1925}
1926
1927#define test_file_name_fail(a,b,c) _test_file_name_fail(__LINE__,a,b,c)
1928static void _test_file_name_fail(unsigned line, HANDLE pipe, NTSTATUS expected_status, BOOL todo)
1929{
1930 char buffer[512];
1933
1936 "expected STATUS_INFO_LENGTH_MISMATCH, got %#lx\n", status );
1937
1940 ok_(__FILE__,line)( status == expected_status, "expected %#lx, got %#lx\n", expected_status, status );
1941}
1942
1943#define test_file_name(a) _test_file_name(__LINE__,a)
1944static void _test_file_name(unsigned line, HANDLE pipe)
1945{
1946 char buffer[512];
1950
1951 static const WCHAR nameW[] =
1952 {'\\','n','t','d','l','l','_','t','e','s','t','s','_','p','i','p','e','.','c'};
1953
1954 memset( buffer, 0xaa, sizeof(buffer) );
1955 memset( &iosb, 0xaa, sizeof(iosb) );
1957 ok_(__FILE__,line)( status == STATUS_SUCCESS, "NtQueryInformationFile failed: %lx\n", status );
1958 ok_(__FILE__,line)( iosb.Status == STATUS_SUCCESS, "Status = %lx\n", iosb.Status );
1959 ok_(__FILE__,line)( iosb.Information == sizeof(name_info->FileNameLength) + sizeof(nameW),
1960 "Information = %Iu\n", iosb.Information );
1961 ok( name_info->FileNameLength == sizeof(nameW), "FileNameLength = %lu\n", name_info->FileNameLength );
1962 ok( !memcmp(name_info->FileName, nameW, sizeof(nameW)), "FileName = %s\n", wine_dbgstr_w(name_info->FileName) );
1963
1964 /* too small buffer */
1965 memset( buffer, 0xaa, sizeof(buffer) );
1966 memset( &iosb, 0xaa, sizeof(iosb) );
1968 ok( status == STATUS_BUFFER_OVERFLOW, "NtQueryInformationFile failed: %lx\n", status );
1969 ok( iosb.Status == STATUS_BUFFER_OVERFLOW, "Status = %lx\n", iosb.Status );
1970 ok( iosb.Information == 20, "Information = %Iu\n", iosb.Information );
1971 ok( name_info->FileNameLength == sizeof(nameW), "FileNameLength = %lu\n", name_info->FileNameLength );
1972 ok( !memcmp(name_info->FileName, nameW, 16), "FileName = %s\n", wine_dbgstr_w(name_info->FileName) );
1973
1974 /* too small buffer */
1975 memset( buffer, 0xaa, sizeof(buffer) );
1976 memset( &iosb, 0xaa, sizeof(iosb) );
1978 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryInformationFile failed: %lx\n", status );
1979}
1980
1982{
1983 HANDLE handle;
1985
1987 ok(status == STATUS_SUCCESS, "create_pipe failed: %lx\n", status);
1988 return handle;
1989}
1990
1992{
1993 HANDLE client;
1994
1997 ok(client != INVALID_HANDLE_VALUE, "can't open pipe: %lu\n", GetLastError());
1998
1999 return client;
2000}
2001
2003{
2004 BYTE buf[10] = {0};
2005 HANDLE client;
2006 DWORD written;
2007 BOOL res;
2008
2010
2011 res = WriteFile(client, buf, sizeof(buf), &written, NULL);
2012 ok(res, "WriteFile failed: %lu\n", GetLastError());
2013 res = WriteFile(server, buf, sizeof(buf), &written, NULL);
2014 ok(res, "WriteFile failed: %lu\n", GetLastError());
2015
2016 return client;
2017}
2018
2019static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
2020{
2021 FILE_PIPE_PEEK_BUFFER peek_buf;
2023 static char buf[] = "test";
2024 NTSTATUS status, expected_status;
2025
2026 memset(&peek_buf, 0xcc, sizeof(peek_buf));
2027 memset(&io, 0xcc, sizeof(io));
2028 status = NtFsControlFile(pipe, NULL, NULL, NULL, &io, FSCTL_PIPE_PEEK, NULL, 0, &peek_buf, sizeof(peek_buf));
2029 if (!status || status == STATUS_PENDING)
2030 status = io.Status;
2031 switch (state)
2032 {
2034 expected_status = is_server ? STATUS_INVALID_PIPE_STATE : STATUS_PIPE_DISCONNECTED;
2035 break;
2037 expected_status = STATUS_INVALID_PIPE_STATE;
2038 break;
2040 expected_status = STATUS_SUCCESS;
2041 break;
2042 default:
2043 expected_status = STATUS_PIPE_BROKEN;
2044 break;
2045 }
2046 ok(status == expected_status, "status = %lx, expected %lx in %s state %lu\n",
2047 status, expected_status, is_server ? "server" : "client", state);
2048 if (!status)
2049 ok(peek_buf.NamedPipeState == state, "NamedPipeState = %lu, expected %lu\n",
2050 peek_buf.NamedPipeState, state);
2051
2053 {
2055 expected_status = STATUS_INVALID_PIPE_STATE;
2057 buf, 1, buf+1, 1);
2058 if (!status || status == STATUS_PENDING)
2059 status = io.Status;
2060 ok(status == expected_status,
2061 "NtFsControlFile(FSCTL_PIPE_TRANSCEIVE) failed in %s state %lu: %lx\n",
2062 is_server ? "server" : "client", state, status);
2063 }
2064
2065 memset(&io, 0xcc, sizeof(io));
2067 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2068 {
2069 ok(status == STATUS_PIPE_DISCONNECTED, "status = %lx in %s state %lu\n",
2070 status, is_server ? "server" : "client", state);
2071 }
2072 else
2073 {
2074 ok(status == STATUS_SUCCESS, "status = %lx in %s state %lu\n",
2075 status, is_server ? "server" : "client", state);
2076 ok(io.Status == status, "io.Status = %lx\n", io.Status);
2077 ok(!io.Information, "io.Information = %Ix\n", io.Information);
2078 }
2079
2081 {
2082 switch (state)
2083 {
2085 expected_status = STATUS_PIPE_DISCONNECTED;
2086 break;
2088 expected_status = STATUS_PIPE_LISTENING;
2089 break;
2090 default:
2091 expected_status = STATUS_PIPE_BROKEN;
2092 break;
2093 }
2094 status = NtReadFile(pipe, NULL, NULL, NULL, &io, buf, 1, NULL, NULL);
2095 ok(status == expected_status, "NtReadFile failed in %s state %lu: %lx\n",
2096 is_server ? "server" : "client", state, status);
2097 }
2098
2100 {
2101 memset(&io, 0xcc, sizeof(io));
2104 "status = %lx in %lu state\n", status, state);
2105 }
2106}
2107
2109{
2110 FILE_PIPE_LOCAL_INFORMATION local_info;
2111 FILE_PIPE_INFORMATION pipe_info;
2112 FILE_PIPE_PEEK_BUFFER peek_buf;
2114 char buf[256] = "test";
2115 NTSTATUS status, expected_status;
2117
2118 memset(&io, 0xcc, sizeof(io));
2119 status = pNtQueryInformationFile(pipe, &io, &local_info, sizeof(local_info), FilePipeLocalInformation);
2120 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2122 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2123 is_server ? "server" : "client", state, status);
2124 else
2126 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2127 is_server ? "server" : "client", state, status);
2128 if (!status)
2129 {
2130 ok(local_info.NamedPipeState == state, "%s NamedPipeState = %lu, expected %lu\n",
2131 is_server ? "server" : "client", local_info.NamedPipeState, state);
2133 ok(local_info.ReadDataAvailable != 0, "ReadDataAvailable, expected non-zero, in %s state %lu\n",
2134 is_server ? "server" : "client", state);
2135 else
2136 ok(local_info.ReadDataAvailable == 0, "ReadDataAvailable, expected zero, in %s state %lu\n",
2137 is_server ? "server" : "client", state);
2138 }
2139
2140 status = pNtQueryInformationFile(pipe, &io, &std_info, sizeof(std_info), FileStandardInformation);
2141 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2143 "NtQueryInformationFile(FileStandardInformation) failed in %s state %lu: %lx\n",
2144 is_server ? "server" : "client", state, status);
2145 else
2147 "NtQueryInformationFile(FileStandardInformation) failed in %s state %lu: %lx\n",
2148 is_server ? "server" : "client", state, status);
2149 if (!status)
2150 {
2151 ok(std_info.AllocationSize.QuadPart == local_info.InboundQuota + local_info.OutboundQuota,
2152 "got %I64u, expected %lu.\n",
2153 std_info.AllocationSize.QuadPart, local_info.InboundQuota + local_info.OutboundQuota);
2154 ok(std_info.EndOfFile.QuadPart == local_info.ReadDataAvailable, "got %I64u.\n", std_info.EndOfFile.QuadPart);
2155 ok(std_info.NumberOfLinks == 1, "got %lu.\n", std_info.NumberOfLinks);
2156 todo_wine ok(std_info.DeletePending, "got %d.\n", std_info.DeletePending);
2157 ok(!std_info.Directory, "got %d.\n", std_info.Directory);
2158 }
2159
2160 status = pNtQueryInformationFile(pipe, &io, &pipe_info, sizeof(pipe_info), FilePipeInformation);
2161 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2163 "NtQueryInformationFile(FilePipeInformation) failed in %s state %lu: %lx\n",
2164 is_server ? "server" : "client", state, status);
2165 else
2167 "NtQueryInformationFile(FilePipeInformation) failed in %s state %lu: %lx\n",
2168 is_server ? "server" : "client", state, status);
2169
2171 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2173 "NtQueryInformationFile(FileNameInformation) failed: %lx\n", status);
2174 else
2177 "NtQueryInformationFile(FileNameInformation) failed: %lx\n", status);
2178
2179 memset(&peek_buf, 0xcc, sizeof(peek_buf));
2180 memset(&io, 0xcc, sizeof(io));
2181 status = NtFsControlFile(pipe, NULL, NULL, NULL, &io, FSCTL_PIPE_PEEK, NULL, 0, &peek_buf, sizeof(peek_buf));
2182 if (!status || status == STATUS_PENDING)
2183 status = io.Status;
2184 switch (state)
2185 {
2187 expected_status = is_server ? STATUS_INVALID_PIPE_STATE : STATUS_PIPE_DISCONNECTED;
2188 break;
2190 expected_status = STATUS_INVALID_PIPE_STATE;
2191 break;
2192 default:
2193 expected_status = STATUS_BUFFER_OVERFLOW;
2194 break;
2195 }
2196 ok(status == expected_status, "status = %lx, expected %lx in %s state %lu\n",
2197 status, expected_status, is_server ? "server" : "client", state);
2199 ok(peek_buf.NamedPipeState == state, "NamedPipeState = %lu, expected %lu\n",
2200 peek_buf.NamedPipeState, state);
2201
2202 switch (state)
2203 {
2205 expected_status = STATUS_PIPE_DISCONNECTED;
2206 break;
2208 expected_status = STATUS_PIPE_LISTENING;
2209 break;
2211 expected_status = STATUS_SUCCESS;
2212 break;
2213 default:
2214 expected_status = STATUS_PIPE_CLOSING;
2215 break;
2216 }
2218 ok(status == expected_status, "NtWriteFile failed in %s state %lu: %lx\n",
2219 is_server ? "server" : "client", state, status);
2220
2222 expected_status = STATUS_SUCCESS;
2223 status = NtReadFile(pipe, NULL, NULL, NULL, &io, buf, 1, NULL, NULL);
2224 ok(status == expected_status, "NtReadFile failed in %s state %lu: %lx\n",
2225 is_server ? "server" : "client", state, status);
2226}
2227
2229 HANDLE (*connect_client)(HANDLE),
2230 void (*test)(HANDLE pipe, BOOL is_server, DWORD pipe_state))
2231{
2235 HANDLE event;
2236 BOOL ret;
2237
2238 event = CreateEventW(NULL, TRUE, FALSE, NULL);
2239
2242
2244 ok(status == STATUS_PENDING, "listen_pipe returned %lx\n", status);
2246
2247 client = connect_client(server);
2250
2251 /* server closed, but not disconnected */
2255
2258 ok(status == STATUS_PENDING, "listen_pipe returned %lx\n", status);
2259
2260 client = connect_client(server);
2262 ok(ret, "DisconnectNamedPipe failed: %lu\n", GetLastError());
2268
2271 ok(status == STATUS_PENDING, "listen_pipe returned %lx\n", status);
2272
2273 client = connect_client(server);
2277 ok(ret, "DisconnectNamedPipe failed: %lu\n", GetLastError());
2279
2281 ok(status == STATUS_PENDING, "listen_pipe returned %lx\n", status);
2282 client = connect_client(server);
2287
2289}
2290
2292{
2297 HANDLE pipe;
2299
2300 pRtlInitUnicodeString(&name, testpipe_nt);
2301
2302 attr.Length = sizeof(attr);
2303 attr.RootDirectory = 0;
2304 attr.ObjectName = &name;
2305 attr.Attributes = OBJ_CASE_INSENSITIVE;
2306 attr.SecurityDescriptor = NULL;
2307 attr.SecurityQualityOfService = NULL;
2308
2309 timeout.QuadPart = -100000000;
2310
2311 status = pNtCreateNamedPipeFile(&pipe, FILE_READ_ATTRIBUTES | SYNCHRONIZE | GENERIC_WRITE,
2312 &attr, &iosb, FILE_SHARE_READ, FILE_CREATE, 0, 1, 0, 0, 1,
2313 100, 200, &timeout);
2314 ok(status == STATUS_SUCCESS, "NtCreateNamedPipeFile failed: %lx\n", status);
2315
2316 return pipe;
2317}
2318
2320{
2321 HANDLE client;
2322
2325 ok(client != INVALID_HANDLE_VALUE, "can't open pipe: %lu\n", GetLastError());
2326
2327 return client;
2328}
2329
2331{
2332 FILE_PIPE_LOCAL_INFORMATION local_info;
2333 FILE_PIPE_INFORMATION pipe_info;
2337 HANDLE new_pipe;
2340
2341 memset(&iosb, 0xcc, sizeof(iosb));
2342 memset(&local_info, 0xcc, sizeof(local_info));
2343 status = pNtQueryInformationFile(pipe, &iosb, &local_info, sizeof(local_info), FilePipeLocalInformation);
2344 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2346 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2347 is_server ? "server" : "client", state, status);
2348 else
2350 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2351 is_server ? "server" : "client", state, status);
2352 if (!status)
2353 {
2354 ok(local_info.NamedPipeType == 1, "NamedPipeType = %lu\n", local_info.NamedPipeType);
2355 ok(local_info.NamedPipeConfiguration == 1, "NamedPipeConfiguration = %lu\n",
2356 local_info.NamedPipeConfiguration);
2357 ok(local_info.MaximumInstances == 1, "MaximumInstances = %lu\n", local_info.MaximumInstances);
2358 if (!is_server && state == FILE_PIPE_CLOSING_STATE)
2359 ok(local_info.CurrentInstances == 0 || broken(local_info.CurrentInstances == 1 /* winxp */),
2360 "CurrentInstances = %lu\n", local_info.CurrentInstances);
2361 else
2362 ok(local_info.CurrentInstances == 1,
2363 "CurrentInstances = %lu\n", local_info.CurrentInstances);
2364 ok(local_info.InboundQuota == 100, "InboundQuota = %lu\n", local_info.InboundQuota);
2365 ok(local_info.ReadDataAvailable == 0, "ReadDataAvailable = %lu\n",
2366 local_info.ReadDataAvailable);
2367 ok(local_info.OutboundQuota == 200, "OutboundQuota = %lu\n", local_info.OutboundQuota);
2368 todo_wine
2369 ok(local_info.WriteQuotaAvailable == (is_server ? 200 : 100), "WriteQuotaAvailable = %lu\n",
2370 local_info.WriteQuotaAvailable);
2371 ok(local_info.NamedPipeState == state, "%s NamedPipeState = %lu, expected %lu\n",
2372 is_server ? "server" : "client", local_info.NamedPipeState, state);
2373 ok(local_info.NamedPipeEnd == is_server, "NamedPipeEnd = %lu\n", local_info.NamedPipeEnd);
2374
2375 /* try to create another, incompatible, instance of pipe */
2376 pRtlInitUnicodeString(&name, testpipe_nt);
2377
2378 attr.Length = sizeof(attr);
2379 attr.RootDirectory = 0;
2380 attr.ObjectName = &name;
2381 attr.Attributes = OBJ_CASE_INSENSITIVE;
2382 attr.SecurityDescriptor = NULL;
2383 attr.SecurityQualityOfService = NULL;
2384
2385 timeout.QuadPart = -100000000;
2386
2387 status = pNtCreateNamedPipeFile(&new_pipe, FILE_READ_ATTRIBUTES | SYNCHRONIZE | GENERIC_READ,
2388 &attr, &iosb, FILE_SHARE_WRITE, FILE_CREATE, 0, 0, 0, 0, 1,
2389 100, 200, &timeout);
2390 if (!local_info.CurrentInstances)
2391 ok(status == STATUS_SUCCESS, "NtCreateNamedPipeFile failed: %lx\n", status);
2392 else
2393 ok(status == STATUS_INSTANCE_NOT_AVAILABLE, "NtCreateNamedPipeFile failed: %lx\n", status);
2394 if (!status) CloseHandle(new_pipe);
2395
2396 memset(&iosb, 0xcc, sizeof(iosb));
2397 status = pNtQueryInformationFile(pipe, &iosb, &local_info, sizeof(local_info),
2400 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2401 is_server ? "server" : "client", state, status);
2402
2403 if (!is_server && state == FILE_PIPE_CLOSING_STATE)
2404 ok(local_info.CurrentInstances == 0 || broken(local_info.CurrentInstances == 1 /* winxp */),
2405 "CurrentInstances = %lu\n", local_info.CurrentInstances);
2406 else
2407 ok(local_info.CurrentInstances == 1,
2408 "CurrentInstances = %lu\n", local_info.CurrentInstances);
2409 }
2410
2411 memset(&iosb, 0xcc, sizeof(iosb));
2412 status = pNtQueryInformationFile(pipe, &iosb, &pipe_info, sizeof(pipe_info), FilePipeInformation);
2413 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2415 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2416 is_server ? "server" : "client", state, status);
2417 else
2419 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2420 is_server ? "server" : "client", state, status);
2421
2422 if (!status)
2423 {
2424 ok(pipe_info.ReadMode == 0, "ReadMode = %lu\n", pipe_info.ReadMode);
2425 ok(pipe_info.CompletionMode == 0, "CompletionMode = %lu\n", pipe_info.CompletionMode);
2426 }
2427
2428 pipe_info.ReadMode = 0;
2429 pipe_info.CompletionMode = 0;
2430 memset(&iosb, 0xcc, sizeof(iosb));
2431 status = pNtSetInformationFile(pipe, &iosb, &pipe_info, sizeof(pipe_info), FilePipeInformation);
2432 if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
2434 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2435 is_server ? "server" : "client", state, status);
2436 else
2438 "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %lu: %lx\n",
2439 is_server ? "server" : "client", state, status);
2440}
2441
2442static void test_file_info(void)
2443{
2445
2447 PIPE_TYPE_MESSAGE, 4096 )) return;
2448
2451
2454
2457
2458 device = CreateFileA("\\\\.\\pipe", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
2459 ok(device != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
2460
2462
2464}
2465
2467{
2468 SECURITY_DESCRIPTOR *sec_desc;
2469 ULONG length = 0;
2471
2473 NULL, 0, &length);
2476 "Failed to query object security descriptor length: %08lx\n", status);
2477 if(status != STATUS_BUFFER_TOO_SMALL) return NULL;
2478 ok(length != 0, "length = 0\n");
2479
2482 sec_desc, length, &length);
2483 ok(status == STATUS_SUCCESS, "Failed to query object security descriptor: %08lx\n", status);
2484
2485 return sec_desc;
2486}
2487
2489{
2490 TOKEN_OWNER *owner;
2491 ULONG length = 0;
2492 HANDLE token;
2493 BOOL ret;
2494
2496 ok(ret, "Failed to get process token: %lu\n", GetLastError());
2497
2500 "GetTokenInformation failed: %lu\n", GetLastError());
2501 ok(length != 0, "Failed to get token owner information length: %lu\n", GetLastError());
2502
2503 owner = HeapAlloc(GetProcessHeap(), 0, length);
2505 ok(ret, "Failed to get token owner information: %lu)\n", GetLastError());
2506
2508 return owner;
2509}
2510
2512{
2514 ULONG length = 0;
2515 HANDLE token;
2516 BOOL ret;
2517
2519 ok(ret, "Failed to get process token: %lu\n", GetLastError());
2520
2523 "GetTokenInformation failed: %lu\n", GetLastError());
2524 ok(length != 0, "Failed to get primary group token information length: %lu\n", GetLastError());
2525
2528 ok(ret, "Failed to get primary group token information: %lu\n", GetLastError());
2529
2531 return group;
2532}
2533
2535{
2537 SID *sid;
2538 BOOL ret;
2539
2541 ret = CreateWellKnownSid(sid_type, NULL, sid, &size);
2542 ok(ret, "CreateWellKnownSid failed: %lu\n", GetLastError());
2543 return sid;
2544}
2545
2546#define test_group(a,b,c) _test_group(__LINE__,a,b,c)
2547static void _test_group(unsigned line, HANDLE handle, SID *expected_sid, BOOL todo)
2548{
2549 SECURITY_DESCRIPTOR *sec_desc;
2550 BOOLEAN defaulted;
2551 PSID group_sid;
2553
2554 sec_desc = get_security_descriptor(handle, todo);
2555 if (!sec_desc) return;
2556
2557 status = RtlGetGroupSecurityDescriptor(sec_desc, &group_sid, &defaulted);
2558 ok_(__FILE__,line)(status == STATUS_SUCCESS,
2559 "Failed to query group from security descriptor: %08lx\n", status);
2561 ok_(__FILE__,line)(EqualSid(group_sid, expected_sid), "SIDs are not equal\n");
2562
2563 HeapFree(GetProcessHeap(), 0, sec_desc);
2564}
2565
2566static void test_security_info(void)
2567{
2568 char sec_desc[SECURITY_DESCRIPTOR_MIN_LENGTH];
2570 SECURITY_ATTRIBUTES sec_attr;
2571 TOKEN_OWNER *process_owner;
2572 HANDLE server, client, server2;
2573 SID *world_sid, *local_sid;
2574 ULONG length;
2576 BOOL ret;
2577
2578 trace("security tests...\n");
2579
2580 process_owner = get_current_owner();
2582 world_sid = well_known_sid(WinWorldSid);
2583 local_sid = well_known_sid(WinLocalSid);
2584
2586 ok(ret, "InitializeSecurityDescriptor failed\n");
2587
2588 ret = SetSecurityDescriptorOwner(sec_desc, process_owner->Owner, FALSE);
2589 ok(ret, "SetSecurityDescriptorOwner failed\n");
2590
2591 ret = SetSecurityDescriptorGroup(sec_desc, process_group->PrimaryGroup, FALSE);
2592 ok(ret, "SetSecurityDescriptorGroup failed\n");
2593
2595 0x20000, 0x20000, 0, NULL);
2596 ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %lu\n", GetLastError());
2597
2599 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
2600
2601 test_group(server, process_group->PrimaryGroup, TRUE);
2602 test_group(client, process_group->PrimaryGroup, TRUE);
2603
2604 /* set server group, client changes as well */
2605 ret = SetSecurityDescriptorGroup(sec_desc, world_sid, FALSE);
2606 ok(ret, "SetSecurityDescriptorGroup failed\n");
2608 ok(status == STATUS_SUCCESS, "NtSetSecurityObject failed: %08lx\n", status);
2609
2610 test_group(server, world_sid, FALSE);
2611 test_group(client, world_sid, FALSE);
2612
2613 /* new instance of pipe server has the same security descriptor */
2615 0x20000, 0x20000, 0, NULL);
2616 ok(server2 != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %lu\n", GetLastError());
2617 test_group(server2, world_sid, FALSE);
2618
2619 /* set client group, server changes as well */
2620 ret = SetSecurityDescriptorGroup(sec_desc, local_sid, FALSE);
2621 ok(ret, "SetSecurityDescriptorGroup failed\n");
2623 ok(status == STATUS_SUCCESS, "NtSetSecurityObject failed: %08lx\n", status);
2624
2625 test_group(server, local_sid, FALSE);
2626 test_group(client, local_sid, FALSE);
2627 test_group(server2, local_sid, FALSE);
2628
2630 /* SD is preserved after closing server object */
2631 test_group(client, local_sid, FALSE);
2633
2634 server = server2;
2636 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
2637
2638 test_group(client, local_sid, FALSE);
2639
2641 ok(ret, "DisconnectNamedPipe failed: %lu\n", GetLastError());
2642
2643 /* disconnected server may be queried for security info, but client does not */
2644 test_group(server, local_sid, FALSE);
2646 NULL, 0, &length);
2647 ok(status == STATUS_PIPE_DISCONNECTED, "NtQuerySecurityObject returned %08lx\n", status);
2649 ok(status == STATUS_PIPE_DISCONNECTED, "NtQuerySecurityObject returned %08lx\n", status);
2650
2651 /* attempting to create another pipe instance with specified sd fails */
2652 sec_attr.nLength = sizeof(sec_attr);
2653 sec_attr.lpSecurityDescriptor = sec_desc;
2654 sec_attr.bInheritHandle = FALSE;
2655 ret = SetSecurityDescriptorGroup(sec_desc, local_sid, FALSE);
2656 ok(ret, "SetSecurityDescriptorGroup failed\n");
2658 0x20000, 0x20000, 0, &sec_attr);
2659 todo_wine
2661 "CreateNamedPipe failed: %lu\n", GetLastError());
2662 if (server2 != INVALID_HANDLE_VALUE) CloseHandle(server2);
2663
2666
2668 0x20000, 0x20000, 0, &sec_attr);
2669 ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %lu\n", GetLastError());
2670 test_group(server, local_sid, FALSE);
2672
2673 HeapFree(GetProcessHeap(), 0, process_owner);
2675 HeapFree(GetProcessHeap(), 0, world_sid);
2676 HeapFree(GetProcessHeap(), 0, local_sid);
2677}
2678
2680{
2681 static const struct fsctl_test {
2682 const char *name;
2683 ULONG code;
2686 } fsctl_tests[] = {
2687#define FSCTL_TEST(code, ...) { #code, code, __VA_ARGS__ }
2696#undef FSCTL_TEST
2697 };
2698 FILE_PIPE_PEEK_BUFFER peek_buf;
2701 char buffer[1024];
2703 ULONG peer_pid;
2704 HANDLE event;
2705 size_t i;
2706
2707 event = NULL;
2710 ok(status == STATUS_SUCCESS, "NtCreateEvent returned %#lx\n", status);
2711
2713 todo_wine
2714 ok(status == STATUS_INVALID_PARAMETER, "NtReadFile on \\Device\\NamedPipe: got %#lx\n", status);
2715
2717 todo_wine
2718 ok(status == STATUS_INVALID_PARAMETER, "NtWriteFile on \\Device\\NamedPipe: got %#lx\n", status);
2719
2720 status = NtFsControlFile(handle, event, NULL, NULL, &io, FSCTL_PIPE_PEEK, NULL, 0, &peek_buf, sizeof(peek_buf));
2721 if (status == STATUS_PENDING)
2722 {
2724 status = io.Status;
2725 }
2726 todo_wine
2727 ok(status == STATUS_INVALID_PARAMETER, "FSCTL_PIPE_PEEK on \\Device\\NamedPipe: got %lx\n", status);
2728
2729 status = NtFsControlFile(handle, event, NULL, NULL, &io, FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ClientProcessId", sizeof("ClientProcessId"), &peer_pid, sizeof(peer_pid));
2730 if (status == STATUS_PENDING)
2731 {
2733 status = io.Status;
2734 }
2735 todo_wine
2736 ok(status == STATUS_INVALID_PARAMETER, "FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE ClientProcessId on \\Device\\NamedPipe: got %lx\n", status);
2737
2738 status = NtFsControlFile(handle, event, NULL, NULL, &io, FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ServerProcessId", sizeof("ServerProcessId"), &peer_pid, sizeof(peer_pid));
2739 if (status == STATUS_PENDING)
2740 {
2742 status = io.Status;
2743 }
2744 todo_wine
2745 ok(status == STATUS_INVALID_PARAMETER, "FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE ServerProcessId on \\Device\\NamedPipe: got %lx\n", status);
2746
2747 for (i = 0; i < ARRAY_SIZE(fsctl_tests); i++)
2748 {
2749 const struct fsctl_test *ft = &fsctl_tests[i];
2750
2751 status = NtFsControlFile(handle, event, NULL, NULL, &io, ft->code, 0, 0, 0, 0);
2752 if (status == STATUS_PENDING)
2753 {
2755 status = io.Status;
2756 }
2757 ok(status == ft->status || (ft->status_broken && broken(status == ft->status_broken)),
2758 "NtFsControlFile(%s) on \\Device\\NamedPipe: expected %#lx, got %#lx\n",
2759 ft->name, ft->status, status);
2760 }
2761
2762 NtClose(event);
2763}
2764
2765static void test_empty_name(void)
2766{
2767 static const LARGE_INTEGER zero_timeout = {{ 0 }};
2768 HANDLE hdirectory, hpipe, hpipe2, hwrite, hwrite2, handle;
2770 OBJECT_NAME_INFORMATION *name_info;
2775 DWORD data, length;
2776 char buffer[1024];
2778 BOOL ret;
2779
2781 name_info = (OBJECT_NAME_INFORMATION *)buffer;
2782
2783 hpipe = hwrite = NULL;
2784
2785 attr.Length = sizeof(attr);
2786 attr.Attributes = OBJ_CASE_INSENSITIVE;
2787 attr.SecurityDescriptor = NULL;
2788 attr.SecurityQualityOfService = NULL;
2789
2790 pRtlInitUnicodeString(&name, L"\\Device\\NamedPipe");
2791 attr.RootDirectory = 0;
2792 attr.ObjectName = &name;
2793
2796 ok(!status, "Got unexpected status %#lx.\n", status);
2797
2798 pRtlInitUnicodeString(&name, L"nonexistent_pipe");
2799 status = wait_pipe(hdirectory, &name, &zero_timeout);
2800 ok(status == STATUS_ILLEGAL_FUNCTION, "unexpected status for FSCTL_PIPE_WAIT on \\Device\\NamedPipe: %#lx\n", status);
2801
2803
2804 name.Buffer = NULL;
2805 name.Length = 0;
2806 name.MaximumLength = 0;
2807 attr.RootDirectory = hdirectory;
2808
2809 timeout.QuadPart = -(LONG64)10000000;
2810 status = pNtCreateNamedPipeFile(&hpipe, GENERIC_READ | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE, &attr,
2812 0, 0, 0, 3, 4096, 4096, &timeout);
2813 todo_wine ok(status == STATUS_OBJECT_NAME_INVALID, "Got unexpected status %#lx.\n", status);
2814 if (!status)
2815 CloseHandle(hpipe);
2816
2817 pRtlInitUnicodeString(&name, L"test3\\pipe");
2818 attr.RootDirectory = hdirectory;
2819 attr.ObjectName = &name;
2820 timeout.QuadPart = -(LONG64)10000000;
2821 status = pNtCreateNamedPipeFile(&hpipe, GENERIC_READ|GENERIC_WRITE, &attr, &io, FILE_SHARE_READ|FILE_SHARE_WRITE,
2822 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout);
2823 ok(status == STATUS_OBJECT_NAME_INVALID, "unexpected status from NtCreateNamedPipeFile: %#lx\n", status);
2824 if (!status)
2825 CloseHandle(hpipe);
2826
2827 CloseHandle(hdirectory);
2828
2829 pRtlInitUnicodeString(&name, L"\\Device\\NamedPipe\\");
2830 attr.RootDirectory = 0;
2831 attr.ObjectName = &name;
2832
2833 status = pNtCreateDirectoryObject(&hdirectory, GENERIC_READ | SYNCHRONIZE, &attr);
2834 todo_wine ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Got unexpected status %#lx.\n", status);
2835
2838 ok(!status, "Got unexpected status %#lx.\n", status);
2839
2840 pRtlInitUnicodeString(&name, L"nonexistent_pipe");
2841 status = wait_pipe(hdirectory, &name, &zero_timeout);
2842 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "unexpected status for FSCTL_PIPE_WAIT on \\Device\\NamedPipe\\: %#lx\n", status);
2843
2845
2846 name.Buffer = NULL;
2847 name.Length = 0;
2848 name.MaximumLength = 0;
2849 attr.RootDirectory = hdirectory;
2850
2851 hpipe = NULL;
2852 status = pNtCreateNamedPipeFile(&hpipe, GENERIC_READ | SYNCHRONIZE, &attr,
2854 0, 0, 0, 3, 4096, 4096, &timeout);
2855 ok(!status, "Got unexpected status %#lx.\n", status);
2856 type_info->TypeName.Buffer = NULL;
2857 status = pNtQueryObject(hpipe, ObjectTypeInformation, type_info, sizeof(buffer), NULL);
2858 ok(!status, "Got unexpected status %#lx.\n", status);
2859 ok(type_info->TypeName.Buffer && !wcscmp(type_info->TypeName.Buffer, L"File"),
2860 "Got unexpected type %s.\n", debugstr_w(type_info->TypeName.Buffer));
2861 status = pNtQueryObject(hpipe, ObjectNameInformation, name_info, sizeof(buffer), NULL);
2862 ok(status == STATUS_OBJECT_PATH_INVALID, "Got unexpected status %#lx.\n", status);
2863
2864 status = pNtCreateNamedPipeFile(&handle, GENERIC_READ | SYNCHRONIZE, &attr,
2866 0, 0, 0, 1, 4096, 4096, &timeout);
2867 todo_wine ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "Got unexpected status %#lx.\n", status);
2868
2869 status = pNtCreateNamedPipeFile(&hpipe2, GENERIC_READ | SYNCHRONIZE, &attr,
2871 0, 0, 0, 3, 4096, 4096, &timeout);
2872 ok(!status, "Got unexpected status %#lx.\n", status);
2873
2874 attr.RootDirectory = hpipe;
2875 pRtlInitUnicodeString(&name, L"a");
2878 ok(status == STATUS_OBJECT_NAME_INVALID, "Got unexpected status %#lx.\n", status);
2879
2880 name.Buffer = NULL;
2881 name.Length = 0;
2882 name.MaximumLength = 0;
2883 attr.RootDirectory = hpipe;
2886 ok(!status, "Got unexpected status %#lx.\n", status);
2887
2888 type_info->TypeName.Buffer = NULL;
2889 status = pNtQueryObject(hwrite, ObjectTypeInformation, type_info, sizeof(buffer), NULL);
2890 ok(!status, "Got unexpected status %#lx.\n", status);
2891 ok(type_info->TypeName.Buffer && !wcscmp(type_info->TypeName.Buffer, L"File"),
2892 "Got unexpected type %s.\n", debugstr_w(type_info->TypeName.Buffer));
2893 status = pNtQueryObject(hwrite, ObjectNameInformation, name_info, sizeof(buffer), NULL);
2894 ok(status == STATUS_OBJECT_PATH_INVALID, "Got unexpected status %#lx.\n", status);
2895
2896 attr.RootDirectory = hpipe;
2900 ok(status == STATUS_PIPE_NOT_AVAILABLE, "Got unexpected status %#lx.\n", status);
2901
2902 attr.RootDirectory = hpipe;
2905 ok(status == STATUS_PIPE_NOT_AVAILABLE, "Got unexpected status %#lx.\n", status);
2906
2907 attr.RootDirectory = hpipe2;
2910 ok(!status, "Got unexpected status %#lx.\n", status);
2911
2912 data = 0xdeadbeef;
2913 ret = WriteFile(hwrite, &data, sizeof(data), &length, NULL);
2914 ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
2915 ok(length == sizeof(data), "Got unexpected length %#lx.\n", length);
2916
2917 data = 0xfeedcafe;
2918 ret = WriteFile(hwrite2, &data, sizeof(data), &length, NULL);
2919 ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
2920 ok(length == sizeof(data), "Got unexpected length %#lx.\n", length);
2921
2922 data = 0;
2923 ret = ReadFile(hpipe, &data, sizeof(data), &length, NULL);
2924 ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
2925 ok(length == sizeof(data), "Got unexpected length %#lx.\n", length);
2926 ok(data == 0xdeadbeef, "Got unexpected data %#lx.\n", data);
2927
2928 data = 0;
2929 ret = ReadFile(hpipe2, &data, sizeof(data), &length, NULL);
2930 ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
2931 ok(length == sizeof(data), "Got unexpected length %#lx.\n", length);
2932 ok(data == 0xfeedcafe, "Got unexpected data %#lx.\n", data);
2933
2934 CloseHandle(hwrite);
2935 CloseHandle(hpipe);
2936 CloseHandle(hpipe2);
2937 CloseHandle(hwrite2);
2938
2939 pRtlInitUnicodeString(&name, L"test3\\pipe");
2940 attr.RootDirectory = hdirectory;
2941 attr.ObjectName = &name;
2942 timeout.QuadPart = -(LONG64)10000000;
2943 status = pNtCreateNamedPipeFile(&hpipe, GENERIC_READ|GENERIC_WRITE, &attr, &io, FILE_SHARE_READ|FILE_SHARE_WRITE,
2944 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout);
2945 ok(!status, "unexpected failure from NtCreateNamedPipeFile: %#lx\n", status);
2946
2947 handle = CreateFileA("\\\\.\\pipe\\test3\\pipe", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
2948 OPEN_EXISTING, 0, 0 );
2949 ok(handle != INVALID_HANDLE_VALUE, "Failed to open NamedPipe (%lu)\n", GetLastError());
2950
2952 CloseHandle(hpipe);
2953 CloseHandle(hdirectory);
2954}
2955
2957 const WCHAR *name;
2961};
2962
2963static void subtest_pipe_name(const struct pipe_name_test *pnt)
2964{
2968 HANDLE pipe, client;
2971
2972#ifdef __REACTOS__
2973 if ((GetNTVersion() < _WIN32_WINNT_VISTA) && (wcscmp(pnt->name, L"\\Device\\NamedPipe\\\\") == 0))
2974 {
2975 win_skip("Skipping subtest_pipe_name for '%ws' on Windows 2003\n", pnt->name);
2976 return;
2977 }
2978#endif
2979 pRtlInitUnicodeString(&name, pnt->name);
2981 timeout.QuadPart = -100000000;
2982 pipe = NULL;
2983 status = pNtCreateNamedPipeFile(&pipe,
2987 0, 0, 0, 3, 4096, 4096, &timeout);
2988 todo_wine_if(pnt->todo)
2989 ok(status == pnt->status, "Expected status %#lx, got %#lx\n", pnt->status, status);
2990
2991 if (!NT_SUCCESS(status))
2992 {
2993 ok(pipe == NULL, "expected NULL handle, got %p\n", pipe);
2994 return;
2995 }
2996
2997 ok(pipe != NULL, "expected non-NULL handle\n");
2998
2999 client = NULL;
3002 ok(status == STATUS_SUCCESS, "Expected success, got %#lx\n", status);
3003 ok(client != NULL, "expected non-NULL handle\n");
3004 NtClose(client);
3005
3006 if (pnt->no_open_name)
3007 {
3008 OBJECT_ATTRIBUTES no_open_attr;
3009 UNICODE_STRING no_open_name;
3010
3011 pRtlInitUnicodeString(&no_open_name, pnt->no_open_name);
3012 InitializeObjectAttributes(&no_open_attr, &no_open_name, OBJ_CASE_INSENSITIVE, NULL, NULL);
3013 client = NULL;
3014 status = NtCreateFile(&client, SYNCHRONIZE, &no_open_attr, &iosb, NULL, 0,
3017 "Expected STATUS_OBJECT_NAME_NOT_FOUND opening %s, got %#lx\n",
3018 debugstr_wn(no_open_name.Buffer, no_open_name.Length / sizeof(WCHAR)), status);
3019 ok(client == NULL, "expected NULL handle, got %p\n", client);
3020 }
3021
3022 NtClose(pipe);
3023}
3024
3025static void test_pipe_names(void)
3026{
3027 static const struct pipe_name_test tests[] = {
3028 { L"\\Device\\NamedPipe" , STATUS_OBJECT_NAME_INVALID, TRUE },
3029 { L"\\Device\\NamedPipe\\" , STATUS_OBJECT_NAME_INVALID, TRUE },
3030 { L"\\Device\\NamedPipe\\\\" , STATUS_SUCCESS },
3031 { L"\\Device\\NamedPipe\\wine-test\\" , STATUS_SUCCESS, 0, L"\\Device\\NamedPipe\\wine-test" },
3032 { L"\\Device\\NamedPipe\\wine/test" , STATUS_SUCCESS, 0, L"\\Device\\NamedPipe\\wine\\test" },
3033 { L"\\Device\\NamedPipe\\wine:test" , STATUS_SUCCESS },
3034 { L"\\Device\\NamedPipe\\wine\\.\\test" , STATUS_SUCCESS, 0, L"\\Device\\NamedPipe\\wine\\test" },
3035 { L"\\Device\\NamedPipe\\wine\\..\\test" , STATUS_SUCCESS, 0, L"\\Device\\NamedPipe\\test" },
3036 { L"\\Device\\NamedPipe\\..\\wine-test" , STATUS_SUCCESS },
3037 { L"\\Device\\NamedPipe\\!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", STATUS_SUCCESS },
3038 };
3039 size_t i;
3040
3041 for (i = 0; i < ARRAY_SIZE(tests); i++)
3042 {
3043 const struct pipe_name_test *pnt = &tests[i];
3044
3045 winetest_push_context("test %Iu: %s", i, debugstr_w(pnt->name));
3046 subtest_pipe_name(pnt);
3048 }
3049}
3050
3052{
3053 static const struct
3054 {
3055 BOOL event;
3058 }
3059 tests[] =
3060 {
3061 {TRUE, NULL},
3062 {FALSE, NULL},
3063 {TRUE, ioapc},
3064 {FALSE, ioapc},
3065 {TRUE, NULL, TRUE},
3066 {FALSE, NULL, TRUE},
3067 {TRUE, ioapc, TRUE},
3068 {FALSE, ioapc, TRUE},
3069 };
3070
3072 char read_buf[16];
3073 HANDLE port, write, read, event, handle2, process_handle;
3076 unsigned int i, other_process;
3077 DWORD ret;
3078 BOOL bret;
3079
3082
3083 status = pNtQueryInformationFile(read, &io, &info, sizeof(info),
3086 "status = %lx\n", status);
3089 if (status)
3090 {
3091 win_skip("FileIoCompletionNotificationInformation is not supported.\n");
3092 return;
3093 }
3094
3095 process_handle = create_process("sleep");
3096 event = CreateEventW(NULL, FALSE, FALSE, NULL);
3097
3098 for (other_process = 0; other_process < 2; ++other_process)
3099 {
3100 for (i = 0; i < ARRAY_SIZE(tests); ++i)
3101 {
3102 winetest_push_context("other_process %u, i %u", other_process, i);
3106 ok(!!port, "got %p.\n", port);
3107
3108 memset(&io, 0xcc, sizeof(io));
3111 read_buf, 16, NULL, NULL);
3112 if (tests[i].apc)
3113 {
3114 ok(status == STATUS_INVALID_PARAMETER, "got %#lx.\n", status);
3119 continue;
3120 }
3121 ok(status == STATUS_PENDING, "got %#lx.\n", status);
3122 ok(io.Status == 0xcccccccc, "got %#lx.\n", io.Status);
3123
3124 bret = DuplicateHandle(GetCurrentProcess(), read, other_process ? process_handle : GetCurrentProcess(),
3125 &handle2, 0, FALSE, DUPLICATE_SAME_ACCESS);
3126 ok(bret, "failed, error %lu.\n", GetLastError());
3127
3129 /* Canceled asyncs with completion port and no event do not update IOSB before removing completion. */
3130 todo_wine_if(other_process && tests[i].apc_context && !tests[i].event)
3131 ok(io.Status == 0xcccccccc, "got %#lx.\n", io.Status);
3132
3133 if (other_process && tests[i].apc_context && !tests[i].event)
3134#ifdef __REACTOS__
3136#endif
3138 else
3140
3142 ok(ret == WAIT_TIMEOUT, "got %#lx.\n", ret);
3143
3144 if (other_process)
3145 {
3146 bret = DuplicateHandle(process_handle, handle2, GetCurrentProcess(), &read, 0, FALSE,
3148 ok(bret, "failed, error %lu.\n", GetLastError());
3149 }
3150 else
3151 {
3152 read = handle2;
3153 }
3158 }
3159 }
3160
3162 TerminateProcess(process_handle, 0);
3163 WaitForSingleObject(process_handle, INFINITE);
3164 CloseHandle(process_handle);
3165}
3166
3168{
3169 char **argv;
3170 int argc;
3171
3172 if (!init_func_ptrs())
3173 return;
3174
3175 if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
3176
3178 if (argc >= 3)
3179 {
3180 if (!strcmp(argv[2], "sleep"))
3181 {
3182 Sleep(5000);
3183 return;
3184 }
3185 return;
3186 }
3187
3188 trace("starting invalid create tests\n");
3190
3191 trace("starting create tests\n");
3192 test_create();
3193
3194 trace("starting overlapped tests\n");
3196
3197 trace("starting completion tests\n");
3199
3200 trace("starting blocking tests\n");
3203
3204 trace("starting FILE_PIPE_INFORMATION tests\n");
3206
3207 if (!pOpenThread || !pQueueUserAPC)
3208 return;
3209
3210 trace("starting alertable tests\n");
3212
3213 trace("starting nonalertable tests\n");
3215
3216 trace("starting cancelio tests\n");
3217 test_cancelio();
3218
3219 trace("starting cancelsynchronousio tests\n");
3221
3222 trace("starting byte read in byte mode client -> server\n");
3224 trace("starting byte read in message mode client -> server\n");
3226 trace("starting message read in message mode client -> server\n");
3228 trace("starting byte read in byte mode server -> client\n");
3230 trace("starting byte read in message mode server -> client\n");
3232 trace("starting message read in message mode server -> client\n");
3234
3239#ifdef __REACTOS__
3241 win_skip("Skipping empty name pipe tests on Windows 2003.\n");
3242 else
3243#endif
3247
3251}
@ ObjectTypeInformation
Definition: DriverTester.h:56
@ ObjectNameInformation
Definition: DriverTester.h:55
#define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE
void CALLBACK completion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags)
Definition: WSARecv.c:16
unsigned char BOOLEAN
Definition: actypes.h:127
#define read
Definition: acwin.h:96
#define write
Definition: acwin.h:97
#define GetNTVersion()
Definition: apitest.h:17
static int state
Definition: maze.c:121
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR nameW[]
Definition: main.c:49
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
EXTERN_C NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
#define ARRAY_SIZE(A)
Definition: main.h:20
static HANDLE thread
Definition: service.c:33
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL
Definition: btrfs_drv.h:156
FT_UInt sid
Definition: cffcmap.c:138
struct __type_info type_info
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: d3dkmdt.h:46
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
LPWSTR Name
Definition: desk.c:124
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NTSTATUS
Definition: precomp.h:19
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
BOOL WINAPI CreateWellKnownSid(IN WELL_KNOWN_SID_TYPE WellKnownSidType, IN PSID DomainSid OPTIONAL, OUT PSID pSid, IN OUT DWORD *cbSid)
Definition: security.c:722
static HRESULT create_server(REFCLSID rclsid, HANDLE *process)
Definition: rpc.c:480
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GetCurrentProcess()
Definition: compat.h:759
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define CALLBACK
Definition: compat.h:35
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define FILE_SHARE_READ
Definition: compat.h:136
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1376
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
Definition: process.c:686
MonoAssembly int argc
Definition: metahost.c:107
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
USHORT port
Definition: uri.c:228
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
r reserved
Definition: btrfs.c:3006
#define INFINITE
Definition: serial.h:102
#define ULONG_PTR
Definition: config.h:101
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define STATUS_ACCESS_VIOLATION
@ FilePipeLocalInformation
Definition: from_kernel.h:85
@ FilePipeInformation
Definition: from_kernel.h:84
@ FileIoCompletionNotificationInformation
Definition: from_kernel.h:102
@ FileNameInformation
Definition: from_kernel.h:70
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_CREATE
Definition: from_kernel.h:55
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
@ FileFsDeviceInformation
Definition: from_kernel.h:222
enum _FSINFOCLASS FS_INFORMATION_CLASS
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
struct _cl_event * event
Definition: glext.h:7739
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLboolean GLuint group
Definition: glext.h:11120
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static HRESULT process_group(struct ciffile *file, struct inf_section *section, const char *section_name)
Definition: icif.c:1619
#define read_buf
Definition: intsym.h:279
NTSTATUS NTAPI NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, OUT PVOID *KeyContext, OUT PVOID *ApcContext, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: iocomp.c:445
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:65
#define FILE_SKIP_SET_EVENT_ON_HANDLE
Definition: iocompl.c:23
#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS
Definition: iocompl.c:22
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:131
NTSTATUS NTAPI NtFlushBuffersFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: iofunc.c:1487
static ULONG *static ULONG *static ULONG *static ULONG *static OVERLAPPED DWORD BOOL
Definition: pipe.c:45
static DWORD
Definition: pipe.c:37
#define test_file_access(a, b)
Definition: pipe.c:148
static void _test_file_access(unsigned line, HANDLE handle, DWORD expected_access)
Definition: pipe.c:149
static void test_overlapped(void)
Definition: pipe.c:2341
#define PIPENAME
Definition: pipe.c:32
#define debugstr_wn
Definition: kernel32.h:33
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
#define win_skip
Definition: minitest.h:67
#define todo_wine_if(is_todo)
Definition: minitest.h:81
#define todo_if(is_todo)
Definition: minitest.h:70
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
#define todo_wine
Definition: minitest.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
static struct test_info tests[]
#define sprintf
Definition: sprintf.c:45
BOOL todo
Definition: filedlg.c:313
DNS_STATUS status_broken
Definition: name.c:37
static HANDLE hEvent
Definition: comm.c:54
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
#define create_process(cmd, pi)
Definition: process.c:2637
static int apc_count
Definition: sync.c:2950
static SYSTEM_INFO si
Definition: virtual.c:39
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:72
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
int k
Definition: mpi.c:3369
#define argv
Definition: mplay32.c:18
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_PIPE_FULL_DUPLEX
Definition: iotypes.h:83
HANDLE hThread
Definition: wizard.c:28
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3096
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
#define GENERIC_ALL
Definition: nt_native.h:92
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define WRITE_OWNER
Definition: nt_native.h:60
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
VOID(* PIO_APC_ROUTINE)(IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved)
Definition: nt_native.h:880
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
@ NotificationEvent
static ACCESS_MASK
Definition: pipe.c:92
#define FSCTL_PIPE_LISTEN
Definition: pipe.c:80
#define FSCTL_PIPE_WAIT
Definition: pipe.c:84
static void test_create_invalid(void)
Definition: pipe.c:272
static void _test_group(unsigned line, HANDLE handle, SID *expected_sid, BOOL todo)
Definition: pipe.c:2547
static BOOL *static HANDLE PIO_APC_ROUTINE apc
Definition: pipe.c:91
static void test_peek(HANDLE pipe)
Definition: pipe.c:1028
struct _FILE_PIPE_WAIT_FOR_BUFFER * PFILE_PIPE_WAIT_FOR_BUFFER
static TOKEN_PRIMARY_GROUP * get_current_group(void)
Definition: pipe.c:2511
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG outbound_quota
Definition: pipe.c:98
static void test_security_info(void)
Definition: pipe.c:2566
static BOOL *static HANDLE PIO_APC_ROUTINE PVOID apc_context
Definition: pipe.c:91
static BOOL init_func_ptrs(void)
Definition: pipe.c:114
#define test_queued_completion(a, b, c, d)
Definition: pipe.c:1464
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:100
static PIO_STATUS_BLOCK PVOID ptr
Definition: pipe.c:103
static TOKEN_OWNER * get_current_owner(void)
Definition: pipe.c:2488
#define test_file_name(a)
Definition: pipe.c:1943
static void test_pipe_names(void)
Definition: pipe.c:3025
static NTSTATUS create_pipe(PHANDLE handle, ULONG access, ULONG sharing, ULONG options)
Definition: pipe.c:191
static BOOL *static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
Definition: pipe.c:91
static HANDLE create_pipe_server(void)
Definition: pipe.c:1981
static BOOL open_succeeded
Definition: pipe.c:457
static HANDLE connect_and_write_pipe(HANDLE server)
Definition: pipe.c:2002
static PIO_STATUS_BLOCK io_status
Definition: pipe.c:104
static HANDLE ULONG_PTR dwData
Definition: pipe.c:111
static BOOL userapc_called
Definition: pipe.c:451
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG completion_mode
Definition: pipe.c:97
static void CALLBACK userapc(ULONG_PTR dwParam)
Definition: pipe.c:452
static void CALLBACK ioapc(void *arg, PIO_STATUS_BLOCK io, ULONG reserved)
Definition: pipe.c:216
#define test_file_name_fail(a, b, c)
Definition: pipe.c:1927
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG sharing
Definition: pipe.c:95
static SID * well_known_sid(WELL_KNOWN_SID_TYPE sid_type)
Definition: pipe.c:2534
static BOOL *static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG code
Definition: pipe.c:91
static void _test_queued_completion(unsigned line, HANDLE port, IO_STATUS_BLOCK *io, NTSTATUS expected_status, ULONG expected_information)
Definition: pipe.c:1465
static OBJECT_ATTRIBUTES *static ULONG access
Definition: pipe.c:93
static void test_create(void)
Definition: pipe.c:332
static void test_filepipeinfo(void)
Definition: pipe.c:823
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:100
static void test_empty_name(void)
Definition: pipe.c:2765
static NTSTATUS listen_pipe(HANDLE hPipe, HANDLE hEvent, PIO_STATUS_BLOCK iosb, BOOL use_apc)
Definition: pipe.c:221
static void test_async_cancel_on_handle_close(void)
Definition: pipe.c:3051
static BOOL is_wow64
Definition: pipe.c:88
static void test_alertable(void)
Definition: pipe.c:486
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG options
Definition: pipe.c:95
static const WCHAR testpipe[]
Definition: pipe.c:186
static void test_blocking(ULONG options)
Definition: pipe.c:1756
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG pipe_type
Definition: pipe.c:96
#define check_pipe_handle_state(handle, r, c)
Definition: pipe.c:821
static BOOL bInheritHandle
Definition: pipe.c:110
static BOOL create_pipe_pair(HANDLE *read, HANDLE *write, ULONG flags, ULONG type, ULONG size)
Definition: pipe.c:1054
static BOOL ioapc_called
Definition: pipe.c:215
static void read_pipe_test(ULONG pipe_flags, ULONG pipe_type)
Definition: pipe.c:1087
#define test_no_queued_completion(a)
Definition: pipe.c:1450
struct _FILE_PIPE_WAIT_FOR_BUFFER FILE_PIPE_WAIT_FOR_BUFFER
static void test_volume_info(void)
Definition: pipe.c:1890
static BOOL DWORD dwThreadId
Definition: pipe.c:110
static void subtest_pipe_name(const struct pipe_name_test *pnt)
Definition: pipe.c:2963
static void test_cancelsynchronousio(void)
Definition: pipe.c:682
static NTSTATUS wait_pipe(HANDLE handle, PUNICODE_STRING name, const LARGE_INTEGER *timeout)
Definition: pipe.c:230
static void test_file_info(void)
Definition: pipe.c:2442
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG dispo
Definition: pipe.c:95
static void pipe_for_each_state(HANDLE(*create_server)(void), HANDLE(*connect_client)(HANDLE), void(*test)(HANDLE pipe, BOOL is_server, DWORD pipe_state))
Definition: pipe.c:2228
static void _test_file_name_fail(unsigned line, HANDLE pipe, NTSTATUS expected_status, BOOL todo)
Definition: pipe.c:1928
static void _test_no_queued_completion(unsigned line, HANDLE port)
Definition: pipe.c:1451
static void ULONG
Definition: pipe.c:101
static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state)
Definition: pipe.c:2108
static void _test_file_name(unsigned line, HANDLE pipe)
Definition: pipe.c:1944
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: pipe.c:76
static DWORD WINAPI synchronousio_thread(void *arg)
Definition: pipe.c:672
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES attr
Definition: pipe.c:94
static PCWSTR source
Definition: pipe.c:108
static PIO_STATUS_BLOCK PVOID ULONG len
Definition: pipe.c:103
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK iosb
Definition: pipe.c:94
static void test_completion(void)
Definition: pipe.c:1482
static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
Definition: pipe.c:2019
#define FSCTL_TEST(code,...)
static BOOL is_signaled(HANDLE obj)
Definition: pipe.c:167
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG Length
Definition: pipe.c:100
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG max_inst
Definition: pipe.c:97
static PLARGE_INTEGER
Definition: pipe.c:107
static PSECURITY_DESCRIPTOR get_security_descriptor(HANDLE handle, BOOL todo)
Definition: pipe.c:2466
static BOOL *static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: pipe.c:91
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG PLARGE_INTEGER timeout
Definition: pipe.c:99
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG inbound_quota
Definition: pipe.c:98
static void ULONG *static PIO_STATUS_BLOCK void ULONG FS_INFORMATION_CLASS info_class
Definition: pipe.c:102
static void test_pipe_local_info(HANDLE pipe, BOOL is_server, DWORD state)
Definition: pipe.c:2330
static OBJECT_INFORMATION_CLASS
Definition: pipe.c:101
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: pipe.c:72
static BOOL *static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
Definition: pipe.c:91
static void test_nonalertable(void)
Definition: pipe.c:556
static DWORD WINAPI blocking_thread(void *arg)
Definition: pipe.c:1709
static HANDLE connect_pipe_reader(HANDLE server)
Definition: pipe.c:2319
static void test_transceive(void)
Definition: pipe.c:1421
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:100
static OBJECT_ATTRIBUTES *static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG read_mode
Definition: pipe.c:96
static BOOL *static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID in_buffer
Definition: pipe.c:91
static void test_cancelio(void)
Definition: pipe.c:601
static void subtest_empty_name_pipe_operations(HANDLE handle)
Definition: pipe.c:2679
#define test_group(a, b, c)
Definition: pipe.c:2546
static const WCHAR testpipe_nt[]
Definition: pipe.c:188
static HANDLE connect_pipe(HANDLE server)
Definition: pipe.c:1991
static PULONG_PTR
Definition: pipe.c:107
static PIO_STATUS_BLOCK
Definition: pipe.c:107
#define loadfunc(name)
static void _check_pipe_handle_state(int line, HANDLE handle, ULONG read, ULONG completion)
Definition: pipe.c:805
static void ULONG *static PIO_STATUS_BLOCK void ULONG length
Definition: pipe.c:102
static HANDLE create_local_info_test_pipe(void)
Definition: pipe.c:2291
NTSYSAPI NTSTATUS NTAPI RtlGetGroupSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PSID *Group, OUT PBOOLEAN GroupDefaulted)
Definition: sd.c:280
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:96
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4017
NTSTATUS NTAPI NtCreateNamedPipeFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN ULONG NamedPipeType, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota, IN PLARGE_INTEGER DefaultTimeout)
Definition: file.c:3856
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:506
#define STATUS_PIPE_NOT_AVAILABLE
Definition: ntstatus.h:502
#define STATUS_PIPE_CONNECTED
Definition: ntstatus.h:508
#define STATUS_PIPE_LISTENING
Definition: ntstatus.h:509
#define STATUS_INVALID_PIPE_STATE
Definition: ntstatus.h:503
#define STATUS_PIPE_BROKEN
Definition: ntstatus.h:661
#define STATUS_OBJECT_PATH_INVALID
Definition: ntstatus.h:387
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:333
#define STATUS_PIPE_CLOSING
Definition: ntstatus.h:507
#define STATUS_INSTANCE_NOT_AVAILABLE
Definition: ntstatus.h:501
#define STATUS_ILLEGAL_FUNCTION
Definition: ntstatus.h:505
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:765
NTSTATUS NTAPI NtQuerySecurityObject(IN HANDLE Handle, IN SECURITY_INFORMATION SecurityInformation, OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Length, OUT PULONG ResultLength)
Definition: obsecure.c:803
short WCHAR
Definition: pedump.c:58
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:62
#define FSCTL_PIPE_IMPERSONATE
Definition: winioctl.h:741
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define test
Definition: rosglue.h:37
#define offsetof(TYPE, MEMBER)
int winetest_get_mainargs(char ***pargv)
#define memset(x, y, z)
Definition: compat.h:39
static FILE * client
Definition: client.c:37
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
Definition: sec.c:288
#define FileAccessInformation
Definition: propsheet.cpp:51
#define FileStandardInformation
Definition: propsheet.cpp:61
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
NTSTATUS WINAPI NtSetSecurityObject(HANDLE Handle, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor)
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
TCHAR * cmdline
Definition: stretchblt.cpp:32
ULONG CompletionMode
Definition: pipe.c:48
ULONG NamedPipeConfiguration
Definition: pipe.c:53
LARGE_INTEGER Timeout
Definition: pipe.c:65
BOOLEAN TimeoutSpecified
Definition: pipe.c:67
LARGE_INTEGER AllocationSize
Definition: propsheet.cpp:54
HANDLE hEvent
Definition: minwinbase.h:230
LPVOID lpSecurityDescriptor
Definition: compat.h:193
PSID Owner
Definition: setypes.h:1040
Definition: cookie.c:202
enum blocking_thread_args::@1826 cmd
Definition: inflate.c:139
Definition: devices.h:37
Definition: copy.c:22
Definition: parser.c:49
Definition: name.c:39
const WCHAR * name
Definition: pipe.c:2957
BOOL todo
Definition: pipe.c:2959
NTSTATUS status
Definition: pipe.c:2958
const WCHAR * no_open_name
Definition: pipe.c:2960
Definition: ps.c:97
IO_STATUS_BLOCK iosb
Definition: pipe.c:669
Definition: tools.h:99
Definition: dhcpd.h:248
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:738
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:573
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:650
#define STATUS_PENDING
Definition: telnetd.h:14
const uint16_t * PCWSTR
Definition: typedefs.h:57
int64_t LONG64
Definition: typedefs.h:68
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
PVOID HANDLE
Definition: typedefs.h:73
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: pdh_main.c:96
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define PIPE_ACCESS_INBOUND
Definition: winbase.h:167
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1146
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:136
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:166
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define PIPE_WAIT
Definition: winbase.h:173
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:172
#define PIPE_ACCESS_OUTBOUND
Definition: winbase.h:168
#define PIPE_TYPE_BYTE
Definition: winbase.h:169
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:170
void * arg
Definition: msvc.h:10
#define WINAPI
Definition: msvc.h:6
#define FSCTL_PIPE_SET_CLIENT_PROCESS
Definition: winioctl.h:326
#define FSCTL_PIPE_ASSIGN_EVENT
Definition: winioctl.h:318
#define FSCTL_PIPE_TRANSCEIVE
Definition: winioctl.h:323
#define FSCTL_PIPE_PEEK
Definition: winioctl.h:321
#define FSCTL_PIPE_QUERY_EVENT
Definition: winioctl.h:322
#define FSCTL_PIPE_DISCONNECT
Definition: winioctl.h:319
#define FSCTL_PIPE_QUERY_CLIENT_PROCESS
Definition: winioctl.h:327
#define FILE_PIPE_DISCONNECTED_STATE
Definition: winternl.h:1741
NTSYSAPI NTSTATUS WINAPI NtCancelSynchronousIoFile(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
#define FILE_PIPE_LISTENING_STATE
Definition: winternl.h:1742
#define FILE_PIPE_CONNECTED_STATE
Definition: winternl.h:1743
#define FILE_PIPE_CLOSING_STATE
Definition: winternl.h:1744
#define ERROR_PIPE_BUSY
Definition: winerror.h:405
#define DUPLICATE_SAME_ACCESS
#define DUPLICATE_CLOSE_SOURCE
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
@ TokenPrimaryGroup
Definition: setypes.h:982
@ TokenOwner
Definition: setypes.h:981
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define GROUP_SECURITY_INFORMATION
Definition: setypes.h:124
#define SECURITY_DESCRIPTOR_MIN_LENGTH
Definition: setypes.h:827
WELL_KNOWN_SID_TYPE
Definition: setypes.h:455
#define SECURITY_MAX_SID_SIZE
Definition: setypes.h:486
#define TOKEN_ALL_ACCESS
Definition: setypes.h:958
unsigned char BYTE
Definition: xxhash.c:193