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.

449 lines
16 KiB

  1. /*++ BUILD Version: 0012 // Increment this if a change has global effects
  2. Copyright (c) 1990-1992 Microsoft Corporation
  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. #ifndef _WINIOCTL_
  10. #define _WINIOCTL_
  11. #ifndef _DEVIOCTL_
  12. #define _DEVIOCTL_
  13. // begin_ntddk begin_nthal begin_ntifs
  14. //
  15. // Define the various device type values. Note that values used by Microsoft
  16. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  17. // by customers.
  18. //
  19. #define DEVICE_TYPE DWORD
  20. #define FILE_DEVICE_BEEP 0x00000001
  21. #define FILE_DEVICE_CD_ROM 0x00000002
  22. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
  23. #define FILE_DEVICE_CONTROLLER 0x00000004
  24. #define FILE_DEVICE_DATALINK 0x00000005
  25. #define FILE_DEVICE_DFS 0x00000006
  26. #define FILE_DEVICE_DISK 0x00000007
  27. #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
  28. #define FILE_DEVICE_FILE_SYSTEM 0x00000009
  29. #define FILE_DEVICE_INPORT_PORT 0x0000000a
  30. #define FILE_DEVICE_KEYBOARD 0x0000000b
  31. #define FILE_DEVICE_MAILSLOT 0x0000000c
  32. #define FILE_DEVICE_MIDI_IN 0x0000000d
  33. #define FILE_DEVICE_MIDI_OUT 0x0000000e
  34. #define FILE_DEVICE_MOUSE 0x0000000f
  35. #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
  36. #define FILE_DEVICE_NAMED_PIPE 0x00000011
  37. #define FILE_DEVICE_NETWORK 0x00000012
  38. #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
  39. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  40. #define FILE_DEVICE_NULL 0x00000015
  41. #define FILE_DEVICE_PARALLEL_PORT 0x00000016
  42. #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
  43. #define FILE_DEVICE_PRINTER 0x00000018
  44. #define FILE_DEVICE_SCANNER 0x00000019
  45. #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
  46. #define FILE_DEVICE_SERIAL_PORT 0x0000001b
  47. #define FILE_DEVICE_SCREEN 0x0000001c
  48. #define FILE_DEVICE_SOUND 0x0000001d
  49. #define FILE_DEVICE_STREAMS 0x0000001e
  50. #define FILE_DEVICE_TAPE 0x0000001f
  51. #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
  52. #define FILE_DEVICE_TRANSPORT 0x00000021
  53. #define FILE_DEVICE_UNKNOWN 0x00000022
  54. #define FILE_DEVICE_VIDEO 0x00000023
  55. #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
  56. #define FILE_DEVICE_WAVE_IN 0x00000025
  57. #define FILE_DEVICE_WAVE_OUT 0x00000026
  58. #define FILE_DEVICE_8042_PORT 0x00000027
  59. #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
  60. //
  61. // Macro definition for defining IOCTL and FSCTL function control codes. Note
  62. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  63. // 2048-4095 are reserved for customers.
  64. //
  65. #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
  66. ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  67. )
  68. //
  69. // Define the method codes for how buffers are passed for I/O and FS controls
  70. //
  71. #define METHOD_BUFFERED 0
  72. #define METHOD_IN_DIRECT 1
  73. #define METHOD_OUT_DIRECT 2
  74. #define METHOD_NEITHER 3
  75. //
  76. // Define the access check value for any access
  77. //
  78. //
  79. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  80. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  81. // constants *MUST* always be in sync.
  82. //
  83. #define FILE_ANY_ACCESS 0
  84. #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
  85. #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
  86. // end_ntddk end_nthal end_ntifs
  87. #endif // _DEVIOCTL_
  88. //
  89. // IoControlCode values for disk devices.
  90. //
  91. #define IOCTL_DISK_BASE FILE_DEVICE_DISK
  92. #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  93. #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  94. #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  95. #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  96. #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  97. #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  98. #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  99. #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  100. #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  101. #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  102. #define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  103. //
  104. // The following device control codes are common for all class drivers. The
  105. // functions codes defined here must match all of the other class drivers.
  106. //
  107. #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  108. #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  109. #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  110. #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  111. #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  112. #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  113. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  114. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  115. //
  116. // Define the partition types returnable by known disk drivers.
  117. //
  118. #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
  119. #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
  120. #define PARTITION_XENIX_1 0x02 // Xenix
  121. #define PARTITION_XENIX_2 0x03 // Xenix
  122. #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
  123. #define PARTITION_EXTENDED 0x05 // Extended partition entry
  124. #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
  125. #define PARTITION_IFS 0x07 // IFS Partition
  126. #define PARTITION_UNIX 0x63 // Unix
  127. #define VALID_NTFT 0xC0 // NTFT uses high order bits
  128. //
  129. // The following macro is used to determine which partitions should be
  130. // assigned drive letters.
  131. //
  132. //++
  133. //
  134. // BOOLEAN
  135. // IsRecognizedPartition(
  136. // IN DWORD PartitionType
  137. // )
  138. //
  139. // Routine Description:
  140. //
  141. // This macro is used to determine to which partitions drive letters
  142. // should be assigned.
  143. //
  144. // Arguments:
  145. //
  146. // PartitionType - Supplies the type of the partition being examined.
  147. //
  148. // Return Value:
  149. //
  150. // The return value is TRUE if the partition type is recognized,
  151. // otherwise FALSE is returned.
  152. //
  153. //--
  154. #define IsRecognizedPartition( PartitionType ) ( \
  155. (((PartitionType & ~0xC0) == PARTITION_FAT_12) || \
  156. ((PartitionType & ~0xC0) == PARTITION_FAT_16) || \
  157. ((PartitionType & ~0xC0) == PARTITION_IFS) || \
  158. ((PartitionType & ~0xC0) == PARTITION_HUGE)) )
  159. //
  160. // The high bit of the partition type code indicates that a partition
  161. // is part of an NTFT mirror or striped array.
  162. //
  163. #define PARTITION_NTFT 0x80 // NTFT partition
  164. //
  165. // Define the media types supported by the driver.
  166. //
  167. typedef enum _MEDIA_TYPE {
  168. Unknown, // Format is unknown
  169. F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  170. F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  171. F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  172. F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  173. F3_720_512, // 3.5", 720KB, 512 bytes/sector
  174. F5_360_512, // 5.25", 360KB, 512 bytes/sector
  175. F5_320_512, // 5.25", 320KB, 512 bytes/sector
  176. F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  177. F5_180_512, // 5.25", 180KB, 512 bytes/sector
  178. F5_160_512, // 5.25", 160KB, 512 bytes/sector
  179. RemovableMedia, // Removable media other than floppy
  180. FixedMedia // Fixed hard disk media
  181. } MEDIA_TYPE, *PMEDIA_TYPE;
  182. //
  183. // Define the input buffer structure for the driver, when
  184. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  185. //
  186. typedef struct _FORMAT_PARAMETERS {
  187. MEDIA_TYPE MediaType;
  188. DWORD StartCylinderNumber;
  189. DWORD EndCylinderNumber;
  190. DWORD StartHeadNumber;
  191. DWORD EndHeadNumber;
  192. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  193. //
  194. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  195. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  196. // what tracks were bad during formatting. The length of that array is
  197. // reported in the `Information' field of the I/O Status Block.
  198. //
  199. typedef WORD BAD_TRACK_NUMBER;
  200. typedef WORD *PBAD_TRACK_NUMBER;
  201. //
  202. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  203. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  204. // request.
  205. //
  206. typedef struct _DISK_GEOMETRY {
  207. LARGE_INTEGER Cylinders;
  208. MEDIA_TYPE MediaType;
  209. DWORD TracksPerCylinder;
  210. DWORD SectorsPerTrack;
  211. DWORD BytesPerSector;
  212. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  213. //
  214. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  215. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request. It is also used in a request
  216. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  217. //
  218. typedef struct _PARTITION_INFORMATION {
  219. LARGE_INTEGER StartingOffset;
  220. LARGE_INTEGER PartitionLength;
  221. DWORD HiddenSectors;
  222. DWORD PartitionNumber;
  223. BYTE PartitionType;
  224. BOOLEAN BootIndicator;
  225. BOOLEAN RecognizedPartition;
  226. BOOLEAN RewritePartition;
  227. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  228. //
  229. // The following structure is used to change the partition type of a
  230. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  231. // request.
  232. //
  233. typedef struct _SET_PARTITION_INFORMATION {
  234. BYTE PartitionType;
  235. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  236. //
  237. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  238. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  239. //
  240. typedef struct _DRIVE_LAYOUT_INFORMATION {
  241. DWORD PartitionCount;
  242. DWORD Signature;
  243. PARTITION_INFORMATION PartitionEntry[1];
  244. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  245. //
  246. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  247. // The offset and length parameters are both given in bytes.
  248. //
  249. typedef struct _VERIFY_INFORMATION {
  250. LARGE_INTEGER StartingOffset;
  251. DWORD Length;
  252. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  253. //
  254. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  255. // request.
  256. //
  257. typedef struct _REASSIGN_BLOCKS {
  258. WORD Reserved;
  259. WORD Count;
  260. DWORD BlockNumber[1];
  261. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  262. //
  263. // IOCTL_DISK_MEDIA_REMOVAL disables the mechanism
  264. // on a SCSI device that ejects media. This function
  265. // may or may not be supported on SCSI devices that
  266. // support removable media.
  267. //
  268. // TRUE means prevent media from being removed.
  269. // FALSE means allow media removal.
  270. //
  271. typedef struct _PREVENT_MEDIA_REMOVAL {
  272. BOOLEAN PreventMediaRemoval;
  273. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  274. ///////////////////////////////////////////////////////
  275. // //
  276. // The following structures define disk debugging //
  277. // capabilities. The IOCTLs are directed to one of //
  278. // the two disk filter drivers. //
  279. // //
  280. // DISKPERF is a utilty for collecting disk request //
  281. // statistics. //
  282. // //
  283. // SIMBAD is a utility for injecting faults in //
  284. // IO requests to disks. //
  285. // //
  286. ///////////////////////////////////////////////////////
  287. //
  288. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  289. // request. This ioctl collects summary disk request statistics used
  290. // in measuring performance.
  291. //
  292. typedef struct _DISK_PERFORMANCE {
  293. LARGE_INTEGER BytesRead;
  294. LARGE_INTEGER BytesWritten;
  295. LARGE_INTEGER ReadTime;
  296. LARGE_INTEGER WriteTime;
  297. DWORD ReadCount;
  298. DWORD WriteCount;
  299. DWORD QueueDepth;
  300. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  301. //
  302. // This structure defines the disk logging record. When disk logging
  303. // is enabled, one of these is written to an internal buffer for each
  304. // disk request.
  305. //
  306. typedef struct _DISK_RECORD {
  307. LARGE_INTEGER ByteOffset;
  308. LARGE_INTEGER StartTime;
  309. LARGE_INTEGER EndTime;
  310. DWORD NumberOfBytes;
  311. BYTE DeviceNumber;
  312. BOOLEAN ReadRequest;
  313. } DISK_RECORD, *PDISK_RECORD;
  314. //
  315. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  316. // Not all fields are valid with each function type.
  317. //
  318. typedef struct _DISK_LOGGING {
  319. BYTE Function;
  320. PVOID BufferAddress;
  321. DWORD BufferSize;
  322. } DISK_LOGGING, *PDISK_LOGGING;
  323. //
  324. // Disk logging functions
  325. //
  326. // Start disk logging. Only the Function and BufferSize fields are valid.
  327. //
  328. #define DISK_LOGGING_START 0
  329. //
  330. // Stop disk logging. Only the Function field is valid.
  331. //
  332. #define DISK_LOGGING_STOP 1
  333. //
  334. // Return disk log. All fields are valid. Data will be copied from internal
  335. // buffer to buffer specified for the number of bytes requested.
  336. //
  337. #define DISK_LOGGING_DUMP 2
  338. #define IOCTL_SERIAL_LSRMST_INSERT CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  339. //
  340. // The following values follow the escape designator in the
  341. // data stream if the LSRMST_INSERT mode has been turned on.
  342. //
  343. #define SERIAL_LSRMST_ESCAPE ((BYTE )0x00)
  344. //
  345. // Following this value is the contents of the line status
  346. // register, and then the character in the RX hardware when
  347. // the line status register was encountered.
  348. //
  349. #define SERIAL_LSRMST_LSR_DATA ((BYTE )0x01)
  350. //
  351. // Following this value is the contents of the line status
  352. // register. No error character follows
  353. //
  354. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  355. //
  356. // Following this value is the contents of the modem status
  357. // register.
  358. //
  359. #define SERIAL_LSRMST_MST ((BYTE )0x03)
  360. #define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  361. #define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  362. #define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  363. #define FSCTL_MOUNT_DBLS_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM,13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  364. #define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  365. #define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,16, METHOD_BUFFERED, FILE_ANY_ACCESS)
  366. #define FSCTL_READ_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,17, METHOD_NEITHER, FILE_ANY_ACCESS)
  367. #define FSCTL_WRITE_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,18, METHOD_NEITHER, FILE_ANY_ACCESS)
  368. #endif // _WINIOCTL_