ReactOS  0.4.15-dev-1070-ge1a01de
npfs.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Kernel-Mode Test Suite NPFS helper declarations
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #ifndef _KMTEST_NPFS_H_
9 #define _KMTEST_NPFS_H_
10 
11 #define DEVICE_NAMED_PIPE L"\\Device\\NamedPipe"
12 
13 #define BYTE_STREAM FILE_PIPE_BYTE_STREAM_MODE
15 #define MESSAGE FILE_PIPE_MESSAGE_MODE
17 #define QUEUE FILE_PIPE_QUEUE_OPERATION
18 #define COMPLETE FILE_PIPE_COMPLETE_OPERATION
19 #define INBOUND FILE_PIPE_INBOUND
20 #define OUTBOUND FILE_PIPE_OUTBOUND
21 #define DUPLEX FILE_PIPE_FULL_DUPLEX
22 
25  OUT PHANDLE ServerHandle,
26  IN PCWSTR PipePath,
27  IN ULONG ReadMode,
28  IN ULONG CompletionMode,
29  IN ULONG NamedPipeType,
31  IN ULONG MaximumInstances,
32  IN ULONG InboundQuota,
33  IN ULONG OutboundQuota,
37  IN PLARGE_INTEGER DefaultTimeout OPTIONAL);
38 
41  OUT PHANDLE ServerHandle,
42  IN PCWSTR PipePath,
43  IN ULONG ReadMode,
44  IN ULONG CompletionMode,
45  IN ULONG NamedPipeType,
46  IN ULONG NamedPipeConfiguration,
47  IN ULONG MaximumInstances,
48  IN ULONG InboundQuota,
49  IN ULONG OutboundQuota);
50 
53  OUT PHANDLE ClientHandle,
54  IN PCWSTR PipePath,
59 
62  OUT PHANDLE ClientHandle,
63  IN PCWSTR PipePath,
64  IN ULONG NamedPipeConfiguration);
65 
72 
73 #define NpListenPipe(ServerHandle) NpControlPipe(ServerHandle, FSCTL_PIPE_LISTEN, NULL, 0)
74 #define NpDisconnectPipe(ServerHandle) NpControlPipe(ServerHandle, FSCTL_PIPE_DISCONNECT, NULL, 0)
75 
78  IN PCWSTR PipeName,
80 
87 
91  IN const VOID *Buffer,
94 
95 #define NpCheckServerPipe(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps) \
96  NpCheckServerPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, __FILE__, __LINE__)
97 
98 #define NpCheckServerPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file, line) \
99  NpCheckServerPipe_(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file ":" KMT_STRINGIZE(line))
100 
101 VOID
103  IN HANDLE ServerHandle,
104  /* PipeInformation */
105  IN ULONG ReadMode,
106  IN ULONG CompletionMode,
107  /* PipeLocalInformation */
108  IN ULONG NamedPipeType,
109  IN ULONG NamedPipeConfiguration,
110  IN ULONG MaximumInstances,
111  IN ULONG CurrentInstances,
112  IN ULONG InboundQuota,
113  IN ULONG ReadDataAvailable,
114  IN ULONG OutboundQuota,
115  IN ULONG WriteQuotaAvailable,
116  IN ULONG NamedPipeState,
117  /* PipeRemoteInformation */
118  /* */
119  IN PCSTR FileAndLine);
120 
121 #define NpCheckClientPipe(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps) \
122  NpCheckClientPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, __FILE__, __LINE__)
123 
124 #define NpCheckClientPipe__(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file, line) \
125  NpCheckClientPipe_(h, rm, cm, npt, npc, mi, ci, iq, rsa, oq, wqa, nps, file ":" KMT_STRINGIZE(line))
126 
127 VOID
129  IN HANDLE ClientHandle,
130  /* PipeInformation */
131  IN ULONG ReadMode,
132  IN ULONG CompletionMode,
133  /* PipeLocalInformation */
134  IN ULONG NamedPipeType,
135  IN ULONG NamedPipeConfiguration,
136  IN ULONG MaximumInstances,
137  IN ULONG CurrentInstances,
138  IN ULONG InboundQuota,
139  IN ULONG ReadDataAvailable,
140  IN ULONG OutboundQuota,
141  IN ULONG WriteQuotaAvailable,
142  IN ULONG NamedPipeState,
143  /* PipeRemoteInformation */
144  /* */
145  IN PCSTR FileAndLine);
146 
147 #define NpQueryPipe(h, es) \
148  NpQueryPipe__(h, es, __FILE__, __LINE__)
149 
150 #define NpQueryPipe__(h, es, file, line) \
151  NpQueryPipe_(h, es, file ":" KMT_STRINGIZE(line))
152 
153 VOID
155  IN HANDLE Handle,
156  IN NTSTATUS ExpectedStatus,
157  IN PCSTR FileAndLine);
158 
159 
160 struct _THREAD_CONTEXT;
163 
164 typedef struct _THREAD_CONTEXT
165 {
167  volatile union
168  {
169  struct
170  {
175  } Connect;
176  struct
177  {
180  } Listen;
181  struct
182  {
188  } ReadWrite;
189  };
195 
196 VOID
199 
200 VOID
203 
204 BOOLEAN
207  IN ULONG MilliSeconds);
208 
209 BOOLEAN
212  IN ULONG MilliSeconds);
213 
214 #endif /* !defined _KMTEST_NPFS_H_ */
#define FILE_PIPE_BYTE_STREAM_TYPE
Definition: iotypes.h:75
NTSTATUS NpCreatePipe(OUT PHANDLE ServerHandle, IN PCWSTR PipePath, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota)
PCWSTR PipePath
Definition: npfs.h:171
HANDLE ServerHandle
Definition: npfs.h:178
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
NTSTATUS NpWaitPipe(IN PCWSTR PipeName, IN PLARGE_INTEGER Timeout)
Definition: NpfsHelpers.c:250
KEVENT StartWorkEvent
Definition: npfs.h:191
BOOLEAN TriggerWork(IN PTHREAD_CONTEXT Context, IN ULONG MilliSeconds)
Definition: NpfsHelpers.c:710
struct _THREAD_CONTEXT * PTHREAD_CONTEXT
VOID StartWorkerThread(OUT PTHREAD_CONTEXT Context)
Definition: NpfsHelpers.c:674
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_PIPE_MESSAGE_TYPE
Definition: iotypes.h:76
VOID FinishWorkerThread(IN PTHREAD_CONTEXT Context)
Definition: NpfsHelpers.c:685
KEVENT ThreadDoneEvent
Definition: npfs.h:190
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4137
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
CHAR InputBuffer[80]
Definition: conmgr.c:33
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS NpControlPipe(IN HANDLE PipeHandle, IN ULONG FsControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength)
Definition: NpfsHelpers.c:208
ULONG BufferSize
Definition: npfs.h:185
VOID NpQueryPipe_(IN HANDLE Handle, IN NTSTATUS ExpectedStatus, IN PCSTR FileAndLine)
Definition: NpfsHelpers.c:594
struct _THREAD_CONTEXT::@1597::@1601 ReadWrite
HANDLE PipeHandle
Definition: npfs.h:183
unsigned char BOOLEAN
BOOLEAN ClientSynchronous
Definition: npfs.h:172
NTSTATUS NpReadPipe(IN HANDLE PipeHandle, OUT PVOID Buffer, IN ULONG BufferSize, OUT PULONG_PTR BytesRead)
Definition: NpfsHelpers.c:322
Definition: bufpool.h:45
NTSTATUS NpWritePipe(IN HANDLE PipeHandle, IN const VOID *Buffer, IN ULONG BufferSize, OUT PULONG_PTR BytesWritten)
Definition: NpfsHelpers.c:374
_In_ HANDLE Handle
Definition: extypes.h:390
PVOID Buffer
Definition: npfs.h:184
NTSTATUS NpOpenPipe(OUT PHANDLE ClientHandle, IN PCWSTR PipePath, IN ULONG NamedPipeConfiguration)
Definition: NpfsHelpers.c:180
struct _THREAD_CONTEXT::@1597::@1599 Connect
#define BufferSize
Definition: classpnp.h:436
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG CreateOptions
Definition: fltkernel.h:1230
NTSTATUS NpCreatePipeEx(OUT PHANDLE ServerHandle, IN PCWSTR PipePath, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG ShareAccess, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota, IN ACCESS_MASK DesiredAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PLARGE_INTEGER DefaultTimeout OPTIONAL)
Definition: NpfsHelpers.c:12
volatile PWORK_FUNCTION Work
Definition: npfs.h:166
VOID() WORK_FUNCTION(IN OUT struct _THREAD_CONTEXT *)
Definition: npfs.h:161
KEVENT WorkCompleteEvent
Definition: npfs.h:192
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
#define VOID
Definition: acefi.h:82
struct _THREAD_CONTEXT THREAD_CONTEXT
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
NTSTATUS Status
Definition: npfs.h:174
BOOLEAN WaitForWork(IN PTHREAD_CONTEXT Context, IN ULONG MilliSeconds)
Definition: NpfsHelpers.c:692
WORK_FUNCTION * PWORK_FUNCTION
Definition: npfs.h:162
C_ASSERT(FIELD_OFFSET(NP_FCB, PrefixTableEntry)==FIELD_OFFSET(NP_DCB, PrefixTableEntry))
static ULONG Timeout
Definition: ping.c:61
ULONG_PTR BytesTransferred
Definition: npfs.h:186
struct _THREAD_CONTEXT::@1597::@1600 Listen
#define FILE_PIPE_MESSAGE_MODE
Definition: iotypes.h:78
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4137
static HANDLE PipeHandle
Definition: dhcpcsvc.c:21
#define FILE_PIPE_BYTE_STREAM_MODE
Definition: iotypes.h:77
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG FsControlCode
Definition: fltkernel.h:1369
#define OUT
Definition: typedefs.h:40
VOID NpCheckClientPipe_(IN HANDLE ClientHandle, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG CurrentInstances, IN ULONG InboundQuota, IN ULONG ReadDataAvailable, IN ULONG OutboundQuota, IN ULONG WriteQuotaAvailable, IN ULONG NamedPipeState, IN PCSTR FileAndLine)
Definition: NpfsHelpers.c:520
HANDLE ClientHandle
Definition: npfs.h:173
unsigned int ULONG
Definition: retypes.h:1
uint32_t * PULONG_PTR
Definition: typedefs.h:65
const char * PCSTR
Definition: typedefs.h:52
VOID NpCheckServerPipe_(IN HANDLE ServerHandle, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG CurrentInstances, IN ULONG InboundQuota, IN ULONG ReadDataAvailable, IN ULONG OutboundQuota, IN ULONG WriteQuotaAvailable, IN ULONG NamedPipeState, IN PCSTR FileAndLine)
Definition: NpfsHelpers.c:446
ULONG ACCESS_MASK
Definition: nt_native.h:40
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
PKTHREAD Thread
Definition: npfs.h:193
NTSTATUS NpOpenPipeEx(OUT PHANDLE ClientHandle, IN PCWSTR PipePath, IN ACCESS_MASK DesiredAccess, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions)
Definition: NpfsHelpers.c:130
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68