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.

3101 lines
96 KiB

  1. /*++ BUILD Version: 0007 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntioapi.h
  5. Abstract:
  6. This module contains the user APIs for the NT I/O system.
  7. Author:
  8. Darryl E. Havens (darrylh) 12-Apr-1989
  9. Revision History:
  10. --*/
  11. #ifndef _NTIOAPI_
  12. #define _NTIOAPI_
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. //
  17. // This file contains io definitions that must be portable across operating
  18. // systems (i.e. DOS)
  19. //
  20. #include <devioctl.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  25. // begin_winnt
  26. //
  27. // Define access rights to files and directories
  28. //
  29. //
  30. // The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
  31. // devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
  32. // constants *MUST* always be in sync.
  33. // The values are redefined in devioctl.h because they must be available to
  34. // both DOS and NT.
  35. //
  36. #define FILE_READ_DATA ( 0x0001 ) // file & pipe
  37. #define FILE_LIST_DIRECTORY ( 0x0001 ) // directory
  38. #define FILE_WRITE_DATA ( 0x0002 ) // file & pipe
  39. #define FILE_ADD_FILE ( 0x0002 ) // directory
  40. #define FILE_APPEND_DATA ( 0x0004 ) // file
  41. #define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory
  42. #define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe
  43. #define FILE_READ_EA ( 0x0008 ) // file & directory
  44. #define FILE_WRITE_EA ( 0x0010 ) // file & directory
  45. #define FILE_EXECUTE ( 0x0020 ) // file
  46. #define FILE_TRAVERSE ( 0x0020 ) // directory
  47. #define FILE_DELETE_CHILD ( 0x0040 ) // directory
  48. #define FILE_READ_ATTRIBUTES ( 0x0080 ) // all
  49. #define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all
  50. #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
  51. #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
  52. FILE_READ_DATA |\
  53. FILE_READ_ATTRIBUTES |\
  54. FILE_READ_EA |\
  55. SYNCHRONIZE)
  56. #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
  57. FILE_WRITE_DATA |\
  58. FILE_WRITE_ATTRIBUTES |\
  59. FILE_WRITE_EA |\
  60. FILE_APPEND_DATA |\
  61. SYNCHRONIZE)
  62. #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  63. FILE_READ_ATTRIBUTES |\
  64. FILE_EXECUTE |\
  65. SYNCHRONIZE)
  66. // end_winnt
  67. //
  68. // Define share access rights to files and directories
  69. //
  70. #define FILE_SHARE_READ 0x00000001 // winnt
  71. #define FILE_SHARE_WRITE 0x00000002 // winnt
  72. #define FILE_SHARE_DELETE 0x00000004 // winnt
  73. #define FILE_SHARE_VALID_FLAGS 0x00000007
  74. //
  75. // Define the file attributes values
  76. //
  77. // Note: 0x00000008 is reserved for use for the old DOS VOLID (volume ID)
  78. // and is therefore not considered valid in NT.
  79. //
  80. // Note: 0x00000010 is reserved for use for the old DOS SUBDIRECTORY flag
  81. // and is therefore not considered valid in NT. This flag has
  82. // been disassociated with file attributes since the other flags are
  83. // protected with READ_ and WRITE_ATTRIBUTES access to the file.
  84. //
  85. // Note: Note also that the order of these flags is set to allow both the
  86. // FAT and the Pinball File Systems to directly set the attributes
  87. // flags in attributes words without having to pick each flag out
  88. // individually. The order of these flags should not be changed!
  89. //
  90. #define FILE_ATTRIBUTE_READONLY 0x00000001 // winnt
  91. #define FILE_ATTRIBUTE_HIDDEN 0x00000002 // winnt
  92. #define FILE_ATTRIBUTE_SYSTEM 0x00000004 // winnt
  93. //OLD DOS VOLID 0x00000008
  94. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 // winnt
  95. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 // winnt
  96. #define FILE_ATTRIBUTE_DEVICE 0x00000040 // winnt
  97. #define FILE_ATTRIBUTE_NORMAL 0x00000080 // winnt
  98. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 // winnt
  99. #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 // winnt
  100. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 // winnt
  101. #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 // winnt
  102. #define FILE_ATTRIBUTE_OFFLINE 0x00001000 // winnt
  103. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 // winnt
  104. #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 // winnt
  105. #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
  106. #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
  107. //
  108. // Define the create disposition values
  109. //
  110. #define FILE_SUPERSEDE 0x00000000
  111. #define FILE_OPEN 0x00000001
  112. #define FILE_CREATE 0x00000002
  113. #define FILE_OPEN_IF 0x00000003
  114. #define FILE_OVERWRITE 0x00000004
  115. #define FILE_OVERWRITE_IF 0x00000005
  116. #define FILE_MAXIMUM_DISPOSITION 0x00000005
  117. //
  118. // Define the create/open option flags
  119. //
  120. #define FILE_DIRECTORY_FILE 0x00000001
  121. #define FILE_WRITE_THROUGH 0x00000002
  122. #define FILE_SEQUENTIAL_ONLY 0x00000004
  123. #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
  124. #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
  125. #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
  126. #define FILE_NON_DIRECTORY_FILE 0x00000040
  127. #define FILE_CREATE_TREE_CONNECTION 0x00000080
  128. #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
  129. #define FILE_NO_EA_KNOWLEDGE 0x00000200
  130. #define FILE_OPEN_FOR_RECOVERY 0x00000400
  131. #define FILE_RANDOM_ACCESS 0x00000800
  132. #define FILE_DELETE_ON_CLOSE 0x00001000
  133. #define FILE_OPEN_BY_FILE_ID 0x00002000
  134. #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
  135. #define FILE_NO_COMPRESSION 0x00008000
  136. #define FILE_RESERVE_OPFILTER 0x00100000
  137. #define FILE_OPEN_REPARSE_POINT 0x00200000
  138. #define FILE_OPEN_NO_RECALL 0x00400000
  139. #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
  140. #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
  141. #define FILE_STRUCTURED_STORAGE 0x00000441
  142. #define FILE_VALID_OPTION_FLAGS 0x00ffffff
  143. #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
  144. #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
  145. #define FILE_VALID_SET_FLAGS 0x00000036
  146. //
  147. // Define the I/O status information return values for NtCreateFile/NtOpenFile
  148. //
  149. #define FILE_SUPERSEDED 0x00000000
  150. #define FILE_OPENED 0x00000001
  151. #define FILE_CREATED 0x00000002
  152. #define FILE_OVERWRITTEN 0x00000003
  153. #define FILE_EXISTS 0x00000004
  154. #define FILE_DOES_NOT_EXIST 0x00000005
  155. // end_ntddk end_wdm end_nthal
  156. //
  157. // Define the I/O status information return values for requests for oplocks
  158. // via NtFsControlFile
  159. //
  160. #define FILE_OPLOCK_BROKEN_TO_LEVEL_2 0x00000007
  161. #define FILE_OPLOCK_BROKEN_TO_NONE 0x00000008
  162. //
  163. // Define the I/O status information return values for NtCreateFile/NtOpenFile
  164. // when the sharing access fails but a batch oplock break is in progress
  165. //
  166. #define FILE_OPBATCH_BREAK_UNDERWAY 0x00000009
  167. //
  168. // Define the filter flags for NtNotifyChangeDirectoryFile
  169. //
  170. #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 // winnt
  171. #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 // winnt
  172. #define FILE_NOTIFY_CHANGE_NAME 0x00000003
  173. #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 // winnt
  174. #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 // winnt
  175. #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 // winnt
  176. #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 // winnt
  177. #define FILE_NOTIFY_CHANGE_CREATION 0x00000040 // winnt
  178. #define FILE_NOTIFY_CHANGE_EA 0x00000080
  179. #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 // winnt
  180. #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
  181. #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
  182. #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
  183. #define FILE_NOTIFY_VALID_MASK 0x00000fff
  184. //
  185. // Define the file action type codes for NtNotifyChangeDirectoryFile
  186. //
  187. #define FILE_ACTION_ADDED 0x00000001 // winnt
  188. #define FILE_ACTION_REMOVED 0x00000002 // winnt
  189. #define FILE_ACTION_MODIFIED 0x00000003 // winnt
  190. #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 // winnt
  191. #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 // winnt
  192. #define FILE_ACTION_ADDED_STREAM 0x00000006
  193. #define FILE_ACTION_REMOVED_STREAM 0x00000007
  194. #define FILE_ACTION_MODIFIED_STREAM 0x00000008
  195. #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
  196. #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A
  197. #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B
  198. //
  199. // Define the NamedPipeType flags for NtCreateNamedPipeFile
  200. //
  201. #define FILE_PIPE_BYTE_STREAM_TYPE 0x00000000
  202. #define FILE_PIPE_MESSAGE_TYPE 0x00000001
  203. //
  204. // Define the CompletionMode flags for NtCreateNamedPipeFile
  205. //
  206. #define FILE_PIPE_QUEUE_OPERATION 0x00000000
  207. #define FILE_PIPE_COMPLETE_OPERATION 0x00000001
  208. //
  209. // Define the ReadMode flags for NtCreateNamedPipeFile
  210. //
  211. #define FILE_PIPE_BYTE_STREAM_MODE 0x00000000
  212. #define FILE_PIPE_MESSAGE_MODE 0x00000001
  213. //
  214. // Define the NamedPipeConfiguration flags for NtQueryInformation
  215. //
  216. #define FILE_PIPE_INBOUND 0x00000000
  217. #define FILE_PIPE_OUTBOUND 0x00000001
  218. #define FILE_PIPE_FULL_DUPLEX 0x00000002
  219. //
  220. // Define the NamedPipeState flags for NtQueryInformation
  221. //
  222. #define FILE_PIPE_DISCONNECTED_STATE 0x00000001
  223. #define FILE_PIPE_LISTENING_STATE 0x00000002
  224. #define FILE_PIPE_CONNECTED_STATE 0x00000003
  225. #define FILE_PIPE_CLOSING_STATE 0x00000004
  226. //
  227. // Define the NamedPipeEnd flags for NtQueryInformation
  228. //
  229. #define FILE_PIPE_CLIENT_END 0x00000000
  230. #define FILE_PIPE_SERVER_END 0x00000001
  231. // end_ntifs
  232. //
  233. // Special values for mailslot information.
  234. //
  235. //
  236. // Special value for NextMessageSize to indicate that there is no next
  237. // message.
  238. //
  239. #define MAILSLOT_NO_MESSAGE ((ULONG)-1) // winnt
  240. //
  241. // Special value for mailslot size creation to indicate that MSFS should
  242. // choose the size of the mailslot buffer.
  243. //
  244. #define MAILSLOT_SIZE_AUTO 0
  245. //
  246. // Special value for read timeout to indicate that mailslot reads should
  247. // never timeout.
  248. //
  249. #define MAILSLOT_WAIT_FOREVER ((ULONG)-1) // winnt
  250. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  251. //
  252. // Define special ByteOffset parameters for read and write operations
  253. //
  254. #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
  255. #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
  256. //
  257. // Define alignment requirement values
  258. //
  259. #define FILE_BYTE_ALIGNMENT 0x00000000
  260. #define FILE_WORD_ALIGNMENT 0x00000001
  261. #define FILE_LONG_ALIGNMENT 0x00000003
  262. #define FILE_QUAD_ALIGNMENT 0x00000007
  263. #define FILE_OCTA_ALIGNMENT 0x0000000f
  264. #define FILE_32_BYTE_ALIGNMENT 0x0000001f
  265. #define FILE_64_BYTE_ALIGNMENT 0x0000003f
  266. #define FILE_128_BYTE_ALIGNMENT 0x0000007f
  267. #define FILE_256_BYTE_ALIGNMENT 0x000000ff
  268. #define FILE_512_BYTE_ALIGNMENT 0x000001ff
  269. //
  270. // Define the maximum length of a filename string
  271. //
  272. #define MAXIMUM_FILENAME_LENGTH 256
  273. // end_ntddk end_wdm end_nthal
  274. //
  275. // Define the file system attributes flags
  276. //
  277. #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 // winnt
  278. #define FILE_CASE_PRESERVED_NAMES 0x00000002 // winnt
  279. #define FILE_UNICODE_ON_DISK 0x00000004 // winnt
  280. #define FILE_PERSISTENT_ACLS 0x00000008 // winnt
  281. #define FILE_FILE_COMPRESSION 0x00000010 // winnt
  282. #define FILE_VOLUME_QUOTAS 0x00000020 // winnt
  283. #define FILE_SUPPORTS_SPARSE_FILES 0x00000040 // winnt
  284. #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 // winnt
  285. #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 // winnt
  286. #define FILE_VOLUME_IS_COMPRESSED 0x00008000 // winnt
  287. #define FILE_SUPPORTS_OBJECT_IDS 0x00010000 // winnt
  288. #define FILE_SUPPORTS_ENCRYPTION 0x00020000 // winnt
  289. #define FILE_NAMED_STREAMS 0x00040000 // winnt
  290. #define FILE_READ_ONLY_VOLUME 0x00080000 // winnt
  291. //
  292. // Define the flags for NtSet(Query)EaFile service structure entries
  293. //
  294. #define FILE_NEED_EA 0x00000080
  295. //
  296. // Define EA type values
  297. //
  298. #define FILE_EA_TYPE_BINARY 0xfffe
  299. #define FILE_EA_TYPE_ASCII 0xfffd
  300. #define FILE_EA_TYPE_BITMAP 0xfffb
  301. #define FILE_EA_TYPE_METAFILE 0xfffa
  302. #define FILE_EA_TYPE_ICON 0xfff9
  303. #define FILE_EA_TYPE_EA 0xffee
  304. #define FILE_EA_TYPE_MVMT 0xffdf
  305. #define FILE_EA_TYPE_MVST 0xffde
  306. #define FILE_EA_TYPE_ASN1 0xffdd
  307. #define FILE_EA_TYPE_FAMILY_IDS 0xff01
  308. // begin_ntddk begin_wdm begin_nthal
  309. //
  310. // Define the various device characteristics flags
  311. //
  312. #define FILE_REMOVABLE_MEDIA 0x00000001
  313. #define FILE_READ_ONLY_DEVICE 0x00000002
  314. #define FILE_FLOPPY_DISKETTE 0x00000004
  315. #define FILE_WRITE_ONCE_MEDIA 0x00000008
  316. #define FILE_REMOTE_DEVICE 0x00000010
  317. #define FILE_DEVICE_IS_MOUNTED 0x00000020
  318. #define FILE_VIRTUAL_VOLUME 0x00000040
  319. #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
  320. #define FILE_DEVICE_SECURE_OPEN 0x00000100
  321. #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800
  322. // end_wdm
  323. //
  324. // The FILE_EXPECT flags will only exist for WinXP. After that they will be
  325. // ignored and an IRP will be sent in their place.
  326. //
  327. #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
  328. #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
  329. #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
  330. //
  331. // flags specified here will be propagated up and down a device stack
  332. // after FDO and all filter devices are added, but before the device
  333. // stack is started
  334. //
  335. #define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \
  336. FILE_READ_ONLY_DEVICE | \
  337. FILE_FLOPPY_DISKETTE | \
  338. FILE_WRITE_ONCE_MEDIA | \
  339. FILE_DEVICE_SECURE_OPEN )
  340. // end_ntddk end_nthal
  341. // begin_ntddk begin_wdm begin_nthal
  342. //
  343. // Define the base asynchronous I/O argument types
  344. //
  345. typedef struct _IO_STATUS_BLOCK {
  346. union {
  347. NTSTATUS Status;
  348. PVOID Pointer;
  349. };
  350. ULONG_PTR Information;
  351. } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
  352. #if defined(_WIN64)
  353. typedef struct _IO_STATUS_BLOCK32 {
  354. NTSTATUS Status;
  355. ULONG Information;
  356. } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
  357. #endif
  358. //
  359. // Define an Asynchronous Procedure Call from I/O viewpoint
  360. //
  361. typedef
  362. VOID
  363. (NTAPI *PIO_APC_ROUTINE) (
  364. IN PVOID ApcContext,
  365. IN PIO_STATUS_BLOCK IoStatusBlock,
  366. IN ULONG Reserved
  367. );
  368. #define PIO_APC_ROUTINE_DEFINED
  369. // end_ntddk end_wdm end_nthal
  370. // begin_winnt
  371. //
  372. // Define the file notification information structure
  373. //
  374. typedef struct _FILE_NOTIFY_INFORMATION {
  375. ULONG NextEntryOffset;
  376. ULONG Action;
  377. ULONG FileNameLength;
  378. WCHAR FileName[1];
  379. } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
  380. // end_winnt
  381. // begin_ntddk begin_wdm begin_nthal
  382. //
  383. // Define the file information class values
  384. //
  385. // WARNING: The order of the following values are assumed by the I/O system.
  386. // Any changes made here should be reflected there as well.
  387. //
  388. typedef enum _FILE_INFORMATION_CLASS {
  389. // end_wdm
  390. FileDirectoryInformation = 1,
  391. FileFullDirectoryInformation, // 2
  392. FileBothDirectoryInformation, // 3
  393. FileBasicInformation, // 4 wdm
  394. FileStandardInformation, // 5 wdm
  395. FileInternalInformation, // 6
  396. FileEaInformation, // 7
  397. FileAccessInformation, // 8
  398. FileNameInformation, // 9
  399. FileRenameInformation, // 10
  400. FileLinkInformation, // 11
  401. FileNamesInformation, // 12
  402. FileDispositionInformation, // 13
  403. FilePositionInformation, // 14 wdm
  404. FileFullEaInformation, // 15
  405. FileModeInformation, // 16
  406. FileAlignmentInformation, // 17
  407. FileAllInformation, // 18
  408. FileAllocationInformation, // 19
  409. FileEndOfFileInformation, // 20 wdm
  410. FileAlternateNameInformation, // 21
  411. FileStreamInformation, // 22
  412. FilePipeInformation, // 23
  413. FilePipeLocalInformation, // 24
  414. FilePipeRemoteInformation, // 25
  415. FileMailslotQueryInformation, // 26
  416. FileMailslotSetInformation, // 27
  417. FileCompressionInformation, // 28
  418. FileObjectIdInformation, // 29
  419. FileCompletionInformation, // 30
  420. FileMoveClusterInformation, // 31
  421. FileQuotaInformation, // 32
  422. FileReparsePointInformation, // 33
  423. FileNetworkOpenInformation, // 34
  424. FileAttributeTagInformation, // 35
  425. FileTrackingInformation, // 36
  426. FileIdBothDirectoryInformation, // 37
  427. FileIdFullDirectoryInformation, // 38
  428. FileValidDataLengthInformation, // 39
  429. FileShortNameInformation, // 40
  430. FileMaximumInformation
  431. // begin_wdm
  432. } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
  433. //
  434. // Define the various structures which are returned on query operations
  435. //
  436. // end_ntddk end_wdm end_nthal
  437. //
  438. // NtQueryDirectoryFile return types:
  439. //
  440. // FILE_DIRECTORY_INFORMATION
  441. // FILE_FULL_DIR_INFORMATION
  442. // FILE_ID_FULL_DIR_INFORMATION
  443. // FILE_BOTH_DIR_INFORMATION
  444. // FILE_ID_BOTH_DIR_INFORMATION
  445. // FILE_NAMES_INFORMATION
  446. // FILE_OBJECTID_INFORMATION
  447. //
  448. typedef struct _FILE_DIRECTORY_INFORMATION {
  449. ULONG NextEntryOffset;
  450. ULONG FileIndex;
  451. LARGE_INTEGER CreationTime;
  452. LARGE_INTEGER LastAccessTime;
  453. LARGE_INTEGER LastWriteTime;
  454. LARGE_INTEGER ChangeTime;
  455. LARGE_INTEGER EndOfFile;
  456. LARGE_INTEGER AllocationSize;
  457. ULONG FileAttributes;
  458. ULONG FileNameLength;
  459. WCHAR FileName[1];
  460. } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
  461. typedef struct _FILE_FULL_DIR_INFORMATION {
  462. ULONG NextEntryOffset;
  463. ULONG FileIndex;
  464. LARGE_INTEGER CreationTime;
  465. LARGE_INTEGER LastAccessTime;
  466. LARGE_INTEGER LastWriteTime;
  467. LARGE_INTEGER ChangeTime;
  468. LARGE_INTEGER EndOfFile;
  469. LARGE_INTEGER AllocationSize;
  470. ULONG FileAttributes;
  471. ULONG FileNameLength;
  472. ULONG EaSize;
  473. WCHAR FileName[1];
  474. } FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
  475. typedef struct _FILE_ID_FULL_DIR_INFORMATION {
  476. ULONG NextEntryOffset;
  477. ULONG FileIndex;
  478. LARGE_INTEGER CreationTime;
  479. LARGE_INTEGER LastAccessTime;
  480. LARGE_INTEGER LastWriteTime;
  481. LARGE_INTEGER ChangeTime;
  482. LARGE_INTEGER EndOfFile;
  483. LARGE_INTEGER AllocationSize;
  484. ULONG FileAttributes;
  485. ULONG FileNameLength;
  486. ULONG EaSize;
  487. LARGE_INTEGER FileId;
  488. WCHAR FileName[1];
  489. } FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;
  490. typedef struct _FILE_BOTH_DIR_INFORMATION {
  491. ULONG NextEntryOffset;
  492. ULONG FileIndex;
  493. LARGE_INTEGER CreationTime;
  494. LARGE_INTEGER LastAccessTime;
  495. LARGE_INTEGER LastWriteTime;
  496. LARGE_INTEGER ChangeTime;
  497. LARGE_INTEGER EndOfFile;
  498. LARGE_INTEGER AllocationSize;
  499. ULONG FileAttributes;
  500. ULONG FileNameLength;
  501. ULONG EaSize;
  502. CCHAR ShortNameLength;
  503. WCHAR ShortName[12];
  504. WCHAR FileName[1];
  505. } FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
  506. typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
  507. ULONG NextEntryOffset;
  508. ULONG FileIndex;
  509. LARGE_INTEGER CreationTime;
  510. LARGE_INTEGER LastAccessTime;
  511. LARGE_INTEGER LastWriteTime;
  512. LARGE_INTEGER ChangeTime;
  513. LARGE_INTEGER EndOfFile;
  514. LARGE_INTEGER AllocationSize;
  515. ULONG FileAttributes;
  516. ULONG FileNameLength;
  517. ULONG EaSize;
  518. CCHAR ShortNameLength;
  519. WCHAR ShortName[12];
  520. LARGE_INTEGER FileId;
  521. WCHAR FileName[1];
  522. } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
  523. typedef struct _FILE_NAMES_INFORMATION {
  524. ULONG NextEntryOffset;
  525. ULONG FileIndex;
  526. ULONG FileNameLength;
  527. WCHAR FileName[1];
  528. } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
  529. typedef struct _FILE_OBJECTID_INFORMATION {
  530. LONGLONG FileReference;
  531. UCHAR ObjectId[16];
  532. union {
  533. struct {
  534. UCHAR BirthVolumeId[16];
  535. UCHAR BirthObjectId[16];
  536. UCHAR DomainId[16];
  537. } ;
  538. UCHAR ExtendedInfo[48];
  539. };
  540. } FILE_OBJECTID_INFORMATION, *PFILE_OBJECTID_INFORMATION;
  541. //
  542. // The following constants provide addition meta characters to fully
  543. // support the more obscure aspects of DOS wild card processing.
  544. //
  545. #define ANSI_DOS_STAR ('<')
  546. #define ANSI_DOS_QM ('>')
  547. #define ANSI_DOS_DOT ('"')
  548. #define DOS_STAR (L'<')
  549. #define DOS_QM (L'>')
  550. #define DOS_DOT (L'"')
  551. //
  552. // NtQuery(Set)InformationFile return types:
  553. //
  554. // FILE_BASIC_INFORMATION
  555. // FILE_STANDARD_INFORMATION
  556. // FILE_INTERNAL_INFORMATION
  557. // FILE_EA_INFORMATION
  558. // FILE_ACCESS_INFORMATION
  559. // FILE_POSITION_INFORMATION
  560. // FILE_MODE_INFORMATION
  561. // FILE_ALIGNMENT_INFORMATION
  562. // FILE_NAME_INFORMATION
  563. // FILE_ALL_INFORMATION
  564. //
  565. // FILE_NETWORK_OPEN_INFORMATION
  566. //
  567. // FILE_ALLOCATION_INFORMATION
  568. // FILE_COMPRESSION_INFORMATION
  569. // FILE_DISPOSITION_INFORMATION
  570. // FILE_END_OF_FILE_INFORMATION
  571. // FILE_LINK_INFORMATION
  572. // FILE_MOVE_CLUSTER_INFORMATION
  573. // FILE_RENAME_INFORMATION
  574. // FILE_SHORT_NAME_INFORMATION
  575. // FILE_STREAM_INFORMATION
  576. // FILE_COMPLETION_INFORMATION
  577. //
  578. // FILE_PIPE_INFORMATION
  579. // FILE_PIPE_LOCAL_INFORMATION
  580. // FILE_PIPE_REMOTE_INFORMATION
  581. //
  582. // FILE_MAILSLOT_QUERY_INFORMATION
  583. // FILE_MAILSLOT_SET_INFORMATION
  584. // FILE_REPARSE_POINT_INFORMATION
  585. //
  586. typedef struct _FILE_BASIC_INFORMATION { // ntddk wdm nthal
  587. LARGE_INTEGER CreationTime; // ntddk wdm nthal
  588. LARGE_INTEGER LastAccessTime; // ntddk wdm nthal
  589. LARGE_INTEGER LastWriteTime; // ntddk wdm nthal
  590. LARGE_INTEGER ChangeTime; // ntddk wdm nthal
  591. ULONG FileAttributes; // ntddk wdm nthal
  592. } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; // ntddk wdm nthal
  593. // ntddk wdm nthal
  594. typedef struct _FILE_STANDARD_INFORMATION { // ntddk wdm nthal
  595. LARGE_INTEGER AllocationSize; // ntddk wdm nthal
  596. LARGE_INTEGER EndOfFile; // ntddk wdm nthal
  597. ULONG NumberOfLinks; // ntddk wdm nthal
  598. BOOLEAN DeletePending; // ntddk wdm nthal
  599. BOOLEAN Directory; // ntddk wdm nthal
  600. } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; // ntddk wdm nthal
  601. // ntddk wdm nthal
  602. typedef struct _FILE_INTERNAL_INFORMATION {
  603. LARGE_INTEGER IndexNumber;
  604. } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
  605. typedef struct _FILE_EA_INFORMATION {
  606. ULONG EaSize;
  607. } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
  608. typedef struct _FILE_ACCESS_INFORMATION {
  609. ACCESS_MASK AccessFlags;
  610. } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
  611. typedef struct _FILE_POSITION_INFORMATION { // ntddk wdm nthal
  612. LARGE_INTEGER CurrentByteOffset; // ntddk wdm nthal
  613. } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; // ntddk wdm nthal
  614. // ntddk wdm nthal
  615. typedef struct _FILE_MODE_INFORMATION {
  616. ULONG Mode;
  617. } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
  618. typedef struct _FILE_ALIGNMENT_INFORMATION { // ntddk nthal
  619. ULONG AlignmentRequirement; // ntddk nthal
  620. } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; // ntddk nthal
  621. // ntddk nthal
  622. typedef struct _FILE_NAME_INFORMATION { // ntddk
  623. ULONG FileNameLength; // ntddk
  624. WCHAR FileName[1]; // ntddk
  625. } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; // ntddk
  626. // ntddk
  627. typedef struct _FILE_ALL_INFORMATION {
  628. FILE_BASIC_INFORMATION BasicInformation;
  629. FILE_STANDARD_INFORMATION StandardInformation;
  630. FILE_INTERNAL_INFORMATION InternalInformation;
  631. FILE_EA_INFORMATION EaInformation;
  632. FILE_ACCESS_INFORMATION AccessInformation;
  633. FILE_POSITION_INFORMATION PositionInformation;
  634. FILE_MODE_INFORMATION ModeInformation;
  635. FILE_ALIGNMENT_INFORMATION AlignmentInformation;
  636. FILE_NAME_INFORMATION NameInformation;
  637. } FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
  638. typedef struct _FILE_NETWORK_OPEN_INFORMATION { // ntddk wdm nthal
  639. LARGE_INTEGER CreationTime; // ntddk wdm nthal
  640. LARGE_INTEGER LastAccessTime; // ntddk wdm nthal
  641. LARGE_INTEGER LastWriteTime; // ntddk wdm nthal
  642. LARGE_INTEGER ChangeTime; // ntddk wdm nthal
  643. LARGE_INTEGER AllocationSize; // ntddk wdm nthal
  644. LARGE_INTEGER EndOfFile; // ntddk wdm nthal
  645. ULONG FileAttributes; // ntddk wdm nthal
  646. } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; // ntddk wdm nthal
  647. // ntddk wdm nthal
  648. typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { // ntddk nthal
  649. ULONG FileAttributes; // ntddk nthal
  650. ULONG ReparseTag; // ntddk nthal
  651. } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; // ntddk nthal
  652. // ntddk nthal
  653. typedef struct _FILE_ALLOCATION_INFORMATION {
  654. LARGE_INTEGER AllocationSize;
  655. } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
  656. typedef struct _FILE_COMPRESSION_INFORMATION {
  657. LARGE_INTEGER CompressedFileSize;
  658. USHORT CompressionFormat;
  659. UCHAR CompressionUnitShift;
  660. UCHAR ChunkShift;
  661. UCHAR ClusterShift;
  662. UCHAR Reserved[3];
  663. } FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
  664. typedef struct _FILE_DISPOSITION_INFORMATION { // ntddk nthal
  665. BOOLEAN DeleteFile; // ntddk nthal
  666. } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; // ntddk nthal
  667. // ntddk nthal
  668. typedef struct _FILE_END_OF_FILE_INFORMATION { // ntddk nthal
  669. LARGE_INTEGER EndOfFile; // ntddk nthal
  670. } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; // ntddk nthal
  671. // ntddk nthal
  672. typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { // ntddk nthal
  673. LARGE_INTEGER ValidDataLength; // ntddk nthal
  674. } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; // ntddk nthal
  675. #ifdef _MAC
  676. #pragma warning( disable : 4121)
  677. #endif
  678. typedef struct _FILE_LINK_INFORMATION {
  679. BOOLEAN ReplaceIfExists;
  680. HANDLE RootDirectory;
  681. ULONG FileNameLength;
  682. WCHAR FileName[1];
  683. } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
  684. #ifdef _MAC
  685. #pragma warning( default : 4121 )
  686. #endif
  687. typedef struct _FILE_MOVE_CLUSTER_INFORMATION {
  688. ULONG ClusterCount;
  689. HANDLE RootDirectory;
  690. ULONG FileNameLength;
  691. WCHAR FileName[1];
  692. } FILE_MOVE_CLUSTER_INFORMATION, *PFILE_MOVE_CLUSTER_INFORMATION;
  693. #ifdef _MAC
  694. #pragma warning( disable : 4121)
  695. #endif
  696. typedef struct _FILE_RENAME_INFORMATION {
  697. BOOLEAN ReplaceIfExists;
  698. HANDLE RootDirectory;
  699. ULONG FileNameLength;
  700. WCHAR FileName[1];
  701. } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
  702. #ifdef _MAC
  703. #pragma warning( default : 4121 )
  704. #endif
  705. typedef struct _FILE_STREAM_INFORMATION {
  706. ULONG NextEntryOffset;
  707. ULONG StreamNameLength;
  708. LARGE_INTEGER StreamSize;
  709. LARGE_INTEGER StreamAllocationSize;
  710. WCHAR StreamName[1];
  711. } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
  712. typedef struct _FILE_TRACKING_INFORMATION {
  713. HANDLE DestinationFile;
  714. ULONG ObjectInformationLength;
  715. CHAR ObjectInformation[1];
  716. } FILE_TRACKING_INFORMATION, *PFILE_TRACKING_INFORMATION;
  717. typedef struct _FILE_COMPLETION_INFORMATION {
  718. HANDLE Port;
  719. PVOID Key;
  720. } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
  721. typedef struct _FILE_PIPE_INFORMATION {
  722. ULONG ReadMode;
  723. ULONG CompletionMode;
  724. } FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
  725. typedef struct _FILE_PIPE_LOCAL_INFORMATION {
  726. ULONG NamedPipeType;
  727. ULONG NamedPipeConfiguration;
  728. ULONG MaximumInstances;
  729. ULONG CurrentInstances;
  730. ULONG InboundQuota;
  731. ULONG ReadDataAvailable;
  732. ULONG OutboundQuota;
  733. ULONG WriteQuotaAvailable;
  734. ULONG NamedPipeState;
  735. ULONG NamedPipeEnd;
  736. } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
  737. typedef struct _FILE_PIPE_REMOTE_INFORMATION {
  738. LARGE_INTEGER CollectDataTime;
  739. ULONG MaximumCollectionCount;
  740. } FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
  741. typedef struct _FILE_MAILSLOT_QUERY_INFORMATION {
  742. ULONG MaximumMessageSize;
  743. ULONG MailslotQuota;
  744. ULONG NextMessageSize;
  745. ULONG MessagesAvailable;
  746. LARGE_INTEGER ReadTimeout;
  747. } FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION;
  748. typedef struct _FILE_MAILSLOT_SET_INFORMATION {
  749. PLARGE_INTEGER ReadTimeout;
  750. } FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
  751. typedef struct _FILE_REPARSE_POINT_INFORMATION {
  752. LONGLONG FileReference;
  753. ULONG Tag;
  754. } FILE_REPARSE_POINT_INFORMATION, *PFILE_REPARSE_POINT_INFORMATION;
  755. //
  756. // NtQuery(Set)EaFile
  757. //
  758. // The offset for the start of EaValue is EaName[EaNameLength + 1]
  759. //
  760. // begin_ntddk begin_wdm
  761. typedef struct _FILE_FULL_EA_INFORMATION {
  762. ULONG NextEntryOffset;
  763. UCHAR Flags;
  764. UCHAR EaNameLength;
  765. USHORT EaValueLength;
  766. CHAR EaName[1];
  767. } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
  768. // end_ntddk end_wdm
  769. typedef struct _FILE_GET_EA_INFORMATION {
  770. ULONG NextEntryOffset;
  771. UCHAR EaNameLength;
  772. CHAR EaName[1];
  773. } FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
  774. //
  775. // NtQuery(Set)QuotaInformationFile
  776. //
  777. typedef struct _FILE_GET_QUOTA_INFORMATION {
  778. ULONG NextEntryOffset;
  779. ULONG SidLength;
  780. SID Sid;
  781. } FILE_GET_QUOTA_INFORMATION, *PFILE_GET_QUOTA_INFORMATION;
  782. typedef struct _FILE_QUOTA_INFORMATION {
  783. ULONG NextEntryOffset;
  784. ULONG SidLength;
  785. LARGE_INTEGER ChangeTime;
  786. LARGE_INTEGER QuotaUsed;
  787. LARGE_INTEGER QuotaThreshold;
  788. LARGE_INTEGER QuotaLimit;
  789. SID Sid;
  790. } FILE_QUOTA_INFORMATION, *PFILE_QUOTA_INFORMATION;
  791. // begin_ntddk begin_wdm begin_nthal
  792. //
  793. // Define the file system information class values
  794. //
  795. // WARNING: The order of the following values are assumed by the I/O system.
  796. // Any changes made here should be reflected there as well.
  797. typedef enum _FSINFOCLASS {
  798. FileFsVolumeInformation = 1,
  799. FileFsLabelInformation, // 2
  800. FileFsSizeInformation, // 3
  801. FileFsDeviceInformation, // 4
  802. FileFsAttributeInformation, // 5
  803. FileFsControlInformation, // 6
  804. FileFsFullSizeInformation, // 7
  805. FileFsObjectIdInformation, // 8
  806. FileFsDriverPathInformation, // 9
  807. FileFsMaximumInformation
  808. } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
  809. // end_ntddk end_wdm end_nthal
  810. //
  811. // NtQuery[Set]VolumeInformationFile types:
  812. //
  813. // FILE_FS_LABEL_INFORMATION
  814. // FILE_FS_VOLUME_INFORMATION
  815. // FILE_FS_SIZE_INFORMATION
  816. // FILE_FS_DEVICE_INFORMATION
  817. // FILE_FS_ATTRIBUTE_INFORMATION
  818. // FILE_FS_CONTROL_INFORMATION
  819. // FILE_FS_OBJECTID_INFORMATION
  820. //
  821. typedef struct _FILE_FS_LABEL_INFORMATION {
  822. ULONG VolumeLabelLength;
  823. WCHAR VolumeLabel[1];
  824. } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
  825. typedef struct _FILE_FS_VOLUME_INFORMATION {
  826. LARGE_INTEGER VolumeCreationTime;
  827. ULONG VolumeSerialNumber;
  828. ULONG VolumeLabelLength;
  829. BOOLEAN SupportsObjects;
  830. WCHAR VolumeLabel[1];
  831. } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
  832. typedef struct _FILE_FS_SIZE_INFORMATION {
  833. LARGE_INTEGER TotalAllocationUnits;
  834. LARGE_INTEGER AvailableAllocationUnits;
  835. ULONG SectorsPerAllocationUnit;
  836. ULONG BytesPerSector;
  837. } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
  838. typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
  839. LARGE_INTEGER TotalAllocationUnits;
  840. LARGE_INTEGER CallerAvailableAllocationUnits;
  841. LARGE_INTEGER ActualAvailableAllocationUnits;
  842. ULONG SectorsPerAllocationUnit;
  843. ULONG BytesPerSector;
  844. } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
  845. typedef struct _FILE_FS_OBJECTID_INFORMATION {
  846. UCHAR ObjectId[16];
  847. UCHAR ExtendedInfo[48];
  848. } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
  849. typedef struct _FILE_FS_DEVICE_INFORMATION { // ntddk wdm nthal
  850. DEVICE_TYPE DeviceType; // ntddk wdm nthal
  851. ULONG Characteristics; // ntddk wdm nthal
  852. } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; // ntddk wdm nthal
  853. // ntddk wdm nthal
  854. typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
  855. ULONG FileSystemAttributes;
  856. LONG MaximumComponentNameLength;
  857. ULONG FileSystemNameLength;
  858. WCHAR FileSystemName[1];
  859. } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
  860. typedef struct _FILE_FS_DRIVER_PATH_INFORMATION {
  861. BOOLEAN DriverInPath;
  862. ULONG DriverNameLength;
  863. WCHAR DriverName[1];
  864. } FILE_FS_DRIVER_PATH_INFORMATION, *PFILE_FS_DRIVER_PATH_INFORMATION;
  865. //
  866. // File system control flags
  867. //
  868. #define FILE_VC_QUOTA_NONE 0x00000000
  869. #define FILE_VC_QUOTA_TRACK 0x00000001
  870. #define FILE_VC_QUOTA_ENFORCE 0x00000002
  871. #define FILE_VC_QUOTA_MASK 0x00000003
  872. #define FILE_VC_CONTENT_INDEX_DISABLED 0x00000008
  873. #define FILE_VC_LOG_QUOTA_THRESHOLD 0x00000010
  874. #define FILE_VC_LOG_QUOTA_LIMIT 0x00000020
  875. #define FILE_VC_LOG_VOLUME_THRESHOLD 0x00000040
  876. #define FILE_VC_LOG_VOLUME_LIMIT 0x00000080
  877. #define FILE_VC_QUOTAS_INCOMPLETE 0x00000100
  878. #define FILE_VC_QUOTAS_REBUILDING 0x00000200
  879. #define FILE_VC_VALID_MASK 0x000003ff
  880. typedef struct _FILE_FS_CONTROL_INFORMATION {
  881. LARGE_INTEGER FreeSpaceStartFiltering;
  882. LARGE_INTEGER FreeSpaceThreshold;
  883. LARGE_INTEGER FreeSpaceStopFiltering;
  884. LARGE_INTEGER DefaultQuotaThreshold;
  885. LARGE_INTEGER DefaultQuotaLimit;
  886. ULONG FileSystemControlFlags;
  887. } FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION;
  888. // begin_winnt begin_ntddk begin_nthal
  889. //
  890. // Define segement buffer structure for scatter/gather read/write.
  891. //
  892. typedef union _FILE_SEGMENT_ELEMENT {
  893. PVOID64 Buffer;
  894. ULONGLONG Alignment;
  895. }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
  896. // end_ntifs end_winnt end_ntddk end_nthal
  897. //
  898. // I/O system user APIs
  899. //
  900. NTSYSCALLAPI
  901. NTSTATUS
  902. NTAPI
  903. NtCancelIoFile(
  904. IN HANDLE FileHandle,
  905. OUT PIO_STATUS_BLOCK IoStatusBlock
  906. );
  907. NTSYSCALLAPI
  908. NTSTATUS
  909. NTAPI
  910. NtCreateNamedPipeFile(
  911. OUT PHANDLE FileHandle,
  912. IN ULONG DesiredAccess,
  913. IN POBJECT_ATTRIBUTES ObjectAttributes,
  914. OUT PIO_STATUS_BLOCK IoStatusBlock,
  915. IN ULONG ShareAccess,
  916. IN ULONG CreateDisposition,
  917. IN ULONG CreateOptions,
  918. IN ULONG NamedPipeType,
  919. IN ULONG ReadMode,
  920. IN ULONG CompletionMode,
  921. IN ULONG MaximumInstances,
  922. IN ULONG InboundQuota,
  923. IN ULONG OutboundQuota,
  924. IN PLARGE_INTEGER DefaultTimeout OPTIONAL
  925. );
  926. NTSYSCALLAPI
  927. NTSTATUS
  928. NTAPI
  929. NtCreateMailslotFile(
  930. OUT PHANDLE FileHandle,
  931. IN ULONG DesiredAccess,
  932. IN POBJECT_ATTRIBUTES ObjectAttributes,
  933. OUT PIO_STATUS_BLOCK IoStatusBlock,
  934. ULONG CreateOptions,
  935. IN ULONG MailslotQuota,
  936. IN ULONG MaximumMessageSize,
  937. IN PLARGE_INTEGER ReadTimeout
  938. );
  939. NTSYSCALLAPI
  940. NTSTATUS
  941. NTAPI
  942. NtDeleteFile(
  943. IN POBJECT_ATTRIBUTES ObjectAttributes
  944. );
  945. NTSYSCALLAPI
  946. NTSTATUS
  947. NTAPI
  948. NtFlushBuffersFile(
  949. IN HANDLE FileHandle,
  950. OUT PIO_STATUS_BLOCK IoStatusBlock
  951. );
  952. NTSYSCALLAPI
  953. NTSTATUS
  954. NTAPI
  955. NtNotifyChangeDirectoryFile(
  956. IN HANDLE FileHandle,
  957. IN HANDLE Event OPTIONAL,
  958. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  959. IN PVOID ApcContext OPTIONAL,
  960. OUT PIO_STATUS_BLOCK IoStatusBlock,
  961. OUT PVOID Buffer,
  962. IN ULONG Length,
  963. IN ULONG CompletionFilter,
  964. IN BOOLEAN WatchTree
  965. );
  966. NTSYSCALLAPI
  967. NTSTATUS
  968. NTAPI
  969. NtQueryAttributesFile(
  970. IN POBJECT_ATTRIBUTES ObjectAttributes,
  971. OUT PFILE_BASIC_INFORMATION FileInformation
  972. );
  973. NTSYSCALLAPI
  974. NTSTATUS
  975. NTAPI
  976. NtQueryFullAttributesFile(
  977. IN POBJECT_ATTRIBUTES ObjectAttributes,
  978. OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation
  979. );
  980. NTSYSCALLAPI
  981. NTSTATUS
  982. NTAPI
  983. NtQueryEaFile(
  984. IN HANDLE FileHandle,
  985. OUT PIO_STATUS_BLOCK IoStatusBlock,
  986. OUT PVOID Buffer,
  987. IN ULONG Length,
  988. IN BOOLEAN ReturnSingleEntry,
  989. IN PVOID EaList OPTIONAL,
  990. IN ULONG EaListLength,
  991. IN PULONG EaIndex OPTIONAL,
  992. IN BOOLEAN RestartScan
  993. );
  994. // begin_ntifs
  995. NTSYSCALLAPI
  996. NTSTATUS
  997. NTAPI
  998. NtCreateFile(
  999. OUT PHANDLE FileHandle,
  1000. IN ACCESS_MASK DesiredAccess,
  1001. IN POBJECT_ATTRIBUTES ObjectAttributes,
  1002. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1003. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  1004. IN ULONG FileAttributes,
  1005. IN ULONG ShareAccess,
  1006. IN ULONG CreateDisposition,
  1007. IN ULONG CreateOptions,
  1008. IN PVOID EaBuffer OPTIONAL,
  1009. IN ULONG EaLength
  1010. );
  1011. NTSYSCALLAPI
  1012. NTSTATUS
  1013. NTAPI
  1014. NtDeviceIoControlFile(
  1015. IN HANDLE FileHandle,
  1016. IN HANDLE Event OPTIONAL,
  1017. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1018. IN PVOID ApcContext OPTIONAL,
  1019. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1020. IN ULONG IoControlCode,
  1021. IN PVOID InputBuffer OPTIONAL,
  1022. IN ULONG InputBufferLength,
  1023. OUT PVOID OutputBuffer OPTIONAL,
  1024. IN ULONG OutputBufferLength
  1025. );
  1026. NTSYSCALLAPI
  1027. NTSTATUS
  1028. NTAPI
  1029. NtFsControlFile(
  1030. IN HANDLE FileHandle,
  1031. IN HANDLE Event OPTIONAL,
  1032. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1033. IN PVOID ApcContext OPTIONAL,
  1034. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1035. IN ULONG FsControlCode,
  1036. IN PVOID InputBuffer OPTIONAL,
  1037. IN ULONG InputBufferLength,
  1038. OUT PVOID OutputBuffer OPTIONAL,
  1039. IN ULONG OutputBufferLength
  1040. );
  1041. NTSYSCALLAPI
  1042. NTSTATUS
  1043. NTAPI
  1044. NtLockFile(
  1045. IN HANDLE FileHandle,
  1046. IN HANDLE Event OPTIONAL,
  1047. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1048. IN PVOID ApcContext OPTIONAL,
  1049. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1050. IN PLARGE_INTEGER ByteOffset,
  1051. IN PLARGE_INTEGER Length,
  1052. IN ULONG Key,
  1053. IN BOOLEAN FailImmediately,
  1054. IN BOOLEAN ExclusiveLock
  1055. );
  1056. NTSYSCALLAPI
  1057. NTSTATUS
  1058. NTAPI
  1059. NtOpenFile(
  1060. OUT PHANDLE FileHandle,
  1061. IN ACCESS_MASK DesiredAccess,
  1062. IN POBJECT_ATTRIBUTES ObjectAttributes,
  1063. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1064. IN ULONG ShareAccess,
  1065. IN ULONG OpenOptions
  1066. );
  1067. NTSYSCALLAPI
  1068. NTSTATUS
  1069. NTAPI
  1070. NtQueryDirectoryFile(
  1071. IN HANDLE FileHandle,
  1072. IN HANDLE Event OPTIONAL,
  1073. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1074. IN PVOID ApcContext OPTIONAL,
  1075. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1076. OUT PVOID FileInformation,
  1077. IN ULONG Length,
  1078. IN FILE_INFORMATION_CLASS FileInformationClass,
  1079. IN BOOLEAN ReturnSingleEntry,
  1080. IN PUNICODE_STRING FileName OPTIONAL,
  1081. IN BOOLEAN RestartScan
  1082. );
  1083. NTSYSCALLAPI
  1084. NTSTATUS
  1085. NTAPI
  1086. NtQueryInformationFile(
  1087. IN HANDLE FileHandle,
  1088. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1089. OUT PVOID FileInformation,
  1090. IN ULONG Length,
  1091. IN FILE_INFORMATION_CLASS FileInformationClass
  1092. );
  1093. NTSYSCALLAPI
  1094. NTSTATUS
  1095. NTAPI
  1096. NtQueryQuotaInformationFile(
  1097. IN HANDLE FileHandle,
  1098. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1099. OUT PVOID Buffer,
  1100. IN ULONG Length,
  1101. IN BOOLEAN ReturnSingleEntry,
  1102. IN PVOID SidList OPTIONAL,
  1103. IN ULONG SidListLength,
  1104. IN PSID StartSid OPTIONAL,
  1105. IN BOOLEAN RestartScan
  1106. );
  1107. NTSYSCALLAPI
  1108. NTSTATUS
  1109. NTAPI
  1110. NtQueryVolumeInformationFile(
  1111. IN HANDLE FileHandle,
  1112. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1113. OUT PVOID FsInformation,
  1114. IN ULONG Length,
  1115. IN FS_INFORMATION_CLASS FsInformationClass
  1116. );
  1117. NTSYSCALLAPI
  1118. NTSTATUS
  1119. NTAPI
  1120. NtReadFile(
  1121. IN HANDLE FileHandle,
  1122. IN HANDLE Event OPTIONAL,
  1123. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1124. IN PVOID ApcContext OPTIONAL,
  1125. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1126. OUT PVOID Buffer,
  1127. IN ULONG Length,
  1128. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  1129. IN PULONG Key OPTIONAL
  1130. );
  1131. NTSYSCALLAPI
  1132. NTSTATUS
  1133. NTAPI
  1134. NtSetInformationFile(
  1135. IN HANDLE FileHandle,
  1136. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1137. IN PVOID FileInformation,
  1138. IN ULONG Length,
  1139. IN FILE_INFORMATION_CLASS FileInformationClass
  1140. );
  1141. NTSYSCALLAPI
  1142. NTSTATUS
  1143. NTAPI
  1144. NtSetQuotaInformationFile(
  1145. IN HANDLE FileHandle,
  1146. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1147. IN PVOID Buffer,
  1148. IN ULONG Length
  1149. );
  1150. NTSYSCALLAPI
  1151. NTSTATUS
  1152. NTAPI
  1153. NtSetVolumeInformationFile(
  1154. IN HANDLE FileHandle,
  1155. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1156. IN PVOID FsInformation,
  1157. IN ULONG Length,
  1158. IN FS_INFORMATION_CLASS FsInformationClass
  1159. );
  1160. NTSYSCALLAPI
  1161. NTSTATUS
  1162. NTAPI
  1163. NtWriteFile(
  1164. IN HANDLE FileHandle,
  1165. IN HANDLE Event OPTIONAL,
  1166. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1167. IN PVOID ApcContext OPTIONAL,
  1168. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1169. IN PVOID Buffer,
  1170. IN ULONG Length,
  1171. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  1172. IN PULONG Key OPTIONAL
  1173. );
  1174. NTSYSCALLAPI
  1175. NTSTATUS
  1176. NTAPI
  1177. NtUnlockFile(
  1178. IN HANDLE FileHandle,
  1179. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1180. IN PLARGE_INTEGER ByteOffset,
  1181. IN PLARGE_INTEGER Length,
  1182. IN ULONG Key
  1183. );
  1184. // end_ntifs
  1185. NTSYSCALLAPI
  1186. NTSTATUS
  1187. NTAPI
  1188. NtReadFile64(
  1189. IN HANDLE FileHandle,
  1190. IN HANDLE Event OPTIONAL,
  1191. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1192. IN PVOID ApcContext OPTIONAL,
  1193. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1194. OUT PVOID64 *Buffer,
  1195. IN ULONG Length,
  1196. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  1197. IN PULONG Key OPTIONAL
  1198. );
  1199. NTSYSCALLAPI
  1200. NTSTATUS
  1201. NTAPI
  1202. NtReadFileScatter(
  1203. IN HANDLE FileHandle,
  1204. IN HANDLE Event OPTIONAL,
  1205. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1206. IN PVOID ApcContext OPTIONAL,
  1207. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1208. IN PFILE_SEGMENT_ELEMENT SegmentArray,
  1209. IN ULONG Length,
  1210. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  1211. IN PULONG Key OPTIONAL
  1212. );
  1213. NTSYSCALLAPI
  1214. NTSTATUS
  1215. NTAPI
  1216. NtSetEaFile(
  1217. IN HANDLE FileHandle,
  1218. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1219. IN PVOID Buffer,
  1220. IN ULONG Length
  1221. );
  1222. NTSYSCALLAPI
  1223. NTSTATUS
  1224. NTAPI
  1225. NtWriteFile64(
  1226. IN HANDLE FileHandle,
  1227. IN HANDLE Event OPTIONAL,
  1228. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1229. IN PVOID ApcContext OPTIONAL,
  1230. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1231. IN PVOID64 *Buffer,
  1232. IN ULONG Length,
  1233. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  1234. IN PULONG Key OPTIONAL
  1235. );
  1236. NTSYSCALLAPI
  1237. NTSTATUS
  1238. NTAPI
  1239. NtWriteFileGather(
  1240. IN HANDLE FileHandle,
  1241. IN HANDLE Event OPTIONAL,
  1242. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1243. IN PVOID ApcContext OPTIONAL,
  1244. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1245. IN PFILE_SEGMENT_ELEMENT SegmentArray,
  1246. IN ULONG Length,
  1247. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  1248. IN PULONG Key OPTIONAL
  1249. );
  1250. NTSYSCALLAPI
  1251. NTSTATUS
  1252. NTAPI
  1253. NtLoadDriver(
  1254. IN PUNICODE_STRING DriverServiceName
  1255. );
  1256. NTSYSCALLAPI
  1257. NTSTATUS
  1258. NTAPI
  1259. NtUnloadDriver(
  1260. IN PUNICODE_STRING DriverServiceName
  1261. );
  1262. // begin_ntifs
  1263. //
  1264. // Macro definition for defining IOCTL and FSCTL function control codes. Note
  1265. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  1266. // 2048-4095 are reserved for customers.
  1267. //
  1268. // These macros are defined in devioctl.h which contains the portable IO
  1269. // definitions (for use by both DOS and NT)
  1270. //
  1271. //
  1272. // The IoGetFunctionCodeFromCtlCode( ControlCode ) Macro is defined in io.h
  1273. // This macro is used to extract the function code from an IOCTL (or FSCTL).
  1274. // The macro can only be used in kernel mode code.
  1275. //
  1276. //
  1277. // General File System control codes - Note that these values are valid
  1278. // regardless of the actual file system type
  1279. //
  1280. //
  1281. // IMPORTANT: These values have been arranged in order of increasing
  1282. // control codes. Do NOT breaks this!! Add all new codes
  1283. // at end of list regardless of functionality type.
  1284. //
  1285. // Note: FSCTL_QUERY_RETRIEVAL_POINTER and FSCTL_MARK_AS_SYSTEM_HIVE only
  1286. // work from Kernel mode on local paging files or the system hives.
  1287. //
  1288. // begin_winioctl
  1289. #ifndef _FILESYSTEMFSCTL_
  1290. #define _FILESYSTEMFSCTL_
  1291. //
  1292. // The following is a list of the native file system fsctls followed by
  1293. // additional network file system fsctls. Some values have been
  1294. // decommissioned.
  1295. //
  1296. #define FSCTL_REQUEST_OPLOCK_LEVEL_1 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1297. #define FSCTL_REQUEST_OPLOCK_LEVEL_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1298. #define FSCTL_REQUEST_BATCH_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1299. #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1300. #define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1301. #define FSCTL_OPLOCK_BREAK_NOTIFY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1302. #define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1303. #define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1304. #define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1305. // decommissioned fsctl value 9
  1306. #define FSCTL_IS_VOLUME_MOUNTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1307. #define FSCTL_IS_PATHNAME_VALID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) // PATHNAME_BUFFER,
  1308. #define FSCTL_MARK_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1309. // decommissioned fsctl value 13
  1310. #define FSCTL_QUERY_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS)
  1311. #define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1312. #define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  1313. // decommissioned fsctl value 17
  1314. // decommissioned fsctl value 18
  1315. #define FSCTL_MARK_AS_SYSTEM_HIVE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS)
  1316. #define FSCTL_OPLOCK_BREAK_ACK_NO_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1317. #define FSCTL_INVALIDATE_VOLUMES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1318. #define FSCTL_QUERY_FAT_BPB CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) // FSCTL_QUERY_FAT_BPB_BUFFER
  1319. #define FSCTL_REQUEST_FILTER_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1320. #define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILESYSTEM_STATISTICS
  1321. #if(_WIN32_WINNT >= 0x0400)
  1322. #define FSCTL_GET_NTFS_VOLUME_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS) // NTFS_VOLUME_DATA_BUFFER
  1323. #define FSCTL_GET_NTFS_FILE_RECORD CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS) // NTFS_FILE_RECORD_INPUT_BUFFER, NTFS_FILE_RECORD_OUTPUT_BUFFER
  1324. #define FSCTL_GET_VOLUME_BITMAP CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_LCN_INPUT_BUFFER, VOLUME_BITMAP_BUFFER
  1325. #define FSCTL_GET_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER
  1326. #define FSCTL_MOVE_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // MOVE_FILE_DATA,
  1327. #define FSCTL_IS_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1328. // decomissioned fsctl value 31
  1329. #define FSCTL_ALLOW_EXTENDED_DASD_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS)
  1330. #endif /* _WIN32_WINNT >= 0x0400 */
  1331. #if(_WIN32_WINNT >= 0x0500)
  1332. // decommissioned fsctl value 33
  1333. // decommissioned fsctl value 34
  1334. #define FSCTL_FIND_FILES_BY_SID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS) // FIND_BY_SID_DATA, FIND_BY_SID_OUTPUT
  1335. // decommissioned fsctl value 36
  1336. // decommissioned fsctl value 37
  1337. #define FSCTL_SET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // FILE_OBJECTID_BUFFER
  1338. #define FSCTL_GET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER
  1339. #define FSCTL_DELETE_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1340. #define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER,
  1341. #define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) // REPARSE_DATA_BUFFER
  1342. #define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER,
  1343. #define FSCTL_ENUM_USN_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS) // MFT_ENUM_DATA,
  1344. #define FSCTL_SECURITY_ID_CHECK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, FILE_READ_DATA) // BULK_SECURITY_TEST_DATA,
  1345. #define FSCTL_READ_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS) // READ_USN_JOURNAL_DATA, USN
  1346. #define FSCTL_SET_OBJECT_ID_EXTENDED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1347. #define FSCTL_CREATE_OR_GET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER
  1348. #define FSCTL_SET_SPARSE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1349. #define FSCTL_SET_ZERO_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) // FILE_ZERO_DATA_INFORMATION,
  1350. #define FSCTL_QUERY_ALLOCATED_RANGES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, FILE_READ_DATA) // FILE_ALLOCATED_RANGE_BUFFER, FILE_ALLOCATED_RANGE_BUFFER
  1351. // decommissioned fsctl value 52
  1352. #define FSCTL_SET_ENCRYPTION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS) // ENCRYPTION_BUFFER, DECRYPTION_STATUS_BUFFER
  1353. #define FSCTL_ENCRYPTION_FSCTL_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS)
  1354. #define FSCTL_WRITE_RAW_ENCRYPTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS) // ENCRYPTED_DATA_INFO,
  1355. #define FSCTL_READ_RAW_ENCRYPTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS) // REQUEST_RAW_ENCRYPTED_DATA, ENCRYPTED_DATA_INFO
  1356. #define FSCTL_CREATE_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS) // CREATE_USN_JOURNAL_DATA,
  1357. #define FSCTL_READ_FILE_USN_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, FILE_ANY_ACCESS) // Read the Usn Record for a file
  1358. #define FSCTL_WRITE_USN_CLOSE_RECORD CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS) // Generate Close Usn Record
  1359. #define FSCTL_EXTEND_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1360. #define FSCTL_QUERY_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1361. #define FSCTL_DELETE_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1362. #define FSCTL_MARK_HANDLE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1363. #define FSCTL_SIS_COPYFILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1364. #define FSCTL_SIS_LINK_FILES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  1365. #define FSCTL_HSM_MSG CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 66, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  1366. // decommissioned fsctl value 67
  1367. #define FSCTL_HSM_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 68, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
  1368. #define FSCTL_RECALL_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
  1369. // decommissioned fsctl value 70
  1370. #define FSCTL_READ_FROM_PLEX CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA)
  1371. #define FSCTL_FILE_PREFETCH CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // FILE_PREFETCH
  1372. #endif /* _WIN32_WINNT >= 0x0500 */
  1373. //
  1374. // The following long list of structs are associated with the preceeding
  1375. // file system fsctls.
  1376. //
  1377. //
  1378. // Structure for FSCTL_IS_PATHNAME_VALID
  1379. //
  1380. typedef struct _PATHNAME_BUFFER {
  1381. ULONG PathNameLength;
  1382. WCHAR Name[1];
  1383. } PATHNAME_BUFFER, *PPATHNAME_BUFFER;
  1384. //
  1385. // Structure for FSCTL_QUERY_BPB_INFO
  1386. //
  1387. typedef struct _FSCTL_QUERY_FAT_BPB_BUFFER {
  1388. UCHAR First0x24BytesOfBootSector[0x24];
  1389. } FSCTL_QUERY_FAT_BPB_BUFFER, *PFSCTL_QUERY_FAT_BPB_BUFFER;
  1390. #if(_WIN32_WINNT >= 0x0400)
  1391. //
  1392. // Structures for FSCTL_GET_NTFS_VOLUME_DATA.
  1393. // The user must pass the basic buffer below. Ntfs
  1394. // will return as many fields as available in the extended
  1395. // buffer which follows immediately after the VOLUME_DATA_BUFFER.
  1396. //
  1397. typedef struct {
  1398. LARGE_INTEGER VolumeSerialNumber;
  1399. LARGE_INTEGER NumberSectors;
  1400. LARGE_INTEGER TotalClusters;
  1401. LARGE_INTEGER FreeClusters;
  1402. LARGE_INTEGER TotalReserved;
  1403. ULONG BytesPerSector;
  1404. ULONG BytesPerCluster;
  1405. ULONG BytesPerFileRecordSegment;
  1406. ULONG ClustersPerFileRecordSegment;
  1407. LARGE_INTEGER MftValidDataLength;
  1408. LARGE_INTEGER MftStartLcn;
  1409. LARGE_INTEGER Mft2StartLcn;
  1410. LARGE_INTEGER MftZoneStart;
  1411. LARGE_INTEGER MftZoneEnd;
  1412. } NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;
  1413. typedef struct {
  1414. ULONG ByteCount;
  1415. USHORT MajorVersion;
  1416. USHORT MinorVersion;
  1417. } NTFS_EXTENDED_VOLUME_DATA, *PNTFS_EXTENDED_VOLUME_DATA;
  1418. #endif /* _WIN32_WINNT >= 0x0400 */
  1419. #if(_WIN32_WINNT >= 0x0400)
  1420. //
  1421. // Structure for FSCTL_GET_VOLUME_BITMAP
  1422. //
  1423. typedef struct {
  1424. LARGE_INTEGER StartingLcn;
  1425. } STARTING_LCN_INPUT_BUFFER, *PSTARTING_LCN_INPUT_BUFFER;
  1426. typedef struct {
  1427. LARGE_INTEGER StartingLcn;
  1428. LARGE_INTEGER BitmapSize;
  1429. UCHAR Buffer[1];
  1430. } VOLUME_BITMAP_BUFFER, *PVOLUME_BITMAP_BUFFER;
  1431. #endif /* _WIN32_WINNT >= 0x0400 */
  1432. #if(_WIN32_WINNT >= 0x0400)
  1433. //
  1434. // Structure for FSCTL_GET_RETRIEVAL_POINTERS
  1435. //
  1436. typedef struct {
  1437. LARGE_INTEGER StartingVcn;
  1438. } STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER;
  1439. typedef struct RETRIEVAL_POINTERS_BUFFER {
  1440. ULONG ExtentCount;
  1441. LARGE_INTEGER StartingVcn;
  1442. struct {
  1443. LARGE_INTEGER NextVcn;
  1444. LARGE_INTEGER Lcn;
  1445. } Extents[1];
  1446. } RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER;
  1447. #endif /* _WIN32_WINNT >= 0x0400 */
  1448. #if(_WIN32_WINNT >= 0x0400)
  1449. //
  1450. // Structures for FSCTL_GET_NTFS_FILE_RECORD
  1451. //
  1452. typedef struct {
  1453. LARGE_INTEGER FileReferenceNumber;
  1454. } NTFS_FILE_RECORD_INPUT_BUFFER, *PNTFS_FILE_RECORD_INPUT_BUFFER;
  1455. typedef struct {
  1456. LARGE_INTEGER FileReferenceNumber;
  1457. ULONG FileRecordLength;
  1458. UCHAR FileRecordBuffer[1];
  1459. } NTFS_FILE_RECORD_OUTPUT_BUFFER, *PNTFS_FILE_RECORD_OUTPUT_BUFFER;
  1460. #endif /* _WIN32_WINNT >= 0x0400 */
  1461. #if(_WIN32_WINNT >= 0x0400)
  1462. //
  1463. // Structure for FSCTL_MOVE_FILE
  1464. //
  1465. typedef struct {
  1466. HANDLE FileHandle;
  1467. LARGE_INTEGER StartingVcn;
  1468. LARGE_INTEGER StartingLcn;
  1469. ULONG ClusterCount;
  1470. } MOVE_FILE_DATA, *PMOVE_FILE_DATA;
  1471. #if defined(_WIN64)
  1472. //
  1473. // 32/64 Bit thunking support structure
  1474. //
  1475. typedef struct _MOVE_FILE_DATA32 {
  1476. UINT32 FileHandle;
  1477. LARGE_INTEGER StartingVcn;
  1478. LARGE_INTEGER StartingLcn;
  1479. ULONG ClusterCount;
  1480. } MOVE_FILE_DATA32, *PMOVE_FILE_DATA32;
  1481. #endif
  1482. #endif /* _WIN32_WINNT >= 0x0400 */
  1483. #if(_WIN32_WINNT >= 0x0500)
  1484. //
  1485. // Structures for FSCTL_FIND_FILES_BY_SID
  1486. //
  1487. typedef struct {
  1488. ULONG Restart;
  1489. SID Sid;
  1490. } FIND_BY_SID_DATA, *PFIND_BY_SID_DATA;
  1491. typedef struct {
  1492. ULONG NextEntryOffset;
  1493. ULONG FileIndex;
  1494. ULONG FileNameLength;
  1495. WCHAR FileName[1];
  1496. } FIND_BY_SID_OUTPUT, *PFIND_BY_SID_OUTPUT;
  1497. #endif /* _WIN32_WINNT >= 0x0500 */
  1498. #if(_WIN32_WINNT >= 0x0500)
  1499. //
  1500. // The following structures apply to Usn operations.
  1501. //
  1502. //
  1503. // Structure for FSCTL_ENUM_USN_DATA
  1504. //
  1505. typedef struct {
  1506. ULONGLONG StartFileReferenceNumber;
  1507. USN LowUsn;
  1508. USN HighUsn;
  1509. } MFT_ENUM_DATA, *PMFT_ENUM_DATA;
  1510. //
  1511. // Structure for FSCTL_CREATE_USN_JOURNAL
  1512. //
  1513. typedef struct {
  1514. ULONGLONG MaximumSize;
  1515. ULONGLONG AllocationDelta;
  1516. } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA;
  1517. //
  1518. // Structure for FSCTL_READ_USN_JOURNAL
  1519. //
  1520. typedef struct {
  1521. USN StartUsn;
  1522. ULONG ReasonMask;
  1523. ULONG ReturnOnlyOnClose;
  1524. ULONGLONG Timeout;
  1525. ULONGLONG BytesToWaitFor;
  1526. ULONGLONG UsnJournalID;
  1527. } READ_USN_JOURNAL_DATA, *PREAD_USN_JOURNAL_DATA;
  1528. //
  1529. // The initial Major.Minor version of the Usn record will be 2.0.
  1530. // In general, the MinorVersion may be changed if fields are added
  1531. // to this structure in such a way that the previous version of the
  1532. // software can still correctly the fields it knows about. The
  1533. // MajorVersion should only be changed if the previous version of
  1534. // any software using this structure would incorrectly handle new
  1535. // records due to structure changes.
  1536. //
  1537. // The first update to this will force the structure to version 2.0.
  1538. // This will add the extended information about the source as
  1539. // well as indicate the file name offset within the structure.
  1540. //
  1541. // The following structure is returned with these fsctls.
  1542. //
  1543. // FSCTL_READ_USN_JOURNAL
  1544. // FSCTL_READ_FILE_USN_DATA
  1545. // FSCTL_ENUM_USN_DATA
  1546. //
  1547. typedef struct {
  1548. ULONG RecordLength;
  1549. USHORT MajorVersion;
  1550. USHORT MinorVersion;
  1551. ULONGLONG FileReferenceNumber;
  1552. ULONGLONG ParentFileReferenceNumber;
  1553. USN Usn;
  1554. LARGE_INTEGER TimeStamp;
  1555. ULONG Reason;
  1556. ULONG SourceInfo;
  1557. ULONG SecurityId;
  1558. ULONG FileAttributes;
  1559. USHORT FileNameLength;
  1560. USHORT FileNameOffset;
  1561. WCHAR FileName[1];
  1562. } USN_RECORD, *PUSN_RECORD;
  1563. #define USN_PAGE_SIZE (0x1000)
  1564. #define USN_REASON_DATA_OVERWRITE (0x00000001)
  1565. #define USN_REASON_DATA_EXTEND (0x00000002)
  1566. #define USN_REASON_DATA_TRUNCATION (0x00000004)
  1567. #define USN_REASON_NAMED_DATA_OVERWRITE (0x00000010)
  1568. #define USN_REASON_NAMED_DATA_EXTEND (0x00000020)
  1569. #define USN_REASON_NAMED_DATA_TRUNCATION (0x00000040)
  1570. #define USN_REASON_FILE_CREATE (0x00000100)
  1571. #define USN_REASON_FILE_DELETE (0x00000200)
  1572. #define USN_REASON_EA_CHANGE (0x00000400)
  1573. #define USN_REASON_SECURITY_CHANGE (0x00000800)
  1574. #define USN_REASON_RENAME_OLD_NAME (0x00001000)
  1575. #define USN_REASON_RENAME_NEW_NAME (0x00002000)
  1576. #define USN_REASON_INDEXABLE_CHANGE (0x00004000)
  1577. #define USN_REASON_BASIC_INFO_CHANGE (0x00008000)
  1578. #define USN_REASON_HARD_LINK_CHANGE (0x00010000)
  1579. #define USN_REASON_COMPRESSION_CHANGE (0x00020000)
  1580. #define USN_REASON_ENCRYPTION_CHANGE (0x00040000)
  1581. #define USN_REASON_OBJECT_ID_CHANGE (0x00080000)
  1582. #define USN_REASON_REPARSE_POINT_CHANGE (0x00100000)
  1583. #define USN_REASON_STREAM_CHANGE (0x00200000)
  1584. #define USN_REASON_CLOSE (0x80000000)
  1585. //
  1586. // Structure for FSCTL_QUERY_USN_JOUNAL
  1587. //
  1588. typedef struct {
  1589. ULONGLONG UsnJournalID;
  1590. USN FirstUsn;
  1591. USN NextUsn;
  1592. USN LowestValidUsn;
  1593. USN MaxUsn;
  1594. ULONGLONG MaximumSize;
  1595. ULONGLONG AllocationDelta;
  1596. } USN_JOURNAL_DATA, *PUSN_JOURNAL_DATA;
  1597. //
  1598. // Structure for FSCTL_DELETE_USN_JOURNAL
  1599. //
  1600. typedef struct {
  1601. ULONGLONG UsnJournalID;
  1602. ULONG DeleteFlags;
  1603. } DELETE_USN_JOURNAL_DATA, *PDELETE_USN_JOURNAL_DATA;
  1604. #define USN_DELETE_FLAG_DELETE (0x00000001)
  1605. #define USN_DELETE_FLAG_NOTIFY (0x00000002)
  1606. #define USN_DELETE_VALID_FLAGS (0x00000003)
  1607. //
  1608. // Structure for FSCTL_MARK_HANDLE
  1609. //
  1610. typedef struct {
  1611. ULONG UsnSourceInfo;
  1612. HANDLE VolumeHandle;
  1613. ULONG HandleInfo;
  1614. } MARK_HANDLE_INFO, *PMARK_HANDLE_INFO;
  1615. #if defined(_WIN64)
  1616. //
  1617. // 32/64 Bit thunking support structure
  1618. //
  1619. typedef struct {
  1620. ULONG UsnSourceInfo;
  1621. UINT32 VolumeHandle;
  1622. ULONG HandleInfo;
  1623. } MARK_HANDLE_INFO32, *PMARK_HANDLE_INFO32;
  1624. #endif
  1625. //
  1626. // Flags for the additional source information above.
  1627. //
  1628. // USN_SOURCE_DATA_MANAGEMENT - Service is not modifying the external view
  1629. // of any part of the file. Typical case is HSM moving data to
  1630. // and from external storage.
  1631. //
  1632. // USN_SOURCE_AUXILIARY_DATA - Service is not modifying the external view
  1633. // of the file with regard to the application that created this file.
  1634. // Can be used to add private data streams to a file.
  1635. //
  1636. // USN_SOURCE_REPLICATION_MANAGEMENT - Service is modifying a file to match
  1637. // the contents of the same file which exists in another member of the
  1638. // replica set.
  1639. //
  1640. #define USN_SOURCE_DATA_MANAGEMENT (0x00000001)
  1641. #define USN_SOURCE_AUXILIARY_DATA (0x00000002)
  1642. #define USN_SOURCE_REPLICATION_MANAGEMENT (0x00000004)
  1643. //
  1644. // Flags for the HandleInfo field above
  1645. //
  1646. // MARK_HANDLE_PROTECT_CLUSTERS - disallow any defragmenting (FSCTL_MOVE_FILE) until the
  1647. // the handle is closed
  1648. //
  1649. #define MARK_HANDLE_PROTECT_CLUSTERS (0x00000001)
  1650. #endif /* _WIN32_WINNT >= 0x0500 */
  1651. #if(_WIN32_WINNT >= 0x0500)
  1652. //
  1653. // Structure for FSCTL_SECURITY_ID_CHECK
  1654. //
  1655. typedef struct {
  1656. ACCESS_MASK DesiredAccess;
  1657. ULONG SecurityIds[1];
  1658. } BULK_SECURITY_TEST_DATA, *PBULK_SECURITY_TEST_DATA;
  1659. #endif /* _WIN32_WINNT >= 0x0500 */
  1660. #if(_WIN32_WINNT >= 0x0500)
  1661. //
  1662. // Output flags for the FSCTL_IS_VOLUME_DIRTY
  1663. //
  1664. #define VOLUME_IS_DIRTY (0x00000001)
  1665. #define VOLUME_UPGRADE_SCHEDULED (0x00000002)
  1666. #endif /* _WIN32_WINNT >= 0x0500 */
  1667. //
  1668. // Structures for FSCTL_FILE_PREFETCH
  1669. //
  1670. typedef struct _FILE_PREFETCH {
  1671. ULONG Type;
  1672. ULONG Count;
  1673. ULONGLONG Prefetch[1];
  1674. } FILE_PREFETCH, *PFILE_PREFETCH;
  1675. #define FILE_PREFETCH_TYPE_FOR_CREATE 0x1
  1676. // Structures for FSCTL_FILESYSTEM_GET_STATISTICS
  1677. //
  1678. // Filesystem performance counters
  1679. //
  1680. typedef struct _FILESYSTEM_STATISTICS {
  1681. USHORT FileSystemType;
  1682. USHORT Version; // currently version 1
  1683. ULONG SizeOfCompleteStructure; // must by a mutiple of 64 bytes
  1684. ULONG UserFileReads;
  1685. ULONG UserFileReadBytes;
  1686. ULONG UserDiskReads;
  1687. ULONG UserFileWrites;
  1688. ULONG UserFileWriteBytes;
  1689. ULONG UserDiskWrites;
  1690. ULONG MetaDataReads;
  1691. ULONG MetaDataReadBytes;
  1692. ULONG MetaDataDiskReads;
  1693. ULONG MetaDataWrites;
  1694. ULONG MetaDataWriteBytes;
  1695. ULONG MetaDataDiskWrites;
  1696. //
  1697. // The file system's private structure is appended here.
  1698. //
  1699. } FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS;
  1700. // values for FS_STATISTICS.FileSystemType
  1701. #define FILESYSTEM_STATISTICS_TYPE_NTFS 1
  1702. #define FILESYSTEM_STATISTICS_TYPE_FAT 2
  1703. //
  1704. // File System Specific Statistics Data
  1705. //
  1706. typedef struct _FAT_STATISTICS {
  1707. ULONG CreateHits;
  1708. ULONG SuccessfulCreates;
  1709. ULONG FailedCreates;
  1710. ULONG NonCachedReads;
  1711. ULONG NonCachedReadBytes;
  1712. ULONG NonCachedWrites;
  1713. ULONG NonCachedWriteBytes;
  1714. ULONG NonCachedDiskReads;
  1715. ULONG NonCachedDiskWrites;
  1716. } FAT_STATISTICS, *PFAT_STATISTICS;
  1717. typedef struct _NTFS_STATISTICS {
  1718. ULONG LogFileFullExceptions;
  1719. ULONG OtherExceptions;
  1720. //
  1721. // Other meta data io's
  1722. //
  1723. ULONG MftReads;
  1724. ULONG MftReadBytes;
  1725. ULONG MftWrites;
  1726. ULONG MftWriteBytes;
  1727. struct {
  1728. USHORT Write;
  1729. USHORT Create;
  1730. USHORT SetInfo;
  1731. USHORT Flush;
  1732. } MftWritesUserLevel;
  1733. USHORT MftWritesFlushForLogFileFull;
  1734. USHORT MftWritesLazyWriter;
  1735. USHORT MftWritesUserRequest;
  1736. ULONG Mft2Writes;
  1737. ULONG Mft2WriteBytes;
  1738. struct {
  1739. USHORT Write;
  1740. USHORT Create;
  1741. USHORT SetInfo;
  1742. USHORT Flush;
  1743. } Mft2WritesUserLevel;
  1744. USHORT Mft2WritesFlushForLogFileFull;
  1745. USHORT Mft2WritesLazyWriter;
  1746. USHORT Mft2WritesUserRequest;
  1747. ULONG RootIndexReads;
  1748. ULONG RootIndexReadBytes;
  1749. ULONG RootIndexWrites;
  1750. ULONG RootIndexWriteBytes;
  1751. ULONG BitmapReads;
  1752. ULONG BitmapReadBytes;
  1753. ULONG BitmapWrites;
  1754. ULONG BitmapWriteBytes;
  1755. USHORT BitmapWritesFlushForLogFileFull;
  1756. USHORT BitmapWritesLazyWriter;
  1757. USHORT BitmapWritesUserRequest;
  1758. struct {
  1759. USHORT Write;
  1760. USHORT Create;
  1761. USHORT SetInfo;
  1762. } BitmapWritesUserLevel;
  1763. ULONG MftBitmapReads;
  1764. ULONG MftBitmapReadBytes;
  1765. ULONG MftBitmapWrites;
  1766. ULONG MftBitmapWriteBytes;
  1767. USHORT MftBitmapWritesFlushForLogFileFull;
  1768. USHORT MftBitmapWritesLazyWriter;
  1769. USHORT MftBitmapWritesUserRequest;
  1770. struct {
  1771. USHORT Write;
  1772. USHORT Create;
  1773. USHORT SetInfo;
  1774. USHORT Flush;
  1775. } MftBitmapWritesUserLevel;
  1776. ULONG UserIndexReads;
  1777. ULONG UserIndexReadBytes;
  1778. ULONG UserIndexWrites;
  1779. ULONG UserIndexWriteBytes;
  1780. //
  1781. // Additions for NT 5.0
  1782. //
  1783. ULONG LogFileReads;
  1784. ULONG LogFileReadBytes;
  1785. ULONG LogFileWrites;
  1786. ULONG LogFileWriteBytes;
  1787. struct {
  1788. ULONG Calls; // number of individual calls to allocate clusters
  1789. ULONG Clusters; // number of clusters allocated
  1790. ULONG Hints; // number of times a hint was specified
  1791. ULONG RunsReturned; // number of runs used to satisify all the requests
  1792. ULONG HintsHonored; // number of times the hint was useful
  1793. ULONG HintsClusters; // number of clusters allocated via the hint
  1794. ULONG Cache; // number of times the cache was useful other than the hint
  1795. ULONG CacheClusters; // number of clusters allocated via the cache other than the hint
  1796. ULONG CacheMiss; // number of times the cache wasn't useful
  1797. ULONG CacheMissClusters; // number of clusters allocated without the cache
  1798. } Allocate;
  1799. } NTFS_STATISTICS, *PNTFS_STATISTICS;
  1800. #if(_WIN32_WINNT >= 0x0500)
  1801. //
  1802. // Structure for FSCTL_SET_OBJECT_ID, FSCTL_GET_OBJECT_ID, and FSCTL_CREATE_OR_GET_OBJECT_ID
  1803. //
  1804. #if _MSC_VER >= 1200
  1805. #pragma warning(push)
  1806. #endif
  1807. #pragma warning(disable:4201) // unnamed struct
  1808. typedef struct _FILE_OBJECTID_BUFFER {
  1809. //
  1810. // This is the portion of the object id that is indexed.
  1811. //
  1812. UCHAR ObjectId[16];
  1813. //
  1814. // This portion of the object id is not indexed, it's just
  1815. // some metadata for the user's benefit.
  1816. //
  1817. union {
  1818. struct {
  1819. UCHAR BirthVolumeId[16];
  1820. UCHAR BirthObjectId[16];
  1821. UCHAR DomainId[16];
  1822. } ;
  1823. UCHAR ExtendedInfo[48];
  1824. };
  1825. } FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER;
  1826. #if _MSC_VER >= 1200
  1827. #pragma warning(pop)
  1828. #else
  1829. #pragma warning( default : 4201 )
  1830. #endif
  1831. #endif /* _WIN32_WINNT >= 0x0500 */
  1832. #if(_WIN32_WINNT >= 0x0500)
  1833. //
  1834. // Structure for FSCTL_SET_SPARSE
  1835. //
  1836. typedef struct _FILE_SET_SPARSE_BUFFER {
  1837. BOOLEAN SetSparse;
  1838. } FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER;
  1839. #endif /* _WIN32_WINNT >= 0x0500 */
  1840. #if(_WIN32_WINNT >= 0x0500)
  1841. //
  1842. // Structure for FSCTL_SET_ZERO_DATA
  1843. //
  1844. typedef struct _FILE_ZERO_DATA_INFORMATION {
  1845. LARGE_INTEGER FileOffset;
  1846. LARGE_INTEGER BeyondFinalZero;
  1847. } FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION;
  1848. #endif /* _WIN32_WINNT >= 0x0500 */
  1849. #if(_WIN32_WINNT >= 0x0500)
  1850. //
  1851. // Structure for FSCTL_QUERY_ALLOCATED_RANGES
  1852. //
  1853. //
  1854. // Querying the allocated ranges requires an output buffer to store the
  1855. // allocated ranges and an input buffer to specify the range to query.
  1856. // The input buffer contains a single entry, the output buffer is an
  1857. // array of the following structure.
  1858. //
  1859. typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
  1860. LARGE_INTEGER FileOffset;
  1861. LARGE_INTEGER Length;
  1862. } FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
  1863. #endif /* _WIN32_WINNT >= 0x0500 */
  1864. #if(_WIN32_WINNT >= 0x0500)
  1865. //
  1866. // Structures for FSCTL_SET_ENCRYPTION, FSCTL_WRITE_RAW_ENCRYPTED, and FSCTL_READ_RAW_ENCRYPTED
  1867. //
  1868. //
  1869. // The input buffer to set encryption indicates whether we are to encrypt/decrypt a file
  1870. // or an individual stream.
  1871. //
  1872. typedef struct _ENCRYPTION_BUFFER {
  1873. ULONG EncryptionOperation;
  1874. UCHAR Private[1];
  1875. } ENCRYPTION_BUFFER, *PENCRYPTION_BUFFER;
  1876. #define FILE_SET_ENCRYPTION 0x00000001
  1877. #define FILE_CLEAR_ENCRYPTION 0x00000002
  1878. #define STREAM_SET_ENCRYPTION 0x00000003
  1879. #define STREAM_CLEAR_ENCRYPTION 0x00000004
  1880. #define MAXIMUM_ENCRYPTION_VALUE 0x00000004
  1881. //
  1882. // The optional output buffer to set encryption indicates that the last encrypted
  1883. // stream in a file has been marked as decrypted.
  1884. //
  1885. typedef struct _DECRYPTION_STATUS_BUFFER {
  1886. BOOLEAN NoEncryptedStreams;
  1887. } DECRYPTION_STATUS_BUFFER, *PDECRYPTION_STATUS_BUFFER;
  1888. #define ENCRYPTION_FORMAT_DEFAULT (0x01)
  1889. #define COMPRESSION_FORMAT_SPARSE (0x4000)
  1890. //
  1891. // Request Encrypted Data structure. This is used to indicate
  1892. // the range of the file to read. It also describes the
  1893. // output buffer used to return the data.
  1894. //
  1895. typedef struct _REQUEST_RAW_ENCRYPTED_DATA {
  1896. //
  1897. // Requested file offset and requested length to read.
  1898. // The fsctl will round the starting offset down
  1899. // to a file system boundary. It will also
  1900. // round the length up to a file system boundary.
  1901. //
  1902. LONGLONG FileOffset;
  1903. ULONG Length;
  1904. } REQUEST_RAW_ENCRYPTED_DATA, *PREQUEST_RAW_ENCRYPTED_DATA;
  1905. //
  1906. // Encrypted Data Information structure. This structure
  1907. // is used to return raw encrypted data from a file in
  1908. // order to perform off-line recovery. The data will be
  1909. // encrypted or encrypted and compressed. The off-line
  1910. // service will need to use the encryption and compression
  1911. // format information to recover the file data. In the
  1912. // event that the data is both encrypted and compressed then
  1913. // the decryption must occur before decompression. All
  1914. // the data units below must be encrypted and compressed
  1915. // with the same format.
  1916. //
  1917. // The data will be returned in units. The data unit size
  1918. // will be fixed per request. If the data is compressed
  1919. // then the data unit size will be the compression unit size.
  1920. //
  1921. // This structure is at the beginning of the buffer used to
  1922. // return the encrypted data. The actual raw bytes from
  1923. // the file will follow this buffer. The offset of the
  1924. // raw bytes from the beginning of this structure is
  1925. // specified in the REQUEST_RAW_ENCRYPTED_DATA structure
  1926. // described above.
  1927. //
  1928. typedef struct _ENCRYPTED_DATA_INFO {
  1929. //
  1930. // This is the file offset for the first entry in the
  1931. // data block array. The file system will round
  1932. // the requested start offset down to a boundary
  1933. // that is consistent with the format of the file.
  1934. //
  1935. ULONGLONG StartingFileOffset;
  1936. //
  1937. // Data offset in output buffer. The output buffer
  1938. // begins with an ENCRYPTED_DATA_INFO structure.
  1939. // The file system will then store the raw bytes from
  1940. // disk beginning at the following offset within the
  1941. // output buffer.
  1942. //
  1943. ULONG OutputBufferOffset;
  1944. //
  1945. // The number of bytes being returned that are within
  1946. // the size of the file. If this value is less than
  1947. // (NumberOfDataBlocks << DataUnitShift), it means the
  1948. // end of the file occurs within this transfer. Any
  1949. // data beyond file size is invalid and was never
  1950. // passed to the encryption driver.
  1951. //
  1952. ULONG BytesWithinFileSize;
  1953. //
  1954. // The number of bytes being returned that are below
  1955. // valid data length. If this value is less than
  1956. // (NumberOfDataBlocks << DataUnitShift), it means the
  1957. // end of the valid data occurs within this transfer.
  1958. // After decrypting the data from this transfer, any
  1959. // byte(s) beyond valid data length must be zeroed.
  1960. //
  1961. ULONG BytesWithinValidDataLength;
  1962. //
  1963. // Code for the compression format as defined in
  1964. // ntrtl.h. Note that COMPRESSION_FORMAT_NONE
  1965. // and COMPRESSION_FORMAT_DEFAULT are invalid if
  1966. // any of the described chunks are compressed.
  1967. //
  1968. USHORT CompressionFormat;
  1969. //
  1970. // The DataUnit is the granularity used to access the
  1971. // disk. It will be the same as the compression unit
  1972. // size for a compressed file. For an uncompressed
  1973. // file, it will be some cluster-aligned power of 2 that
  1974. // the file system deems convenient. A caller should
  1975. // not expect that successive calls will have the
  1976. // same data unit shift value as the previous call.
  1977. //
  1978. // Since chunks and compression units are expected to be
  1979. // powers of 2 in size, we express them log2. So, for
  1980. // example (1 << ChunkShift) == ChunkSizeInBytes. The
  1981. // ClusterShift indicates how much space must be saved
  1982. // to successfully compress a compression unit - each
  1983. // successfully compressed data unit must occupy
  1984. // at least one cluster less in bytes than an uncompressed
  1985. // data block unit.
  1986. //
  1987. UCHAR DataUnitShift;
  1988. UCHAR ChunkShift;
  1989. UCHAR ClusterShift;
  1990. //
  1991. // The format for the encryption.
  1992. //
  1993. UCHAR EncryptionFormat;
  1994. //
  1995. // This is the number of entries in the data block size
  1996. // array.
  1997. //
  1998. USHORT NumberOfDataBlocks;
  1999. //
  2000. // This is an array of sizes in the data block array. There
  2001. // must be one entry in this array for each data block
  2002. // read from disk. The size has a different meaning
  2003. // depending on whether the file is compressed.
  2004. //
  2005. // A size of zero always indicates that the final data consists entirely
  2006. // of zeroes. There is no decryption or decompression to
  2007. // perform.
  2008. //
  2009. // If the file is compressed then the data block size indicates
  2010. // whether this block is compressed. A size equal to
  2011. // the block size indicates that the corresponding block did
  2012. // not compress. Any other non-zero size indicates the
  2013. // size of the compressed data which needs to be
  2014. // decrypted/decompressed.
  2015. //
  2016. // If the file is not compressed then the data block size
  2017. // indicates the amount of data within the block that
  2018. // needs to be decrypted. Any other non-zero size indicates
  2019. // that the remaining bytes in the data unit within the file
  2020. // consists of zeros. An example of this is when the
  2021. // the read spans the valid data length of the file. There
  2022. // is no data to decrypt past the valid data length.
  2023. //
  2024. ULONG DataBlockSize[ANYSIZE_ARRAY];
  2025. } ENCRYPTED_DATA_INFO;
  2026. typedef ENCRYPTED_DATA_INFO *PENCRYPTED_DATA_INFO;
  2027. #endif /* _WIN32_WINNT >= 0x0500 */
  2028. #if(_WIN32_WINNT >= 0x0500)
  2029. //
  2030. // FSCTL_READ_FROM_PLEX support
  2031. // Request Plex Read Data structure. This is used to indicate
  2032. // the range of the file to read. It also describes
  2033. // which plex to perform the read from.
  2034. //
  2035. typedef struct _PLEX_READ_DATA_REQUEST {
  2036. //
  2037. // Requested offset and length to read.
  2038. // The offset can be the virtual offset (vbo) in to a file,
  2039. // or a volume. In the case of a file offset,
  2040. // the fsd will round the starting offset down
  2041. // to a file system boundary. It will also
  2042. // round the length up to a file system boundary and
  2043. // enforce any other applicable limits.
  2044. //
  2045. LARGE_INTEGER ByteOffset;
  2046. ULONG ByteLength;
  2047. ULONG PlexNumber;
  2048. } PLEX_READ_DATA_REQUEST, *PPLEX_READ_DATA_REQUEST;
  2049. #endif /* _WIN32_WINNT >= 0x0500 */
  2050. #if(_WIN32_WINNT >= 0x0500)
  2051. //
  2052. // FSCTL_SIS_COPYFILE support
  2053. // Source and destination file names are passed in the FileNameBuffer.
  2054. // Both strings are null terminated, with the source name starting at
  2055. // the beginning of FileNameBuffer, and the destination name immediately
  2056. // following. Length fields include terminating nulls.
  2057. //
  2058. typedef struct _SI_COPYFILE {
  2059. ULONG SourceFileNameLength;
  2060. ULONG DestinationFileNameLength;
  2061. ULONG Flags;
  2062. WCHAR FileNameBuffer[1];
  2063. } SI_COPYFILE, *PSI_COPYFILE;
  2064. #define COPYFILE_SIS_LINK 0x0001 // Copy only if source is SIS
  2065. #define COPYFILE_SIS_REPLACE 0x0002 // Replace destination if it exists, otherwise don't.
  2066. #define COPYFILE_SIS_FLAGS 0x0003
  2067. #endif /* _WIN32_WINNT >= 0x0500 */
  2068. #endif // _FILESYSTEMFSCTL_
  2069. // end_winioctl
  2070. //
  2071. // Structures for FSCTL_SET_REPARSE_POINT, FSCTL_GET_REPARSE_POINT, and FSCTL_DELETE_REPARSE_POINT
  2072. //
  2073. //
  2074. // The reparse structure is used by layered drivers to store data in a
  2075. // reparse point. The constraints on reparse tags are defined below.
  2076. // This version of the reparse data buffer is only for Microsoft tags.
  2077. //
  2078. #if _MSC_VER >= 1200
  2079. #pragma warning(push)
  2080. #endif
  2081. #pragma warning(disable:4201) // unnamed struct
  2082. typedef struct _REPARSE_DATA_BUFFER {
  2083. ULONG ReparseTag;
  2084. USHORT ReparseDataLength;
  2085. USHORT Reserved;
  2086. union {
  2087. struct {
  2088. USHORT SubstituteNameOffset;
  2089. USHORT SubstituteNameLength;
  2090. USHORT PrintNameOffset;
  2091. USHORT PrintNameLength;
  2092. WCHAR PathBuffer[1];
  2093. } SymbolicLinkReparseBuffer;
  2094. struct {
  2095. USHORT SubstituteNameOffset;
  2096. USHORT SubstituteNameLength;
  2097. USHORT PrintNameOffset;
  2098. USHORT PrintNameLength;
  2099. WCHAR PathBuffer[1];
  2100. } MountPointReparseBuffer;
  2101. struct {
  2102. UCHAR DataBuffer[1];
  2103. } GenericReparseBuffer;
  2104. };
  2105. } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
  2106. #if _MSC_VER >= 1200
  2107. #pragma warning(pop)
  2108. #else
  2109. #pragma warning( default : 4201 )
  2110. #endif
  2111. #define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
  2112. // begin_winnt
  2113. //
  2114. // The reparse GUID structure is used by all 3rd party layered drivers to
  2115. // store data in a reparse point. For non-Microsoft tags, The GUID field
  2116. // cannot be GUID_NULL.
  2117. // The constraints on reparse tags are defined below.
  2118. // Microsoft tags can also be used with this format of the reparse point buffer.
  2119. //
  2120. typedef struct _REPARSE_GUID_DATA_BUFFER {
  2121. ULONG ReparseTag;
  2122. USHORT ReparseDataLength;
  2123. USHORT Reserved;
  2124. GUID ReparseGuid;
  2125. struct {
  2126. UCHAR DataBuffer[1];
  2127. } GenericReparseBuffer;
  2128. } REPARSE_GUID_DATA_BUFFER, *PREPARSE_GUID_DATA_BUFFER;
  2129. #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer)
  2130. // end_winnt end_ntifs
  2131. //
  2132. // The reparse information structure is used to return information about
  2133. // a reparse point to the caller.
  2134. //
  2135. typedef struct _REPARSE_POINT_INFORMATION {
  2136. USHORT ReparseDataLength;
  2137. USHORT UnparsedNameLength;
  2138. } REPARSE_POINT_INFORMATION, *PREPARSE_POINT_INFORMATION;
  2139. // begin_winnt begin_ntifs
  2140. //
  2141. // Maximum allowed size of the reparse data.
  2142. //
  2143. #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
  2144. //
  2145. // Predefined reparse tags.
  2146. // These tags need to avoid conflicting with IO_REMOUNT defined in ntos\inc\io.h
  2147. //
  2148. #define IO_REPARSE_TAG_RESERVED_ZERO (0)
  2149. #define IO_REPARSE_TAG_RESERVED_ONE (1)
  2150. //
  2151. // The value of the following constant needs to satisfy the following conditions:
  2152. // (1) Be at least as large as the largest of the reserved tags.
  2153. // (2) Be strictly smaller than all the tags in use.
  2154. //
  2155. #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_ONE
  2156. //
  2157. // The reparse tags are a ULONG. The 32 bits are laid out as follows:
  2158. //
  2159. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2160. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  2161. // +-+-+-+-+-----------------------+-------------------------------+
  2162. // |M|R|N|R| Reserved bits | Reparse Tag Value |
  2163. // +-+-+-+-+-----------------------+-------------------------------+
  2164. //
  2165. // M is the Microsoft bit. When set to 1, it denotes a tag owned by Microsoft.
  2166. // All ISVs must use a tag with a 0 in this position.
  2167. // Note: If a Microsoft tag is used by non-Microsoft software, the
  2168. // behavior is not defined.
  2169. //
  2170. // R is reserved. Must be zero for non-Microsoft tags.
  2171. //
  2172. // N is name surrogate. When set to 1, the file represents another named
  2173. // entity in the system.
  2174. //
  2175. // The M and N bits are OR-able.
  2176. // The following macros check for the M and N bit values:
  2177. //
  2178. //
  2179. // Macro to determine whether a reparse point tag corresponds to a tag
  2180. // owned by Microsoft.
  2181. //
  2182. #define IsReparseTagMicrosoft(_tag) ( \
  2183. ((_tag) & 0x80000000) \
  2184. )
  2185. //
  2186. // Macro to determine whether a reparse point tag is a name surrogate
  2187. //
  2188. #define IsReparseTagNameSurrogate(_tag) ( \
  2189. ((_tag) & 0x20000000) \
  2190. )
  2191. // end_winnt
  2192. //
  2193. // The following constant represents the bits that are valid to use in
  2194. // reparse tags.
  2195. //
  2196. #define IO_REPARSE_TAG_VALID_VALUES (0xF000FFFF)
  2197. //
  2198. // Macro to determine whether a reparse tag is a valid tag.
  2199. //
  2200. #define IsReparseTagValid(_tag) ( \
  2201. !((_tag) & ~IO_REPARSE_TAG_VALID_VALUES) && \
  2202. ((_tag) > IO_REPARSE_TAG_RESERVED_RANGE) \
  2203. )
  2204. //
  2205. // Microsoft tags for reparse points.
  2206. //
  2207. #define IO_REPARSE_TAG_SYMBOLIC_LINK IO_REPARSE_TAG_RESERVED_ZERO
  2208. #define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) // winnt ntifs
  2209. #define IO_REPARSE_TAG_HSM (0xC0000004L) // winnt ntifs
  2210. #define IO_REPARSE_TAG_SIS (0x80000007L) // winnt ntifs
  2211. //
  2212. // The reparse tag 0x80000008 is reserved for Microsoft internal use
  2213. // (may be published in the future)
  2214. //
  2215. //
  2216. // Microsoft reparse tag reserved for DFS
  2217. //
  2218. #define IO_REPARSE_TAG_DFS (0x8000000AL) // winnt ntifs
  2219. //
  2220. // Microsoft reparse tag reserved for the file system filter manager
  2221. //
  2222. #define IO_REPARSE_TAG_FILTER_MANAGER (0x8000000BL) // winnt ntifs
  2223. //
  2224. // Non-Microsoft tags for reparse points
  2225. //
  2226. //
  2227. // Tag allocated to CONGRUENT, May 2000. Used by IFSTEST
  2228. //
  2229. #define IO_REPARSE_TAG_IFSTEST_CONGRUENT (0x00000009L)
  2230. //
  2231. // Tag allocated to ARKIVIO
  2232. //
  2233. #define IO_REPARSE_TAG_ARKIVIO (0x0000000CL)
  2234. //
  2235. // Tag allocated to SOLUTIONSOFT
  2236. //
  2237. #define IO_REPARSE_TAG_SOLUTIONSOFT (0x2000000DL)
  2238. //
  2239. // Tag allocated to COMMVAULT
  2240. //
  2241. #define IO_REPARSE_TAG_COMMVAULT (0x0000000EL)
  2242. //
  2243. // The following three FSCTLs are placed in this file to facilitate sharing
  2244. // between the redirector and the IO subsystem
  2245. //
  2246. // This FSCTL is used to garner the link tracking information for a file.
  2247. // The data structures used for retreving the information are
  2248. // LINK_TRACKING_INFORMATION defined further down in this file.
  2249. //
  2250. #define FSCTL_LMR_GET_LINK_TRACKING_INFORMATION CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,58,METHOD_BUFFERED,FILE_ANY_ACCESS)
  2251. //
  2252. // This FSCTL is used to update the link tracking information on a server for
  2253. // an intra machine/ inter volume move on that server
  2254. //
  2255. #define FSCTL_LMR_SET_LINK_TRACKING_INFORMATION CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,59,METHOD_BUFFERED,FILE_ANY_ACCESS)
  2256. //
  2257. // The following IOCTL is used in link tracking implementation. It determines if the
  2258. // two file objects passed in are on the same server. This IOCTL is available in
  2259. // kernel mode only since it accepts FILE_OBJECT as parameters
  2260. //
  2261. #define IOCTL_LMR_ARE_FILE_OBJECTS_ON_SAME_SERVER CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM,60,METHOD_BUFFERED,FILE_ANY_ACCESS)
  2262. //
  2263. // Named Pipe file control code and structure declarations
  2264. //
  2265. //
  2266. // External named pipe file control operations
  2267. //
  2268. #define FSCTL_PIPE_ASSIGN_EVENT CTL_CODE(FILE_DEVICE_NAMED_PIPE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2269. #define FSCTL_PIPE_DISCONNECT CTL_CODE(FILE_DEVICE_NAMED_PIPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2270. #define FSCTL_PIPE_LISTEN CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2271. #define FSCTL_PIPE_PEEK CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_DATA)
  2272. #define FSCTL_PIPE_QUERY_EVENT CTL_CODE(FILE_DEVICE_NAMED_PIPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2273. #define FSCTL_PIPE_TRANSCEIVE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
  2274. #define FSCTL_PIPE_WAIT CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2275. #define FSCTL_PIPE_IMPERSONATE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2276. #define FSCTL_PIPE_SET_CLIENT_PROCESS CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2277. #define FSCTL_PIPE_QUERY_CLIENT_PROCESS CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2278. //
  2279. // Internal named pipe file control operations
  2280. //
  2281. #define FSCTL_PIPE_INTERNAL_READ CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA)
  2282. #define FSCTL_PIPE_INTERNAL_WRITE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA)
  2283. #define FSCTL_PIPE_INTERNAL_TRANSCEIVE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
  2284. #define FSCTL_PIPE_INTERNAL_READ_OVFLOW CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2048, METHOD_BUFFERED, FILE_READ_DATA)
  2285. //
  2286. // Define entry types for query event information
  2287. //
  2288. #define FILE_PIPE_READ_DATA 0x00000000
  2289. #define FILE_PIPE_WRITE_SPACE 0x00000001
  2290. //
  2291. // Named pipe file system control structure declarations
  2292. //
  2293. // Control structure for FSCTL_PIPE_ASSIGN_EVENT
  2294. typedef struct _FILE_PIPE_ASSIGN_EVENT_BUFFER {
  2295. HANDLE EventHandle;
  2296. ULONG KeyValue;
  2297. } FILE_PIPE_ASSIGN_EVENT_BUFFER, *PFILE_PIPE_ASSIGN_EVENT_BUFFER;
  2298. // Control structure for FSCTL_PIPE_PEEK
  2299. typedef struct _FILE_PIPE_PEEK_BUFFER {
  2300. ULONG NamedPipeState;
  2301. ULONG ReadDataAvailable;
  2302. ULONG NumberOfMessages;
  2303. ULONG MessageLength;
  2304. CHAR Data[1];
  2305. } FILE_PIPE_PEEK_BUFFER, *PFILE_PIPE_PEEK_BUFFER;
  2306. // Control structure for FSCTL_PIPE_QUERY_EVENT
  2307. typedef struct _FILE_PIPE_EVENT_BUFFER {
  2308. ULONG NamedPipeState;
  2309. ULONG EntryType;
  2310. ULONG ByteCount;
  2311. ULONG KeyValue;
  2312. ULONG NumberRequests;
  2313. } FILE_PIPE_EVENT_BUFFER, *PFILE_PIPE_EVENT_BUFFER;
  2314. // Control structure for FSCTL_PIPE_WAIT
  2315. typedef struct _FILE_PIPE_WAIT_FOR_BUFFER {
  2316. LARGE_INTEGER Timeout;
  2317. ULONG NameLength;
  2318. BOOLEAN TimeoutSpecified;
  2319. WCHAR Name[1];
  2320. } FILE_PIPE_WAIT_FOR_BUFFER, *PFILE_PIPE_WAIT_FOR_BUFFER;
  2321. // Control structure for FSCTL_PIPE_SET_CLIENT_PROCESS and FSCTL_PIPE_QUERY_CLIENT_PROCESS
  2322. typedef struct _FILE_PIPE_CLIENT_PROCESS_BUFFER {
  2323. #if !defined(BUILD_WOW6432)
  2324. PVOID ClientSession;
  2325. PVOID ClientProcess;
  2326. #else
  2327. ULONGLONG ClientSession;
  2328. ULONGLONG ClientProcess;
  2329. #endif
  2330. } FILE_PIPE_CLIENT_PROCESS_BUFFER, *PFILE_PIPE_CLIENT_PROCESS_BUFFER;
  2331. // This is an extension to the client process info buffer containing the client
  2332. // computer name
  2333. #define FILE_PIPE_COMPUTER_NAME_LENGTH 15
  2334. typedef struct _FILE_PIPE_CLIENT_PROCESS_BUFFER_EX {
  2335. #if !defined(BUILD_WOW6432)
  2336. PVOID ClientSession;
  2337. PVOID ClientProcess;
  2338. #else
  2339. ULONGLONG ClientSession;
  2340. ULONGLONG ClientProcess;
  2341. #endif
  2342. USHORT ClientComputerNameLength; // in bytes
  2343. WCHAR ClientComputerBuffer[FILE_PIPE_COMPUTER_NAME_LENGTH+1]; // terminated
  2344. } FILE_PIPE_CLIENT_PROCESS_BUFFER_EX, *PFILE_PIPE_CLIENT_PROCESS_BUFFER_EX;
  2345. // end_ntifs
  2346. //
  2347. // Mailslot file control code and structure definitions.
  2348. //
  2349. //
  2350. // Mailslot classes.
  2351. //
  2352. #define MAILSLOT_CLASS_FIRSTCLASS 1
  2353. #define MAILSLOT_CLASS_SECONDCLASS 2
  2354. //
  2355. // Mailslot file control operations.
  2356. //
  2357. #define FSCTL_MAILSLOT_PEEK CTL_CODE(FILE_DEVICE_MAILSLOT, 0, METHOD_NEITHER, FILE_READ_DATA) // ntifs
  2358. // Output control structure for FSCTL_MAILSLOT_PEEK
  2359. typedef struct _FILE_MAILSLOT_PEEK_BUFFER {
  2360. ULONG ReadDataAvailable;
  2361. ULONG NumberOfMessages;
  2362. ULONG MessageLength;
  2363. } FILE_MAILSLOT_PEEK_BUFFER, *PFILE_MAILSLOT_PEEK_BUFFER;
  2364. // begin_ntifs
  2365. //
  2366. // Control structure for FSCTL_LMR_GET_LINK_TRACKING_INFORMATION
  2367. //
  2368. //
  2369. // For links on DFS volumes the volume id and machine id are returned for
  2370. // link tracking
  2371. //
  2372. typedef enum _LINK_TRACKING_INFORMATION_TYPE {
  2373. NtfsLinkTrackingInformation,
  2374. DfsLinkTrackingInformation
  2375. } LINK_TRACKING_INFORMATION_TYPE, *PLINK_TRACKING_INFORMATION_TYPE;
  2376. typedef struct _LINK_TRACKING_INFORMATION {
  2377. LINK_TRACKING_INFORMATION_TYPE Type;
  2378. UCHAR VolumeId[16];
  2379. } LINK_TRACKING_INFORMATION, *PLINK_TRACKING_INFORMATION;
  2380. //
  2381. // Control structure for FSCTL_LMR_SET_LINK_TRACKING_INFORMATION
  2382. //
  2383. typedef struct _REMOTE_LINK_TRACKING_INFORMATION_ {
  2384. PVOID TargetFileObject;
  2385. ULONG TargetLinkTrackingInformationLength;
  2386. UCHAR TargetLinkTrackingInformationBuffer[1];
  2387. } REMOTE_LINK_TRACKING_INFORMATION,
  2388. *PREMOTE_LINK_TRACKING_INFORMATION;
  2389. // end_ntifs
  2390. //
  2391. // I/O Completion Specific Access Rights.
  2392. //
  2393. #define IO_COMPLETION_QUERY_STATE 0x0001
  2394. #define IO_COMPLETION_MODIFY_STATE 0x0002 // winnt
  2395. #define IO_COMPLETION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) // winnt
  2396. //
  2397. // I/O Completion Information Classes.
  2398. //
  2399. typedef enum _IO_COMPLETION_INFORMATION_CLASS {
  2400. IoCompletionBasicInformation
  2401. } IO_COMPLETION_INFORMATION_CLASS;
  2402. //
  2403. // I/O Completition Information Structures.
  2404. //
  2405. typedef struct _IO_COMPLETION_BASIC_INFORMATION {
  2406. LONG Depth;
  2407. } IO_COMPLETION_BASIC_INFORMATION, *PIO_COMPLETION_BASIC_INFORMATION;
  2408. NTSYSCALLAPI
  2409. NTSTATUS
  2410. NTAPI
  2411. NtCreateIoCompletion (
  2412. OUT PHANDLE IoCompletionHandle,
  2413. IN ACCESS_MASK DesiredAccess,
  2414. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  2415. IN ULONG Count OPTIONAL
  2416. );
  2417. NTSYSCALLAPI
  2418. NTSTATUS
  2419. NTAPI
  2420. NtOpenIoCompletion (
  2421. OUT PHANDLE IoCompletionHandle,
  2422. IN ACCESS_MASK DesiredAccess,
  2423. IN POBJECT_ATTRIBUTES ObjectAttributes
  2424. );
  2425. NTSYSCALLAPI
  2426. NTSTATUS
  2427. NTAPI
  2428. NtQueryIoCompletion (
  2429. IN HANDLE IoCompletionHandle,
  2430. IN IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass,
  2431. OUT PVOID IoCompletionInformation,
  2432. IN ULONG IoCompletionInformationLength,
  2433. OUT PULONG ReturnLength OPTIONAL
  2434. );
  2435. NTSYSCALLAPI
  2436. NTSTATUS
  2437. NTAPI
  2438. NtSetIoCompletion (
  2439. IN HANDLE IoCompletionHandle,
  2440. IN PVOID KeyContext,
  2441. IN PVOID ApcContext,
  2442. IN NTSTATUS IoStatus,
  2443. IN ULONG_PTR IoStatusInformation
  2444. );
  2445. NTSYSCALLAPI
  2446. NTSTATUS
  2447. NTAPI
  2448. NtRemoveIoCompletion (
  2449. IN HANDLE IoCompletionHandle,
  2450. OUT PVOID *KeyContext,
  2451. OUT PVOID *ApcContext,
  2452. OUT PIO_STATUS_BLOCK IoStatusBlock,
  2453. IN PLARGE_INTEGER Timeout
  2454. );
  2455. //
  2456. // Defines that are used to access the registry, but are not registry
  2457. // specific.
  2458. //
  2459. // begin_ntddk begin_wdm begin_nthal begin_ntminiport begin_ntndis begin_ntifs
  2460. //
  2461. // Define the I/O bus interface types.
  2462. //
  2463. typedef enum _INTERFACE_TYPE {
  2464. InterfaceTypeUndefined = -1,
  2465. Internal,
  2466. Isa,
  2467. Eisa,
  2468. MicroChannel,
  2469. TurboChannel,
  2470. PCIBus,
  2471. VMEBus,
  2472. NuBus,
  2473. PCMCIABus,
  2474. CBus,
  2475. MPIBus,
  2476. MPSABus,
  2477. ProcessorInternal,
  2478. InternalPowerBus,
  2479. PNPISABus,
  2480. PNPBus,
  2481. MaximumInterfaceType
  2482. }INTERFACE_TYPE, *PINTERFACE_TYPE;
  2483. //
  2484. // Define the DMA transfer widths.
  2485. //
  2486. typedef enum _DMA_WIDTH {
  2487. Width8Bits,
  2488. Width16Bits,
  2489. Width32Bits,
  2490. MaximumDmaWidth
  2491. }DMA_WIDTH, *PDMA_WIDTH;
  2492. //
  2493. // Define DMA transfer speeds.
  2494. //
  2495. typedef enum _DMA_SPEED {
  2496. Compatible,
  2497. TypeA,
  2498. TypeB,
  2499. TypeC,
  2500. TypeF,
  2501. MaximumDmaSpeed
  2502. }DMA_SPEED, *PDMA_SPEED;
  2503. //
  2504. // Define Interface reference/dereference routines for
  2505. // Interfaces exported by IRP_MN_QUERY_INTERFACE
  2506. //
  2507. typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context);
  2508. typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context);
  2509. // end_wdm
  2510. //
  2511. // Define types of bus information.
  2512. //
  2513. typedef enum _BUS_DATA_TYPE {
  2514. ConfigurationSpaceUndefined = -1,
  2515. Cmos,
  2516. EisaConfiguration,
  2517. Pos,
  2518. CbusConfiguration,
  2519. PCIConfiguration,
  2520. VMEConfiguration,
  2521. NuBusConfiguration,
  2522. PCMCIAConfiguration,
  2523. MPIConfiguration,
  2524. MPSAConfiguration,
  2525. PNPISAConfiguration,
  2526. SgiInternalConfiguration,
  2527. MaximumBusDataType
  2528. } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
  2529. // end_ntddk end_nthal end_ntminiport end_ntndis end_ntifs
  2530. #ifdef __cplusplus
  2531. }
  2532. #endif
  2533. #endif // _NTIOAPI_