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

Go to the source code of this file.

Classes

struct  FILE_PIPE_INFORMATION
 
struct  FILE_PIPE_LOCAL_INFORMATION
 

Macros

#define WIN32_NO_STATUS
 
#define FILE_SYNCHRONOUS_IO_ALERT   0x10
 
#define FILE_SYNCHRONOUS_IO_NONALERT   0x20
 
#define FSCTL_PIPE_LISTEN   CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
#define loadfunc(name)
 
#define check_pipe_handle_state(handle, r, c)   _check_pipe_handle_state(__LINE__, handle, r, c)
 
#define PIPENAME   "\\\\.\\pipe\\ntdll_tests_pipe.c"
 
#define test_file_name_fail(a, b)   _test_file_name_fail(__LINE__,a,b)
 
#define test_file_name(a)   _test_file_name(__LINE__,a)
 
#define test_group(a, b, c)   _test_group(__LINE__,a,b,c)
 

Functions

static NTSTATUS (WINAPI *pNtFsControlFile)(HANDLE handle
 
static void (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING target
 
static HANDLE (WINAPI *pOpenThread)(DWORD dwDesiredAccess
 
static DWORD (WINAPI *pQueueUserAPC)(PAPCFUNC pfnAPC
 
static BOOL init_func_ptrs (void)
 
static BOOL is_signaled (HANDLE obj)
 
static NTSTATUS create_pipe (PHANDLE handle, ULONG sharing, ULONG options)
 
static void CALLBACK ioapc (void *arg, PIO_STATUS_BLOCK io, ULONG reserved)
 
static NTSTATUS listen_pipe (HANDLE hPipe, HANDLE hEvent, PIO_STATUS_BLOCK iosb, BOOL use_apc)
 
static void test_create_invalid (void)
 
static void test_create (void)
 
static void test_overlapped (void)
 
static void test_completion (void)
 
static void CALLBACK userapc (ULONG_PTR dwParam)
 
static DWORD WINAPI thread (PVOID main_thread)
 
static void test_alertable (void)
 
static void test_nonalertable (void)
 
static void test_cancelio (void)
 
static void _check_pipe_handle_state (int line, HANDLE handle, ULONG read, ULONG completion)
 
static void test_filepipeinfo (void)
 
static void WINAPI apc (void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved)
 
static void test_peek (HANDLE pipe)
 
static BOOL create_pipe_pair (HANDLE *read, HANDLE *write, ULONG flags, ULONG type, ULONG size)
 
static void read_pipe_test (ULONG pipe_flags, ULONG pipe_type)
 
static void test_volume_info (void)
 
static void _test_file_name_fail (unsigned line, HANDLE pipe, NTSTATUS expected_status)
 
static void _test_file_name (unsigned line, HANDLE pipe)
 
static void test_file_info (void)
 
static PSECURITY_DESCRIPTOR get_security_descriptor (HANDLE handle, BOOL todo)
 
static TOKEN_OWNERget_current_owner (void)
 
static TOKEN_PRIMARY_GROUPget_current_group (void)
 
static SIDwell_known_sid (WELL_KNOWN_SID_TYPE sid_type)
 
static void _test_group (unsigned line, HANDLE handle, SID *expected_sid, BOOL todo)
 
static void test_security_info (void)
 
 START_TEST (pipe)
 

Variables

static HANDLE event
 
static HANDLE PIO_APC_ROUTINE apc
 
static HANDLE PIO_APC_ROUTINE PVOID apc_context
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG code
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID in_buffer
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
 
static ULONG access
 
static ULONG POBJECT_ATTRIBUTES attr
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK iosb
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG sharing
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG dispo
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG options
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG pipe_type
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG read_mode
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG completion_mode
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG max_inst
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG inbound_quota
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG outbound_quota
 
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG PLARGE_INTEGER timeout
 
static OUT PIO_STATUS_BLOCK IoStatusBlock
 
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
 
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG Length
 
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
 
static PIO_STATUS_BLOCK voidbuffer
 
static PIO_STATUS_BLOCK void ULONG length
 
static PIO_STATUS_BLOCK void ULONG FS_INFORMATION_CLASS info_class
 
static PIO_STATUS_BLOCK PVOID ptr
 
static PIO_STATUS_BLOCK PVOID ULONG len
 
static PIO_STATUS_BLOCK PVOID ULONG FILE_INFORMATION_CLASS class
 
static PIO_STATUS_BLOCK io_status
 
static PCWSTR source
 
static BOOL bInheritHandle
 
static BOOL DWORD dwThreadId
 
static HANDLE hThread
 
static HANDLE ULONG_PTR dwData
 
static const WCHAR testpipe []
 
static const WCHAR testpipe_nt []
 
static BOOL ioapc_called
 
static BOOL userapc_called
 
static BOOL open_succeeded
 

Macro Definition Documentation

◆ check_pipe_handle_state

#define check_pipe_handle_state (   handle,
  r,
  c 
)    _check_pipe_handle_state(__LINE__, handle, r, c)

Definition at line 628 of file pipe.c.

◆ FILE_SYNCHRONOUS_IO_ALERT

#define FILE_SYNCHRONOUS_IO_ALERT   0x10

Definition at line 55 of file pipe.c.

◆ FILE_SYNCHRONOUS_IO_NONALERT

#define FILE_SYNCHRONOUS_IO_NONALERT   0x20

Definition at line 59 of file pipe.c.

◆ FSCTL_PIPE_LISTEN

Definition at line 63 of file pipe.c.

◆ loadfunc

#define loadfunc (   name)
Value:
if (!(p##name = (void *)GetProcAddress(module, #name))) { \
trace("GetProcAddress(%s) failed\n", #name); \
return FALSE; \
}
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
GLfloat GLfloat p
Definition: glext.h:8902
Definition: name.c:39

◆ PIPENAME

#define PIPENAME   "\\\\.\\pipe\\ntdll_tests_pipe.c"

Definition at line 829 of file pipe.c.

◆ test_file_name

#define test_file_name (   a)    _test_file_name(__LINE__,a)

Definition at line 1224 of file pipe.c.

◆ test_file_name_fail

#define test_file_name_fail (   a,
  b 
)    _test_file_name_fail(__LINE__,a,b)

Definition at line 1212 of file pipe.c.

◆ test_group

#define test_group (   a,
  b,
  c 
)    _test_group(__LINE__,a,b,c)

Definition at line 1359 of file pipe.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 24 of file pipe.c.

Function Documentation

◆ _check_pipe_handle_state()

static void _check_pipe_handle_state ( int  line,
HANDLE  handle,
ULONG  read,
ULONG  completion 
)
static

Definition at line 612 of file pipe.c.

613{
618 {
619 memset(&fpi, 0x55, sizeof(fpi));
620 res = pNtQueryInformationFile(handle, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
621 ok_(__FILE__, line)(!res, "NtQueryInformationFile returned %x\n", res);
622 ok_(__FILE__, line)(fpi.ReadMode == read, "Unexpected ReadMode, expected %x, got %x\n",
623 read, fpi.ReadMode);
624 ok_(__FILE__, line)(fpi.CompletionMode == completion, "Unexpected CompletionMode, expected %x, got %x\n",
626 }
627}
void CALLBACK completion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags)
Definition: WSARecv.c:16
#define read
Definition: acwin.h:96
#define ok_(x1, x2)
Definition: atltest.h:61
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
GLuint res
Definition: glext.h:9613
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK iosb
Definition: pipe.c:69
#define memset(x, y, z)
Definition: compat.h:39
ULONG CompletionMode
Definition: pipe.c:38
Definition: parser.c:49

◆ _test_file_name()

static void _test_file_name ( unsigned  line,
HANDLE  pipe 
)
static

Definition at line 1225 of file pipe.c.

1226{
1227 char buffer[512];
1231
1232 static const WCHAR nameW[] =
1233 {'\\','n','t','d','l','l','_','t','e','s','t','s','_','p','i','p','e','.','c'};
1234
1235 memset( buffer, 0xaa, sizeof(buffer) );
1236 memset( &iosb, 0xaa, sizeof(iosb) );
1238 ok_(__FILE__,line)( status == STATUS_SUCCESS, "NtQueryInformationFile failed: %x\n", status );
1239 ok_(__FILE__,line)( iosb.Status == STATUS_SUCCESS, "Status = %x\n", iosb.Status );
1240 ok_(__FILE__,line)( iosb.Information == sizeof(name_info->FileNameLength) + sizeof(nameW),
1241 "Information = %lu\n", iosb.Information );
1242 ok( name_info->FileNameLength == sizeof(nameW), "FileNameLength = %u\n", name_info->FileNameLength );
1243 ok( !memcmp(name_info->FileName, nameW, sizeof(nameW)), "FileName = %s\n", wine_dbgstr_w(name_info->FileName) );
1244
1245 /* too small buffer */
1246 memset( buffer, 0xaa, sizeof(buffer) );
1247 memset( &iosb, 0xaa, sizeof(iosb) );
1249 ok( status == STATUS_BUFFER_OVERFLOW, "NtQueryInformationFile failed: %x\n", status );
1250 ok( iosb.Status == STATUS_BUFFER_OVERFLOW, "Status = %x\n", iosb.Status );
1251 ok( iosb.Information == 20, "Information = %lu\n", iosb.Information );
1252 ok( name_info->FileNameLength == sizeof(nameW), "FileNameLength = %u\n", name_info->FileNameLength );
1253 ok( !memcmp(name_info->FileName, nameW, 16), "FileName = %s\n", wine_dbgstr_w(name_info->FileName) );
1254
1255 /* too small buffer */
1256 memset( buffer, 0xaa, sizeof(buffer) );
1257 memset( &iosb, 0xaa, sizeof(iosb) );
1259 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryInformationFile failed: %x\n", status );
1260}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR nameW[]
Definition: main.c:46
@ FileNameInformation
Definition: from_kernel.h:70
GLuint buffer
Definition: glext.h:5915
#define wine_dbgstr_w
Definition: kernel32.h:34
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
Definition: ps.c:97
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ _test_file_name_fail()

static void _test_file_name_fail ( unsigned  line,
HANDLE  pipe,
NTSTATUS  expected_status 
)
static

Definition at line 1213 of file pipe.c.

1214{
1215 char buffer[512];
1218
1220 ok_(__FILE__,line)( status == expected_status, "NtQueryInformationFile failed: %x, expected %x\n",
1221 status, expected_status );
1222}

◆ _test_group()

static void _test_group ( unsigned  line,
HANDLE  handle,
SID expected_sid,
BOOL  todo 
)
static

Definition at line 1360 of file pipe.c.

1361{
1362 SECURITY_DESCRIPTOR *sec_desc;
1363 BOOLEAN defaulted;
1364 PSID group_sid;
1366
1367 sec_desc = get_security_descriptor(handle, todo);
1368 if (!sec_desc) return;
1369
1370 status = RtlGetGroupSecurityDescriptor(sec_desc, &group_sid, &defaulted);
1371 ok_(__FILE__,line)(status == STATUS_SUCCESS,
1372 "Failed to query group from security descriptor: %08x\n", status);
1374 ok_(__FILE__,line)(EqualSid(group_sid, expected_sid), "SIDs are not equal\n");
1375
1376 HeapFree(GetProcessHeap(), 0, sec_desc);
1377}
unsigned char BOOLEAN
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL todo
Definition: filedlg.c:313
#define todo_wine_if(is_todo)
Definition: custom.c:76
static PSECURITY_DESCRIPTOR get_security_descriptor(HANDLE handle, BOOL todo)
Definition: pipe.c:1279
NTSYSAPI NTSTATUS NTAPI RtlGetGroupSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PSID *Group, OUT PBOOLEAN GroupDefaulted)
Definition: sd.c:280

◆ apc()

static void WINAPI apc ( void arg,
IO_STATUS_BLOCK iosb,
ULONG  reserved 
)
static

Definition at line 798 of file pipe.c.

799{
800 int *count = arg;
801 (*count)++;
802 ok( !reserved, "reserved is not 0: %x\n", reserved );
803}
r reserved
Definition: btrfs.c:3006
GLuint GLuint GLsizei count
Definition: gl.h:1545
void * arg
Definition: msvc.h:10

◆ create_pipe()

static NTSTATUS create_pipe ( PHANDLE  handle,
ULONG  sharing,
ULONG  options 
)
static

Definition at line 121 of file pipe.c.

122{
128
129 pRtlInitUnicodeString(&name, testpipe_nt);
130
131 attr.Length = sizeof(attr);
132 attr.RootDirectory = 0;
133 attr.ObjectName = &name;
134 attr.Attributes = 0x40; /*case insensitive */
135 attr.SecurityDescriptor = NULL;
136 attr.SecurityQualityOfService = NULL;
137
138 timeout.QuadPart = -100000000;
139
140 res = pNtCreateNamedPipeFile(handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, sharing, 2 /*FILE_CREATE*/,
141 options, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
142 return res;
143}
#define NULL
Definition: types.h:112
static ULONG POBJECT_ATTRIBUTES attr
Definition: pipe.c:69
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG sharing
Definition: pipe.c:70
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG ULONG PLARGE_INTEGER timeout
Definition: pipe.c:74
static const WCHAR testpipe_nt[]
Definition: pipe.c:118
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
Definition: cookie.c:202
Definition: dhcpd.h:245

Referenced by test_alertable(), test_cancelio(), test_completion(), test_create(), test_nonalertable(), and test_overlapped().

◆ create_pipe_pair()

static BOOL create_pipe_pair ( HANDLE read,
HANDLE write,
ULONG  flags,
ULONG  type,
ULONG  size 
)
static

Definition at line 831 of file pipe.c.

832{
833 const BOOL server_reader = flags & PIPE_ACCESS_INBOUND;
835
838 ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
839
842 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError());
843
844 if(server_reader)
845 {
846 *read = server;
847 *write = client;
848 }
849 else
850 {
852 {
854 ok(SetNamedPipeHandleState(client, &read_mode, NULL, NULL), "Change mode\n");
855 }
856
857 *read = client;
858 *write = server;
859 }
860 return TRUE;
861}
#define write
Definition: acwin.h:97
#define TRUE
Definition: types.h:120
#define OPEN_EXISTING
Definition: compat.h:775
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define PIPENAME
Definition: pipe.c:32
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG ULONG read_mode
Definition: pipe.c:71
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
#define GENERIC_WRITE
Definition: nt_native.h:90
static FILE * client
Definition: client.c:41
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define PIPE_ACCESS_INBOUND
Definition: winbase.h:165
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170

Referenced by read_pipe_test(), test_file_info(), and test_volume_info().

◆ DWORD()

static DWORD ( WINAPI pQueueUserAPC)
static

◆ get_current_group()

static TOKEN_PRIMARY_GROUP * get_current_group ( void  )
static

Definition at line 1324 of file pipe.c.

1325{
1327 ULONG length = 0;
1328 HANDLE token;
1329 BOOL ret;
1330
1332 ok(ret, "Failed to get process token: %u\n", GetLastError());
1333
1336 "GetTokenInformation failed: %u\n", GetLastError());
1337 ok(length != 0, "Failed to get primary group token information length: %u\n", GetLastError());
1338
1341 ok(ret, "Failed to get primary group token information: %u\n", GetLastError());
1342
1344 return group;
1345}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define HeapAlloc
Definition: compat.h:733
#define GetCurrentProcess()
Definition: compat.h:759
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLboolean GLuint group
Definition: glext.h:11120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
uint32_t ULONG
Definition: typedefs.h:59
int ret
@ TokenPrimaryGroup
Definition: setypes.h:970
#define TOKEN_ALL_ACCESS
Definition: setypes.h:946

Referenced by test_security_info().

◆ get_current_owner()

static TOKEN_OWNER * get_current_owner ( void  )
static

Definition at line 1301 of file pipe.c.

1302{
1303 TOKEN_OWNER *owner;
1304 ULONG length = 0;
1305 HANDLE token;
1306 BOOL ret;
1307
1309 ok(ret, "Failed to get process token: %u\n", GetLastError());
1310
1313 "GetTokenInformation failed: %u\n", GetLastError());
1314 ok(length != 0, "Failed to get token owner information length: %u\n", GetLastError());
1315
1316 owner = HeapAlloc(GetProcessHeap(), 0, length);
1318 ok(ret, "Failed to get token owner information: %u)\n", GetLastError());
1319
1321 return owner;
1322}
@ TokenOwner
Definition: setypes.h:969

Referenced by test_security_info().

◆ get_security_descriptor()

static PSECURITY_DESCRIPTOR get_security_descriptor ( HANDLE  handle,
BOOL  todo 
)
static

Definition at line 1279 of file pipe.c.

1280{
1281 SECURITY_DESCRIPTOR *sec_desc;
1282 ULONG length = 0;
1284
1286 NULL, 0, &length);
1289 "Failed to query object security descriptor length: %08x\n", status);
1290 if(status != STATUS_BUFFER_TOO_SMALL) return NULL;
1291 ok(length != 0, "length = 0\n");
1292
1295 sec_desc, length, &length);
1296 ok(status == STATUS_SUCCESS, "Failed to query object security descriptor: %08x\n", status);
1297
1298 return sec_desc;
1299}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:412
NTSTATUS NTAPI NtQuerySecurityObject(IN HANDLE Handle, IN SECURITY_INFORMATION SecurityInformation, OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Length, OUT PULONG ResultLength)
Definition: obsecure.c:803
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
#define GROUP_SECURITY_INFORMATION
Definition: setypes.h:124

Referenced by _test_group().

◆ HANDLE()

static HANDLE ( WINAPI pOpenThread)
static

◆ init_func_ptrs()

static BOOL init_func_ptrs ( void  )
static

Definition at line 86 of file pipe.c.

87{
88 HMODULE module = GetModuleHandleA("ntdll.dll");
89
90#define loadfunc(name) if (!(p##name = (void *)GetProcAddress(module, #name))) { \
91 trace("GetProcAddress(%s) failed\n", #name); \
92 return FALSE; \
93 }
94
102
103 /* not fatal */
104 pNtCancelIoFileEx = (void *)GetProcAddress(module, "NtCancelIoFileEx");
105 module = GetModuleHandleA("kernel32.dll");
106 pOpenThread = (void *)GetProcAddress(module, "OpenThread");
107 pQueueUserAPC = (void *)GetProcAddress(module, "QueueUserAPC");
108 return TRUE;
109}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define loadfunc(name)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3096
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4019
NTSTATUS NTAPI NtCreateNamedPipeFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN ULONG NamedPipeType, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota, IN PLARGE_INTEGER DefaultTimeout)
Definition: file.c:3858
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)

Referenced by START_TEST().

◆ ioapc()

static void CALLBACK ioapc ( void arg,
PIO_STATUS_BLOCK  io,
ULONG  reserved 
)
static

Definition at line 146 of file pipe.c.

147{
149}
static BOOL ioapc_called
Definition: pipe.c:145

Referenced by listen_pipe().

◆ is_signaled()

static BOOL is_signaled ( HANDLE  obj)
inlinestatic

Definition at line 111 of file pipe.c.

112{
113 return WaitForSingleObject( obj, 0 ) == WAIT_OBJECT_0;
114}
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by read_pipe_test(), test_overlapped(), and test_peek().

◆ listen_pipe()

static NTSTATUS listen_pipe ( HANDLE  hPipe,
HANDLE  hEvent,
PIO_STATUS_BLOCK  iosb,
BOOL  use_apc 
)
static

Definition at line 151 of file pipe.c.

152{
153 int dummy;
154
156
157 return pNtFsControlFile(hPipe, hEvent, use_apc ? &ioapc: NULL, use_apc ? &dummy: NULL, iosb, FSCTL_PIPE_LISTEN, 0, 0, 0, 0);
158}
static HANDLE hEvent
Definition: comm.c:54
#define FSCTL_PIPE_LISTEN
Definition: pipe.c:63
static void CALLBACK ioapc(void *arg, PIO_STATUS_BLOCK io, ULONG reserved)
Definition: pipe.c:146

Referenced by test_alertable(), test_cancelio(), test_completion(), test_create(), test_nonalertable(), and test_overlapped().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtFsControlFile)
static

◆ read_pipe_test()

static void read_pipe_test ( ULONG  pipe_flags,
ULONG  pipe_type 
)
static

Definition at line 863 of file pipe.c.

864{
865 IO_STATUS_BLOCK iosb, iosb2;
867 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
868 int apc_count = 0;
869 char buffer[128];
870 DWORD written;
871 BOOL ret;
873
874 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
875
876 /* try read with no data */
877 U(iosb).Status = 0xdeadbabe;
878 iosb.Information = 0xdeadbeef;
879 ok( is_signaled( read ), "read handle is not signaled\n" );
880 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
881 ok( status == STATUS_PENDING, "wrong status %x\n", status );
882 ok( !is_signaled( read ), "read handle is signaled\n" );
883 ok( !is_signaled( event ), "event is signaled\n" );
884 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
885 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
886 ok( !apc_count, "apc was called\n" );
887 ret = WriteFile( write, buffer, 1, &written, NULL );
888 ok(ret && written == 1, "WriteFile error %d\n", GetLastError());
889 /* iosb updated here by async i/o */
890 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
891 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
892 ok( !is_signaled( read ), "read handle is signaled\n" );
893 ok( is_signaled( event ), "event is not signaled\n" );
894 ok( !apc_count, "apc was called\n" );
895 apc_count = 0;
896 SleepEx( 1, FALSE ); /* non-alertable sleep */
897 ok( !apc_count, "apc was called\n" );
898 SleepEx( 1, TRUE ); /* alertable sleep */
899 ok( apc_count == 1, "apc not called\n" );
900
901 /* with no event, the pipe handle itself gets signaled */
902 apc_count = 0;
903 U(iosb).Status = 0xdeadbabe;
904 iosb.Information = 0xdeadbeef;
905 ok( !is_signaled( read ), "read handle is signaled\n" );
906 status = NtReadFile( read, 0, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
907 ok( status == STATUS_PENDING, "wrong status %x\n", status );
908 ok( !is_signaled( read ), "read handle is signaled\n" );
909 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
910 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
911 ok( !apc_count, "apc was called\n" );
912 ret = WriteFile( write, buffer, 1, &written, NULL );
913 ok(ret && written == 1, "WriteFile error %d\n", GetLastError());
914 /* iosb updated here by async i/o */
915 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
916 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
917 ok( is_signaled( read ), "read handle is not signaled\n" );
918 ok( !apc_count, "apc was called\n" );
919 apc_count = 0;
920 SleepEx( 1, FALSE ); /* non-alertable sleep */
921 ok( !apc_count, "apc was called\n" );
922 SleepEx( 1, TRUE ); /* alertable sleep */
923 ok( apc_count == 1, "apc not called\n" );
924
925 /* now read with data ready */
926 apc_count = 0;
927 U(iosb).Status = 0xdeadbabe;
928 iosb.Information = 0xdeadbeef;
929 ResetEvent( event );
930 ret = WriteFile( write, buffer, 1, &written, NULL );
931 ok(ret && written == 1, "WriteFile error %d\n", GetLastError());
932
934
935 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
936 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
937 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
938 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
939 ok( is_signaled( event ), "event is not signaled\n" );
940 ok( !apc_count, "apc was called\n" );
941 SleepEx( 1, FALSE ); /* non-alertable sleep */
942 ok( !apc_count, "apc was called\n" );
943 SleepEx( 1, TRUE ); /* alertable sleep */
944 ok( apc_count == 1, "apc not called\n" );
945
946 /* now partial read with data ready */
947 apc_count = 0;
948 U(iosb).Status = 0xdeadbabe;
949 iosb.Information = 0xdeadbeef;
950 ResetEvent( event );
951 ret = WriteFile( write, buffer, 2, &written, NULL );
952 ok(ret && written == 2, "WriteFile error %d\n", GetLastError());
953 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
955 {
956 ok( status == STATUS_BUFFER_OVERFLOW, "wrong status %x\n", status );
957 ok( U(iosb).Status == STATUS_BUFFER_OVERFLOW, "wrong status %x\n", U(iosb).Status );
958 }
959 else
960 {
961 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
962 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
963 }
964 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
965 ok( is_signaled( event ), "event is not signaled\n" );
966 ok( !apc_count, "apc was called\n" );
967 SleepEx( 1, FALSE ); /* non-alertable sleep */
968 ok( !apc_count, "apc was called\n" );
969 SleepEx( 1, TRUE ); /* alertable sleep */
970 ok( apc_count == 1, "apc not called\n" );
971 apc_count = 0;
972 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
973 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
974 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
975 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
976 ok( is_signaled( event ), "event is not signaled\n" );
977 ok( !apc_count, "apc was called\n" );
978 SleepEx( 1, FALSE ); /* non-alertable sleep */
979 ok( !apc_count, "apc was called\n" );
980 SleepEx( 1, TRUE ); /* alertable sleep */
981 ok( apc_count == 1, "apc not called\n" );
982
983 /* try read with no data */
984 apc_count = 0;
985 U(iosb).Status = 0xdeadbabe;
986 iosb.Information = 0xdeadbeef;
987 ok( is_signaled( event ), "event is not signaled\n" ); /* check that read resets the event */
988 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
989 ok( status == STATUS_PENDING, "wrong status %x\n", status );
990 ok( !is_signaled( event ), "event is signaled\n" );
991 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
992 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
993 ok( !apc_count, "apc was called\n" );
994 ret = WriteFile( write, buffer, 1, &written, NULL );
995 ok(ret && written == 1, "WriteFile error %d\n", GetLastError());
996 /* partial read is good enough */
997 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
998 ok( is_signaled( event ), "event is not signaled\n" );
999 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
1000 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
1001 ok( !apc_count, "apc was called\n" );
1002 SleepEx( 1, TRUE ); /* alertable sleep */
1003 ok( apc_count == 1, "apc was not called\n" );
1004
1005 /* read from disconnected pipe */
1006 apc_count = 0;
1007 U(iosb).Status = 0xdeadbabe;
1008 iosb.Information = 0xdeadbeef;
1009 CloseHandle( write );
1010 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
1011 ok( status == STATUS_PIPE_BROKEN, "wrong status %x\n", status );
1012 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1013 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1014 ok( !is_signaled( event ), "event is signaled\n" );
1015 ok( !apc_count, "apc was called\n" );
1016 SleepEx( 1, TRUE ); /* alertable sleep */
1017 ok( !apc_count, "apc was called\n" );
1018 CloseHandle( read );
1019
1020 /* read from disconnected pipe, with invalid event handle */
1021 apc_count = 0;
1022 U(iosb).Status = 0xdeadbabe;
1023 iosb.Information = 0xdeadbeef;
1024 status = NtReadFile( read, (HANDLE)0xdeadbeef, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
1025 ok( status == STATUS_INVALID_HANDLE, "wrong status %x\n", status );
1026 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1027 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1028 ok( !apc_count, "apc was called\n" );
1029 SleepEx( 1, TRUE ); /* alertable sleep */
1030 ok( !apc_count, "apc was called\n" );
1031 CloseHandle( read );
1032
1033 /* read from closed handle */
1034 apc_count = 0;
1035 U(iosb).Status = 0xdeadbabe;
1036 iosb.Information = 0xdeadbeef;
1037 SetEvent( event );
1038 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
1039 ok( status == STATUS_INVALID_HANDLE, "wrong status %x\n", status );
1040 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1041 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1042 ok( is_signaled( event ), "event is not signaled\n" ); /* not reset on invalid handle */
1043 ok( !apc_count, "apc was called\n" );
1044 SleepEx( 1, TRUE ); /* alertable sleep */
1045 ok( !apc_count, "apc was called\n" );
1046
1047 /* disconnect while async read is in progress */
1048 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1049 apc_count = 0;
1050 U(iosb).Status = 0xdeadbabe;
1051 iosb.Information = 0xdeadbeef;
1052 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
1053 ok( status == STATUS_PENDING, "wrong status %x\n", status );
1054 ok( !is_signaled( event ), "event is signaled\n" );
1055 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1056 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1057 ok( !apc_count, "apc was called\n" );
1058 CloseHandle( write );
1059 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1060 ok( U(iosb).Status == STATUS_PIPE_BROKEN, "wrong status %x\n", U(iosb).Status );
1061 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
1062 ok( is_signaled( event ), "event is not signaled\n" );
1063 ok( !apc_count, "apc was called\n" );
1064 SleepEx( 1, TRUE ); /* alertable sleep */
1065 ok( apc_count == 1, "apc was not called\n" );
1066 CloseHandle( read );
1067
1068 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1070 ok(ret, "Failed to duplicate handle: %d\n", GetLastError());
1071
1072 apc_count = 0;
1073 U(iosb).Status = 0xdeadbabe;
1074 iosb.Information = 0xdeadbeef;
1075 status = NtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
1076 ok( status == STATUS_PENDING, "wrong status %x\n", status );
1077 ok( !is_signaled( event ), "event is signaled\n" );
1078 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1079 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1080 ok( !apc_count, "apc was called\n" );
1081 /* Cancel by other handle */
1082 status = pNtCancelIoFile( read, &iosb2 );
1083 ok(status == STATUS_SUCCESS, "failed to cancel by different handle: %x\n", status);
1084 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1085 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
1086 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
1087 ok( is_signaled( event ), "event is not signaled\n" );
1088 ok( !apc_count, "apc was called\n" );
1089 SleepEx( 1, TRUE ); /* alertable sleep */
1090 ok( apc_count == 1, "apc was not called\n" );
1091
1092 apc_count = 0;
1093 U(iosb).Status = 0xdeadbabe;
1094 iosb.Information = 0xdeadbeef;
1095 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
1096 ok( status == STATUS_PENDING, "wrong status %x\n", status );
1097 ok( !is_signaled( event ), "event is signaled\n" );
1098 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1099 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1100 ok( !apc_count, "apc was called\n" );
1101 /* Close queued handle */
1102 CloseHandle( read );
1103 SleepEx( 1, TRUE ); /* alertable sleep */
1104 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1105 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1106 status = pNtCancelIoFile( read, &iosb2 );
1107 ok(status == STATUS_INVALID_HANDLE, "cancelled by closed handle?\n");
1108 status = pNtCancelIoFile( handle, &iosb2 );
1109 ok(status == STATUS_SUCCESS, "failed to cancel: %x\n", status);
1110 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1111 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
1112 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
1113 ok( is_signaled( event ), "event is not signaled\n" );
1114 ok( !apc_count, "apc was called\n" );
1115 SleepEx( 1, TRUE ); /* alertable sleep */
1116 ok( apc_count == 1, "apc was not called\n" );
1118 CloseHandle( write );
1119
1120 if (pNtCancelIoFileEx)
1121 {
1122 /* Basic Cancel Ex */
1123 if (!create_pipe_pair( &read, &write, FILE_FLAG_OVERLAPPED | pipe_flags, pipe_type, 4096 )) return;
1124
1125 apc_count = 0;
1126 U(iosb).Status = 0xdeadbabe;
1127 iosb.Information = 0xdeadbeef;
1128 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
1129 ok( status == STATUS_PENDING, "wrong status %x\n", status );
1130 ok( !is_signaled( event ), "event is signaled\n" );
1131 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1132 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1133 ok( !apc_count, "apc was called\n" );
1134 status = pNtCancelIoFileEx( read, &iosb, &iosb2 );
1135 ok(status == STATUS_SUCCESS, "Failed to cancel I/O\n");
1136 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1137 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
1138 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
1139 ok( is_signaled( event ), "event is not signaled\n" );
1140 ok( !apc_count, "apc was called\n" );
1141 SleepEx( 1, TRUE ); /* alertable sleep */
1142 ok( apc_count == 1, "apc was not called\n" );
1143
1144 /* Duplicate iosb */
1145 apc_count = 0;
1146 U(iosb).Status = 0xdeadbabe;
1147 iosb.Information = 0xdeadbeef;
1148 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
1149 ok( status == STATUS_PENDING, "wrong status %x\n", status );
1150 ok( !is_signaled( event ), "event is signaled\n" );
1151 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1152 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1153 ok( !apc_count, "apc was called\n" );
1154 status = NtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
1155 ok( status == STATUS_PENDING, "wrong status %x\n", status );
1156 ok( !is_signaled( event ), "event is signaled\n" );
1157 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
1158 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
1159 ok( !apc_count, "apc was called\n" );
1160 status = pNtCancelIoFileEx( read, &iosb, &iosb2 );
1161 ok(status == STATUS_SUCCESS, "Failed to cancel I/O\n");
1162 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
1163 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
1164 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
1165 ok( is_signaled( event ), "event is not signaled\n" );
1166 ok( !apc_count, "apc was called\n" );
1167 SleepEx( 1, TRUE ); /* alertable sleep */
1168 ok( apc_count == 2, "apc was not called\n" );
1169
1170 CloseHandle( read );
1171 CloseHandle( write );
1172 }
1173 else
1174 win_skip("NtCancelIoFileEx not available\n");
1175
1177}
#define U(x)
Definition: wordpad.c:45
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
Status
Definition: gdiplustypes.h:25
struct _cl_event * event
Definition: glext.h:7739
static void test_peek(HANDLE pipe)
Definition: pipe.c:805
static HANDLE PIO_APC_ROUTINE apc
Definition: pipe.c:67
static BOOL create_pipe_pair(HANDLE *read, HANDLE *write, ULONG flags, ULONG type, ULONG size)
Definition: pipe.c:831
static BOOL is_signaled(HANDLE obj)
Definition: pipe.c:111
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG ULONG ULONG ULONG pipe_type
Definition: pipe.c:71
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_PIPE_BROKEN
Definition: ntstatus.h:567
#define win_skip
Definition: test.h:160
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define DUPLICATE_SAME_ACCESS

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( pipe  )

Definition at line 1492 of file pipe.c.

1493{
1494 if (!init_func_ptrs())
1495 return;
1496
1497 trace("starting invalid create tests\n");
1499
1500 trace("starting create tests\n");
1501 test_create();
1502
1503 trace("starting overlapped tests\n");
1505
1506 trace("starting completion tests\n");
1508
1509 trace("starting FILE_PIPE_INFORMATION tests\n");
1511
1512 if (!pOpenThread || !pQueueUserAPC)
1513 return;
1514
1515 trace("starting alertable tests\n");
1517
1518 trace("starting nonalertable tests\n");
1520
1521 trace("starting cancelio tests\n");
1522 test_cancelio();
1523
1524 trace("starting byte read in byte mode client -> server\n");
1526 trace("starting byte read in message mode client -> server\n");
1528 trace("starting message read in message mode client -> server\n");
1530 trace("starting byte read in byte mode server -> client\n");
1532 trace("starting byte read in message mode server -> client\n");
1534 trace("starting message read in message mode server -> client\n");
1536
1540}
#define trace
Definition: atltest.h:70
static void test_overlapped(void)
Definition: pipe.c:2278
static void test_create_invalid(void)
Definition: pipe.c:160
static void test_security_info(void)
Definition: pipe.c:1379
static BOOL init_func_ptrs(void)
Definition: pipe.c:86
static void test_create(void)
Definition: pipe.c:220
static void test_filepipeinfo(void)
Definition: pipe.c:630
static void test_alertable(void)
Definition: pipe.c:441
static void read_pipe_test(ULONG pipe_flags, ULONG pipe_type)
Definition: pipe.c:863
static void test_volume_info(void)
Definition: pipe.c:1179
static void test_file_info(void)
Definition: pipe.c:1262
static void test_completion(void)
Definition: pipe.c:339
static void test_nonalertable(void)
Definition: pipe.c:511
static void test_cancelio(void)
Definition: pipe.c:556
#define PIPE_ACCESS_OUTBOUND
Definition: winbase.h:166
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168

◆ test_alertable()

static void test_alertable ( void  )
static

Definition at line 441 of file pipe.c.

442{
445 HANDLE hPipe;
448 DWORD ret;
449
450 memset(&iosb, 0x55, sizeof(iosb));
451
453 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError());
454
456 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
457
458/* queue an user apc before calling listen */
460 ret = pQueueUserAPC(&userapc, GetCurrentThread(), 0);
461 ok(ret, "can't queue user apc, GetLastError: %x\n", GetLastError());
462
463 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
464 todo_wine ok(res == STATUS_CANCELLED, "NtFsControlFile returned %x\n", res);
465
466 todo_wine ok(userapc_called, "user apc didn't run\n");
467 ok(U(iosb).Status == 0x55555555, "iosb.Status got changed to %x\n", U(iosb).Status);
468 todo_wine ok(WaitForSingleObjectEx(hEvent, 0, TRUE) == WAIT_TIMEOUT, "hEvent signaled\n");
469 ok(!ioapc_called, "IOAPC ran\n");
470
471/* queue an user apc from a different thread */
473 ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %x\n", GetLastError());
474
475 /* wine_todo: the earlier NtFsControlFile call gets cancelled after the pipe gets set into listen state
476 instead of before, so this NtFsControlFile will fail STATUS_INVALID_HANDLE */
477 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
478 todo_wine ok(res == STATUS_CANCELLED, "NtFsControlFile returned %x\n", res);
479
480 ok(userapc_called, "user apc didn't run\n");
481 ok(U(iosb).Status == 0x55555555, "iosb.Status got changed to %x\n", U(iosb).Status);
482 ok(WaitForSingleObjectEx(hEvent, 0, TRUE) == WAIT_TIMEOUT, "hEvent signaled\n");
483 ok(!ioapc_called, "IOAPC ran\n");
484
486
487 SleepEx(0, TRUE); /* get rid of the userapc, if NtFsControlFile failed */
488
489 ok(open_succeeded, "couldn't open client side pipe\n");
490
492 DisconnectNamedPipe(hPipe);
493
494/* finally try without an apc */
495 hThread = CreateThread(NULL, 0, &thread, 0, 0, 0);
496 ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %x\n", GetLastError());
497
498 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
499 todo_wine ok(!res, "NtFsControlFile returned %x\n", res);
500
501 ok(open_succeeded, "couldn't open client side pipe\n");
502 ok(!U(iosb).Status, "Wrong iostatus %x\n", U(iosb).Status);
503 todo_wine ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
504
508 CloseHandle(hPipe);
509}
static HANDLE thread
Definition: service.c:33
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define FILE_SHARE_READ
Definition: compat.h:136
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define INFINITE
Definition: serial.h:102
static HANDLE hThread
Definition: pipe.c:40
#define todo_wine
Definition: custom.c:79
static NTSTATUS create_pipe(PHANDLE handle, ULONG sharing, ULONG options)
Definition: pipe.c:121
static BOOL open_succeeded
Definition: pipe.c:412
static BOOL userapc_called
Definition: pipe.c:406
static void CALLBACK userapc(ULONG_PTR dwParam)
Definition: pipe.c:407
static NTSTATUS listen_pipe(HANDLE hPipe, HANDLE hEvent, PIO_STATUS_BLOCK iosb, BOOL use_apc)
Definition: pipe.c:151
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: pipe.c:55
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by START_TEST().

◆ test_cancelio()

static void test_cancelio ( void  )
static

Definition at line 556 of file pipe.c.

557{
559 IO_STATUS_BLOCK cancel_sb;
561 HANDLE hPipe;
563
565 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError());
566
567 res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
568 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
569
570 memset(&iosb, 0x55, sizeof(iosb));
571
572 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
573 ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res);
574
575 res = pNtCancelIoFile(hPipe, &cancel_sb);
576 ok(!res, "NtCancelIoFile returned %x\n", res);
577
578 ok(U(iosb).Status == STATUS_CANCELLED, "Wrong iostatus %x\n", U(iosb).Status);
579 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
580
581 ok(!ioapc_called, "IOAPC ran too early\n");
582
583 SleepEx(0, TRUE); /* alertable wait state */
584
585 ok(ioapc_called, "IOAPC didn't run\n");
586
587 CloseHandle(hPipe);
588
589 if (pNtCancelIoFileEx)
590 {
591 res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
592 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
593
594 memset(&iosb, 0x55, sizeof(iosb));
595 res = listen_pipe(hPipe, hEvent, &iosb, FALSE);
596 ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res);
597
598 res = pNtCancelIoFileEx(hPipe, &iosb, &cancel_sb);
599 ok(!res, "NtCancelIoFileEx returned %x\n", res);
600
601 ok(U(iosb).Status == STATUS_CANCELLED, "Wrong iostatus %x\n", U(iosb).Status);
602 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
603
604 CloseHandle(hPipe);
605 }
606 else
607 win_skip("NtCancelIoFileEx not available\n");
608
610}

Referenced by START_TEST().

◆ test_completion()

static void test_completion ( void  )
static

Definition at line 339 of file pipe.c.

340{
341 static const char buf[] = "testdata";
343 HANDLE port, pipe, client;
345 OVERLAPPED ov, *pov;
348 DWORD num_bytes;
350 DWORD dwret;
351 BOOL ret;
352
353 memset(&ov, 0, sizeof(ov));
355 ok(ov.hEvent != INVALID_HANDLE_VALUE, "CreateEvent failed, error %u\n", GetLastError());
356
357 status = create_pipe(&pipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
358 ok(!status, "NtCreateNamedPipeFile returned %x\n", status);
359 status = listen_pipe(pipe, ov.hEvent, &iosb, FALSE);
360 ok(status == STATUS_PENDING, "NtFsControlFile returned %x\n", status);
361
364 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed, error %u\n", GetLastError());
365 dwret = WaitForSingleObject(ov.hEvent, 0);
366 ok(dwret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", dwret);
367
368 port = CreateIoCompletionPort(client, NULL, 0xdeadbeef, 0);
369 ok(port != NULL, "CreateIoCompletionPort failed, error %u\n", GetLastError());
370
371 ret = WriteFile(client, buf, sizeof(buf), &num_bytes, &ov);
372 ok(ret, "WriteFile failed, error %u\n", GetLastError());
373 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %u\n", num_bytes);
374
375 key = 0;
376 pov = NULL;
377 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 1000);
378 ok(ret, "GetQueuedCompletionStatus failed, error %u\n", GetLastError());
379 ok(key == 0xdeadbeef, "expected 0xdeadbeef, got %lx\n", key);
380 ok(pov == &ov, "expected %p, got %p\n", &ov, pov);
381
383 status = pNtSetInformationFile(client, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
384 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
385
386 info.Flags = 0;
387 status = pNtQueryInformationFile(client, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
388 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
389 ok((info.Flags & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS) != 0, "got %08x\n", info.Flags);
390
391 ret = WriteFile(client, buf, sizeof(buf), &num_bytes, &ov);
392 ok(ret, "WriteFile failed, error %u\n", GetLastError());
393 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %u\n", num_bytes);
394
395 pov = (void *)0xdeadbeef;
396 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 1000);
397 ok(!ret, "GetQueuedCompletionStatus succeeded\n");
398 ok(pov == NULL, "expected NULL, got %p\n", pov);
399
402 CloseHandle(pipe);
404}
#define CreateFileW
Definition: compat.h:741
USHORT port
Definition: uri.c:228
@ FileIoCompletionNotificationInformation
Definition: from_kernel.h:102
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:65
#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS
Definition: iocompl.c:22
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:131
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
static const WCHAR testpipe[]
Definition: pipe.c:116
HANDLE hEvent
Definition: winbase.h:820
Definition: copy.c:22
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by START_TEST().

◆ test_create()

static void test_create ( void  )
static

Definition at line 220 of file pipe.c.

221{
222 HANDLE hserver;
224 int j, k;
228
231 static const DWORD pipe_config[]= { 1, 0, 2 };
232
233 for (j = 0; j < sizeof(sharing) / sizeof(DWORD); j++) {
234 for (k = 0; k < sizeof(access) / sizeof(DWORD); k++) {
235 HANDLE hclient;
236 BOOL should_succeed = TRUE;
237
238 res = create_pipe(&hserver, sharing[j], 0);
239 if (res) {
240 ok(0, "NtCreateNamedPipeFile returned %x, sharing: %x\n", res, sharing[j]);
241 continue;
242 }
243
244 res = listen_pipe(hserver, hEvent, &iosb, FALSE);
245 ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res);
246
247 res = pNtQueryInformationFile(hserver, &iosb, &info, sizeof(info), (FILE_INFORMATION_CLASS)24);
248 ok(!res, "NtQueryInformationFile for server returned %x, sharing: %x\n", res, sharing[j]);
249 ok(info.NamedPipeConfiguration == pipe_config[j], "wrong duplex status for pipe: %d, expected %d\n",
250 info.NamedPipeConfiguration, pipe_config[j]);
251
252 hclient = CreateFileW(testpipe, access[k], 0, 0, OPEN_EXISTING, 0, 0);
253 if (hclient != INVALID_HANDLE_VALUE) {
254 res = pNtQueryInformationFile(hclient, &iosb, &info, sizeof(info), (FILE_INFORMATION_CLASS)24);
255 ok(!res, "NtQueryInformationFile for client returned %x, access: %x, sharing: %x\n",
256 res, access[k], sharing[j]);
257 ok(info.NamedPipeConfiguration == pipe_config[j], "wrong duplex status for pipe: %d, expected %d\n",
258 info.NamedPipeConfiguration, pipe_config[j]);
259
260 res = listen_pipe(hclient, hEvent, &iosb, FALSE);
261 ok(res == STATUS_ILLEGAL_FUNCTION, "expected STATUS_ILLEGAL_FUNCTION, got %x\n", res);
262 CloseHandle(hclient);
263 }
264
265 if (access[k] & GENERIC_WRITE)
266 should_succeed &= !!(sharing[j] & FILE_SHARE_WRITE);
267 if (access[k] & GENERIC_READ)
268 should_succeed &= !!(sharing[j] & FILE_SHARE_READ);
269
270 if (should_succeed)
271 ok(hclient != INVALID_HANDLE_VALUE, "CreateFile failed for sharing %x, access: %x, GetLastError: %d\n",
273 else
274 ok(hclient == INVALID_HANDLE_VALUE, "CreateFile succeeded for sharing %x, access: %x\n", sharing[j], access[k]);
275
276 CloseHandle(hserver);
277 }
278 }
280}
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static ULONG access
Definition: pipe.c:68
int k
Definition: mpi.c:3369
#define STATUS_ILLEGAL_FUNCTION
Definition: ntstatus.h:411

Referenced by START_TEST().

◆ test_create_invalid()

static void test_create_invalid ( void  )
static

Definition at line 160 of file pipe.c.

161{
167 HANDLE handle, handle2;
169
170 pRtlInitUnicodeString(&name, testpipe_nt);
171
172 attr.Length = sizeof(attr);
173 attr.RootDirectory = 0;
174 attr.ObjectName = &name;
175 attr.Attributes = 0x40; /*case insensitive */
176 attr.SecurityDescriptor = NULL;
177 attr.SecurityQualityOfService = NULL;
178
179 timeout.QuadPart = -100000000;
180
181/* create a pipe with FILE_OVERWRITE */
182 res = pNtCreateNamedPipeFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ, 4 /*FILE_OVERWRITE*/,
183 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
184 todo_wine ok(res == STATUS_INVALID_PARAMETER, "NtCreateNamedPipeFile returned %x\n", res);
185 if (!res)
187
188/* create a pipe with FILE_OVERWRITE_IF */
189 res = pNtCreateNamedPipeFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ, 5 /*FILE_OVERWRITE_IF*/,
190 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
191 todo_wine ok(res == STATUS_INVALID_PARAMETER, "NtCreateNamedPipeFile returned %x\n", res);
192 if (!res)
194
195/* create a pipe with sharing = 0 */
196 res = pNtCreateNamedPipeFile(&handle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, 0, 2 /*FILE_CREATE*/,
197 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
198 ok(res == STATUS_INVALID_PARAMETER, "NtCreateNamedPipeFile returned %x\n", res);
199 if (!res)
201
202/* create a pipe without r/w access */
203 res = pNtCreateNamedPipeFile(&handle, SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /*FILE_CREATE*/,
204 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
205 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
206
207 res = pNtQueryInformationFile(handle, &iosb, &info, sizeof(info), (FILE_INFORMATION_CLASS)24);
208 ok(res == STATUS_ACCESS_DENIED, "NtQueryInformationFile returned %x\n", res);
209
210/* test FILE_CREATE creation disposition */
211 res = pNtCreateNamedPipeFile(&handle2, SYNCHRONIZE, &attr, &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /*FILE_CREATE*/,
212 0, 1, 0, 0, 0xFFFFFFFF, 500, 500, &timeout);
213 todo_wine ok(res == STATUS_ACCESS_DENIED, "NtCreateNamedPipeFile returned %x\n", res);
214 if (!res)
215 CloseHandle(handle2);
216
218}
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by START_TEST().

◆ test_file_info()

static void test_file_info ( void  )
static

Definition at line 1262 of file pipe.c.

1263{
1265
1267 PIPE_TYPE_MESSAGE, 4096 )) return;
1268
1271
1274
1277}
#define test_file_name(a)
Definition: pipe.c:1224
#define test_file_name_fail(a, b)
Definition: pipe.c:1212

Referenced by START_TEST(), and test_actctx().

◆ test_filepipeinfo()

static void test_filepipeinfo ( void  )
static

Definition at line 630 of file pipe.c.

631{
636 HANDLE hServer, hClient;
639
640 pRtlInitUnicodeString(&name, testpipe_nt);
641
642 attr.Length = sizeof(attr);
643 attr.RootDirectory = 0;
644 attr.ObjectName = &name;
645 attr.Attributes = 0x40; /* case insensitive */
646 attr.SecurityDescriptor = NULL;
647 attr.SecurityQualityOfService = NULL;
648
649 timeout.QuadPart = -100000000;
650
651 /* test with INVALID_HANDLE_VALUE */
652 res = pNtQueryInformationFile(INVALID_HANDLE_VALUE, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
653 ok(res == STATUS_OBJECT_TYPE_MISMATCH, "NtQueryInformationFile returned %x\n", res);
654
655 fpi.ReadMode = 0;
656 fpi.CompletionMode = 0;
657 res = pNtSetInformationFile(INVALID_HANDLE_VALUE, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
658 ok(res == STATUS_OBJECT_TYPE_MISMATCH, "NtSetInformationFile returned %x\n", res);
659
660 /* server end with read-only attributes */
661 res = pNtCreateNamedPipeFile(&hServer, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb,
662 FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /* FILE_CREATE */,
663 0, 0, 0, 1, 0xFFFFFFFF, 500, 500, &timeout);
664 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
665
666 check_pipe_handle_state(hServer, 0, 1);
667
669 ok(hClient != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_PIPE_BUSY) /* > Win 8 */,
670 "can't open pipe, GetLastError: %x\n", GetLastError());
671
672 check_pipe_handle_state(hServer, 0, 1);
673 check_pipe_handle_state(hClient, 0, 0);
674
675 fpi.ReadMode = 0;
676 fpi.CompletionMode = 0;
677 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
678 ok(res == STATUS_ACCESS_DENIED, "NtSetInformationFile returned %x\n", res);
679
680 check_pipe_handle_state(hServer, 0, 1);
681 check_pipe_handle_state(hClient, 0, 0);
682
683 fpi.ReadMode = 1; /* invalid on a byte stream pipe */
684 fpi.CompletionMode = 1;
685 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
686 ok(res == STATUS_ACCESS_DENIED, "NtSetInformationFile returned %x\n", res);
687
688 check_pipe_handle_state(hServer, 0, 1);
689 check_pipe_handle_state(hClient, 0, 0);
690
691 if (hClient != INVALID_HANDLE_VALUE)
692 {
693 fpi.ReadMode = 1; /* invalid on a byte stream pipe */
694 fpi.CompletionMode = 1;
695 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
696 ok(res == STATUS_INVALID_PARAMETER, "NtSetInformationFile returned %x\n", res);
697 }
698
699 check_pipe_handle_state(hServer, 0, 1);
700 check_pipe_handle_state(hClient, 0, 0);
701
702 if (hClient != INVALID_HANDLE_VALUE)
703 {
704 fpi.ReadMode = 0;
705 fpi.CompletionMode = 1;
706 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
707 ok(!res, "NtSetInformationFile returned %x\n", res);
708 }
709
710 check_pipe_handle_state(hServer, 0, 1);
711 check_pipe_handle_state(hClient, 0, 1);
712
713 if (hClient != INVALID_HANDLE_VALUE)
714 {
715 fpi.ReadMode = 0;
716 fpi.CompletionMode = 2; /* not in range 0-1 */
717 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
718 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %x\n", res);
719
720 fpi.ReadMode = 2; /* not in range 0-1 */
721 fpi.CompletionMode = 0;
722 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
723 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %x\n", res);
724 }
725
726 CloseHandle(hClient);
727
728 check_pipe_handle_state(hServer, 0, 1);
729
730 fpi.ReadMode = 0;
731 fpi.CompletionMode = 0;
732 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
733 ok(res == STATUS_ACCESS_DENIED, "NtSetInformationFile returned %x\n", res);
734
735 CloseHandle(hServer);
736
737 /* message mode server with read/write attributes */
738 res = pNtCreateNamedPipeFile(&hServer, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb,
739 FILE_SHARE_READ | FILE_SHARE_WRITE, 2 /* FILE_CREATE */,
740 0, 1, 1, 0, 0xFFFFFFFF, 500, 500, &timeout);
741 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
742
743 check_pipe_handle_state(hServer, 1, 0);
744
746 ok(hClient != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_PIPE_BUSY) /* > Win 8 */,
747 "can't open pipe, GetLastError: %x\n", GetLastError());
748
749 check_pipe_handle_state(hServer, 1, 0);
750 check_pipe_handle_state(hClient, 0, 0);
751
752 if (hClient != INVALID_HANDLE_VALUE)
753 {
754 fpi.ReadMode = 1;
755 fpi.CompletionMode = 1;
756 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
757 ok(!res, "NtSetInformationFile returned %x\n", res);
758 }
759
760 check_pipe_handle_state(hServer, 1, 0);
761 check_pipe_handle_state(hClient, 1, 1);
762
763 fpi.ReadMode = 0;
764 fpi.CompletionMode = 1;
765 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
766 ok(!res, "NtSetInformationFile returned %x\n", res);
767
768 check_pipe_handle_state(hServer, 0, 1);
769 check_pipe_handle_state(hClient, 1, 1);
770
771 if (hClient != INVALID_HANDLE_VALUE)
772 {
773 fpi.ReadMode = 0;
774 fpi.CompletionMode = 2; /* not in range 0-1 */
775 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
776 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %x\n", res);
777
778 fpi.ReadMode = 2; /* not in range 0-1 */
779 fpi.CompletionMode = 0;
780 res = pNtSetInformationFile(hClient, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
781 ok(res == STATUS_INVALID_PARAMETER || broken(!res) /* < Vista */, "NtSetInformationFile returned %x\n", res);
782 }
783
784 CloseHandle(hClient);
785
786 check_pipe_handle_state(hServer, 0, 1);
787
788 fpi.ReadMode = 1;
789 fpi.CompletionMode = 0;
790 res = pNtSetInformationFile(hServer, &iosb, &fpi, sizeof(fpi), (FILE_INFORMATION_CLASS)23);
791 ok(!res, "NtSetInformationFile returned %x\n", res);
792
793 check_pipe_handle_state(hServer, 1, 0);
794
795 CloseHandle(hServer);
796}
#define broken(x)
Definition: _sntprintf.h:21
#define check_pipe_handle_state(handle, r, c)
Definition: pipe.c:628
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:273
#define ERROR_PIPE_BUSY
Definition: winerror.h:283

Referenced by START_TEST().

◆ test_nonalertable()

static void test_nonalertable ( void  )
static

Definition at line 511 of file pipe.c.

512{
515 HANDLE hPipe;
518 DWORD ret;
519
520 memset(&iosb, 0x55, sizeof(iosb));
521
523 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError());
524
526 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
527
528 hThread = CreateThread(NULL, 0, &thread, 0, 0, 0);
529 ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %x\n", GetLastError());
530
532 ret = pQueueUserAPC(&userapc, GetCurrentThread(), 0);
533 ok(ret, "can't queue user apc, GetLastError: %x\n", GetLastError());
534
535 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
536 todo_wine ok(!res, "NtFsControlFile returned %x\n", res);
537
538 ok(open_succeeded, "couldn't open client side pipe\n");
539 todo_wine ok(!U(iosb).Status, "Wrong iostatus %x\n", U(iosb).Status);
540 todo_wine ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
541
542 ok(!ioapc_called, "IOAPC ran too early\n");
543 ok(!userapc_called, "user apc ran too early\n");
544
545 SleepEx(0, TRUE); /* alertable wait state */
546
547 ok(ioapc_called, "IOAPC didn't run\n");
548 ok(userapc_called, "user apc didn't run\n");
549
553 CloseHandle(hPipe);
554}
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: pipe.c:59

Referenced by START_TEST().

◆ test_overlapped()

static void test_overlapped ( void  )
static

Definition at line 282 of file pipe.c.

283{
286 HANDLE hPipe;
287 HANDLE hClient;
289
291 ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError());
292
293 res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
294 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
295
296 memset(&iosb, 0x55, sizeof(iosb));
297 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
298 ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res);
299 ok(U(iosb).Status == 0x55555555, "iosb.Status got changed to %x\n", U(iosb).Status);
300
302 ok(hClient != INVALID_HANDLE_VALUE, "can't open pipe, GetLastError: %x\n", GetLastError());
303
304 ok(U(iosb).Status == 0, "Wrong iostatus %x\n", U(iosb).Status);
305 ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n");
306
307 ok(!ioapc_called, "IOAPC ran too early\n");
308
309 SleepEx(0, TRUE); /* alertable wait state */
310
311 ok(ioapc_called, "IOAPC didn't run\n");
312
313 CloseHandle(hPipe);
314 CloseHandle(hClient);
315
316 res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */);
317 ok(!res, "NtCreateNamedPipeFile returned %x\n", res);
318
320 ok(hClient != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_PIPE_BUSY) /* > Win 8 */,
321 "can't open pipe, GetLastError: %x\n", GetLastError());
322
323 if (hClient != INVALID_HANDLE_VALUE)
324 {
326 memset(&iosb, 0x55, sizeof(iosb));
327 res = listen_pipe(hPipe, hEvent, &iosb, TRUE);
328 ok(res == STATUS_PIPE_CONNECTED, "NtFsControlFile returned %x\n", res);
329 ok(U(iosb).Status == 0x55555555, "iosb.Status got changed to %x\n", U(iosb).Status);
330 ok(!is_signaled(hEvent), "hEvent not signaled\n");
331
332 CloseHandle(hClient);
333 }
334
335 CloseHandle(hPipe);
337}
#define STATUS_PIPE_CONNECTED
Definition: ntstatus.h:414

◆ test_peek()

static void test_peek ( HANDLE  pipe)
static

Definition at line 805 of file pipe.c.

806{
809 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
811
812 memset(&iosb, 0x55, sizeof(iosb));
813 status = NtFsControlFile(pipe, NULL, NULL, NULL, &iosb, FSCTL_PIPE_PEEK, NULL, 0, &buf, sizeof(buf));
814 ok(!status || status == STATUS_PENDING, "NtFsControlFile failed: %x\n", status);
815 ok(!iosb.Status, "iosb.Status = %x\n", iosb.Status);
816 ok(buf.ReadDataAvailable == 1, "ReadDataAvailable = %u\n", buf.ReadDataAvailable);
817
819 memset(&iosb, 0x55, sizeof(iosb));
820 status = NtFsControlFile(pipe, event, NULL, NULL, &iosb, FSCTL_PIPE_PEEK, NULL, 0, &buf, sizeof(buf));
821 ok(!status || status == STATUS_PENDING, "NtFsControlFile failed: %x\n", status);
822 ok(buf.ReadDataAvailable == 1, "ReadDataAvailable = %u\n", buf.ReadDataAvailable);
823 ok(!iosb.Status, "iosb.Status = %x\n", iosb.Status);
824 ok(is_signaled(event), "event is not signaled\n");
825
827}
#define FSCTL_PIPE_PEEK
Definition: winioctl.h:196

Referenced by read_pipe_test().

◆ test_security_info()

static void test_security_info ( void  )
static

Definition at line 1379 of file pipe.c.

1380{
1381 char sec_desc[SECURITY_DESCRIPTOR_MIN_LENGTH];
1383 SECURITY_ATTRIBUTES sec_attr;
1384 TOKEN_OWNER *process_owner;
1385 HANDLE server, client, server2;
1386 SID *world_sid, *local_sid;
1387 ULONG length;
1389 BOOL ret;
1390
1391 trace("security tests...\n");
1392
1393 process_owner = get_current_owner();
1395 world_sid = well_known_sid(WinWorldSid);
1396 local_sid = well_known_sid(WinLocalSid);
1397
1399 ok(ret, "InitializeSecurityDescriptor failed\n");
1400
1401 ret = SetSecurityDescriptorOwner(sec_desc, process_owner->Owner, FALSE);
1402 ok(ret, "SetSecurityDescriptorOwner failed\n");
1403
1404 ret = SetSecurityDescriptorGroup(sec_desc, process_group->PrimaryGroup, FALSE);
1405 ok(ret, "SetSecurityDescriptorGroup failed\n");
1406
1408 0x20000, 0x20000, 0, NULL);
1409 ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %u\n", GetLastError());
1410
1412 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
1413
1414 test_group(server, process_group->PrimaryGroup, TRUE);
1415 test_group(client, process_group->PrimaryGroup, TRUE);
1416
1417 /* set server group, client changes as well */
1418 ret = SetSecurityDescriptorGroup(sec_desc, world_sid, FALSE);
1419 ok(ret, "SetSecurityDescriptorGroup failed\n");
1421 ok(status == STATUS_SUCCESS, "NtSetSecurityObject failed: %08x\n", status);
1422
1423 test_group(server, world_sid, FALSE);
1424 test_group(client, world_sid, FALSE);
1425
1426 /* new instance of pipe server has the same security descriptor */
1428 0x20000, 0x20000, 0, NULL);
1429 ok(server2 != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %u\n", GetLastError());
1430 test_group(server2, world_sid, FALSE);
1431
1432 /* set client group, server changes as well */
1433 ret = SetSecurityDescriptorGroup(sec_desc, local_sid, FALSE);
1434 ok(ret, "SetSecurityDescriptorGroup failed\n");
1436 ok(status == STATUS_SUCCESS, "NtSetSecurityObject failed: %08x\n", status);
1437
1438 test_group(server, local_sid, FALSE);
1439 test_group(client, local_sid, FALSE);
1440 test_group(server2, local_sid, FALSE);
1441
1443 /* SD is preserved after closing server object */
1444 test_group(client, local_sid, TRUE);
1446
1447 server = server2;
1449 ok(client != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
1450
1451 test_group(client, local_sid, FALSE);
1452
1454 ok(ret, "DisconnectNamedPipe failed: %u\n", GetLastError());
1455
1456 /* disconnected server may be queried for security info, but client does not */
1457 test_group(server, local_sid, FALSE);
1459 NULL, 0, &length);
1460 ok(status == STATUS_PIPE_DISCONNECTED, "NtQuerySecurityObject returned %08x\n", status);
1462 ok(status == STATUS_PIPE_DISCONNECTED, "NtQuerySecurityObject returned %08x\n", status);
1463
1464 /* attempting to create another pipe instance with specified sd fails */
1465 sec_attr.nLength = sizeof(sec_attr);
1466 sec_attr.lpSecurityDescriptor = sec_desc;
1467 sec_attr.bInheritHandle = FALSE;
1468 ret = SetSecurityDescriptorGroup(sec_desc, local_sid, FALSE);
1469 ok(ret, "SetSecurityDescriptorGroup failed\n");
1471 0x20000, 0x20000, 0, &sec_attr);
1472 todo_wine
1474 "CreateNamedPipe failed: %u\n", GetLastError());
1475 if (server2 != INVALID_HANDLE_VALUE) CloseHandle(server2);
1476
1479
1481 0x20000, 0x20000, 0, &sec_attr);
1482 ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %u\n", GetLastError());
1483 test_group(server, local_sid, FALSE);
1485
1486 HeapFree(GetProcessHeap(), 0, process_owner);
1488 HeapFree(GetProcessHeap(), 0, world_sid);
1489 HeapFree(GetProcessHeap(), 0, local_sid);
1490}
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
static HRESULT process_group(struct ciffile *file, struct inf_section *section, const char *section_name)
Definition: icif.c:1619
static TOKEN_PRIMARY_GROUP * get_current_group(void)
Definition: pipe.c:1324
static TOKEN_OWNER * get_current_owner(void)
Definition: pipe.c:1301
static SID * well_known_sid(WELL_KNOWN_SID_TYPE sid_type)
Definition: pipe.c:1347
static PIO_STATUS_BLOCK void ULONG length
Definition: pipe.c:76
#define test_group(a, b, c)
Definition: pipe.c:1359
#define GENERIC_ALL
Definition: nt_native.h:92
#define WRITE_OWNER
Definition: nt_native.h:60
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
Definition: sec.c:288
NTSTATUS WINAPI NtSetSecurityObject(HANDLE Handle, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor)
LPVOID lpSecurityDescriptor
Definition: compat.h:193
PSID Owner
Definition: setypes.h:1028
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define SECURITY_DESCRIPTOR_MIN_LENGTH
Definition: setypes.h:815

Referenced by START_TEST().

◆ test_volume_info()

static void test_volume_info ( void  )
static

Definition at line 1179 of file pipe.c.

1180{
1181 FILE_FS_DEVICE_INFORMATION *device_info;
1183 HANDLE read, write;
1184 char buffer[128];
1186
1188 PIPE_TYPE_MESSAGE, 4096 )) return;
1189
1190 memset( buffer, 0xaa, sizeof(buffer) );
1191 status = pNtQueryVolumeInformationFile( read, &iosb, buffer, sizeof(buffer), FileFsDeviceInformation );
1192 ok( status == STATUS_SUCCESS, "NtQueryVolumeInformationFile failed: %x\n", status );
1193 ok( iosb.Information == sizeof(*device_info), "Information = %lu\n", iosb.Information );
1194 device_info = (FILE_FS_DEVICE_INFORMATION*)buffer;
1195 ok( device_info->DeviceType == FILE_DEVICE_NAMED_PIPE, "DeviceType = %u\n", device_info->DeviceType );
1197 "Characteristics = %x\n", device_info->Characteristics );
1198
1199 memset( buffer, 0xaa, sizeof(buffer) );
1200 status = pNtQueryVolumeInformationFile( write, &iosb, buffer, sizeof(buffer), FileFsDeviceInformation );
1201 ok( status == STATUS_SUCCESS, "NtQueryVolumeInformationFile failed: %x\n", status );
1202 ok( iosb.Information == sizeof(*device_info), "Information = %lu\n", iosb.Information );
1203 device_info = (FILE_FS_DEVICE_INFORMATION*)buffer;
1204 ok( device_info->DeviceType == FILE_DEVICE_NAMED_PIPE, "DeviceType = %u\n", device_info->DeviceType );
1206 "Characteristics = %x\n", device_info->Characteristics );
1207
1208 CloseHandle( read );
1209 CloseHandle( write );
1210}
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL
Definition: btrfs_drv.h:156
@ FileFsDeviceInformation
Definition: from_kernel.h:222
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:123

Referenced by START_TEST().

◆ thread()

static DWORD WINAPI thread ( PVOID  main_thread)
static

Definition at line 413 of file pipe.c.

414{
415 HANDLE h;
416
417 Sleep(400);
418
419 if (main_thread) {
420 DWORD ret;
422 ret = pQueueUserAPC(&userapc, main_thread, 0);
423 ok(ret, "can't queue user apc, GetLastError: %x\n", GetLastError());
424 CloseHandle(main_thread);
425 }
426
427 Sleep(400);
428
430
431 if (h != INVALID_HANDLE_VALUE) {
433 Sleep(100);
434 CloseHandle(h);
435 } else
437
438 return 0;
439}
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

◆ userapc()

static void CALLBACK userapc ( ULONG_PTR  dwParam)
static

Definition at line 407 of file pipe.c.

408{
410}

Referenced by test_alertable(), test_nonalertable(), and thread().

◆ void()

static void ( WINAPI pRtlInitUnicodeString)
static

◆ well_known_sid()

static SID * well_known_sid ( WELL_KNOWN_SID_TYPE  sid_type)
static

Definition at line 1347 of file pipe.c.

1348{
1350 SID *sid;
1351 BOOL ret;
1352
1354 ret = CreateWellKnownSid(sid_type, NULL, sid, &size);
1355 ok(ret, "CreateWellKnownSid failed: %u\n", GetLastError());
1356 return sid;
1357}
FT_UInt sid
Definition: cffcmap.c:139
BOOL WINAPI CreateWellKnownSid(IN WELL_KNOWN_SID_TYPE WellKnownSidType, IN PSID DomainSid OPTIONAL, OUT PSID pSid, IN OUT DWORD *cbSid)
Definition: security.c:722
#define SECURITY_MAX_SID_SIZE
Definition: setypes.h:486

Referenced by test_security_info().

Variable Documentation

◆ access

Definition at line 68 of file pipe.c.

Referenced by test_create().

◆ apc

Definition at line 67 of file pipe.c.

Referenced by read_pipe_test().

◆ apc_context

Definition at line 67 of file pipe.c.

◆ attr

◆ bInheritHandle

◆ buffer

Definition at line 76 of file pipe.c.

◆ class

Definition at line 77 of file pipe.c.

◆ code

◆ completion_mode

Definition at line 72 of file pipe.c.

◆ dispo

Definition at line 70 of file pipe.c.

◆ dwData

HANDLE ULONG_PTR dwData

Definition at line 83 of file pipe.c.

◆ dwThreadId

BOOL DWORD dwThreadId

Definition at line 82 of file pipe.c.

◆ event

Definition at line 67 of file pipe.c.

◆ FileInformation

◆ FileInformationClass

◆ hThread

HANDLE hThread

Definition at line 83 of file pipe.c.

◆ in_buffer

Definition at line 67 of file pipe.c.

◆ in_size

Definition at line 67 of file pipe.c.

◆ inbound_quota

◆ info_class

◆ io

Definition at line 67 of file pipe.c.

◆ io_status

Definition at line 78 of file pipe.c.

◆ ioapc_called

BOOL ioapc_called
static

◆ iosb

◆ IoStatusBlock

_Out_ PIO_STATUS_BLOCK IoStatusBlock

Definition at line 75 of file pipe.c.

Referenced by AccpOpenNamedObject(), AcsHlpSendCommand(), AddPartitionToDisk(), AddRemoteDatabaseEntry(), AfdAPC(), AfdInfoAPC(), AllocConsole(), ApcRoutine(), ApphelpCacheQueryInfo(), BaseMarkFileForDelete(), BasepCopyFileExW(), BasepDoTapeOperation(), BasepIoCompletion(), BasepIoCompletionSimple(), BasepMapFile(), BasepNotifyTrackingService(), BasepOpenFileForMove(), BatteryIoctl(), Beep(), BroadcastOpen(), CabinetExtractFile(), CabinetOpen(), CallCacheControl(), CancelIo(), clean_main(), CmBattSendDownStreamIrp(), CmBattWaitWakeLoop(), CmpFileFlush(), CmpFileRead(), CmpFileSetSize(), CmpFileWrite(), CmpInitializeHive(), CmpOpenHiveFiles(), CommandDumpSector(), CommandPartInfo(), CommitWaveBufferApc(), CompareFileContents(), CompBattGetDeviceObjectPointer(), CopyLoop(), CreateDirectoryExW(), CreateDirectoryW(), CreateFileW(), CreateHardLinkW(), CreateIoCompletionPort(), CreateProcessInternalW(), CreateRegistryFile(), CreateRemoteDatabaseWorker(), CreateSymbolicLinkW(), DbgkCreateThread(), DbgkpPostFakeModuleMessages(), DbgkpSectionToFileHandle(), DeleteFileW(), DeleteRemoteDatabaseEntry(), DismountVolume(), DoesPathExist(), EngLoadModuleEx(), Fat12WriteBootSector(), Fat12WriteFAT(), Fat12WriteRootDirectory(), Fat16WriteBootSector(), Fat16WriteFAT(), Fat16WriteRootDirectory(), Fat32WriteBootSector(), Fat32WriteFAT(), Fat32WriteFsInfo(), Fat32WriteRootDirectory(), FatWipeSectors(), Fatx16WriteFAT(), Fatx32WriteFAT(), FatxWriteBootSector(), FatxWriteRootDirectory(), FdoSendInquiry(), FillConsoleOutputAttribute(), FillConsoleOutputCharacterA(), FilterConnectCommunicationPort(), FindFirstChangeNotificationW(), FindFirstFileExW(), FindFirstStreamW(), FindNextFileW(), FindNTOSInstallations(), FlushConsoleInputBuffer(), FlushFileBuffers(), FlushViewOfFile(), FsRecGetDeviceSectors(), FsRecGetDeviceSectorSize(), FsRecReadBlock(), FsRtlBalanceReads(), FsRtlpOpenDev(), FsRtlpRegisterProviderWithMUP(), FsRtlProcessFileLock(), FstubGetDiskGeometry(), FstubReadSector(), FstubWriteSector(), GetCompressedFileSizeW(), GetConnectionHandle(), GetConsoleScreenBufferInfo(), GetDiskFreeSpaceExW(), GetDiskFreeSpaceW(), GetDriveTypeAndCharacteristics(), GetDriveTypeW(), GetFileAttributesByHandle(), GetFileInformationByHandle(), GetFileSize(), GetFileSizeEx(), GetFileSystem(), GetFileSystemInfo(), GetFileSystemName_UStr(), GetFileSystemNameWorker(), GetFileTime(), GetPhysicalFileSize(), GetRemoteDatabaseEntry(), GetRemoteDatabaseSize(), GetVolumeInformationW(), GetVolumeNameForRoot(), GetVolumeType(), HalpDeleteMountLetter(), HalpEnableAutomaticDriveLetterAssignment(), HalpGetFullGeometry(), HalpIsOldStyleFloppy(), HalpNextMountLetter(), HalpQueryPartitionType(), HalpSetMountLetter(), HidClass_DeviceControl(), HidClass_Write(), HidUsb_ResetPort(), HvpQueryHiveSize(), Icmp6CreateFile(), Icmp6SendEcho2(), IcmpCreateFile(), IcmpSendEcho(), IcmpSendEcho2(), InferFileSystem(), InferFileSystemWorker(), InfOpenFile(), InfWriteFile(), IniCacheLoad(), IniCacheLoadByHandle(), IniCacheSave(), IniCacheSaveByHandle(), InstallBootCodeToDisk(), InstallBootCodeToFile(), InstallBtrfsBootCode(), InstallFat32BootCode(), InstallFatBootCode(), InstallMbrBootCode(), InstallNtfsBootCode(), InstallSetupInfFile(), IntAgpGetInterface(), IntGetFullFileName(), IntUpdateControlKeyState(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IoBuildSynchronousFsdRequest(), IoCreateFile(), IoCreateFileSpecifyDeviceObjectHint(), IoGetBootDiskInformation(), IoGetDmaAdapter(), IopCancelPrepareDeviceForRemoval(), IopCloseFile(), IopComputeHarddiskDerangements(), IopCreateArcNamesCd(), IopCreateArcNamesDisk(), IopCreateDeviceInstancePath(), IopCreateFile(), IopCreateLogFile(), IopDeviceFsIoControl(), IopFilterResourceRequirements(), IopFinalizeAsynchronousIo(), IopGetBasicInformationFile(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopGetFileInformation(), IopGetSetSecurityObject(), IopInitiatePnpIrp(), IopLoadFileSystemDriver(), IopMarkBootPartition(), IopMountVolume(), IopOpenLinkOrRenameTarget(), IopParseDevice(), IopPrepareDeviceForRemoval(), IopQueryCompatibleIds(), IopQueryDeviceInformation(), IopQueryHardwareIds(), IopStartRamdisk(), IopSynchronousCall(), IopWriteLogFile(), IoRequestDeviceEject(), IoSetInformation(), IoVerifyVolume(), IoVolumeDeviceToDosName(), IsFtVolume(), IssueSyncIoControlRequest(), IsThisARootDirectory(), IsValidNTOSInstallation(), KernelModeTest(), KmtInitTestFiles(), KsecDeviceIoControl(), KsecOpenDevice(), KsiCreateObjectType(), KspCreateObjectType(), KspSynchronousIoControlDeviceCompletion(), KsQueryInformationFile(), KsReadFile(), KsStreamIo(), KsSynchronousIoControlDevice(), KsWriteFile(), LdrpCreateDllSection(), LdrVerifyImageMatchesChecksum(), LockFile(), LogfBackupFile(), LogfCreate(), LogfpFlushFile(), LogfpReadFile(), LogfpSetFileSize(), LogfpWriteFile(), main(), MakeBeep(), MapFile(), MmCheckSystemImage(), MmLoadSystemImage(), MountMgrNotifyNameChange(), MountMgrValidateBackPointer(), MountMgrVolumeMountPointChanged(), MoveFileWithProgressW(), MyDeleteFile(), NdisOpenFile(), NpCheckClientPipe_(), NpCheckServerPipe_(), NpControlPipe(), NpCreatePipeEx(), NpOpenPipeEx(), NpQueryPipe_(), NpReadPipe(), NpWaitPipe(), NpWritePipe(), nt_mailslot_test(), NtCancelIoFile(), NtCreateFile(), NtCreateMailslotFile(), NtCreateNamedPipeFile(), NtDeviceIoControlFile(), NtFlushBuffersFile(), NtFlushVirtualMemory(), NtFsControlFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtNotifyChangeKey(), NtOpenFile(), NtQueryDirectoryFile(), NtQueryInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtRemoveIoCompletion(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), NtWriteFile(), OnlineMountedVolumes(), OpenAndMapFile(), OpenBootStore_UStr(), OpenDevice(), OpenDirectoryByHandleOrPath(), OpenFile(), OpenIniBootLoaderStore(), OpenKeyboard(), OpenRemoteDatabase(), PciGetDeviceCapabilities(), PciQueryForPciBusInterface(), PciSendIoctl(), PiInitializeDevNode(), PopAddRemoveSysCapsCallback(), PopFlushVolumeWorker(), PopSendQuerySystemPowerState(), PopSendSetSystemPowerState(), PortSendInquiry(), PrivMoveFileIdentityW(), ProtectBootIni(), PsLocateSystemDll(), QueryDeviceInformation(), QueryFileInfo(), QuerySuggestedLinkName(), QueryVolumeName(), RawQueryFsSizeInfo(), ReadBlock(), ReadBootCodeByHandle(), ReadBootCodeFromFile(), ReadDirectoryChangesW(), ReconcileThisDatabaseWithMasterWorker(), RegisterUncProvider(), RegNotifyChangeKeyValue(), RegRestoreKeyW(), RegSaveKeyW(), RemoveDirectoryW(), ReplaceFileW(), RosSymZwReadFile(), RosSymZwSeekFile(), RtlCreateBootStatusDataFile(), RtlCreateSystemVolumeInformationFolder(), RtlGetSetBootStatusData(), RtlLockBootStatusData(), RtlpMapFile(), RtlpSysVolTakeOwnership(), RtlpWorkerThreadProc(), RtlSetCurrentDirectory_U(), RtlSetIoCompletionCallback(), RtlUnlockBootStatusData(), SaveBootSector(), SdbpOpenMemMappedFile(), SendIoctl(), SendLinkCreated(), SendLinkDeleted(), SendOnlineNotification(), SetAttributesOnFile(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleOutputCP(), SetConsoleTextAttribute(), SetEndOfFile(), SetFileAttributesByHandle(), SetFileAttributesW(), SetFileCompletionNotificationModes(), SetFileInformationByHandle(), SetFilePointer(), SetFilePointerEx(), SetFileShortNameW(), SetFileTime(), SetFileValidData(), SetLastWriteTime(), SetupCopyFile(), SetupCreateSingleDirectory(), SetupDeleteFile(), SetupMoveFile(), SetVolumeLabelW(), SimpleErrorChecks(), SmpCreateVolumeDescriptors(), SmpDeletePagingFile(), SmpGetPagingFileSize(), SmpGetVolumeFreeSpace(), SmpInitializeKnownDllsInternal(), SmpProcessFileRenames(), SockAsyncSelectCompletionRoutine(), SpeakerInitialize(), START_TEST(), StreamClassRWCompletion(), TCPSendIoctl(), TdiCall(), Test_ImageSection(), Test_ImageSection2(), TestFileFsAttributeInformation(), TestFileFsDeviceInformation(), TestFileFsVolumeInformation(), TestFileInfo(), TestIoCreateFile(), TestKM(), TestSymlinks(), TestVolumeInfo(), TruncateRemoteDatabase(), UnprotectBootIni(), USBH_EnableParentPort(), USBH_GetPortStatus(), USBH_SyncGetDeviceHandle(), USBH_SyncGetHubCount(), USBH_SyncGetRootHubPdo(), USBH_SyncSubmitUrb(), USBPORT_IsCompanionController(), USBPORT_QueryPciBusInterface(), UserModeTest(), VfatFlushVolume(), VfatSetRenameInformation(), VideoPortCheckForDeviceExistence(), ViReadFile(), W32kOpenFile(), WahCreateSocketHandle(), WahOpenHandleHelper(), WaitForKeyboard(), WaitNamedPipeW(), WdmAudOpenSysAudioDevice(), WriteConsole(), WriteConsoleOutputCharacterA(), WriteConsoleOutputCharacterW(), WriteRemoteDatabaseEntry(), WSPCloseSocket(), xHalExamineMBR(), xHalGetPartialGeometry(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), xHalIoWritePartitionTable(), and xOpenFile().

◆ len

Definition at line 77 of file pipe.c.

◆ Length

Definition at line 75 of file pipe.c.

◆ length

Definition at line 76 of file pipe.c.

Referenced by test_security_info().

◆ max_inst

◆ open_succeeded

BOOL open_succeeded
static

Definition at line 412 of file pipe.c.

Referenced by test_alertable(), test_nonalertable(), and thread().

◆ options

◆ out_buffer

Definition at line 67 of file pipe.c.

◆ out_size

◆ outbound_quota

◆ pipe_type

Definition at line 71 of file pipe.c.

Referenced by read_pipe_test().

◆ ptr

Definition at line 77 of file pipe.c.

◆ read_mode

◆ sharing

◆ source

Definition at line 80 of file pipe.c.

◆ testpipe

const WCHAR testpipe[]
static
Initial value:
= { '\\', '\\', '.', '\\', 'p', 'i', 'p', 'e', '\\',
't', 'e', 's', 't', 'p', 'i', 'p', 'e', 0 }

Definition at line 116 of file pipe.c.

Referenced by test_completion(), test_create(), test_filepipeinfo(), test_overlapped(), and thread().

◆ testpipe_nt

const WCHAR testpipe_nt[]
static
Initial value:
= { '\\', '?', '?', '\\', 'p', 'i', 'p', 'e', '\\',
't', 'e', 's', 't', 'p', 'i', 'p', 'e', 0 }

Definition at line 118 of file pipe.c.

Referenced by create_pipe(), test_create_invalid(), and test_filepipeinfo().

◆ timeout

◆ userapc_called

BOOL userapc_called
static

Definition at line 406 of file pipe.c.

Referenced by test_alertable(), test_nonalertable(), thread(), and userapc().