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