:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / include / napi / npipe.h
1 #ifndef __INCLUDE_NAPI_NPIPE_H
2 #define __INCLUDE_NAPI_NPIPE_H
3
4 #include <ddk/ntddk.h>
5
6 /*
7  * FUNCTION: ZwCreateNamedPipeFile creates named pipe
8  * ARGUMENTS:
9  *        NamedPipeFileHandle (OUT) = Caller supplied storage for the 
10  *                                    resulting handle
11  *        DesiredAccess = Specifies the type of access that the caller 
12  *                        requires to the file boject
13  *        ObjectAttributes = Points to a structure that specifies the
14  *                           object attributes.
15  *        IoStatusBlock = Points to a variable that receives the final
16  *                        completion status and information
17  *        ShareAccess = Specifies the limitations on sharing of the file.
18  *                      This parameter can be zero or any compatible 
19  *                      combination of the following flags
20  *                         FILE_SHARE_READ
21  *                         FILE_SHARE_WRITE
22  *        CreateDisposition = Specifies what to do depending on whether
23  *                            the file already exists. This must be one of
24  *                            the following values
25  *                                  FILE_OPEN
26  *                                  FILE_CREATE
27  *                                  FILE_OPEN_IF
28  *        CreateOptions = Specifies the options to be applied when
29  *                        creating or opening the file, as a compatible
30  *                        combination of the following flags
31  *                            FILE_WRITE_THROUGH
32  *                            FILE_SYNCHRONOUS_IO_ALERT
33  *                            FILE_SYNCHRONOUS_IO_NONALERT
34  *        TypeMessage = Specifies whether the data written to the pipe is
35  *                      interpreted as a sequence of messages or as a 
36  *                      stream of bytes
37  *        ReadModeMessage = Specifies whether the data read from the pipe
38  *                          is interpreted as a sequence of messages or as
39  *                          a stream of bytes
40  *        NonBlocking = Specifies whether non-blocking mode is enabled
41  *        MaxInstances = Specifies the maximum number of instancs that can
42  *                       be created for this pipe
43  *        InBufferSize = Specifies the number of bytes to reserve for the
44  *                       input buffer
45  *        OutBufferSize = Specifies the number of bytes to reserve for the
46  *                        output buffer
47  *        DefaultTimeout = Optionally points to a variable that specifies
48  *                         the default timeout value in units of 
49  *                         100-nanoseconds.
50  * REMARKS: This funciton maps to the win32 function CreateNamedPipe
51  * RETURNS:
52  *      Status
53  */
54
55 NTSTATUS STDCALL NtCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
56                                        IN ACCESS_MASK DesiredAccess,
57                                        IN POBJECT_ATTRIBUTES ObjectAttributes,
58                                        OUT PIO_STATUS_BLOCK IoStatusBlock,
59                                        IN ULONG ShareAccess,
60                                        IN ULONG CreateDisposition,
61                                        IN ULONG CreateOptions,
62                                        IN BOOLEAN WriteModeMessage,
63                                        IN BOOLEAN ReadModeMessage,
64                                        IN BOOLEAN NonBlocking,
65                                        IN ULONG MaxInstances,
66                                        IN ULONG InBufferSize,
67                                        IN ULONG OutBufferSize,
68                                        IN PLARGE_INTEGER DefaultTimeOut);
69 NTSTATUS STDCALL ZwCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
70                                        IN ACCESS_MASK DesiredAccess,
71                                        IN POBJECT_ATTRIBUTES ObjectAttributes,
72                                        OUT PIO_STATUS_BLOCK IoStatusBlock,
73                                        IN ULONG ShareAccess,
74                                        IN ULONG CreateDisposition,
75                                        IN ULONG CreateOptions,
76                                        IN BOOLEAN WriteModeMessage,
77                                        IN BOOLEAN ReadModeMessage,
78                                        IN BOOLEAN NonBlocking,
79                                        IN ULONG MaxInstances,
80                                        IN ULONG InBufferSize,
81                                        IN ULONG OutBufferSize,
82                                        IN PLARGE_INTEGER DefaultTimeOut);
83
84 #define FSCTL_PIPE_ASSIGN_EVENT \
85         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
86
87 #define FSCTL_PIPE_DISCONNECT \
88         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
89
90 #define FSCTL_PIPE_LISTEN \
91         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
92
93 #define FSCTL_PIPE_PEEK \
94         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
95
96 #define FSCTL_PIPE_QUERY_EVENT \
97         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
98
99 #define FSCTL_PIPE_TRANSCEIVE \
100         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER,  FILE_READ_DATA | FILE_WRITE_DATA)
101
102 #define FSCTL_PIPE_WAIT \
103         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
104
105 #define FSCTL_PIPE_IMPERSONATE \
106         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
107
108 #define FSCTL_PIPE_SET_CLIENT_PROCESS \
109         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
110
111 #define FSCTL_PIPE_QUERY_CLIENT_PROCESS \
112         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
113
114 #define FSCTL_PIPE_GET_STATE \
115         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
116
117 #define FSCTL_PIPE_SET_STATE \
118         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
119
120 #define FSCTL_PIPE_INTERNAL_READ \
121         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
122
123 #define FSCTL_PIPE_INTERNAL_WRITE \
124         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
125
126 #define FSCTL_PIPE_INTERNAL_TRANSCEIVE \
127         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
128
129 #define FSCTL_PIPE_INTERNAL_READ_OVFLOW \
130         CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
131
132
133 typedef struct _NPFS_WAIT_PIPE
134 {
135    LARGE_INTEGER Timeout;
136 } NPFS_WAIT_PIPE, *PNPFS_WAIT_PIPE;
137
138 typedef struct _NPFS_LISTEN
139 {
140 } NPFS_LISTEN, *PNPFS_LISTEN;
141
142 typedef struct _NPFS_SET_STATE
143 {
144    BOOLEAN WriteModeMessage;
145    BOOLEAN ReadModeMessage;
146    BOOLEAN NonBlocking;
147    ULONG InBufferSize;
148    ULONG OutBufferSize;
149    LARGE_INTEGER Timeout;
150 } NPFS_SET_STATE, *PNPFS_SET_STATE;
151
152 typedef struct _NPFS_GET_STATE
153 {
154    BOOLEAN WriteModeMessage;
155    BOOLEAN ReadModeMessage;
156    BOOLEAN NonBlocking;
157    ULONG InBufferSize;
158    ULONG OutBufferSize;
159    LARGE_INTEGER Timeout;
160 } NPFS_GET_STATE, *PNPFS_GET_STATE;
161
162 typedef struct _FILE_PIPE_PEEK_BUFFER
163 {
164   ULONG NamedPipeState;
165   ULONG ReadDataAvailable;
166   ULONG NumberOfMessages;
167   ULONG MessageLength;
168   CHAR Data[1];
169 } FILE_PIPE_PEEK_BUFFER, *PFILE_PIPE_PEEK_BUFFER;
170
171 #define FILE_PIPE_BYTE_STREAM_TYPE      0x00000000
172 #define FILE_PIPE_MESSAGE_TYPE          0x00000001
173
174 #define FILE_PIPE_BYTE_STREAM_MODE      0x00000000
175 #define FILE_PIPE_MESSAGE_MODE          0x00000001
176
177 #define FILE_PIPE_QUEUE_OPERATION       0x00000000
178 #define FILE_PIPE_COMPLETE_OPERATION    0x00000001
179
180 #define FILE_PIPE_INBOUND               0x00000000
181 #define FILE_PIPE_OUTBOUND              0x00000001
182 #define FILE_PIPE_FULL_DUPLEX           0x00000002
183
184 #define FILE_PIPE_DISCONNECTED_STATE    0x00000001
185 #define FILE_PIPE_LISTENING_STATE       0x00000002
186 #define FILE_PIPE_CONNECTED_STATE       0x00000003
187 #define FILE_PIPE_CLOSING_STATE         0x00000004
188
189 #define FILE_PIPE_CLIENT_END            0x00000000
190 #define FILE_PIPE_SERVER_END            0x00000001
191
192 #define FILE_PIPE_READ_DATA             0x00000000
193 #define FILE_PIPE_WRITE_SPACE           0x00000001
194
195
196 #endif /* __INCLUDE_NAPI_NPIPE_H */