1 /* 2 * ntdddisk.h 3 * 4 * Disk IOCTL interface. 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns (at) users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #ifndef _NTDDDISK_H_ 24 #define _NTDDDISK_H_ 25 26 #include "ntddstor.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #define DD_DISK_DEVICE_NAME "\\Device\\UNKNOWN" 33 #define DD_DISK_DEVICE_NAME_U L"\\Device\\UNKNOWN" 34 35 #define IOCTL_DISK_BASE FILE_DEVICE_DISK 36 37 #define IOCTL_DISK_CHECK_VERIFY \ 38 CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS) 39 40 #define IOCTL_DISK_CONTROLLER_NUMBER \ 41 CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS) 42 43 #define IOCTL_DISK_CREATE_DISK \ 44 CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 45 46 #define IOCTL_DISK_DELETE_DRIVE_LAYOUT \ 47 CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 48 49 #define IOCTL_DISK_FIND_NEW_DEVICES \ 50 CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS) 51 52 #define IOCTL_DISK_FORMAT_TRACKS \ 53 CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 54 55 #define IOCTL_DISK_FORMAT_TRACKS_EX \ 56 CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 57 58 #define IOCTL_DISK_GET_CACHE_INFORMATION \ 59 CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS) 60 61 #define IOCTL_DISK_GET_DRIVE_GEOMETRY \ 62 CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS) 63 64 #define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX \ 65 CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS) 66 67 #define IOCTL_DISK_GET_DRIVE_LAYOUT \ 68 CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS) 69 70 #define IOCTL_DISK_GET_DRIVE_LAYOUT_EX \ 71 CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS) 72 73 #define IOCTL_DISK_GET_MEDIA_TYPES \ 74 CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS) 75 76 #define IOCTL_DISK_GET_LENGTH_INFO \ 77 CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS) 78 79 #define IOCTL_DISK_GET_PARTITION_INFO \ 80 CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS) 81 82 #define IOCTL_DISK_GET_PARTITION_INFO_EX \ 83 CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS) 84 85 #define IOCTL_DISK_GROW_PARTITION \ 86 CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 87 88 #define IOCTL_DISK_HISTOGRAM_STRUCTURE \ 89 CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS) 90 91 #define IOCTL_DISK_HISTOGRAM_DATA \ 92 CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS) 93 94 #define IOCTL_DISK_HISTOGRAM_RESET \ 95 CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS) 96 97 #define IOCTL_DISK_INTERNAL_CLEAR_VERIFY \ 98 CTL_CODE(IOCTL_DISK_BASE, 0x0101, METHOD_NEITHER, FILE_ANY_ACCESS) 99 100 #define IOCTL_DISK_INTERNAL_SET_VERIFY \ 101 CTL_CODE(IOCTL_DISK_BASE, 0x0100, METHOD_NEITHER, FILE_ANY_ACCESS) 102 103 #define IOCTL_DISK_IS_WRITABLE \ 104 CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS) 105 106 #define IOCTL_DISK_LOGGING \ 107 CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS) 108 109 #define IOCTL_DISK_PERFORMANCE \ 110 CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS) 111 112 #define IOCTL_DISK_PERFORMANCE_OFF \ 113 CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS) 114 115 #define IOCTL_DISK_REASSIGN_BLOCKS \ 116 CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 117 118 #define IOCTL_DISK_REQUEST_DATA \ 119 CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS) 120 121 #define IOCTL_DISK_REQUEST_STRUCTURE \ 122 CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS) 123 124 #define IOCTL_DISK_MEDIA_REMOVAL \ 125 CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS) 126 127 #define IOCTL_DISK_EJECT_MEDIA \ 128 CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS) 129 130 #define IOCTL_DISK_LOAD_MEDIA \ 131 CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS) 132 133 #define IOCTL_DISK_RESERVE \ 134 CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS) 135 136 #define IOCTL_DISK_RELEASE \ 137 CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS) 138 139 #define IOCTL_DISK_FIND_NEW_DEVICES \ 140 CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS) 141 142 #define IOCTL_DISK_SET_CACHE_INFORMATION \ 143 CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 144 145 #define IOCTL_DISK_SET_DRIVE_LAYOUT \ 146 CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 147 148 #define IOCTL_DISK_SET_DRIVE_LAYOUT_EX \ 149 CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 150 151 #define IOCTL_DISK_SET_PARTITION_INFO \ 152 CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 153 154 #define IOCTL_DISK_SET_PARTITION_INFO_EX \ 155 CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 156 157 #define IOCTL_DISK_UPDATE_DRIVE_SIZE \ 158 CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 159 160 #define IOCTL_DISK_VERIFY \ 161 CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS) 162 163 #define SMART_GET_VERSION \ 164 CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS) 165 166 #define SMART_RCV_DRIVE_DATA \ 167 CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 168 169 #define SMART_SEND_DRIVE_COMMAND \ 170 CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 171 172 #define IOCTL_DISK_UPDATE_PROPERTIES \ 173 CTL_CODE(IOCTL_DISK_BASE, 0x50, METHOD_BUFFERED, FILE_ANY_ACCESS) 174 175 #define PARTITION_ENTRY_UNUSED 0x00 176 #define PARTITION_FAT_12 0x01 177 #define PARTITION_XENIX_1 0x02 178 #define PARTITION_XENIX_2 0x03 179 #define PARTITION_FAT_16 0x04 180 #define PARTITION_EXTENDED 0x05 181 #define PARTITION_HUGE 0x06 182 #define PARTITION_IFS 0x07 183 #define PARTITION_OS2BOOTMGR 0x0A 184 #define PARTITION_FAT32 0x0B 185 #define PARTITION_FAT32_XINT13 0x0C 186 #define PARTITION_XINT13 0x0E 187 #define PARTITION_XINT13_EXTENDED 0x0F 188 #define PARTITION_PREP 0x41 189 #define PARTITION_LDM 0x42 190 #define PARTITION_UNIX 0x63 191 #define VALID_NTFT 0xC0 192 #define PARTITION_NTFT 0x80 193 194 #define IsFTPartition( PartitionType ) \ 195 (((PartitionType) & PARTITION_NTFT) && \ 196 IsRecognizedPartition(PartitionType)) 197 198 #define IsContainerPartition(PartitionType) \ 199 (((PartitionType) == PARTITION_EXTENDED) || \ 200 ((PartitionType) == PARTITION_XINT13_EXTENDED)) 201 202 #define IsRecognizedPartition(PartitionType) ( \ 203 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT_12)) || \ 204 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_HUGE)) || \ 205 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_IFS)) || \ 206 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32)) || \ 207 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32_XINT13)) || \ 208 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_XINT13)) || \ 209 ((PartitionType) == PARTITION_FAT_12) || \ 210 ((PartitionType) == PARTITION_FAT_16) || \ 211 ((PartitionType) == PARTITION_HUGE) || \ 212 ((PartitionType) == PARTITION_IFS) || \ 213 ((PartitionType) == PARTITION_FAT32) || \ 214 ((PartitionType) == PARTITION_FAT32_XINT13) || \ 215 ((PartitionType) == PARTITION_XINT13)) 216 217 #define WMI_DISK_GEOMETRY_GUID \ 218 {0x25007f51, 0x57c2, 0x11d1, {0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10}} 219 220 typedef USHORT BAD_TRACK_NUMBER; 221 typedef USHORT *PBAD_TRACK_NUMBER; 222 223 typedef enum _MEDIA_TYPE { 224 Unknown, 225 F5_1Pt2_512, 226 F3_1Pt44_512, 227 F3_2Pt88_512, 228 F3_20Pt8_512, 229 F3_720_512, 230 F5_360_512, 231 F5_320_512, 232 F5_320_1024, 233 F5_180_512, 234 F5_160_512, 235 RemovableMedia, 236 FixedMedia, 237 F3_120M_512, 238 F3_640_512, 239 F5_640_512, 240 F5_720_512, 241 F3_1Pt2_512, 242 F3_1Pt23_1024, 243 F5_1Pt23_1024, 244 F3_128Mb_512, 245 F3_230Mb_512, 246 F8_256_128 247 } MEDIA_TYPE, *PMEDIA_TYPE; 248 249 typedef enum _DETECTION_TYPE { 250 DetectNone, 251 DetectInt13, 252 DetectExInt13 253 } DETECTION_TYPE; 254 255 typedef struct _DISK_CONTROLLER_NUMBER { 256 ULONG ControllerNumber; 257 ULONG DiskNumber; 258 } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER; 259 260 typedef struct _DISK_INT13_INFO { 261 USHORT DriveSelect; 262 ULONG MaxCylinders; 263 USHORT SectorsPerTrack; 264 USHORT MaxHeads; 265 USHORT NumberDrives; 266 } DISK_INT13_INFO, *PDISK_INT13_INFO; 267 268 typedef struct _DISK_EX_INT13_INFO { 269 USHORT ExBufferSize; 270 USHORT ExFlags; 271 ULONG ExCylinders; 272 ULONG ExHeads; 273 ULONG ExSectorsPerTrack; 274 ULONG64 ExSectorsPerDrive; 275 USHORT ExSectorSize; 276 USHORT ExReserved; 277 } DISK_EX_INT13_INFO, *PDISK_EX_INT13_INFO; 278 279 typedef struct _DISK_DETECTION_INFO { 280 ULONG SizeOfDetectInfo; 281 DETECTION_TYPE DetectionType; 282 _ANONYMOUS_UNION union { 283 _ANONYMOUS_STRUCT struct { 284 DISK_INT13_INFO Int13; 285 DISK_EX_INT13_INFO ExInt13; 286 } DUMMYSTRUCTNAME; 287 } DUMMYUNIONNAME; 288 } DISK_DETECTION_INFO, *PDISK_DETECTION_INFO; 289 290 typedef struct _DISK_GEOMETRY { 291 LARGE_INTEGER Cylinders; 292 MEDIA_TYPE MediaType; 293 ULONG TracksPerCylinder; 294 ULONG SectorsPerTrack; 295 ULONG BytesPerSector; 296 } DISK_GEOMETRY, *PDISK_GEOMETRY; 297 298 typedef struct _DISK_GEOMETRY_EX { 299 DISK_GEOMETRY Geometry; 300 LARGE_INTEGER DiskSize; 301 UCHAR Data[1]; 302 } DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX; 303 304 #define DiskGeometryGetPartition(Geometry) \ 305 ((PDISK_PARTITION_INFO)((Geometry) + 1)) 306 307 #define DiskGeometryGetDetect(Geometry)\ 308 ((PDISK_DETECTION_INFO)(((PBYTE)DiskGeometryGetPartition(Geometry) + \ 309 DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo))) 310 311 typedef struct _PARTITION_INFORMATION { 312 LARGE_INTEGER StartingOffset; 313 LARGE_INTEGER PartitionLength; 314 ULONG HiddenSectors; 315 ULONG PartitionNumber; 316 UCHAR PartitionType; 317 BOOLEAN BootIndicator; 318 BOOLEAN RecognizedPartition; 319 BOOLEAN RewritePartition; 320 } PARTITION_INFORMATION, *PPARTITION_INFORMATION; 321 322 typedef struct _PARTITION_INFORMATION_GPT { 323 GUID PartitionType; 324 GUID PartitionId; 325 ULONG64 Attributes; 326 WCHAR Name [36]; 327 } PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT; 328 329 typedef enum _PARTITION_STYLE { 330 PARTITION_STYLE_MBR, 331 PARTITION_STYLE_GPT, 332 PARTITION_STYLE_RAW 333 } PARTITION_STYLE; 334 335 typedef struct _DISK_PARTITION_INFO { 336 ULONG SizeOfPartitionInfo; 337 PARTITION_STYLE PartitionStyle; 338 _ANONYMOUS_UNION union { 339 struct { 340 ULONG Signature; 341 ULONG CheckSum; 342 } Mbr; 343 struct { 344 GUID DiskId; 345 } Gpt; 346 } DUMMYUNIONNAME; 347 } DISK_PARTITION_INFO, *PDISK_PARTITION_INFO; 348 349 typedef struct _DISK_PERFORMANCE { 350 LARGE_INTEGER BytesRead; 351 LARGE_INTEGER BytesWritten; 352 LARGE_INTEGER ReadTime; 353 LARGE_INTEGER WriteTime; 354 LARGE_INTEGER IdleTime; 355 ULONG ReadCount; 356 ULONG WriteCount; 357 ULONG QueueDepth; 358 ULONG SplitCount; 359 LARGE_INTEGER QueryTime; 360 ULONG StorageDeviceNumber; 361 WCHAR StorageManagerName[8]; 362 } DISK_PERFORMANCE, *PDISK_PERFORMANCE; 363 364 typedef struct _PARTITION_INFORMATION_MBR { 365 UCHAR PartitionType; 366 BOOLEAN BootIndicator; 367 BOOLEAN RecognizedPartition; 368 ULONG HiddenSectors; 369 } PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR; 370 371 typedef struct _PARTITION_INFORMATION_EX { 372 PARTITION_STYLE PartitionStyle; 373 LARGE_INTEGER StartingOffset; 374 LARGE_INTEGER PartitionLength; 375 ULONG PartitionNumber; 376 BOOLEAN RewritePartition; 377 _ANONYMOUS_UNION union { 378 PARTITION_INFORMATION_MBR Mbr; 379 PARTITION_INFORMATION_GPT Gpt; 380 } DUMMYUNIONNAME; 381 } PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX; 382 383 typedef struct _DRIVE_LAYOUT_INFORMATION { 384 ULONG PartitionCount; 385 ULONG Signature; 386 PARTITION_INFORMATION PartitionEntry[1]; 387 } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION; 388 389 typedef struct _DRIVE_LAYOUT_INFORMATION_MBR { 390 ULONG Signature; 391 } DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR; 392 393 typedef struct _DRIVE_LAYOUT_INFORMATION_GPT { 394 GUID DiskId; 395 LARGE_INTEGER StartingUsableOffset; 396 LARGE_INTEGER UsableLength; 397 ULONG MaxPartitionCount; 398 } DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT; 399 400 typedef struct _DRIVE_LAYOUT_INFORMATION_EX { 401 ULONG PartitionStyle; 402 ULONG PartitionCount; 403 __GNU_EXTENSION union { 404 DRIVE_LAYOUT_INFORMATION_MBR Mbr; 405 DRIVE_LAYOUT_INFORMATION_GPT Gpt; 406 }; 407 PARTITION_INFORMATION_EX PartitionEntry[1]; 408 } DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX; 409 410 typedef struct _FORMAT_EX_PARAMETERS { 411 MEDIA_TYPE MediaType; 412 ULONG StartCylinderNumber; 413 ULONG EndCylinderNumber; 414 ULONG StartHeadNumber; 415 ULONG EndHeadNumber; 416 USHORT FormatGapLength; 417 USHORT SectorsPerTrack; 418 USHORT SectorNumber[1]; 419 } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS; 420 421 typedef struct _FORMAT_PARAMETERS { 422 MEDIA_TYPE MediaType; 423 ULONG StartCylinderNumber; 424 ULONG EndCylinderNumber; 425 ULONG StartHeadNumber; 426 ULONG EndHeadNumber; 427 } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS; 428 429 typedef struct _GET_LENGTH_INFORMATION { 430 LARGE_INTEGER Length; 431 } GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION; 432 433 typedef struct _REASSIGN_BLOCKS { 434 USHORT Reserved; 435 USHORT Count; 436 ULONG BlockNumber[1]; 437 } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS; 438 439 typedef struct _SET_PARTITION_INFORMATION { 440 UCHAR PartitionType; 441 } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION; 442 443 typedef SET_PARTITION_INFORMATION SET_PARTITION_INFORMATION_MBR; 444 typedef PARTITION_INFORMATION_GPT SET_PARTITION_INFORMATION_GPT; 445 446 typedef struct _SET_PARTITION_INFORMATION_EX { 447 PARTITION_STYLE PartitionStyle; 448 _ANONYMOUS_UNION union { 449 SET_PARTITION_INFORMATION_MBR Mbr; 450 SET_PARTITION_INFORMATION_GPT Gpt; 451 } DUMMYUNIONNAME; 452 } SET_PARTITION_INFORMATION_EX, *PSET_PARTITION_INFORMATION_EX; 453 454 typedef struct _VERIFY_INFORMATION { 455 LARGE_INTEGER StartingOffset; 456 ULONG Length; 457 } VERIFY_INFORMATION, *PVERIFY_INFORMATION; 458 459 typedef enum { 460 EqualPriority, 461 KeepPrefetchedData, 462 KeepReadData 463 } DISK_CACHE_RETENTION_PRIORITY; 464 465 typedef struct _DISK_CACHE_INFORMATION { 466 BOOLEAN ParametersSavable; 467 BOOLEAN ReadCacheEnabled; 468 BOOLEAN WriteCacheEnabled; 469 DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority; 470 DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority; 471 USHORT DisablePrefetchTransferLength; 472 BOOLEAN PrefetchScalar; 473 _ANONYMOUS_UNION union { 474 struct { 475 USHORT Minimum; 476 USHORT Maximum; 477 USHORT MaximumBlocks; 478 } ScalarPrefetch; 479 struct { 480 USHORT Minimum; 481 USHORT Maximum; 482 } BlockPrefetch; 483 } DUMMYUNIONNAME; 484 } DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION; 485 486 typedef struct _DISK_GROW_PARTITION { 487 ULONG PartitionNumber; 488 LARGE_INTEGER BytesToGrow; 489 } DISK_GROW_PARTITION, *PDISK_GROW_PARTITION; 490 491 /* GETVERSIONINPARAMS.fCapabilities constants */ 492 #define CAP_ATA_ID_CMD 1 493 #define CAP_ATAPI_ID_CMD 2 494 #define CAP_SMART_CMD 4 495 496 typedef struct _GETVERSIONINPARAMS { 497 UCHAR bVersion; 498 UCHAR bRevision; 499 UCHAR bReserved; 500 UCHAR bIDEDeviceMap; 501 ULONG fCapabilities; 502 ULONG dwReserved[4]; 503 } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS; 504 505 /* IDEREGS.bCommandReg constants */ 506 #define ATAPI_ID_CMD 0xA1 507 #define ID_CMD 0xEC 508 #define SMART_CMD 0xB0 509 510 #define SMART_CYL_LOW 0x4F 511 #define SMART_CYL_HI 0xC2 512 513 typedef struct _IDEREGS { 514 UCHAR bFeaturesReg; 515 UCHAR bSectorCountReg; 516 UCHAR bSectorNumberReg; 517 UCHAR bCylLowReg; 518 UCHAR bCylHighReg; 519 UCHAR bDriveHeadReg; 520 UCHAR bCommandReg; 521 UCHAR bReserved; 522 } IDEREGS, *PIDEREGS, *LPIDEREGS; 523 524 #include <pshpack1.h> 525 typedef struct _SENDCMDINPARAMS { 526 ULONG cBufferSize; 527 IDEREGS irDriveRegs; 528 UCHAR bDriveNumber; 529 UCHAR bReserved[3]; 530 ULONG dwReserved[4]; 531 UCHAR bBuffer[1]; 532 } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS; 533 #include <poppack.h> 534 535 /* DRIVERSTATUS.bDriverError constants */ 536 #define SMART_NO_ERROR 0 537 #define SMART_IDE_ERROR 1 538 #define SMART_INVALID_FLAG 2 539 #define SMART_INVALID_COMMAND 3 540 #define SMART_INVALID_BUFFER 4 541 #define SMART_INVALID_DRIVE 5 542 #define SMART_INVALID_IOCTL 6 543 #define SMART_ERROR_NO_MEM 7 544 #define SMART_INVALID_REGISTER 8 545 #define SMART_NOT_SUPPORTED 9 546 #define SMART_NO_IDE_DEVICE 10 547 548 #define SMART_OFFLINE_ROUTINE_OFFLINE 0 549 #define SMART_SHORT_SELFTEST_OFFLINE 1 550 #define SMART_EXTENDED_SELFTEST_OFFLINE 2 551 #define SMART_ABORT_OFFLINE_SELFTEST 127 552 #define SMART_SHORT_SELFTEST_CAPTIVE 129 553 #define SMART_EXTENDED_SELFTEST_CAPTIVE 130 554 555 typedef struct _DRIVERSTATUS { 556 UCHAR bDriverError; 557 UCHAR bIDEError; 558 UCHAR bReserved[2]; 559 ULONG dwReserved[2]; 560 } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS; 561 562 #define READ_ATTRIBUTE_BUFFER_SIZE 512 563 #define IDENTIFY_BUFFER_SIZE 512 564 #define READ_THRESHOLD_BUFFER_SIZE 512 565 #define SMART_LOG_SECTOR_SIZE 512 566 567 #include <pshpack1.h> 568 typedef struct _SENDCMDOUTPARAMS { 569 ULONG cBufferSize; 570 DRIVERSTATUS DriverStatus; 571 UCHAR bBuffer[1]; 572 } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS; 573 #include <poppack.h> 574 575 #define READ_ATTRIBUTES 0xD0 576 #define READ_THRESHOLDS 0xD1 577 #define ENABLE_DISABLE_AUTOSAVE 0xD2 578 #define SAVE_ATTRIBUTE_VALUES 0xD3 579 #define EXECUTE_OFFLINE_DIAGS 0xD4 580 #define SMART_READ_LOG 0xD5 581 #define SMART_WRITE_LOG 0xd6 582 #define ENABLE_SMART 0xD8 583 #define DISABLE_SMART 0xD9 584 #define RETURN_SMART_STATUS 0xDA 585 #define ENABLE_DISABLE_AUTO_OFFLINE 0xDB 586 587 typedef struct _MAPPED_ADDRESS { 588 struct _MAPPED_ADDRESS *NextMappedAddress; 589 PVOID MappedAddress; 590 ULONG NumberOfBytes; 591 LARGE_INTEGER IoAddress; 592 ULONG BusNumber; 593 } MAPPED_ADDRESS, *PMAPPED_ADDRESS; 594 595 596 #ifdef __cplusplus 597 } 598 #endif 599 600 #endif /* _NTDDDISK_H_ */ 601