Source code of Windows XP (NT5)
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.

3451 lines
117 KiB

  1. /*++ BUILD Version: 0015 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. winioctl.h
  5. Abstract:
  6. This module defines the 32-Bit Windows Device I/O control codes.
  7. Revision History:
  8. --*/
  9. //
  10. // Device interface class GUIDs.
  11. //
  12. // need these GUIDs outside conditional includes so that user can
  13. // #include <winioctl.h> in precompiled header
  14. // #include <initguid.h> in a single source file
  15. // #include <winioctl.h> in that source file a second time to instantiate the GUIDs
  16. //
  17. #ifdef DEFINE_GUID
  18. //
  19. // Make sure FAR is defined...
  20. //
  21. #ifndef FAR
  22. #ifdef _WIN32
  23. #define FAR
  24. #else
  25. #define FAR _far
  26. #endif
  27. #endif
  28. DEFINE_GUID(GUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  29. DEFINE_GUID(GUID_DEVINTERFACE_CDROM, 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  30. DEFINE_GUID(GUID_DEVINTERFACE_PARTITION, 0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  31. DEFINE_GUID(GUID_DEVINTERFACE_TAPE, 0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  32. DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK, 0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  33. DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  34. DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER, 0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  35. DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY, 0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  36. DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER, 0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  37. DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  38. DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
  39. DEFINE_GUID(GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, 0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
  40. //
  41. // Obsolete device interface class GUID names.
  42. // (use of above GUID_DEVINTERFACE_* names is recommended).
  43. //
  44. #define DiskClassGuid GUID_DEVINTERFACE_DISK
  45. #define CdRomClassGuid GUID_DEVINTERFACE_CDROM
  46. #define PartitionClassGuid GUID_DEVINTERFACE_PARTITION
  47. #define TapeClassGuid GUID_DEVINTERFACE_TAPE
  48. #define WriteOnceDiskClassGuid GUID_DEVINTERFACE_WRITEONCEDISK
  49. #define VolumeClassGuid GUID_DEVINTERFACE_VOLUME
  50. #define MediumChangerClassGuid GUID_DEVINTERFACE_MEDIUMCHANGER
  51. #define FloppyClassGuid GUID_DEVINTERFACE_FLOPPY
  52. #define CdChangerClassGuid GUID_DEVINTERFACE_CDCHANGER
  53. #define StoragePortClassGuid GUID_DEVINTERFACE_STORAGEPORT
  54. #define GUID_CLASS_COMPORT GUID_DEVINTERFACE_COMPORT
  55. #define GUID_SERENUM_BUS_ENUMERATOR GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR
  56. #endif // DEFINE_GUID
  57. #ifndef _WINIOCTL_
  58. #define _WINIOCTL_
  59. #ifndef _DEVIOCTL_
  60. #define _DEVIOCTL_
  61. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  62. //
  63. // Define the various device type values. Note that values used by Microsoft
  64. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  65. // by customers.
  66. //
  67. #define DEVICE_TYPE DWORD
  68. #define FILE_DEVICE_BEEP 0x00000001
  69. #define FILE_DEVICE_CD_ROM 0x00000002
  70. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
  71. #define FILE_DEVICE_CONTROLLER 0x00000004
  72. #define FILE_DEVICE_DATALINK 0x00000005
  73. #define FILE_DEVICE_DFS 0x00000006
  74. #define FILE_DEVICE_DISK 0x00000007
  75. #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
  76. #define FILE_DEVICE_FILE_SYSTEM 0x00000009
  77. #define FILE_DEVICE_INPORT_PORT 0x0000000a
  78. #define FILE_DEVICE_KEYBOARD 0x0000000b
  79. #define FILE_DEVICE_MAILSLOT 0x0000000c
  80. #define FILE_DEVICE_MIDI_IN 0x0000000d
  81. #define FILE_DEVICE_MIDI_OUT 0x0000000e
  82. #define FILE_DEVICE_MOUSE 0x0000000f
  83. #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
  84. #define FILE_DEVICE_NAMED_PIPE 0x00000011
  85. #define FILE_DEVICE_NETWORK 0x00000012
  86. #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
  87. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  88. #define FILE_DEVICE_NULL 0x00000015
  89. #define FILE_DEVICE_PARALLEL_PORT 0x00000016
  90. #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
  91. #define FILE_DEVICE_PRINTER 0x00000018
  92. #define FILE_DEVICE_SCANNER 0x00000019
  93. #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
  94. #define FILE_DEVICE_SERIAL_PORT 0x0000001b
  95. #define FILE_DEVICE_SCREEN 0x0000001c
  96. #define FILE_DEVICE_SOUND 0x0000001d
  97. #define FILE_DEVICE_STREAMS 0x0000001e
  98. #define FILE_DEVICE_TAPE 0x0000001f
  99. #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
  100. #define FILE_DEVICE_TRANSPORT 0x00000021
  101. #define FILE_DEVICE_UNKNOWN 0x00000022
  102. #define FILE_DEVICE_VIDEO 0x00000023
  103. #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
  104. #define FILE_DEVICE_WAVE_IN 0x00000025
  105. #define FILE_DEVICE_WAVE_OUT 0x00000026
  106. #define FILE_DEVICE_8042_PORT 0x00000027
  107. #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
  108. #define FILE_DEVICE_BATTERY 0x00000029
  109. #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
  110. #define FILE_DEVICE_MODEM 0x0000002b
  111. #define FILE_DEVICE_VDM 0x0000002c
  112. #define FILE_DEVICE_MASS_STORAGE 0x0000002d
  113. #define FILE_DEVICE_SMB 0x0000002e
  114. #define FILE_DEVICE_KS 0x0000002f
  115. #define FILE_DEVICE_CHANGER 0x00000030
  116. #define FILE_DEVICE_SMARTCARD 0x00000031
  117. #define FILE_DEVICE_ACPI 0x00000032
  118. #define FILE_DEVICE_DVD 0x00000033
  119. #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
  120. #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
  121. #define FILE_DEVICE_DFS_VOLUME 0x00000036
  122. #define FILE_DEVICE_SERENUM 0x00000037
  123. #define FILE_DEVICE_TERMSRV 0x00000038
  124. #define FILE_DEVICE_KSEC 0x00000039
  125. #define FILE_DEVICE_FIPS 0x0000003A
  126. //
  127. // Macro definition for defining IOCTL and FSCTL function control codes. Note
  128. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  129. // 2048-4095 are reserved for customers.
  130. //
  131. #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
  132. ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  133. )
  134. //
  135. // Macro to extract device type out of the device io control code
  136. //
  137. #define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((DWORD)(ctrlCode & 0xffff0000)) >> 16)
  138. //
  139. // Define the method codes for how buffers are passed for I/O and FS controls
  140. //
  141. #define METHOD_BUFFERED 0
  142. #define METHOD_IN_DIRECT 1
  143. #define METHOD_OUT_DIRECT 2
  144. #define METHOD_NEITHER 3
  145. //
  146. // Define the access check value for any access
  147. //
  148. //
  149. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  150. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  151. // constants *MUST* always be in sync.
  152. //
  153. //
  154. // FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS.
  155. // The file systems, however, may add additional access checks for I/O and FS controls
  156. // that use this value.
  157. //
  158. #define FILE_ANY_ACCESS 0
  159. #define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS)
  160. #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
  161. #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
  162. // end_ntddk end_wdm end_nthal end_ntifs
  163. #endif // _DEVIOCTL_
  164. #ifndef _NTDDSTOR_H_
  165. #define _NTDDSTOR_H_
  166. #ifdef __cplusplus
  167. extern "C" {
  168. #endif
  169. //
  170. // IoControlCode values for storage devices
  171. //
  172. #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
  173. //
  174. // The following device control codes are common for all class drivers. They
  175. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  176. // common codes
  177. //
  178. #define IOCTL_STORAGE_CHECK_VERIFY CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  179. #define IOCTL_STORAGE_CHECK_VERIFY2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
  180. #define IOCTL_STORAGE_MEDIA_REMOVAL CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  181. #define IOCTL_STORAGE_EJECT_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  182. #define IOCTL_STORAGE_LOAD_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  183. #define IOCTL_STORAGE_LOAD_MEDIA2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
  184. #define IOCTL_STORAGE_RESERVE CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  185. #define IOCTL_STORAGE_RELEASE CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  186. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  187. #define IOCTL_STORAGE_EJECTION_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
  188. #define IOCTL_STORAGE_MCN_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
  189. #define IOCTL_STORAGE_GET_MEDIA_TYPES CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  190. #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
  191. #define IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)
  192. #define IOCTL_STORAGE_GET_HOTPLUG_INFO CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS)
  193. #define IOCTL_STORAGE_SET_HOTPLUG_INFO CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  194. #define IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
  195. #define IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
  196. #define IOCTL_STORAGE_BREAK_RESERVATION CTL_CODE(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
  197. #define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
  198. #define IOCTL_STORAGE_PREDICT_FAILURE CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
  199. //
  200. // These ioctl codes are obsolete. They are defined here to avoid resuing them
  201. // and to allow class drivers to respond to them more easily.
  202. //
  203. #define OBSOLETE_IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  204. #define OBSOLETE_IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  205. //
  206. // IOCTL_STORAGE_GET_HOTPLUG_INFO
  207. //
  208. typedef struct _STORAGE_HOTPLUG_INFO {
  209. DWORD Size; // version
  210. BOOLEAN MediaRemovable; // ie. zip, jaz, cdrom, mo, etc. vs hdd
  211. BOOLEAN MediaHotplug; // ie. does the device succeed a lock even though its not lockable media?
  212. BOOLEAN DeviceHotplug; // ie. 1394, USB, etc.
  213. BOOLEAN WriteCacheEnableOverride; // This field should not be relied upon because it is no longer used
  214. } STORAGE_HOTPLUG_INFO, *PSTORAGE_HOTPLUG_INFO;
  215. //
  216. // IOCTL_STORAGE_GET_DEVICE_NUMBER
  217. //
  218. // input - none
  219. //
  220. // output - STORAGE_DEVICE_NUMBER structure
  221. // The values in the STORAGE_DEVICE_NUMBER structure are guaranteed
  222. // to remain unchanged until the system is rebooted. They are not
  223. // guaranteed to be persistant across boots.
  224. //
  225. typedef struct _STORAGE_DEVICE_NUMBER {
  226. //
  227. // The FILE_DEVICE_XXX type for this device.
  228. //
  229. DEVICE_TYPE DeviceType;
  230. //
  231. // The number of this device
  232. //
  233. DWORD DeviceNumber;
  234. //
  235. // If the device is partitionable, the partition number of the device.
  236. // Otherwise -1
  237. //
  238. DWORD PartitionNumber;
  239. } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
  240. //
  241. // Define the structures for scsi resets
  242. //
  243. typedef struct _STORAGE_BUS_RESET_REQUEST {
  244. BYTE PathId;
  245. } STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
  246. //
  247. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  248. // on a storage device that ejects media. This function
  249. // may or may not be supported on storage devices that
  250. // support removable media.
  251. //
  252. // TRUE means prevent media from being removed.
  253. // FALSE means allow media removal.
  254. //
  255. typedef struct _PREVENT_MEDIA_REMOVAL {
  256. BOOLEAN PreventMediaRemoval;
  257. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  258. // begin_ntminitape
  259. typedef struct _TAPE_STATISTICS {
  260. DWORD Version;
  261. DWORD Flags;
  262. LARGE_INTEGER RecoveredWrites;
  263. LARGE_INTEGER UnrecoveredWrites;
  264. LARGE_INTEGER RecoveredReads;
  265. LARGE_INTEGER UnrecoveredReads;
  266. BYTE CompressionRatioReads;
  267. BYTE CompressionRatioWrites;
  268. } TAPE_STATISTICS, *PTAPE_STATISTICS;
  269. #define RECOVERED_WRITES_VALID 0x00000001
  270. #define UNRECOVERED_WRITES_VALID 0x00000002
  271. #define RECOVERED_READS_VALID 0x00000004
  272. #define UNRECOVERED_READS_VALID 0x00000008
  273. #define WRITE_COMPRESSION_INFO_VALID 0x00000010
  274. #define READ_COMPRESSION_INFO_VALID 0x00000020
  275. typedef struct _TAPE_GET_STATISTICS {
  276. DWORD Operation;
  277. } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
  278. #define TAPE_RETURN_STATISTICS 0L
  279. #define TAPE_RETURN_ENV_INFO 1L
  280. #define TAPE_RESET_STATISTICS 2L
  281. //
  282. // IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
  283. // structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
  284. //
  285. typedef enum _STORAGE_MEDIA_TYPE {
  286. //
  287. // Following are defined in ntdddisk.h in the MEDIA_TYPE enum
  288. //
  289. // Unknown, // Format is unknown
  290. // F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  291. // F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  292. // F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  293. // F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  294. // F3_720_512, // 3.5", 720KB, 512 bytes/sector
  295. // F5_360_512, // 5.25", 360KB, 512 bytes/sector
  296. // F5_320_512, // 5.25", 320KB, 512 bytes/sector
  297. // F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  298. // F5_180_512, // 5.25", 180KB, 512 bytes/sector
  299. // F5_160_512, // 5.25", 160KB, 512 bytes/sector
  300. // RemovableMedia, // Removable media other than floppy
  301. // FixedMedia, // Fixed hard disk media
  302. // F3_120M_512, // 3.5", 120M Floppy
  303. // F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  304. // F5_640_512, // 5.25", 640KB, 512 bytes/sector
  305. // F5_720_512, // 5.25", 720KB, 512 bytes/sector
  306. // F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  307. // F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  308. // F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  309. // F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  310. // F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  311. // F8_256_128, // 8", 256KB, 128 bytes/sector
  312. // F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  313. //
  314. DDS_4mm = 0x20, // Tape - DAT DDS1,2,... (all vendors)
  315. MiniQic, // Tape - miniQIC Tape
  316. Travan, // Tape - Travan TR-1,2,3,...
  317. QIC, // Tape - QIC
  318. MP_8mm, // Tape - 8mm Exabyte Metal Particle
  319. AME_8mm, // Tape - 8mm Exabyte Advanced Metal Evap
  320. AIT1_8mm, // Tape - 8mm Sony AIT
  321. DLT, // Tape - DLT Compact IIIxt, IV
  322. NCTP, // Tape - Philips NCTP
  323. IBM_3480, // Tape - IBM 3480
  324. IBM_3490E, // Tape - IBM 3490E
  325. IBM_Magstar_3590, // Tape - IBM Magstar 3590
  326. IBM_Magstar_MP, // Tape - IBM Magstar MP
  327. STK_DATA_D3, // Tape - STK Data D3
  328. SONY_DTF, // Tape - Sony DTF
  329. DV_6mm, // Tape - 6mm Digital Video
  330. DMI, // Tape - Exabyte DMI and compatibles
  331. SONY_D2, // Tape - Sony D2S and D2L
  332. CLEANER_CARTRIDGE, // Cleaner - All Drive types that support Drive Cleaners
  333. CD_ROM, // Opt_Disk - CD
  334. CD_R, // Opt_Disk - CD-Recordable (Write Once)
  335. CD_RW, // Opt_Disk - CD-Rewriteable
  336. DVD_ROM, // Opt_Disk - DVD-ROM
  337. DVD_R, // Opt_Disk - DVD-Recordable (Write Once)
  338. DVD_RW, // Opt_Disk - DVD-Rewriteable
  339. MO_3_RW, // Opt_Disk - 3.5" Rewriteable MO Disk
  340. MO_5_WO, // Opt_Disk - MO 5.25" Write Once
  341. MO_5_RW, // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
  342. MO_5_LIMDOW, // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
  343. PC_5_WO, // Opt_Disk - Phase Change 5.25" Write Once Optical
  344. PC_5_RW, // Opt_Disk - Phase Change 5.25" Rewriteable
  345. PD_5_RW, // Opt_Disk - PhaseChange Dual Rewriteable
  346. ABL_5_WO, // Opt_Disk - Ablative 5.25" Write Once Optical
  347. PINNACLE_APEX_5_RW, // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
  348. SONY_12_WO, // Opt_Disk - Sony 12" Write Once
  349. PHILIPS_12_WO, // Opt_Disk - Philips/LMS 12" Write Once
  350. HITACHI_12_WO, // Opt_Disk - Hitachi 12" Write Once
  351. CYGNET_12_WO, // Opt_Disk - Cygnet/ATG 12" Write Once
  352. KODAK_14_WO, // Opt_Disk - Kodak 14" Write Once
  353. MO_NFR_525, // Opt_Disk - Near Field Recording (Terastor)
  354. NIKON_12_RW, // Opt_Disk - Nikon 12" Rewriteable
  355. IOMEGA_ZIP, // Mag_Disk - Iomega Zip
  356. IOMEGA_JAZ, // Mag_Disk - Iomega Jaz
  357. SYQUEST_EZ135, // Mag_Disk - Syquest EZ135
  358. SYQUEST_EZFLYER, // Mag_Disk - Syquest EzFlyer
  359. SYQUEST_SYJET, // Mag_Disk - Syquest SyJet
  360. AVATAR_F2, // Mag_Disk - 2.5" Floppy
  361. MP2_8mm, // Tape - 8mm Hitachi
  362. DST_S, // Ampex DST Small Tapes
  363. DST_M, // Ampex DST Medium Tapes
  364. DST_L, // Ampex DST Large Tapes
  365. VXATape_1, // Ecrix 8mm Tape
  366. VXATape_2, // Ecrix 8mm Tape
  367. STK_9840, // STK 9840
  368. LTO_Ultrium, // IBM, HP, Seagate LTO Ultrium
  369. LTO_Accelis, // IBM, HP, Seagate LTO Accelis
  370. DVD_RAM, // Opt_Disk - DVD-RAM
  371. AIT_8mm, // AIT2 or higher
  372. ADR_1, // OnStream ADR Mediatypes
  373. ADR_2
  374. } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
  375. #define MEDIA_ERASEABLE 0x00000001
  376. #define MEDIA_WRITE_ONCE 0x00000002
  377. #define MEDIA_READ_ONLY 0x00000004
  378. #define MEDIA_READ_WRITE 0x00000008
  379. #define MEDIA_WRITE_PROTECTED 0x00000100
  380. #define MEDIA_CURRENTLY_MOUNTED 0x80000000
  381. //
  382. // Define the different storage bus types
  383. // Bus types below 128 (0x80) are reserved for Microsoft use
  384. //
  385. typedef enum _STORAGE_BUS_TYPE {
  386. BusTypeUnknown = 0x00,
  387. BusTypeScsi,
  388. BusTypeAtapi,
  389. BusTypeAta,
  390. BusType1394,
  391. BusTypeSsa,
  392. BusTypeFibre,
  393. BusTypeUsb,
  394. BusTypeRAID,
  395. BusTypeMaxReserved = 0x7F
  396. } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
  397. typedef struct _DEVICE_MEDIA_INFO {
  398. union {
  399. struct {
  400. LARGE_INTEGER Cylinders;
  401. STORAGE_MEDIA_TYPE MediaType;
  402. DWORD TracksPerCylinder;
  403. DWORD SectorsPerTrack;
  404. DWORD BytesPerSector;
  405. DWORD NumberMediaSides;
  406. DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  407. } DiskInfo;
  408. struct {
  409. LARGE_INTEGER Cylinders;
  410. STORAGE_MEDIA_TYPE MediaType;
  411. DWORD TracksPerCylinder;
  412. DWORD SectorsPerTrack;
  413. DWORD BytesPerSector;
  414. DWORD NumberMediaSides;
  415. DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  416. } RemovableDiskInfo;
  417. struct {
  418. STORAGE_MEDIA_TYPE MediaType;
  419. DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  420. DWORD CurrentBlockSize;
  421. STORAGE_BUS_TYPE BusType;
  422. //
  423. // Bus specific information describing the medium supported.
  424. //
  425. union {
  426. struct {
  427. BYTE MediumType;
  428. BYTE DensityCode;
  429. } ScsiInformation;
  430. } BusSpecificData;
  431. } TapeInfo;
  432. } DeviceSpecific;
  433. } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
  434. typedef struct _GET_MEDIA_TYPES {
  435. DWORD DeviceType; // FILE_DEVICE_XXX values
  436. DWORD MediaInfoCount;
  437. DEVICE_MEDIA_INFO MediaInfo[1];
  438. } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
  439. //
  440. // IOCTL_STORAGE_PREDICT_FAILURE
  441. //
  442. // input - none
  443. //
  444. // output - STORAGE_PREDICT_FAILURE structure
  445. // PredictFailure returns zero if no failure predicted and non zero
  446. // if a failure is predicted.
  447. //
  448. // VendorSpecific returns 512 bytes of vendor specific information
  449. // if a failure is predicted
  450. //
  451. typedef struct _STORAGE_PREDICT_FAILURE
  452. {
  453. DWORD PredictFailure;
  454. BYTE VendorSpecific[512];
  455. } STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
  456. // end_ntminitape
  457. #ifdef __cplusplus
  458. }
  459. #endif
  460. #endif // _NTDDSTOR_H_
  461. //
  462. // IoControlCode values for disk devices.
  463. //
  464. #define IOCTL_DISK_BASE FILE_DEVICE_DISK
  465. #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  466. #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  467. #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  468. #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  469. #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  470. #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  471. #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  472. #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  473. #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  474. #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  475. #define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  476. #define IOCTL_DISK_FORMAT_TRACKS_EX CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  477. #define IOCTL_DISK_HISTOGRAM_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  478. #define IOCTL_DISK_HISTOGRAM_DATA CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  479. #define IOCTL_DISK_HISTOGRAM_RESET CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  480. #define IOCTL_DISK_REQUEST_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  481. #define IOCTL_DISK_REQUEST_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  482. #define IOCTL_DISK_PERFORMANCE_OFF CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS)
  483. #if(_WIN32_WINNT >= 0x0400)
  484. #define IOCTL_DISK_CONTROLLER_NUMBER CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  485. //
  486. // IOCTL support for SMART drive fault prediction.
  487. //
  488. #define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  489. #define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  490. #define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  491. #endif /* _WIN32_WINNT >= 0x0400 */
  492. #if (_WIN32_WINNT >= 0x500)
  493. //
  494. // New IOCTLs for GUID Partition tabled disks.
  495. //
  496. #define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
  497. #define IOCTL_DISK_SET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  498. #define IOCTL_DISK_GET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS)
  499. #define IOCTL_DISK_SET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  500. #define IOCTL_DISK_CREATE_DISK CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  501. #define IOCTL_DISK_GET_LENGTH_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS)
  502. #define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS)
  503. #endif /* _WIN32_WINNT >= 0x0500 */
  504. #if(_WIN32_WINNT >= 0x0500)
  505. #define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  506. #define IOCTL_DISK_GROW_PARTITION CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  507. #define IOCTL_DISK_GET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS)
  508. #define IOCTL_DISK_SET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  509. #define IOCTL_DISK_GET_WRITE_CACHE_STATE CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS)
  510. #define IOCTL_DISK_DELETE_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  511. //
  512. // Called to flush cached information that the driver may have about this
  513. // device's characteristics. Not all drivers cache characteristics, and not
  514. // cached properties can be flushed. This simply serves as an update to the
  515. // driver that it may want to do an expensive reexamination of the device's
  516. // characteristics now (fixed media size, partition table, etc...)
  517. //
  518. #define IOCTL_DISK_UPDATE_PROPERTIES CTL_CODE(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS)
  519. //
  520. // Special IOCTLs needed to support PC-98 machines in Japan
  521. //
  522. #define IOCTL_DISK_FORMAT_DRIVE CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  523. #define IOCTL_DISK_SENSE_DEVICE CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  524. #endif /* _WIN32_WINNT >= 0x0500 */
  525. //
  526. // The following device control codes are common for all class drivers. The
  527. // functions codes defined here must match all of the other class drivers.
  528. //
  529. // Warning: these codes will be replaced in the future by equivalent
  530. // IOCTL_STORAGE codes
  531. //
  532. #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  533. #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  534. #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  535. #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  536. #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  537. #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  538. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  539. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  540. //
  541. // Define the partition types returnable by known disk drivers.
  542. //
  543. #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
  544. #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
  545. #define PARTITION_XENIX_1 0x02 // Xenix
  546. #define PARTITION_XENIX_2 0x03 // Xenix
  547. #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
  548. #define PARTITION_EXTENDED 0x05 // Extended partition entry
  549. #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
  550. #define PARTITION_IFS 0x07 // IFS Partition
  551. #define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
  552. #define PARTITION_FAT32 0x0B // FAT32
  553. #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
  554. #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
  555. #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
  556. #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
  557. #define PARTITION_LDM 0x42 // Logical Disk Manager partition
  558. #define PARTITION_UNIX 0x63 // Unix
  559. #define VALID_NTFT 0xC0 // NTFT uses high order bits
  560. //
  561. // The high bit of the partition type code indicates that a partition
  562. // is part of an NTFT mirror or striped array.
  563. //
  564. #define PARTITION_NTFT 0x80 // NTFT partition
  565. //
  566. // The following macro is used to determine which partitions should be
  567. // assigned drive letters.
  568. //
  569. //++
  570. //
  571. // BOOLEAN
  572. // IsRecognizedPartition(
  573. // IN DWORD PartitionType
  574. // )
  575. //
  576. // Routine Description:
  577. //
  578. // This macro is used to determine to which partitions drive letters
  579. // should be assigned.
  580. //
  581. // Arguments:
  582. //
  583. // PartitionType - Supplies the type of the partition being examined.
  584. //
  585. // Return Value:
  586. //
  587. // The return value is TRUE if the partition type is recognized,
  588. // otherwise FALSE is returned.
  589. //
  590. //--
  591. #define IsRecognizedPartition( PartitionType ) ( \
  592. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) || \
  593. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) || \
  594. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) || \
  595. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) || \
  596. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) || \
  597. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) || \
  598. ((PartitionType) == PARTITION_FAT_12) || \
  599. ((PartitionType) == PARTITION_FAT_16) || \
  600. ((PartitionType) == PARTITION_IFS) || \
  601. ((PartitionType) == PARTITION_HUGE) || \
  602. ((PartitionType) == PARTITION_FAT32) || \
  603. ((PartitionType) == PARTITION_FAT32_XINT13) || \
  604. ((PartitionType) == PARTITION_XINT13) )
  605. //++
  606. //
  607. // BOOLEAN
  608. // IsContainerPartition(
  609. // IN DWORD PartitionType
  610. // )
  611. //
  612. // Routine Description:
  613. //
  614. // This macro is used to determine to which partition types are actually
  615. // containers for other partitions (ie, extended partitions).
  616. //
  617. // Arguments:
  618. //
  619. // PartitionType - Supplies the type of the partition being examined.
  620. //
  621. // Return Value:
  622. //
  623. // The return value is TRUE if the partition type is a container,
  624. // otherwise FALSE is returned.
  625. //
  626. //--
  627. #define IsContainerPartition( PartitionType ) \
  628. ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  629. //++
  630. //
  631. // BOOLEAN
  632. // IsFTPartition(
  633. // IN DWORD PartitionType
  634. // )
  635. //
  636. // Routine Description:
  637. //
  638. // This macro is used to determine if the given partition is an FT
  639. // partition.
  640. //
  641. // Arguments:
  642. //
  643. // PartitionType - Supplies the type of the partition being examined.
  644. //
  645. // Return Value:
  646. //
  647. // The return value is TRUE if the partition type is an FT partition,
  648. // otherwise FALSE is returned.
  649. //
  650. //--
  651. #define IsFTPartition( PartitionType ) \
  652. (((PartitionType)&PARTITION_NTFT) && IsRecognizedPartition(PartitionType))
  653. //
  654. // Define the media types supported by the driver.
  655. //
  656. typedef enum _MEDIA_TYPE {
  657. Unknown, // Format is unknown
  658. F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  659. F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  660. F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  661. F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  662. F3_720_512, // 3.5", 720KB, 512 bytes/sector
  663. F5_360_512, // 5.25", 360KB, 512 bytes/sector
  664. F5_320_512, // 5.25", 320KB, 512 bytes/sector
  665. F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  666. F5_180_512, // 5.25", 180KB, 512 bytes/sector
  667. F5_160_512, // 5.25", 160KB, 512 bytes/sector
  668. RemovableMedia, // Removable media other than floppy
  669. FixedMedia, // Fixed hard disk media
  670. F3_120M_512, // 3.5", 120M Floppy
  671. F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  672. F5_640_512, // 5.25", 640KB, 512 bytes/sector
  673. F5_720_512, // 5.25", 720KB, 512 bytes/sector
  674. F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  675. F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  676. F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  677. F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  678. F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  679. F8_256_128, // 8", 256KB, 128 bytes/sector
  680. F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  681. F3_240M_512, // 3.5", 240Mb Floppy (HiFD)
  682. F3_32M_512 // 3.5", 32Mb Floppy
  683. } MEDIA_TYPE, *PMEDIA_TYPE;
  684. //
  685. // Define the input buffer structure for the driver, when
  686. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  687. //
  688. typedef struct _FORMAT_PARAMETERS {
  689. MEDIA_TYPE MediaType;
  690. DWORD StartCylinderNumber;
  691. DWORD EndCylinderNumber;
  692. DWORD StartHeadNumber;
  693. DWORD EndHeadNumber;
  694. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  695. //
  696. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  697. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  698. // what tracks were bad during formatting. The length of that array is
  699. // reported in the `Information' field of the I/O Status Block.
  700. //
  701. typedef WORD BAD_TRACK_NUMBER;
  702. typedef WORD *PBAD_TRACK_NUMBER;
  703. //
  704. // Define the input buffer structure for the driver, when
  705. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  706. //
  707. typedef struct _FORMAT_EX_PARAMETERS {
  708. MEDIA_TYPE MediaType;
  709. DWORD StartCylinderNumber;
  710. DWORD EndCylinderNumber;
  711. DWORD StartHeadNumber;
  712. DWORD EndHeadNumber;
  713. WORD FormatGapLength;
  714. WORD SectorsPerTrack;
  715. WORD SectorNumber[1];
  716. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  717. //
  718. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  719. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  720. // request.
  721. //
  722. typedef struct _DISK_GEOMETRY {
  723. LARGE_INTEGER Cylinders;
  724. MEDIA_TYPE MediaType;
  725. DWORD TracksPerCylinder;
  726. DWORD SectorsPerTrack;
  727. DWORD BytesPerSector;
  728. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  729. //
  730. // This wmi guid returns a DISK_GEOMETRY structure
  731. //
  732. #define WMI_DISK_GEOMETRY_GUID { 0x25007f51, 0x57c2, 0x11d1, { 0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10 } }
  733. //
  734. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  735. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request. It is also used in a request
  736. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  737. //
  738. typedef struct _PARTITION_INFORMATION {
  739. LARGE_INTEGER StartingOffset;
  740. LARGE_INTEGER PartitionLength;
  741. DWORD HiddenSectors;
  742. DWORD PartitionNumber;
  743. BYTE PartitionType;
  744. BOOLEAN BootIndicator;
  745. BOOLEAN RecognizedPartition;
  746. BOOLEAN RewritePartition;
  747. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  748. //
  749. // The following structure is used to change the partition type of a
  750. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  751. // request.
  752. //
  753. typedef struct _SET_PARTITION_INFORMATION {
  754. BYTE PartitionType;
  755. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  756. //
  757. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  758. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  759. //
  760. typedef struct _DRIVE_LAYOUT_INFORMATION {
  761. DWORD PartitionCount;
  762. DWORD Signature;
  763. PARTITION_INFORMATION PartitionEntry[1];
  764. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  765. //
  766. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  767. // The offset and length parameters are both given in bytes.
  768. //
  769. typedef struct _VERIFY_INFORMATION {
  770. LARGE_INTEGER StartingOffset;
  771. DWORD Length;
  772. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  773. //
  774. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  775. // request.
  776. //
  777. typedef struct _REASSIGN_BLOCKS {
  778. WORD Reserved;
  779. WORD Count;
  780. DWORD BlockNumber[1];
  781. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  782. #if(_WIN32_WINNT >= 0x500)
  783. //
  784. // Support for GUID Partition Table (GPT) disks.
  785. //
  786. //
  787. // There are currently two ways a disk can be partitioned. With a traditional
  788. // AT-style master boot record (PARTITION_STYLE_MBR) and with a new, GPT
  789. // partition table (PARTITION_STYLE_GPT). RAW is for an unrecognizable
  790. // partition style. There are a very limited number of things you can
  791. // do with a RAW partititon.
  792. //
  793. typedef enum _PARTITION_STYLE {
  794. PARTITION_STYLE_MBR,
  795. PARTITION_STYLE_GPT,
  796. PARTITION_STYLE_RAW
  797. } PARTITION_STYLE;
  798. //
  799. // The following structure defines information in a GPT partition that is
  800. // not common to both GPT and MBR partitions.
  801. //
  802. typedef struct _PARTITION_INFORMATION_GPT {
  803. GUID PartitionType; // Partition type. See table 16-3.
  804. GUID PartitionId; // Unique GUID for this partition.
  805. DWORD64 Attributes; // See table 16-4.
  806. WCHAR Name [36]; // Partition Name in Unicode.
  807. } PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT;
  808. //
  809. // The following are GPT partition attributes applicable for any
  810. // partition type. These attributes are not OS-specific
  811. //
  812. #define GPT_ATTRIBUTE_PLATFORM_REQUIRED (0x0000000000000001)
  813. //
  814. // The following are GPT partition attributes applicable when the
  815. // PartitionType is PARTITION_BASIC_DATA_GUID.
  816. //
  817. #define GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER (0x8000000000000000)
  818. #define GPT_BASIC_DATA_ATTRIBUTE_HIDDEN (0x4000000000000000)
  819. #define GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY (0x1000000000000000)
  820. //
  821. // The following structure defines information in an MBR partition that is not
  822. // common to both GPT and MBR partitions.
  823. //
  824. typedef struct _PARTITION_INFORMATION_MBR {
  825. BYTE PartitionType;
  826. BOOLEAN BootIndicator;
  827. BOOLEAN RecognizedPartition;
  828. DWORD HiddenSectors;
  829. } PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR;
  830. //
  831. // The structure SET_PARTITION_INFO_EX is used with the ioctl
  832. // IOCTL_SET_PARTITION_INFO_EX to set information about a specific
  833. // partition. Note that for MBR partitions, you can only set the partition
  834. // signature, whereas GPT partitions allow setting of all fields that
  835. // you can get.
  836. //
  837. typedef SET_PARTITION_INFORMATION SET_PARTITION_INFORMATION_MBR;
  838. typedef PARTITION_INFORMATION_GPT SET_PARTITION_INFORMATION_GPT;
  839. typedef struct _SET_PARTITION_INFORMATION_EX {
  840. PARTITION_STYLE PartitionStyle;
  841. union {
  842. SET_PARTITION_INFORMATION_MBR Mbr;
  843. SET_PARTITION_INFORMATION_GPT Gpt;
  844. };
  845. } SET_PARTITION_INFORMATION_EX, *PSET_PARTITION_INFORMATION_EX;
  846. //
  847. // The structure CREATE_DISK_GPT with the ioctl IOCTL_DISK_CREATE_DISK
  848. // to initialize an virgin disk with an empty GPT partition table.
  849. //
  850. typedef struct _CREATE_DISK_GPT {
  851. GUID DiskId; // Unique disk id for the disk.
  852. DWORD MaxPartitionCount; // Maximim number of partitions allowable.
  853. } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
  854. //
  855. // The structure CREATE_DISK_MBR with the ioctl IOCTL_DISK_CREATE_DISK
  856. // to initialize an virgin disk with an empty MBR partition table.
  857. //
  858. typedef struct _CREATE_DISK_MBR {
  859. DWORD Signature;
  860. } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
  861. typedef struct _CREATE_DISK {
  862. PARTITION_STYLE PartitionStyle;
  863. union {
  864. CREATE_DISK_MBR Mbr;
  865. CREATE_DISK_GPT Gpt;
  866. };
  867. } CREATE_DISK, *PCREATE_DISK;
  868. //
  869. // The structure GET_LENGTH_INFORMATION is used with the ioctl
  870. // IOCTL_DISK_GET_LENGTH_INFO to obtain the length, in bytes, of the
  871. // disk, partition, or volume.
  872. //
  873. typedef struct _GET_LENGTH_INFORMATION {
  874. LARGE_INTEGER Length;
  875. } GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION;
  876. //
  877. // The PARTITION_INFORMATION_EX structure is used with the
  878. // IOCTL_DISK_GET_DRIVE_LAYOUT_EX, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
  879. // IOCTL_DISK_GET_PARTITION_INFO_EX and IOCTL_DISK_GET_PARTITION_INFO_EX calls.
  880. //
  881. typedef struct _PARTITION_INFORMATION_EX {
  882. PARTITION_STYLE PartitionStyle;
  883. LARGE_INTEGER StartingOffset;
  884. LARGE_INTEGER PartitionLength;
  885. DWORD PartitionNumber;
  886. BOOLEAN RewritePartition;
  887. union {
  888. PARTITION_INFORMATION_MBR Mbr;
  889. PARTITION_INFORMATION_GPT Gpt;
  890. };
  891. } PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX;
  892. //
  893. // GPT specific drive layout information.
  894. //
  895. typedef struct _DRIVE_LAYOUT_INFORMATION_GPT {
  896. GUID DiskId;
  897. LARGE_INTEGER StartingUsableOffset;
  898. LARGE_INTEGER UsableLength;
  899. DWORD MaxPartitionCount;
  900. } DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT;
  901. //
  902. // MBR specific drive layout information.
  903. //
  904. typedef struct _DRIVE_LAYOUT_INFORMATION_MBR {
  905. DWORD Signature;
  906. } DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR;
  907. //
  908. // The structure DRIVE_LAYOUT_INFORMATION_EX is used with the
  909. // IOCTL_SET_DRIVE_LAYOUT_EX and IOCTL_GET_DRIVE_LAYOUT_EX calls.
  910. //
  911. typedef struct _DRIVE_LAYOUT_INFORMATION_EX {
  912. DWORD PartitionStyle;
  913. DWORD PartitionCount;
  914. union {
  915. DRIVE_LAYOUT_INFORMATION_MBR Mbr;
  916. DRIVE_LAYOUT_INFORMATION_GPT Gpt;
  917. };
  918. PARTITION_INFORMATION_EX PartitionEntry[1];
  919. } DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX;
  920. #endif // (_WIN32_WINNT >= 0x0500)
  921. #if(_WIN32_WINNT >= 0x0500)
  922. //
  923. // The DISK_GEOMETRY_EX structure is returned on issuing an
  924. // IOCTL_DISK_GET_DRIVE_GEOMETRY_EX ioctl.
  925. //
  926. typedef enum _DETECTION_TYPE {
  927. DetectNone,
  928. DetectInt13,
  929. DetectExInt13
  930. } DETECTION_TYPE;
  931. typedef struct _DISK_INT13_INFO {
  932. WORD DriveSelect;
  933. DWORD MaxCylinders;
  934. WORD SectorsPerTrack;
  935. WORD MaxHeads;
  936. WORD NumberDrives;
  937. } DISK_INT13_INFO, *PDISK_INT13_INFO;
  938. typedef struct _DISK_EX_INT13_INFO {
  939. WORD ExBufferSize;
  940. WORD ExFlags;
  941. DWORD ExCylinders;
  942. DWORD ExHeads;
  943. DWORD ExSectorsPerTrack;
  944. DWORD64 ExSectorsPerDrive;
  945. WORD ExSectorSize;
  946. WORD ExReserved;
  947. } DISK_EX_INT13_INFO, *PDISK_EX_INT13_INFO;
  948. typedef struct _DISK_DETECTION_INFO {
  949. DWORD SizeOfDetectInfo;
  950. DETECTION_TYPE DetectionType;
  951. union {
  952. struct {
  953. //
  954. // If DetectionType == DETECTION_INT13 then we have just the Int13
  955. // information.
  956. //
  957. DISK_INT13_INFO Int13;
  958. //
  959. // If DetectionType == DETECTION_EX_INT13, then we have the
  960. // extended int 13 information.
  961. //
  962. DISK_EX_INT13_INFO ExInt13; // If DetectionType == DetectExInt13
  963. };
  964. };
  965. } DISK_DETECTION_INFO, *PDISK_DETECTION_INFO;
  966. typedef struct _DISK_PARTITION_INFO {
  967. DWORD SizeOfPartitionInfo;
  968. PARTITION_STYLE PartitionStyle; // PartitionStyle = RAW, GPT or MBR
  969. union {
  970. struct { // If PartitionStyle == MBR
  971. DWORD Signature; // MBR Signature
  972. DWORD CheckSum; // MBR CheckSum
  973. } Mbr;
  974. struct { // If PartitionStyle == GPT
  975. GUID DiskId;
  976. } Gpt;
  977. };
  978. } DISK_PARTITION_INFO, *PDISK_PARTITION_INFO;
  979. //
  980. // The Geometry structure is a variable length structure composed of a
  981. // DISK_GEOMETRY_EX structure followed by a DISK_PARTITION_INFO structure
  982. // followed by a DISK_DETECTION_DATA structure.
  983. //
  984. #define DiskGeometryGetPartition(Geometry)\
  985. ((PDISK_PARTITION_INFO)((Geometry)+1))
  986. #define DiskGeometryGetDetect(Geometry)\
  987. ((PDISK_DETECTION_INFO)(((PBYTE)DiskGeometryGetPartition(Geometry)+\
  988. DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo)))
  989. typedef struct _DISK_GEOMETRY_EX {
  990. DISK_GEOMETRY Geometry; // Standard disk geometry: may be faked by driver.
  991. LARGE_INTEGER DiskSize; // Must always be correct
  992. BYTE Data[1]; // Partition, Detect info
  993. } DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX;
  994. #endif // (_WIN32_WINNT > 0x0500)
  995. #if(_WIN32_WINNT >= 0x0400)
  996. //
  997. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  998. // number for the handle. This is used to determine if a disk
  999. // is attached to the primary or secondary IDE controller.
  1000. //
  1001. typedef struct _DISK_CONTROLLER_NUMBER {
  1002. DWORD ControllerNumber;
  1003. DWORD DiskNumber;
  1004. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  1005. #endif /* _WIN32_WINNT >= 0x0400 */
  1006. #if(_WIN32_WINNT >= 0x0500)
  1007. //
  1008. // IOCTL_DISK_SET_CACHE allows the caller to get or set the state of the disk
  1009. // read/write caches.
  1010. //
  1011. // If the structure is provided as the input buffer for the ioctl the read &
  1012. // write caches will be enabled or disabled depending on the parameters
  1013. // provided.
  1014. //
  1015. // If the structure is provided as an output buffer for the ioctl the state
  1016. // of the read & write caches will be returned. If both input and outut buffers
  1017. // are provided the output buffer will contain the cache state BEFORE any
  1018. // changes are made
  1019. //
  1020. typedef enum {
  1021. EqualPriority,
  1022. KeepPrefetchedData,
  1023. KeepReadData
  1024. } DISK_CACHE_RETENTION_PRIORITY;
  1025. typedef enum _DISK_WRITE_CACHE_STATE {
  1026. DiskWriteCacheNormal,
  1027. DiskWriteCacheForceDisable,
  1028. DiskWriteCacheDisableNotSupported
  1029. } DISK_WRITE_CACHE_STATE, *PDISK_WRITE_CACHE_STATE;
  1030. typedef struct _DISK_CACHE_INFORMATION {
  1031. //
  1032. // on return indicates that the device is capable of saving any parameters
  1033. // in non-volatile storage. On send indicates that the device should
  1034. // save the state in non-volatile storage.
  1035. //
  1036. BOOLEAN ParametersSavable;
  1037. //
  1038. // Indicates whether the write and read caches are enabled.
  1039. //
  1040. BOOLEAN ReadCacheEnabled;
  1041. BOOLEAN WriteCacheEnabled;
  1042. //
  1043. // Controls the likelyhood of data remaining in the cache depending on how
  1044. // it got there. Data cached from a READ or WRITE operation may be given
  1045. // higher, lower or equal priority to data entered into the cache for other
  1046. // means (like prefetch)
  1047. //
  1048. DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority;
  1049. DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority;
  1050. //
  1051. // Requests for a larger number of blocks than this may have prefetching
  1052. // disabled. If this value is set to 0 prefetch will be disabled.
  1053. //
  1054. WORD DisablePrefetchTransferLength;
  1055. //
  1056. // If TRUE then ScalarPrefetch (below) will be valid. If FALSE then
  1057. // the minimum and maximum values should be treated as a block count
  1058. // (BlockPrefetch)
  1059. //
  1060. BOOLEAN PrefetchScalar;
  1061. //
  1062. // Contains the minimum and maximum amount of data which will be
  1063. // will be prefetched into the cache on a disk operation. This value
  1064. // may either be a scalar multiplier of the transfer length of the request,
  1065. // or an abolute number of disk blocks. PrefetchScalar (above) indicates
  1066. // which interpretation is used.
  1067. //
  1068. union {
  1069. struct {
  1070. WORD Minimum;
  1071. WORD Maximum;
  1072. //
  1073. // The maximum number of blocks which will be prefetched - useful
  1074. // with the scalar limits to set definite upper limits.
  1075. //
  1076. WORD MaximumBlocks;
  1077. } ScalarPrefetch;
  1078. struct {
  1079. WORD Minimum;
  1080. WORD Maximum;
  1081. } BlockPrefetch;
  1082. };
  1083. } DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION;
  1084. //
  1085. // IOCTL_DISK_GROW_PARTITION will update the size of a partition
  1086. // by adding sectors to the length. The number of sectors must be
  1087. // predetermined by examining PARTITION_INFORMATION.
  1088. //
  1089. typedef struct _DISK_GROW_PARTITION {
  1090. DWORD PartitionNumber;
  1091. LARGE_INTEGER BytesToGrow;
  1092. } DISK_GROW_PARTITION, *PDISK_GROW_PARTITION;
  1093. #endif /* _WIN32_WINNT >= 0x0500 */
  1094. ///////////////////////////////////////////////////////
  1095. // //
  1096. // The following structures define disk performance //
  1097. // statistics: specifically the locations of all the //
  1098. // reads and writes which have occured on the disk. //
  1099. // //
  1100. // To use these structures, you must issue an IOCTL_ //
  1101. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to //
  1102. // obtain the basic histogram information. The //
  1103. // number of buckets which must allocated is part of //
  1104. // this structure. Allocate the required number of //
  1105. // buckets and call an IOCTL_DISK_HIST_DATA to fill //
  1106. // in the data //
  1107. // //
  1108. ///////////////////////////////////////////////////////
  1109. #define HIST_NO_OF_BUCKETS 24
  1110. typedef struct _HISTOGRAM_BUCKET {
  1111. DWORD Reads;
  1112. DWORD Writes;
  1113. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  1114. #define HISTOGRAM_BUCKET_SIZE sizeof(HISTOGRAM_BUCKET)
  1115. typedef struct _DISK_HISTOGRAM {
  1116. LARGE_INTEGER DiskSize;
  1117. LARGE_INTEGER Start;
  1118. LARGE_INTEGER End;
  1119. LARGE_INTEGER Average;
  1120. LARGE_INTEGER AverageRead;
  1121. LARGE_INTEGER AverageWrite;
  1122. DWORD Granularity;
  1123. DWORD Size;
  1124. DWORD ReadCount;
  1125. DWORD WriteCount;
  1126. PHISTOGRAM_BUCKET Histogram;
  1127. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  1128. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  1129. ///////////////////////////////////////////////////////
  1130. // //
  1131. // The following structures define disk debugging //
  1132. // capabilities. The IOCTLs are directed to one of //
  1133. // the two disk filter drivers. //
  1134. // //
  1135. // DISKPERF is a utilty for collecting disk request //
  1136. // statistics. //
  1137. // //
  1138. // SIMBAD is a utility for injecting faults in //
  1139. // IO requests to disks. //
  1140. // //
  1141. ///////////////////////////////////////////////////////
  1142. //
  1143. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  1144. // request. This ioctl collects summary disk request statistics used
  1145. // in measuring performance.
  1146. //
  1147. typedef struct _DISK_PERFORMANCE {
  1148. LARGE_INTEGER BytesRead;
  1149. LARGE_INTEGER BytesWritten;
  1150. LARGE_INTEGER ReadTime;
  1151. LARGE_INTEGER WriteTime;
  1152. LARGE_INTEGER IdleTime;
  1153. DWORD ReadCount;
  1154. DWORD WriteCount;
  1155. DWORD QueueDepth;
  1156. DWORD SplitCount;
  1157. LARGE_INTEGER QueryTime;
  1158. DWORD StorageDeviceNumber;
  1159. WCHAR StorageManagerName[8];
  1160. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  1161. //
  1162. // This structure defines the disk logging record. When disk logging
  1163. // is enabled, one of these is written to an internal buffer for each
  1164. // disk request.
  1165. //
  1166. typedef struct _DISK_RECORD {
  1167. LARGE_INTEGER ByteOffset;
  1168. LARGE_INTEGER StartTime;
  1169. LARGE_INTEGER EndTime;
  1170. PVOID VirtualAddress;
  1171. DWORD NumberOfBytes;
  1172. BYTE DeviceNumber;
  1173. BOOLEAN ReadRequest;
  1174. } DISK_RECORD, *PDISK_RECORD;
  1175. //
  1176. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  1177. // Not all fields are valid with each function type.
  1178. //
  1179. typedef struct _DISK_LOGGING {
  1180. BYTE Function;
  1181. PVOID BufferAddress;
  1182. DWORD BufferSize;
  1183. } DISK_LOGGING, *PDISK_LOGGING;
  1184. //
  1185. // Disk logging functions
  1186. //
  1187. // Start disk logging. Only the Function and BufferSize fields are valid.
  1188. //
  1189. #define DISK_LOGGING_START 0
  1190. //
  1191. // Stop disk logging. Only the Function field is valid.
  1192. //
  1193. #define DISK_LOGGING_STOP 1
  1194. //
  1195. // Return disk log. All fields are valid. Data will be copied from internal
  1196. // buffer to buffer specified for the number of bytes requested.
  1197. //
  1198. #define DISK_LOGGING_DUMP 2
  1199. //
  1200. // DISK BINNING
  1201. //
  1202. // DISKPERF will keep counters for IO that falls in each of these ranges.
  1203. // The application determines the number and size of the ranges.
  1204. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  1205. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  1206. //
  1207. #define DISK_BINNING 3
  1208. //
  1209. // Bin types
  1210. //
  1211. typedef enum _BIN_TYPES {
  1212. RequestSize,
  1213. RequestLocation
  1214. } BIN_TYPES;
  1215. //
  1216. // Bin ranges
  1217. //
  1218. typedef struct _BIN_RANGE {
  1219. LARGE_INTEGER StartValue;
  1220. LARGE_INTEGER Length;
  1221. } BIN_RANGE, *PBIN_RANGE;
  1222. //
  1223. // Bin definition
  1224. //
  1225. typedef struct _PERF_BIN {
  1226. DWORD NumberOfBins;
  1227. DWORD TypeOfBin;
  1228. BIN_RANGE BinsRanges[1];
  1229. } PERF_BIN, *PPERF_BIN ;
  1230. //
  1231. // Bin count
  1232. //
  1233. typedef struct _BIN_COUNT {
  1234. BIN_RANGE BinRange;
  1235. DWORD BinCount;
  1236. } BIN_COUNT, *PBIN_COUNT;
  1237. //
  1238. // Bin results
  1239. //
  1240. typedef struct _BIN_RESULTS {
  1241. DWORD NumberOfBins;
  1242. BIN_COUNT BinCounts[1];
  1243. } BIN_RESULTS, *PBIN_RESULTS;
  1244. #if(_WIN32_WINNT >= 0x0400)
  1245. //
  1246. // Data structures for SMART drive fault prediction.
  1247. //
  1248. // GETVERSIONINPARAMS contains the data returned from the
  1249. // Get Driver Version function.
  1250. //
  1251. #include <pshpack1.h>
  1252. typedef struct _GETVERSIONINPARAMS {
  1253. BYTE bVersion; // Binary driver version.
  1254. BYTE bRevision; // Binary driver revision.
  1255. BYTE bReserved; // Not used.
  1256. BYTE bIDEDeviceMap; // Bit map of IDE devices.
  1257. DWORD fCapabilities; // Bit mask of driver capabilities.
  1258. DWORD dwReserved[4]; // For future use.
  1259. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  1260. #include <poppack.h>
  1261. //
  1262. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  1263. //
  1264. #define CAP_ATA_ID_CMD 1 // ATA ID command supported
  1265. #define CAP_ATAPI_ID_CMD 2 // ATAPI ID command supported
  1266. #define CAP_SMART_CMD 4 // SMART commannds supported
  1267. //
  1268. // IDE registers
  1269. //
  1270. #include <pshpack1.h>
  1271. typedef struct _IDEREGS {
  1272. BYTE bFeaturesReg; // Used for specifying SMART "commands".
  1273. BYTE bSectorCountReg; // IDE sector count register
  1274. BYTE bSectorNumberReg; // IDE sector number register
  1275. BYTE bCylLowReg; // IDE low order cylinder value
  1276. BYTE bCylHighReg; // IDE high order cylinder value
  1277. BYTE bDriveHeadReg; // IDE drive/head register
  1278. BYTE bCommandReg; // Actual IDE command.
  1279. BYTE bReserved; // reserved for future use. Must be zero.
  1280. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  1281. #include <poppack.h>
  1282. //
  1283. // Valid values for the bCommandReg member of IDEREGS.
  1284. //
  1285. #define ATAPI_ID_CMD 0xA1 // Returns ID sector for ATAPI.
  1286. #define ID_CMD 0xEC // Returns ID sector for ATA.
  1287. #define SMART_CMD 0xB0 // Performs SMART cmd.
  1288. // Requires valid bFeaturesReg,
  1289. // bCylLowReg, and bCylHighReg
  1290. //
  1291. // Cylinder register defines for SMART command
  1292. //
  1293. #define SMART_CYL_LOW 0x4F
  1294. #define SMART_CYL_HI 0xC2
  1295. //
  1296. // SENDCMDINPARAMS contains the input parameters for the
  1297. // Send Command to Drive function.
  1298. //
  1299. #include <pshpack1.h>
  1300. typedef struct _SENDCMDINPARAMS {
  1301. DWORD cBufferSize; // Buffer size in bytes
  1302. IDEREGS irDriveRegs; // Structure with drive register values.
  1303. BYTE bDriveNumber; // Physical drive number to send
  1304. // command to (0,1,2,3).
  1305. BYTE bReserved[3]; // Reserved for future expansion.
  1306. DWORD dwReserved[4]; // For future use.
  1307. BYTE bBuffer[1]; // Input buffer.
  1308. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  1309. #include <poppack.h>
  1310. //
  1311. // Status returned from driver
  1312. //
  1313. #include <pshpack1.h>
  1314. typedef struct _DRIVERSTATUS {
  1315. BYTE bDriverError; // Error code from driver,
  1316. // or 0 if no error.
  1317. BYTE bIDEError; // Contents of IDE Error register.
  1318. // Only valid when bDriverError
  1319. // is SMART_IDE_ERROR.
  1320. BYTE bReserved[2]; // Reserved for future expansion.
  1321. DWORD dwReserved[2]; // Reserved for future expansion.
  1322. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  1323. #include <poppack.h>
  1324. //
  1325. // bDriverError values
  1326. //
  1327. #define SMART_NO_ERROR 0 // No error
  1328. #define SMART_IDE_ERROR 1 // Error from IDE controller
  1329. #define SMART_INVALID_FLAG 2 // Invalid command flag
  1330. #define SMART_INVALID_COMMAND 3 // Invalid command byte
  1331. #define SMART_INVALID_BUFFER 4 // Bad buffer (null, invalid addr..)
  1332. #define SMART_INVALID_DRIVE 5 // Drive number not valid
  1333. #define SMART_INVALID_IOCTL 6 // Invalid IOCTL
  1334. #define SMART_ERROR_NO_MEM 7 // Could not lock user's buffer
  1335. #define SMART_INVALID_REGISTER 8 // Some IDE Register not valid
  1336. #define SMART_NOT_SUPPORTED 9 // Invalid cmd flag set
  1337. #define SMART_NO_IDE_DEVICE 10 // Cmd issued to device not present
  1338. // although drive number is valid
  1339. //
  1340. // SMART sub commands for execute offline diags
  1341. //
  1342. #define SMART_OFFLINE_ROUTINE_OFFLINE 0
  1343. #define SMART_SHORT_SELFTEST_OFFLINE 1
  1344. #define SMART_EXTENDED_SELFTEST_OFFLINE 2
  1345. #define SMART_ABORT_OFFLINE_SELFTEST 127
  1346. #define SMART_SHORT_SELFTEST_CAPTIVE 129
  1347. #define SMART_EXTENDED_SELFTEST_CAPTIVE 130
  1348. #include <pshpack1.h>
  1349. typedef struct _SENDCMDOUTPARAMS {
  1350. DWORD cBufferSize; // Size of bBuffer in bytes
  1351. DRIVERSTATUS DriverStatus; // Driver status structure.
  1352. BYTE bBuffer[1]; // Buffer of arbitrary length in which to store the data read from the // drive.
  1353. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  1354. #include <poppack.h>
  1355. #define READ_ATTRIBUTE_BUFFER_SIZE 512
  1356. #define IDENTIFY_BUFFER_SIZE 512
  1357. #define READ_THRESHOLD_BUFFER_SIZE 512
  1358. #define SMART_LOG_SECTOR_SIZE 512
  1359. //
  1360. // Feature register defines for SMART "sub commands"
  1361. //
  1362. #define READ_ATTRIBUTES 0xD0
  1363. #define READ_THRESHOLDS 0xD1
  1364. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  1365. #define SAVE_ATTRIBUTE_VALUES 0xD3
  1366. #define EXECUTE_OFFLINE_DIAGS 0xD4
  1367. #define SMART_READ_LOG 0xD5
  1368. #define SMART_WRITE_LOG 0xd6
  1369. #define ENABLE_SMART 0xD8
  1370. #define DISABLE_SMART 0xD9
  1371. #define RETURN_SMART_STATUS 0xDA
  1372. #define ENABLE_DISABLE_AUTO_OFFLINE 0xDB
  1373. #endif /* _WIN32_WINNT >= 0x0400 */
  1374. #define IOCTL_CHANGER_BASE FILE_DEVICE_CHANGER
  1375. #define IOCTL_CHANGER_GET_PARAMETERS CTL_CODE(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
  1376. #define IOCTL_CHANGER_GET_STATUS CTL_CODE(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  1377. #define IOCTL_CHANGER_GET_PRODUCT_DATA CTL_CODE(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
  1378. #define IOCTL_CHANGER_SET_ACCESS CTL_CODE(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1379. #define IOCTL_CHANGER_GET_ELEMENT_STATUS CTL_CODE(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1380. #define IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS CTL_CODE(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
  1381. #define IOCTL_CHANGER_SET_POSITION CTL_CODE(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
  1382. #define IOCTL_CHANGER_EXCHANGE_MEDIUM CTL_CODE(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
  1383. #define IOCTL_CHANGER_MOVE_MEDIUM CTL_CODE(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS)
  1384. #define IOCTL_CHANGER_REINITIALIZE_TRANSPORT CTL_CODE(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
  1385. #define IOCTL_CHANGER_QUERY_VOLUME_TAGS CTL_CODE(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1386. #define MAX_VOLUME_ID_SIZE 36
  1387. #define MAX_VOLUME_TEMPLATE_SIZE 40
  1388. #define VENDOR_ID_LENGTH 8
  1389. #define PRODUCT_ID_LENGTH 16
  1390. #define REVISION_LENGTH 4
  1391. #define SERIAL_NUMBER_LENGTH 32
  1392. //
  1393. // Common structures describing elements.
  1394. //
  1395. typedef enum _ELEMENT_TYPE {
  1396. AllElements, // As defined by SCSI
  1397. ChangerTransport, // As defined by SCSI
  1398. ChangerSlot, // As defined by SCSI
  1399. ChangerIEPort, // As defined by SCSI
  1400. ChangerDrive, // As defined by SCSI
  1401. ChangerDoor, // Front panel, used to access internal of cabinet.
  1402. ChangerKeypad, // Keypad/input on front panel.
  1403. ChangerMaxElement // Placeholder only. Not a valid type.
  1404. } ELEMENT_TYPE, *PELEMENT_TYPE;
  1405. typedef struct _CHANGER_ELEMENT {
  1406. ELEMENT_TYPE ElementType;
  1407. DWORD ElementAddress;
  1408. } CHANGER_ELEMENT, *PCHANGER_ELEMENT;
  1409. typedef struct _CHANGER_ELEMENT_LIST {
  1410. CHANGER_ELEMENT Element;
  1411. DWORD NumberOfElements;
  1412. } CHANGER_ELEMENT_LIST , *PCHANGER_ELEMENT_LIST;
  1413. //
  1414. // Definitions for IOCTL_CHANGER_GET_PARAMETERS
  1415. //
  1416. //
  1417. // Definitions for Features0 of GET_CHANGER_PARAMETERS
  1418. //
  1419. #define CHANGER_BAR_CODE_SCANNER_INSTALLED 0x00000001 // The medium-changer has a bar code scanner installed.
  1420. #define CHANGER_INIT_ELEM_STAT_WITH_RANGE 0x00000002 // The medium-changer has the ability to initialize elements within a specified range.
  1421. #define CHANGER_CLOSE_IEPORT 0x00000004 // The medium-changer has the ability to close the i/e port door.
  1422. #define CHANGER_OPEN_IEPORT 0x00000008 // The medium-changer can open the i/e port door.
  1423. #define CHANGER_STATUS_NON_VOLATILE 0x00000010 // The medium-changer uses non-volatile memory for element status information.
  1424. #define CHANGER_EXCHANGE_MEDIA 0x00000020 // The medium-changer supports exchange operations.
  1425. #define CHANGER_CLEANER_SLOT 0x00000040 // The medium-changer has a fixed slot designated for cleaner cartridges.
  1426. #define CHANGER_LOCK_UNLOCK 0x00000080 // The medium-changer can be (un)secured to (allow)prevent media removal.
  1427. #define CHANGER_CARTRIDGE_MAGAZINE 0x00000100 // The medium-changer uses cartridge magazines for some storage slots.
  1428. #define CHANGER_MEDIUM_FLIP 0x00000200 // The medium-changer can flip medium.
  1429. #define CHANGER_POSITION_TO_ELEMENT 0x00000400 // The medium-changer can position the transport to a particular element.
  1430. #define CHANGER_REPORT_IEPORT_STATE 0x00000800 // The medium-changer can determine whether media is present
  1431. // in the IE Port.
  1432. #define CHANGER_STORAGE_DRIVE 0x00001000 // The medium-changer can use a drive as an independent storage element.
  1433. #define CHANGER_STORAGE_IEPORT 0x00002000 // The medium-changer can use a i/e port as an independent storage element.
  1434. #define CHANGER_STORAGE_SLOT 0x00004000 // The medium-changer can use a slot as an independent storage element.
  1435. #define CHANGER_STORAGE_TRANSPORT 0x00008000 // The medium-changer can use a transport as an independent storage element.
  1436. #define CHANGER_DRIVE_CLEANING_REQUIRED 0x00010000 // The drives controlled by the medium changer require periodic cleaning
  1437. // initiated by an application.
  1438. #define CHANGER_PREDISMOUNT_EJECT_REQUIRED 0x00020000 // The medium-changer requires a drive eject command to be issued, before a changer
  1439. // move / exchange command can be issued to the drive.
  1440. #define CHANGER_CLEANER_ACCESS_NOT_VALID 0x00040000 // The access bit in GES isn't valid for cleaner cartridges.
  1441. #define CHANGER_PREMOUNT_EJECT_REQUIRED 0x00080000 // The medium-changer requires a drive eject command to be issued
  1442. // before a move / exchange command can be issued with the drive as src/dst.
  1443. #define CHANGER_VOLUME_IDENTIFICATION 0x00100000 // The medium-changer supports volume identification.
  1444. #define CHANGER_VOLUME_SEARCH 0x00200000 // The medium-changer can search for volume information.
  1445. #define CHANGER_VOLUME_ASSERT 0x00400000 // The medium-changer can verify volume information.
  1446. #define CHANGER_VOLUME_REPLACE 0x00800000 // The medium-changer can replace volume information.
  1447. #define CHANGER_VOLUME_UNDEFINE 0x01000000 // The medium-changer can undefine volume information.
  1448. #define CHANGER_SERIAL_NUMBER_VALID 0x04000000 // The serial number reported in GetProductData is valid
  1449. // and unique.
  1450. #define CHANGER_DEVICE_REINITIALIZE_CAPABLE 0x08000000 // The medium-changer can be issued a ChangerReinitializeUnit.
  1451. #define CHANGER_KEYPAD_ENABLE_DISABLE 0x10000000 // Indicates that the keypad can be enabled/disabled.
  1452. #define CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS 0x20000000 // Drives must be empty before access via the door is possible.
  1453. #define CHANGER_RESERVED_BIT 0x80000000 // Will be used to indicate Features1 capability bits.
  1454. //
  1455. // Definitions for Features1 of GET_CHANGER_PARAMETERS
  1456. //
  1457. #define CHANGER_PREDISMOUNT_ALIGN_TO_SLOT 0x80000001 // The transport must be prepositioned to the slot prior to ejecting the media.
  1458. #define CHANGER_PREDISMOUNT_ALIGN_TO_DRIVE 0x80000002 // The transport must be prepositioned to the drive prior to ejecting the media.
  1459. #define CHANGER_CLEANER_AUTODISMOUNT 0x80000004 // The device will move the cleaner cartridge back into the slot when cleaning has completed.
  1460. #define CHANGER_TRUE_EXCHANGE_CAPABLE 0x80000008 // Device can do src -> dest2 exchanges.
  1461. #define CHANGER_SLOTS_USE_TRAYS 0x80000010 // Slots have removable trays, requiring multiple moves for inject/eject.
  1462. #define CHANGER_RTN_MEDIA_TO_ORIGINAL_ADDR 0x80000020 // Media must be returned to the slot from which it originated after a move to another element.
  1463. #define CHANGER_CLEANER_OPS_NOT_SUPPORTED 0x80000040 // Automated cleaning operations are not supported on this device.
  1464. #define CHANGER_IEPORT_USER_CONTROL_OPEN 0x80000080 // Indicates that user action is necessary to open a closed ieport.
  1465. #define CHANGER_IEPORT_USER_CONTROL_CLOSE 0x80000100 // Indicates that user action is necessary to close an opened ieport.
  1466. #define CHANGER_MOVE_EXTENDS_IEPORT 0x80000200 // Indicates that a move media to the ieport extends the tray.
  1467. #define CHANGER_MOVE_RETRACTS_IEPORT 0x80000400 // Indicates that a move media from the ieport retracts the tray.
  1468. //
  1469. // Definitions for MoveFrom, ExchangeFrom, and PositionCapabilities
  1470. //
  1471. #define CHANGER_TO_TRANSPORT 0x01 // The device can carry out the operation to a transport from the specified element.
  1472. #define CHANGER_TO_SLOT 0x02 // The device can carry out the operation to a slot from the specified element.
  1473. #define CHANGER_TO_IEPORT 0x04 // The device can carry out the operation to an IE Port from the specified element.
  1474. #define CHANGER_TO_DRIVE 0x08 // The device can carry out the operation to a drive from the specified element.
  1475. //
  1476. // Definitions for LockUnlockCapabilities
  1477. //
  1478. #define LOCK_UNLOCK_IEPORT 0x01 // The device can lock/unlock the ieport(s).
  1479. #define LOCK_UNLOCK_DOOR 0x02 // The device can lock/unlock the door(s).
  1480. #define LOCK_UNLOCK_KEYPAD 0x04 // The device can lock/unlock the keypad.
  1481. typedef struct _GET_CHANGER_PARAMETERS {
  1482. //
  1483. // Size of the structure. Can be used for versioning.
  1484. //
  1485. DWORD Size;
  1486. //
  1487. // Number of N element(s) as defined by the Element Address Page (or equivalent...).
  1488. //
  1489. WORD NumberTransportElements;
  1490. WORD NumberStorageElements; // for data cartridges only
  1491. WORD NumberCleanerSlots; // for cleaner cartridges
  1492. WORD NumberIEElements;
  1493. WORD NumberDataTransferElements;
  1494. //
  1495. // Number of doors/front panels (allows user entry into the cabinet).
  1496. //
  1497. WORD NumberOfDoors;
  1498. //
  1499. // The device-specific address (from user manual of the device) of the first N element. Used
  1500. // by the UI to relate the various elements to the user.
  1501. //
  1502. WORD FirstSlotNumber;
  1503. WORD FirstDriveNumber;
  1504. WORD FirstTransportNumber;
  1505. WORD FirstIEPortNumber;
  1506. WORD FirstCleanerSlotAddress;
  1507. //
  1508. // Indicates the capacity of each magazine, if they exist.
  1509. //
  1510. WORD MagazineSize;
  1511. //
  1512. // Specifies the approximate number of seconds for when a cleaning should be completed.
  1513. // Only applicable if drive cleaning is supported. See Features0.
  1514. //
  1515. DWORD DriveCleanTimeout;
  1516. //
  1517. // See features bits, above.
  1518. //
  1519. DWORD Features0;
  1520. DWORD Features1;
  1521. //
  1522. // Bitmask defining Move from N element to element. Defined by Device Capabilities Page (or equivalent).
  1523. // AND-masking with the TO_XXX values will indicate legal destinations.
  1524. //
  1525. BYTE MoveFromTransport;
  1526. BYTE MoveFromSlot;
  1527. BYTE MoveFromIePort;
  1528. BYTE MoveFromDrive;
  1529. //
  1530. // Bitmask defining Exchange from N element to element. Defined by Device Capabilities Page (or equivalent).
  1531. // AND-masking with the TO_XXX values will indicate legal destinations.
  1532. //
  1533. BYTE ExchangeFromTransport;
  1534. BYTE ExchangeFromSlot;
  1535. BYTE ExchangeFromIePort;
  1536. BYTE ExchangeFromDrive;
  1537. //
  1538. // Bitmask defining which elements are capable of lock/unlock. Valid only if
  1539. // CHANGER_LOCK_UNLOCK is set in Features0.
  1540. //
  1541. BYTE LockUnlockCapabilities;
  1542. //
  1543. // Bitmask defining which elements valid for positioning operations. Valid only if
  1544. // CHANGER_POSITION_TO_ELEMENT is set in Features0.
  1545. //
  1546. BYTE PositionCapabilities;
  1547. //
  1548. // For future expansion.
  1549. //
  1550. BYTE Reserved1[2];
  1551. DWORD Reserved2[2];
  1552. } GET_CHANGER_PARAMETERS, * PGET_CHANGER_PARAMETERS;
  1553. //
  1554. // Definitions for IOCTL_CHANGER_GET_PRODUCT_DATA
  1555. //
  1556. typedef struct _CHANGER_PRODUCT_DATA {
  1557. //
  1558. // Device manufacturer's name - based on inquiry data
  1559. //
  1560. BYTE VendorId[VENDOR_ID_LENGTH];
  1561. //
  1562. // Product identification as defined by the vendor - based on Inquiry data
  1563. //
  1564. BYTE ProductId[PRODUCT_ID_LENGTH];
  1565. //
  1566. // Product revision as defined by the vendor.
  1567. //
  1568. BYTE Revision[REVISION_LENGTH];
  1569. //
  1570. // Vendor unique value used to globally identify this device. Can
  1571. // be from Vital Product Data, for example.
  1572. //
  1573. BYTE SerialNumber[SERIAL_NUMBER_LENGTH];
  1574. //
  1575. // Indicates device type of data transports, as defined by SCSI-2.
  1576. //
  1577. BYTE DeviceType;
  1578. } CHANGER_PRODUCT_DATA, *PCHANGER_PRODUCT_DATA;
  1579. //
  1580. // Definitions for IOCTL_CHANGER_SET_ACCESS
  1581. //
  1582. #define LOCK_ELEMENT 0
  1583. #define UNLOCK_ELEMENT 1
  1584. #define EXTEND_IEPORT 2
  1585. #define RETRACT_IEPORT 3
  1586. typedef struct _CHANGER_SET_ACCESS {
  1587. //
  1588. // Element can be ChangerIEPort, ChangerDoor, ChangerKeypad
  1589. //
  1590. CHANGER_ELEMENT Element;
  1591. //
  1592. // See above for possible operations.
  1593. //
  1594. DWORD Control;
  1595. } CHANGER_SET_ACCESS, *PCHANGER_SET_ACCESS;
  1596. //
  1597. // Definitions for IOCTL_CHANGER_GET_ELEMENT_STATUS
  1598. //
  1599. //
  1600. // Input buffer.
  1601. //
  1602. typedef struct _CHANGER_READ_ELEMENT_STATUS {
  1603. //
  1604. // List describing the elements and range on which to return information.
  1605. //
  1606. CHANGER_ELEMENT_LIST ElementList;
  1607. //
  1608. // Indicates whether volume tag information is to be returned.
  1609. //
  1610. BOOLEAN VolumeTagInfo;
  1611. } CHANGER_READ_ELEMENT_STATUS, *PCHANGER_READ_ELEMENT_STATUS;
  1612. //
  1613. // Output buffer.
  1614. //
  1615. typedef struct _CHANGER_ELEMENT_STATUS {
  1616. //
  1617. // Element to which this structure refers.
  1618. //
  1619. CHANGER_ELEMENT Element;
  1620. //
  1621. // Address of the element from which the media was originally moved.
  1622. // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
  1623. // Needs to be converted to a zero-based offset from the device-unique value.
  1624. //
  1625. CHANGER_ELEMENT SrcElementAddress;
  1626. //
  1627. // See below.
  1628. //
  1629. DWORD Flags;
  1630. //
  1631. // See below for possible values.
  1632. //
  1633. DWORD ExceptionCode;
  1634. //
  1635. // Scsi Target Id of this element.
  1636. // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
  1637. //
  1638. BYTE TargetId;
  1639. //
  1640. // LogicalUnitNumber of this element.
  1641. // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
  1642. //
  1643. BYTE Lun;
  1644. WORD Reserved;
  1645. //
  1646. // Primary volume identification for the media.
  1647. // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
  1648. //
  1649. BYTE PrimaryVolumeID[MAX_VOLUME_ID_SIZE];
  1650. //
  1651. // Alternate volume identification for the media.
  1652. // Valid for two-sided media only, and pertains to the id. of the inverted side.
  1653. // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
  1654. //
  1655. BYTE AlternateVolumeID[MAX_VOLUME_ID_SIZE];
  1656. } CHANGER_ELEMENT_STATUS, *PCHANGER_ELEMENT_STATUS;
  1657. //
  1658. // Output buffer. This is same as CHANGER_ELEMENT_STATUS with
  1659. // the addition of product info fields. New applications should
  1660. // use this struct instead of the older CHANGER_ELEMENT_STATUS
  1661. //
  1662. typedef struct _CHANGER_ELEMENT_STATUS_EX {
  1663. //
  1664. // Element to which this structure refers.
  1665. //
  1666. CHANGER_ELEMENT Element;
  1667. //
  1668. // Address of the element from which the media was originally moved.
  1669. // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
  1670. // Needs to be converted to a zero-based offset from the device-unique value.
  1671. //
  1672. CHANGER_ELEMENT SrcElementAddress;
  1673. //
  1674. // See below.
  1675. //
  1676. DWORD Flags;
  1677. //
  1678. // See below for possible values.
  1679. //
  1680. DWORD ExceptionCode;
  1681. //
  1682. // Scsi Target Id of this element.
  1683. // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
  1684. //
  1685. BYTE TargetId;
  1686. //
  1687. // LogicalUnitNumber of this element.
  1688. // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
  1689. //
  1690. BYTE Lun;
  1691. WORD Reserved;
  1692. //
  1693. // Primary volume identification for the media.
  1694. // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
  1695. //
  1696. BYTE PrimaryVolumeID[MAX_VOLUME_ID_SIZE];
  1697. //
  1698. // Alternate volume identification for the media.
  1699. // Valid for two-sided media only, and pertains to the id. of the inverted side.
  1700. // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
  1701. //
  1702. BYTE AlternateVolumeID[MAX_VOLUME_ID_SIZE];
  1703. //
  1704. // Vendor ID
  1705. //
  1706. BYTE VendorIdentification[VENDOR_ID_LENGTH];
  1707. //
  1708. // Product ID
  1709. //
  1710. BYTE ProductIdentification[PRODUCT_ID_LENGTH];
  1711. //
  1712. // Serial number
  1713. //
  1714. BYTE SerialNumber[SERIAL_NUMBER_LENGTH];
  1715. } CHANGER_ELEMENT_STATUS_EX, *PCHANGER_ELEMENT_STATUS_EX;
  1716. //
  1717. // Possible flag values
  1718. //
  1719. #define ELEMENT_STATUS_FULL 0x00000001 // Element contains a unit of media.
  1720. #define ELEMENT_STATUS_IMPEXP 0x00000002 // Media in i/e port was placed there by an operator.
  1721. #define ELEMENT_STATUS_EXCEPT 0x00000004 // Element is in an abnormal state; check ExceptionCode field for more information.
  1722. #define ELEMENT_STATUS_ACCESS 0x00000008 // Access to the i/e port from the medium changer is allowed.
  1723. #define ELEMENT_STATUS_EXENAB 0x00000010 // Export of media is supported.
  1724. #define ELEMENT_STATUS_INENAB 0x00000020 // Import of media is supported.
  1725. #define ELEMENT_STATUS_PRODUCT_DATA 0x00000040 // Serial number valid for the drive
  1726. #define ELEMENT_STATUS_LUN_VALID 0x00001000 // Lun information is valid.
  1727. #define ELEMENT_STATUS_ID_VALID 0x00002000 // SCSI Id information is valid.
  1728. #define ELEMENT_STATUS_NOT_BUS 0x00008000 // Lun and SCSI Id fields are not on same bus as medium changer.
  1729. #define ELEMENT_STATUS_INVERT 0x00400000 // Media in element was inverted (valid only if ELEMENT_STATUS_SVALID bit is set)
  1730. #define ELEMENT_STATUS_SVALID 0x00800000 // SourceElementAddress field and ELEMENT_STATUS_INVERT bit are valid.
  1731. #define ELEMENT_STATUS_PVOLTAG 0x10000000 // Primary volume information is valid.
  1732. #define ELEMENT_STATUS_AVOLTAG 0x20000000 // Alternate volume information is valid.
  1733. //
  1734. // ExceptionCode values.
  1735. //
  1736. #define ERROR_LABEL_UNREADABLE 0x00000001 // Bar code scanner could not read bar code label.
  1737. #define ERROR_LABEL_QUESTIONABLE 0x00000002 // Label could be invalid due to unit attention condition.
  1738. #define ERROR_SLOT_NOT_PRESENT 0x00000004 // Slot is currently not addressable in the device.
  1739. #define ERROR_DRIVE_NOT_INSTALLED 0x00000008 // Drive is not installed.
  1740. #define ERROR_TRAY_MALFUNCTION 0x00000010 // Media tray is malfunctioning/broken.
  1741. #define ERROR_INIT_STATUS_NEEDED 0x00000011 // An Initialize Element Status command is needed.
  1742. #define ERROR_UNHANDLED_ERROR 0xFFFFFFFF // Unknown error condition
  1743. //
  1744. // Definitions for IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS
  1745. //
  1746. typedef struct _CHANGER_INITIALIZE_ELEMENT_STATUS {
  1747. //
  1748. // List describing the elements and range on which to initialize.
  1749. //
  1750. CHANGER_ELEMENT_LIST ElementList;
  1751. //
  1752. // Indicates whether a bar code scan should be used. Only applicable if
  1753. // CHANGER_BAR_CODE_SCANNER_INSTALLED is set in Features0 of CHANGER_GET_PARAMETERS.
  1754. //
  1755. BOOLEAN BarCodeScan;
  1756. } CHANGER_INITIALIZE_ELEMENT_STATUS, *PCHANGER_INITIALIZE_ELEMENT_STATUS;
  1757. //
  1758. // Definitions for IOCTL_CHANGER_SET_POSITION
  1759. //
  1760. typedef struct _CHANGER_SET_POSITION {
  1761. //
  1762. // Indicates which transport to move.
  1763. //
  1764. CHANGER_ELEMENT Transport;
  1765. //
  1766. // Indicates the final destination of the transport.
  1767. //
  1768. CHANGER_ELEMENT Destination;
  1769. //
  1770. // Indicates whether the media currently carried by Transport, should be flipped.
  1771. //
  1772. BOOLEAN Flip;
  1773. } CHANGER_SET_POSITION, *PCHANGER_SET_POSITION;
  1774. //
  1775. // Definitions for IOCTL_CHANGER_EXCHANGE_MEDIUM
  1776. //
  1777. typedef struct _CHANGER_EXCHANGE_MEDIUM {
  1778. //
  1779. // Indicates which transport to use for the exchange operation.
  1780. //
  1781. CHANGER_ELEMENT Transport;
  1782. //
  1783. // Indicates the source for the media that is to be moved.
  1784. //
  1785. CHANGER_ELEMENT Source;
  1786. //
  1787. // Indicates the final destination of the media originally at Source.
  1788. //
  1789. CHANGER_ELEMENT Destination1;
  1790. //
  1791. // Indicates the destination of the media moved from Destination1.
  1792. //
  1793. CHANGER_ELEMENT Destination2;
  1794. //
  1795. // Indicates whether the medium should be flipped.
  1796. //
  1797. BOOLEAN Flip1;
  1798. BOOLEAN Flip2;
  1799. } CHANGER_EXCHANGE_MEDIUM, *PCHANGER_EXCHANGE_MEDIUM;
  1800. //
  1801. // Definitions for IOCTL_CHANGER_MOVE_MEDIUM
  1802. //
  1803. typedef struct _CHANGER_MOVE_MEDIUM {
  1804. //
  1805. // Indicates which transport to use for the move operation.
  1806. //
  1807. CHANGER_ELEMENT Transport;
  1808. //
  1809. // Indicates the source for the media that is to be moved.
  1810. //
  1811. CHANGER_ELEMENT Source;
  1812. //
  1813. // Indicates the destination of the media originally at Source.
  1814. //
  1815. CHANGER_ELEMENT Destination;
  1816. //
  1817. // Indicates whether the media should be flipped.
  1818. //
  1819. BOOLEAN Flip;
  1820. } CHANGER_MOVE_MEDIUM, *PCHANGER_MOVE_MEDIUM;
  1821. //
  1822. // Definitions for IOCTL_QUERY_VOLUME_TAGS
  1823. //
  1824. //
  1825. // Input buffer.
  1826. //
  1827. typedef struct _CHANGER_SEND_VOLUME_TAG_INFORMATION {
  1828. //
  1829. // Describes the starting element for which to return information.
  1830. //
  1831. CHANGER_ELEMENT StartingElement;
  1832. //
  1833. // Indicates the specific action to perform. See below.
  1834. //
  1835. DWORD ActionCode;
  1836. //
  1837. // Template used by the device to search for volume ids.
  1838. //
  1839. BYTE VolumeIDTemplate[MAX_VOLUME_TEMPLATE_SIZE];
  1840. } CHANGER_SEND_VOLUME_TAG_INFORMATION, *PCHANGER_SEND_VOLUME_TAG_INFORMATION;
  1841. //
  1842. // Output buffer.
  1843. //
  1844. typedef struct _READ_ELEMENT_ADDRESS_INFO {
  1845. //
  1846. // Number of elements matching criteria set forth by ActionCode.
  1847. //
  1848. DWORD NumberOfElements;
  1849. //
  1850. // Array of CHANGER_ELEMENT_STATUS structures, one for each element that corresponded
  1851. // with the information passed in with the CHANGER_SEND_VOLUME_TAG_INFORMATION structure.
  1852. //
  1853. CHANGER_ELEMENT_STATUS ElementStatus[1];
  1854. } READ_ELEMENT_ADDRESS_INFO, *PREAD_ELEMENT_ADDRESS_INFO;
  1855. //
  1856. // Possible ActionCode values. See Features0 of CHANGER_GET_PARAMETERS for compatibility with
  1857. // the current device.
  1858. //
  1859. #define SEARCH_ALL 0x0 // Translate - search all defined volume tags.
  1860. #define SEARCH_PRIMARY 0x1 // Translate - search only primary volume tags.
  1861. #define SEARCH_ALTERNATE 0x2 // Translate - search only alternate volume tags.
  1862. #define SEARCH_ALL_NO_SEQ 0x4 // Translate - search all defined volume tags but ignore sequence numbers.
  1863. #define SEARCH_PRI_NO_SEQ 0x5 // Translate - search only primary volume tags but ignore sequence numbers.
  1864. #define SEARCH_ALT_NO_SEQ 0x6 // Translate - search only alternate volume tags but ignore sequence numbers.
  1865. #define ASSERT_PRIMARY 0x8 // Assert - as the primary volume tag - if tag now undefined.
  1866. #define ASSERT_ALTERNATE 0x9 // Assert - as the alternate volume tag - if tag now undefined.
  1867. #define REPLACE_PRIMARY 0xA // Replace - the primary volume tag - current tag ignored.
  1868. #define REPLACE_ALTERNATE 0xB // Replace - the alternate volume tag - current tag ignored.
  1869. #define UNDEFINE_PRIMARY 0xC // Undefine - the primary volume tag - current tag ignored.
  1870. #define UNDEFINE_ALTERNATE 0xD // Undefine - the alternate volume tag - current tag ignored.
  1871. //
  1872. // Changer diagnostic test related definitions
  1873. //
  1874. typedef enum _CHANGER_DEVICE_PROBLEM_TYPE {
  1875. DeviceProblemNone,
  1876. DeviceProblemHardware,
  1877. DeviceProblemCHMError,
  1878. DeviceProblemDoorOpen,
  1879. DeviceProblemCalibrationError,
  1880. DeviceProblemTargetFailure,
  1881. DeviceProblemCHMMoveError,
  1882. DeviceProblemCHMZeroError,
  1883. DeviceProblemCartridgeInsertError,
  1884. DeviceProblemPositionError,
  1885. DeviceProblemSensorError,
  1886. DeviceProblemCartridgeEjectError,
  1887. DeviceProblemGripperError,
  1888. DeviceProblemDriveError
  1889. } CHANGER_DEVICE_PROBLEM_TYPE, *PCHANGER_DEVICE_PROBLEM_TYPE;
  1890. #define IOCTL_SERIAL_LSRMST_INSERT CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1891. #define IOCTL_SERENUM_EXPOSE_HARDWARE CTL_CODE(FILE_DEVICE_SERENUM,128,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1892. #define IOCTL_SERENUM_REMOVE_HARDWARE CTL_CODE(FILE_DEVICE_SERENUM,129,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1893. #define IOCTL_SERENUM_PORT_DESC CTL_CODE(FILE_DEVICE_SERENUM,130,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1894. #define IOCTL_SERENUM_GET_PORT_NAME CTL_CODE(FILE_DEVICE_SERENUM,131,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1895. //
  1896. // The following values follow the escape designator in the
  1897. // data stream if the LSRMST_INSERT mode has been turned on.
  1898. //
  1899. #define SERIAL_LSRMST_ESCAPE ((BYTE )0x00)
  1900. //
  1901. // Following this value is the contents of the line status
  1902. // register, and then the character in the RX hardware when
  1903. // the line status register was encountered.
  1904. //
  1905. #define SERIAL_LSRMST_LSR_DATA ((BYTE )0x01)
  1906. //
  1907. // Following this value is the contents of the line status
  1908. // register. No error character follows
  1909. //
  1910. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  1911. //
  1912. // Following this value is the contents of the modem status
  1913. // register.
  1914. //
  1915. #define SERIAL_LSRMST_MST ((BYTE )0x03)
  1916. //
  1917. // Bit values for FIFO Control Register
  1918. //
  1919. #define SERIAL_IOC_FCR_FIFO_ENABLE ((DWORD)0x00000001)
  1920. #define SERIAL_IOC_FCR_RCVR_RESET ((DWORD)0x00000002)
  1921. #define SERIAL_IOC_FCR_XMIT_RESET ((DWORD)0x00000004)
  1922. #define SERIAL_IOC_FCR_DMA_MODE ((DWORD)0x00000008)
  1923. #define SERIAL_IOC_FCR_RES1 ((DWORD)0x00000010)
  1924. #define SERIAL_IOC_FCR_RES2 ((DWORD)0x00000020)
  1925. #define SERIAL_IOC_FCR_RCVR_TRIGGER_LSB ((DWORD)0x00000040)
  1926. #define SERIAL_IOC_FCR_RCVR_TRIGGER_MSB ((DWORD)0x00000080)
  1927. //
  1928. // Bit values for Modem Control Register
  1929. //
  1930. #define SERIAL_IOC_MCR_DTR ((DWORD)0x00000001)
  1931. #define SERIAL_IOC_MCR_RTS ((DWORD)0x00000002)
  1932. #define SERIAL_IOC_MCR_OUT1 ((DWORD)0x00000004)
  1933. #define SERIAL_IOC_MCR_OUT2 ((DWORD)0x00000008)
  1934. #define SERIAL_IOC_MCR_LOOP ((DWORD)0x00000010)
  1935. #ifndef _FILESYSTEMFSCTL_
  1936. #define _FILESYSTEMFSCTL_
  1937. //
  1938. // The following is a list of the native file system fsctls followed by
  1939. // additional network file system fsctls. Some values have been
  1940. // decommissioned.
  1941. //
  1942. #define FSCTL_REQUEST_OPLOCK_LEVEL_1 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1943. #define FSCTL_REQUEST_OPLOCK_LEVEL_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1944. #define FSCTL_REQUEST_BATCH_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1945. #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1946. #define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1947. #define FSCTL_OPLOCK_BREAK_NOTIFY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1948. #define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1949. #define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1950. #define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1951. // decommissioned fsctl value 9
  1952. #define FSCTL_IS_VOLUME_MOUNTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1953. #define FSCTL_IS_PATHNAME_VALID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) // PATHNAME_BUFFER,
  1954. #define FSCTL_MARK_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1955. // decommissioned fsctl value 13
  1956. #define FSCTL_QUERY_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS)
  1957. #define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1958. #define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  1959. // decommissioned fsctl value 17
  1960. // decommissioned fsctl value 18
  1961. #define FSCTL_MARK_AS_SYSTEM_HIVE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS)
  1962. #define FSCTL_OPLOCK_BREAK_ACK_NO_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1963. #define FSCTL_INVALIDATE_VOLUMES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1964. #define FSCTL_QUERY_FAT_BPB CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) // FSCTL_QUERY_FAT_BPB_BUFFER
  1965. #define FSCTL_REQUEST_FILTER_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1966. #define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILESYSTEM_STATISTICS
  1967. #if(_WIN32_WINNT >= 0x0400)
  1968. #define FSCTL_GET_NTFS_VOLUME_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS) // NTFS_VOLUME_DATA_BUFFER
  1969. #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
  1970. #define FSCTL_GET_VOLUME_BITMAP CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_LCN_INPUT_BUFFER, VOLUME_BITMAP_BUFFER
  1971. #define FSCTL_GET_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER
  1972. #define FSCTL_MOVE_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // MOVE_FILE_DATA,
  1973. #define FSCTL_IS_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1974. // decomissioned fsctl value 31
  1975. #define FSCTL_ALLOW_EXTENDED_DASD_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS)
  1976. #endif /* _WIN32_WINNT >= 0x0400 */
  1977. #if(_WIN32_WINNT >= 0x0500)
  1978. // decommissioned fsctl value 33
  1979. // decommissioned fsctl value 34
  1980. #define FSCTL_FIND_FILES_BY_SID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS)
  1981. // decommissioned fsctl value 36
  1982. // decommissioned fsctl value 37
  1983. #define FSCTL_SET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // FILE_OBJECTID_BUFFER
  1984. #define FSCTL_GET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER
  1985. #define FSCTL_DELETE_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1986. #define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER,
  1987. #define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) // REPARSE_DATA_BUFFER
  1988. #define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER,
  1989. #define FSCTL_ENUM_USN_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS) // MFT_ENUM_DATA,
  1990. #define FSCTL_SECURITY_ID_CHECK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, FILE_READ_DATA) // BULK_SECURITY_TEST_DATA,
  1991. #define FSCTL_READ_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS) // READ_USN_JOURNAL_DATA, USN
  1992. #define FSCTL_SET_OBJECT_ID_EXTENDED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1993. #define FSCTL_CREATE_OR_GET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER
  1994. #define FSCTL_SET_SPARSE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1995. #define FSCTL_SET_ZERO_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) // FILE_ZERO_DATA_INFORMATION,
  1996. #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
  1997. // decommissioned fsctl value 52
  1998. #define FSCTL_SET_ENCRYPTION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS) // ENCRYPTION_BUFFER, DECRYPTION_STATUS_BUFFER
  1999. #define FSCTL_ENCRYPTION_FSCTL_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS)
  2000. #define FSCTL_WRITE_RAW_ENCRYPTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS) // ENCRYPTED_DATA_INFO,
  2001. #define FSCTL_READ_RAW_ENCRYPTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS) // REQUEST_RAW_ENCRYPTED_DATA, ENCRYPTED_DATA_INFO
  2002. #define FSCTL_CREATE_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS) // CREATE_USN_JOURNAL_DATA,
  2003. #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
  2004. #define FSCTL_WRITE_USN_CLOSE_RECORD CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS) // Generate Close Usn Record
  2005. #define FSCTL_EXTEND_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2006. #define FSCTL_QUERY_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2007. #define FSCTL_DELETE_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2008. #define FSCTL_MARK_HANDLE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2009. #define FSCTL_SIS_COPYFILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2010. #define FSCTL_SIS_LINK_FILES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  2011. #define FSCTL_HSM_MSG CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 66, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  2012. // decommissioned fsctl value 67
  2013. #define FSCTL_HSM_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 68, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
  2014. #define FSCTL_RECALL_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
  2015. // decommissioned fsctl value 70
  2016. #define FSCTL_READ_FROM_PLEX CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA)
  2017. #define FSCTL_FILE_PREFETCH CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // FILE_PREFETCH
  2018. #endif /* _WIN32_WINNT >= 0x0500 */
  2019. //
  2020. // The following long list of structs are associated with the preceeding
  2021. // file system fsctls.
  2022. //
  2023. //
  2024. // Structure for FSCTL_IS_PATHNAME_VALID
  2025. //
  2026. typedef struct _PATHNAME_BUFFER {
  2027. DWORD PathNameLength;
  2028. WCHAR Name[1];
  2029. } PATHNAME_BUFFER, *PPATHNAME_BUFFER;
  2030. //
  2031. // Structure for FSCTL_QUERY_BPB_INFO
  2032. //
  2033. typedef struct _FSCTL_QUERY_FAT_BPB_BUFFER {
  2034. BYTE First0x24BytesOfBootSector[0x24];
  2035. } FSCTL_QUERY_FAT_BPB_BUFFER, *PFSCTL_QUERY_FAT_BPB_BUFFER;
  2036. #if(_WIN32_WINNT >= 0x0400)
  2037. //
  2038. // Structures for FSCTL_GET_NTFS_VOLUME_DATA.
  2039. // The user must pass the basic buffer below. Ntfs
  2040. // will return as many fields as available in the extended
  2041. // buffer which follows immediately after the VOLUME_DATA_BUFFER.
  2042. //
  2043. typedef struct {
  2044. LARGE_INTEGER VolumeSerialNumber;
  2045. LARGE_INTEGER NumberSectors;
  2046. LARGE_INTEGER TotalClusters;
  2047. LARGE_INTEGER FreeClusters;
  2048. LARGE_INTEGER TotalReserved;
  2049. DWORD BytesPerSector;
  2050. DWORD BytesPerCluster;
  2051. DWORD BytesPerFileRecordSegment;
  2052. DWORD ClustersPerFileRecordSegment;
  2053. LARGE_INTEGER MftValidDataLength;
  2054. LARGE_INTEGER MftStartLcn;
  2055. LARGE_INTEGER Mft2StartLcn;
  2056. LARGE_INTEGER MftZoneStart;
  2057. LARGE_INTEGER MftZoneEnd;
  2058. } NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;
  2059. typedef struct {
  2060. DWORD ByteCount;
  2061. WORD MajorVersion;
  2062. WORD MinorVersion;
  2063. } NTFS_EXTENDED_VOLUME_DATA, *PNTFS_EXTENDED_VOLUME_DATA;
  2064. #endif /* _WIN32_WINNT >= 0x0400 */
  2065. #if(_WIN32_WINNT >= 0x0400)
  2066. //
  2067. // Structure for FSCTL_GET_VOLUME_BITMAP
  2068. //
  2069. typedef struct {
  2070. LARGE_INTEGER StartingLcn;
  2071. } STARTING_LCN_INPUT_BUFFER, *PSTARTING_LCN_INPUT_BUFFER;
  2072. typedef struct {
  2073. LARGE_INTEGER StartingLcn;
  2074. LARGE_INTEGER BitmapSize;
  2075. BYTE Buffer[1];
  2076. } VOLUME_BITMAP_BUFFER, *PVOLUME_BITMAP_BUFFER;
  2077. #endif /* _WIN32_WINNT >= 0x0400 */
  2078. #if(_WIN32_WINNT >= 0x0400)
  2079. //
  2080. // Structure for FSCTL_GET_RETRIEVAL_POINTERS
  2081. //
  2082. typedef struct {
  2083. LARGE_INTEGER StartingVcn;
  2084. } STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER;
  2085. typedef struct RETRIEVAL_POINTERS_BUFFER {
  2086. DWORD ExtentCount;
  2087. LARGE_INTEGER StartingVcn;
  2088. struct {
  2089. LARGE_INTEGER NextVcn;
  2090. LARGE_INTEGER Lcn;
  2091. } Extents[1];
  2092. } RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER;
  2093. #endif /* _WIN32_WINNT >= 0x0400 */
  2094. #if(_WIN32_WINNT >= 0x0400)
  2095. //
  2096. // Structures for FSCTL_GET_NTFS_FILE_RECORD
  2097. //
  2098. typedef struct {
  2099. LARGE_INTEGER FileReferenceNumber;
  2100. } NTFS_FILE_RECORD_INPUT_BUFFER, *PNTFS_FILE_RECORD_INPUT_BUFFER;
  2101. typedef struct {
  2102. LARGE_INTEGER FileReferenceNumber;
  2103. DWORD FileRecordLength;
  2104. BYTE FileRecordBuffer[1];
  2105. } NTFS_FILE_RECORD_OUTPUT_BUFFER, *PNTFS_FILE_RECORD_OUTPUT_BUFFER;
  2106. #endif /* _WIN32_WINNT >= 0x0400 */
  2107. #if(_WIN32_WINNT >= 0x0400)
  2108. //
  2109. // Structure for FSCTL_MOVE_FILE
  2110. //
  2111. typedef struct {
  2112. HANDLE FileHandle;
  2113. LARGE_INTEGER StartingVcn;
  2114. LARGE_INTEGER StartingLcn;
  2115. DWORD ClusterCount;
  2116. } MOVE_FILE_DATA, *PMOVE_FILE_DATA;
  2117. #if defined(_WIN64)
  2118. //
  2119. // 32/64 Bit thunking support structure
  2120. //
  2121. typedef struct _MOVE_FILE_DATA32 {
  2122. UINT32 FileHandle;
  2123. LARGE_INTEGER StartingVcn;
  2124. LARGE_INTEGER StartingLcn;
  2125. DWORD ClusterCount;
  2126. } MOVE_FILE_DATA32, *PMOVE_FILE_DATA32;
  2127. #endif
  2128. #endif /* _WIN32_WINNT >= 0x0400 */
  2129. #if(_WIN32_WINNT >= 0x0500)
  2130. //
  2131. // Structure for FSCTL_FIND_FILES_BY_SID
  2132. //
  2133. typedef struct {
  2134. DWORD Restart;
  2135. SID Sid;
  2136. } FIND_BY_SID_DATA, *PFIND_BY_SID_DATA;
  2137. #endif /* _WIN32_WINNT >= 0x0500 */
  2138. #if(_WIN32_WINNT >= 0x0500)
  2139. //
  2140. // The following structures apply to Usn operations.
  2141. //
  2142. //
  2143. // Structure for FSCTL_ENUM_USN_DATA
  2144. //
  2145. typedef struct {
  2146. DWORDLONG StartFileReferenceNumber;
  2147. USN LowUsn;
  2148. USN HighUsn;
  2149. } MFT_ENUM_DATA, *PMFT_ENUM_DATA;
  2150. //
  2151. // Structure for FSCTL_CREATE_USN_JOURNAL
  2152. //
  2153. typedef struct {
  2154. DWORDLONG MaximumSize;
  2155. DWORDLONG AllocationDelta;
  2156. } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA;
  2157. //
  2158. // Structure for FSCTL_READ_USN_JOURNAL
  2159. //
  2160. typedef struct {
  2161. USN StartUsn;
  2162. DWORD ReasonMask;
  2163. DWORD ReturnOnlyOnClose;
  2164. DWORDLONG Timeout;
  2165. DWORDLONG BytesToWaitFor;
  2166. DWORDLONG UsnJournalID;
  2167. } READ_USN_JOURNAL_DATA, *PREAD_USN_JOURNAL_DATA;
  2168. //
  2169. // The initial Major.Minor version of the Usn record will be 2.0.
  2170. // In general, the MinorVersion may be changed if fields are added
  2171. // to this structure in such a way that the previous version of the
  2172. // software can still correctly the fields it knows about. The
  2173. // MajorVersion should only be changed if the previous version of
  2174. // any software using this structure would incorrectly handle new
  2175. // records due to structure changes.
  2176. //
  2177. // The first update to this will force the structure to version 2.0.
  2178. // This will add the extended information about the source as
  2179. // well as indicate the file name offset within the structure.
  2180. //
  2181. // The following structure is returned with these fsctls.
  2182. //
  2183. // FSCTL_READ_USN_JOURNAL
  2184. // FSCTL_READ_FILE_USN_DATA
  2185. // FSCTL_ENUM_USN_DATA
  2186. //
  2187. typedef struct {
  2188. DWORD RecordLength;
  2189. WORD MajorVersion;
  2190. WORD MinorVersion;
  2191. DWORDLONG FileReferenceNumber;
  2192. DWORDLONG ParentFileReferenceNumber;
  2193. USN Usn;
  2194. LARGE_INTEGER TimeStamp;
  2195. DWORD Reason;
  2196. DWORD SourceInfo;
  2197. DWORD SecurityId;
  2198. DWORD FileAttributes;
  2199. WORD FileNameLength;
  2200. WORD FileNameOffset;
  2201. WCHAR FileName[1];
  2202. } USN_RECORD, *PUSN_RECORD;
  2203. #define USN_PAGE_SIZE (0x1000)
  2204. #define USN_REASON_DATA_OVERWRITE (0x00000001)
  2205. #define USN_REASON_DATA_EXTEND (0x00000002)
  2206. #define USN_REASON_DATA_TRUNCATION (0x00000004)
  2207. #define USN_REASON_NAMED_DATA_OVERWRITE (0x00000010)
  2208. #define USN_REASON_NAMED_DATA_EXTEND (0x00000020)
  2209. #define USN_REASON_NAMED_DATA_TRUNCATION (0x00000040)
  2210. #define USN_REASON_FILE_CREATE (0x00000100)
  2211. #define USN_REASON_FILE_DELETE (0x00000200)
  2212. #define USN_REASON_EA_CHANGE (0x00000400)
  2213. #define USN_REASON_SECURITY_CHANGE (0x00000800)
  2214. #define USN_REASON_RENAME_OLD_NAME (0x00001000)
  2215. #define USN_REASON_RENAME_NEW_NAME (0x00002000)
  2216. #define USN_REASON_INDEXABLE_CHANGE (0x00004000)
  2217. #define USN_REASON_BASIC_INFO_CHANGE (0x00008000)
  2218. #define USN_REASON_HARD_LINK_CHANGE (0x00010000)
  2219. #define USN_REASON_COMPRESSION_CHANGE (0x00020000)
  2220. #define USN_REASON_ENCRYPTION_CHANGE (0x00040000)
  2221. #define USN_REASON_OBJECT_ID_CHANGE (0x00080000)
  2222. #define USN_REASON_REPARSE_POINT_CHANGE (0x00100000)
  2223. #define USN_REASON_STREAM_CHANGE (0x00200000)
  2224. #define USN_REASON_CLOSE (0x80000000)
  2225. //
  2226. // Structure for FSCTL_QUERY_USN_JOUNAL
  2227. //
  2228. typedef struct {
  2229. DWORDLONG UsnJournalID;
  2230. USN FirstUsn;
  2231. USN NextUsn;
  2232. USN LowestValidUsn;
  2233. USN MaxUsn;
  2234. DWORDLONG MaximumSize;
  2235. DWORDLONG AllocationDelta;
  2236. } USN_JOURNAL_DATA, *PUSN_JOURNAL_DATA;
  2237. //
  2238. // Structure for FSCTL_DELETE_USN_JOURNAL
  2239. //
  2240. typedef struct {
  2241. DWORDLONG UsnJournalID;
  2242. DWORD DeleteFlags;
  2243. } DELETE_USN_JOURNAL_DATA, *PDELETE_USN_JOURNAL_DATA;
  2244. #define USN_DELETE_FLAG_DELETE (0x00000001)
  2245. #define USN_DELETE_FLAG_NOTIFY (0x00000002)
  2246. #define USN_DELETE_VALID_FLAGS (0x00000003)
  2247. //
  2248. // Structure for FSCTL_MARK_HANDLE
  2249. //
  2250. typedef struct {
  2251. DWORD UsnSourceInfo;
  2252. HANDLE VolumeHandle;
  2253. DWORD HandleInfo;
  2254. } MARK_HANDLE_INFO, *PMARK_HANDLE_INFO;
  2255. #if defined(_WIN64)
  2256. //
  2257. // 32/64 Bit thunking support structure
  2258. //
  2259. typedef struct {
  2260. DWORD UsnSourceInfo;
  2261. UINT32 VolumeHandle;
  2262. DWORD HandleInfo;
  2263. } MARK_HANDLE_INFO32, *PMARK_HANDLE_INFO32;
  2264. #endif
  2265. //
  2266. // Flags for the additional source information above.
  2267. //
  2268. // USN_SOURCE_DATA_MANAGEMENT - Service is not modifying the external view
  2269. // of any part of the file. Typical case is HSM moving data to
  2270. // and from external storage.
  2271. //
  2272. // USN_SOURCE_AUXILIARY_DATA - Service is not modifying the external view
  2273. // of the file with regard to the application that created this file.
  2274. // Can be used to add private data streams to a file.
  2275. //
  2276. // USN_SOURCE_REPLICATION_MANAGEMENT - Service is modifying a file to match
  2277. // the contents of the same file which exists in another member of the
  2278. // replica set.
  2279. //
  2280. #define USN_SOURCE_DATA_MANAGEMENT (0x00000001)
  2281. #define USN_SOURCE_AUXILIARY_DATA (0x00000002)
  2282. #define USN_SOURCE_REPLICATION_MANAGEMENT (0x00000004)
  2283. //
  2284. // Flags for the HandleInfo field above
  2285. //
  2286. // MARK_HANDLE_PROTECT_CLUSTERS - disallow any defragmenting (FSCTL_MOVE_FILE) until the
  2287. // the handle is closed
  2288. //
  2289. #define MARK_HANDLE_PROTECT_CLUSTERS (0x00000001)
  2290. #endif /* _WIN32_WINNT >= 0x0500 */
  2291. #if(_WIN32_WINNT >= 0x0500)
  2292. //
  2293. // Structure for FSCTL_SECURITY_ID_CHECK
  2294. //
  2295. typedef struct {
  2296. ACCESS_MASK DesiredAccess;
  2297. DWORD SecurityIds[1];
  2298. } BULK_SECURITY_TEST_DATA, *PBULK_SECURITY_TEST_DATA;
  2299. #endif /* _WIN32_WINNT >= 0x0500 */
  2300. #if(_WIN32_WINNT >= 0x0500)
  2301. //
  2302. // Output flags for the FSCTL_IS_VOLUME_DIRTY
  2303. //
  2304. #define VOLUME_IS_DIRTY (0x00000001)
  2305. #define VOLUME_UPGRADE_SCHEDULED (0x00000002)
  2306. #endif /* _WIN32_WINNT >= 0x0500 */
  2307. //
  2308. // Structures for FSCTL_FILE_PREFETCH
  2309. //
  2310. typedef struct _FILE_PREFETCH {
  2311. DWORD Type;
  2312. DWORD Count;
  2313. DWORDLONG Prefetch[1];
  2314. } FILE_PREFETCH, *PFILE_PREFETCH;
  2315. #define FILE_PREFETCH_TYPE_FOR_CREATE 0x1
  2316. // Structures for FSCTL_FILESYSTEM_GET_STATISTICS
  2317. //
  2318. // Filesystem performance counters
  2319. //
  2320. typedef struct _FILESYSTEM_STATISTICS {
  2321. WORD FileSystemType;
  2322. WORD Version; // currently version 1
  2323. DWORD SizeOfCompleteStructure; // must by a mutiple of 64 bytes
  2324. DWORD UserFileReads;
  2325. DWORD UserFileReadBytes;
  2326. DWORD UserDiskReads;
  2327. DWORD UserFileWrites;
  2328. DWORD UserFileWriteBytes;
  2329. DWORD UserDiskWrites;
  2330. DWORD MetaDataReads;
  2331. DWORD MetaDataReadBytes;
  2332. DWORD MetaDataDiskReads;
  2333. DWORD MetaDataWrites;
  2334. DWORD MetaDataWriteBytes;
  2335. DWORD MetaDataDiskWrites;
  2336. //
  2337. // The file system's private structure is appended here.
  2338. //
  2339. } FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS;
  2340. // values for FS_STATISTICS.FileSystemType
  2341. #define FILESYSTEM_STATISTICS_TYPE_NTFS 1
  2342. #define FILESYSTEM_STATISTICS_TYPE_FAT 2
  2343. //
  2344. // File System Specific Statistics Data
  2345. //
  2346. typedef struct _FAT_STATISTICS {
  2347. DWORD CreateHits;
  2348. DWORD SuccessfulCreates;
  2349. DWORD FailedCreates;
  2350. DWORD NonCachedReads;
  2351. DWORD NonCachedReadBytes;
  2352. DWORD NonCachedWrites;
  2353. DWORD NonCachedWriteBytes;
  2354. DWORD NonCachedDiskReads;
  2355. DWORD NonCachedDiskWrites;
  2356. } FAT_STATISTICS, *PFAT_STATISTICS;
  2357. typedef struct _NTFS_STATISTICS {
  2358. DWORD LogFileFullExceptions;
  2359. DWORD OtherExceptions;
  2360. //
  2361. // Other meta data io's
  2362. //
  2363. DWORD MftReads;
  2364. DWORD MftReadBytes;
  2365. DWORD MftWrites;
  2366. DWORD MftWriteBytes;
  2367. struct {
  2368. WORD Write;
  2369. WORD Create;
  2370. WORD SetInfo;
  2371. WORD Flush;
  2372. } MftWritesUserLevel;
  2373. WORD MftWritesFlushForLogFileFull;
  2374. WORD MftWritesLazyWriter;
  2375. WORD MftWritesUserRequest;
  2376. DWORD Mft2Writes;
  2377. DWORD Mft2WriteBytes;
  2378. struct {
  2379. WORD Write;
  2380. WORD Create;
  2381. WORD SetInfo;
  2382. WORD Flush;
  2383. } Mft2WritesUserLevel;
  2384. WORD Mft2WritesFlushForLogFileFull;
  2385. WORD Mft2WritesLazyWriter;
  2386. WORD Mft2WritesUserRequest;
  2387. DWORD RootIndexReads;
  2388. DWORD RootIndexReadBytes;
  2389. DWORD RootIndexWrites;
  2390. DWORD RootIndexWriteBytes;
  2391. DWORD BitmapReads;
  2392. DWORD BitmapReadBytes;
  2393. DWORD BitmapWrites;
  2394. DWORD BitmapWriteBytes;
  2395. WORD BitmapWritesFlushForLogFileFull;
  2396. WORD BitmapWritesLazyWriter;
  2397. WORD BitmapWritesUserRequest;
  2398. struct {
  2399. WORD Write;
  2400. WORD Create;
  2401. WORD SetInfo;
  2402. } BitmapWritesUserLevel;
  2403. DWORD MftBitmapReads;
  2404. DWORD MftBitmapReadBytes;
  2405. DWORD MftBitmapWrites;
  2406. DWORD MftBitmapWriteBytes;
  2407. WORD MftBitmapWritesFlushForLogFileFull;
  2408. WORD MftBitmapWritesLazyWriter;
  2409. WORD MftBitmapWritesUserRequest;
  2410. struct {
  2411. WORD Write;
  2412. WORD Create;
  2413. WORD SetInfo;
  2414. WORD Flush;
  2415. } MftBitmapWritesUserLevel;
  2416. DWORD UserIndexReads;
  2417. DWORD UserIndexReadBytes;
  2418. DWORD UserIndexWrites;
  2419. DWORD UserIndexWriteBytes;
  2420. //
  2421. // Additions for NT 5.0
  2422. //
  2423. DWORD LogFileReads;
  2424. DWORD LogFileReadBytes;
  2425. DWORD LogFileWrites;
  2426. DWORD LogFileWriteBytes;
  2427. struct {
  2428. DWORD Calls; // number of individual calls to allocate clusters
  2429. DWORD Clusters; // number of clusters allocated
  2430. DWORD Hints; // number of times a hint was specified
  2431. DWORD RunsReturned; // number of runs used to satisify all the requests
  2432. DWORD HintsHonored; // number of times the hint was useful
  2433. DWORD HintsClusters; // number of clusters allocated via the hint
  2434. DWORD Cache; // number of times the cache was useful other than the hint
  2435. DWORD CacheClusters; // number of clusters allocated via the cache other than the hint
  2436. DWORD CacheMiss; // number of times the cache wasn't useful
  2437. DWORD CacheMissClusters; // number of clusters allocated without the cache
  2438. } Allocate;
  2439. } NTFS_STATISTICS, *PNTFS_STATISTICS;
  2440. #if(_WIN32_WINNT >= 0x0500)
  2441. //
  2442. // Structure for FSCTL_SET_OBJECT_ID, FSCTL_GET_OBJECT_ID, and FSCTL_CREATE_OR_GET_OBJECT_ID
  2443. //
  2444. #if _MSC_VER >= 1200
  2445. #pragma warning(push)
  2446. #endif
  2447. #pragma warning(disable:4201) // unnamed struct
  2448. typedef struct _FILE_OBJECTID_BUFFER {
  2449. //
  2450. // This is the portion of the object id that is indexed.
  2451. //
  2452. BYTE ObjectId[16];
  2453. //
  2454. // This portion of the object id is not indexed, it's just
  2455. // some metadata for the user's benefit.
  2456. //
  2457. union {
  2458. struct {
  2459. BYTE BirthVolumeId[16];
  2460. BYTE BirthObjectId[16];
  2461. BYTE DomainId[16];
  2462. } ;
  2463. BYTE ExtendedInfo[48];
  2464. };
  2465. } FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER;
  2466. #if _MSC_VER >= 1200
  2467. #pragma warning(pop)
  2468. #else
  2469. #pragma warning( default : 4201 )
  2470. #endif
  2471. #endif /* _WIN32_WINNT >= 0x0500 */
  2472. #if(_WIN32_WINNT >= 0x0500)
  2473. //
  2474. // Structure for FSCTL_SET_SPARSE
  2475. //
  2476. typedef struct _FILE_SET_SPARSE_BUFFER {
  2477. BOOLEAN SetSparse;
  2478. } FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER;
  2479. #endif /* _WIN32_WINNT >= 0x0500 */
  2480. #if(_WIN32_WINNT >= 0x0500)
  2481. //
  2482. // Structure for FSCTL_SET_ZERO_DATA
  2483. //
  2484. typedef struct _FILE_ZERO_DATA_INFORMATION {
  2485. LARGE_INTEGER FileOffset;
  2486. LARGE_INTEGER BeyondFinalZero;
  2487. } FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION;
  2488. #endif /* _WIN32_WINNT >= 0x0500 */
  2489. #if(_WIN32_WINNT >= 0x0500)
  2490. //
  2491. // Structure for FSCTL_QUERY_ALLOCATED_RANGES
  2492. //
  2493. //
  2494. // Querying the allocated ranges requires an output buffer to store the
  2495. // allocated ranges and an input buffer to specify the range to query.
  2496. // The input buffer contains a single entry, the output buffer is an
  2497. // array of the following structure.
  2498. //
  2499. typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
  2500. LARGE_INTEGER FileOffset;
  2501. LARGE_INTEGER Length;
  2502. } FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
  2503. #endif /* _WIN32_WINNT >= 0x0500 */
  2504. #if(_WIN32_WINNT >= 0x0500)
  2505. //
  2506. // Structures for FSCTL_SET_ENCRYPTION, FSCTL_WRITE_RAW_ENCRYPTED, and FSCTL_READ_RAW_ENCRYPTED
  2507. //
  2508. //
  2509. // The input buffer to set encryption indicates whether we are to encrypt/decrypt a file
  2510. // or an individual stream.
  2511. //
  2512. typedef struct _ENCRYPTION_BUFFER {
  2513. DWORD EncryptionOperation;
  2514. BYTE Private[1];
  2515. } ENCRYPTION_BUFFER, *PENCRYPTION_BUFFER;
  2516. #define FILE_SET_ENCRYPTION 0x00000001
  2517. #define FILE_CLEAR_ENCRYPTION 0x00000002
  2518. #define STREAM_SET_ENCRYPTION 0x00000003
  2519. #define STREAM_CLEAR_ENCRYPTION 0x00000004
  2520. #define MAXIMUM_ENCRYPTION_VALUE 0x00000004
  2521. //
  2522. // The optional output buffer to set encryption indicates that the last encrypted
  2523. // stream in a file has been marked as decrypted.
  2524. //
  2525. typedef struct _DECRYPTION_STATUS_BUFFER {
  2526. BOOLEAN NoEncryptedStreams;
  2527. } DECRYPTION_STATUS_BUFFER, *PDECRYPTION_STATUS_BUFFER;
  2528. #define ENCRYPTION_FORMAT_DEFAULT (0x01)
  2529. #define COMPRESSION_FORMAT_SPARSE (0x4000)
  2530. //
  2531. // Request Encrypted Data structure. This is used to indicate
  2532. // the range of the file to read. It also describes the
  2533. // output buffer used to return the data.
  2534. //
  2535. typedef struct _REQUEST_RAW_ENCRYPTED_DATA {
  2536. //
  2537. // Requested file offset and requested length to read.
  2538. // The fsctl will round the starting offset down
  2539. // to a file system boundary. It will also
  2540. // round the length up to a file system boundary.
  2541. //
  2542. LONGLONG FileOffset;
  2543. DWORD Length;
  2544. } REQUEST_RAW_ENCRYPTED_DATA, *PREQUEST_RAW_ENCRYPTED_DATA;
  2545. //
  2546. // Encrypted Data Information structure. This structure
  2547. // is used to return raw encrypted data from a file in
  2548. // order to perform off-line recovery. The data will be
  2549. // encrypted or encrypted and compressed. The off-line
  2550. // service will need to use the encryption and compression
  2551. // format information to recover the file data. In the
  2552. // event that the data is both encrypted and compressed then
  2553. // the decryption must occur before decompression. All
  2554. // the data units below must be encrypted and compressed
  2555. // with the same format.
  2556. //
  2557. // The data will be returned in units. The data unit size
  2558. // will be fixed per request. If the data is compressed
  2559. // then the data unit size will be the compression unit size.
  2560. //
  2561. // This structure is at the beginning of the buffer used to
  2562. // return the encrypted data. The actual raw bytes from
  2563. // the file will follow this buffer. The offset of the
  2564. // raw bytes from the beginning of this structure is
  2565. // specified in the REQUEST_RAW_ENCRYPTED_DATA structure
  2566. // described above.
  2567. //
  2568. typedef struct _ENCRYPTED_DATA_INFO {
  2569. //
  2570. // This is the file offset for the first entry in the
  2571. // data block array. The file system will round
  2572. // the requested start offset down to a boundary
  2573. // that is consistent with the format of the file.
  2574. //
  2575. DWORDLONG StartingFileOffset;
  2576. //
  2577. // Data offset in output buffer. The output buffer
  2578. // begins with an ENCRYPTED_DATA_INFO structure.
  2579. // The file system will then store the raw bytes from
  2580. // disk beginning at the following offset within the
  2581. // output buffer.
  2582. //
  2583. DWORD OutputBufferOffset;
  2584. //
  2585. // The number of bytes being returned that are within
  2586. // the size of the file. If this value is less than
  2587. // (NumberOfDataBlocks << DataUnitShift), it means the
  2588. // end of the file occurs within this transfer. Any
  2589. // data beyond file size is invalid and was never
  2590. // passed to the encryption driver.
  2591. //
  2592. DWORD BytesWithinFileSize;
  2593. //
  2594. // The number of bytes being returned that are below
  2595. // valid data length. If this value is less than
  2596. // (NumberOfDataBlocks << DataUnitShift), it means the
  2597. // end of the valid data occurs within this transfer.
  2598. // After decrypting the data from this transfer, any
  2599. // byte(s) beyond valid data length must be zeroed.
  2600. //
  2601. DWORD BytesWithinValidDataLength;
  2602. //
  2603. // Code for the compression format as defined in
  2604. // ntrtl.h. Note that COMPRESSION_FORMAT_NONE
  2605. // and COMPRESSION_FORMAT_DEFAULT are invalid if
  2606. // any of the described chunks are compressed.
  2607. //
  2608. WORD CompressionFormat;
  2609. //
  2610. // The DataUnit is the granularity used to access the
  2611. // disk. It will be the same as the compression unit
  2612. // size for a compressed file. For an uncompressed
  2613. // file, it will be some cluster-aligned power of 2 that
  2614. // the file system deems convenient. A caller should
  2615. // not expect that successive calls will have the
  2616. // same data unit shift value as the previous call.
  2617. //
  2618. // Since chunks and compression units are expected to be
  2619. // powers of 2 in size, we express them log2. So, for
  2620. // example (1 << ChunkShift) == ChunkSizeInBytes. The
  2621. // ClusterShift indicates how much space must be saved
  2622. // to successfully compress a compression unit - each
  2623. // successfully compressed data unit must occupy
  2624. // at least one cluster less in bytes than an uncompressed
  2625. // data block unit.
  2626. //
  2627. BYTE DataUnitShift;
  2628. BYTE ChunkShift;
  2629. BYTE ClusterShift;
  2630. //
  2631. // The format for the encryption.
  2632. //
  2633. BYTE EncryptionFormat;
  2634. //
  2635. // This is the number of entries in the data block size
  2636. // array.
  2637. //
  2638. WORD NumberOfDataBlocks;
  2639. //
  2640. // This is an array of sizes in the data block array. There
  2641. // must be one entry in this array for each data block
  2642. // read from disk. The size has a different meaning
  2643. // depending on whether the file is compressed.
  2644. //
  2645. // A size of zero always indicates that the final data consists entirely
  2646. // of zeroes. There is no decryption or decompression to
  2647. // perform.
  2648. //
  2649. // If the file is compressed then the data block size indicates
  2650. // whether this block is compressed. A size equal to
  2651. // the block size indicates that the corresponding block did
  2652. // not compress. Any other non-zero size indicates the
  2653. // size of the compressed data which needs to be
  2654. // decrypted/decompressed.
  2655. //
  2656. // If the file is not compressed then the data block size
  2657. // indicates the amount of data within the block that
  2658. // needs to be decrypted. Any other non-zero size indicates
  2659. // that the remaining bytes in the data unit within the file
  2660. // consists of zeros. An example of this is when the
  2661. // the read spans the valid data length of the file. There
  2662. // is no data to decrypt past the valid data length.
  2663. //
  2664. DWORD DataBlockSize[ANYSIZE_ARRAY];
  2665. } ENCRYPTED_DATA_INFO;
  2666. typedef ENCRYPTED_DATA_INFO *PENCRYPTED_DATA_INFO;
  2667. #endif /* _WIN32_WINNT >= 0x0500 */
  2668. #if(_WIN32_WINNT >= 0x0500)
  2669. //
  2670. // FSCTL_READ_FROM_PLEX support
  2671. // Request Plex Read Data structure. This is used to indicate
  2672. // the range of the file to read. It also describes
  2673. // which plex to perform the read from.
  2674. //
  2675. typedef struct _PLEX_READ_DATA_REQUEST {
  2676. //
  2677. // Requested offset and length to read.
  2678. // The offset can be the virtual offset (vbo) in to a file,
  2679. // or a volume. In the case of a file offset,
  2680. // the fsd will round the starting offset down
  2681. // to a file system boundary. It will also
  2682. // round the length up to a file system boundary and
  2683. // enforce any other applicable limits.
  2684. //
  2685. LARGE_INTEGER ByteOffset;
  2686. DWORD ByteLength;
  2687. DWORD PlexNumber;
  2688. } PLEX_READ_DATA_REQUEST, *PPLEX_READ_DATA_REQUEST;
  2689. #endif /* _WIN32_WINNT >= 0x0500 */
  2690. #if(_WIN32_WINNT >= 0x0500)
  2691. //
  2692. // FSCTL_SIS_COPYFILE support
  2693. // Source and destination file names are passed in the FileNameBuffer.
  2694. // Both strings are null terminated, with the source name starting at
  2695. // the beginning of FileNameBuffer, and the destination name immediately
  2696. // following. Length fields include terminating nulls.
  2697. //
  2698. typedef struct _SI_COPYFILE {
  2699. DWORD SourceFileNameLength;
  2700. DWORD DestinationFileNameLength;
  2701. DWORD Flags;
  2702. WCHAR FileNameBuffer[1];
  2703. } SI_COPYFILE, *PSI_COPYFILE;
  2704. #define COPYFILE_SIS_LINK 0x0001 // Copy only if source is SIS
  2705. #define COPYFILE_SIS_REPLACE 0x0002 // Replace destination if it exists, otherwise don't.
  2706. #define COPYFILE_SIS_FLAGS 0x0003
  2707. #endif /* _WIN32_WINNT >= 0x0500 */
  2708. #endif // _FILESYSTEMFSCTL_
  2709. //
  2710. // These IOCTLs are handled by hard disk volumes.
  2711. //
  2712. #define IOCTL_VOLUME_BASE ((DWORD) 'V')
  2713. #define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS CTL_CODE(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2714. #define IOCTL_VOLUME_IS_CLUSTERED CTL_CODE(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2715. //
  2716. // Disk extent definition.
  2717. //
  2718. typedef struct _DISK_EXTENT {
  2719. DWORD DiskNumber;
  2720. LARGE_INTEGER StartingOffset;
  2721. LARGE_INTEGER ExtentLength;
  2722. } DISK_EXTENT, *PDISK_EXTENT;
  2723. //
  2724. // Output structure for IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.
  2725. //
  2726. typedef struct _VOLUME_DISK_EXTENTS {
  2727. DWORD NumberOfDiskExtents;
  2728. DISK_EXTENT Extents[1];
  2729. } VOLUME_DISK_EXTENTS, *PVOLUME_DISK_EXTENTS;
  2730. #endif // _WINIOCTL_