ReactOS  0.4.15-dev-1177-g6cb3b62
pipe.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "winioctl.h"
#include "wine/test.h"
Include dependency graph for pipe.c:

Go to the source code of this file.

Classes

struct  rpcThreadArgs
 
struct  named_pipe_client_params
 
struct  overlapped_server_args
 

Macros

#define WIN32_NO_STATUS
 
#define PIPENAME   "\\\\.\\PiPe\\tests_pipe.c"
 
#define PIPENAME_SPECIAL   "\\\\.\\PiPe\\tests->pipe.c"
 
#define NB_SERVER_LOOPS   8
 
#define test_not_signaled(h)   _test_not_signaled(__LINE__,h)
 
#define test_signaled(h)   _test_signaled(__LINE__,h)
 
#define test_pipe_info(a, b, c, d, e)   _test_pipe_info(__LINE__,a,b,c,d,e)
 
#define PIPE_NAME   "\\\\.\\pipe\\named_pipe_test"
 
#define test_peek_pipe(a, b, c, d)   _test_peek_pipe(__LINE__,a,b,c,d)
 
#define overlapped_read_sync(a, b, c, d, e)   _overlapped_read_sync(__LINE__,a,b,c,d,e)
 
#define overlapped_read_async(a, b, c, d)   _overlapped_read_async(__LINE__,a,b,c,d)
 
#define overlapped_write_sync(a, b, c)   _overlapped_write_sync(__LINE__,a,b,c)
 
#define overlapped_write_async(a, b, c, d)   _overlapped_write_async(__LINE__,a,b,c,d)
 
#define test_flush_sync(a)   _test_flush_sync(__LINE__,a)
 
#define test_flush_async(a, b)   _test_flush_async(__LINE__,a,b)
 
#define test_flush_done(a)   _test_flush_done(__LINE__,a)
 
#define test_overlapped_result(a, b, c, d)   _test_overlapped_result(__LINE__,a,b,c,d)
 
#define test_overlapped_failure(a, b, c)   _test_overlapped_failure(__LINE__,a,b,c)
 
#define cancel_overlapped(a, b)   _cancel_overlapped(__LINE__,a,b)
 

Enumerations

enum  rpcThreadOp { RPC_READFILE }
 

Functions

static BOOL (WINAPI *pDuplicateTokenEx)(HANDLE
 
static DWORD (WINAPI *pQueueUserAPC)(PAPCFUNC pfnAPC
 
static void CALLBACK user_apc (ULONG_PTR param)
 
static DWORD CALLBACK rpcThreadMain (LPVOID arg)
 
static BOOL RpcReadFile (HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD bytesRead, LPOVERLAPPED overlapped)
 
static void _test_not_signaled (unsigned line, HANDLE handle)
 
static void _test_signaled (unsigned line, HANDLE handle)
 
static void _test_pipe_info (unsigned line, HANDLE pipe, DWORD ex_flags, DWORD ex_out_buf_size, DWORD ex_in_buf_size, DWORD ex_max_instances)
 
static void test_CreateNamedPipe (int pipemode)
 
static void test_CreateNamedPipe_instances_must_match (void)
 
static void test_ReadFile (void)
 
static DWORD CALLBACK alarmThreadMain (LPVOID arg)
 
static DWORD CALLBACK serverThreadMain1 (LPVOID arg)
 
static DWORD CALLBACK serverThreadMain2 (LPVOID arg)
 
static DWORD CALLBACK serverThreadMain3 (LPVOID arg)
 
static DWORD CALLBACK serverThreadMain4 (LPVOID arg)
 
static VOID WINAPI completion_routine (DWORD errorcode, DWORD num_bytes, LPOVERLAPPED lpoverlapped)
 
static DWORD CALLBACK serverThreadMain5 (LPVOID arg)
 
static void exercizeServer (const char *pipename, HANDLE serverThread)
 
static void test_NamedPipe_2 (void)
 
static int test_DisconnectNamedPipe (void)
 
static void test_CreatePipe (void)
 
static void test_CloseHandle (void)
 
static DWORD CALLBACK named_pipe_client_func (LPVOID p)
 
static HANDLE make_impersonation_token (DWORD Access, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
 
static void test_ImpersonateNamedPipeClient (HANDLE hClientToken, DWORD security_flags, BOOL revert, void(*test_func)(int, HANDLE))
 
static BOOL are_all_privileges_disabled (HANDLE hToken)
 
static DWORD get_privilege_count (HANDLE hToken)
 
static void test_no_sqos_no_token (int call_index, HANDLE hToken)
 
static void test_no_sqos (int call_index, HANDLE hToken)
 
static void test_static_context (int call_index, HANDLE hToken)
 
static void test_dynamic_context (int call_index, HANDLE hToken)
 
static void test_dynamic_context_no_token (int call_index, HANDLE hToken)
 
static void test_no_sqos_revert (int call_index, HANDLE hToken)
 
static void test_static_context_revert (int call_index, HANDLE hToken)
 
static void test_dynamic_context_revert (int call_index, HANDLE hToken)
 
static void test_impersonation (void)
 
static DWORD CALLBACK overlapped_server (LPVOID arg)
 
static void test_overlapped (void)
 
static void test_overlapped_error (void)
 
static void test_NamedPipeHandleState (void)
 
static void test_GetNamedPipeInfo (void)
 
static void test_readfileex_pending (void)
 
static void _test_peek_pipe (unsigned line, HANDLE pipe, DWORD expected_read, DWORD expected_avail, DWORD expected_message_length)
 
static void _overlapped_read_sync (unsigned line, HANDLE reader, void *buf, DWORD buf_size, DWORD expected_result, BOOL partial_read)
 
static void _overlapped_read_async (unsigned line, HANDLE reader, void *buf, DWORD buf_size, OVERLAPPED *overlapped)
 
static void _overlapped_write_sync (unsigned line, HANDLE writer, void *buf, DWORD size)
 
static void _overlapped_write_async (unsigned line, HANDLE writer, void *buf, DWORD size, OVERLAPPED *overlapped)
 
static void _test_flush_sync (unsigned line, HANDLE pipe)
 
static DWORD CALLBACK flush_proc (HANDLE pipe)
 
static HANDLE _test_flush_async (unsigned line, HANDLE pipe, DWORD error)
 
static void _test_flush_done (unsigned line, HANDLE thread)
 
static void _test_overlapped_result (unsigned line, HANDLE handle, OVERLAPPED *overlapped, DWORD expected_result, BOOL partial_read)
 
static void _test_overlapped_failure (unsigned line, HANDLE handle, OVERLAPPED *overlapped, DWORD error)
 
static void _cancel_overlapped (unsigned line, HANDLE handle, OVERLAPPED *overlapped)
 
static void test_blocking_rw (HANDLE writer, HANDLE reader, DWORD buf_size, BOOL msg_mode, BOOL msg_read)
 
static void child_process_write_pipe (HANDLE pipe)
 
static HANDLE create_writepipe_process (HANDLE pipe)
 
static void create_overlapped_pipe (DWORD mode, HANDLE *client, HANDLE *server)
 
static void test_overlapped_transport (BOOL msg_mode, BOOL msg_read_mode)
 
 START_TEST (pipe)
 

Variables

static HANDLE alarm_event
 
static DWORD
 
static LPSECURITY_ATTRIBUTES
 
static SECURITY_IMPERSONATION_LEVEL
 
static TOKEN_TYPE
 
static PHANDLE
 
static HANDLE hThread
 
static HANDLE ULONG_PTR dwData
 
static LPOVERLAPPED lpOverlapped
 
static BOOL user_apc_ran
 
static HANDLE hnp = INVALID_HANDLE_VALUE
 
static int completion_called
 
static DWORD completion_errorcode
 
static DWORD completion_num_bytes
 
static LPOVERLAPPED completion_lpoverlapped
 
static DWORD expected_flush_error
 

Macro Definition Documentation

◆ cancel_overlapped

#define cancel_overlapped (   a,
  b 
)    _cancel_overlapped(__LINE__,a,b)

Definition at line 2874 of file pipe.c.

◆ NB_SERVER_LOOPS

#define NB_SERVER_LOOPS   8

Definition at line 35 of file pipe.c.

◆ overlapped_read_async

#define overlapped_read_async (   a,
  b,
  c,
  d 
)    _overlapped_read_async(__LINE__,a,b,c,d)

Definition at line 2743 of file pipe.c.

◆ overlapped_read_sync

#define overlapped_read_sync (   a,
  b,
  c,
  d,
  e 
)    _overlapped_read_sync(__LINE__,a,b,c,d,e)

Definition at line 2713 of file pipe.c.

◆ overlapped_write_async

#define overlapped_write_async (   a,
  b,
  c,
  d 
)    _overlapped_write_async(__LINE__,a,b,c,d)

Definition at line 2779 of file pipe.c.

◆ overlapped_write_sync

#define overlapped_write_sync (   a,
  b,
  c 
)    _overlapped_write_sync(__LINE__,a,b,c)

Definition at line 2758 of file pipe.c.

◆ PIPE_NAME

#define PIPE_NAME   "\\\\.\\pipe\\named_pipe_test"

Definition at line 1784 of file pipe.c.

◆ PIPENAME

#define PIPENAME   "\\\\.\\PiPe\\tests_pipe.c"

Definition at line 32 of file pipe.c.

◆ PIPENAME_SPECIAL

#define PIPENAME_SPECIAL   "\\\\.\\PiPe\\tests->pipe.c"

Definition at line 33 of file pipe.c.

◆ test_flush_async

#define test_flush_async (   a,
  b 
)    _test_flush_async(__LINE__,a,b)

Definition at line 2819 of file pipe.c.

◆ test_flush_done

#define test_flush_done (   a)    _test_flush_done(__LINE__,a)

Definition at line 2834 of file pipe.c.

◆ test_flush_sync

#define test_flush_sync (   a)    _test_flush_sync(__LINE__,a)

Definition at line 2796 of file pipe.c.

◆ test_not_signaled

#define test_not_signaled (   h)    _test_not_signaled(__LINE__,h)

Definition at line 116 of file pipe.c.

◆ test_overlapped_failure

#define test_overlapped_failure (   a,
  b,
  c 
)    _test_overlapped_failure(__LINE__,a,b,c)

Definition at line 2859 of file pipe.c.

◆ test_overlapped_result

#define test_overlapped_result (   a,
  b,
  c,
  d 
)    _test_overlapped_result(__LINE__,a,b,c,d)

Definition at line 2842 of file pipe.c.

◆ test_peek_pipe

#define test_peek_pipe (   a,
  b,
  c,
  d 
)    _test_peek_pipe(__LINE__,a,b,c,d)

Definition at line 2677 of file pipe.c.

◆ test_pipe_info

#define test_pipe_info (   a,
  b,
  c,
  d,
  e 
)    _test_pipe_info(__LINE__,a,b,c,d,e)

Definition at line 131 of file pipe.c.

◆ test_signaled

#define test_signaled (   h)    _test_signaled(__LINE__,h)

Definition at line 124 of file pipe.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file pipe.c.

Enumeration Type Documentation

◆ rpcThreadOp

Enumerator
RPC_READFILE 

Definition at line 50 of file pipe.c.

51 {
53 };

Function Documentation

◆ _cancel_overlapped()

static void _cancel_overlapped ( unsigned  line,
HANDLE  handle,
OVERLAPPED overlapped 
)
static

Definition at line 2875 of file pipe.c.

2876 {
2877  BOOL res;
2878 
2879  res = pCancelIoEx(handle, overlapped);
2880  ok_(__FILE__,line)(res, "CancelIoEx failed: %u\n", GetLastError());
2881 
2883 }
static void _test_overlapped_failure(unsigned line, HANDLE handle, OVERLAPPED *overlapped, DWORD error)
Definition: pipe.c:2860
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _overlapped_read_async()

static void _overlapped_read_async ( unsigned  line,
HANDLE  reader,
void buf,
DWORD  buf_size,
OVERLAPPED overlapped 
)
static

Definition at line 2744 of file pipe.c.

2745 {
2746  DWORD read_bytes = 0xdeadbeef;
2747  BOOL res;
2748 
2749  memset(overlapped, 0, sizeof(*overlapped));
2750  overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
2751  res = ReadFile(reader, buf, buf_size, &read_bytes, overlapped);
2752  ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "ReadFile returned %x(%u)\n", res, GetLastError());
2753  ok_(__FILE__,line)(!read_bytes, "read_bytes %u expected 0\n", read_bytes);
2754 
2756 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:168
#define ERROR_IO_PENDING
Definition: dderror.h:15
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static void _test_not_signaled(unsigned line, HANDLE handle)
Definition: pipe.c:117
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
Definition: reader.h:83
GLuint res
Definition: glext.h:9613
#define memset(x, y, z)
Definition: compat.h:39
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _overlapped_read_sync()

static void _overlapped_read_sync ( unsigned  line,
HANDLE  reader,
void buf,
DWORD  buf_size,
DWORD  expected_result,
BOOL  partial_read 
)
static

Definition at line 2714 of file pipe.c.

2715 {
2716  DWORD read_bytes = 0xdeadbeef;
2718  BOOL res;
2719 
2720  memset(&overlapped, 0, sizeof(overlapped));
2721  overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
2722  res = ReadFile(reader, buf, buf_size, &read_bytes, &overlapped);
2723  if (partial_read)
2724  ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x (%u)\n", res, GetLastError());
2725  else
2726  ok_(__FILE__,line)(res, "ReadFile failed: %u\n", GetLastError());
2727  if(partial_read)
2728  ok_(__FILE__,line)(!read_bytes, "read_bytes %u expected 0\n", read_bytes);
2729  else
2730  ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %u expected %u\n", read_bytes, expected_result);
2731 
2732  read_bytes = 0xdeadbeef;
2734  if (partial_read)
2735  ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA,
2736  "GetOverlappedResult returned: %x (%u)\n", res, GetLastError());
2737  else
2738  ok_(__FILE__,line)(res, "GetOverlappedResult failed: %u\n", GetLastError());
2739  ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %u expected %u\n", read_bytes, expected_result);
2740  CloseHandle(overlapped.hEvent);
2741 }
#define CloseHandle
Definition: compat.h:487
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:168
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_MORE_DATA
Definition: dderror.h:13
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
Definition: reader.h:83
const char * expected_result
Definition: mimeole.c:1468
GLuint res
Definition: glext.h:9613
#define memset(x, y, z)
Definition: compat.h:39
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _overlapped_write_async()

static void _overlapped_write_async ( unsigned  line,
HANDLE  writer,
void buf,
DWORD  size,
OVERLAPPED overlapped 
)
static

Definition at line 2780 of file pipe.c.

2781 {
2782  DWORD written_bytes = 0xdeadbeef;
2783  BOOL res;
2784 
2785  memset(overlapped, 0, sizeof(*overlapped));
2786  overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
2787  res = WriteFile(writer, buf, size, &written_bytes, overlapped);
2789  ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%u)\n", res, GetLastError());
2791  ok_(__FILE__,line)(!written_bytes, "written_bytes = %u\n", written_bytes);
2792 
2794 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ERROR_IO_PENDING
Definition: dderror.h:15
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static void _test_not_signaled(unsigned line, HANDLE handle)
Definition: pipe.c:117
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define disable_success_count
Definition: test.h:170
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
GLuint res
Definition: glext.h:9613
#define memset(x, y, z)
Definition: compat.h:39
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _overlapped_write_sync()

static void _overlapped_write_sync ( unsigned  line,
HANDLE  writer,
void buf,
DWORD  size 
)
static

Definition at line 2759 of file pipe.c.

2760 {
2761  DWORD written_bytes = 0xdeadbeef;
2763  BOOL res;
2764 
2765  memset(&overlapped, 0, sizeof(overlapped));
2766  overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
2767  res = WriteFile(writer, buf, size, &written_bytes, &overlapped);
2768  ok_(__FILE__,line)(res, "WriteFile returned %x(%u)\n", res, GetLastError());
2769  ok_(__FILE__,line)(written_bytes == size, "WriteFile returned written_bytes = %u\n", written_bytes);
2770 
2771  written_bytes = 0xdeadbeef;
2772  res = GetOverlappedResult(writer, &overlapped, &written_bytes, FALSE);
2773  ok_(__FILE__,line)(res, "GetOverlappedResult failed: %u\n", GetLastError());
2774  ok_(__FILE__,line)(written_bytes == size, "GetOverlappedResult returned written_bytes %u expected %u\n", written_bytes, size);
2775 
2776  CloseHandle(overlapped.hEvent);
2777 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:487
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
GLuint res
Definition: glext.h:9613
#define memset(x, y, z)
Definition: compat.h:39
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_flush_async()

static HANDLE _test_flush_async ( unsigned  line,
HANDLE  pipe,
DWORD  error 
)
static

Definition at line 2820 of file pipe.c.

2821 {
2822  HANDLE thread;
2823  DWORD tid;
2824 
2826  thread = CreateThread(NULL, 0, flush_proc, pipe, 0, &tid);
2827  ok_(__FILE__,line)(thread != NULL, "CreateThread failed: %u\n", GetLastError());
2828 
2829  Sleep(50);
2831  return thread;
2832 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static void _test_not_signaled(unsigned line, HANDLE handle)
Definition: pipe.c:117
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:136
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD CALLBACK flush_proc(HANDLE pipe)
Definition: pipe.c:2807
static DWORD WINAPI thread(PVOID main_thread)
Definition: pipe.c:413
static DWORD expected_flush_error
Definition: pipe.c:2805
static TfClientId tid
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_flush_done()

static void _test_flush_done ( unsigned  line,
HANDLE  thread 
)
static

Definition at line 2835 of file pipe.c.

2836 {
2838  ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u (%u)\n", res, GetLastError());
2840 }
#define CloseHandle
Definition: compat.h:487
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
Definition: parser.c:48
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD WINAPI thread(PVOID main_thread)
Definition: pipe.c:413
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_flush_sync()

static void _test_flush_sync ( unsigned  line,
HANDLE  pipe 
)
static

Definition at line 2797 of file pipe.c.

2798 {
2799  BOOL res;
2800 
2801  res = FlushFileBuffers(pipe);
2802  ok_(__FILE__,line)(res, "FlushFileBuffers failed: %u\n", GetLastError());
2803 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_not_signaled()

static void _test_not_signaled ( unsigned  line,
HANDLE  handle 
)
static

Definition at line 117 of file pipe.c.

118 {
121  ok_(__FILE__,line)(res == WAIT_TIMEOUT, "WaitForSingleObject returned %u (%u)\n", res, GetLastError());
122 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define disable_success_count
Definition: test.h:170
#define WAIT_TIMEOUT
Definition: dderror.h:14
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by _overlapped_read_async(), _overlapped_write_async(), and _test_flush_async().

◆ _test_overlapped_failure()

static void _test_overlapped_failure ( unsigned  line,
HANDLE  handle,
OVERLAPPED overlapped,
DWORD  error 
)
static

Definition at line 2860 of file pipe.c.

2861 {
2862  DWORD result;
2863  BOOL res;
2864 
2865  _test_signaled(line, overlapped->hEvent);
2866 
2868  ok_(__FILE__,line)(!res && GetLastError() == error, "GetOverlappedResult returned: %x (%u), expected error %u\n",
2869  res, GetLastError(), error);
2870  ok_(__FILE__,line)(!result, "result = %u\n", result);
2871  CloseHandle(overlapped->hEvent);
2872 }
#define CloseHandle
Definition: compat.h:487
#define error(str)
Definition: mkdosfs.c:1605
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
static void _test_signaled(unsigned line, HANDLE handle)
Definition: pipe.c:125
unsigned long DWORD
Definition: ntddk_ex.h:95
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by _cancel_overlapped().

◆ _test_overlapped_result()

static void _test_overlapped_result ( unsigned  line,
HANDLE  handle,
OVERLAPPED overlapped,
DWORD  expected_result,
BOOL  partial_read 
)
static

Definition at line 2843 of file pipe.c.

2844 {
2845  DWORD result = 0xdeadbeef;
2846  BOOL res;
2847 
2848  _test_signaled(line, overlapped->hEvent);
2849 
2851  if (partial_read)
2852  ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA, "GetOverlappedResult returned: %x (%u)\n", res, GetLastError());
2853  else
2854  ok_(__FILE__,line)(res, "GetOverlappedResult failed: %u\n", GetLastError());
2855  ok_(__FILE__,line)(result == expected_result, "read_bytes = %u, expected %u\n", result, expected_result);
2856  CloseHandle(overlapped->hEvent);
2857 }
#define CloseHandle
Definition: compat.h:487
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
static void _test_signaled(unsigned line, HANDLE handle)
Definition: pipe.c:125
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_MORE_DATA
Definition: dderror.h:13
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
const char * expected_result
Definition: mimeole.c:1468
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_peek_pipe()

static void _test_peek_pipe ( unsigned  line,
HANDLE  pipe,
DWORD  expected_read,
DWORD  expected_avail,
DWORD  expected_message_length 
)
static

Definition at line 2678 of file pipe.c.

2679 {
2680  DWORD bytes_read = 0xdeadbeed, avail = 0xdeadbeef, left = 0xdeadbeed;
2681  char buf[4000];
2682  FILE_PIPE_PEEK_BUFFER *peek_buf = (void*)buf;
2684  NTSTATUS status;
2685  BOOL r;
2686 
2687  r = PeekNamedPipe(pipe, buf, sizeof(buf), &bytes_read, &avail, &left);
2688  ok_(__FILE__,line)(r, "PeekNamedPipe failed: %u\n", GetLastError());
2689  ok_(__FILE__,line)(bytes_read == expected_read, "bytes_read = %u, expected %u\n", bytes_read, expected_read);
2690  ok_(__FILE__,line)(avail == expected_avail, "avail = %u, expected %u\n", avail, expected_avail);
2691  ok_(__FILE__,line)(left == expected_message_length - expected_read, "left = %d, expected %d\n",
2692  left, expected_message_length - expected_read);
2693 
2694  status = NtFsControlFile(pipe, 0, NULL, NULL, &io, FSCTL_PIPE_PEEK, NULL, 0, buf, sizeof(buf));
2695  ok_(__FILE__,line)(!status || status == STATUS_PENDING, "NtFsControlFile(FSCTL_PIPE_PEEK) failed: %x\n", status);
2696  ok_(__FILE__,line)(io.Information == FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[expected_read]),
2697  "io.Information = %lu\n", io.Information);
2698  ok_(__FILE__,line)(peek_buf->ReadDataAvailable == expected_avail, "ReadDataAvailable = %u, expected %u\n",
2699  peek_buf->ReadDataAvailable, expected_avail);
2700  ok_(__FILE__,line)(peek_buf->MessageLength == expected_message_length, "MessageLength = %u, expected %u\n",
2701  peek_buf->MessageLength, expected_message_length);
2702 
2703  if (expected_read)
2704  {
2705  r = PeekNamedPipe(pipe, buf, 1, &bytes_read, &avail, &left);
2706  ok_(__FILE__,line)(r, "PeekNamedPipe failed: %u\n", GetLastError());
2707  ok_(__FILE__,line)(bytes_read == 1, "bytes_read = %u, expected %u\n", bytes_read, expected_read);
2708  ok_(__FILE__,line)(avail == expected_avail, "avail = %u, expected %u\n", avail, expected_avail);
2709  ok_(__FILE__,line)(left == expected_message_length-1, "left = %d, expected %d\n", left, expected_message_length-1);
2710  }
2711 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: pipe.c:67
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
static int avail
Definition: adh-main.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
#define FSCTL_PIPE_PEEK
Definition: winioctl.h:196
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI PeekNamedPipe(HANDLE hNamedPipe, LPVOID lpBuffer, DWORD nBufferSize, LPDWORD lpBytesRead, LPDWORD lpTotalBytesAvail, LPDWORD lpBytesLeftThisMessage)
Definition: npipe.c:1214
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: ps.c:97

◆ _test_pipe_info()

static void _test_pipe_info ( unsigned  line,
HANDLE  pipe,
DWORD  ex_flags,
DWORD  ex_out_buf_size,
DWORD  ex_in_buf_size,
DWORD  ex_max_instances 
)
static

Definition at line 132 of file pipe.c.

133 {
134  DWORD flags = 0xdeadbeef, out_buf_size = 0xdeadbeef, in_buf_size = 0xdeadbeef, max_instances = 0xdeadbeef;
135  BOOL res;
136 
137  res = GetNamedPipeInfo(pipe, &flags, &out_buf_size, &in_buf_size, &max_instances);
138  ok_(__FILE__,line)(res, "GetNamedPipeInfo failed: %x\n", res);
139  ok_(__FILE__,line)(flags == ex_flags, "flags = %x, expected %x\n", flags, ex_flags);
140  ok_(__FILE__,line)(out_buf_size == ex_out_buf_size, "out_buf_size = %x, expected %u\n", out_buf_size, ex_out_buf_size);
141  ok_(__FILE__,line)(in_buf_size == ex_in_buf_size, "in_buf_size = %x, expected %u\n", in_buf_size, ex_in_buf_size);
142  ok_(__FILE__,line)(max_instances == ex_max_instances, "max_instances = %x, expected %u\n", max_instances, ex_max_instances);
143 }
BOOL WINAPI GetNamedPipeInfo(HANDLE hNamedPipe, LPDWORD lpFlags, LPDWORD lpOutBufferSize, LPDWORD lpInBufferSize, LPDWORD lpMaxInstances)
Definition: npipe.c:1164
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_signaled()

static void _test_signaled ( unsigned  line,
HANDLE  handle 
)
static

Definition at line 125 of file pipe.c.

126 {
128  ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", res);
129 }
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
Definition: parser.c:48
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by _test_overlapped_failure(), and _test_overlapped_result().

◆ alarmThreadMain()

static DWORD CALLBACK alarmThreadMain ( LPVOID  arg)
static

implementation of alarm()

Definition at line 784 of file pipe.c.

785 {
787  if (winetest_debug > 1) trace("alarmThreadMain\n");
789  {
790  ok(FALSE, "alarm\n");
791  ExitProcess(1);
792  }
793  return 1;
794 }
#define DWORD_PTR
Definition: treelist.c:76
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
Definition: dhcpd.h:245
int winetest_debug
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
#define trace
Definition: atltest.h:70
#define WAIT_TIMEOUT
Definition: dderror.h:14
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ok(value,...)
Definition: atltest.h:57
static HANDLE alarm_event
Definition: pipe.c:37

Referenced by test_NamedPipe_2().

◆ are_all_privileges_disabled()

static BOOL are_all_privileges_disabled ( HANDLE  hToken)
static

Definition at line 1979 of file pipe.c.

1980 {
1981  BOOL ret;
1983  DWORD Size = 0;
1984  BOOL all_privs_disabled = TRUE;
1985  DWORD i;
1986 
1987  ret = GetTokenInformation(hToken, TokenPrivileges, NULL, 0, &Size);
1989  {
1992  if (!ret)
1993  {
1995  return FALSE;
1996  }
1997  }
1998  else
1999  return FALSE;
2000 
2001  for (i = 0; i < Privileges->PrivilegeCount; i++)
2002  {
2003  if (Privileges->Privileges[i].Attributes & SE_PRIVILEGE_ENABLED)
2004  {
2005  all_privs_disabled = FALSE;
2006  break;
2007  }
2008  }
2009 
2011 
2012  return all_privs_disabled;
2013 }
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
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
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET * Privileges
Definition: sefuncs.h:13
int ret
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
#define HeapFree(x, y, z)
Definition: compat.h:483
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by test_dynamic_context(), test_dynamic_context_no_token(), test_dynamic_context_revert(), test_impersonation(), test_no_sqos(), test_no_sqos_no_token(), test_no_sqos_revert(), test_static_context(), and test_static_context_revert().

◆ BOOL()

static BOOL ( WINAPI pDuplicateTokenEx)
static

◆ child_process_write_pipe()

static void child_process_write_pipe ( HANDLE  pipe)
static

Definition at line 3027 of file pipe.c.

3028 {
3030  char buf[10000];
3031 
3032  memset(buf, 'x', sizeof(buf));
3033  overlapped_write_async(pipe, buf, sizeof(buf), &overlapped);
3034 
3035  /* sleep until parent process terminates this process */
3036  Sleep(INFINITE);
3037 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define overlapped_write_async(a, b, c, d)
Definition: pipe.c:2779
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
#define INFINITE
Definition: serial.h:102
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ completion_routine()

static VOID WINAPI completion_routine ( DWORD  errorcode,
DWORD  num_bytes,
LPOVERLAPPED  lpoverlapped 
)
static

Definition at line 1209 of file pipe.c.

1210 {
1212  completion_errorcode = errorcode;
1214  completion_lpoverlapped = lpoverlapped;
1215  SetEvent(lpoverlapped->hEvent);
1216 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HANDLE hEvent
Definition: winbase.h:798
static DWORD completion_num_bytes
Definition: pipe.c:1206
static LPOVERLAPPED completion_lpoverlapped
Definition: pipe.c:1207
ed2 num_bytes
Definition: write.c:2832
static int completion_called
Definition: pipe.c:1204
static DWORD completion_errorcode
Definition: pipe.c:1205

Referenced by serverThreadMain5(), and test_readfileex_pending().

◆ create_overlapped_pipe()

static void create_overlapped_pipe ( DWORD  mode,
HANDLE client,
HANDLE server 
)
static

Definition at line 3055 of file pipe.c.

3056 {
3057  SECURITY_ATTRIBUTES sec_attr = { sizeof(sec_attr), NULL, TRUE };
3060  BOOL res;
3061 
3063  PIPE_WAIT | mode, 1, 5000, 6000, NMPWAIT_USE_DEFAULT_WAIT, NULL);
3064  ok(&server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %u\n", GetLastError());
3066 
3067  memset(&overlapped, 0, sizeof(overlapped));
3068  overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
3070  ok(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%u)\n", res, GetLastError());
3072  test_not_signaled(overlapped.hEvent);
3073 
3075  ok(*server != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
3076 
3078  ok(res, "SetNamedPipeHandleState failed: %u\n", GetLastError());
3079 
3083 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define TRUE
Definition: types.h:120
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
#define test_signaled(h)
Definition: pipe.c:124
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define ERROR_IO_PENDING
Definition: dderror.h:15
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define test_overlapped_result(a, b, c, d)
Definition: pipe.c:2842
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
static FILE * client
Definition: client.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GENERIC_READ
Definition: compat.h:135
GLenum mode
Definition: glext.h:6217
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
#define ok(value,...)
Definition: atltest.h:57
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG read_mode
Definition: pipe.c:68
#define test_not_signaled(h)
Definition: pipe.c:116
GLuint res
Definition: glext.h:9613
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:488
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701
#define PIPE_READMODE_BYTE
Definition: winbase.h:169

Referenced by test_overlapped_transport().

◆ create_writepipe_process()

static HANDLE create_writepipe_process ( HANDLE  pipe)
static

Definition at line 3039 of file pipe.c.

3040 {
3041  STARTUPINFOA si = { sizeof(si) };
3043  char **argv, buf[MAX_PATH];
3044  BOOL res;
3045 
3047  sprintf(buf, "\"%s\" pipe writepipe %lx", argv[0], (UINT_PTR)pipe);
3048  res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0L, NULL, NULL, &si, &info);
3049  ok(res, "CreateProcess failed: %u\n", GetLastError());
3050  CloseHandle(info.hThread);
3051 
3052  return info.hProcess;
3053 }
#define CloseHandle
Definition: compat.h:487
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define argv
Definition: mplay32.c:18
struct _test_info info[]
Definition: SetCursorPos.c:19
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4744
#define MAX_PATH
Definition: compat.h:34
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int winetest_get_mainargs(char ***pargv)
static const WCHAR L[]
Definition: oid.c:1250
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613

Referenced by test_overlapped_transport().

◆ DWORD()

static DWORD ( WINAPI pQueueUserAPC)
static

◆ exercizeServer()

static void exercizeServer ( const char pipename,
HANDLE  serverThread 
)
static

Definition at line 1311 of file pipe.c.

1312 {
1313  int i;
1314 
1315  if (winetest_debug > 1) trace("exercizeServer starting\n");
1316  for (i = 0; i < NB_SERVER_LOOPS; i++) {
1318  static const char obuf[] = "Bit Bucket";
1319  char ibuf[32];
1320  DWORD written;
1321  DWORD readden;
1322  int loop;
1323 
1324  for (loop = 0; loop < 3; loop++) {
1325  DWORD err;
1326  if (winetest_debug > 1) trace("Client connecting...\n");
1327  /* Connect to the server */
1328  hFile = CreateFileA(pipename, GENERIC_READ | GENERIC_WRITE, 0,
1329  NULL, OPEN_EXISTING, 0, 0);
1330  if (hFile != INVALID_HANDLE_VALUE)
1331  break;
1332  err = GetLastError();
1333  if (loop == 0)
1334  ok(err == ERROR_PIPE_BUSY || err == ERROR_FILE_NOT_FOUND, "connecting to pipe\n");
1335  else
1336  ok(err == ERROR_PIPE_BUSY, "connecting to pipe\n");
1337  if (winetest_debug > 1) trace("connect failed, retrying\n");
1338  Sleep(200);
1339  }
1340  ok(hFile != INVALID_HANDLE_VALUE, "client opening named pipe\n");
1341 
1342  /* Make sure it can echo */
1343  memset(ibuf, 0, sizeof(ibuf));
1344  if (winetest_debug > 1) trace("Client writing...\n");
1345  ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile to client end of pipe\n");
1346  ok(written == sizeof(obuf), "write file len\n");
1347  if (winetest_debug > 1) trace("Client reading...\n");
1348  ok(ReadFile(hFile, ibuf, sizeof(obuf), &readden, NULL), "ReadFile from client end of pipe\n");
1349  ok(readden == sizeof(obuf), "read file len\n");
1350  ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
1351 
1352  if (winetest_debug > 1) trace("Client closing...\n");
1353  ok(CloseHandle(hFile), "CloseHandle\n");
1354  }
1355 
1356  ok(WaitForSingleObject(serverThread,INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject\n");
1357  CloseHandle(hnp);
1358  if (winetest_debug > 1) trace("exercizeServer returning\n");
1359 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:487
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define NB_SERVER_LOOPS
Definition: pipe.c:35
static HANDLE hnp
Definition: pipe.c:796
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
int winetest_debug
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
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
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define OPEN_EXISTING
Definition: compat.h:523
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_PIPE_BUSY
Definition: winerror.h:283
#define GENERIC_READ
Definition: compat.h:135
#define err(...)
_In_ HANDLE hFile
Definition: mswsock.h:90
static char obuf[100]
Definition: i386-dis.c:1266
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:488
#define INFINITE
Definition: serial.h:102
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_NamedPipe_2().

◆ flush_proc()

static DWORD CALLBACK flush_proc ( HANDLE  pipe)
static

Definition at line 2807 of file pipe.c.

2808 {
2809  BOOL res;
2810 
2811  res = FlushFileBuffers(pipe);
2813  ok(res, "FlushFileBuffers failed: %u\n", GetLastError());
2814  else
2815  todo_wine ok(!res && GetLastError() == expected_flush_error, "FlushFileBuffers failed: %u\n", GetLastError());
2816  return 0;
2817 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define todo_wine
Definition: test.h:162
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613
static DWORD expected_flush_error
Definition: pipe.c:2805

Referenced by _test_flush_async().

◆ get_privilege_count()

static DWORD get_privilege_count ( HANDLE  hToken)
static

Definition at line 2015 of file pipe.c.

2016 {
2017  TOKEN_STATISTICS Statistics;
2018  DWORD Size = sizeof(Statistics);
2019  BOOL ret;
2020 
2021  ret = GetTokenInformation(hToken, TokenStatistics, &Statistics, Size, &Size);
2022  ok(ret, "GetTokenInformation(TokenStatistics)\n");
2023  if (!ret) return -1;
2024 
2025  return Statistics.PrivilegeCount;
2026 }
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
$ULONG PrivilegeCount
Definition: setypes.h:1040
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413

Referenced by test_impersonation(), test_no_sqos_no_token(), and test_no_sqos_revert().

◆ make_impersonation_token()

static HANDLE make_impersonation_token ( DWORD  Access,
SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel 
)
static

Definition at line 1876 of file pipe.c.

1877 {
1878  HANDLE ProcessToken;
1879  HANDLE Token = NULL;
1880  BOOL ret;
1881 
1883  ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
1884 
1885  ret = pDuplicateTokenEx(ProcessToken, Access, NULL, ImpersonationLevel, TokenImpersonation, &Token);
1886  ok(ret, "DuplicateToken failed with error %d\n", GetLastError());
1887 
1888  CloseHandle(ProcessToken);
1889 
1890  return Token;
1891 }
#define CloseHandle
Definition: compat.h:487
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Out_ PBOOLEAN _Out_ PBOOLEAN _Out_ PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: psfuncs.h:154
#define TOKEN_DUPLICATE
Definition: setypes.h:872
int ret
#define GetCurrentProcess()
Definition: compat.h:507
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296

Referenced by test_impersonation().

◆ named_pipe_client_func()

static DWORD CALLBACK named_pipe_client_func ( LPVOID  p)
static

Definition at line 1786 of file pipe.c.

1787 {
1788  struct named_pipe_client_params *params = p;
1789  HANDLE pipe;
1790  BOOL ret;
1791  const char message[] = "Test";
1792  DWORD bytes_read, bytes_written;
1793  char dummy;
1795 
1796  if (params->token)
1797  {
1798  if (params->revert)
1799  {
1800  /* modify the token so we can tell if the pipe impersonation
1801  * token reverts to the process token */
1802  ret = AdjustTokenPrivileges(params->token, TRUE, NULL, 0, NULL, NULL);
1803  ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
1804  }
1805  ret = SetThreadToken(NULL, params->token);
1806  ok(ret, "SetThreadToken failed with error %d\n", GetLastError());
1807  }
1808  else
1809  {
1810  DWORD Size = 0;
1811  HANDLE process_token;
1812 
1814  ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
1815 
1816  ret = GetTokenInformation(process_token, TokenPrivileges, NULL, 0, &Size);
1817  ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetTokenInformation(TokenPrivileges) failed with %d\n", GetLastError());
1820  ok(ret, "GetTokenInformation(TokenPrivileges) failed with %d\n", GetLastError());
1821 
1822  ret = AdjustTokenPrivileges(process_token, TRUE, NULL, 0, NULL, NULL);
1823  ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
1824 
1825  CloseHandle(process_token);
1826  }
1827 
1828  pipe = CreateFileA(PIPE_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, params->security_flags, NULL);
1829  ok(pipe != INVALID_HANDLE_VALUE, "CreateFile for pipe failed with error %d\n", GetLastError());
1830 
1831  ret = WriteFile(pipe, message, sizeof(message), &bytes_written, NULL);
1832  ok(ret, "WriteFile failed with error %d\n", GetLastError());
1833 
1834  ret = ReadFile(pipe, &dummy, sizeof(dummy), &bytes_read, NULL);
1835  ok(ret, "ReadFile failed with error %d\n", GetLastError());
1836 
1837  if (params->token)
1838  {
1839  if (params->revert)
1840  {
1841  ret = RevertToSelf();
1842  ok(ret, "RevertToSelf failed with error %d\n", GetLastError());
1843  }
1844  else
1845  {
1846  ret = AdjustTokenPrivileges(params->token, TRUE, NULL, 0, NULL, NULL);
1847  ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
1848  }
1849  }
1850  else
1851  {
1852  HANDLE process_token;
1853 
1855  ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
1856 
1857  ret = AdjustTokenPrivileges(process_token, FALSE, Privileges, 0, NULL, NULL);
1858  ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
1859 
1861 
1862  CloseHandle(process_token);
1863  }
1864 
1865  ret = WriteFile(pipe, message, sizeof(message), &bytes_written, NULL);
1866  ok(ret, "WriteFile failed with error %d\n", GetLastError());
1867 
1868  ret = ReadFile(pipe, &dummy, sizeof(dummy), &bytes_read, NULL);
1869  ok(ret, "ReadFile failed with error %d\n", GetLastError());
1870 
1871  CloseHandle(pipe);
1872 
1873  return 0;
1874 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
Definition: tftpd.h:59
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define PIPE_NAME
Definition: pipe.c:1784
BOOL WINAPI SetThreadToken(IN PHANDLE ThreadHandle OPTIONAL, IN HANDLE TokenHandle)
Definition: security.c:463
#define FALSE
Definition: types.h:117
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET * Privileges
Definition: sefuncs.h:13
int ret
#define GetCurrentProcess()
Definition: compat.h:507
#define GENERIC_READ
Definition: compat.h:135
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
unsigned char dummy
Definition: maze.c:118
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:488
GLfloat GLfloat p
Definition: glext.h:8902
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
#define HeapFree(x, y, z)
Definition: compat.h:483
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by test_ImpersonateNamedPipeClient().

◆ overlapped_server()

static DWORD CALLBACK overlapped_server ( LPVOID  arg)
static

Definition at line 2228 of file pipe.c.

2229 {
2230  OVERLAPPED ol;
2231  HANDLE pipe;
2232  int ret, err;
2233  struct overlapped_server_args *a = arg;
2234  DWORD num;
2235  char buf[100];
2236 
2237  pipe = CreateNamedPipeA("\\\\.\\pipe\\my pipe", FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1, 0, 0, 100000, NULL);
2238  ok(pipe != NULL, "pipe NULL\n");
2239 
2240  ol.hEvent = CreateEventA(0, 1, 0, 0);
2241  ok(ol.hEvent != NULL, "event NULL\n");
2242  ret = ConnectNamedPipe(pipe, &ol);
2243  err = GetLastError();
2244  ok(ret == 0, "ret %d\n", ret);
2245  ok(err == ERROR_IO_PENDING, "gle %d\n", err);
2246  SetEvent(a->pipe_created);
2247 
2249  ok(ret == WAIT_OBJECT_0, "ret %x\n", ret);
2250 
2251  ret = GetOverlappedResult(pipe, &ol, &num, 1);
2252  ok(ret == 1, "ret %d\n", ret);
2253 
2254  /* This should block */
2255  ret = ReadFile(pipe, buf, sizeof(buf), &num, NULL);
2256  ok(ret == 1, "ret %d\n", ret);
2257 
2258  DisconnectNamedPipe(pipe);
2259 
2260  ret = ConnectNamedPipe(pipe, &ol);
2261  err = GetLastError();
2262  ok(ret == 0, "ret %d\n", ret);
2263  ok(err == ERROR_IO_PENDING, "gle %d\n", err);
2264  CancelIo(pipe);
2266  ok(ret == WAIT_OBJECT_0, "ret %x\n", ret);
2267 
2268  ret = GetOverlappedResult(pipe, &ol, &num, 1);
2269  err = GetLastError();
2270  ok(ret == 0, "ret %d\n", ret);
2271  ok(err == ERROR_OPERATION_ABORTED, "gle %d\n", err);
2272 
2273  CloseHandle(ol.hEvent);
2274  CloseHandle(pipe);
2275  return 1;
2276 }
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define CloseHandle
Definition: compat.h:487
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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 DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
void * arg
Definition: msvc.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575
HANDLE hEvent
Definition: winbase.h:798
BOOL WINAPI CancelIo(IN HANDLE hFile)
Definition: deviceio.c:290
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
int ret
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
#define err(...)
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define INFINITE
Definition: serial.h:102
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701

Referenced by test_overlapped().

◆ RpcReadFile()

static BOOL RpcReadFile ( HANDLE  hFile,
LPVOID  buffer,
DWORD  bytesToRead,
LPDWORD  bytesRead,
LPOVERLAPPED  overlapped 
)
static

Definition at line 91 of file pipe.c.

92 {
93  struct rpcThreadArgs rpcargs;
94  HANDLE thread;
95  DWORD threadId, ret;
96 
97  rpcargs.returnValue = 0;
98  rpcargs.lastError = GetLastError();
99  rpcargs.op = RPC_READFILE;
100  rpcargs.args[0] = (ULONG_PTR)hFile;
101  rpcargs.args[1] = (ULONG_PTR)buffer;
102  rpcargs.args[2] = (ULONG_PTR)bytesToRead;
103  rpcargs.args[3] = (ULONG_PTR)bytesRead;
104  rpcargs.args[4] = (ULONG_PTR)overlapped;
105 
106  thread = CreateThread(NULL, 0, rpcThreadMain, (void *)&rpcargs, 0, &threadId);
107  ok(thread != NULL, "CreateThread failed. %d\n", GetLastError());
109  ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed with %d.\n", GetLastError());
111 
112  SetLastError(rpcargs.lastError);
113  return (BOOL)rpcargs.returnValue;
114 }
#define CloseHandle
Definition: compat.h:487
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
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:136
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
int ret
_In_ HANDLE hFile
Definition: mswsock.h:90
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
#define ok(value,...)
Definition: atltest.h:57
static DWORD WINAPI thread(PVOID main_thread)
Definition: pipe.c:413
#define ULONG_PTR
Definition: config.h:101
#define INFINITE
Definition: serial.h:102
static DWORD CALLBACK rpcThreadMain(LPVOID arg)
Definition: pipe.c:63

Referenced by test_CreateNamedPipe().

◆ rpcThreadMain()

static DWORD CALLBACK rpcThreadMain ( LPVOID  arg)
static

Definition at line 63 of file pipe.c.

64 {
65  struct rpcThreadArgs *rpcargs = (struct rpcThreadArgs *)arg;
66  if (winetest_debug > 1) trace("rpcThreadMain starting\n");
67  SetLastError( rpcargs->lastError );
68 
69  switch (rpcargs->op)
70  {
71  case RPC_READFILE:
72  rpcargs->returnValue = (ULONG_PTR)ReadFile( (HANDLE)rpcargs->args[0], /* hFile */
73  (LPVOID)rpcargs->args[1], /* buffer */
74  (DWORD)rpcargs->args[2], /* bytesToRead */
75  (LPDWORD)rpcargs->args[3], /* bytesRead */
76  (LPOVERLAPPED)rpcargs->args[4] ); /* overlapped */
77  break;
78 
79  default:
81  rpcargs->returnValue = 0;
82  break;
83  }
84 
85  rpcargs->lastError = GetLastError();
86  if (winetest_debug > 1) trace("rpcThreadMain returning\n");
87  return 0;
88 }
DWORD lastError
Definition: pipe.c:58
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
int winetest_debug
ULONG_PTR args[5]
Definition: pipe.c:60
enum rpcThreadOp op
Definition: pipe.c:59
ULONG_PTR returnValue
Definition: pipe.c:57
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
#define LPVOID
Definition: nt_native.h:45
#define LPDWORD
Definition: nt_native.h:46
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ULONG_PTR
Definition: config.h:101

Referenced by RpcReadFile().

◆ serverThreadMain1()

static DWORD CALLBACK serverThreadMain1 ( LPVOID  arg)
static

Trivial byte echo server - disconnects after each session

Definition at line 799 of file pipe.c.

800 {
801  int i;
802 
803  if (winetest_debug > 1) trace("serverThreadMain1 start\n");
804  /* Set up a simple echo server */
805  hnp = CreateNamedPipeA(PIPENAME "serverThreadMain1", PIPE_ACCESS_DUPLEX,
807  /* nMaxInstances */ 1,
808  /* nOutBufSize */ 1024,
809  /* nInBufSize */ 1024,
810  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
811  /* lpSecurityAttrib */ NULL);
812 
813  ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
814  for (i = 0; i < NB_SERVER_LOOPS; i++) {
815  char buf[512];
816  DWORD written;
817  DWORD readden;
818  BOOL success;
819 
820  /* Wait for client to connect */
821  if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n");
823  || GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n");
824  if (winetest_debug > 1) trace("ConnectNamedPipe returned.\n");
825 
826  /* Echo bytes once */
827  memset(buf, 0, sizeof(buf));
828 
829  if (winetest_debug > 1) trace("Server reading...\n");
830  success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
831  if (winetest_debug > 1) trace("Server done reading.\n");
832  ok(success, "ReadFile\n");
833  ok(readden, "short read\n");
834 
835  if (winetest_debug > 1) trace("Server writing...\n");
836  ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n");
837  if (winetest_debug > 1) trace("Server done writing.\n");
838  ok(written == readden, "write file len\n");
839 
840  /* finish this connection, wait for next one */
841  ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
842  if (winetest_debug > 1) trace("Server done flushing.\n");
843  ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
844  if (winetest_debug > 1) trace("Server done disconnecting.\n");
845  }
846  return 0;
847 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define NB_SERVER_LOOPS
Definition: pipe.c:35
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
static HANDLE hnp
Definition: pipe.c:796
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
int winetest_debug
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define trace
Definition: atltest.h:70
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
unsigned long DWORD
Definition: ntddk_ex.h:95
#define success(from, fromstr, to, tostr)
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701

Referenced by test_NamedPipe_2().

◆ serverThreadMain2()

static DWORD CALLBACK serverThreadMain2 ( LPVOID  arg)
static

Trivial byte echo server - closes after each connection

Definition at line 850 of file pipe.c.

851 {
852  int i;
853  HANDLE hnpNext = 0;
854 
855  trace("serverThreadMain2\n");
856  /* Set up a simple echo server */
857  hnp = CreateNamedPipeA(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
859  /* nMaxInstances */ 2,
860  /* nOutBufSize */ 1024,
861  /* nInBufSize */ 1024,
862  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
863  /* lpSecurityAttrib */ NULL);
864  ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
865 
866  for (i = 0; i < NB_SERVER_LOOPS; i++) {
867  char buf[512];
868  DWORD written;
869  DWORD readden;
870  DWORD ret;
871  BOOL success;
872 
873 
875  if (i == 0 && pQueueUserAPC) {
876  if (winetest_debug > 1) trace("Queueing an user APC\n"); /* verify the pipe is non alerable */
877  ret = pQueueUserAPC(&user_apc, GetCurrentThread(), 0);
878  ok(ret, "QueueUserAPC failed: %d\n", GetLastError());
879  }
880 
881  /* Wait for client to connect */
882  if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n");
884  || GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe\n");
885  if (winetest_debug > 1) trace("ConnectNamedPipe returned.\n");
886 
887  /* Echo bytes once */
888  memset(buf, 0, sizeof(buf));
889 
890  if (winetest_debug > 1) trace("Server reading...\n");
891  success = ReadFile(hnp, buf, sizeof(buf), &readden, NULL);
892  if (winetest_debug > 1) trace("Server done reading.\n");
893  ok(success, "ReadFile\n");
894 
895  if (winetest_debug > 1) trace("Server writing...\n");
896  ok(WriteFile(hnp, buf, readden, &written, NULL), "WriteFile\n");
897  if (winetest_debug > 1) trace("Server done writing.\n");
898  ok(written == readden, "write file len\n");
899 
900  /* finish this connection, wait for next one */
901  ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
902  ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
903 
904  ok(user_apc_ran == FALSE, "UserAPC ran, pipe using alertable io mode\n");
905 
906  if (i == 0 && pQueueUserAPC)
907  SleepEx(0, TRUE); /* get rid of apc */
908 
909  /* Set up next echo server */
910  hnpNext =
911  CreateNamedPipeA(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
913  /* nMaxInstances */ 2,
914  /* nOutBufSize */ 1024,
915  /* nInBufSize */ 1024,
916  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
917  /* lpSecurityAttrib */ NULL);
918 
919  ok(hnpNext != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
920 
921  ok(CloseHandle(hnp), "CloseHandle\n");
922  hnp = hnpNext;
923  }
924  return 0;
925 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:487
#define NB_SERVER_LOOPS
Definition: pipe.c:35
static BOOL user_apc_ran
Definition: pipe.c:43
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
static HANDLE hnp
Definition: pipe.c:796
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
int winetest_debug
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
#define FALSE
Definition: types.h:117
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define trace
Definition: atltest.h:70
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
unsigned long DWORD
Definition: ntddk_ex.h:95
#define success(from, fromstr, to, tostr)
int ret
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
static void CALLBACK user_apc(ULONG_PTR param)
Definition: pipe.c:44
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701

Referenced by test_NamedPipe_2().

◆ serverThreadMain3()

static DWORD CALLBACK serverThreadMain3 ( LPVOID  arg)
static

Trivial byte echo server - uses overlapped named pipe calls

Definition at line 928 of file pipe.c.

929 {
930  int i;
931  HANDLE hEvent;
932 
933  if (winetest_debug > 1) trace("serverThreadMain3\n");
934  /* Set up a simple echo server */
937  /* nMaxInstances */ 1,
938  /* nOutBufSize */ 1024,
939  /* nInBufSize */ 1024,
940  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
941  /* lpSecurityAttrib */ NULL);
942  ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
943 
944  hEvent = CreateEventW(NULL, /* security attribute */
945  TRUE, /* manual reset event */
946  FALSE, /* initial state */
947  NULL); /* name */
948  ok(hEvent != NULL, "CreateEvent\n");
949 
950  for (i = 0; i < NB_SERVER_LOOPS; i++) {
951  char buf[512];
952  DWORD written;
953  DWORD readden;
954  DWORD dummy;
955  BOOL success;
956  OVERLAPPED oOverlap;
957  int letWFSOEwait = (i & 2);
958  int letGORwait = (i & 1);
959  DWORD err;
960 
961  memset(&oOverlap, 0, sizeof(oOverlap));
962  oOverlap.hEvent = hEvent;
963 
964  /* Wait for client to connect */
965  if (i == 0) {
966  if (winetest_debug > 1) trace("Server calling non-overlapped ConnectNamedPipe on overlapped pipe...\n");
968  err = GetLastError();
969  ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %d\n", err);
970  if (winetest_debug > 1) trace("ConnectNamedPipe operation complete.\n");
971  } else {
972  if (winetest_debug > 1) trace("Server calling overlapped ConnectNamedPipe...\n");
973  success = ConnectNamedPipe(hnp, &oOverlap);
974  err = GetLastError();
975  ok(!success && (err == ERROR_IO_PENDING || err == ERROR_PIPE_CONNECTED), "overlapped ConnectNamedPipe\n");
976  if (winetest_debug > 1) trace("overlapped ConnectNamedPipe returned.\n");
977  if (!success && (err == ERROR_IO_PENDING)) {
978  if (letWFSOEwait)
979  {
980  DWORD ret;
981  do {
983  } while (ret == WAIT_IO_COMPLETION);
984  ok(ret == 0, "wait ConnectNamedPipe returned %x\n", ret);
985  }
986  success = GetOverlappedResult(hnp, &oOverlap, &dummy, letGORwait);
987  if (!letGORwait && !letWFSOEwait && !success) {
988  ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
989  success = GetOverlappedResult(hnp, &oOverlap, &dummy, TRUE);
990  }
991  }
992  ok(success || (err == ERROR_PIPE_CONNECTED), "GetOverlappedResult ConnectNamedPipe\n");
993  if (winetest_debug > 1) trace("overlapped ConnectNamedPipe operation complete.\n");
994  }
995 
996  /* Echo bytes once */
997  memset(buf, 0, sizeof(buf));
998 
999  if (winetest_debug > 1) trace("Server reading...\n");
1000  success = ReadFile(hnp, buf, sizeof(buf), &readden, &oOverlap);
1001  if (winetest_debug > 1) trace("Server ReadFile returned...\n");
1002  err = GetLastError();
1003  ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile\n");
1004  if (winetest_debug > 1) trace("overlapped ReadFile returned.\n");
1005  if (!success && (err == ERROR_IO_PENDING)) {
1006  if (letWFSOEwait)
1007  {
1008  DWORD ret;
1009  do {
1011  } while (ret == WAIT_IO_COMPLETION);
1012  ok(ret == 0, "wait ReadFile returned %x\n", ret);
1013  }
1014  success = GetOverlappedResult(hnp, &oOverlap, &readden, letGORwait);
1015  if (!letGORwait && !letWFSOEwait && !success) {
1016  ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
1017  success = GetOverlappedResult(hnp, &oOverlap, &readden, TRUE);
1018  }
1019  }
1020  if (winetest_debug > 1) trace("Server done reading.\n");
1021  ok(success, "overlapped ReadFile\n");
1022 
1023  if (winetest_debug > 1) trace("Server writing...\n");
1024  success = WriteFile(hnp, buf, readden, &written, &oOverlap);
1025  if (winetest_debug > 1) trace("Server WriteFile returned...\n");
1026  err = GetLastError();
1027  ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile\n");
1028  if (winetest_debug > 1) trace("overlapped WriteFile returned.\n");
1029  if (!success && (err == ERROR_IO_PENDING)) {
1030  if (letWFSOEwait)
1031  {
1032  DWORD ret;
1033  do {
1035  } while (ret == WAIT_IO_COMPLETION);
1036  ok(ret == 0, "wait WriteFile returned %x\n", ret);
1037  }
1038  success = GetOverlappedResult(hnp, &oOverlap, &written, letGORwait);
1039  if (!letGORwait && !letWFSOEwait && !success) {
1040  ok(GetLastError() == ERROR_IO_INCOMPLETE, "GetOverlappedResult\n");
1041  success = GetOverlappedResult(hnp, &oOverlap, &written, TRUE);
1042  }
1043  }
1044  if (winetest_debug > 1) trace("Server done writing.\n");
1045  ok(success, "overlapped WriteFile\n");
1046  ok(written == readden, "write file len\n");
1047 
1048  /* finish this connection, wait for next one */
1049  ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
1050  ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
1051  }
1052  return 0;
1053 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define NB_SERVER_LOOPS
Definition: pipe.c:35
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
static HANDLE hnp
Definition: pipe.c:796
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define ERROR_IO_PENDING
Definition: dderror.h:15
int winetest_debug
#define ERROR_IO_INCOMPLETE
Definition: winerror.h:576
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static HANDLE hEvent
Definition: comm.c:54
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
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
HANDLE hEvent
Definition: winbase.h:798
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_IO_COMPLETION
Definition: winbase.h:392
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define trace
Definition: atltest.h:70
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
unsigned long DWORD
Definition: ntddk_ex.h:95
#define success(from, fromstr, to, tostr)
int ret
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
#define err(...)
unsigned char dummy
Definition: maze.c:118
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define INFINITE
Definition: serial.h:102
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701

Referenced by test_NamedPipe_2().

◆ serverThreadMain4()

static DWORD CALLBACK serverThreadMain4 ( LPVOID  arg)
static

Trivial byte echo server - uses i/o completion ports

Definition at line 1056 of file pipe.c.

1057 {
1058  int i;
1059  HANDLE hcompletion;
1060  BOOL ret;
1061 
1062  if (winetest_debug > 1) trace("serverThreadMain4\n");
1063  /* Set up a simple echo server */
1066  /* nMaxInstances */ 1,
1067  /* nOutBufSize */ 1024,
1068  /* nInBufSize */ 1024,
1069  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
1070  /* lpSecurityAttrib */ NULL);
1071  ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
1072 
1073  hcompletion = CreateIoCompletionPort(hnp, NULL, 12345, 1);
1074  ok(hcompletion != NULL, "CreateIoCompletionPort failed, error=%i\n", GetLastError());
1075 
1076  for (i = 0; i < NB_SERVER_LOOPS; i++) {
1077  char buf[512];
1078  DWORD written;
1079  DWORD readden;
1080  DWORD dummy;
1081  BOOL success;
1082  OVERLAPPED oConnect;
1083  OVERLAPPED oRead;
1084  OVERLAPPED oWrite;
1085  OVERLAPPED *oResult;
1086  DWORD err;
1087  ULONG_PTR compkey;
1088 
1089  memset(&oConnect, 0, sizeof(oConnect));
1090  memset(&oRead, 0, sizeof(oRead));
1091  memset(&oWrite, 0, sizeof(oWrite));
1092 
1093  /* Wait for client to connect */
1094  if (winetest_debug > 1) trace("Server calling overlapped ConnectNamedPipe...\n");
1095  success = ConnectNamedPipe(hnp, &oConnect);
1096  err = GetLastError();
1098  "overlapped ConnectNamedPipe got %u err %u\n", success, err );
1099  if (!success && err == ERROR_IO_PENDING) {
1100  if (winetest_debug > 1) trace("ConnectNamedPipe GetQueuedCompletionStatus\n");
1101  success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 0);
1102  if (!success)
1103  {
1105  "ConnectNamedPipe GetQueuedCompletionStatus wrong error %u\n", GetLastError());
1106  success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 10000);
1107  }
1108  ok(success, "ConnectNamedPipe GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
1109  if (success)
1110  {
1111  ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
1112  ok(oResult == &oConnect, "got overlapped pointer %p instead of %p\n", oResult, &oConnect);
1113  }
1114  }
1115  if (winetest_debug > 1) trace("overlapped ConnectNamedPipe operation complete.\n");
1116 
1117  /* Echo bytes once */
1118  memset(buf, 0, sizeof(buf));
1119 
1120  if (winetest_debug > 1) trace("Server reading...\n");
1121  success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead);
1122  if (winetest_debug > 1) trace("Server ReadFile returned...\n");
1123  err = GetLastError();
1124  ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile, err=%i\n", err);
1125  success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey,
1126  &oResult, 10000);
1127  ok(success, "ReadFile GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
1128  if (success)
1129  {
1130  ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
1131  ok(oResult == &oRead, "got overlapped pointer %p instead of %p\n", oResult, &oRead);
1132  }
1133  if (winetest_debug > 1) trace("Server done reading.\n");
1134 
1135  if (winetest_debug > 1) trace("Server writing...\n");
1136  success = WriteFile(hnp, buf, readden, &written, &oWrite);
1137  if (winetest_debug > 1) trace("Server WriteFile returned...\n");
1138  err = GetLastError();
1139  ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile failed, err=%u\n", err);
1140  success = GetQueuedCompletionStatus(hcompletion, &written, &compkey,
1141  &oResult, 10000);
1142  ok(success, "WriteFile GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
1143  if (success)
1144  {
1145  ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
1146  ok(oResult == &oWrite, "got overlapped pointer %p instead of %p\n", oResult, &oWrite);
1147  ok(written == readden, "write file len\n");
1148  }
1149  if (winetest_debug > 1) trace("Server done writing.\n");
1150 
1151  /* Client will finish this connection, the following ops will trigger broken pipe errors. */
1152 
1153  /* Wait for the pipe to break. */
1154  while (PeekNamedPipe(hnp, NULL, 0, NULL, &written, &written));
1155 
1156  if (winetest_debug > 1) trace("Server writing on disconnected pipe...\n");
1158  success = WriteFile(hnp, buf, readden, &written, &oWrite);
1159  err = GetLastError();
1161  "overlapped WriteFile on disconnected pipe returned %u, err=%i\n", success, err);
1162 
1163  /* No completion status is queued on immediate error. */
1165  oResult = (OVERLAPPED *)0xdeadbeef;
1166  success = GetQueuedCompletionStatus(hcompletion, &written, &compkey,
1167  &oResult, 0);
1168  err = GetLastError();
1169  ok(!success && err == WAIT_TIMEOUT && !oResult,
1170  "WriteFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n",
1171  success, err, oResult);
1172 
1173  if (winetest_debug > 1) trace("Server reading from disconnected pipe...\n");
1175  success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead);
1176  if (winetest_debug > 1) trace("Server ReadFile from disconnected pipe returned...\n");
1177  err = GetLastError();
1179  "overlapped ReadFile on disconnected pipe returned %u, err=%i\n", success, err);
1180 
1182  oResult = (OVERLAPPED *)0xdeadbeef;
1183  success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey,
1184  &oResult, 0);
1185  err = GetLastError();
1186  ok(!success && err == WAIT_TIMEOUT && !oResult,
1187  "ReadFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n",
1188  success, err, oResult);
1189 
1190  /* finish this connection, wait for next one */
1191  ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
1193  ok(success, "DisconnectNamedPipe failed, err %u\n", GetLastError());
1194  }
1195 
1196  ret = CloseHandle(hnp);
1197  ok(ret, "CloseHandle named pipe failed, err=%i\n", GetLastError());
1198  ret = CloseHandle(hcompletion);
1199  ok(ret, "CloseHandle completion failed, err=%i\n", GetLastError());
1200 
1201  return 0;
1202 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:487
#define NB_SERVER_LOOPS
Definition: pipe.c:35
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
static HANDLE hnp
Definition: pipe.c:796
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define ERROR_IO_PENDING
Definition: dderror.h:15
int winetest_debug
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:163
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define trace
Definition: atltest.h:70
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
#define ERROR_NO_DATA
Definition: winerror.h:284
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_PIPE_NOT_CONNECTED
Definition: winerror.h:285
#define ERROR_BROKEN_PIPE
Definition: winerror.h:183
#define success(from, fromstr, to, tostr)
#define SetLastError(x)
Definition: compat.h:500
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
#define err(...)
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:48
unsigned char dummy
Definition: maze.c:118
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701
BOOL WINAPI PeekNamedPipe(HANDLE hNamedPipe, LPVOID lpBuffer, DWORD nBufferSize, LPDWORD lpBytesRead, LPDWORD lpTotalBytesAvail, LPDWORD lpBytesLeftThisMessage)
Definition: npipe.c:1214

Referenced by test_NamedPipe_2().

◆ serverThreadMain5()

static DWORD CALLBACK serverThreadMain5 ( LPVOID  arg)
static

Trivial byte echo server - uses ReadFileEx/WriteFileEx

Definition at line 1219 of file pipe.c.

1220 {
1221  int i;
1222  HANDLE hEvent;
1223 
1224  if (winetest_debug > 1) trace("serverThreadMain5\n");
1225  /* Set up a simple echo server */
1228  /* nMaxInstances */ 1,
1229  /* nOutBufSize */ 1024,
1230  /* nInBufSize */ 1024,
1231  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
1232  /* lpSecurityAttrib */ NULL);
1233  ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
1234 
1235  hEvent = CreateEventW(NULL, /* security attribute */
1236  TRUE, /* manual reset event */
1237  FALSE, /* initial state */
1238  NULL); /* name */
1239  ok(hEvent != NULL, "CreateEvent\n");
1240 
1241  for (i = 0; i < NB_SERVER_LOOPS; i++) {
1242  char buf[512];
1243  DWORD readden;
1244  BOOL success;
1245  OVERLAPPED oOverlap;
1246  DWORD err;
1247 
1248  memset(&oOverlap, 0, sizeof(oOverlap));
1249  oOverlap.hEvent = hEvent;
1250 
1251  /* Wait for client to connect */
1252  if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n");
1254  err = GetLastError();
1255  ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %d\n", err);
1256  if (winetest_debug > 1) trace("ConnectNamedPipe operation complete.\n");
1257 
1258  /* Echo bytes once */
1259  memset(buf, 0, sizeof(buf));
1260 
1261  if (winetest_debug > 1) trace("Server reading...\n");
1262  completion_called = 0;
1263  ResetEvent(hEvent);
1264  success = ReadFileEx(hnp, buf, sizeof(buf), &oOverlap, completion_routine);
1265  if (winetest_debug > 1) trace("Server ReadFileEx returned...\n");
1266  ok(success, "ReadFileEx failed, err=%i\n", GetLastError());
1267  ok(completion_called == 0, "completion routine called before ReadFileEx return\n");
1268  if (winetest_debug > 1) trace("ReadFileEx returned.\n");
1269  if (success) {
1270  DWORD ret;
1271  do {
1273  } while (ret == WAIT_IO_COMPLETION);
1274  ok(ret == 0, "wait ReadFileEx returned %x\n", ret);
1275  }
1276  ok(completion_called == 1, "completion routine called %i times\n", completion_called);
1277  ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %d\n", completion_errorcode);
1278  ok(completion_num_bytes != 0, "read 0 bytes\n");
1279  ok(completion_lpoverlapped == &oOverlap, "got wrong overlapped pointer %p\n", completion_lpoverlapped);
1280  readden = completion_num_bytes;
1281  if (winetest_debug > 1) trace("Server done reading.\n");
1282 
1283  if (winetest_debug > 1) trace("Server writing...\n");
1284  completion_called = 0;
1285  ResetEvent(hEvent);
1286  success = WriteFileEx(hnp, buf, readden, &oOverlap, completion_routine);
1287  if (winetest_debug > 1) trace("Server WriteFileEx returned...\n");
1288  ok(success, "WriteFileEx failed, err=%i\n", GetLastError());
1289  ok(completion_called == 0, "completion routine called before ReadFileEx return\n");
1290  if (winetest_debug > 1) trace("overlapped WriteFile returned.\n");
1291  if (success) {
1292  DWORD ret;
1293  do {
1295  } while (ret == WAIT_IO_COMPLETION);
1296  ok(ret == 0, "wait WriteFileEx returned %x\n", ret);
1297  }
1298  if (winetest_debug > 1) trace("Server done writing.\n");
1299  ok(completion_called == 1, "completion routine called %i times\n", completion_called);
1300  ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %d\n", completion_errorcode);
1301  ok(completion_num_bytes == readden, "read %i bytes wrote %i\n", readden, completion_num_bytes);
1302  ok(completion_lpoverlapped == &oOverlap, "got wrong overlapped pointer %p\n", completion_lpoverlapped);
1303 
1304  /* finish this connection, wait for next one */
1305  ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
1306  ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
1307  }
1308  return 0;
1309 }
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define NB_SERVER_LOOPS
Definition: pipe.c:35
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
static HANDLE hnp
Definition: pipe.c:796
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
int winetest_debug
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static HANDLE hEvent
Definition: comm.c:54
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
BOOL WINAPI ReadFileEx(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: rw.c:299
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
HANDLE hEvent
Definition: winbase.h:798
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_IO_COMPLETION
Definition: winbase.h:392
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
#define trace
Definition: atltest.h:70
static DWORD completion_num_bytes
Definition: pipe.c:1206
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
static LPOVERLAPPED completion_lpoverlapped
Definition: pipe.c:1207
static int completion_called
Definition: pipe.c:1204
unsigned long DWORD
Definition: ntddk_ex.h:95
#define success(from, fromstr, to, tostr)
int ret
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
#define err(...)
static VOID WINAPI completion_routine(DWORD errorcode, DWORD num_bytes, LPOVERLAPPED lpoverlapped)
Definition: pipe.c:1209
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
static DWORD completion_errorcode
Definition: pipe.c:1205
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define INFINITE
Definition: serial.h:102
BOOL WINAPI WriteFileEx(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: rw.c:262
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701

Referenced by test_NamedPipe_2().

◆ START_TEST()

START_TEST ( pipe  )

Definition at line 3162 of file pipe.c.

3163 {
3164  char **argv;
3165  int argc;
3166  HMODULE hmod;
3167 
3168  hmod = GetModuleHandleA("advapi32.dll");
3169  pDuplicateTokenEx = (void *) GetProcAddress(hmod, "DuplicateTokenEx");
3170  hmod = GetModuleHandleA("kernel32.dll");
3171  pQueueUserAPC = (void *) GetProcAddress(hmod, "QueueUserAPC");
3172  pCancelIoEx = (void *) GetProcAddress(hmod, "CancelIoEx");
3173 
3175 
3176  if (argc > 3 && !strcmp(argv[2], "writepipe"))
3177  {
3178  UINT_PTR handle;
3179  sscanf(argv[3], "%lx", &handle);
3181  return;
3182  }
3183 
3185  return;
3187  test_NamedPipe_2();
3190  test_CreatePipe();
3191  test_ReadFile();
3192  test_CloseHandle();
3194  test_overlapped();
3202 }
static int argc
Definition: ServiceArgs.c:12
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
static void test_readfileex_pending(void)
Definition: pipe.c:2520
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168
#define TRUE
Definition: types.h:120
static void test_CreateNamedPipe(int pipemode)
Definition: pipe.c:145
static void test_CreatePipe(void)
Definition: pipe.c:1483
static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode)
Definition: pipe.c:3085
static void test_GetNamedPipeInfo(void)
Definition: pipe.c:2463
#define argv
Definition: mplay32.c:18
#define FALSE
Definition: types.h:117
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
static void child_process_write_pipe(HANDLE pipe)
Definition: pipe.c:3027
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
static int test_DisconnectNamedPipe(void)
Definition: pipe.c:1415
static void test_NamedPipe_2(void)
Definition: pipe.c:1361
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int winetest_get_mainargs(char ***pargv)
static void test_overlapped(void)
Definition: pipe.c:2278
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_CloseHandle(void)
Definition: pipe.c:1551
static void test_impersonation(void)
Definition: pipe.c:2164
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
static void test_NamedPipeHandleState(void)
Definition: pipe.c:2362
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static void test_overlapped_error(void)
Definition: pipe.c:2304
#define GetProcAddress(x, y)
Definition: compat.h:501
static void test_ReadFile(void)
Definition: pipe.c:729
static void test_CreateNamedPipe_instances_must_match(void)
Definition: pipe.c:644

◆ test_blocking_rw()

static void test_blocking_rw ( HANDLE  writer,
HANDLE  reader,
DWORD  buf_size,
BOOL  msg_mode,
BOOL  msg_read 
)
static

Definition at line 2885 of file pipe.c.

2886 {
2887  OVERLAPPED read_overlapped, read_overlapped2, write_overlapped, write_overlapped2;
2888  char buf[10000], read_buf[10000];
2889  HANDLE flush_thread;
2890 
2891  memset(buf, 0xaa, sizeof(buf));
2892 
2893  /* test pending read with overlapped event */
2894  overlapped_read_async(reader, read_buf, 1000, &read_overlapped);
2895  test_flush_sync(writer);
2896  test_peek_pipe(reader, 0, 0, 0);
2897 
2898  /* write more data than needed for read */
2899  overlapped_write_sync(writer, buf, 4000);
2900  test_overlapped_result(reader, &read_overlapped, 1000, msg_read);
2901 
2902  /* test pending write with overlapped event */
2903  overlapped_write_async(writer, buf, buf_size, &write_overlapped);
2904 
2905  /* write one more byte */
2906  overlapped_write_async(writer, buf, 1, &write_overlapped2);
2907  flush_thread = test_flush_async(writer, ERROR_SUCCESS);
2908  test_not_signaled(write_overlapped.hEvent);
2909 
2910  /* empty write will not block */
2911  overlapped_write_sync(writer, buf, 0);
2912  test_not_signaled(write_overlapped.hEvent);
2913  test_not_signaled(write_overlapped2.hEvent);
2914 
2915  /* read remaining data from the first write */
2916  overlapped_read_sync(reader, read_buf, 3000, 3000, FALSE);
2917  test_overlapped_result(writer, &write_overlapped, buf_size, FALSE);
2918  test_not_signaled(write_overlapped2.hEvent);
2919  test_not_signaled(flush_thread);
2920 
2921  /* read one byte so that the next write fits the buffer */
2922  overlapped_read_sync(reader, read_buf, 1, 1, msg_read);
2923  test_overlapped_result(writer, &write_overlapped2, 1, FALSE);
2924 
2925  /* read the whole buffer */
2926  overlapped_read_sync(reader, read_buf, buf_size, buf_size-msg_read, FALSE);
2927 
2928  if(msg_read)
2930 
2931  if(msg_mode) {
2932  /* we still have an empty message in queue */
2934  }
2935  test_flush_done(flush_thread);
2936 
2937  /* pipe is empty, the next read will block */
2938  overlapped_read_async(reader, read_buf, 0, &read_overlapped);
2939  overlapped_read_async(reader, read_buf, 1000, &read_overlapped2);
2940 
2941  /* write one byte */
2942  overlapped_write_sync(writer, buf, 1);
2943  test_overlapped_result(reader, &read_overlapped, 0, msg_read);
2944  test_overlapped_result(reader, &read_overlapped2, 1, FALSE);
2945 
2946  /* write a message larger than buffer */
2947  overlapped_write_async(writer, buf, buf_size+2000, &write_overlapped);
2948 
2949  /* read so that pending write is still larger than the buffer */
2950  overlapped_read_sync(reader, read_buf, 1999, 1999, msg_read);
2951  test_not_signaled(write_overlapped.hEvent);
2952 
2953  /* read one more byte */
2954  overlapped_read_sync(reader, read_buf, 1, 1, msg_read);
2955  test_overlapped_result(writer, &write_overlapped, buf_size+2000, FALSE);
2956 
2957  /* read remaining data */
2958  overlapped_read_sync(reader, read_buf, buf_size+1, buf_size, FALSE);
2959 
2960  /* simple pass of empty message */
2961  overlapped_write_sync(writer, buf, 0);
2962  if(msg_mode)
2964 
2965  /* pipe is empty, the next read will block */
2966  test_flush_sync(writer);
2967  overlapped_read_async(reader, read_buf, 0, &read_overlapped);
2968  overlapped_read_async(reader, read_buf, 1, &read_overlapped2);
2969 
2970  /* 0 length write wakes one read in msg mode */
2971  overlapped_write_sync(writer, buf, 0);
2972  if(msg_mode)
2973  test_overlapped_result(reader, &read_overlapped, 0, FALSE);
2974  else
2975  test_not_signaled(read_overlapped.hEvent);
2976  test_not_signaled(read_overlapped2.hEvent);
2977  overlapped_write_sync(writer, buf, 1);
2978  test_overlapped_result(reader, &read_overlapped2, 1, FALSE);
2979 
2980  overlapped_write_sync(writer, buf, 20);
2981  test_peek_pipe(reader, 20, 20, msg_mode ? 20 : 0);
2982  overlapped_write_sync(writer, buf, 15);
2983  test_peek_pipe(reader, msg_mode ? 20 : 35, 35, msg_mode ? 20 : 0);
2984  overlapped_read_sync(reader, read_buf, 10, 10, msg_read);
2985  test_peek_pipe(reader, msg_mode ? 10 : 25, 25, msg_mode ? 10 : 0);
2987  test_peek_pipe(reader, 15, 15, msg_mode ? 15 : 0);
2989 
2990  if(!pCancelIoEx) {
2991  win_skip("CancelIoEx not available\n");
2992  return;
2993  }
2994 
2995  /* add one more pending read, then cancel the first one */
2996  overlapped_read_async(reader, read_buf, 1, &read_overlapped);
2997  overlapped_read_async(reader, read_buf, 1, &read_overlapped2);
2998  cancel_overlapped(reader, &read_overlapped2);
2999  test_not_signaled(read_overlapped.hEvent);
3000  overlapped_write_sync(writer, buf, 1);
3001  test_overlapped_result(reader, &read_overlapped, 1, FALSE);
3002 
3003  /* make two async writes, cancel the first one and make sure that we read from the second one */
3004  overlapped_write_async(writer, buf, buf_size+2000, &write_overlapped);
3005  overlapped_write_async(writer, buf, 1, &write_overlapped2);
3006  cancel_overlapped(writer, &write_overlapped);
3008  test_overlapped_result(writer, &write_overlapped2, 1, FALSE);
3009 
3010  /* same as above, but parially read written data before canceling */
3011  overlapped_write_async(writer, buf, buf_size+2000, &write_overlapped);
3012  overlapped_write_async(writer, buf, 1, &write_overlapped2);
3013  overlapped_read_sync(reader, read_buf, 10, 10, msg_read);
3014  test_not_signaled(write_overlapped.hEvent);
3015  cancel_overlapped(writer, &write_overlapped);
3017  test_overlapped_result(writer, &write_overlapped2, 1, FALSE);
3018 
3019  /* empty queue by canceling write and make sure that flush is signaled */
3020  overlapped_write_async(writer, buf, buf_size+2000, &write_overlapped);
3021  flush_thread = test_flush_async(writer, ERROR_SUCCESS);
3022  test_not_signaled(flush_thread);
3023  cancel_overlapped(writer, &write_overlapped);
3024  test_flush_done(flush_thread);
3025 }
#define overlapped_read_sync(a, b, c, d, e)
Definition: pipe.c:2713
#define ERROR_SUCCESS
Definition: deptool.c:10
#define overlapped_read_async(a, b, c, d)
Definition: pipe.c:2743
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define overlapped_write_async(a, b, c, d)
Definition: pipe.c:2779
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.c:1167
#define FALSE
Definition: types.h:117
#define test_flush_async(a, b)
Definition: pipe.c:2819
#define test_overlapped_result(a, b, c, d)
Definition: pipe.c:2842
HANDLE hEvent
Definition: winbase.h:798
#define test_flush_done(a)
Definition: pipe.c:2834
#define cancel_overlapped(a, b)
Definition: pipe.c:2874
#define test_peek_pipe(a, b, c, d)
Definition: pipe.c:2677
Definition: reader.h:83
#define test_not_signaled(h)
Definition: pipe.c:116
#define test_flush_sync(a)
Definition: pipe.c:2796
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:149
#define overlapped_write_sync(a, b, c)
Definition: pipe.c:2758

Referenced by test_overlapped_transport().

◆ test_CloseHandle()

static void test_CloseHandle ( void  )
static

Definition at line 1551 of file pipe.c.

1552 {
1553  static const char testdata[] = "Hello World";
1554  DWORD state, numbytes;
1555  HANDLE hpipe, hfile;
1556  char buffer[32];
1557  BOOL ret;
1558 
1561  1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
1562  ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
1563 
1565  ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
1566 
1567  numbytes = 0xdeadbeef;
1568  ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL);
1569  ok(ret, "WriteFile failed with %u\n", GetLastError());
1570  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1571 
1572  numbytes = 0xdeadbeef;
1573  ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL);
1574  ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
1575  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1576 
1577  ret = CloseHandle(hpipe);
1578  ok(ret, "CloseHandle failed with %u\n", GetLastError());
1579 
1580  numbytes = 0xdeadbeef;
1581  memset(buffer, 0, sizeof(buffer));
1582  ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
1583  ok(ret, "ReadFile failed with %u\n", GetLastError());
1584  ok(numbytes == 0, "expected 0, got %u\n", numbytes);
1585 
1586  numbytes = 0xdeadbeef;
1587  ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL);
1588  ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
1589  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1590 
1591  numbytes = 0xdeadbeef;
1592  memset(buffer, 0, sizeof(buffer));
1593  ret = ReadFile(hfile, buffer, sizeof(buffer), &numbytes, NULL);
1594  ok(ret, "ReadFile failed with %u\n", GetLastError());
1595  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1596 
1597  ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
1598  ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
1600  ret = SetNamedPipeHandleState(hfile, &state, NULL, NULL);
1601  ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
1602 
1603  SetLastError(0xdeadbeef);
1604  ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
1605  ok(!ret, "ReadFile unexpectedly succeeded\n");
1606  ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
1607 
1608  numbytes = 0xdeadbeef;
1609  ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL);
1610  ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%u)\n",
1611  ret, GetLastError());
1612  ok(numbytes == 0xdeadbeef, "numbytes = %u\n", numbytes);
1613 
1614  SetLastError(0xdeadbeef);
1615  ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL);
1616  ok(!ret, "WriteFile unexpectedly succeeded\n");
1617  todo_wine ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
1618 
1619  CloseHandle(hfile);
1620 
1623  1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
1624  ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
1625 
1627  ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
1628 
1629  numbytes = 0xdeadbeef;
1630  ret = WriteFile(hpipe, testdata, 0, &numbytes, NULL);
1631  ok(ret, "WriteFile failed with %u\n", GetLastError());
1632  ok(numbytes == 0, "expected 0, got %u\n", numbytes);
1633 
1634  ret = CloseHandle(hpipe);
1635  ok(ret, "CloseHandle failed with %u\n", GetLastError());
1636 
1637  numbytes = 0xdeadbeef;
1638  memset(buffer, 0, sizeof(buffer));
1639  ret = ReadFile(hfile, buffer, sizeof(buffer), &numbytes, NULL);
1640  ok(ret, "ReadFile failed with %u\n", GetLastError());
1641  ok(numbytes == 0, "expected 0, got %u\n", numbytes);
1642 
1643  SetLastError(0xdeadbeef);
1644  ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
1645  ok(!ret, "ReadFile unexpectedly succeeded\n");
1646  ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
1647 
1648  ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
1649  ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
1651  ret = SetNamedPipeHandleState(hfile, &state, NULL, NULL);
1652  ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
1653 
1654  SetLastError(0xdeadbeef);
1655  ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
1656  ok(!ret, "ReadFile unexpectedly succeeded\n");
1657  ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
1658 
1659  SetLastError(0xdeadbeef);
1660  ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL);
1661  ok(!ret, "WriteFile unexpectedly succeeded\n");
1662  todo_wine ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
1663 
1664  CloseHandle(hfile);
1665 
1666  /* repeat test with hpipe <-> hfile swapped */
1667 
1670  1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
1671  ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
1672 
1674  ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
1675 
1676  numbytes = 0xdeadbeef;
1677  ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL);
1678  ok(ret, "WriteFile failed with %u\n", GetLastError());
1679  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1680 
1681  numbytes = 0xdeadbeef;
1682  ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL);
1683  ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
1684  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1685 
1686  ret = CloseHandle(hfile);
1687  ok(ret, "CloseHandle failed with %u\n", GetLastError());
1688 
1689  numbytes = 0xdeadbeef;
1690  memset(buffer, 0, sizeof(buffer));
1691  ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
1692  ok(ret || GetLastError() == ERROR_MORE_DATA /* >= Win 8 */,
1693  "ReadFile failed with %u\n", GetLastError());
1694  ok(numbytes == 0, "expected 0, got %u\n", numbytes);
1695 
1696  numbytes = 0xdeadbeef;
1697  ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL);
1698  ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
1699  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1700 
1701  numbytes = 0xdeadbeef;
1702  memset(buffer, 0, sizeof(buffer));
1703  ret = ReadFile(hpipe, buffer, sizeof(buffer), &numbytes, NULL);
1704  ok(ret, "ReadFile failed with %u\n", GetLastError());
1705  ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
1706 
1707  ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
1708  ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
1710  ret = SetNamedPipeHandleState(hpipe, &state, NULL, NULL);
1711  ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
1712 
1713  SetLastError(0xdeadbeef);
1714  ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
1715  ok(!ret, "ReadFile unexpectedly succeeded\n");
1716  ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
1717 
1718  numbytes = 0xdeadbeef;
1719  ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL);
1720  ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%u)\n",
1721  ret, GetLastError());
1722  ok(numbytes == 0xdeadbeef, "numbytes = %u\n", numbytes);
1723 
1724  SetLastError(0xdeadbeef);
1725  ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL);
1726  ok(!ret, "WriteFile unexpectedly succeeded\n");
1727  todo_wine ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
1728 
1729  CloseHandle(hpipe);
1730 
1733  1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
1734  ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
1735 
1737  ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
1738 
1739  numbytes = 0xdeadbeef;
1740  ret = WriteFile(hfile, testdata, 0, &numbytes, NULL);
1741  ok(ret, "WriteFile failed with %u\n", GetLastError());
1742  ok(numbytes == 0, "expected 0, got %u\n", numbytes);
1743 
1744  ret = CloseHandle(hfile);
1745  ok(ret, "CloseHandle failed with %u\n", GetLastError());
1746 
1747  numbytes = 0xdeadbeef;
1748  memset(buffer, 0, sizeof(buffer));
1749  ret = ReadFile(hpipe, buffer, sizeof(buffer), &numbytes, NULL);
1750  ok(ret, "ReadFile failed with %u\n", GetLastError());
1751  ok(numbytes == 0, "expected 0, got %u\n", numbytes);
1752 
1753  SetLastError(0xdeadbeef);
1754  ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
1755  ok(!ret, "ReadFile unexpectedly succeeded\n");
1756  ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
1757 
1758  ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
1759  ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
1761  ret = SetNamedPipeHandleState(hpipe, &state, NULL, NULL);
1762  ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
1763 
1764  SetLastError(0xdeadbeef);
1765  ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
1766  ok(!ret, "ReadFile unexpectedly succeeded\n");
1767  ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
1768 
1769  SetLastError(0xdeadbeef);
1770  ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL);
1771  ok(!ret, "WriteFile unexpectedly succeeded\n");
1772  todo_wine ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
1773 
1774  CloseHandle(hpipe);
1775 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:487
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPENAME
Definition: pipe.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
#define ERROR_NO_DATA
Definition: winerror.h:284
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_BROKEN_PIPE
Definition: winerror.h:183
#define SetLastError(x)
Definition: compat.h:500
int ret
#define todo_wine
Definition: test.h:162
static int state
Definition: maze.c:121
#define GENERIC_READ
Definition: compat.h:135
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
BOOL WINAPI GetNamedPipeHandleStateA(HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout, LPSTR lpUserName, DWORD nMaxUserNameSize)
Definition: npipe.c:1103
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:488
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI PeekNamedPipe(HANDLE hNamedPipe, LPVOID lpBuffer, DWORD nBufferSize, LPDWORD lpBytesRead, LPDWORD lpTotalBytesAvail, LPDWORD lpBytesLeftThisMessage)
Definition: npipe.c:1214

Referenced by START_TEST().

◆ test_CreateNamedPipe()

static void test_CreateNamedPipe ( int  pipemode)
static

Definition at line 145 of file pipe.c.

146 {
147  HANDLE hnp;
148  HANDLE hFile;
149  static const char obuf[] = "Bit Bucket";
150  static const char obuf2[] = "More bits";
151  char ibuf[32], *pbuf;
152  DWORD written;
153  DWORD readden;
154  DWORD avail;
155  DWORD left;
156  DWORD lpmode;
157  BOOL ret;
158 
159  if (pipemode == PIPE_TYPE_BYTE)
160  trace("test_CreateNamedPipe starting in byte mode\n");
161  else
162  trace("test_CreateNamedPipe starting in message mode\n");
163 
164  /* Wait for nonexistent pipe */
165  ret = WaitNamedPipeA(PIPENAME, 2000);
166  ok(ret == 0, "WaitNamedPipe returned %d for nonexistent pipe\n", ret);
167  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
168 
169  /* Bad parameter checks */
170  hnp = CreateNamedPipeA("not a named pipe", PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
171  /* nMaxInstances */ 1,
172  /* nOutBufSize */ 1024,
173  /* nInBufSize */ 1024,
174  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
175  /* lpSecurityAttrib */ NULL);
177  "CreateNamedPipe should fail if name doesn't start with \\\\.\\pipe\n");
178 
179  if (pipemode == PIPE_TYPE_BYTE)
180  {
181  /* Bad parameter checks */
183  /* nMaxInstances */ 1,
184  /* nOutBufSize */ 1024,
185  /* nInBufSize */ 1024,
186  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
187  /* lpSecurityAttrib */ NULL);
189  "CreateNamedPipe should fail with PIPE_TYPE_BYTE | PIPE_READMODE_MESSAGE\n");
190  }
191 
193  PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
194  1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
196  "CreateNamedPipe should fail if name is NULL\n");
197 
201  "connecting to nonexistent named pipe should fail with ERROR_FILE_NOT_FOUND\n");
202 
203  /* Functional checks */
204 
206  /* nMaxInstances */ 1,
207  /* nOutBufSize */ 1024,
208  /* nInBufSize */ 1024,
209  /* nDefaultWait */ NMPWAIT_USE_DEFAULT_WAIT,
210  /* lpSecurityAttrib */ NULL);
211  ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
213 
214  ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL);
215  todo_wine
216  ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n",
217  ret, GetLastError());
218 
219  ret = WaitNamedPipeA(PIPENAME, 2000);
220  ok(ret, "WaitNamedPipe failed (%d)\n", GetLastError());
221 
223  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError());
224 
225  ok(!WaitNamedPipeA(PIPENAME, 100), "WaitNamedPipe succeeded\n");
226 
227  ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError());
228 
229  /* Test ConnectNamedPipe() in both directions */
230  ok(!ConnectNamedPipe(hnp, NULL), "ConnectNamedPipe(server) succeeded\n");
231  ok(GetLastError() == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %u\n", GetLastError());
232  ok(!ConnectNamedPipe(hFile, NULL), "ConnectNamedPipe(client) succeeded\n");
233  ok(GetLastError() == ERROR_INVALID_FUNCTION, "expected ERROR_INVALID_FUNCTION, got %u\n", GetLastError());
234 
235  /* don't try to do i/o if one side couldn't be opened, as it hangs */
236  if (hFile != INVALID_HANDLE_VALUE) {
237  HANDLE hFile2;
238 
239  /* Make sure we can read and write a few bytes in both directions */
240  memset(ibuf, 0, sizeof(ibuf));
241  ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
242  ok(written == sizeof(obuf), "write file len\n");
243  ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
244  ok(readden == sizeof(obuf), "read got %d bytes\n", readden);
245  ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
246 
247  memset(ibuf, 0, sizeof(ibuf));
248  ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
249  ok(written == sizeof(obuf2), "write file len\n");
250  ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
251  ok(readden == sizeof(obuf2), "read got %d bytes\n", readden);
252  ok(memcmp(obuf2, ibuf, written) == 0, "content check\n");
253 
254  /* Now the same again, but with an additional call to PeekNamedPipe */
255  memset(ibuf, 0, sizeof(ibuf));
256  ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
257  ok(written == sizeof(obuf), "write file len 1\n");
258  ok(PeekNamedPipe(hFile, NULL, 0, NULL, &avail, &left), "Peek\n");
259  ok(avail == sizeof(obuf), "peek 1 got %d bytes\n", avail);
260  if (pipemode == PIPE_TYPE_BYTE)
261  ok(left == 0, "peek 1 got %d bytes left\n", left);
262  else
263  ok(left == sizeof(obuf), "peek 1 got %d bytes left\n", left);
264  ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
265  ok(readden == sizeof(obuf), "read 1 got %d bytes\n", readden);
266  ok(memcmp(obuf, ibuf, written) == 0, "content 1 check\n");
267 
268  memset(ibuf, 0, sizeof(ibuf));
269  ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
270  ok(written == sizeof(obuf2), "write file len 2\n");
271  ok(PeekNamedPipe(hnp, NULL, 0, NULL, &avail, &left), "Peek\n");
272  ok(avail == sizeof(obuf2), "peek 2 got %d bytes\n", avail);
273  if (pipemode == PIPE_TYPE_BYTE)
274  ok(left == 0, "peek 2 got %d bytes left\n", left);
275  else
276  ok(left == sizeof(obuf2), "peek 2 got %d bytes left\n", left);
277  ok(PeekNamedPipe(hnp, (LPVOID)1, 0, NULL, &avail, &left), "Peek\n");
278  ok(avail == sizeof(obuf2), "peek 2 got %d bytes\n", avail);
279  if (pipemode == PIPE_TYPE_BYTE)
280  ok(left == 0, "peek 2 got %d bytes left\n", left);
281  else
282  ok(left == sizeof(obuf2), "peek 2 got %d bytes left\n", left);
283  ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
284  ok(readden == sizeof(obuf2), "read 2 got %d bytes\n", readden);
285  ok(memcmp(obuf2, ibuf, written) == 0, "content 2 check\n");
286 
287  /* Test how ReadFile behaves when the buffer is not big enough for the whole message */
288  memset(ibuf, 0, sizeof(ibuf));
289  ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
290  ok(written == sizeof(obuf2), "write file len\n");
291  ok(PeekNamedPipe(hFile, ibuf, 4, &readden, &avail, &left), "Peek\n");
292  ok(readden == 4, "peek got %d bytes\n", readden);
293  ok(avail == sizeof(obuf2), "peek got %d bytes available\n", avail);
294  if (pipemode == PIPE_TYPE_BYTE)
295  ok(left == -4, "peek got %d bytes left\n", left);
296  else
297  ok(left == sizeof(obuf2)-4, "peek got %d bytes left\n", left);
298  ok(ReadFile(hFile, ibuf, 4, &readden, NULL), "ReadFile\n");
299  ok(readden == 4, "read got %d bytes\n", readden);
300  ok(ReadFile(hFile, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile\n");
301  ok(readden == sizeof(obuf2) - 4, "read got %d bytes\n", readden);
302  ok(memcmp(obuf2, ibuf, written) == 0, "content check\n");
303 
304  memset(ibuf, 0, sizeof(ibuf));
305  ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
306  ok(written == sizeof(obuf), "write file len\n");
307  ok(PeekNamedPipe(hnp, ibuf, 4, &readden, &avail, &left), "Peek\n");
308  ok(readden == 4, "peek got %d bytes\n", readden);
309  ok(avail == sizeof(obuf), "peek got %d bytes available\n", avail);
310  if (pipemode == PIPE_TYPE_BYTE)
311  {
312  ok(left == -4, "peek got %d bytes left\n", left);
313  ok(ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
314  }
315  else
316  {
317  ok(left == sizeof(obuf)-4, "peek got %d bytes left\n", left);
318  SetLastError(0xdeadbeef);
319  ok(!ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
320  ok(GetLastError() == ERROR_MORE_DATA, "wrong error\n");
321  }
322  ok(readden == 4, "read got %d bytes\n", readden);
323  ok(ReadFile(hnp, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile\n");
324  ok(readden == sizeof(obuf) - 4, "read got %d bytes\n", readden);
325  ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
326 
327  /* Similar to above, but use a read buffer size small enough to read in three parts */
328  memset(ibuf, 0, sizeof(ibuf));
329  ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
330  ok(written == sizeof(obuf2), "write file len\n");
331  if (pipemode == PIPE_TYPE_BYTE)
332  {
333  ok(ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
334  ok(readden == 4, "read got %d bytes\n", readden);
335  ok(ReadFile(hnp, ibuf + 4, 4, &readden, NULL), "ReadFile\n");
336  }
337  else
338  {
339  SetLastError(0xdeadbeef);
340  ok(!ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
341  ok(GetLastError() == ERROR_MORE_DATA, "wrong error\n");
342  ok(readden == 4, "read got %d bytes\n", readden);
343  SetLastError(0xdeadbeef);
344  ok(!ReadFile(hnp, ibuf + 4, 4, &readden, NULL), "ReadFile\n");
345  ok(GetLastError() == ERROR_MORE_DATA, "wrong error\n");
346  }
347  ok(readden == 4, "read got %d bytes\n", readden);
348  ok(ReadFile(hnp, ibuf + 8, sizeof(ibuf) - 8, &readden, NULL), "ReadFile\n");
349  ok(readden == sizeof(obuf2) - 8, "read got %d bytes\n", readden);
350  ok(memcmp(obuf2, ibuf, written) == 0, "content check\n");
351 
352  /* Test reading of multiple writes */
353  memset(ibuf, 0, sizeof(ibuf));
354  ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile3a\n");
355  ok(written == sizeof(obuf), "write file len 3a\n");
356  ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile3b\n");
357  ok(written == sizeof(obuf2), "write file len 3b\n");
358  ok(PeekNamedPipe(hFile, ibuf, 4, &readden, &avail, &left), "Peek3\n");
359  ok(readden == 4, "peek3 got %d bytes\n", readden);
360  if (pipemode == PIPE_TYPE_BYTE)
361  ok(left == -4, "peek3 got %d bytes left\n", left);
362  else
363  ok(left == sizeof(obuf)-4, "peek3 got %d bytes left\n", left);
364  ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail);
365  ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, &left), "Peek3\n");
366  if (pipemode == PIPE_TYPE_BYTE) {
367  ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes\n", readden);
368  ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek3 got %d bytes left\n", left);
369  }
370  else
371  {
372  ok(readden == sizeof(obuf), "peek3 got %d bytes\n", readden);
373  ok(left == 0, "peek3 got %d bytes left\n", left);
374  }
375  ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail);
376  pbuf = ibuf;
377  ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 3a check\n");
378  if (pipemode == PIPE_TYPE_BYTE && readden >= sizeof(obuf)+sizeof(obuf2)) {
379  pbuf += sizeof(obuf);
380  ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "pipe content 3b check\n");
381  }
382  ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
383  ok(readden == sizeof(obuf) + sizeof(obuf2), "read 3 got %d bytes\n", readden);
384  pbuf = ibuf;
385  ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 3a check\n");
386  pbuf += sizeof(obuf);
387  o