[SDK] One step further towards ReactOS source code tree restructure: the sdk folder...
[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 #endif
227
228 #define IsFTPartition( PartitionType ) \
229 (((PartitionType) & PARTITION_NTFT) && \
230 IsRecognizedPartition(PartitionType))
231
232 #define IsContainerPartition(PartitionType) \
233 (((PartitionType) == PARTITION_EXTENDED) || \
234 ((PartitionType) == PARTITION_XINT13_EXTENDED))
235
236 #ifdef __REACTOS__
237 #define IsRecognizedPartition(PartitionType) ( \
238 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT_12)) || \
239 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_HUGE)) || \
240 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_IFS)) || \
241 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32)) || \
242 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32_XINT13)) || \
243 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_XINT13)) || \
244 ((PartitionType) == PARTITION_FAT_12) || \
245 ((PartitionType) == PARTITION_FAT_16) || \
246 ((PartitionType) == PARTITION_HUGE) || \
247 ((PartitionType) == PARTITION_IFS) || \
248 ((PartitionType) == PARTITION_FAT32) || \
249 ((PartitionType) == PARTITION_FAT32_XINT13) || \
250 ((PartitionType) == PARTITION_XINT13) || \
251 ((PartitionType) == PARTITION_LINUX) || \
252 ((PartitionType) == PARTITION_OLD_LINUX))
253 #else
254 #define IsRecognizedPartition(PartitionType) ( \
255 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT_12)) || \
256 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_HUGE)) || \
257 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_IFS)) || \
258 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32)) || \
259 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32_XINT13)) || \
260 (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_XINT13)) || \
261 ((PartitionType) == PARTITION_FAT_12) || \
262 ((PartitionType) == PARTITION_FAT_16) || \
263 ((PartitionType) == PARTITION_HUGE) || \
264 ((PartitionType) == PARTITION_IFS) || \
265 ((PartitionType) == PARTITION_FAT32) || \
266 ((PartitionType) == PARTITION_FAT32_XINT13) || \
267 ((PartitionType) == PARTITION_XINT13))
268 #endif
269
270 #if(_WIN32_WINNT >= 0x0500)
271 #define GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY 0x10000000
272 #define GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY 0x20000000
273 #define GPT_BASIC_DATA_ATTRIBUTE_HIDDEN 0x40000000
274 #define GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER 0x80000000
275 #endif
276
277 #define WMI_DISK_GEOMETRY_GUID \
278 {0x25007f51, 0x57c2, 0x11d1, {0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10}}
279
280 typedef USHORT BAD_TRACK_NUMBER;
281 typedef USHORT *PBAD_TRACK_NUMBER;
282
283 typedef enum _MEDIA_TYPE {
284 Unknown,
285 F5_1Pt2_512,
286 F3_1Pt44_512,
287 F3_2Pt88_512,
288 F3_20Pt8_512,
289 F3_720_512,
290 F5_360_512,
291 F5_320_512,
292 F5_320_1024,
293 F5_180_512,
294 F5_160_512,
295 RemovableMedia,
296 FixedMedia,
297 F3_120M_512,
298 F3_640_512,
299 F5_640_512,
300 F5_720_512,
301 F3_1Pt2_512,
302 F3_1Pt23_1024,
303 F5_1Pt23_1024,
304 F3_128Mb_512,
305 F3_230Mb_512,
306 F8_256_128
307 } MEDIA_TYPE, *PMEDIA_TYPE;
308
309 typedef enum _DETECTION_TYPE {
310 DetectNone,
311 DetectInt13,
312 DetectExInt13
313 } DETECTION_TYPE;
314
315 typedef struct _DISK_CONTROLLER_NUMBER {
316 ULONG ControllerNumber;
317 ULONG DiskNumber;
318 } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
319
320 typedef struct _DISK_INT13_INFO {
321 USHORT DriveSelect;
322 ULONG MaxCylinders;
323 USHORT SectorsPerTrack;
324 USHORT MaxHeads;
325 USHORT NumberDrives;
326 } DISK_INT13_INFO, *PDISK_INT13_INFO;
327
328 typedef struct _DISK_EX_INT13_INFO {
329 USHORT ExBufferSize;
330 USHORT ExFlags;
331 ULONG ExCylinders;
332 ULONG ExHeads;
333 ULONG ExSectorsPerTrack;
334 ULONG64 ExSectorsPerDrive;
335 USHORT ExSectorSize;
336 USHORT ExReserved;
337 } DISK_EX_INT13_INFO, *PDISK_EX_INT13_INFO;
338
339 typedef struct _DISK_DETECTION_INFO {
340 ULONG SizeOfDetectInfo;
341 DETECTION_TYPE DetectionType;
342 _ANONYMOUS_UNION union {
343 _ANONYMOUS_STRUCT struct {
344 DISK_INT13_INFO Int13;
345 DISK_EX_INT13_INFO ExInt13;
346 } DUMMYSTRUCTNAME;
347 } DUMMYUNIONNAME;
348 } DISK_DETECTION_INFO, *PDISK_DETECTION_INFO;
349
350 typedef struct _DISK_GEOMETRY {
351 LARGE_INTEGER Cylinders;
352 MEDIA_TYPE MediaType;
353 ULONG TracksPerCylinder;
354 ULONG SectorsPerTrack;
355 ULONG BytesPerSector;
356 } DISK_GEOMETRY, *PDISK_GEOMETRY;
357
358 typedef struct _DISK_GEOMETRY_EX {
359 DISK_GEOMETRY Geometry;
360 LARGE_INTEGER DiskSize;
361 UCHAR Data[1];
362 } DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX;
363
364 #define DiskGeometryGetPartition(Geometry) \
365 ((PDISK_PARTITION_INFO)((Geometry) + 1))
366
367 #define DiskGeometryGetDetect(Geometry)\
368 ((PDISK_DETECTION_INFO)(((PBYTE)DiskGeometryGetPartition(Geometry) + \
369 DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo)))
370
371 typedef struct _PARTITION_INFORMATION {
372 LARGE_INTEGER StartingOffset;
373 LARGE_INTEGER PartitionLength;
374 ULONG HiddenSectors;
375 ULONG PartitionNumber;
376 UCHAR PartitionType;
377 BOOLEAN BootIndicator;
378 BOOLEAN RecognizedPartition;
379 BOOLEAN RewritePartition;
380 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
381
382 typedef struct _PARTITION_INFORMATION_GPT {
383 GUID PartitionType;
384 GUID PartitionId;
385 ULONG64 Attributes;
386 WCHAR Name [36];
387 } PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT;
388
389 typedef enum _PARTITION_STYLE {
390 PARTITION_STYLE_MBR,
391 PARTITION_STYLE_GPT,
392 PARTITION_STYLE_RAW
393 } PARTITION_STYLE;
394
395 typedef struct _DISK_PARTITION_INFO {
396 ULONG SizeOfPartitionInfo;
397 PARTITION_STYLE PartitionStyle;
398 _ANONYMOUS_UNION union {
399 struct {
400 ULONG Signature;
401 ULONG CheckSum;
402 } Mbr;
403 struct {
404 GUID DiskId;
405 } Gpt;
406 } DUMMYUNIONNAME;
407 } DISK_PARTITION_INFO, *PDISK_PARTITION_INFO;
408
409 typedef struct _DISK_PERFORMANCE {
410 LARGE_INTEGER BytesRead;
411 LARGE_INTEGER BytesWritten;
412 LARGE_INTEGER ReadTime;
413 LARGE_INTEGER WriteTime;
414 LARGE_INTEGER IdleTime;
415 ULONG ReadCount;
416 ULONG WriteCount;
417 ULONG QueueDepth;
418 ULONG SplitCount;
419 LARGE_INTEGER QueryTime;
420 ULONG StorageDeviceNumber;
421 WCHAR StorageManagerName[8];
422 } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
423
424 typedef struct _PARTITION_INFORMATION_MBR {
425 UCHAR PartitionType;
426 BOOLEAN BootIndicator;
427 BOOLEAN RecognizedPartition;
428 ULONG HiddenSectors;
429 } PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR;
430
431 typedef struct _PARTITION_INFORMATION_EX {
432 PARTITION_STYLE PartitionStyle;
433 LARGE_INTEGER StartingOffset;
434 LARGE_INTEGER PartitionLength;
435 ULONG PartitionNumber;
436 BOOLEAN RewritePartition;
437 _ANONYMOUS_UNION union {
438 PARTITION_INFORMATION_MBR Mbr;
439 PARTITION_INFORMATION_GPT Gpt;
440 } DUMMYUNIONNAME;
441 } PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX;
442
443 typedef struct _DRIVE_LAYOUT_INFORMATION {
444 ULONG PartitionCount;
445 ULONG Signature;
446 PARTITION_INFORMATION PartitionEntry[1];
447 } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
448
449 typedef struct _DRIVE_LAYOUT_INFORMATION_MBR {
450 ULONG Signature;
451 } DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR;
452
453 typedef struct _DRIVE_LAYOUT_INFORMATION_GPT {
454 GUID DiskId;
455 LARGE_INTEGER StartingUsableOffset;
456 LARGE_INTEGER UsableLength;
457 ULONG MaxPartitionCount;
458 } DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT;
459
460 typedef struct _DRIVE_LAYOUT_INFORMATION_EX {
461 ULONG PartitionStyle;
462 ULONG PartitionCount;
463 __GNU_EXTENSION union {
464 DRIVE_LAYOUT_INFORMATION_MBR Mbr;
465 DRIVE_LAYOUT_INFORMATION_GPT Gpt;
466 };
467 PARTITION_INFORMATION_EX PartitionEntry[1];
468 } DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX;
469
470 typedef struct _FORMAT_EX_PARAMETERS {
471 MEDIA_TYPE MediaType;
472 ULONG StartCylinderNumber;
473 ULONG EndCylinderNumber;
474 ULONG StartHeadNumber;
475 ULONG EndHeadNumber;
476 USHORT FormatGapLength;
477 USHORT SectorsPerTrack;
478 USHORT SectorNumber[1];
479 } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
480
481 typedef struct _FORMAT_PARAMETERS {
482 MEDIA_TYPE MediaType;
483 ULONG StartCylinderNumber;
484 ULONG EndCylinderNumber;
485 ULONG StartHeadNumber;
486 ULONG EndHeadNumber;
487 } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
488
489 typedef struct _GET_LENGTH_INFORMATION {
490 LARGE_INTEGER Length;
491 } GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION;
492
493 typedef struct _REASSIGN_BLOCKS {
494 USHORT Reserved;
495 USHORT Count;
496 ULONG BlockNumber[1];
497 } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
498
499 typedef struct _SET_PARTITION_INFORMATION {
500 UCHAR PartitionType;
501 } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
502
503 typedef SET_PARTITION_INFORMATION SET_PARTITION_INFORMATION_MBR;
504 typedef PARTITION_INFORMATION_GPT SET_PARTITION_INFORMATION_GPT;
505
506 typedef struct _SET_PARTITION_INFORMATION_EX {
507 PARTITION_STYLE PartitionStyle;
508 _ANONYMOUS_UNION union {
509 SET_PARTITION_INFORMATION_MBR Mbr;
510 SET_PARTITION_INFORMATION_GPT Gpt;
511 } DUMMYUNIONNAME;
512 } SET_PARTITION_INFORMATION_EX, *PSET_PARTITION_INFORMATION_EX;
513
514 typedef struct _VERIFY_INFORMATION {
515 LARGE_INTEGER StartingOffset;
516 ULONG Length;
517 } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
518
519 /* GETVERSIONINPARAMS.fCapabilities constants */
520 #define CAP_ATA_ID_CMD 1
521 #define CAP_ATAPI_ID_CMD 2
522 #define CAP_SMART_CMD 4
523
524 typedef struct _GETVERSIONINPARAMS {
525 UCHAR bVersion;
526 UCHAR bRevision;
527 UCHAR bReserved;
528 UCHAR bIDEDeviceMap;
529 ULONG fCapabilities;
530 ULONG dwReserved[4];
531 } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
532
533 /* IDEREGS.bCommandReg constants */
534 #define ATAPI_ID_CMD 0xA1
535 #define ID_CMD 0xEC
536 #define SMART_CMD 0xB0
537
538 #define SMART_CYL_LOW 0x4F
539 #define SMART_CYL_HI 0xC2
540
541 typedef struct _IDEREGS {
542 UCHAR bFeaturesReg;
543 UCHAR bSectorCountReg;
544 UCHAR bSectorNumberReg;
545 UCHAR bCylLowReg;
546 UCHAR bCylHighReg;
547 UCHAR bDriveHeadReg;
548 UCHAR bCommandReg;
549 UCHAR bReserved;
550 } IDEREGS, *PIDEREGS, *LPIDEREGS;
551
552 #include <pshpack1.h>
553 typedef struct _SENDCMDINPARAMS {
554 ULONG cBufferSize;
555 IDEREGS irDriveRegs;
556 UCHAR bDriveNumber;
557 UCHAR bReserved[3];
558 ULONG dwReserved[4];
559 UCHAR bBuffer[1];
560 } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
561 #include <poppack.h>
562
563 /* DRIVERSTATUS.bDriverError constants */
564 #define SMART_NO_ERROR 0
565 #define SMART_IDE_ERROR 1
566 #define SMART_INVALID_FLAG 2
567 #define SMART_INVALID_COMMAND 3
568 #define SMART_INVALID_BUFFER 4
569 #define SMART_INVALID_DRIVE 5
570 #define SMART_INVALID_IOCTL 6
571 #define SMART_ERROR_NO_MEM 7
572 #define SMART_INVALID_REGISTER 8
573 #define SMART_NOT_SUPPORTED 9
574 #define SMART_NO_IDE_DEVICE 10
575
576 #define SMART_OFFLINE_ROUTINE_OFFLINE 0
577 #define SMART_SHORT_SELFTEST_OFFLINE 1
578 #define SMART_EXTENDED_SELFTEST_OFFLINE 2
579 #define SMART_ABORT_OFFLINE_SELFTEST 127
580 #define SMART_SHORT_SELFTEST_CAPTIVE 129
581 #define SMART_EXTENDED_SELFTEST_CAPTIVE 130
582
583 typedef struct _DRIVERSTATUS {
584 UCHAR bDriverError;
585 UCHAR bIDEError;
586 UCHAR bReserved[2];
587 ULONG dwReserved[2];
588 } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
589
590 #define READ_ATTRIBUTE_BUFFER_SIZE 512
591 #define IDENTIFY_BUFFER_SIZE 512
592 #define READ_THRESHOLD_BUFFER_SIZE 512
593 #define SMART_LOG_SECTOR_SIZE 512
594
595 #include <pshpack1.h>
596 typedef struct _SENDCMDOUTPARAMS {
597 ULONG cBufferSize;
598 DRIVERSTATUS DriverStatus;
599 UCHAR bBuffer[1];
600 } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
601 #include <poppack.h>
602
603 #define READ_ATTRIBUTES 0xD0
604 #define READ_THRESHOLDS 0xD1
605 #define ENABLE_DISABLE_AUTOSAVE 0xD2
606 #define SAVE_ATTRIBUTE_VALUES 0xD3
607 #define EXECUTE_OFFLINE_DIAGS 0xD4
608 #define SMART_READ_LOG 0xD5
609 #define SMART_WRITE_LOG 0xd6
610 #define ENABLE_SMART 0xD8
611 #define DISABLE_SMART 0xD9
612 #define RETURN_SMART_STATUS 0xDA
613 #define ENABLE_DISABLE_AUTO_OFFLINE 0xDB
614
615 typedef struct _MAPPED_ADDRESS {
616 struct _MAPPED_ADDRESS *NextMappedAddress;
617 PVOID MappedAddress;
618 ULONG NumberOfBytes;
619 LARGE_INTEGER IoAddress;
620 ULONG BusNumber;
621 } MAPPED_ADDRESS, *PMAPPED_ADDRESS;
622
623
624
625 #if(_WIN32_WINNT >= 0x0500)
626
627 typedef struct _CREATE_DISK_GPT
628 {
629 GUID DiskId;
630 ULONG MaxPartitionCount;
631 } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
632
633 typedef struct _CREATE_DISK_MBR
634 {
635 ULONG Signature;
636 } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
637
638
639 typedef struct _CREATE_DISK
640 {
641 PARTITION_STYLE PartitionStyle;
642 union {
643 CREATE_DISK_MBR Mbr;
644 CREATE_DISK_GPT Gpt;
645 };
646 } CREATE_DISK, *PCREATE_DISK;
647
648
649 typedef enum {
650 EqualPriority,
651 KeepPrefetchedData,
652 KeepReadData
653 } DISK_CACHE_RETENTION_PRIORITY;
654
655 typedef enum _DISK_WRITE_CACHE_STATE {
656 DiskWriteCacheNormal,
657 DiskWriteCacheForceDisable,
658 DiskWriteCacheDisableNotSupported
659 } DISK_WRITE_CACHE_STATE, *PDISK_WRITE_CACHE_STATE;
660
661
662 typedef struct _DISK_CACHE_INFORMATION
663 {
664 BOOLEAN ParametersSavable;
665 BOOLEAN ReadCacheEnabled;
666 BOOLEAN WriteCacheEnabled;
667 DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority;
668 DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority;
669 USHORT DisablePrefetchTransferLength;
670 BOOLEAN PrefetchScalar;
671 union {
672 struct {
673 USHORT Minimum;
674 USHORT Maximum;
675 USHORT MaximumBlocks;
676 } ScalarPrefetch;
677
678 struct {
679 USHORT Minimum;
680 USHORT Maximum;
681 } BlockPrefetch;
682 };
683
684 } DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION;
685
686 typedef struct _DISK_GROW_PARTITION {
687 ULONG PartitionNumber;
688 LARGE_INTEGER BytesToGrow;
689 } DISK_GROW_PARTITION, *PDISK_GROW_PARTITION;
690 #endif
691
692
693 #ifdef __cplusplus
694 }
695 #endif
696
697 #endif /* _NTDDDISK_H_ */