Windows: Deny writes/truncation to files w RO attr
[openafs.git] / src / WINNT / afsrdr / user / RDRPrototypes.h
1 /*
2  * Copyright (c) 2008 Secure Endpoints, Inc.
3  * Copyright (c) 2009-2013 Your File System, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  *   this list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  *   this list of conditions and the following disclaimer in the documentation
13  *   and/or other materials provided with the distribution.
14  * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
15  *   may be used to endorse or promote products derived from this software without
16  *   specific prior written permission from Secure Endpoints, Inc. and
17  *   Your File System, Inc.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #include <ntsecapi.h>
37
38 // The following are forward declarations of structures
39 // which are referenced in the RDR code only by pointer.
40 typedef struct cm_user cm_user_t;
41 typedef struct cm_req cm_req_t;
42 typedef struct cm_fid cm_fid_t;
43 typedef struct cm_scache cm_scache_t;
44
45 // Function Declarations
46 #include <../common/AFSUserPrototypes.h>
47
48 void
49 RDR_InitReq( IN OUT cm_req_t *reqp, BOOL bWow64);
50
51 DWORD
52 RDR_SetInitParams( OUT AFSRedirectorInitInfo **ppRedirInitInfo,
53                    OUT DWORD * pRedirInitInfoLen );
54
55 DWORD
56 WINAPI
57 RDR_RequestWorkerThread( LPVOID lpParameter);
58
59 DWORD
60 RDR_ProcessWorkerThreads( IN DWORD);
61
62 void
63 RDR_ProcessRequest( AFSCommRequest *RequestBuffer);
64
65 void
66 RDR_EnumerateDirectory( IN cm_user_t *userp,
67                         IN AFSFileID ParentID,
68                         IN AFSDirQueryCB *QueryCB,
69                         IN BOOL bWow64,
70                         IN BOOL bQueryStatus,
71                         IN DWORD ResultBufferLength,
72                         IN OUT AFSCommResult **ResultCB);
73
74 void
75 RDR_EvaluateNodeByName( IN cm_user_t *userp,
76                         IN AFSFileID ParentID,
77                         IN WCHAR     *Name,
78                         IN DWORD     NameLength,
79                         IN BOOL      CaseSensitive,
80                         IN BOOL      LastComponent,
81                         IN BOOL      bWow64,
82                         IN BOOL      bFollowMount,
83                         IN BOOL      bHoldFid,
84                         IN DWORD     ResultBufferLength,
85                         IN OUT AFSCommResult **ResultCB);
86
87 void
88 RDR_EvaluateNodeByID( IN cm_user_t *userp,
89                       IN AFSFileID ParentID,
90                       IN AFSFileID SourceID,
91                       IN BOOL bWow64,
92                       IN BOOL bQueryStatus,
93                       IN BOOL      bHoldFid,
94                       IN DWORD    ResultBufferLength,
95                       IN OUT AFSCommResult **ResultCB);
96
97 void
98 RDR_CreateFileEntry( IN cm_user_t *userp,
99                      IN WCHAR *FileName,
100                      IN DWORD FileNameLength,
101                      IN AFSFileCreateCB *CreateCB,
102                      IN BOOL bWow64,
103                      IN BOOL bHoldFid,
104                      IN DWORD ResultBufferLength,
105                      IN OUT AFSCommResult **ResultCB);
106
107 void
108 RDR_UpdateFileEntry( IN cm_user_t *userp,
109                      IN AFSFileID FileId,
110                      IN AFSFileUpdateCB *UpdateCB,
111                      IN BOOL bWow64,
112                      IN DWORD ResultBufferLength,
113                      IN OUT AFSCommResult **ResultCB);
114
115 void
116 RDR_DeleteFileEntry( IN cm_user_t *userp,
117                      IN AFSFileID ParentId,
118                      IN ULONGLONG ProcessId,
119                      IN WCHAR *FileName,
120                      IN DWORD FileNameLength,
121                      IN BOOL bWow64,
122                      IN BOOL bCheckOnly,
123                      IN DWORD ResultBufferLength,
124                      IN OUT AFSCommResult **ResultCB);
125
126 void
127 RDR_RenameFileEntry( IN cm_user_t *userp,
128                      IN WCHAR    *SourceFileName,
129                      IN DWORD     SourceFileNameLength,
130                      IN AFSFileID SourceFileId,
131                      IN AFSFileRenameCB *RenameCB,
132                      IN BOOL bWow64,
133                      IN DWORD ResultBufferLength,
134                      IN OUT AFSCommResult **ResultCB);
135
136 void
137 RDR_HardLinkFileEntry( IN cm_user_t *userp,
138                        IN WCHAR    *SourceFileName,
139                        IN DWORD     SourceFileNameLength,
140                        IN AFSFileID SourceFileId,
141                        IN AFSFileHardLinkCB *HardLinkCB,
142                        IN BOOL bWow64,
143                        IN DWORD ResultBufferLength,
144                        IN OUT AFSCommResult **ResultCB);
145
146 void
147 RDR_CreateSymlinkEntry( IN cm_user_t *userp,
148                         IN AFSFileID FileId,
149                         IN WCHAR *FileName,
150                         IN DWORD FileNameLength,
151                         IN AFSCreateSymlinkCB *SymlinkCB,
152                         IN BOOL bWow64,
153                         IN DWORD ResultBufferLength,
154                         IN OUT AFSCommResult **ResultCB);
155
156 void
157 RDR_FlushFileEntry( IN cm_user_t *userp,
158                     IN AFSFileID FileId,
159                     IN BOOL bWow64,
160                     IN DWORD ResultBufferLength,
161                     IN OUT AFSCommResult **ResultCB);
162
163 void
164 RDR_OpenFileEntry( IN cm_user_t *userp,
165                    IN AFSFileID FileId,
166                    IN AFSFileOpenCB *OpenCB,
167                    IN BOOL bWow64,
168                    IN BOOL bHoldFid,
169                    IN DWORD ResultBufferLength,
170                    IN OUT AFSCommResult **ResultCB);
171
172 void
173 RDR_ReleaseFileAccess( IN cm_user_t *userp,
174                        IN AFSFileID FileId,
175                        IN AFSFileAccessReleaseCB *ReleaseFileCB,
176                        IN BOOL bWow64,
177                        IN DWORD ResultBufferLength,
178                        IN OUT AFSCommResult **ResultCB);
179
180 void
181 RDR_CleanupFileEntry( IN cm_user_t *userp,
182                       IN AFSFileID FileId,
183                       IN WCHAR *FileName,
184                       IN DWORD FileNameLength,
185                       IN AFSFileCleanupCB *CleanupCB,
186                       IN BOOL bWow64,
187                       IN BOOL bFlushFile,
188                       IN BOOL bDeleteFile,
189                       IN BOOL bUnlockFile,
190                       IN DWORD ResultBufferLength,
191                       IN OUT AFSCommResult **ResultCB);
192
193 BOOL
194 RDR_RequestFileExtentsAsync( IN cm_user_t *userp,
195                              IN AFSFileID FileId,
196                              IN AFSRequestExtentsCB *RequestExtentsCB,
197                              IN BOOL bWow64,
198                              IN OUT DWORD * ResultBufferLength,
199                              IN OUT AFSSetFileExtentsCB **ResultCB);
200
201 void
202 RDR_ReleaseFileExtents( IN cm_user_t *userp,
203                         IN AFSFileID FileId,
204                         IN AFSReleaseExtentsCB *ReleaseExtentsCB,
205                         IN BOOL bWow64,
206                         IN DWORD ResultBufferLength,
207                         IN OUT AFSCommResult **ResultCB);
208
209 DWORD
210 RDR_RequestExtentRelease( IN cm_fid_t *fidp,
211                           IN LARGE_INTEGER numOfHeldExtents,
212                           IN DWORD numOfExtents,
213                           IN AFSFileExtentCB *extentList);
214
215 DWORD
216 RDR_ProcessReleaseFileExtentsResult( IN AFSReleaseFileExtentsResultCB *ReleaseFileExtentsResultCB,
217                                      IN DWORD ResultBufferLength);
218
219 DWORD
220 RDR_ReleaseFailedSetFileExtents( IN cm_user_t *userp,
221                                  IN AFSSetFileExtentsCB *SetFileExtentsResultCB,
222                                  IN DWORD ResultBufferLength);
223
224 DWORD
225 RDR_SetFileExtents( IN AFSSetFileExtentsCB *pSetFileExtentsResultCB,
226                     IN DWORD dwResultBufferLength);
227 void
228 RDR_PioctlOpen( IN cm_user_t *userp,
229                 IN AFSFileID  ParentId,
230                 IN AFSPIOCtlOpenCloseRequestCB *pPioctlCB,
231                 IN BOOL bWow64,
232                 IN DWORD ResultBufferLength,
233                 IN OUT AFSCommResult **ResultCB);
234
235 void
236 RDR_PioctlClose( IN cm_user_t *userp,
237                  IN AFSFileID  ParentId,
238                  IN AFSPIOCtlOpenCloseRequestCB *pPioctlCB,
239                  IN BOOL bWow64,
240                  IN DWORD ResultBufferLength,
241                  IN OUT AFSCommResult **ResultCB);
242
243 void
244 RDR_PioctlWrite( IN cm_user_t *userp,
245                  IN AFSFileID  ParentId,
246                  IN AFSPIOCtlIORequestCB *pPioctlCB,
247                  IN BOOL bWow64,
248                  IN DWORD ResultBufferLength,
249                  IN OUT AFSCommResult **ResultCB);
250
251 void
252 RDR_PioctlRead( IN cm_user_t *userp,
253                 IN AFSFileID  ParentId,
254                 IN AFSPIOCtlIORequestCB *pPioctlCB,
255                 IN BOOL bWow64,
256                 IN BOOL bIsLocalSystem,
257                 IN DWORD ResultBufferLength,
258                 IN OUT AFSCommResult **ResultCB);
259
260 void
261 RDR_ByteRangeLockSync( IN cm_user_t     *userp,
262                        IN AFSFileID     FileId,
263                        IN AFSByteRangeLockRequestCB *pBRLRequestCB,
264                        IN BOOL bWow64,
265                        IN DWORD ResultBufferLength,
266                        IN OUT AFSCommResult **ResultCB);
267
268 void
269 RDR_ByteRangeUnlock( IN cm_user_t     *userp,
270                      IN AFSFileID     FileId,
271                      IN AFSByteRangeUnlockRequestCB *pBRURequestCB,
272                      IN BOOL bWow64,
273                      IN DWORD ResultBufferLength,
274                      IN OUT AFSCommResult **ResultCB);
275
276 void
277 RDR_ByteRangeUnlockAll( IN cm_user_t     *userp,
278                         IN AFSFileID     FileId,
279                         IN AFSByteRangeUnlockRequestCB *pBRURequestCB,
280                         IN BOOL bWow64,
281                         IN DWORD ResultBufferLength,
282                         IN OUT AFSCommResult **ResultCB);
283
284 void
285 RDR_GetVolumeInfo( IN cm_user_t     *userp,
286                    IN AFSFileID     FileId,
287                    IN BOOL bWow64,
288                    IN DWORD ResultBufferLength,
289                    IN OUT AFSCommResult **ResultCB);
290
291 void
292 RDR_GetVolumeSizeInfo( IN cm_user_t     *userp,
293                        IN AFSFileID     FileId,
294                        IN BOOL bWow64,
295                        IN DWORD ResultBufferLength,
296                        IN OUT AFSCommResult **ResultCB);
297
298 void
299 RDR_HoldFid( IN cm_user_t     *userp,
300              IN AFSHoldFidRequestCB * pHoldFidCB,
301              IN BOOL bFast,
302              IN DWORD ResultBufferLength,
303              IN OUT AFSCommResult **ResultCB);
304
305 void
306 RDR_ReleaseFid( IN cm_user_t     *userp,
307                 IN AFSReleaseFidRequestCB * pReleaseFidCB,
308                 IN BOOL bFast,
309                 IN DWORD ResultBufferLength,
310                 IN OUT AFSCommResult **ResultCB);
311
312 void
313 RDR_InitPipe(void);
314
315 void
316 RDR_ShutdownPipe(void);
317
318 void
319 RDR_PipeOpen( IN cm_user_t *userp,
320               IN AFSFileID  ParentId,
321               IN WCHAR     *Name,
322               IN DWORD      NameLength,
323               IN AFSPipeOpenCloseRequestCB *pPipeCB,
324               IN BOOL bWow64,
325               IN DWORD ResultBufferLength,
326               IN OUT AFSCommResult **ResultCB);
327
328 void
329 RDR_PipeClose( IN cm_user_t *userp,
330                IN AFSFileID  ParentId,
331                IN AFSPipeOpenCloseRequestCB *pPipeCB,
332                IN BOOL bWow64,
333                IN DWORD ResultBufferLength,
334                IN OUT AFSCommResult **ResultCB);
335
336 void
337 RDR_PipeWrite( IN cm_user_t *userp,
338                IN AFSFileID  ParentId,
339                IN AFSPipeIORequestCB *pPipeCB,
340                IN BYTE *pPipeData,
341                IN BOOL bWow64,
342                IN DWORD ResultBufferLength,
343                IN OUT AFSCommResult **ResultCB);
344
345 void
346 RDR_PipeRead( IN cm_user_t *userp,
347               IN AFSFileID  ParentId,
348               IN AFSPipeIORequestCB *pPipeCB,
349               IN BOOL bWow64,
350               IN DWORD ResultBufferLength,
351               IN OUT AFSCommResult **ResultCB);
352
353 void
354 RDR_PipeSetInfo( IN cm_user_t *userp,
355                  IN AFSFileID  ParentId,
356                  IN AFSPipeInfoRequestCB *pPipeCB,
357                  IN BYTE *pPipeData,
358                  IN BOOL bWow64,
359                  IN DWORD ResultBufferLength,
360                  IN OUT AFSCommResult **ResultCB);
361
362 void
363 RDR_PipeQueryInfo( IN cm_user_t *userp,
364                    IN AFSFileID  ParentId,
365                    IN AFSPipeInfoRequestCB *pPipeCB,
366                    IN BOOL bWow64,
367                    IN DWORD ResultBufferLength,
368                    IN OUT AFSCommResult **ResultCB);
369
370 void
371 RDR_PipeTransceive( IN cm_user_t     *userp,
372                     IN AFSFileID  ParentId,
373                     IN AFSPipeIORequestCB *pPipeCB,
374                     IN BYTE *pPipeData,
375                     IN BOOL bWow64,
376                     IN DWORD          ResultBufferLength,
377                     IN OUT AFSCommResult **ResultCB);
378
379 void
380 RDR_ReadFile( IN cm_user_t     *userp,
381               IN AFSFileID      FileID,
382               IN LARGE_INTEGER *Offset,
383               IN ULONG          Length,
384               IN PVOID          Buffer,
385               IN BOOL           bWow64,
386               IN BOOL           bCacheBypass,
387               IN DWORD          ResultBufferLength,
388               IN OUT AFSCommResult **ResultCB);
389
390 void
391 RDR_WriteFile( IN cm_user_t     *userp,
392                IN AFSFileID      FileID,
393                IN AFSFileIOCB   *FileIOCB,
394                IN LARGE_INTEGER *Offset,
395                IN ULONG          Length,
396                IN PVOID          Buffer,
397                IN BOOL           bWow64,
398                IN BOOL           bCacheBypass,
399                IN DWORD          ResultBufferLength,
400                IN OUT AFSCommResult **ResultCB);
401
402 cm_user_t *
403 RDR_UserFromCommRequest( IN AFSCommRequest * pRequest);
404
405 cm_user_t *
406 RDR_UserFromAuthGroup( IN GUID *pGuid);
407
408 void
409 RDR_ReleaseUser( IN cm_user_t *userp);
410
411 void
412 RDR_fid2FID( IN cm_fid_t *fid,
413              IN AFSFileID *FileId);
414
415 void
416 RDR_FID2fid( IN AFSFileID *FileId,
417              IN cm_fid_t *fid);
418
419 void
420 RDR_InitIoctl(void);
421
422 void
423 RDR_ShutdownIoctl(void);
424
425 #ifdef __cplusplus
426 }
427 #endif
428