| 1 |
/* |
| 2 |
* ddk/ntdddisk.h |
| 3 |
* |
| 4 |
* Driver Development Kit -- Disk IOCTL interface. |
| 5 |
* |
| 6 |
* Written by Casper S. Hornstrup <chorns@users.sourceforge.net> |
| 7 |
* Copyright (C) 2002-2004, 2015, 2016, MinGW.org Project. |
| 8 |
* |
| 9 |
* |
| 10 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 11 |
* copy of this software and associated documentation files (the "Software"), |
| 12 |
* to deal in the Software without restriction, including without limitation |
| 13 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 15 |
* Software is furnished to do so, subject to the following conditions: |
| 16 |
* |
| 17 |
* The above copyright notice, this permission notice, and the following |
| 18 |
* disclaimer shall be included in all copies or substantial portions of |
| 19 |
* the Software. |
| 20 |
* |
| 21 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 22 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 24 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 26 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER |
| 27 |
* DEALINGS IN THE SOFTWARE. |
| 28 |
* |
| 29 |
*/ |
| 30 |
#ifndef _DDK_NTDDDISK_H |
| 31 |
#pragma GCC system_header |
| 32 |
|
| 33 |
/* This file supports partial inclusion by <winioctl.h>; defer definition |
| 34 |
* of its normal repeat inclusion guard macro... |
| 35 |
*/ |
| 36 |
#ifndef __WINIOCTL_H_SOURCED__ |
| 37 |
/* ...until we've ascertained that this is NOT such partial inclusion. |
| 38 |
*/ |
| 39 |
#define _DDK_NTDDDISK_H |
| 40 |
|
| 41 |
/* In case of full inclusion, we must also include the full content of: |
| 42 |
*/ |
| 43 |
#include "ntddk.h" |
| 44 |
#endif |
| 45 |
|
| 46 |
/* In either case, we always include <ddk/ntddstor.h>, either in full, |
| 47 |
* or under the same criterion of selectivity as for this file itself. |
| 48 |
*/ |
| 49 |
#include "ntddstor.h" |
| 50 |
|
| 51 |
#if ! (defined _DDK_NTDDDISK_H && defined _WINIOCTL_H) |
| 52 |
/* The content of this section is common to both <ddk/ntdddisk.h> and |
| 53 |
* <winioctl.h>. If both repeat inclusion guards are already defined, |
| 54 |
* then we've already seen it; there is no need to process it again. |
| 55 |
*/ |
| 56 |
#define __IOCTL_DISK_(FN,M,A) CTL_CODE(IOCTL_DISK_BASE,(FN),(M),(A)) |
| 57 |
|
| 58 |
#define IOCTL_DISK_BASE FILE_TYPE_DISK |
| 59 |
#define IOCTL_DISK_GET_DRIVE_GEOMETRY __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0000) |
| 60 |
#define IOCTL_DISK_GET_PARTITION_INFO __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0001) |
| 61 |
#define IOCTL_DISK_SET_PARTITION_INFO __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0002) |
| 62 |
#define IOCTL_DISK_GET_DRIVE_LAYOUT __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0003) |
| 63 |
#define IOCTL_DISK_SET_DRIVE_LAYOUT __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0004) |
| 64 |
#define IOCTL_DISK_VERIFY __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0005) |
| 65 |
#define IOCTL_DISK_FORMAT_TRACKS __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0006) |
| 66 |
#define IOCTL_DISK_REASSIGN_BLOCKS __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0007) |
| 67 |
#define IOCTL_DISK_PERFORMANCE __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0008) |
| 68 |
#define IOCTL_DISK_IS_WRITABLE __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0009) |
| 69 |
#define IOCTL_DISK_FORMAT_TRACKS_EX __FILE_RW_BUFFERED(__IOCTL_DISK_,0x000B) |
| 70 |
#define IOCTL_DISK_GET_PARTITION_INFO_EX __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0012) |
| 71 |
#define IOCTL_DISK_SET_PARTITION_INFO_EX __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0013) |
| 72 |
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0014) |
| 73 |
#define IOCTL_DISK_SET_DRIVE_LAYOUT_EX __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0015) |
| 74 |
#define IOCTL_DISK_CREATE_DISK __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0016) |
| 75 |
#define IOCTL_DISK_GET_LENGTH_INFO __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0017) |
| 76 |
#define IOCTL_DISK_PERFORMANCE_OFF __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0018) |
| 77 |
#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0028) |
| 78 |
#define IOCTL_DISK_UPDATE_DRIVE_SIZE __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0032) |
| 79 |
#define IOCTL_DISK_GROW_PARTITION __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0034) |
| 80 |
#define IOCTL_DISK_GET_CACHE_INFORMATION __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0035) |
| 81 |
#define IOCTL_DISK_SET_CACHE_INFORMATION __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0036) |
| 82 |
#define IOCTL_DISK_DELETE_DRIVE_LAYOUT __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0040) |
| 83 |
#define IOCTL_DISK_CHECK_VERIFY __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0200) |
| 84 |
#define IOCTL_DISK_RESERVE __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0204) |
| 85 |
#define IOCTL_DISK_FIND_NEW_DEVICES __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0206) |
| 86 |
#define IOCTL_DISK_GET_MEDIA_TYPES __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0300) |
| 87 |
|
| 88 |
enum |
| 89 |
{ PARTITION_ENTRY_UNUSED = 0x00, |
| 90 |
PARTITION_FAT_12 = 0x01, |
| 91 |
PARTITION_XENIX_1 = 0x02, |
| 92 |
PARTITION_XENIX_2 = 0x03, |
| 93 |
PARTITION_FAT_16 = 0x04, |
| 94 |
PARTITION_EXTENDED = 0x05, |
| 95 |
PARTITION_HUGE = 0x06, |
| 96 |
PARTITION_IFS = 0x07, |
| 97 |
PARTITION_OS2BOOTMGR = 0x0A, |
| 98 |
PARTITION_FAT32 = 0x0B, |
| 99 |
PARTITION_FAT32_XINT13 = 0x0C, |
| 100 |
PARTITION_XINT13 = 0x0E, |
| 101 |
PARTITION_XINT13_EXTENDED = 0x0F, |
| 102 |
PARTITION_PREP = 0x41, |
| 103 |
PARTITION_LDM = 0x42, |
| 104 |
PARTITION_UNIX = 0x63, |
| 105 |
PARTITION_NTFT = 0x80, |
| 106 |
VALID_NTFT = 0xC0 |
| 107 |
}; |
| 108 |
|
| 109 |
#define IsRecognizedPartition( TYPE ) \ |
| 110 |
( (((TYPE) & PARTITION_NTFT) && (((TYPE) & ~VALID_NTFT) == PARTITION_FAT_12))\ |
| 111 |
|| (((TYPE) & PARTITION_NTFT) && (((TYPE) & ~VALID_NTFT) == PARTITION_HUGE))\ |
| 112 |
|| (((TYPE) & PARTITION_NTFT) && (((TYPE) & ~VALID_NTFT) == PARTITION_IFS))\ |
| 113 |
|| (((TYPE) & PARTITION_NTFT) && (((TYPE) & ~VALID_NTFT) == PARTITION_FAT32))\ |
| 114 |
|| (((TYPE) & PARTITION_NTFT) && (((TYPE) & ~VALID_NTFT) == PARTITION_FAT32_XINT13))\ |
| 115 |
|| (((TYPE) & PARTITION_NTFT) && (((TYPE) & ~VALID_NTFT) == PARTITION_XINT13))\ |
| 116 |
|| ((TYPE) == PARTITION_FAT32) || ((TYPE) == PARTITION_FAT32_XINT13)\ |
| 117 |
|| ((TYPE) == PARTITION_FAT_12) || ((TYPE) == PARTITION_FAT_16)\ |
| 118 |
|| ((TYPE) == PARTITION_HUGE) || ((TYPE) == PARTITION_IFS)\ |
| 119 |
|| ((TYPE) == PARTITION_XINT13)\ |
| 120 |
) |
| 121 |
#define IsContainerPartition( TYPE ) \ |
| 122 |
(((TYPE) == PARTITION_EXTENDED) || ((TYPE) == PARTITION_XINT13_EXTENDED)) |
| 123 |
|
| 124 |
typedef |
| 125 |
enum _MEDIA_TYPE |
| 126 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff562216(v=vs.85).aspx */ |
| 127 |
{ Unknown = 0x00, |
| 128 |
F5_1Pt2_512 = 0x01, |
| 129 |
F3_1Pt44_512 = 0x02, |
| 130 |
F3_2Pt88_512 = 0x03, |
| 131 |
F3_20Pt8_512 = 0x04, |
| 132 |
F3_720_512 = 0x05, |
| 133 |
F5_360_512 = 0x06, |
| 134 |
F5_320_512 = 0x07, |
| 135 |
F5_320_1024 = 0x08, |
| 136 |
F5_180_512 = 0x09, |
| 137 |
F5_160_512 = 0x0A, |
| 138 |
RemovableMedia = 0x0B, |
| 139 |
FixedMedia = 0x0C, |
| 140 |
F3_120M_512 = 0x0D, |
| 141 |
F3_640_512 = 0x0E, |
| 142 |
F5_640_512 = 0x0F, |
| 143 |
F5_720_512 = 0x10, |
| 144 |
F3_1Pt2_512 = 0x11, |
| 145 |
F3_1Pt23_1024 = 0x12, |
| 146 |
F5_1Pt23_1024 = 0x13, |
| 147 |
F3_128Mb_512 = 0x14, |
| 148 |
F3_230Mb_512 = 0x15, |
| 149 |
F8_256_128 = 0x16, |
| 150 |
F3_200Mb_512 = 0x17, |
| 151 |
F3_240M_512 = 0x18, |
| 152 |
F3_32M_512 = 0x19 |
| 153 |
} MEDIA_TYPE, *PMEDIA_TYPE; |
| 154 |
|
| 155 |
typedef |
| 156 |
enum _DETECTION_TYPE |
| 157 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552516%28v=vs.85%29.aspx */ |
| 158 |
{ DetectNone = 0, |
| 159 |
DetectInt13 = 1, |
| 160 |
DetectExInt13 = 2 |
| 161 |
} DETECTION_TYPE; |
| 162 |
|
| 163 |
typedef |
| 164 |
struct _DISK_INT13_INFO |
| 165 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552624(v=vs.85).aspx */ |
| 166 |
{ USHORT DriveSelect; |
| 167 |
ULONG MaxCylinders; |
| 168 |
USHORT SectorsPerTrack; |
| 169 |
USHORT MaxHeads; |
| 170 |
USHORT NumberDrives; |
| 171 |
} DISK_INT13_INFO, *PDISK_INT13_INFO; |
| 172 |
|
| 173 |
typedef |
| 174 |
struct _DISK_EX_INT13_INFO |
| 175 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552610(v=vs.85).aspx */ |
| 176 |
{ USHORT ExBufferSize; |
| 177 |
USHORT ExFlags; |
| 178 |
ULONG ExCylinders; |
| 179 |
ULONG ExHeads; |
| 180 |
ULONG ExSectorsPerTrack; |
| 181 |
ULONG64 ExSectorsPerDrive; |
| 182 |
USHORT ExSectorSize; |
| 183 |
USHORT ExReserved; |
| 184 |
} DISK_EX_INT13_INFO, *PDISK_EX_INT13_INFO; |
| 185 |
|
| 186 |
typedef |
| 187 |
struct _DISK_DETECTION_INFO |
| 188 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552601(v=vs.85).aspx */ |
| 189 |
{ ULONG SizeOfDetectInfo; |
| 190 |
DETECTION_TYPE DetectionType; |
| 191 |
_ANONYMOUS_UNION union |
| 192 |
{ _ANONYMOUS_STRUCT struct |
| 193 |
{ DISK_INT13_INFO Int13; |
| 194 |
DISK_EX_INT13_INFO ExInt13; |
| 195 |
} DUMMYSTRUCTNAME; |
| 196 |
} DUMMYUNIONNAME; |
| 197 |
} DISK_DETECTION_INFO, *PDISK_DETECTION_INFO; |
| 198 |
|
| 199 |
typedef |
| 200 |
struct _DISK_GEOMETRY |
| 201 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552613(v=vs.85).aspx */ |
| 202 |
{ LARGE_INTEGER Cylinders; |
| 203 |
MEDIA_TYPE MediaType; |
| 204 |
ULONG TracksPerCylinder; |
| 205 |
ULONG SectorsPerTrack; |
| 206 |
ULONG BytesPerSector; |
| 207 |
} DISK_GEOMETRY, *PDISK_GEOMETRY; |
| 208 |
|
| 209 |
typedef |
| 210 |
struct _DISK_GEOMETRY_EX |
| 211 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552618(v=vs.85).aspx */ |
| 212 |
{ DISK_GEOMETRY Geometry; |
| 213 |
LARGE_INTEGER DiskSize; |
| 214 |
UCHAR Data[1]; |
| 215 |
} DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX; |
| 216 |
|
| 217 |
/* Note: although declared as an array of only one byte, the Data area within |
| 218 |
* the DISK_GEOMETRY_EX structure represents a variable size region containing |
| 219 |
* a DISK_PARTITION_INFO structure followed by a DISK_DETECTION_INFO structure; |
| 220 |
* the above <ddk/ntdddisk.h> reference defines the following pair of macros, |
| 221 |
* for obtaining pointers to the embedded structures, given a pointer to the |
| 222 |
* containing DISK_GEOMETRY_EX structure itself; (the corresponding reference |
| 223 |
* for <winioctl.h> refers to these macros, without defining them). |
| 224 |
*/ |
| 225 |
#if NTDDI_VERSION < NTDDI_WS03 |
| 226 |
/* FIXME: given the above definition for DISK_GEOMETRY_EX, this pair of |
| 227 |
* macro definitions makes no sense at all... |
| 228 |
*/ |
| 229 |
# define DiskGeometryGetPartition(Geometry) \ |
| 230 |
((PDISK_PARTITION_INFO)((Geometry) + 1)) |
| 231 |
|
| 232 |
# define DiskGeometryGetDetect(Geometry) \ |
| 233 |
((PDISK_DETECTION_INFO)(((PBYTE)DiskGeometryGetPartition(Geometry) + \ |
| 234 |
DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo))) |
| 235 |
#else |
| 236 |
/* ...whereas this pair would seem to be appropriate, regardless of the |
| 237 |
* underlying NTDDI_VERSION. |
| 238 |
*/ |
| 239 |
# define DiskGeometryGetPartition(Geometry) \ |
| 240 |
((PDISK_PARTITION_INFO)((Geometry)->Data)) |
| 241 |
|
| 242 |
# define DiskGeometryGetDetect(Geometry) \ |
| 243 |
((PDISK_DETECTION_INFO)(((ULONG_PTR)DiskGeometryGetPartition(Geometry) + \ |
| 244 |
DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo))) |
| 245 |
#endif |
| 246 |
|
| 247 |
typedef |
| 248 |
struct _PARTITION_INFORMATION |
| 249 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff563751(v=vs.85).aspx */ |
| 250 |
{ LARGE_INTEGER StartingOffset; |
| 251 |
LARGE_INTEGER PartitionLength; |
| 252 |
ULONG HiddenSectors; |
| 253 |
ULONG PartitionNumber; |
| 254 |
UCHAR PartitionType; |
| 255 |
BOOLEAN BootIndicator; |
| 256 |
BOOLEAN RecognizedPartition; |
| 257 |
BOOLEAN RewritePartition; |
| 258 |
} PARTITION_INFORMATION, *PPARTITION_INFORMATION; |
| 259 |
|
| 260 |
typedef |
| 261 |
struct _PARTITION_INFORMATION_GPT |
| 262 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff563763(v=vs.85).aspx */ |
| 263 |
{ GUID PartitionType; |
| 264 |
GUID PartitionId; |
| 265 |
ULONG64 Attributes; |
| 266 |
WCHAR Name[36]; |
| 267 |
} PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT; |
| 268 |
|
| 269 |
typedef |
| 270 |
struct _DISK_PARTITION_INFO |
| 271 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552629(v=vs.85).aspx */ |
| 272 |
{ ULONG SizeOfPartitionInfo; |
| 273 |
PARTITION_STYLE PartitionStyle; |
| 274 |
_ANONYMOUS_UNION union |
| 275 |
{ struct |
| 276 |
{ ULONG Signature; |
| 277 |
ULONG CheckSum; |
| 278 |
} Mbr; |
| 279 |
struct |
| 280 |
{ GUID DiskId; |
| 281 |
} Gpt; |
| 282 |
} DUMMYUNIONNAME; |
| 283 |
} DISK_PARTITION_INFO, *PDISK_PARTITION_INFO; |
| 284 |
|
| 285 |
typedef |
| 286 |
struct _DISK_PERFORMANCE |
| 287 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552633(v=vs.85).aspx */ |
| 288 |
{ LARGE_INTEGER BytesRead; |
| 289 |
LARGE_INTEGER BytesWritten; |
| 290 |
LARGE_INTEGER ReadTime; |
| 291 |
LARGE_INTEGER WriteTime; |
| 292 |
LARGE_INTEGER IdleTime; |
| 293 |
ULONG ReadCount; |
| 294 |
ULONG WriteCount; |
| 295 |
ULONG QueueDepth; |
| 296 |
ULONG SplitCount; |
| 297 |
LARGE_INTEGER QueryTime; |
| 298 |
ULONG StorageDeviceNumber; |
| 299 |
WCHAR StorageManagerName[8]; |
| 300 |
} DISK_PERFORMANCE, *PDISK_PERFORMANCE; |
| 301 |
|
| 302 |
typedef |
| 303 |
struct _PARTITION_INFORMATION_EX |
| 304 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff563754(v=vs.85).aspx */ |
| 305 |
{ PARTITION_STYLE PartitionStyle; |
| 306 |
LARGE_INTEGER StartingOffset; |
| 307 |
LARGE_INTEGER PartitionLength; |
| 308 |
ULONG PartitionNumber; |
| 309 |
BOOLEAN RewritePartition; |
| 310 |
_ANONYMOUS_UNION union |
| 311 |
{ PARTITION_INFORMATION_MBR Mbr; |
| 312 |
PARTITION_INFORMATION_GPT Gpt; |
| 313 |
} DUMMYUNIONNAME; |
| 314 |
} PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX; |
| 315 |
|
| 316 |
typedef |
| 317 |
struct _FORMAT_EX_PARAMETERS |
| 318 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff553875(v=vs.85).aspx */ |
| 319 |
{ MEDIA_TYPE MediaType; |
| 320 |
ULONG StartCylinderNumber; |
| 321 |
ULONG EndCylinderNumber; |
| 322 |
ULONG StartHeadNumber; |
| 323 |
ULONG EndHeadNumber; |
| 324 |
USHORT FormatGapLength; |
| 325 |
USHORT SectorsPerTrack; |
| 326 |
USHORT SectorNumber[1]; |
| 327 |
} FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS; |
| 328 |
|
| 329 |
typedef |
| 330 |
struct _FORMAT_PARAMETERS |
| 331 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff553878(v=vs.85).aspx */ |
| 332 |
{ MEDIA_TYPE MediaType; |
| 333 |
ULONG StartCylinderNumber; |
| 334 |
ULONG EndCylinderNumber; |
| 335 |
ULONG StartHeadNumber; |
| 336 |
ULONG EndHeadNumber; |
| 337 |
} FORMAT_PARAMETERS, *PFORMAT_PARAMETERS; |
| 338 |
|
| 339 |
typedef |
| 340 |
struct _GET_LENGTH_INFORMATION |
| 341 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff554986(v=vs.85).aspx */ |
| 342 |
{ LARGE_INTEGER Length; |
| 343 |
} GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION; |
| 344 |
|
| 345 |
typedef |
| 346 |
struct _REASSIGN_BLOCKS |
| 347 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff563962(v=vs.85).aspx */ |
| 348 |
{ USHORT Reserved; |
| 349 |
USHORT Count; |
| 350 |
ULONG BlockNumber[1]; |
| 351 |
} REASSIGN_BLOCKS, *PREASSIGN_BLOCKS; |
| 352 |
|
| 353 |
typedef |
| 354 |
struct _SET_PARTITION_INFORMATION |
| 355 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff566192(v=vs.85).aspx */ |
| 356 |
{ UCHAR PartitionType; |
| 357 |
} SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION; |
| 358 |
|
| 359 |
typedef |
| 360 |
struct _VERIFY_INFORMATION |
| 361 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff568005(v=vs.85).aspx */ |
| 362 |
{ LARGE_INTEGER StartingOffset; |
| 363 |
ULONG Length; |
| 364 |
} VERIFY_INFORMATION, *PVERIFY_INFORMATION; |
| 365 |
|
| 366 |
typedef enum |
| 367 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552583(v=vs.85).aspx */ |
| 368 |
{ EqualPriority = 0, |
| 369 |
KeepPrefetchedData = 1, |
| 370 |
KeepReadData = 2 |
| 371 |
} DISK_CACHE_RETENTION_PRIORITY; |
| 372 |
|
| 373 |
typedef |
| 374 |
struct _DISK_CACHE_INFORMATION |
| 375 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552580(v=vs.85).aspx */ |
| 376 |
{ BOOLEAN ParametersSavable; |
| 377 |
BOOLEAN ReadCacheEnabled; |
| 378 |
BOOLEAN WriteCacheEnabled; |
| 379 |
DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority; |
| 380 |
DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority; |
| 381 |
USHORT DisablePrefetchTransferLength; |
| 382 |
BOOLEAN PrefetchScalar; |
| 383 |
_ANONYMOUS_UNION union |
| 384 |
{ struct |
| 385 |
{ USHORT Minimum; |
| 386 |
USHORT Maximum; |
| 387 |
USHORT MaximumBlocks; |
| 388 |
} ScalarPrefetch; |
| 389 |
struct |
| 390 |
{ USHORT Minimum; |
| 391 |
USHORT Maximum; |
| 392 |
} BlockPrefetch; |
| 393 |
} DUMMYUNIONNAME; |
| 394 |
} DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION; |
| 395 |
|
| 396 |
typedef |
| 397 |
struct _DISK_GROW_PARTITION |
| 398 |
/* https://msdn.microsoft.com/en-us/library/windows/hardware/ff552621(v=vs.85).aspx */ |
| 399 |
{ ULONG PartitionNumber; |
| 400 |
LARGE_INTEGER BytesToGrow; |
| 401 |
} DISK_GROW_PARTITION, *PDISK_GROW_PARTITION; |
| 402 |
|
| 403 |
/* End of _DDK_NTDDDISK_H and _WINIOCTL_H common declarations. |
| 404 |
*/ |
| 405 |
#endif |
| 406 |
#ifdef _DDK_NTDDDISK_H |
| 407 |
/* Declarations specific to _DDK_NTDDDISK_H alone. |
| 408 |
*/ |
| 409 |
_BEGIN_C_DECLS |
| 410 |
|
| 411 |
#define DD_DISK_DEVICE_NAME "\\Device\\UNKNOWN" |
| 412 |
#define DD_DISK_DEVICE_NAME_U L"\\Device\\UNKNOWN" |
| 413 |
|
| 414 |
#define IOCTL_DISK_CONTROLLER_NUMBER __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0011) |
| 415 |
#define IOCTL_DISK_INTERNAL_SET_VERIFY __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0100) |
| 416 |
#define IOCTL_DISK_INTERNAL_CLEAR_VERIFY __FILE_AM_BUFFERED(__IOCTL_DISK_,0x0101) |
| 417 |
|
| 418 |
#define SMART_GET_VERSION __FILE_RD_BUFFERED(__IOCTL_DISK_,0x0020) |
| 419 |
#define SMART_RCV_DRIVE_DATA __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0022) |
| 420 |
#define SMART_SEND_DRIVE_COMMAND __FILE_RW_BUFFERED(__IOCTL_DISK_,0x0021) |
| 421 |
|
| 422 |
#define IsFTPartition( PartitionType ) \ |
| 423 |
(((PartitionType) & PARTITION_NTFT) && IsRecognizedPartition(PartitionType)) |
| 424 |
|
| 425 |
DEFINE_GUID( WMI_DISK_GEOMETRY_GUID, |
| 426 |
0x25007f51L, 0x57c2, 0x11d1, 0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10 |
| 427 |
); |
| 428 |
|
| 429 |
typedef USHORT BAD_TRACK_NUMBER; |
| 430 |
typedef USHORT *PBAD_TRACK_NUMBER; |
| 431 |
|
| 432 |
typedef |
| 433 |
struct _DISK_CONTROLLER_NUMBER |
| 434 |
{ ULONG ControllerNumber; |
| 435 |
ULONG DiskNumber; |
| 436 |
} DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER; |
| 437 |
|
| 438 |
typedef SET_PARTITION_INFORMATION SET_PARTITION_INFORMATION_MBR; |
| 439 |
typedef PARTITION_INFORMATION_GPT SET_PARTITION_INFORMATION_GPT; |
| 440 |
|
| 441 |
typedef |
| 442 |
struct _SET_PARTITION_INFORMATION_EX |
| 443 |
{ PARTITION_STYLE PartitionStyle; |
| 444 |
_ANONYMOUS_UNION union |
| 445 |
{ SET_PARTITION_INFORMATION_MBR Mbr; |
| 446 |
SET_PARTITION_INFORMATION_GPT Gpt; |
| 447 |
} DUMMYUNIONNAME; |
| 448 |
} SET_PARTITION_INFORMATION_EX, *PSET_PARTITION_INFORMATION_EX; |
| 449 |
|
| 450 |
/* GETVERSIONINPARAMS.fCapabilities constants |
| 451 |
*/ |
| 452 |
#define CAP_ATA_ID_CMD 1 |
| 453 |
#define CAP_ATAPI_ID_CMD 2 |
| 454 |
#define CAP_SMART_CMD 4 |
| 455 |
|
| 456 |
typedef |
| 457 |
struct _GETVERSIONINPARAMS |
| 458 |
{ UCHAR bVersion; |
| 459 |
UCHAR bRevision; |
| 460 |
UCHAR bReserved; |
| 461 |
UCHAR bIDEDeviceMap; |
| 462 |
ULONG fCapabilities; |
| 463 |
ULONG dwReserved[4]; |
| 464 |
} GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS; |
| 465 |
|
| 466 |
/* IDEREGS.bCommandReg constants |
| 467 |
*/ |
| 468 |
#define ATAPI_ID_CMD 0xA1 |
| 469 |
#define ID_CMD 0xEC |
| 470 |
#define SMART_CMD 0xB0 |
| 471 |
|
| 472 |
#define SMART_CYL_LOW 0x4F |
| 473 |
#define SMART_CYL_HI 0xC2 |
| 474 |
|
| 475 |
typedef |
| 476 |
struct _IDEREGS |
| 477 |
{ UCHAR bFeaturesReg; |
| 478 |
UCHAR bSectorCountReg; |
| 479 |
UCHAR bSectorNumberReg; |
| 480 |
UCHAR bCylLowReg; |
| 481 |
UCHAR bCylHighReg; |
| 482 |
UCHAR bDriveHeadReg; |
| 483 |
UCHAR bCommandReg; |
| 484 |
UCHAR bReserved; |
| 485 |
} IDEREGS, *PIDEREGS, *LPIDEREGS; |
| 486 |
|
| 487 |
#include <pshpack1.h> |
| 488 |
typedef |
| 489 |
struct _SENDCMDINPARAMS |
| 490 |
{ ULONG cBufferSize; |
| 491 |
IDEREGS irDriveRegs; |
| 492 |
UCHAR bDriveNumber; |
| 493 |
UCHAR bReserved[3]; |
| 494 |
ULONG dwReserved[4]; |
| 495 |
UCHAR bBuffer[1]; |
| 496 |
} SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS; |
| 497 |
#include <poppack.h> |
| 498 |
|
| 499 |
/* DRIVERSTATUS.bDriverError constants |
| 500 |
*/ |
| 501 |
#define SMART_NO_ERROR 0 |
| 502 |
#define SMART_IDE_ERROR 1 |
| 503 |
#define SMART_INVALID_FLAG 2 |
| 504 |
#define SMART_INVALID_COMMAND 3 |
| 505 |
#define SMART_INVALID_BUFFER 4 |
| 506 |
#define SMART_INVALID_DRIVE 5 |
| 507 |
#define SMART_INVALID_IOCTL 6 |
| 508 |
#define SMART_ERROR_NO_MEM 7 |
| 509 |
#define SMART_INVALID_REGISTER 8 |
| 510 |
#define SMART_NOT_SUPPORTED 9 |
| 511 |
#define SMART_NO_IDE_DEVICE 10 |
| 512 |
|
| 513 |
#define SMART_OFFLINE_ROUTINE_OFFLINE 0 |
| 514 |
#define SMART_SHORT_SELFTEST_OFFLINE 1 |
| 515 |
#define SMART_EXTENDED_SELFTEST_OFFLINE 2 |
| 516 |
#define SMART_ABORT_OFFLINE_SELFTEST 127 |
| 517 |
#define SMART_SHORT_SELFTEST_CAPTIVE 129 |
| 518 |
#define SMART_EXTENDED_SELFTEST_CAPTIVE 130 |
| 519 |
|
| 520 |
typedef |
| 521 |
struct _DRIVERSTATUS |
| 522 |
{ UCHAR bDriverError; |
| 523 |
UCHAR bIDEError; |
| 524 |
UCHAR bReserved[2]; |
| 525 |
ULONG dwReserved[2]; |
| 526 |
} DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS; |
| 527 |
|
| 528 |
#define READ_ATTRIBUTE_BUFFER_SIZE 512 |
| 529 |
#define IDENTIFY_BUFFER_SIZE 512 |
| 530 |
#define READ_THRESHOLD_BUFFER_SIZE 512 |
| 531 |
#define SMART_LOG_SECTOR_SIZE 512 |
| 532 |
|
| 533 |
#include <pshpack1.h> |
| 534 |
typedef |
| 535 |
struct _SENDCMDOUTPARAMS |
| 536 |
{ ULONG cBufferSize; |
| 537 |
DRIVERSTATUS DriverStatus; |
| 538 |
UCHAR bBuffer[1]; |
| 539 |
} SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS; |
| 540 |
#include <poppack.h> |
| 541 |
|
| 542 |
#define READ_ATTRIBUTES 0xD0 |
| 543 |
#define READ_THRESHOLDS 0xD1 |
| 544 |
#define ENABLE_DISABLE_AUTOSAVE 0xD2 |
| 545 |
#define SAVE_ATTRIBUTE_VALUES 0xD3 |
| 546 |
#define EXECUTE_OFFLINE_DIAGS 0xD4 |
| 547 |
#define SMART_READ_LOG 0xD5 |
| 548 |
#define SMART_WRITE_LOG 0xd6 |
| 549 |
#define ENABLE_SMART 0xD8 |
| 550 |
#define DISABLE_SMART 0xD9 |
| 551 |
#define RETURN_SMART_STATUS 0xDA |
| 552 |
#define ENABLE_DISABLE_AUTO_OFFLINE 0xDB |
| 553 |
|
| 554 |
_END_C_DECLS |
| 555 |
|
| 556 |
#endif /* _DDK_NTDDDISK_H */ |
| 557 |
#endif /* !_DDK_NTDDDISK_H: $RCSfile: ntdddisk.h,v $: end of file */ |