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.

1216 lines
40 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntdddisk.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. accessing the Disk device.
  8. Revision History:
  9. --*/
  10. #ifndef _NTDDDISK_H_
  11. #define _NTDDDISK_H_
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif
  15. #include <diskguid.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. //
  20. // Device Name - this string is the name of the device. It is the name
  21. // that should be passed to NtOpenFile when accessing the device.
  22. //
  23. // Note: For devices that support multiple units, it should be suffixed
  24. // with the Ascii representation of the unit number.
  25. //
  26. #define DD_DISK_DEVICE_NAME "\\Device\\UNKNOWN"
  27. //
  28. // NtDeviceIoControlFile
  29. // begin_winioctl
  30. //
  31. // IoControlCode values for disk devices.
  32. //
  33. #define IOCTL_DISK_BASE FILE_DEVICE_DISK
  34. #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  35. #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  36. #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  37. #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  38. #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  39. #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  40. #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  41. #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  42. #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  43. #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  44. #define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  45. #define IOCTL_DISK_FORMAT_TRACKS_EX CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  46. #define IOCTL_DISK_HISTOGRAM_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  47. #define IOCTL_DISK_HISTOGRAM_DATA CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  48. #define IOCTL_DISK_HISTOGRAM_RESET CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  49. #define IOCTL_DISK_REQUEST_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  50. #define IOCTL_DISK_REQUEST_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  51. #define IOCTL_DISK_PERFORMANCE_OFF CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS)
  52. #if(_WIN32_WINNT >= 0x0400)
  53. #define IOCTL_DISK_CONTROLLER_NUMBER CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  54. //
  55. // IOCTL support for SMART drive fault prediction.
  56. //
  57. #define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  58. #define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  59. #define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  60. #endif /* _WIN32_WINNT >= 0x0400 */
  61. #if (_WIN32_WINNT >= 0x500)
  62. //
  63. // New IOCTLs for GUID Partition tabled disks.
  64. //
  65. #define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
  66. #define IOCTL_DISK_SET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  67. #define IOCTL_DISK_GET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS)
  68. #define IOCTL_DISK_SET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  69. #define IOCTL_DISK_CREATE_DISK CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  70. #define IOCTL_DISK_GET_LENGTH_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS)
  71. #define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS)
  72. #endif /* _WIN32_WINNT >= 0x0500 */
  73. #if(_WIN32_WINNT >= 0x0500)
  74. #define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  75. #define IOCTL_DISK_GROW_PARTITION CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  76. #define IOCTL_DISK_GET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS)
  77. #define IOCTL_DISK_SET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  78. #define IOCTL_DISK_GET_WRITE_CACHE_STATE CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS)
  79. #define IOCTL_DISK_DELETE_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  80. //
  81. // Called to flush cached information that the driver may have about this
  82. // device's characteristics. Not all drivers cache characteristics, and not
  83. // cached properties can be flushed. This simply serves as an update to the
  84. // driver that it may want to do an expensive reexamination of the device's
  85. // characteristics now (fixed media size, partition table, etc...)
  86. //
  87. #define IOCTL_DISK_UPDATE_PROPERTIES CTL_CODE(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS)
  88. //
  89. // Special IOCTLs needed to support PC-98 machines in Japan
  90. //
  91. #define IOCTL_DISK_FORMAT_DRIVE CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  92. #define IOCTL_DISK_SENSE_DEVICE CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  93. #endif /* _WIN32_WINNT >= 0x0500 */
  94. // end_winioctl
  95. //
  96. // Internal disk driver device controls to maintain the verify status bit
  97. // for the device object.
  98. //
  99. #define IOCTL_DISK_INTERNAL_SET_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0100, METHOD_NEITHER, FILE_ANY_ACCESS)
  100. #define IOCTL_DISK_INTERNAL_CLEAR_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0101, METHOD_NEITHER, FILE_ANY_ACCESS)
  101. //
  102. // Internal disk driver device control to set notification routine for
  103. // the device object. Used in DiskPerf.
  104. //
  105. #define IOCTL_DISK_INTERNAL_SET_NOTIFY CTL_CODE(IOCTL_DISK_BASE, 0x0102, METHOD_BUFFERED, FILE_ANY_ACCESS)
  106. // begin_winioctl
  107. //
  108. // The following device control codes are common for all class drivers. The
  109. // functions codes defined here must match all of the other class drivers.
  110. //
  111. // Warning: these codes will be replaced in the future by equivalent
  112. // IOCTL_STORAGE codes
  113. //
  114. #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  115. #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  116. #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  117. #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  118. #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  119. #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  120. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  121. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  122. // end_winioctl
  123. //
  124. // The following file contains the IOCTL_STORAGE class ioctls
  125. //
  126. #include <ntddstor.h>
  127. // begin_winioctl
  128. //
  129. // Define the partition types returnable by known disk drivers.
  130. //
  131. #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
  132. #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
  133. #define PARTITION_XENIX_1 0x02 // Xenix
  134. #define PARTITION_XENIX_2 0x03 // Xenix
  135. #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
  136. #define PARTITION_EXTENDED 0x05 // Extended partition entry
  137. #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
  138. #define PARTITION_IFS 0x07 // IFS Partition
  139. #define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
  140. #define PARTITION_FAT32 0x0B // FAT32
  141. #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
  142. #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
  143. #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
  144. #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
  145. #define PARTITION_LDM 0x42 // Logical Disk Manager partition
  146. #define PARTITION_UNIX 0x63 // Unix
  147. #define VALID_NTFT 0xC0 // NTFT uses high order bits
  148. //
  149. // The high bit of the partition type code indicates that a partition
  150. // is part of an NTFT mirror or striped array.
  151. //
  152. #define PARTITION_NTFT 0x80 // NTFT partition
  153. //
  154. // The following macro is used to determine which partitions should be
  155. // assigned drive letters.
  156. //
  157. //++
  158. //
  159. // BOOLEAN
  160. // IsRecognizedPartition(
  161. // IN ULONG PartitionType
  162. // )
  163. //
  164. // Routine Description:
  165. //
  166. // This macro is used to determine to which partitions drive letters
  167. // should be assigned.
  168. //
  169. // Arguments:
  170. //
  171. // PartitionType - Supplies the type of the partition being examined.
  172. //
  173. // Return Value:
  174. //
  175. // The return value is TRUE if the partition type is recognized,
  176. // otherwise FALSE is returned.
  177. //
  178. //--
  179. #define IsRecognizedPartition( PartitionType ) ( \
  180. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) || \
  181. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) || \
  182. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) || \
  183. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) || \
  184. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) || \
  185. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) || \
  186. ((PartitionType) == PARTITION_FAT_12) || \
  187. ((PartitionType) == PARTITION_FAT_16) || \
  188. ((PartitionType) == PARTITION_IFS) || \
  189. ((PartitionType) == PARTITION_HUGE) || \
  190. ((PartitionType) == PARTITION_FAT32) || \
  191. ((PartitionType) == PARTITION_FAT32_XINT13) || \
  192. ((PartitionType) == PARTITION_XINT13) )
  193. //++
  194. //
  195. // BOOLEAN
  196. // IsContainerPartition(
  197. // IN ULONG PartitionType
  198. // )
  199. //
  200. // Routine Description:
  201. //
  202. // This macro is used to determine to which partition types are actually
  203. // containers for other partitions (ie, extended partitions).
  204. //
  205. // Arguments:
  206. //
  207. // PartitionType - Supplies the type of the partition being examined.
  208. //
  209. // Return Value:
  210. //
  211. // The return value is TRUE if the partition type is a container,
  212. // otherwise FALSE is returned.
  213. //
  214. //--
  215. #define IsContainerPartition( PartitionType ) \
  216. ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  217. //++
  218. //
  219. // BOOLEAN
  220. // IsFTPartition(
  221. // IN ULONG PartitionType
  222. // )
  223. //
  224. // Routine Description:
  225. //
  226. // This macro is used to determine if the given partition is an FT
  227. // partition.
  228. //
  229. // Arguments:
  230. //
  231. // PartitionType - Supplies the type of the partition being examined.
  232. //
  233. // Return Value:
  234. //
  235. // The return value is TRUE if the partition type is an FT partition,
  236. // otherwise FALSE is returned.
  237. //
  238. //--
  239. #define IsFTPartition( PartitionType ) \
  240. (((PartitionType)&PARTITION_NTFT) && IsRecognizedPartition(PartitionType))
  241. //
  242. // Define the media types supported by the driver.
  243. //
  244. typedef enum _MEDIA_TYPE {
  245. Unknown, // Format is unknown
  246. F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  247. F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  248. F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  249. F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  250. F3_720_512, // 3.5", 720KB, 512 bytes/sector
  251. F5_360_512, // 5.25", 360KB, 512 bytes/sector
  252. F5_320_512, // 5.25", 320KB, 512 bytes/sector
  253. F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  254. F5_180_512, // 5.25", 180KB, 512 bytes/sector
  255. F5_160_512, // 5.25", 160KB, 512 bytes/sector
  256. RemovableMedia, // Removable media other than floppy
  257. FixedMedia, // Fixed hard disk media
  258. F3_120M_512, // 3.5", 120M Floppy
  259. F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  260. F5_640_512, // 5.25", 640KB, 512 bytes/sector
  261. F5_720_512, // 5.25", 720KB, 512 bytes/sector
  262. F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  263. F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  264. F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  265. F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  266. F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  267. F8_256_128, // 8", 256KB, 128 bytes/sector
  268. F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  269. F3_240M_512, // 3.5", 240Mb Floppy (HiFD)
  270. F3_32M_512 // 3.5", 32Mb Floppy
  271. } MEDIA_TYPE, *PMEDIA_TYPE;
  272. //
  273. // Define the input buffer structure for the driver, when
  274. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  275. //
  276. typedef struct _FORMAT_PARAMETERS {
  277. MEDIA_TYPE MediaType;
  278. ULONG StartCylinderNumber;
  279. ULONG EndCylinderNumber;
  280. ULONG StartHeadNumber;
  281. ULONG EndHeadNumber;
  282. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  283. //
  284. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  285. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  286. // what tracks were bad during formatting. The length of that array is
  287. // reported in the `Information' field of the I/O Status Block.
  288. //
  289. typedef USHORT BAD_TRACK_NUMBER;
  290. typedef USHORT *PBAD_TRACK_NUMBER;
  291. //
  292. // Define the input buffer structure for the driver, when
  293. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  294. //
  295. typedef struct _FORMAT_EX_PARAMETERS {
  296. MEDIA_TYPE MediaType;
  297. ULONG StartCylinderNumber;
  298. ULONG EndCylinderNumber;
  299. ULONG StartHeadNumber;
  300. ULONG EndHeadNumber;
  301. USHORT FormatGapLength;
  302. USHORT SectorsPerTrack;
  303. USHORT SectorNumber[1];
  304. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  305. //
  306. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  307. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  308. // request.
  309. //
  310. typedef struct _DISK_GEOMETRY {
  311. LARGE_INTEGER Cylinders;
  312. MEDIA_TYPE MediaType;
  313. ULONG TracksPerCylinder;
  314. ULONG SectorsPerTrack;
  315. ULONG BytesPerSector;
  316. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  317. //
  318. // This wmi guid returns a DISK_GEOMETRY structure
  319. //
  320. #define WMI_DISK_GEOMETRY_GUID { 0x25007f51, 0x57c2, 0x11d1, { 0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10 } }
  321. //
  322. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  323. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request. It is also used in a request
  324. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  325. //
  326. typedef struct _PARTITION_INFORMATION {
  327. LARGE_INTEGER StartingOffset;
  328. LARGE_INTEGER PartitionLength;
  329. ULONG HiddenSectors;
  330. ULONG PartitionNumber;
  331. UCHAR PartitionType;
  332. BOOLEAN BootIndicator;
  333. BOOLEAN RecognizedPartition;
  334. BOOLEAN RewritePartition;
  335. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  336. //
  337. // The following structure is used to change the partition type of a
  338. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  339. // request.
  340. //
  341. typedef struct _SET_PARTITION_INFORMATION {
  342. UCHAR PartitionType;
  343. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  344. //
  345. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  346. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  347. //
  348. typedef struct _DRIVE_LAYOUT_INFORMATION {
  349. ULONG PartitionCount;
  350. ULONG Signature;
  351. PARTITION_INFORMATION PartitionEntry[1];
  352. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  353. //
  354. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  355. // The offset and length parameters are both given in bytes.
  356. //
  357. typedef struct _VERIFY_INFORMATION {
  358. LARGE_INTEGER StartingOffset;
  359. ULONG Length;
  360. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  361. //
  362. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  363. // request.
  364. //
  365. typedef struct _REASSIGN_BLOCKS {
  366. USHORT Reserved;
  367. USHORT Count;
  368. ULONG BlockNumber[1];
  369. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  370. #if(_WIN32_WINNT >= 0x500)
  371. //
  372. // Support for GUID Partition Table (GPT) disks.
  373. //
  374. //
  375. // There are currently two ways a disk can be partitioned. With a traditional
  376. // AT-style master boot record (PARTITION_STYLE_MBR) and with a new, GPT
  377. // partition table (PARTITION_STYLE_GPT). RAW is for an unrecognizable
  378. // partition style. There are a very limited number of things you can
  379. // do with a RAW partititon.
  380. //
  381. typedef enum _PARTITION_STYLE {
  382. PARTITION_STYLE_MBR,
  383. PARTITION_STYLE_GPT,
  384. PARTITION_STYLE_RAW
  385. } PARTITION_STYLE;
  386. //
  387. // The following structure defines information in a GPT partition that is
  388. // not common to both GPT and MBR partitions.
  389. //
  390. typedef struct _PARTITION_INFORMATION_GPT {
  391. GUID PartitionType; // Partition type. See table 16-3.
  392. GUID PartitionId; // Unique GUID for this partition.
  393. ULONG64 Attributes; // See table 16-4.
  394. WCHAR Name [36]; // Partition Name in Unicode.
  395. } PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT;
  396. //
  397. // The following are GPT partition attributes applicable for any
  398. // partition type. These attributes are not OS-specific
  399. //
  400. #define GPT_ATTRIBUTE_PLATFORM_REQUIRED (0x0000000000000001)
  401. //
  402. // The following are GPT partition attributes applicable when the
  403. // PartitionType is PARTITION_BASIC_DATA_GUID.
  404. //
  405. #define GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER (0x8000000000000000)
  406. #define GPT_BASIC_DATA_ATTRIBUTE_HIDDEN (0x4000000000000000)
  407. #define GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY (0x1000000000000000)
  408. //
  409. // The following structure defines information in an MBR partition that is not
  410. // common to both GPT and MBR partitions.
  411. //
  412. typedef struct _PARTITION_INFORMATION_MBR {
  413. UCHAR PartitionType;
  414. BOOLEAN BootIndicator;
  415. BOOLEAN RecognizedPartition;
  416. ULONG HiddenSectors;
  417. } PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR;
  418. //
  419. // The structure SET_PARTITION_INFO_EX is used with the ioctl
  420. // IOCTL_SET_PARTITION_INFO_EX to set information about a specific
  421. // partition. Note that for MBR partitions, you can only set the partition
  422. // signature, whereas GPT partitions allow setting of all fields that
  423. // you can get.
  424. //
  425. typedef SET_PARTITION_INFORMATION SET_PARTITION_INFORMATION_MBR;
  426. typedef PARTITION_INFORMATION_GPT SET_PARTITION_INFORMATION_GPT;
  427. typedef struct _SET_PARTITION_INFORMATION_EX {
  428. PARTITION_STYLE PartitionStyle;
  429. union {
  430. SET_PARTITION_INFORMATION_MBR Mbr;
  431. SET_PARTITION_INFORMATION_GPT Gpt;
  432. };
  433. } SET_PARTITION_INFORMATION_EX, *PSET_PARTITION_INFORMATION_EX;
  434. //
  435. // The structure CREATE_DISK_GPT with the ioctl IOCTL_DISK_CREATE_DISK
  436. // to initialize an virgin disk with an empty GPT partition table.
  437. //
  438. typedef struct _CREATE_DISK_GPT {
  439. GUID DiskId; // Unique disk id for the disk.
  440. ULONG MaxPartitionCount; // Maximim number of partitions allowable.
  441. } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
  442. //
  443. // The structure CREATE_DISK_MBR with the ioctl IOCTL_DISK_CREATE_DISK
  444. // to initialize an virgin disk with an empty MBR partition table.
  445. //
  446. typedef struct _CREATE_DISK_MBR {
  447. ULONG Signature;
  448. } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
  449. typedef struct _CREATE_DISK {
  450. PARTITION_STYLE PartitionStyle;
  451. union {
  452. CREATE_DISK_MBR Mbr;
  453. CREATE_DISK_GPT Gpt;
  454. };
  455. } CREATE_DISK, *PCREATE_DISK;
  456. //
  457. // The structure GET_LENGTH_INFORMATION is used with the ioctl
  458. // IOCTL_DISK_GET_LENGTH_INFO to obtain the length, in bytes, of the
  459. // disk, partition, or volume.
  460. //
  461. typedef struct _GET_LENGTH_INFORMATION {
  462. LARGE_INTEGER Length;
  463. } GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION;
  464. //
  465. // The PARTITION_INFORMATION_EX structure is used with the
  466. // IOCTL_DISK_GET_DRIVE_LAYOUT_EX, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
  467. // IOCTL_DISK_GET_PARTITION_INFO_EX and IOCTL_DISK_GET_PARTITION_INFO_EX calls.
  468. //
  469. typedef struct _PARTITION_INFORMATION_EX {
  470. PARTITION_STYLE PartitionStyle;
  471. LARGE_INTEGER StartingOffset;
  472. LARGE_INTEGER PartitionLength;
  473. ULONG PartitionNumber;
  474. BOOLEAN RewritePartition;
  475. union {
  476. PARTITION_INFORMATION_MBR Mbr;
  477. PARTITION_INFORMATION_GPT Gpt;
  478. };
  479. } PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX;
  480. //
  481. // GPT specific drive layout information.
  482. //
  483. typedef struct _DRIVE_LAYOUT_INFORMATION_GPT {
  484. GUID DiskId;
  485. LARGE_INTEGER StartingUsableOffset;
  486. LARGE_INTEGER UsableLength;
  487. ULONG MaxPartitionCount;
  488. } DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT;
  489. //
  490. // MBR specific drive layout information.
  491. //
  492. typedef struct _DRIVE_LAYOUT_INFORMATION_MBR {
  493. ULONG Signature;
  494. } DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR;
  495. //
  496. // The structure DRIVE_LAYOUT_INFORMATION_EX is used with the
  497. // IOCTL_SET_DRIVE_LAYOUT_EX and IOCTL_GET_DRIVE_LAYOUT_EX calls.
  498. //
  499. typedef struct _DRIVE_LAYOUT_INFORMATION_EX {
  500. ULONG PartitionStyle;
  501. ULONG PartitionCount;
  502. union {
  503. DRIVE_LAYOUT_INFORMATION_MBR Mbr;
  504. DRIVE_LAYOUT_INFORMATION_GPT Gpt;
  505. };
  506. PARTITION_INFORMATION_EX PartitionEntry[1];
  507. } DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX;
  508. #endif // (_WIN32_WINNT >= 0x0500)
  509. #if(_WIN32_WINNT >= 0x0500)
  510. //
  511. // The DISK_GEOMETRY_EX structure is returned on issuing an
  512. // IOCTL_DISK_GET_DRIVE_GEOMETRY_EX ioctl.
  513. //
  514. typedef enum _DETECTION_TYPE {
  515. DetectNone,
  516. DetectInt13,
  517. DetectExInt13
  518. } DETECTION_TYPE;
  519. typedef struct _DISK_INT13_INFO {
  520. USHORT DriveSelect;
  521. ULONG MaxCylinders;
  522. USHORT SectorsPerTrack;
  523. USHORT MaxHeads;
  524. USHORT NumberDrives;
  525. } DISK_INT13_INFO, *PDISK_INT13_INFO;
  526. typedef struct _DISK_EX_INT13_INFO {
  527. USHORT ExBufferSize;
  528. USHORT ExFlags;
  529. ULONG ExCylinders;
  530. ULONG ExHeads;
  531. ULONG ExSectorsPerTrack;
  532. ULONG64 ExSectorsPerDrive;
  533. USHORT ExSectorSize;
  534. USHORT ExReserved;
  535. } DISK_EX_INT13_INFO, *PDISK_EX_INT13_INFO;
  536. typedef struct _DISK_DETECTION_INFO {
  537. ULONG SizeOfDetectInfo;
  538. DETECTION_TYPE DetectionType;
  539. union {
  540. struct {
  541. //
  542. // If DetectionType == DETECTION_INT13 then we have just the Int13
  543. // information.
  544. //
  545. DISK_INT13_INFO Int13;
  546. //
  547. // If DetectionType == DETECTION_EX_INT13, then we have the
  548. // extended int 13 information.
  549. //
  550. DISK_EX_INT13_INFO ExInt13; // If DetectionType == DetectExInt13
  551. };
  552. };
  553. } DISK_DETECTION_INFO, *PDISK_DETECTION_INFO;
  554. typedef struct _DISK_PARTITION_INFO {
  555. ULONG SizeOfPartitionInfo;
  556. PARTITION_STYLE PartitionStyle; // PartitionStyle = RAW, GPT or MBR
  557. union {
  558. struct { // If PartitionStyle == MBR
  559. ULONG Signature; // MBR Signature
  560. ULONG CheckSum; // MBR CheckSum
  561. } Mbr;
  562. struct { // If PartitionStyle == GPT
  563. GUID DiskId;
  564. } Gpt;
  565. };
  566. } DISK_PARTITION_INFO, *PDISK_PARTITION_INFO;
  567. //
  568. // The Geometry structure is a variable length structure composed of a
  569. // DISK_GEOMETRY_EX structure followed by a DISK_PARTITION_INFO structure
  570. // followed by a DISK_DETECTION_DATA structure.
  571. //
  572. #define DiskGeometryGetPartition(Geometry)\
  573. ((PDISK_PARTITION_INFO)((Geometry)+1))
  574. #define DiskGeometryGetDetect(Geometry)\
  575. ((PDISK_DETECTION_INFO)(((PBYTE)DiskGeometryGetPartition(Geometry)+\
  576. DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo)))
  577. typedef struct _DISK_GEOMETRY_EX {
  578. DISK_GEOMETRY Geometry; // Standard disk geometry: may be faked by driver.
  579. LARGE_INTEGER DiskSize; // Must always be correct
  580. UCHAR Data[1]; // Partition, Detect info
  581. } DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX;
  582. #endif // (_WIN32_WINNT > 0x0500)
  583. #if(_WIN32_WINNT >= 0x0400)
  584. //
  585. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  586. // number for the handle. This is used to determine if a disk
  587. // is attached to the primary or secondary IDE controller.
  588. //
  589. typedef struct _DISK_CONTROLLER_NUMBER {
  590. ULONG ControllerNumber;
  591. ULONG DiskNumber;
  592. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  593. #endif /* _WIN32_WINNT >= 0x0400 */
  594. #if(_WIN32_WINNT >= 0x0500)
  595. //
  596. // IOCTL_DISK_SET_CACHE allows the caller to get or set the state of the disk
  597. // read/write caches.
  598. //
  599. // If the structure is provided as the input buffer for the ioctl the read &
  600. // write caches will be enabled or disabled depending on the parameters
  601. // provided.
  602. //
  603. // If the structure is provided as an output buffer for the ioctl the state
  604. // of the read & write caches will be returned. If both input and outut buffers
  605. // are provided the output buffer will contain the cache state BEFORE any
  606. // changes are made
  607. //
  608. typedef enum {
  609. EqualPriority,
  610. KeepPrefetchedData,
  611. KeepReadData
  612. } DISK_CACHE_RETENTION_PRIORITY;
  613. typedef enum _DISK_WRITE_CACHE_STATE {
  614. DiskWriteCacheNormal,
  615. DiskWriteCacheForceDisable,
  616. DiskWriteCacheDisableNotSupported
  617. } DISK_WRITE_CACHE_STATE, *PDISK_WRITE_CACHE_STATE;
  618. typedef struct _DISK_CACHE_INFORMATION {
  619. //
  620. // on return indicates that the device is capable of saving any parameters
  621. // in non-volatile storage. On send indicates that the device should
  622. // save the state in non-volatile storage.
  623. //
  624. BOOLEAN ParametersSavable;
  625. //
  626. // Indicates whether the write and read caches are enabled.
  627. //
  628. BOOLEAN ReadCacheEnabled;
  629. BOOLEAN WriteCacheEnabled;
  630. //
  631. // Controls the likelyhood of data remaining in the cache depending on how
  632. // it got there. Data cached from a READ or WRITE operation may be given
  633. // higher, lower or equal priority to data entered into the cache for other
  634. // means (like prefetch)
  635. //
  636. DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority;
  637. DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority;
  638. //
  639. // Requests for a larger number of blocks than this may have prefetching
  640. // disabled. If this value is set to 0 prefetch will be disabled.
  641. //
  642. USHORT DisablePrefetchTransferLength;
  643. //
  644. // If TRUE then ScalarPrefetch (below) will be valid. If FALSE then
  645. // the minimum and maximum values should be treated as a block count
  646. // (BlockPrefetch)
  647. //
  648. BOOLEAN PrefetchScalar;
  649. //
  650. // Contains the minimum and maximum amount of data which will be
  651. // will be prefetched into the cache on a disk operation. This value
  652. // may either be a scalar multiplier of the transfer length of the request,
  653. // or an abolute number of disk blocks. PrefetchScalar (above) indicates
  654. // which interpretation is used.
  655. //
  656. union {
  657. struct {
  658. USHORT Minimum;
  659. USHORT Maximum;
  660. //
  661. // The maximum number of blocks which will be prefetched - useful
  662. // with the scalar limits to set definite upper limits.
  663. //
  664. USHORT MaximumBlocks;
  665. } ScalarPrefetch;
  666. struct {
  667. USHORT Minimum;
  668. USHORT Maximum;
  669. } BlockPrefetch;
  670. };
  671. } DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION;
  672. //
  673. // IOCTL_DISK_GROW_PARTITION will update the size of a partition
  674. // by adding sectors to the length. The number of sectors must be
  675. // predetermined by examining PARTITION_INFORMATION.
  676. //
  677. typedef struct _DISK_GROW_PARTITION {
  678. ULONG PartitionNumber;
  679. LARGE_INTEGER BytesToGrow;
  680. } DISK_GROW_PARTITION, *PDISK_GROW_PARTITION;
  681. #endif /* _WIN32_WINNT >= 0x0500 */
  682. ///////////////////////////////////////////////////////
  683. // //
  684. // The following structures define disk performance //
  685. // statistics: specifically the locations of all the //
  686. // reads and writes which have occured on the disk. //
  687. // //
  688. // To use these structures, you must issue an IOCTL_ //
  689. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to //
  690. // obtain the basic histogram information. The //
  691. // number of buckets which must allocated is part of //
  692. // this structure. Allocate the required number of //
  693. // buckets and call an IOCTL_DISK_HIST_DATA to fill //
  694. // in the data //
  695. // //
  696. ///////////////////////////////////////////////////////
  697. #define HIST_NO_OF_BUCKETS 24
  698. typedef struct _HISTOGRAM_BUCKET {
  699. ULONG Reads;
  700. ULONG Writes;
  701. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  702. #define HISTOGRAM_BUCKET_SIZE sizeof(HISTOGRAM_BUCKET)
  703. typedef struct _DISK_HISTOGRAM {
  704. LARGE_INTEGER DiskSize;
  705. LARGE_INTEGER Start;
  706. LARGE_INTEGER End;
  707. LARGE_INTEGER Average;
  708. LARGE_INTEGER AverageRead;
  709. LARGE_INTEGER AverageWrite;
  710. ULONG Granularity;
  711. ULONG Size;
  712. ULONG ReadCount;
  713. ULONG WriteCount;
  714. PHISTOGRAM_BUCKET Histogram;
  715. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  716. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  717. ///////////////////////////////////////////////////////
  718. // //
  719. // The following structures define disk debugging //
  720. // capabilities. The IOCTLs are directed to one of //
  721. // the two disk filter drivers. //
  722. // //
  723. // DISKPERF is a utilty for collecting disk request //
  724. // statistics. //
  725. // //
  726. // SIMBAD is a utility for injecting faults in //
  727. // IO requests to disks. //
  728. // //
  729. ///////////////////////////////////////////////////////
  730. //
  731. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  732. // request. This ioctl collects summary disk request statistics used
  733. // in measuring performance.
  734. //
  735. typedef struct _DISK_PERFORMANCE {
  736. LARGE_INTEGER BytesRead;
  737. LARGE_INTEGER BytesWritten;
  738. LARGE_INTEGER ReadTime;
  739. LARGE_INTEGER WriteTime;
  740. LARGE_INTEGER IdleTime;
  741. ULONG ReadCount;
  742. ULONG WriteCount;
  743. ULONG QueueDepth;
  744. ULONG SplitCount;
  745. LARGE_INTEGER QueryTime;
  746. ULONG StorageDeviceNumber;
  747. WCHAR StorageManagerName[8];
  748. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  749. //
  750. // This structure defines the disk logging record. When disk logging
  751. // is enabled, one of these is written to an internal buffer for each
  752. // disk request.
  753. //
  754. typedef struct _DISK_RECORD {
  755. LARGE_INTEGER ByteOffset;
  756. LARGE_INTEGER StartTime;
  757. LARGE_INTEGER EndTime;
  758. PVOID VirtualAddress;
  759. ULONG NumberOfBytes;
  760. UCHAR DeviceNumber;
  761. BOOLEAN ReadRequest;
  762. } DISK_RECORD, *PDISK_RECORD;
  763. //
  764. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  765. // Not all fields are valid with each function type.
  766. //
  767. typedef struct _DISK_LOGGING {
  768. UCHAR Function;
  769. PVOID BufferAddress;
  770. ULONG BufferSize;
  771. } DISK_LOGGING, *PDISK_LOGGING;
  772. //
  773. // Disk logging functions
  774. //
  775. // Start disk logging. Only the Function and BufferSize fields are valid.
  776. //
  777. #define DISK_LOGGING_START 0
  778. //
  779. // Stop disk logging. Only the Function field is valid.
  780. //
  781. #define DISK_LOGGING_STOP 1
  782. //
  783. // Return disk log. All fields are valid. Data will be copied from internal
  784. // buffer to buffer specified for the number of bytes requested.
  785. //
  786. #define DISK_LOGGING_DUMP 2
  787. //
  788. // DISK BINNING
  789. //
  790. // DISKPERF will keep counters for IO that falls in each of these ranges.
  791. // The application determines the number and size of the ranges.
  792. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  793. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  794. //
  795. #define DISK_BINNING 3
  796. //
  797. // Bin types
  798. //
  799. typedef enum _BIN_TYPES {
  800. RequestSize,
  801. RequestLocation
  802. } BIN_TYPES;
  803. //
  804. // Bin ranges
  805. //
  806. typedef struct _BIN_RANGE {
  807. LARGE_INTEGER StartValue;
  808. LARGE_INTEGER Length;
  809. } BIN_RANGE, *PBIN_RANGE;
  810. //
  811. // Bin definition
  812. //
  813. typedef struct _PERF_BIN {
  814. ULONG NumberOfBins;
  815. ULONG TypeOfBin;
  816. BIN_RANGE BinsRanges[1];
  817. } PERF_BIN, *PPERF_BIN ;
  818. //
  819. // Bin count
  820. //
  821. typedef struct _BIN_COUNT {
  822. BIN_RANGE BinRange;
  823. ULONG BinCount;
  824. } BIN_COUNT, *PBIN_COUNT;
  825. //
  826. // Bin results
  827. //
  828. typedef struct _BIN_RESULTS {
  829. ULONG NumberOfBins;
  830. BIN_COUNT BinCounts[1];
  831. } BIN_RESULTS, *PBIN_RESULTS;
  832. #if(_WIN32_WINNT >= 0x0400)
  833. //
  834. // Data structures for SMART drive fault prediction.
  835. //
  836. // GETVERSIONINPARAMS contains the data returned from the
  837. // Get Driver Version function.
  838. //
  839. #include <pshpack1.h>
  840. typedef struct _GETVERSIONINPARAMS {
  841. UCHAR bVersion; // Binary driver version.
  842. UCHAR bRevision; // Binary driver revision.
  843. UCHAR bReserved; // Not used.
  844. UCHAR bIDEDeviceMap; // Bit map of IDE devices.
  845. ULONG fCapabilities; // Bit mask of driver capabilities.
  846. ULONG dwReserved[4]; // For future use.
  847. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  848. #include <poppack.h>
  849. //
  850. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  851. //
  852. #define CAP_ATA_ID_CMD 1 // ATA ID command supported
  853. #define CAP_ATAPI_ID_CMD 2 // ATAPI ID command supported
  854. #define CAP_SMART_CMD 4 // SMART commannds supported
  855. //
  856. // IDE registers
  857. //
  858. #include <pshpack1.h>
  859. typedef struct _IDEREGS {
  860. UCHAR bFeaturesReg; // Used for specifying SMART "commands".
  861. UCHAR bSectorCountReg; // IDE sector count register
  862. UCHAR bSectorNumberReg; // IDE sector number register
  863. UCHAR bCylLowReg; // IDE low order cylinder value
  864. UCHAR bCylHighReg; // IDE high order cylinder value
  865. UCHAR bDriveHeadReg; // IDE drive/head register
  866. UCHAR bCommandReg; // Actual IDE command.
  867. UCHAR bReserved; // reserved for future use. Must be zero.
  868. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  869. #include <poppack.h>
  870. //
  871. // Valid values for the bCommandReg member of IDEREGS.
  872. //
  873. #define ATAPI_ID_CMD 0xA1 // Returns ID sector for ATAPI.
  874. #define ID_CMD 0xEC // Returns ID sector for ATA.
  875. #define SMART_CMD 0xB0 // Performs SMART cmd.
  876. // Requires valid bFeaturesReg,
  877. // bCylLowReg, and bCylHighReg
  878. //
  879. // Cylinder register defines for SMART command
  880. //
  881. #define SMART_CYL_LOW 0x4F
  882. #define SMART_CYL_HI 0xC2
  883. //
  884. // SENDCMDINPARAMS contains the input parameters for the
  885. // Send Command to Drive function.
  886. //
  887. #include <pshpack1.h>
  888. typedef struct _SENDCMDINPARAMS {
  889. ULONG cBufferSize; // Buffer size in bytes
  890. IDEREGS irDriveRegs; // Structure with drive register values.
  891. UCHAR bDriveNumber; // Physical drive number to send
  892. // command to (0,1,2,3).
  893. UCHAR bReserved[3]; // Reserved for future expansion.
  894. ULONG dwReserved[4]; // For future use.
  895. UCHAR bBuffer[1]; // Input buffer.
  896. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  897. #include <poppack.h>
  898. //
  899. // Status returned from driver
  900. //
  901. #include <pshpack1.h>
  902. typedef struct _DRIVERSTATUS {
  903. UCHAR bDriverError; // Error code from driver,
  904. // or 0 if no error.
  905. UCHAR bIDEError; // Contents of IDE Error register.
  906. // Only valid when bDriverError
  907. // is SMART_IDE_ERROR.
  908. UCHAR bReserved[2]; // Reserved for future expansion.
  909. ULONG dwReserved[2]; // Reserved for future expansion.
  910. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  911. #include <poppack.h>
  912. //
  913. // bDriverError values
  914. //
  915. #define SMART_NO_ERROR 0 // No error
  916. #define SMART_IDE_ERROR 1 // Error from IDE controller
  917. #define SMART_INVALID_FLAG 2 // Invalid command flag
  918. #define SMART_INVALID_COMMAND 3 // Invalid command byte
  919. #define SMART_INVALID_BUFFER 4 // Bad buffer (null, invalid addr..)
  920. #define SMART_INVALID_DRIVE 5 // Drive number not valid
  921. #define SMART_INVALID_IOCTL 6 // Invalid IOCTL
  922. #define SMART_ERROR_NO_MEM 7 // Could not lock user's buffer
  923. #define SMART_INVALID_REGISTER 8 // Some IDE Register not valid
  924. #define SMART_NOT_SUPPORTED 9 // Invalid cmd flag set
  925. #define SMART_NO_IDE_DEVICE 10 // Cmd issued to device not present
  926. // although drive number is valid
  927. //
  928. // SMART sub commands for execute offline diags
  929. //
  930. #define SMART_OFFLINE_ROUTINE_OFFLINE 0
  931. #define SMART_SHORT_SELFTEST_OFFLINE 1
  932. #define SMART_EXTENDED_SELFTEST_OFFLINE 2
  933. #define SMART_ABORT_OFFLINE_SELFTEST 127
  934. #define SMART_SHORT_SELFTEST_CAPTIVE 129
  935. #define SMART_EXTENDED_SELFTEST_CAPTIVE 130
  936. #include <pshpack1.h>
  937. typedef struct _SENDCMDOUTPARAMS {
  938. ULONG cBufferSize; // Size of bBuffer in bytes
  939. DRIVERSTATUS DriverStatus; // Driver status structure.
  940. UCHAR bBuffer[1]; // Buffer of arbitrary length in which to store the data read from the // drive.
  941. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  942. #include <poppack.h>
  943. #define READ_ATTRIBUTE_BUFFER_SIZE 512
  944. #define IDENTIFY_BUFFER_SIZE 512
  945. #define READ_THRESHOLD_BUFFER_SIZE 512
  946. #define SMART_LOG_SECTOR_SIZE 512
  947. //
  948. // Feature register defines for SMART "sub commands"
  949. //
  950. #define READ_ATTRIBUTES 0xD0
  951. #define READ_THRESHOLDS 0xD1
  952. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  953. #define SAVE_ATTRIBUTE_VALUES 0xD3
  954. #define EXECUTE_OFFLINE_DIAGS 0xD4
  955. #define SMART_READ_LOG 0xD5
  956. #define SMART_WRITE_LOG 0xd6
  957. #define ENABLE_SMART 0xD8
  958. #define DISABLE_SMART 0xD9
  959. #define RETURN_SMART_STATUS 0xDA
  960. #define ENABLE_DISABLE_AUTO_OFFLINE 0xDB
  961. #endif /* _WIN32_WINNT >= 0x0400 */
  962. // end_winioctl
  963. //
  964. // The following device control code is for the SIMBAD simulated bad
  965. // sector facility. See SIMBAD.H in this directory for related structures.
  966. //
  967. #define IOCTL_DISK_SIMBAD CTL_CODE(IOCTL_DISK_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  968. //
  969. // Queue link for mapped addresses stored for unmapping.
  970. //
  971. typedef struct _MAPPED_ADDRESS {
  972. struct _MAPPED_ADDRESS *NextMappedAddress;
  973. PVOID MappedAddress;
  974. ULONG NumberOfBytes;
  975. LARGE_INTEGER IoAddress;
  976. ULONG BusNumber;
  977. } MAPPED_ADDRESS, *PMAPPED_ADDRESS;
  978. #ifdef __cplusplus
  979. }
  980. #endif
  981. #endif // _NTDDDISK_H_