Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

620 lines
16 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ifsurtl.h
  5. Abstract:
  6. This module defines all EXIFS shared routines exported to user-mode.
  7. Author:
  8. Rajeev Rajan [RajeevR] 2-June-1999
  9. Rohan Phillips [Rohanp] 23-June-1999 - Added provider functions
  10. Revision History:
  11. --*/
  12. #ifndef _IFSURTL_H_
  13. #define _IFSURTL_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #ifdef _IFSURTL_IMPLEMENTATION_
  18. #ifndef IFSURTL_EXPORT
  19. #define IFSURTL_EXPORT __declspec( dllexport )
  20. #endif
  21. #else
  22. #ifndef IFSURTL_EXPORT
  23. #define IFSURTL_EXPORT __declspec( dllimport )
  24. #endif
  25. #endif
  26. #ifndef IFSURTL_CALLTYPE
  27. #define IFSURTL_CALLTYPE __stdcall
  28. #endif
  29. ///////////////////////////////////////////////////////////////////////////////
  30. //
  31. // Callback for IFS functions
  32. //
  33. ///////////////////////////////////////////////////////////////////////////////
  34. typedef void (WINAPI *PFN_IFSCALLBACK)(PVOID);
  35. ///////////////////////////////////////////////////////////////////////////////
  36. //
  37. // Following are the structures / definitions for the large buffer package
  38. //
  39. ///////////////////////////////////////////////////////////////////////////////
  40. #define IFS_LARGE_BUFFER_SIGNATURE (ULONG) 'fubL'
  41. #define IFS_CURSOR_SIGNATURE (ULONG) 'rsrC'
  42. #define IFS_LARGE_BUFFER_SHARED_VIEWSIZE (256*1024)
  43. //
  44. // An IFS_LARGE_BUFFER object encapsulates a temp file containing
  45. // data that can be passed around and used like a buffer. Typically,
  46. // a producer would make one of these objects and stream in large
  47. // amounts of data. A consumer would read different chunks of the
  48. // data. The object will maintain a single mapping/view of the first
  49. // 256K of the file.
  50. //
  51. // Consumers will need to access data using IFS_CURSORS that specify
  52. // the <offset,len> pair for the span of data they are interested in.
  53. // In the most common case, this should lie in the first 256K region,
  54. // which would yield the default view. If it is beyond this region,
  55. // views will be mapped/unmapped on demand.
  56. //
  57. typedef struct _IFS_LARGE_BUFFER {
  58. //
  59. // Signature
  60. //
  61. ULONG m_Signature;
  62. //
  63. // Handle
  64. //
  65. HANDLE m_FileContext1;
  66. //
  67. // FileObject
  68. //
  69. PVOID m_FileContext2;
  70. //
  71. // FileMapping context for first 256K or filesize
  72. //
  73. HANDLE m_MappingContext;
  74. //
  75. // Process context (optional)
  76. //
  77. PVOID m_ProcessContext;
  78. //
  79. // Memory pointer for first 256K or filesize
  80. //
  81. PBYTE m_MemoryPtr;
  82. //
  83. // Ref count - the lower WORD will count cursor refs
  84. // the higher WORD will count object refs
  85. //
  86. ULONG m_ReferenceCount;
  87. //
  88. // Is this a reference or a live object ?
  89. // If this is a reference, the fields above are NULL and
  90. // the m_TempFileName should be used to make a new object !
  91. //
  92. BOOL m_IsThisAReference;
  93. //
  94. // Current ValidDataLength
  95. //
  96. LARGE_INTEGER m_ValidDataLength;
  97. //
  98. // Name of temp file - we will use fixed
  99. // names so we can make simplyfying assumptions
  100. // about the filename len !
  101. //
  102. WCHAR m_TempFileName [MAX_PATH+1];
  103. } IFS_LARGE_BUFFER,*PIFS_LARGE_BUFFER;
  104. #define IsScatterListLarge( s ) FlagOn((s)->Flags, IFS_SLIST_FLAGS_LARGE_BUFFER)
  105. #define EXIFS_EA_LEN_LARGE_SCATTER_LIST \
  106. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  107. sizeof(EXIFS_EA_NAME_SCATTER_LIST) + \
  108. LongAlign(sizeof(SCATTER_LIST) + sizeof(IFS_LARGE_BUFFER) ))
  109. #define EXIFS_EA_VALUE_LEN_LARGE_SCATTER_LIST \
  110. LongAlign(sizeof(SCATTER_LIST) + sizeof(IFS_LARGE_BUFFER) )
  111. //
  112. // An IFS_CURSOR object provides a view into a large buffer.
  113. // Usage is as follows:
  114. // + Call IfsStartCursor() to init a cursor and get a pointer
  115. // + Use the pointer to read/write data via IfsConsumeCursor()
  116. // + Call IfsFinishCursor() to close the cursor
  117. //
  118. // NOTE: Cursor usage will bump ref counts on the LARGE_BUFFER
  119. // object. If the LARGE_BUFFER object passed in is NOT live it
  120. // will instantiate one from the reference !
  121. //
  122. typedef struct _IFS_CURSOR {
  123. //
  124. // Signature
  125. //
  126. ULONG m_Signature;
  127. //
  128. // Owning large buffer object
  129. //
  130. PIFS_LARGE_BUFFER m_pLargeBuffer;
  131. //
  132. // Current Offset to start of data
  133. //
  134. LARGE_INTEGER m_Offset;
  135. //
  136. // Current Span of data
  137. //
  138. ULONG m_Length;
  139. //
  140. // Append mode - if TRUE client can cursor beyond EOF
  141. //
  142. BOOL m_AppendMode;
  143. //
  144. // Is this a shared view
  145. //
  146. BOOL m_IsViewShared;
  147. //
  148. // Did we open the buffer
  149. //
  150. HANDLE m_OwnBufferOpen;
  151. //
  152. // Did we attach to the large buffer process
  153. //
  154. BOOL m_AttachedToProcess;
  155. //
  156. // The following fields are relevant only if the view is not shared.
  157. // The first 256K view is shared via the mapping in the large buffer object.
  158. // Cursors that extend beyond 256K make their own mapping - See Below.
  159. //
  160. //
  161. // FileMapping context for this cursor
  162. //
  163. HANDLE m_MappingContext;
  164. //
  165. // Memory pointer for this cursor
  166. //
  167. PBYTE m_MemoryPtr;
  168. } IFS_CURSOR,*PIFS_CURSOR;
  169. //
  170. // Returns a pointer to data that can be used to
  171. // read/write. The pointer is valid only for the length
  172. // requested !
  173. // NOTE: If AppendMode is TRUE, cursors will be allowed
  174. // beyond EOF. This should be used by clients that wish
  175. // to append data to the large buffer.
  176. //
  177. PBYTE
  178. IFSURTL_EXPORT
  179. IFSURTL_CALLTYPE
  180. IfsGetFirstCursor(
  181. IN PIFS_LARGE_BUFFER pLargeBuffer,
  182. IN PIFS_CURSOR pCursor,
  183. IN ULONG StartOffsetHigh,
  184. IN ULONG StartOffsetLow,
  185. IN ULONG StartLength,
  186. IN BOOL fAppendMode
  187. );
  188. //
  189. // Consume bytes within current cursor
  190. // returns next pointer at which to read/write data !
  191. //
  192. // NOTE: If all the data in the cursor is consumed, returns NULL
  193. //
  194. PBYTE
  195. IFSURTL_EXPORT
  196. IFSURTL_CALLTYPE
  197. IfsConsumeCursor(
  198. IN PIFS_CURSOR pCursor,
  199. IN ULONG Length
  200. );
  201. //
  202. // Returns a pointer to data that can be used to
  203. // read/write. The pointer is valid only for the length
  204. // requested relative to the current cursor !
  205. //
  206. // NOTE: This call advances the cursor in the large buffer
  207. //
  208. PBYTE
  209. IFSURTL_EXPORT
  210. IFSURTL_CALLTYPE
  211. IfsGetNextCursor(
  212. IN PIFS_CURSOR pCursor,
  213. IN ULONG NextLength
  214. );
  215. //
  216. // Should be called for every matching GetFirstCursor() call.
  217. //
  218. VOID
  219. IFSURTL_EXPORT
  220. IFSURTL_CALLTYPE
  221. IfsFinishCursor(
  222. IN PIFS_CURSOR pCursor
  223. );
  224. //
  225. // Should be called to truncate the large buffer's valid data length
  226. //
  227. VOID
  228. IFSURTL_EXPORT
  229. IFSURTL_CALLTYPE
  230. IfsTruncateLargeBuffer(
  231. IN PIFS_LARGE_BUFFER pLargeBuffer,
  232. IN PLARGE_INTEGER pSizeToTruncate
  233. );
  234. //
  235. // Rules for passing around IFS_LARGE_BUFFERs:
  236. // 1. These objects should be passed around by reference. eg passing
  237. // between user & kernel or between kernel and the namecache.
  238. // 2. Use IfsCopyBufferByReference() to create a reference.
  239. // 3. If a reference exists, there should always be a live object whose
  240. // lifetime encapsulates the reference. This allows the consumer of the
  241. // reference to make a *real* copy using the reference.
  242. // 4. A reference can be converted into a live object. It is the responsibility
  243. // of the module that does this conversion to close the live object.
  244. // 5. Example: When EA is checked in to the namecache during CLOSE,
  245. // it will be passed in as a reference. During checkin, the namecache should
  246. // call IfsOpenBufferToReference() to hold on to the buffer. Thus,
  247. // when the namecache blob is finalized, it needs to call IfsCloseBuffer()
  248. // to close the large buffer !
  249. //
  250. //
  251. // IN: pLargeBuffer should be allocated by caller of the function
  252. // IN: Len of the buffer required - zero if len is not known apriori
  253. //
  254. // NOTE: Object needs to be closed via IfsCloseBuffer()
  255. //
  256. // USAGE: Should be used when caller needs to instantiate a large buffer
  257. //
  258. NTSTATUS
  259. IFSURTL_EXPORT
  260. IFSURTL_CALLTYPE
  261. IfsCreateNewBuffer(
  262. IN PIFS_LARGE_BUFFER pLargeBuffer,
  263. IN DWORD dwSizeHigh,
  264. IN DWORD dwSizeLow,
  265. IN PVOID ProcessContext // optional
  266. );
  267. //
  268. // IN: pLargeBuffer should be allocated by caller of the function
  269. // IN: Len of the buffer required - zero if len is not known apriori
  270. //
  271. // NOTE: Object needs to be closed via IfsCloseBuffer()
  272. //
  273. // USAGE: Should be used when caller needs to instantiate a large buffer
  274. //
  275. NTSTATUS
  276. IFSURTL_EXPORT
  277. IFSURTL_CALLTYPE
  278. IfsCreateNewBufferEx(
  279. IN PIFS_LARGE_BUFFER pLargeBuffer,
  280. IN DWORD dwSizeHigh,
  281. IN DWORD dwSizeLow,
  282. IN PVOID ProcessContext, // optional
  283. IN PUNICODE_STRING FilePath // optional
  284. );
  285. //
  286. // IN: pSrcLargeBuffer points to a live large buffer object
  287. // IN OUT: pDstLargeBuffer is initialized as a reference to the Src
  288. //
  289. // USAGE: Should be used to pass large buffers between user/kernel
  290. //
  291. VOID
  292. IFSURTL_EXPORT
  293. IFSURTL_CALLTYPE
  294. IfsCopyBufferToReference(
  295. IN PIFS_LARGE_BUFFER pSrcLargeBuffer,
  296. IN OUT PIFS_LARGE_BUFFER pDstLargeBuffer
  297. );
  298. //
  299. // IN: pSrcLargeBuffer points to a large buffer object (or reference)
  300. // IN OUT: pDstLargeBuffer will be initialized as a live object based on
  301. // the reference passed in
  302. //
  303. // USAGE: Should be used to pass large buffers between user/kernel
  304. //
  305. NTSTATUS
  306. IFSURTL_EXPORT
  307. IFSURTL_CALLTYPE
  308. IfsCopyReferenceToBuffer(
  309. IN PIFS_LARGE_BUFFER pSrcLargeBuffer,
  310. IN PVOID ProcessContext, // optional
  311. IN OUT PIFS_LARGE_BUFFER pDstLargeBuffer
  312. );
  313. //
  314. // IN: pLargeBuffer points to a large buffer object (or reference)
  315. //
  316. // NOTE: Object needs to be closed via IfsCloseBuffer()
  317. // OpenBuffer will always assume that the buffer len is fixed !
  318. //
  319. // USAGE: Should be used when caller needs to convert a reference to a
  320. // live object. If the object is already live, this will bump
  321. // a reference on the object !
  322. //
  323. NTSTATUS
  324. IFSURTL_EXPORT
  325. IFSURTL_CALLTYPE
  326. IfsOpenBufferToReference(
  327. IN PIFS_LARGE_BUFFER pLargeBuffer
  328. );
  329. //
  330. // IN: pLargeBuffer coming in points to a live large buffer
  331. // OUT: pLargeBuffer going out points to a NEW live large buffer
  332. // The functions does a (deep) copy of the buffer data.
  333. //
  334. // NOTE: Since the incoming object is live, it is closed and a
  335. // new object is instantiated in its place. Thus, IfsCloseBuffer()
  336. // needs to be called as usual on this !
  337. //
  338. NTSTATUS
  339. IFSURTL_EXPORT
  340. IFSURTL_CALLTYPE
  341. IfsCopyBufferToNewBuffer(
  342. IN OUT PIFS_LARGE_BUFFER pLargeBuffer
  343. );
  344. //
  345. // IN: Object should have been initialized by IfsCreateNewBuffer() or
  346. // IfsOpenBufferToReference() or IfsCopyReferenceToBuffer()
  347. //
  348. VOID
  349. IFSURTL_EXPORT
  350. IFSURTL_CALLTYPE
  351. IfsCloseBuffer(
  352. IN PIFS_LARGE_BUFFER pLargeBuffer
  353. );
  354. BOOL
  355. IFSURTL_EXPORT
  356. IFSURTL_CALLTYPE
  357. IfsInitializeProvider(DWORD OsType);
  358. DWORD
  359. IFSURTL_EXPORT
  360. IFSURTL_CALLTYPE
  361. IfsCloseProvider(void);
  362. HANDLE
  363. IFSURTL_EXPORT
  364. IFSURTL_CALLTYPE
  365. IfsCreateFileProv(WCHAR * FileName, DWORD DesiredAccess, DWORD ShareMode, PVOID
  366. lpSecurityAttributes, DWORD CreateDisposition, DWORD FlagsAndAttributes,
  367. PVOID EaBuffer, DWORD EaBufferSize);
  368. BOOL
  369. IFSURTL_EXPORT
  370. IFSURTL_CALLTYPE
  371. IfsInitializeRoot(HANDLE hFileHandle, WCHAR * szRootName, WCHAR * SlvFileName, DWORD InstanceId,
  372. DWORD AllocationUnit, DWORD FileFlags);
  373. BOOL
  374. IFSURTL_EXPORT
  375. IFSURTL_CALLTYPE
  376. IfsSpaceGrantRoot(HANDLE hFileHandle, WCHAR * szRootName, PSCATTER_LIST pSList, size_t cbListSize);
  377. BOOL
  378. IFSURTL_EXPORT
  379. IFSURTL_CALLTYPE
  380. IfsSetEndOfFileRoot(HANDLE hFileHandle, WCHAR * szRootName, LONGLONG EndOfFile);
  381. BOOL
  382. IFSURTL_EXPORT
  383. IFSURTL_CALLTYPE
  384. IfsSpaceRequestRoot(HANDLE hFileHandle, WCHAR * szRootName, PFN_IFSCALLBACK pfnIfsCallBack,
  385. PVOID pContext, PVOID Ov);
  386. BOOL
  387. IFSURTL_EXPORT
  388. IFSURTL_CALLTYPE
  389. IfsQueryEaFile(HANDLE hFileHandle, WCHAR * szFileName, WCHAR * NetRootName, PVOID EaBufferIn, DWORD EaBufferInSize,
  390. PVOID EaBufferOut, DWORD EaBufferOutSize, DWORD * RequiredLength);
  391. BOOL
  392. IFSURTL_EXPORT
  393. IFSURTL_CALLTYPE
  394. IfsSetEaFile(HANDLE hFileHandle, WCHAR * szFileName, PVOID EaBufferIn, DWORD EaBufferInSize);
  395. BOOL
  396. IFSURTL_EXPORT
  397. IFSURTL_CALLTYPE
  398. IfsTerminateRoot(HANDLE hFileHandle, WCHAR *szRootName, ULONG Mode);
  399. BOOL
  400. IFSURTL_EXPORT
  401. IFSURTL_CALLTYPE
  402. IfsGetOverlappedResult(HANDLE hFileHandle, PVOID Ov, DWORD * BytesReturned, BOOL Wait);
  403. BOOL
  404. IFSURTL_EXPORT
  405. IFSURTL_CALLTYPE
  406. IfsReadFile(HANDLE hFileHandle, BYTE * InputBuffer, DWORD BytesToRead, PFN_IFSCALLBACK IfsCallBack,
  407. PVOID Overlapped);
  408. BOOL
  409. IFSURTL_EXPORT
  410. IFSURTL_CALLTYPE
  411. IfsWriteFile(HANDLE hFileHandle, BYTE * InputBuffer, DWORD BytesToWrite, PFN_IFSCALLBACK IfsCallBack,
  412. PVOID Overlapped);
  413. BOOL
  414. IFSURTL_EXPORT
  415. IFSURTL_CALLTYPE
  416. IfsDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInputBuffer, DWORD cbInBufferSize,
  417. LPVOID lpOutBuffer, DWORD cbOutBufferSize, LPDWORD lpBytesReturned, PVOID Overlapped);
  418. BOOL
  419. IFSURTL_EXPORT
  420. IFSURTL_CALLTYPE
  421. IfsExpungName(HANDLE hFileHandle, WCHAR * szRootName, WCHAR * szFileName, ULONG cbPath);
  422. BOOL
  423. IFSURTL_EXPORT
  424. IFSURTL_CALLTYPE
  425. IfsDirChangeReport(HANDLE hFileHandle, WCHAR * szRootName, ULONG ulFilterMatch,
  426. ULONG ulAction, PWSTR pwszPath, ULONG cbPath);
  427. BOOL
  428. IFSURTL_EXPORT
  429. IFSURTL_CALLTYPE
  430. IfsQueryRootStats(HANDLE hFileHandle, WCHAR * szRootName, PVOID Buffer, DWORD BuffSize);
  431. BOOL
  432. IFSURTL_EXPORT
  433. IFSURTL_CALLTYPE
  434. IfsRegisterUmrThread(HANDLE hFileHandle, PFN_IFSCALLBACK pfnIfsCallBack);
  435. BOOL
  436. IFSURTL_EXPORT
  437. IFSURTL_CALLTYPE
  438. IfsUmrEnableNetRoot(HANDLE hFileHandle, WCHAR * szRootName, DWORD * InstanceId);
  439. BOOL
  440. IFSURTL_EXPORT
  441. IFSURTL_CALLTYPE
  442. IfsUmrDisableNetRoot(HANDLE hFileHandle, WCHAR * szRootName);
  443. BOOL
  444. IFSURTL_EXPORT
  445. IFSURTL_CALLTYPE
  446. IfsStopUmrEngine(HANDLE hFileHandle, WCHAR * szRootName);
  447. BOOL
  448. IFSURTL_EXPORT
  449. IFSURTL_CALLTYPE
  450. IfsStartUmrEngine(HANDLE hFileHandle, WCHAR * szRootName);
  451. BOOL
  452. IFSURTL_EXPORT
  453. IFSURTL_CALLTYPE
  454. IfsCloseHandle(HANDLE hFileHandle);
  455. BOOL
  456. IFSURTL_EXPORT
  457. IFSURTL_CALLTYPE
  458. IfsSetRootMap(HANDLE hFileHandle, WCHAR * szRootName, PSCATTER_LIST pSList, size_t cbListSize);
  459. BOOL
  460. IFSURTL_EXPORT
  461. IFSURTL_CALLTYPE
  462. IfsResetRootMap(HANDLE hFileHandle, WCHAR * szRootName);
  463. NTSTATUS
  464. IFSURTL_EXPORT
  465. NTAPI
  466. IfsNtCreateFile(
  467. OUT PHANDLE FileHandle,
  468. IN ACCESS_MASK DesiredAccess,
  469. IN POBJECT_ATTRIBUTES ObjectAttributes,
  470. OUT PIO_STATUS_BLOCK IoStatusBlock,
  471. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  472. IN ULONG FileAttributes,
  473. IN ULONG ShareAccess,
  474. IN ULONG CreateDisposition,
  475. IN ULONG CreateOptions,
  476. IN PVOID EaBuffer OPTIONAL,
  477. IN ULONG EaLength
  478. );
  479. NTSTATUS
  480. IFSURTL_EXPORT
  481. NTAPI
  482. IfsNtQueryEaFile(
  483. IN HANDLE FileHandle,
  484. OUT PIO_STATUS_BLOCK IoStatusBlock,
  485. OUT PVOID Buffer,
  486. IN ULONG Length,
  487. IN BOOLEAN ReturnSingleEntry,
  488. IN PVOID EaList OPTIONAL,
  489. IN ULONG EaListLength,
  490. IN PULONG EaIndex OPTIONAL,
  491. IN BOOLEAN RestartScan
  492. );
  493. VOID
  494. IFSURTL_EXPORT
  495. NTAPI
  496. IfsRtlInitUnicodeString(
  497. PUNICODE_STRING DestinationString,
  498. PCWSTR SourceString
  499. );
  500. LONG
  501. IFSURTL_EXPORT
  502. NTAPI
  503. IfsRtlCompareUnicodeString(
  504. PUNICODE_STRING String1,
  505. PUNICODE_STRING String2,
  506. BOOLEAN CaseInSensitive
  507. );
  508. BOOL
  509. IFSURTL_EXPORT
  510. IFSURTL_CALLTYPE
  511. IfsFlushHandle(HANDLE hFileHandle,
  512. WCHAR * szFileName,
  513. WCHAR * NetRootName,
  514. PVOID EaBufferIn,
  515. DWORD EaBufferInSize
  516. );
  517. #ifdef __cplusplus
  518. }
  519. #endif
  520. #endif // _IFSURTL_H_