6 #define HIST_NO_OF_BUCKETS 24
7 #define HISTOGRAM_BUCKET_SIZE sizeof(HISTOGRAM_BUCKET)
8 #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
9 #define CTL_CODE(t,f,m,a) (((t)<<16)|((a)<<14)|((f)<<2)|(m))
10 #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
11 #define IOCTL_STORAGE_CHECK_VERIFY CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
12 #define IOCTL_STORAGE_CHECK_VERIFY2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
13 #define IOCTL_STORAGE_MEDIA_REMOVAL CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
14 #define IOCTL_STORAGE_EJECT_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
15 #define IOCTL_STORAGE_LOAD_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
16 #define IOCTL_STORAGE_LOAD_MEDIA2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
17 #define IOCTL_STORAGE_RESERVE CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
18 #define IOCTL_STORAGE_RELEASE CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
19 #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
20 #define IOCTL_STORAGE_EJECTION_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
21 #define IOCTL_STORAGE_MCN_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
22 #define IOCTL_STORAGE_GET_MEDIA_TYPES CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
23 #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
24 #define IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
25 #define IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
26 #define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
27 #define IOCTL_STORAGE_PREDICT_FAILURE CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
28 #define IOCTL_DISK_BASE FILE_DEVICE_DISK
29 #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE,0,METHOD_BUFFERED, FILE_ANY_ACCESS)
30 #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE,1,METHOD_BUFFERED,FILE_READ_ACCESS)
31 #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE,2,METHOD_BUFFERED,FILE_READ_ACCESS|FILE_WRITE_ACCESS)
32 #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE,3,METHOD_BUFFERED,FILE_READ_ACCESS)
33 #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE,4,METHOD_BUFFERED,FILE_READ_ACCESS|FILE_WRITE_ACCESS)
34 #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE,5,METHOD_BUFFERED,FILE_ANY_ACCESS)
35 #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE,6,METHOD_BUFFERED,FILE_READ_ACCESS|FILE_WRITE_ACCESS)
36 #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE,7,METHOD_BUFFERED,FILE_READ_ACCESS|FILE_WRITE_ACCESS)
37 #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE,8,METHOD_BUFFERED,FILE_ANY_ACCESS)
38 #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE,9,METHOD_BUFFERED,FILE_ANY_ACCESS)
39 #define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE,10,METHOD_BUFFERED,FILE_ANY_ACCESS)
40 #define IOCTL_DISK_FORMAT_TRACKS_EX CTL_CODE(IOCTL_DISK_BASE,11,METHOD_BUFFERED,FILE_READ_ACCESS|FILE_WRITE_ACCESS)
41 #define IOCTL_DISK_HISTOGRAM_STRUCTURE CTL_CODE(IOCTL_DISK_BASE,12,METHOD_BUFFERED,FILE_ANY_ACCESS)
42 #define IOCTL_DISK_HISTOGRAM_DATA CTL_CODE(IOCTL_DISK_BASE,13,METHOD_BUFFERED,FILE_ANY_ACCESS)
43 #define IOCTL_DISK_HISTOGRAM_RESET CTL_CODE(IOCTL_DISK_BASE,14,METHOD_BUFFERED,FILE_ANY_ACCESS)
44 #define IOCTL_DISK_REQUEST_STRUCTURE CTL_CODE(IOCTL_DISK_BASE,15,METHOD_BUFFERED,FILE_ANY_ACCESS)
45 #define IOCTL_DISK_REQUEST_DATA CTL_CODE(IOCTL_DISK_BASE,16,METHOD_BUFFERED,FILE_ANY_ACCESS)
46 #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE,0x200,METHOD_BUFFERED,FILE_READ_ACCESS)
47 #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE,0x201,METHOD_BUFFERED,FILE_READ_ACCESS)
48 #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE,0x202,METHOD_BUFFERED,FILE_READ_ACCESS)
49 #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE,0x203,METHOD_BUFFERED,FILE_READ_ACCESS)
50 #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE,0x204,METHOD_BUFFERED,FILE_READ_ACCESS)
51 #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE,0x205,METHOD_BUFFERED,FILE_READ_ACCESS)
52 #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE,0x206,METHOD_BUFFERED,FILE_READ_ACCESS)
53 #define IOCTL_DISK_REMOVE_DEVICE CTL_CODE(IOCTL_DISK_BASE,0x207,METHOD_BUFFERED,FILE_READ_ACCESS)
54 #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE,0x300,METHOD_BUFFERED,FILE_ANY_ACCESS)
55 #define IOCTL_SERIAL_LSRMST_INSERT CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
56 #define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM,6,METHOD_BUFFERED,FILE_ANY_ACCESS)
57 #define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM,7,METHOD_BUFFERED,FILE_ANY_ACCESS)
58 #define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM,8,METHOD_BUFFERED,FILE_ANY_ACCESS)
59 #define FSCTL_MOUNT_DBLS_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM,13,METHOD_BUFFERED,FILE_ANY_ACCESS)
60 #define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,15,METHOD_BUFFERED,FILE_ANY_ACCESS)
61 #define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,16,METHOD_BUFFERED,FILE_READ_DATA|FILE_WRITE_DATA)
62 #define FSCTL_READ_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,17,METHOD_NEITHER,FILE_READ_DATA)
63 #define FSCTL_WRITE_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM,18,METHOD_NEITHER,FILE_WRITE_DATA)
64 #define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
65 #define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_WRITE_DATA)
66 #define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_WRITE_DATA)
67 #define DEVICE_TYPE DWORD
68 #define FILE_DEVICE_BEEP 1
69 #define FILE_DEVICE_CD_ROM 2
70 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 3
71 #define FILE_DEVICE_CONTROLLER 4
72 #define FILE_DEVICE_DATALINK 5
73 #define FILE_DEVICE_DFS 6
74 #define FILE_DEVICE_DISK 7
75 #define FILE_DEVICE_DISK_FILE_SYSTEM 8
76 #define FILE_DEVICE_FILE_SYSTEM 9
77 #define FILE_DEVICE_INPORT_PORT 10
78 #define FILE_DEVICE_KEYBOARD 11
79 #define FILE_DEVICE_MAILSLOT 12
80 #define FILE_DEVICE_MIDI_IN 13
81 #define FILE_DEVICE_MIDI_OUT 14
82 #define FILE_DEVICE_MOUSE 15
83 #define FILE_DEVICE_MULTI_UNC_PROVIDER 16
84 #define FILE_DEVICE_NAMED_PIPE 17
85 #define FILE_DEVICE_NETWORK 18
86 #define FILE_DEVICE_NETWORK_BROWSER 19
87 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 20
88 #define FILE_DEVICE_NULL 21
89 #define FILE_DEVICE_PARALLEL_PORT 22
90 #define FILE_DEVICE_PHYSICAL_NETCARD 23
91 #define FILE_DEVICE_PRINTER 24
92 #define FILE_DEVICE_SCANNER 25
93 #define FILE_DEVICE_SERIAL_MOUSE_PORT 26
94 #define FILE_DEVICE_SERIAL_PORT 27
95 #define FILE_DEVICE_SCREEN 28
96 #define FILE_DEVICE_SOUND 29
97 #define FILE_DEVICE_STREAMS 30
98 #define FILE_DEVICE_TAPE 31
99 #define FILE_DEVICE_TAPE_FILE_SYSTEM 32
100 #define FILE_DEVICE_TRANSPORT 33
101 #define FILE_DEVICE_UNKNOWN 34
102 #define FILE_DEVICE_VIDEO 35
103 #define FILE_DEVICE_VIRTUAL_DISK 36
104 #define FILE_DEVICE_WAVE_IN 37
105 #define FILE_DEVICE_WAVE_OUT 38
106 #define FILE_DEVICE_8042_PORT 39
107 #define FILE_DEVICE_NETWORK_REDIRECTOR 40
108 #define FILE_DEVICE_BATTERY 41
109 #define FILE_DEVICE_BUS_EXTENDER 42
110 #define FILE_DEVICE_MODEM 43
111 #define FILE_DEVICE_VDM 44
112 #define FILE_DEVICE_MASS_STORAGE 45
113 #define FILE_DEVICE_SMB 46
114 #define FILE_DEVICE_KS 47
115 #define FILE_DEVICE_CHANGER 48
116 #define FILE_DEVICE_SMARTCARD 49
117 #define FILE_DEVICE_ACPI 50
118 #define FILE_DEVICE_DVD 51
119 #define FILE_DEVICE_FULLSCREEN_VIDEO 52
120 #define FILE_DEVICE_DFS_FILE_SYSTEM 53
121 #define FILE_DEVICE_DFS_VOLUME 54
122 #define FILE_DEVICE_SERENUM 55
123 #define FILE_DEVICE_TERMSRV 56
124 #define FILE_DEVICE_KSEC 57
125 #define PARTITION_ENTRY_UNUSED 0
126 #define PARTITION_FAT_12 1
127 #define PARTITION_XENIX_1 2
128 #define PARTITION_XENIX_2 3
129 #define PARTITION_FAT_16 4
130 #define PARTITION_EXTENDED 5
131 #define PARTITION_HUGE 6
132 #define PARTITION_IFS 7
133 #define PARTITION_PREP 0x41
134 #define PARTITION_UNIX 0x63
135 #define PARTITION_NTFT 128
136 #define VALID_NTFT 0xC0
137 #define METHOD_BUFFERED 0
138 #define METHOD_IN_DIRECT 1
139 #define METHOD_OUT_DIRECT 2
140 #define METHOD_NEITHER 3
141 #define SERIAL_LSRMST_ESCAPE 0
142 #define SERIAL_LSRMST_LSR_DATA 1
143 #define SERIAL_LSRMST_LSR_NODATA 2
144 #define SERIAL_LSRMST_MST 3
145 #define FILE_ANY_ACCESS 0
146 #define FILE_READ_ACCESS 1
147 #define FILE_WRITE_ACCESS 2
148 #define DISK_LOGGING_START 0
149 #define DISK_LOGGING_STOP 1
150 #define DISK_LOGGING_DUMP 2
151 #define DISK_BINNING 3
152 typedef WORD BAD_TRACK_NUMBER
,*PBAD_TRACK_NUMBER
;
153 typedef enum _BIN_TYPES
{RequestSize
,RequestLocation
} BIN_TYPES
;
154 typedef struct _BIN_RANGE
{
155 LARGE_INTEGER StartValue
;
156 LARGE_INTEGER Length
;
157 } BIN_RANGE
,*PBIN_RANGE
;
158 typedef struct _BIN_COUNT
{
161 } BIN_COUNT
,*PBIN_COUNT
;
162 typedef struct _BIN_RESULTS
{
164 BIN_COUNT BinCounts
[1];
165 } BIN_RESULTS
,*PBIN_RESULTS
;
166 typedef enum _MEDIA_TYPE
{
180 } MEDIA_TYPE
, *PMEDIA_TYPE
;
181 typedef struct _DISK_GEOMETRY
{
182 LARGE_INTEGER Cylinders
;
183 MEDIA_TYPE MediaType
;
184 DWORD TracksPerCylinder
;
185 DWORD SectorsPerTrack
;
186 DWORD BytesPerSector
;
187 } DISK_GEOMETRY
, *PDISK_GEOMETRY
;
188 typedef struct _DISK_PERFORMANCE
{
189 LARGE_INTEGER BytesRead
;
190 LARGE_INTEGER BytesWritten
;
191 LARGE_INTEGER ReadTime
;
192 LARGE_INTEGER WriteTime
;
196 } DISK_PERFORMANCE
, *PDISK_PERFORMANCE
;
197 typedef struct _DISK_RECORD
{
198 LARGE_INTEGER ByteOffset
;
199 LARGE_INTEGER StartTime
;
200 LARGE_INTEGER EndTime
;
201 PVOID VirtualAddress
;
205 } DISK_RECORD
,*PDISK_RECORD
;
206 typedef struct _DISK_LOGGING
{
210 } DISK_LOGGING
,*PDISK_LOGGING
;
211 typedef struct _FORMAT_PARAMETERS
{
212 MEDIA_TYPE MediaType
;
213 DWORD StartCylinderNumber
;
214 DWORD EndCylinderNumber
;
215 DWORD StartHeadNumber
;
217 } FORMAT_PARAMETERS
,*PFORMAT_PARAMETERS
;
218 typedef struct _FORMAT_EX_PARAMETERS
{
219 MEDIA_TYPE MediaType
;
220 DWORD StartCylinderNumber
;
221 DWORD EndCylinderNumber
;
222 DWORD StartHeadNumber
;
224 WORD FormatGapLength
;
225 WORD SectorsPerTrack
;
226 WORD SectorNumber
[1];
227 } FORMAT_EX_PARAMETERS
,*PFORMAT_EX_PARAMETERS
;
228 typedef struct _HISTOGRAM_BUCKET
{
231 } HISTOGRAM_BUCKET
,*PHISTOGRAM_BUCKET
;
232 typedef struct _DISK_HISTOGRAM
{
233 LARGE_INTEGER DiskSize
;
236 LARGE_INTEGER Average
;
237 LARGE_INTEGER AverageRead
;
238 LARGE_INTEGER AverageWrite
;
243 PHISTOGRAM_BUCKET Histogram
;
244 } DISK_HISTOGRAM
,*PDISK_HISTOGRAM
;
245 typedef struct _PARTITION_INFORMATION
{
246 LARGE_INTEGER StartingOffset
;
247 LARGE_INTEGER PartitionLength
;
249 DWORD PartitionNumber
;
251 BOOLEAN BootIndicator
;
252 BOOLEAN RecognizedPartition
;
253 BOOLEAN RewritePartition
;
254 } PARTITION_INFORMATION
,*PPARTITION_INFORMATION
;
255 typedef struct _DRIVE_LAYOUT_INFORMATION
{
256 DWORD PartitionCount
;
258 PARTITION_INFORMATION PartitionEntry
[1];
259 } DRIVE_LAYOUT_INFORMATION
;
260 typedef struct _PERF_BIN
{
263 BIN_RANGE BinsRanges
[1];
264 } PERF_BIN
,*PPERF_BIN
;
265 typedef struct _PREVENT_MEDIA_REMOVAL
{
266 BOOLEAN PreventMediaRemoval
;
267 } PREVENT_MEDIA_REMOVAL
,*PPREVENT_MEDIA_REMOVAL
;
268 typedef struct _REASSIGN_BLOCKS
{
271 DWORD BlockNumber
[1];
272 } REASSIGN_BLOCKS
,*PREASSIGN_BLOCKS
;
273 typedef struct _SET_PARTITION_INFORMATION
{
275 } SET_PARTITION_INFORMATION
,*PSET_PARTITION_INFORMATION
;
276 typedef struct _VERIFY_INFORMATION
{
277 LARGE_INTEGER StartingOffset
;
279 } VERIFY_INFORMATION
,*PVERIFY_INFORMATION
;
280 #define IsRecognizedPartition(t) (((t&PARTITION_NTFT)&&((t&~0xC0)==PARTITION_FAT_12))||\
281 ((t&PARTITION_NTFT)&&((t&~0xC0)==PARTITION_FAT_16))||\
282 ((t&PARTITION_NTFT)&&((t&~0xC0)==PARTITION_IFS))||\
283 ((t&PARTITION_NTFT)&&((t&~0xC0)==PARTITION_HUGE))||\
284 ((t&~PARTITION_NTFT)==PARTITION_FAT_12)||\
285 ((t&~PARTITION_NTFT)==PARTITION_FAT_16)||\
286 ((t&~PARTITION_NTFT)==PARTITION_IFS)||\
287 ((t&~PARTITION_NTFT)==PARTITION_HUGE))