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