1 {******************************************************************************}
2 {                                                                              }
3 { I/O Control Codes API interface Unit for Object Pascal                       }
4 {                                                                              }
5 { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
6 { Corporation. All Rights Reserved.                                            }
7 {                                                                              }
8 { The original file is: winioctl.h, released June 2000. The original Pascal    }
9 { code is: WinIoCtl.pas, released December 2000. The initial developer of the  }
10 { Pascal code is Marcel van Brakel (brakelm att chello dott nl).               }
11 {                                                                              }
12 { Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
13 { Marcel van Brakel. All Rights Reserved.                                      }
14 {                                                                              }
15 { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
16 {                                                                              }
17 { You may retrieve the latest version of this file at the Project JEDI         }
18 { APILIB home page, located at http://jedi-apilib.sourceforge.net              }
19 {                                                                              }
20 { The contents of this file are used with permission, subject to the Mozilla   }
21 { Public License Version 1.1 (the "License"); you may not use this file except }
22 { in compliance with the License. You may obtain a copy of the License at      }
23 { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
24 {                                                                              }
25 { Software distributed under the License is distributed on an "AS IS" basis,   }
26 { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
27 { the specific language governing rights and limitations under the License.    }
28 {                                                                              }
29 { Alternatively, the contents of this file may be used under the terms of the  }
30 { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
31 { provisions of the LGPL License are applicable instead of those above.        }
32 { If you wish to allow use of your version of this file only under the terms   }
33 { of the LGPL License and not to allow others to use your version of this file }
34 { under the MPL, indicate your decision by deleting  the provisions above and  }
35 { replace  them with the notice and other provisions required by the LGPL      }
36 { License.  If you do not delete the provisions above, a recipient may use     }
37 { your version of this file under either the MPL or the LGPL License.          }
38 {                                                                              }
39 { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
40 {                                                                              }
41 {******************************************************************************}
42 
43 // $Id: JwaWinIoctl.pas,v 1.9 2007/09/05 11:58:54 dezipaitor Exp $
44 
45 {$IFNDEF JWA_OMIT_SECTIONS}
46 unit JwaWinIoctl;
47 
48 {$WEAKPACKAGEUNIT}
49 {$ENDIF JWA_OMIT_SECTIONS}
50 
51 {$HPPEMIT ''}
52 {$HPPEMIT '#include "WinIoCtl.h"'}
53 {$HPPEMIT ''}
54 
55 {$IFNDEF JWA_OMIT_SECTIONS}
56 {$I jediapilib.inc}
57 
58 interface
59 
60 uses
61   JwaWinNT, JwaWinType;
62 
63 {$ENDIF JWA_OMIT_SECTIONS}
64 
65 {$IFNDEF JWA_IMPLEMENTATIONSECTION}
66 
67 //
68 // Device interface class GUIDs.
69 //
70 // need these GUIDs outside conditional includes so that user can
71 //   #include <winioctl.h> in precompiled header
72 //   #include <initguid.h> in a single source file
73 //   #include <winioctl.h> in that source file a second time to instantiate the GUIDs
74 //
75 
76 const
77   GUID_DEVINTERFACE_DISK: TGUID = (
78     D1:$53f56307; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
79   {$EXTERNALSYM GUID_DEVINTERFACE_DISK}
80   GUID_DEVINTERFACE_CDROM: TGUID = (
81     D1:$53f56308; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
82   {$EXTERNALSYM GUID_DEVINTERFACE_CDROM}
83   GUID_DEVINTERFACE_PARTITION: TGUID = (
84     D1:$53f5630a; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
85   {$EXTERNALSYM GUID_DEVINTERFACE_PARTITION}
86   GUID_DEVINTERFACE_TAPE: TGUID = (
87     D1:$53f5630b; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
88   {$EXTERNALSYM GUID_DEVINTERFACE_TAPE}
89   GUID_DEVINTERFACE_WRITEONCEDISK: TGUID = (
90     D1:$53f5630c; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
91   {$EXTERNALSYM GUID_DEVINTERFACE_WRITEONCEDISK}
92   GUID_DEVINTERFACE_VOLUME: TGUID = (
93     D1:$53f5630d; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
94   {$EXTERNALSYM GUID_DEVINTERFACE_VOLUME}
95   GUID_DEVINTERFACE_MEDIUMCHANGER: TGUID = (
96     D1:$53f56310; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
97   {$EXTERNALSYM GUID_DEVINTERFACE_MEDIUMCHANGER}
98   GUID_DEVINTERFACE_FLOPPY: TGUID = (
99     D1:$53f56311; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
100   {$EXTERNALSYM GUID_DEVINTERFACE_FLOPPY}
101   GUID_DEVINTERFACE_CDCHANGER: TGUID = (
102     D1:$53f56312; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
103   {$EXTERNALSYM GUID_DEVINTERFACE_CDCHANGER}
104   GUID_DEVINTERFACE_STORAGEPORT: TGUID = (
105     D1:$2accfe60; D2:$c130; D3:$11d2; D4:($b0, $82, $00, $a0, $c9, $1e, $fb, $8b));
106   {$EXTERNALSYM GUID_DEVINTERFACE_STORAGEPORT}
107   GUID_DEVINTERFACE_COMPORT: TGUID = (
108     D1:$86e0d1e0; D2:$8089; D3:$11d0; D4:($9c, $e4, $08, $00, $3e, $30, $1f, $73));
109   {$EXTERNALSYM GUID_DEVINTERFACE_COMPORT}
110   GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR: TGUID = (
111     D1:$4D36E978; D2:$E325; D3:$11CE; D4:($BF, $C1, $08, $00, $2B, $E1, $03, $18));
112   {$EXTERNALSYM GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR}
113 
114 //
115 // Obsolete device interface class GUID names.
116 // (use of above GUID_DEVINTERFACE_* names is recommended).
117 //
118 
119   // MVB: Note that these "constants" are in reality aliases for the list above. Unfortunately you can't
120   // define a GUID without using a type constant and you can't alias a type constant in Delphi...
121 
122   DiskClassGuid: TGUID = (
123     D1:$53f56307; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
124   {$EXTERNALSYM DiskClassGuid}
125   CdRomClassGuid: TGUID = (
126     D1:$53f56308; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
127   {$EXTERNALSYM CdRomClassGuid}
128   PartitionClassGuid: TGUID = (
129     D1:$53f5630a; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
130   {$EXTERNALSYM PartitionClassGuid}
131   TapeClassGuid: TGUID = (
132     D1:$53f5630b; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
133   {$EXTERNALSYM TapeClassGuid}
134   WriteOnceDiskClassGuid: TGUID = (
135     D1:$53f5630c; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
136   {$EXTERNALSYM WriteOnceDiskClassGuid}
137   VolumeClassGuid: TGUID = (
138     D1:$53f5630d; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
139   {$EXTERNALSYM VolumeClassGuid}
140   MediumChangerClassGuid: TGUID = (
141     D1:$53f56310; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
142   {$EXTERNALSYM MediumChangerClassGuid}
143   FloppyClassGuid: TGUID = (
144     D1:$53f56311; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
145   {$EXTERNALSYM FloppyClassGuid}
146   CdChangerClassGuid: TGUID = (
147     D1:$53f56312; D2:$b6bf; D3:$11d0; D4:($94, $f2, $00, $a0, $c9, $1e, $fb, $8b));
148   {$EXTERNALSYM CdChangerClassGuid}
149   StoragePortClassGuid: TGUID = (
150     D1:$2accfe60; D2:$c130; D3:$11d2; D4:($b0, $82, $00, $a0, $c9, $1e, $fb, $8b));
151   {$EXTERNALSYM StoragePortClassGuid}
152   GUID_CLASS_COMPORT: TGUID = (
153     D1:$86e0d1e0; D2:$8089; D3:$11d0; D4:($9c, $e4, $08, $00, $3e, $30, $1f, $73));
154   {$EXTERNALSYM GUID_CLASS_COMPORT}
155   GUID_SERENUM_BUS_ENUMERATOR: TGUID = (
156     D1:$4D36E978; D2:$E325; D3:$11CE; D4:($BF, $C1, $08, $00, $2B, $E1, $03, $18));
157   {$EXTERNALSYM GUID_SERENUM_BUS_ENUMERATOR}
158 
159 //
160 // Define the various device type values.  Note that values used by Microsoft
161 // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
162 // by customers.
163 //
164 
165 type
166   DEVICE_TYPE = DWORD;
167   {$EXTERNALSYM DEVICE_TYPE}
168 
169 const
170   FILE_DEVICE_BEEP                = $00000001;
171   {$EXTERNALSYM FILE_DEVICE_BEEP}
172   FILE_DEVICE_CD_ROM              = $00000002;
173   {$EXTERNALSYM FILE_DEVICE_CD_ROM}
174   FILE_DEVICE_CD_ROM_FILE_SYSTEM  = $00000003;
175   {$EXTERNALSYM FILE_DEVICE_CD_ROM_FILE_SYSTEM}
176   FILE_DEVICE_CONTROLLER          = $00000004;
177   {$EXTERNALSYM FILE_DEVICE_CONTROLLER}
178   FILE_DEVICE_DATALINK            = $00000005;
179   {$EXTERNALSYM FILE_DEVICE_DATALINK}
180   FILE_DEVICE_DFS                 = $00000006;
181   {$EXTERNALSYM FILE_DEVICE_DFS}
182   FILE_DEVICE_DISK                = $00000007;
183   {$EXTERNALSYM FILE_DEVICE_DISK}
184   FILE_DEVICE_DISK_FILE_SYSTEM    = $00000008;
185   {$EXTERNALSYM FILE_DEVICE_DISK_FILE_SYSTEM}
186   FILE_DEVICE_FILE_SYSTEM         = $00000009;
187   {$EXTERNALSYM FILE_DEVICE_FILE_SYSTEM}
188   FILE_DEVICE_INPORT_PORT         = $0000000a;
189   {$EXTERNALSYM FILE_DEVICE_INPORT_PORT}
190   FILE_DEVICE_KEYBOARD            = $0000000b;
191   {$EXTERNALSYM FILE_DEVICE_KEYBOARD}
192   FILE_DEVICE_MAILSLOT            = $0000000c;
193   {$EXTERNALSYM FILE_DEVICE_MAILSLOT}
194   FILE_DEVICE_MIDI_IN             = $0000000d;
195   {$EXTERNALSYM FILE_DEVICE_MIDI_IN}
196   FILE_DEVICE_MIDI_OUT            = $0000000e;
197   {$EXTERNALSYM FILE_DEVICE_MIDI_OUT}
198   FILE_DEVICE_MOUSE               = $0000000f;
199   {$EXTERNALSYM FILE_DEVICE_MOUSE}
200   FILE_DEVICE_MULTI_UNC_PROVIDER  = $00000010;
201   {$EXTERNALSYM FILE_DEVICE_MULTI_UNC_PROVIDER}
202   FILE_DEVICE_NAMED_PIPE          = $00000011;
203   {$EXTERNALSYM FILE_DEVICE_NAMED_PIPE}
204   FILE_DEVICE_NETWORK             = $00000012;
205   {$EXTERNALSYM FILE_DEVICE_NETWORK}
206   FILE_DEVICE_NETWORK_BROWSER     = $00000013;
207   {$EXTERNALSYM FILE_DEVICE_NETWORK_BROWSER}
208   FILE_DEVICE_NETWORK_FILE_SYSTEM = $00000014;
209   {$EXTERNALSYM FILE_DEVICE_NETWORK_FILE_SYSTEM}
210   FILE_DEVICE_NULL                = $00000015;
211   {$EXTERNALSYM FILE_DEVICE_NULL}
212   FILE_DEVICE_PARALLEL_PORT       = $00000016;
213   {$EXTERNALSYM FILE_DEVICE_PARALLEL_PORT}
214   FILE_DEVICE_PHYSICAL_NETCARD    = $00000017;
215   {$EXTERNALSYM FILE_DEVICE_PHYSICAL_NETCARD}
216   FILE_DEVICE_PRINTER             = $00000018;
217   {$EXTERNALSYM FILE_DEVICE_PRINTER}
218   FILE_DEVICE_SCANNER             = $00000019;
219   {$EXTERNALSYM FILE_DEVICE_SCANNER}
220   FILE_DEVICE_SERIAL_MOUSE_PORT   = $0000001a;
221   {$EXTERNALSYM FILE_DEVICE_SERIAL_MOUSE_PORT}
222   FILE_DEVICE_SERIAL_PORT         = $0000001b;
223   {$EXTERNALSYM FILE_DEVICE_SERIAL_PORT}
224   FILE_DEVICE_SCREEN              = $0000001c;
225   {$EXTERNALSYM FILE_DEVICE_SCREEN}
226   FILE_DEVICE_SOUND               = $0000001d;
227   {$EXTERNALSYM FILE_DEVICE_SOUND}
228   FILE_DEVICE_STREAMS             = $0000001e;
229   {$EXTERNALSYM FILE_DEVICE_STREAMS}
230   FILE_DEVICE_TAPE                = $0000001f;
231   {$EXTERNALSYM FILE_DEVICE_TAPE}
232   FILE_DEVICE_TAPE_FILE_SYSTEM    = $00000020;
233   {$EXTERNALSYM FILE_DEVICE_TAPE_FILE_SYSTEM}
234   FILE_DEVICE_TRANSPORT           = $00000021;
235   {$EXTERNALSYM FILE_DEVICE_TRANSPORT}
236   FILE_DEVICE_UNKNOWN             = $00000022;
237   {$EXTERNALSYM FILE_DEVICE_UNKNOWN}
238   FILE_DEVICE_VIDEO               = $00000023;
239   {$EXTERNALSYM FILE_DEVICE_VIDEO}
240   FILE_DEVICE_VIRTUAL_DISK        = $00000024;
241   {$EXTERNALSYM FILE_DEVICE_VIRTUAL_DISK}
242   FILE_DEVICE_WAVE_IN             = $00000025;
243   {$EXTERNALSYM FILE_DEVICE_WAVE_IN}
244   FILE_DEVICE_WAVE_OUT            = $00000026;
245   {$EXTERNALSYM FILE_DEVICE_WAVE_OUT}
246   FILE_DEVICE_8042_PORT           = $00000027;
247   {$EXTERNALSYM FILE_DEVICE_8042_PORT}
248   FILE_DEVICE_NETWORK_REDIRECTOR  = $00000028;
249   {$EXTERNALSYM FILE_DEVICE_NETWORK_REDIRECTOR}
250   FILE_DEVICE_BATTERY             = $00000029;
251   {$EXTERNALSYM FILE_DEVICE_BATTERY}
252   FILE_DEVICE_BUS_EXTENDER        = $0000002a;
253   {$EXTERNALSYM FILE_DEVICE_BUS_EXTENDER}
254   FILE_DEVICE_MODEM               = $0000002b;
255   {$EXTERNALSYM FILE_DEVICE_MODEM}
256   FILE_DEVICE_VDM                 = $0000002c;
257   {$EXTERNALSYM FILE_DEVICE_VDM}
258   FILE_DEVICE_MASS_STORAGE        = $0000002d;
259   {$EXTERNALSYM FILE_DEVICE_MASS_STORAGE}
260   FILE_DEVICE_SMB                 = $0000002e;
261   {$EXTERNALSYM FILE_DEVICE_SMB}
262   FILE_DEVICE_KS                  = $0000002f;
263   {$EXTERNALSYM FILE_DEVICE_KS}
264   FILE_DEVICE_CHANGER             = $00000030;
265   {$EXTERNALSYM FILE_DEVICE_CHANGER}
266   FILE_DEVICE_SMARTCARD           = $00000031;
267   {$EXTERNALSYM FILE_DEVICE_SMARTCARD}
268   FILE_DEVICE_ACPI                = $00000032;
269   {$EXTERNALSYM FILE_DEVICE_ACPI}
270   FILE_DEVICE_DVD                 = $00000033;
271   {$EXTERNALSYM FILE_DEVICE_DVD}
272   FILE_DEVICE_FULLSCREEN_VIDEO    = $00000034;
273   {$EXTERNALSYM FILE_DEVICE_FULLSCREEN_VIDEO}
274   FILE_DEVICE_DFS_FILE_SYSTEM     = $00000035;
275   {$EXTERNALSYM FILE_DEVICE_DFS_FILE_SYSTEM}
276   FILE_DEVICE_DFS_VOLUME          = $00000036;
277   {$EXTERNALSYM FILE_DEVICE_DFS_VOLUME}
278   FILE_DEVICE_SERENUM             = $00000037;
279   {$EXTERNALSYM FILE_DEVICE_SERENUM}
280   FILE_DEVICE_TERMSRV             = $00000038;
281   {$EXTERNALSYM FILE_DEVICE_TERMSRV}
282   FILE_DEVICE_KSEC                = $00000039;
283   {$EXTERNALSYM FILE_DEVICE_KSEC}
284   FILE_DEVICE_FIPS                = $0000003A;
285   {$EXTERNALSYM FILE_DEVICE_FIPS}
286   FILE_DEVICE_INFINIBAND          = $0000003B;
287   {$EXTERNALSYM FILE_DEVICE_INFINIBAND}
288 
289 //
controlnull290 // Macro definition for defining IOCTL and FSCTL function control codes.  Note
291 // that function codes 0-2047 are reserved for Microsoft Corporation, and
292 // 2048-4095 are reserved for customers.
293 //
294 
295 function CTL_CODE(DeviceType, Func, Method, Access: WORD): DWORD;
296 {$EXTERNALSYM CTL_CODE}
297 
298 //
299 // Macro to extract device type out of the device io control code
300 //
301 
DEVICE_TYPE_FROM_CTL_CODEnull302 function DEVICE_TYPE_FROM_CTL_CODE(CtrlCode: DWORD): WORD;
303 {$EXTERNALSYM DEVICE_TYPE_FROM_CTL_CODE}
304 
305 //
306 // Define the method codes for how buffers are passed for I/O and FS controls
307 //
308 
309 const
310   METHOD_BUFFERED   = 0;
311   {$EXTERNALSYM METHOD_BUFFERED}
312   METHOD_IN_DIRECT  = 1;
313   {$EXTERNALSYM METHOD_IN_DIRECT}
314   METHOD_OUT_DIRECT = 2;
315   {$EXTERNALSYM METHOD_OUT_DIRECT}
316   METHOD_NEITHER    = 3;
317   {$EXTERNALSYM METHOD_NEITHER}
318 
319 //
320 // Define some easier to comprehend aliases:
321 //   METHOD_DIRECT_TO_HARDWARE (writes, aka METHOD_IN_DIRECT)
322 //   METHOD_DIRECT_FROM_HARDWARE (reads, aka METHOD_OUT_DIRECT)
323 //
324 
325   METHOD_DIRECT_TO_HARDWARE     = METHOD_IN_DIRECT;
326   {$EXTERNALSYM METHOD_DIRECT_TO_HARDWARE}
327   METHOD_DIRECT_FROM_HARDWARE   = METHOD_OUT_DIRECT;
328   {$EXTERNALSYM METHOD_DIRECT_FROM_HARDWARE}
329 
330 //
331 // Define the access check value for any access
332 //
333 //
334 // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
335 // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
336 // constants *MUST* always be in sync.
337 //
338 //
339 // FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS.
340 // The file systems, however, may add additional access checks for I/O and FS controls
341 // that use this value.
342 //
343 
344 const
345   FILE_ANY_ACCESS     = 0;
346   {$EXTERNALSYM FILE_ANY_ACCESS}
347   FILE_SPECIAL_ACCESS = FILE_ANY_ACCESS;
348   {$EXTERNALSYM FILE_SPECIAL_ACCESS}
349   FILE_READ_ACCESS    = $0001;           // file & pipe
350   {$EXTERNALSYM FILE_READ_ACCESS}
351   FILE_WRITE_ACCESS   = $0002;           // file & pipe
352   {$EXTERNALSYM FILE_WRITE_ACCESS}
353 
354 //
355 // IoControlCode values for storage devices
356 //
357 
358   IOCTL_STORAGE_BASE = FILE_DEVICE_MASS_STORAGE;
359   {$EXTERNALSYM IOCTL_STORAGE_BASE}
360 
361 //
362 // The following device control codes are common for all class drivers.  They
363 // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
364 // common codes
365 //
366 
367 const
368   IOCTL_STORAGE_CHECK_VERIFY = (
369     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
370     ($0200 shl 2) or METHOD_BUFFERED);
371   {$EXTERNALSYM IOCTL_STORAGE_CHECK_VERIFY}
372   IOCTL_STORAGE_CHECK_VERIFY2 = (
373     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
374     ($0200 shl 2) or METHOD_BUFFERED);
375   {$EXTERNALSYM IOCTL_STORAGE_CHECK_VERIFY2}
376   IOCTL_STORAGE_MEDIA_REMOVAL = (
377     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
378     ($0201 shl 2) or METHOD_BUFFERED);
379   {$EXTERNALSYM IOCTL_STORAGE_MEDIA_REMOVAL}
380   IOCTL_STORAGE_EJECT_MEDIA = (
381     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
382     ($0202 shl 2) or METHOD_BUFFERED);
383   {$EXTERNALSYM IOCTL_STORAGE_EJECT_MEDIA}
384   IOCTL_STORAGE_LOAD_MEDIA = (
385     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
386     ($0203 shl 2) or METHOD_BUFFERED);
387   {$EXTERNALSYM IOCTL_STORAGE_LOAD_MEDIA}
388   IOCTL_STORAGE_LOAD_MEDIA2 = (
389     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
390     ($0203 shl 2) or METHOD_BUFFERED);
391   {$EXTERNALSYM IOCTL_STORAGE_LOAD_MEDIA2}
392   IOCTL_STORAGE_RESERVE = (
393     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
394     ($0204 shl 2) or METHOD_BUFFERED);
395   {$EXTERNALSYM IOCTL_STORAGE_RESERVE}
396   IOCTL_STORAGE_RELEASE = (
397     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
398     ($0205 shl 2) or METHOD_BUFFERED);
399   {$EXTERNALSYM IOCTL_STORAGE_RELEASE}
400   IOCTL_STORAGE_FIND_NEW_DEVICES = (
401     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
402     ($0206 shl 2) or METHOD_BUFFERED);
403   {$EXTERNALSYM IOCTL_STORAGE_FIND_NEW_DEVICES}
404 
405   IOCTL_STORAGE_EJECTION_CONTROL = (
406     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
407     ($0250 shl 2) or METHOD_BUFFERED);
408   {$EXTERNALSYM IOCTL_STORAGE_EJECTION_CONTROL}
409   IOCTL_STORAGE_MCN_CONTROL = (
410     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
411     ($0251 shl 2) or METHOD_BUFFERED);
412   {$EXTERNALSYM IOCTL_STORAGE_MCN_CONTROL}
413 
414   IOCTL_STORAGE_GET_MEDIA_TYPES = (
415     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
416     ($0300 shl 2) or METHOD_BUFFERED);
417   {$EXTERNALSYM IOCTL_STORAGE_GET_MEDIA_TYPES}
418   IOCTL_STORAGE_GET_MEDIA_TYPES_EX = (
419     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
420     ($0301 shl 2) or METHOD_BUFFERED);
421   {$EXTERNALSYM IOCTL_STORAGE_GET_MEDIA_TYPES_EX}
422   IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER = (
423     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
424     ($0304 shl 2) or METHOD_BUFFERED);
425   {$EXTERNALSYM IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER}
426   IOCTL_STORAGE_GET_HOTPLUG_INFO = (
427     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
428     ($0305 shl 2) or METHOD_BUFFERED);
429   {$EXTERNALSYM IOCTL_STORAGE_GET_HOTPLUG_INFO}
430   IOCTL_STORAGE_SET_HOTPLUG_INFO = (
431     (IOCTL_STORAGE_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
432     ($0306 shl 2) or METHOD_BUFFERED);
433   {$EXTERNALSYM IOCTL_STORAGE_SET_HOTPLUG_INFO}
434 
435   IOCTL_STORAGE_RESET_BUS = (
436     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
437     ($0400 shl 2) or METHOD_BUFFERED);
438   {$EXTERNALSYM IOCTL_STORAGE_RESET_BUS}
439   IOCTL_STORAGE_RESET_DEVICE = (
440     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
441     ($0401 shl 2) or METHOD_BUFFERED);
442   {$EXTERNALSYM IOCTL_STORAGE_RESET_DEVICE}
443   IOCTL_STORAGE_BREAK_RESERVATION = (
444     (IOCTL_STORAGE_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
445     ($0405 shl 2) or METHOD_BUFFERED);
446   {$EXTERNALSYM IOCTL_STORAGE_BREAK_RESERVATION}
447 
448   IOCTL_STORAGE_GET_DEVICE_NUMBER = (
449     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
450     ($0420 shl 2) or METHOD_BUFFERED);
451   {$EXTERNALSYM IOCTL_STORAGE_GET_DEVICE_NUMBER}
452 
453   IOCTL_STORAGE_PREDICT_FAILURE = (
454     (IOCTL_STORAGE_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
455     ($0440 shl 2) or METHOD_BUFFERED);
456   {$EXTERNALSYM IOCTL_STORAGE_PREDICT_FAILURE}
457 
458 //
459 // These ioctl codes are obsolete.  They are defined here to avoid resuing them
460 // and to allow class drivers to respond to them more easily.
461 //
462 
463   OBSOLETE_IOCTL_STORAGE_RESET_BUS = (
464     (IOCTL_STORAGE_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
465     ($0400 shl 2) or METHOD_BUFFERED);
466   {$EXTERNALSYM OBSOLETE_IOCTL_STORAGE_RESET_BUS}
467 
468   OBSOLETE_IOCTL_STORAGE_RESET_DEVICE = (
469     (IOCTL_STORAGE_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
470     ($0401 shl 2) or METHOD_BUFFERED);
471   {$EXTERNALSYM OBSOLETE_IOCTL_STORAGE_RESET_DEVICE}
472 
473 //
474 // IOCTL_STORAGE_GET_HOTPLUG_INFO
475 //
476 
477 type
478   PSTORAGE_HOTPLUG_INFO = ^STORAGE_HOTPLUG_INFO;
479   {$EXTERNALSYM PSTORAGE_HOTPLUG_INFO}
480   _STORAGE_HOTPLUG_INFO = record
481     Size: DWORD; // version
482     MediaRemovable: BOOLEAN; // ie. zip, jaz, cdrom, mo, etc. vs hdd
483     MediaHotplug: BOOLEAN;   // ie. does the device succeed a lock even though its not lockable media?
484     DeviceHotplug: BOOLEAN;  // ie. 1394, USB, etc.
485     WriteCacheEnableOverride: BOOLEAN; // This field should not be relied upon because it is no longer used
486   end;
487   {$EXTERNALSYM _STORAGE_HOTPLUG_INFO}
488   STORAGE_HOTPLUG_INFO = _STORAGE_HOTPLUG_INFO;
489   {$EXTERNALSYM STORAGE_HOTPLUG_INFO}
490   TStorageHotplugInfo = STORAGE_HOTPLUG_INFO;
491   PStorageHotplugInfo = PSTORAGE_HOTPLUG_INFO;
492 
493 //
494 // IOCTL_STORAGE_GET_DEVICE_NUMBER
495 //
496 // input - none
497 //
498 // output - STORAGE_DEVICE_NUMBER structure
499 //          The values in the STORAGE_DEVICE_NUMBER structure are guaranteed
500 //          to remain unchanged until the system is rebooted.  They are not
501 //          guaranteed to be persistant across boots.
502 //
503 
504 type
505   PSTORAGE_DEVICE_NUMBER = ^STORAGE_DEVICE_NUMBER;
506   {$EXTERNALSYM PSTORAGE_DEVICE_NUMBER}
507   _STORAGE_DEVICE_NUMBER = record
508     //
509     // The FILE_DEVICE_XXX type for this device.
510     //
511     DeviceType: DEVICE_TYPE;
512     //
513     // The number of this device
514     //
515     DeviceNumber: DWORD;
516     //
517     // If the device is partitionable, the partition number of the device.
518     // Otherwise -1
519     //
520     PartitionNumber: DWORD;
521   end;
522   {$EXTERNALSYM _STORAGE_DEVICE_NUMBER}
523   STORAGE_DEVICE_NUMBER = _STORAGE_DEVICE_NUMBER;
524   {$EXTERNALSYM STORAGE_DEVICE_NUMBER}
525   TStorageDeviceNumber = STORAGE_DEVICE_NUMBER;
526   PStorageDeviceNumber = PSTORAGE_DEVICE_NUMBER;
527 
528 //
529 // Define the structures for scsi resets
530 //
531 
532   PSTORAGE_BUS_RESET_REQUEST = ^STORAGE_BUS_RESET_REQUEST;
533   {$EXTERNALSYM PSTORAGE_BUS_RESET_REQUEST}
534   _STORAGE_BUS_RESET_REQUEST = record
535     PathId: BYTE;
536   end;
537   {$EXTERNALSYM _STORAGE_BUS_RESET_REQUEST}
538   STORAGE_BUS_RESET_REQUEST = _STORAGE_BUS_RESET_REQUEST;
539   {$EXTERNALSYM STORAGE_BUS_RESET_REQUEST}
540   TStorageBusResetRequest = STORAGE_BUS_RESET_REQUEST;
541   PStorageBusResetRequest = PSTORAGE_BUS_RESET_REQUEST;
542 
543 //
544 // Break reservation is sent to the Adapter/FDO with the given lun information.
545 //
546 
547   STORAGE_BREAK_RESERVATION_REQUEST = record
548     Length: DWORD;
549     _unused: Byte;
550     PathId: Byte;
551     TargetId: Byte;
552     Lun: Byte;
553   end;
554   {$EXTERNALSYM STORAGE_BREAK_RESERVATION_REQUEST}
555   PSTORAGE_BREAK_RESERVATION_REQUEST = ^STORAGE_BREAK_RESERVATION_REQUEST;
556   {$EXTERNALSYM PSTORAGE_BREAK_RESERVATION_REQUEST}
557   TStorageBreakReservationRequest = STORAGE_BREAK_RESERVATION_REQUEST;
558   PStorageBreakReservationRequest = PSTORAGE_BREAK_RESERVATION_REQUEST;
559 
560 //
561 // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
562 // on a storage device that ejects media. This function
563 // may or may not be supported on storage devices that
564 // support removable media.
565 //
566 // TRUE means prevent media from being removed.
567 // FALSE means allow media removal.
568 //
569 
570   PPREVENT_MEDIA_REMOVAL = ^PREVENT_MEDIA_REMOVAL;
571   {$EXTERNALSYM PPREVENT_MEDIA_REMOVAL}
572   _PREVENT_MEDIA_REMOVAL = record
573     PreventMediaRemoval: ByteBool;
574   end;
575   {$EXTERNALSYM _PREVENT_MEDIA_REMOVAL}
576   PREVENT_MEDIA_REMOVAL = _PREVENT_MEDIA_REMOVAL;
577   {$EXTERNALSYM PREVENT_MEDIA_REMOVAL}
578   TPreventMediaRemoval = PREVENT_MEDIA_REMOVAL;
579   PPreventMediaRemoval = PPREVENT_MEDIA_REMOVAL;
580 
581 //
582 //  This is the format of TARGET_DEVICE_CUSTOM_NOTIFICATION.CustomDataBuffer
583 //  passed to applications by the classpnp autorun code (via IoReportTargetDeviceChangeAsynchronous).
584 //
585 
586   _CLASS_MEDIA_CHANGE_CONTEXT = record
587     MediaChangeCount: DWORD;
588     NewState: DWORD;  // see MEDIA_CHANGE_DETECTION_STATE enum in classpnp.h in DDK
589   end;
590   {$EXTERNALSYM _CLASS_MEDIA_CHANGE_CONTEXT}
591   CLASS_MEDIA_CHANGE_CONTEXT = _CLASS_MEDIA_CHANGE_CONTEXT;
592   {$EXTERNALSYM CLASS_MEDIA_CHANGE_CONTEXT}
593   PCLASS_MEDIA_CHANGE_CONTEXT = ^CLASS_MEDIA_CHANGE_CONTEXT;
594   {$EXTERNALSYM PCLASS_MEDIA_CHANGE_CONTEXT}
595   TClassMediaChangeContext = CLASS_MEDIA_CHANGE_CONTEXT;
596   PClassMediaChangeContext = PCLASS_MEDIA_CHANGE_CONTEXT;
597 
598   PTAPE_STATISTICS = ^TAPE_STATISTICS;
599   {$EXTERNALSYM PTAPE_STATISTICS}
600   _TAPE_STATISTICS = record
601     Version: DWORD;
602     Flags: DWORD;
603     RecoveredWrites: LARGE_INTEGER;
604     UnrecoveredWrites: LARGE_INTEGER;
605     RecoveredReads: LARGE_INTEGER;
606     UnrecoveredReads: LARGE_INTEGER;
607     CompressionRatioReads: BYTE;
608     CompressionRatioWrites: BYTE;
609   end;
610   {$EXTERNALSYM _TAPE_STATISTICS}
611   TAPE_STATISTICS = _TAPE_STATISTICS;
612   {$EXTERNALSYM TAPE_STATISTICS}
613   TTapeStatistics = TAPE_STATISTICS;
614   PTapeStatistics = PTAPE_STATISTICS;
615 
616 const
617   RECOVERED_WRITES_VALID       = $00000001;
618   {$EXTERNALSYM RECOVERED_WRITES_VALID}
619   UNRECOVERED_WRITES_VALID     = $00000002;
620   {$EXTERNALSYM UNRECOVERED_WRITES_VALID}
621   RECOVERED_READS_VALID        = $00000004;
622   {$EXTERNALSYM RECOVERED_READS_VALID}
623   UNRECOVERED_READS_VALID      = $00000008;
624   {$EXTERNALSYM UNRECOVERED_READS_VALID}
625   WRITE_COMPRESSION_INFO_VALID = $00000010;
626   {$EXTERNALSYM WRITE_COMPRESSION_INFO_VALID}
627   READ_COMPRESSION_INFO_VALID  = $00000020;
628   {$EXTERNALSYM READ_COMPRESSION_INFO_VALID}
629 
630 type
631   PTAPE_GET_STATISTICS = ^TAPE_GET_STATISTICS;
632   {$EXTERNALSYM PTAPE_GET_STATISTICS}
633   _TAPE_GET_STATISTICS = record
634     Operation: DWORD;
635   end;
636   {$EXTERNALSYM _TAPE_GET_STATISTICS}
637   TAPE_GET_STATISTICS = _TAPE_GET_STATISTICS;
638   {$EXTERNALSYM TAPE_GET_STATISTICS}
639   TTapeGetStatistics = TAPE_GET_STATISTICS;
640   PTapeGetStatistics = PTAPE_GET_STATISTICS;
641 
642 const
643   TAPE_RETURN_STATISTICS = 0;
644   {$EXTERNALSYM TAPE_RETURN_STATISTICS}
645   TAPE_RETURN_ENV_INFO   = 1;
646   {$EXTERNALSYM TAPE_RETURN_ENV_INFO}
647   TAPE_RESET_STATISTICS  = 2;
648   {$EXTERNALSYM TAPE_RESET_STATISTICS}
649 
650 //
651 // IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
652 // structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
653 //
654 
655 const
656 
657   //
658   // Following are defined in ntdddisk.h in the MEDIA_TYPE enum
659   //
660   // Unknown,                // Format is unknown
661   // F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
662   // F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
663   // F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
664   // F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
665   // F3_720_512,             // 3.5",  720KB,  512 bytes/sector
666   // F5_360_512,             // 5.25", 360KB,  512 bytes/sector
667   // F5_320_512,             // 5.25", 320KB,  512 bytes/sector
668   // F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
669   // F5_180_512,             // 5.25", 180KB,  512 bytes/sector
670   // F5_160_512,             // 5.25", 160KB,  512 bytes/sector
671   // RemovableMedia,         // Removable media other than floppy
672   // FixedMedia,             // Fixed hard disk media
673   // F3_120M_512,            // 3.5", 120M Floppy
674   // F3_640_512,             // 3.5" ,  640KB,  512 bytes/sector
675   // F5_640_512,             // 5.25",  640KB,  512 bytes/sector
676   // F5_720_512,             // 5.25",  720KB,  512 bytes/sector
677   // F3_1Pt2_512,            // 3.5" ,  1.2Mb,  512 bytes/sector
678   // F3_1Pt23_1024,          // 3.5" ,  1.23Mb, 1024 bytes/sector
679   // F5_1Pt23_1024,          // 5.25",  1.23MB, 1024 bytes/sector
680   // F3_128Mb_512,           // 3.5" MO 128Mb   512 bytes/sector
681   // F3_230Mb_512,           // 3.5" MO 230Mb   512 bytes/sector
682   // F8_256_128,             // 8",     256KB,  128 bytes/sector
683   // F3_200Mb_512,           // 3.5",   200M Floppy (HiFD)
684   //
685 
686   DDS_4mm            = $20;  // Tape - DAT DDS1,2,... (all vendors)
687   MiniQic            = $21;  // Tape - miniQIC Tape
688   Travan             = $22;  // Tape - Travan TR-1,2,3,...
689   QIC                = $23;  // Tape - QIC
690   MP_8mm             = $24;  // Tape - 8mm Exabyte Metal Particle
691   AME_8mm            = $25;  // Tape - 8mm Exabyte Advanced Metal Evap
692   AIT1_8mm           = $26;  // Tape - 8mm Sony AIT
693   DLT                = $27;  // Tape - DLT Compact IIIxt, IV
694   NCTP               = $28;  // Tape - Philips NCTP
695   IBM_3480           = $29;  // Tape - IBM 3480
696   IBM_3490E          = $2A;  // Tape - IBM 3490E
697   IBM_Magstar_3590   = $2B;  // Tape - IBM Magstar 3590
698   IBM_Magstar_MP     = $2C;  // Tape - IBM Magstar MP
699   STK_DATA_D3        = $2D;  // Tape - STK Data D3
700   SONY_DTF           = $2E;  // Tape - Sony DTF
701   DV_6mm             = $2F;  // Tape - 6mm Digital Video
702   DMI                = $30;  // Tape - Exabyte DMI and compatibles
703   SONY_D2            = $31;  // Tape - Sony D2S and D2L
704   CLEANER_CARTRIDGE  = $32;  // Cleaner - All Drive types that support Drive Cleaners
705   CD_ROM             = $33;  // Opt_Disk - CD
706   CD_R               = $34;  // Opt_Disk - CD-Recordable (Write Once)
707   CD_RW              = $35;  // Opt_Disk - CD-Rewriteable
708   DVD_ROM            = $36;  // Opt_Disk - DVD-ROM
709   DVD_R              = $37;  // Opt_Disk - DVD-Recordable (Write Once)
710   DVD_RW             = $38;  // Opt_Disk - DVD-Rewriteable
711   MO_3_RW            = $39;  // Opt_Disk - 3.5" Rewriteable MO Disk
712   MO_5_WO            = $3A;  // Opt_Disk - MO 5.25" Write Once
713   MO_5_RW            = $3B;  // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
714   MO_5_LIMDOW        = $3C;  // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
715   PC_5_WO            = $3D;  // Opt_Disk - Phase Change 5.25" Write Once Optical
716   PC_5_RW            = $3E;  // Opt_Disk - Phase Change 5.25" Rewriteable
717   PD_5_RW            = $3F;  // Opt_Disk - PhaseChange Dual Rewriteable
718   ABL_5_WO           = $40;  // Opt_Disk - Ablative 5.25" Write Once Optical
719   PINNACLE_APEX_5_RW = $41;  // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
720   SONY_12_WO         = $42;  // Opt_Disk - Sony 12" Write Once
721   PHILIPS_12_WO      = $43;  // Opt_Disk - Philips/LMS 12" Write Once
722   HITACHI_12_WO      = $44;  // Opt_Disk - Hitachi 12" Write Once
723   CYGNET_12_WO       = $45;  // Opt_Disk - Cygnet/ATG 12" Write Once
724   KODAK_14_WO        = $46;  // Opt_Disk - Kodak 14" Write Once
725   MO_NFR_525         = $47;  // Opt_Disk - Near Field Recording (Terastor)
726   NIKON_12_RW        = $48;  // Opt_Disk - Nikon 12" Rewriteable
727   IOMEGA_ZIP         = $49;  // Mag_Disk - Iomega Zip
728   IOMEGA_JAZ         = $4A;  // Mag_Disk - Iomega Jaz
729   SYQUEST_EZ135      = $4B;  // Mag_Disk - Syquest EZ135
730   SYQUEST_EZFLYER    = $4C;  // Mag_Disk - Syquest EzFlyer
731   SYQUEST_SYJET      = $4D;  // Mag_Disk - Syquest SyJet
732   AVATAR_F2          = $4E;  // Mag_Disk - 2.5" Floppy
733   MP2_8mm            = $4F;  // Tape - 8mm Hitachi
734   DST_S              = $50;  // Ampex DST Small Tapes
735   DST_M              = $51;  // Ampex DST Medium Tapes
736   DST_L              = $52;  // Ampex DST Large Tapes
737   VXATape_1          = $53;  // Ecrix 8mm Tape
738   VXATape_2          = $54;  // Ecrix 8mm Tape
739   STK_9840           = $55;  // STK 9840
740   LTO_Ultrium        = $56;  // IBM, HP, Seagate LTO Ultrium
741   LTO_Accelis        = $57;  // IBM, HP, Seagate LTO Accelis
742   DVD_RAM            = $58;  // Opt_Disk - DVD-RAM
743   AIT_8mm            = $59;  // AIT2 or higher
744   ADR_1              = $5A;  // OnStream ADR Mediatypes
745   ADR_2              = $5B;
746   STK_9940           = $5C;  // STK 9940
747 
748 type
749   STORAGE_MEDIA_TYPE = DWORD;
750   {$EXTERNALSYM STORAGE_MEDIA_TYPE}
751   PSTORAGE_MEDIA_TYPE = ^STORAGE_MEDIA_TYPE;
752   {$EXTERNALSYM PSTORAGE_MEDIA_TYPE}
753   TStorageMediaType = STORAGE_MEDIA_TYPE;
754   PStorageMediaType = ^TStorageMediaType;
755 
756 const
757   MEDIA_ERASEABLE  = $00000001;
758   {$EXTERNALSYM MEDIA_ERASEABLE}
759   MEDIA_WRITE_ONCE = $00000002;
760   {$EXTERNALSYM MEDIA_WRITE_ONCE}
761   MEDIA_READ_ONLY  = $00000004;
762   {$EXTERNALSYM MEDIA_READ_ONLY}
763   MEDIA_READ_WRITE = $00000008;
764   {$EXTERNALSYM MEDIA_READ_WRITE}
765 
766   MEDIA_WRITE_PROTECTED   = $00000100;
767   {$EXTERNALSYM MEDIA_WRITE_PROTECTED}
768   MEDIA_CURRENTLY_MOUNTED = DWORD($80000000);
769   {$EXTERNALSYM MEDIA_CURRENTLY_MOUNTED}
770 
771 //
772 // Define the different storage bus types
773 // Bus types below 128 (0x80) are reserved for Microsoft use
774 //
775 
776 const
777   BusTypeUnknown     = 0;
778   BusTypeScsi        = 1;
779   BusTypeAtapi       = 2;
780   BusTypeAta         = 3;
781   BusType1394        = 4;
782   BusTypeSsa         = 5;
783   BusTypeFibre       = 6;
784   BusTypeUsb         = 7;
785   BusTypeRAID        = 8;
786   BusTypeMaxReserved = $7F;
787 
788 type
789   STORAGE_BUS_TYPE = DWORD;
790   {$EXTERNALSYM STORAGE_BUS_TYPE}
791   PSTORAGE_BUS_TYPE = ^STORAGE_BUS_TYPE;
792   {$EXTERNALSYM PSTORAGE_BUS_TYPE}
793   TStorageBusType = STORAGE_BUS_TYPE;
794   PStorageBusType = PSTORAGE_BUS_TYPE;
795 
796   TDMIDiskInfo = record
797     Cylinders: LARGE_INTEGER;
798     MediaType: STORAGE_MEDIA_TYPE;
799     TracksPerCylinder: DWORD;
800     SectorsPerTrack: DWORD;
801     BytesPerSector: DWORD;
802     NumberMediaSides: DWORD;
803     MediaCharacteristics: DWORD; // Bitmask of MEDIA_XXX values.
804   end;
805 
806   TDMIRemovableDiskInfo = record
807     Cylinders: LARGE_INTEGER;
808     MediaType: STORAGE_MEDIA_TYPE;
809     TracksPerCylinder: DWORD;
810     SectorsPerTrack: DWORD;
811     BytesPerSector: DWORD;
812     NumberMediaSides: DWORD;
813     MediaCharacteristics: DWORD; // Bitmask of MEDIA_XXX values.
814   end;
815 
816   TDMITapeInfo = record
817     MediaType: STORAGE_MEDIA_TYPE;
818     MediaCharacteristics: DWORD; // Bitmask of MEDIA_XXX values.
819     CurrentBlockSize: DWORD;
820     BusType: STORAGE_BUS_TYPE;
821     //
822     // Bus specific information describing the medium supported.
823     //
824     case Integer of {BusSpecificData}
825       0: ( {ScsiInformation}
826         MediumType: BYTE;
827         DensityCode: BYTE);
828   end;
829 
830   PDEVICE_MEDIA_INFO = ^DEVICE_MEDIA_INFO;
831   {$EXTERNALSYM PDEVICE_MEDIA_INFO}
832   _DEVICE_MEDIA_INFO = record
833     case Integer of
834       0: (DiskInfo: TDMIDiskInfo);
835       1: (RemovableDiskInfo: TDMIRemovableDiskInfo);
836       2: (TapeInfo: TDMITapeInfo);
837   end;
838   {$EXTERNALSYM _DEVICE_MEDIA_INFO}
839   DEVICE_MEDIA_INFO = _DEVICE_MEDIA_INFO;
840   {$EXTERNALSYM DEVICE_MEDIA_INFO}
841   TDeviceMediaInfo = DEVICE_MEDIA_INFO;
842   PDeviceMediaInfo = PDEVICE_MEDIA_INFO;
843 
844   PGET_MEDIA_TYPES = ^GET_MEDIA_TYPES;
845   {$EXTERNALSYM PGET_MEDIA_TYPES}
846   _GET_MEDIA_TYPES = record
847     DeviceType: DWORD; // FILE_DEVICE_XXX values
848     MediaInfoCount: DWORD;
849     MediaInfo: array [0..0] of DEVICE_MEDIA_INFO;
850   end;
851   {$EXTERNALSYM _GET_MEDIA_TYPES}
852   GET_MEDIA_TYPES = _GET_MEDIA_TYPES;
853   {$EXTERNALSYM GET_MEDIA_TYPES}
854   TGetMediaTypes = GET_MEDIA_TYPES;
855   PGetMediaTypes = PGET_MEDIA_TYPES;
856 
857 //
858 // IOCTL_STORAGE_PREDICT_FAILURE
859 //
860 // input - none
861 //
862 // output - STORAGE_PREDICT_FAILURE structure
863 //          PredictFailure returns zero if no failure predicted and non zero
864 //                         if a failure is predicted.
865 //
866 //          VendorSpecific returns 512 bytes of vendor specific information
867 //                         if a failure is predicted
868 //
869 
870   PSTORAGE_PREDICT_FAILURE = ^STORAGE_PREDICT_FAILURE;
871   {$EXTERNALSYM PSTORAGE_PREDICT_FAILURE}
872   _STORAGE_PREDICT_FAILURE = record
873     PredictFailure: DWORD;
874     VendorSpecific: array [0..511] of BYTE;
875   end;
876   {$EXTERNALSYM _STORAGE_PREDICT_FAILURE}
877   STORAGE_PREDICT_FAILURE = _STORAGE_PREDICT_FAILURE;
878   {$EXTERNALSYM STORAGE_PREDICT_FAILURE}
879   TStoragePredictFailure = STORAGE_PREDICT_FAILURE;
880   PStoragePredictFailure = PSTORAGE_PREDICT_FAILURE;
881 
882 //
883 // IoControlCode values for disk devices.
884 //
885 
886 const
887   IOCTL_DISK_BASE = FILE_DEVICE_DISK;
888   {$EXTERNALSYM IOCTL_DISK_BASE}
889 
890   IOCTL_DISK_GET_DRIVE_GEOMETRY = (
891     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
892     ($0000 shl 2) or METHOD_BUFFERED);
893   {$EXTERNALSYM IOCTL_DISK_GET_DRIVE_GEOMETRY}
894 
895   IOCTL_DISK_GET_PARTITION_INFO = (
896     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
897     ($0001 shl 2) or METHOD_BUFFERED);
898   {$EXTERNALSYM IOCTL_DISK_GET_PARTITION_INFO}
899 
900   IOCTL_DISK_SET_PARTITION_INFO = (
901     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
902     ($0002 shl 2) or METHOD_BUFFERED);
903   {$EXTERNALSYM IOCTL_DISK_SET_PARTITION_INFO}
904 
905   IOCTL_DISK_GET_DRIVE_LAYOUT = (
906     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
907     ($0003 shl 2) or METHOD_BUFFERED);
908   {$EXTERNALSYM IOCTL_DISK_GET_DRIVE_LAYOUT}
909 
910   IOCTL_DISK_SET_DRIVE_LAYOUT = (
911     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
912     ($0004 shl 2) or METHOD_BUFFERED);
913   {$EXTERNALSYM IOCTL_DISK_SET_DRIVE_LAYOUT}
914 
915   IOCTL_DISK_VERIFY = (
916     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
917     ($0005 shl 2) or METHOD_BUFFERED);
918   {$EXTERNALSYM IOCTL_DISK_VERIFY}
919 
920   IOCTL_DISK_FORMAT_TRACKS = (
921     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
922     ($0006 shl 2) or METHOD_BUFFERED);
923   {$EXTERNALSYM IOCTL_DISK_FORMAT_TRACKS}
924 
925   IOCTL_DISK_REASSIGN_BLOCKS = (
926     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
927     ($0007 shl 2) or METHOD_BUFFERED);
928   {$EXTERNALSYM IOCTL_DISK_REASSIGN_BLOCKS}
929 
930   IOCTL_DISK_PERFORMANCE = (
931     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
932     ($0008 shl 2) or METHOD_BUFFERED);
933   {$EXTERNALSYM IOCTL_DISK_PERFORMANCE}
934 
935   IOCTL_DISK_IS_WRITABLE = (
936     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
937     ($0009 shl 2) or METHOD_BUFFERED);
938   {$EXTERNALSYM IOCTL_DISK_IS_WRITABLE}
939 
940   IOCTL_DISK_LOGGING = (
941     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
942     ($000a shl 2) or METHOD_BUFFERED);
943   {$EXTERNALSYM IOCTL_DISK_LOGGING}
944 
945   IOCTL_DISK_FORMAT_TRACKS_EX = (
946     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
947     ($000b shl 2) or METHOD_BUFFERED);
948   {$EXTERNALSYM IOCTL_DISK_FORMAT_TRACKS_EX}
949 
950   IOCTL_DISK_HISTOGRAM_STRUCTURE = (
951     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
952     ($000c shl 2) or METHOD_BUFFERED);
953   {$EXTERNALSYM IOCTL_DISK_HISTOGRAM_STRUCTURE}
954 
955   IOCTL_DISK_HISTOGRAM_DATA = (
956     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
957     ($000d shl 2) or METHOD_BUFFERED);
958   {$EXTERNALSYM IOCTL_DISK_HISTOGRAM_DATA}
959 
960   IOCTL_DISK_HISTOGRAM_RESET = (
961     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
962     ($000e shl 2) or METHOD_BUFFERED);
963   {$EXTERNALSYM IOCTL_DISK_HISTOGRAM_RESET}
964 
965   IOCTL_DISK_REQUEST_STRUCTURE = (
966     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
967     ($000f shl 2) or METHOD_BUFFERED);
968   {$EXTERNALSYM IOCTL_DISK_REQUEST_STRUCTURE}
969 
970   IOCTL_DISK_REQUEST_DATA = (
971     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
972     ($0010 shl 2) or METHOD_BUFFERED);
973   {$EXTERNALSYM IOCTL_DISK_REQUEST_DATA}
974 
975   IOCTL_DISK_PERFORMANCE_OFF = (
976     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
977     ($0018 shl 2) or METHOD_BUFFERED);
978   {$EXTERNALSYM IOCTL_DISK_PERFORMANCE_OFF}
979 
980   IOCTL_DISK_CONTROLLER_NUMBER = (
981     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
982     ($0011 shl 2) or METHOD_BUFFERED);
983   {$EXTERNALSYM IOCTL_DISK_CONTROLLER_NUMBER}
984 
985 //
986 // IOCTL support for SMART drive fault prediction.
987 //
988 
989   SMART_GET_VERSION = (
990     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
991     ($0020 shl 2) or METHOD_BUFFERED);
992   {$EXTERNALSYM SMART_GET_VERSION}
993 
994   SMART_SEND_DRIVE_COMMAND = (
995     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
996     ($0021 shl 2) or METHOD_BUFFERED);
997   {$EXTERNALSYM SMART_SEND_DRIVE_COMMAND}
998 
999   SMART_RCV_DRIVE_DATA = (
1000     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1001     ($0022 shl 2) or METHOD_BUFFERED);
1002   {$EXTERNALSYM SMART_RCV_DRIVE_DATA}
1003 
1004 //
1005 // New IOCTLs for GUID Partition tabled disks.
1006 //
1007 
1008 // 23-11-2002: various bugs reported by Carsten Grafflage corrected
1009 
1010   IOCTL_DISK_GET_PARTITION_INFO_EX = (
1011     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
1012     ($0012 shl 2) or METHOD_BUFFERED);
1013   {$EXTERNALSYM IOCTL_DISK_GET_PARTITION_INFO_EX}
1014 
1015   IOCTL_DISK_SET_PARTITION_INFO_EX = (
1016     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1017     ($0013 shl 2) or METHOD_BUFFERED);
1018   {$EXTERNALSYM IOCTL_DISK_SET_PARTITION_INFO_EX}
1019 
1020   IOCTL_DISK_GET_DRIVE_LAYOUT_EX = (
1021     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
1022     ($0014 shl 2) or METHOD_BUFFERED);
1023   {$EXTERNALSYM IOCTL_DISK_GET_DRIVE_LAYOUT_EX}
1024 
1025   IOCTL_DISK_SET_DRIVE_LAYOUT_EX = (
1026     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1027     ($0015 shl 2) or METHOD_BUFFERED);
1028   {$EXTERNALSYM IOCTL_DISK_SET_DRIVE_LAYOUT_EX}
1029 
1030   IOCTL_DISK_CREATE_DISK = (
1031     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1032     ($0016 shl 2) or METHOD_BUFFERED);
1033   {$EXTERNALSYM IOCTL_DISK_CREATE_DISK}
1034 
1035   IOCTL_DISK_GET_LENGTH_INFO = (
1036     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1037     ($0017 shl 2) or METHOD_BUFFERED);
1038   {$EXTERNALSYM IOCTL_DISK_GET_LENGTH_INFO}
1039 
1040   IOCTL_DISK_GET_DRIVE_GEOMETRY_EX = (
1041     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
1042     ($0028 shl 2) or METHOD_BUFFERED);
1043   {$EXTERNALSYM IOCTL_DISK_GET_DRIVE_GEOMETRY_EX}
1044 
1045   IOCTL_DISK_UPDATE_DRIVE_SIZE = (
1046     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1047     ($0032 shl 2) or METHOD_BUFFERED);
1048   {$EXTERNALSYM IOCTL_DISK_UPDATE_DRIVE_SIZE}
1049 
1050   IOCTL_DISK_GROW_PARTITION = (
1051     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1052     ($0034 shl 2) or METHOD_BUFFERED);
1053   {$EXTERNALSYM IOCTL_DISK_GROW_PARTITION}
1054 
1055   IOCTL_DISK_GET_CACHE_INFORMATION = (
1056     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1057     ($0035 shl 2) or METHOD_BUFFERED);
1058   {$EXTERNALSYM IOCTL_DISK_GET_CACHE_INFORMATION}
1059 
1060   IOCTL_DISK_SET_CACHE_INFORMATION = (
1061     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1062     ($0036 shl 2) or METHOD_BUFFERED);
1063   {$EXTERNALSYM IOCTL_DISK_SET_CACHE_INFORMATION}
1064 
1065   OBSOLETE_DISK_GET_WRITE_CACHE_STATE = (
1066     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1067     ($0037 shl 2) or METHOD_BUFFERED);
1068   {$EXTERNALSYM OBSOLETE_DISK_GET_WRITE_CACHE_STATE}
1069 
1070   IOCTL_DISK_DELETE_DRIVE_LAYOUT = (
1071     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1072     ($0040 shl 2) or METHOD_BUFFERED);
1073   {$EXTERNALSYM IOCTL_DISK_DELETE_DRIVE_LAYOUT}
1074 
1075 //
1076 // Called to flush cached information that the driver may have about this
1077 // device's characteristics.  Not all drivers cache characteristics, and not
1078 // cached properties can be flushed.  This simply serves as an update to the
1079 // driver that it may want to do an expensive reexamination of the device's
1080 // characteristics now (fixed media size, partition table, etc...)
1081 //
1082 
1083   IOCTL_DISK_UPDATE_PROPERTIES = (
1084     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
1085     ($0050 shl 2) or METHOD_BUFFERED);
1086   {$EXTERNALSYM IOCTL_DISK_UPDATE_PROPERTIES}
1087 
1088 //
1089 //  Special IOCTLs needed to support PC-98 machines in Japan
1090 //
1091 
1092   IOCTL_DISK_FORMAT_DRIVE = (
1093     (IOCTL_DISK_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
1094     ($00f3 shl 2) or METHOD_BUFFERED);
1095   {$EXTERNALSYM IOCTL_DISK_FORMAT_DRIVE}
1096 
1097   IOCTL_DISK_SENSE_DEVICE = (
1098     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
1099     ($00f8 shl 2) or METHOD_BUFFERED);
1100   {$EXTERNALSYM IOCTL_DISK_SENSE_DEVICE}
1101 
1102 //
1103 // The following device control codes are common for all class drivers.  The
1104 // functions codes defined here must match all of the other class drivers.
1105 //
1106 // Warning: these codes will be replaced in the future by equivalent
1107 // IOCTL_STORAGE codes
1108 //
1109 
1110   IOCTL_DISK_CHECK_VERIFY = (
1111     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1112     ($0200 shl 2) or METHOD_BUFFERED);
1113   {$EXTERNALSYM IOCTL_DISK_CHECK_VERIFY}
1114 
1115   IOCTL_DISK_MEDIA_REMOVAL = (
1116     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1117     ($0201 shl 2) or METHOD_BUFFERED);
1118   {$EXTERNALSYM IOCTL_DISK_MEDIA_REMOVAL}
1119 
1120   IOCTL_DISK_EJECT_MEDIA = (
1121     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1122     ($0202 shl 2) or METHOD_BUFFERED);
1123   {$EXTERNALSYM IOCTL_DISK_EJECT_MEDIA}
1124 
1125   IOCTL_DISK_LOAD_MEDIA = (
1126     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1127     ($0203 shl 2) or METHOD_BUFFERED);
1128   {$EXTERNALSYM IOCTL_DISK_LOAD_MEDIA}
1129 
1130   IOCTL_DISK_RESERVE = (
1131     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1132     ($0204 shl 2) or METHOD_BUFFERED);
1133   {$EXTERNALSYM IOCTL_DISK_RESERVE}
1134 
1135   IOCTL_DISK_RELEASE = (
1136     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1137     ($0205 shl 2) or METHOD_BUFFERED);
1138   {$EXTERNALSYM IOCTL_DISK_RELEASE}
1139 
1140   IOCTL_DISK_FIND_NEW_DEVICES = (
1141     (IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
1142     ($0206 shl 2) or METHOD_BUFFERED);
1143   {$EXTERNALSYM IOCTL_DISK_FIND_NEW_DEVICES}
1144 
1145   IOCTL_DISK_GET_MEDIA_TYPES = (
1146     (IOCTL_DISK_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
1147     ($0300 shl 2) or METHOD_BUFFERED);
1148   {$EXTERNALSYM IOCTL_DISK_GET_MEDIA_TYPES}
1149 
1150 //
1151 // Define the partition types returnable by known disk drivers.
1152 //
1153 
1154 const
1155   PARTITION_ENTRY_UNUSED    = $00; // Entry unused
1156   {$EXTERNALSYM PARTITION_ENTRY_UNUSED}
1157   PARTITION_FAT_12          = $01; // 12-bit FAT entries
1158   {$EXTERNALSYM PARTITION_FAT_12}
1159   PARTITION_XENIX_1         = $02; // Xenix
1160   {$EXTERNALSYM PARTITION_XENIX_1}
1161   PARTITION_XENIX_2         = $03; // Xenix
1162   {$EXTERNALSYM PARTITION_XENIX_2}
1163   PARTITION_FAT_16          = $04; // 16-bit FAT entries
1164   {$EXTERNALSYM PARTITION_FAT_16}
1165   PARTITION_EXTENDED        = $05; // Extended partition entry
1166   {$EXTERNALSYM PARTITION_EXTENDED}
1167   PARTITION_HUGE            = $06; // Huge partition MS-DOS V4
1168   {$EXTERNALSYM PARTITION_HUGE}
1169   PARTITION_IFS             = $07; // IFS Partition
1170   {$EXTERNALSYM PARTITION_IFS}
1171   PARTITION_OS2BOOTMGR      = $0A; // OS/2 Boot Manager/OPUS/Coherent swap
1172   {$EXTERNALSYM PARTITION_OS2BOOTMGR}
1173   PARTITION_FAT32           = $0B; // FAT32
1174   {$EXTERNALSYM PARTITION_FAT32}
1175   PARTITION_FAT32_XINT13    = $0C; // FAT32 using extended int13 services
1176   {$EXTERNALSYM PARTITION_FAT32_XINT13}
1177   PARTITION_XINT13          = $0E; // Win95 partition using extended int13 services
1178   {$EXTERNALSYM PARTITION_XINT13}
1179   PARTITION_XINT13_EXTENDED = $0F; // Same as type 5 but uses extended int13 services
1180   {$EXTERNALSYM PARTITION_XINT13_EXTENDED}
1181   PARTITION_PREP            = $41; // PowerPC Reference Platform (PReP) Boot Partition
1182   {$EXTERNALSYM PARTITION_PREP}
1183   PARTITION_LDM             = $42; // Logical Disk Manager partition
1184   {$EXTERNALSYM PARTITION_LDM}
1185   PARTITION_UNIX            = $63; // Unix
1186   {$EXTERNALSYM PARTITION_UNIX}
1187 
1188   VALID_NTFT                = $C0; // NTFT uses high order bits
1189   {$EXTERNALSYM VALID_NTFT}
1190 
1191 //
1192 // The high bit of the partition type code indicates that a partition
1193 // is part of an NTFT mirror or striped array.
1194 //
1195 
1196   PARTITION_NTFT = $80; // NTFT partition
1197   {$EXTERNALSYM PARTITION_NTFT}
1198 
1199 //
1200 // The following macro is used to determine which partitions should be
1201 // assigned drive letters.
1202 //
1203 
1204 //++
1205 //
1206 // BOOLEAN
1207 // IsRecognizedPartition(
1208 //     IN DWORD PartitionType
1209 //     )
1210 //
1211 // Routine Description:
1212 //
1213 //     This macro is used to determine to which partitions drive letters
1214 //     should be assigned.
1215 //
1216 // Arguments:
1217 //
1218 //     PartitionType - Supplies the type of the partition being examined.
1219 //
1220 // Return Value:
1221 //
1222 //     The return value is TRUE if the partition type is recognized,
1223 //     otherwise FALSE is returned.
1224 //
1225 //--
1226 
IsRecognizedPartitionnull1227 function IsRecognizedPartition(PartitionType: DWORD): Boolean;
1228 {$EXTERNALSYM IsRecognizedPartition}
1229 
1230 //++
1231 //
1232 // BOOLEAN
1233 // IsContainerPartition(
1234 //     IN DWORD PartitionType
1235 //     )
1236 //
1237 // Routine Description:
1238 //
1239 //     This macro is used to determine to which partition types are actually
1240 //     containers for other partitions (ie, extended partitions).
1241 //
1242 // Arguments:
1243 //
1244 //     PartitionType - Supplies the type of the partition being examined.
1245 //
1246 // Return Value:
1247 //
1248 //     The return value is TRUE if the partition type is a container,
1249 //     otherwise FALSE is returned.
1250 //
1251 //--
1252 
IsContainerPartitionnull1253 function IsContainerPartition(PartitionType: DWORD): Boolean;
1254 {$EXTERNALSYM IsContainerPartition}
1255 
1256 //++
1257 //
1258 // BOOLEAN
1259 // IsFTPartition(
1260 //     IN DWORD PartitionType
1261 //     )
1262 //
1263 // Routine Description:
1264 //
1265 //     This macro is used to determine if the given partition is an FT
1266 //     partition.
1267 //
1268 // Arguments:
1269 //
1270 //     PartitionType - Supplies the type of the partition being examined.
1271 //
1272 // Return Value:
1273 //
1274 //     The return value is TRUE if the partition type is an FT partition,
1275 //     otherwise FALSE is returned.
1276 //
1277 //--
1278 
IsFTPartitionnull1279 function IsFTPartition(PartitionType: DWORD): Boolean;
1280 {$EXTERNALSYM IsFTPartition}
1281 
1282 //
1283 // Define the media types supported by the driver.
1284 //
1285 
1286 type
1287   _MEDIA_TYPE = (
1288     Unknown,                // Format is unknown
1289     F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
1290     F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
1291     F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
1292     F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
1293     F3_720_512,             // 3.5",  720KB,  512 bytes/sector
1294     F5_360_512,             // 5.25", 360KB,  512 bytes/sector
1295     F5_320_512,             // 5.25", 320KB,  512 bytes/sector
1296     F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
1297     F5_180_512,             // 5.25", 180KB,  512 bytes/sector
1298     F5_160_512,             // 5.25", 160KB,  512 bytes/sector
1299     RemovableMedia,         // Removable media other than floppy
1300     FixedMedia,             // Fixed hard disk media
1301     F3_120M_512,            // 3.5", 120M Floppy
1302     F3_640_512,             // 3.5" ,  640KB,  512 bytes/sector
1303     F5_640_512,             // 5.25",  640KB,  512 bytes/sector
1304     F5_720_512,             // 5.25",  720KB,  512 bytes/sector
1305     F3_1Pt2_512,            // 3.5" ,  1.2Mb,  512 bytes/sector
1306     F3_1Pt23_1024,          // 3.5" ,  1.23Mb, 1024 bytes/sector
1307     F5_1Pt23_1024,          // 5.25",  1.23MB, 1024 bytes/sector
1308     F3_128Mb_512,           // 3.5" MO 128Mb   512 bytes/sector
1309     F3_230Mb_512,           // 3.5" MO 230Mb   512 bytes/sector
1310     F8_256_128,             // 8",     256KB,  128 bytes/sector
1311     F3_200Mb_512,           // 3.5",   200M Floppy (HiFD)
1312     F3_240M_512,            // 3.5",   240Mb Floppy (HiFD)
1313     F3_32M_512);            // 3.5",   32Mb Floppy
1314   {$EXTERNALSYM _MEDIA_TYPE}
1315   MEDIA_TYPE = _MEDIA_TYPE;
1316   {$EXTERNALSYM MEDIA_TYPE}
1317   PMEDIA_TYPE = ^MEDIA_TYPE;
1318   {$EXTERNALSYM PMEDIA_TYPE}
1319   TMediaType = MEDIA_TYPE;
1320   PMediaType = PMEDIA_TYPE;
1321 
1322 //
1323 // Define the input buffer structure for the driver, when
1324 // it is called with IOCTL_DISK_FORMAT_TRACKS.
1325 //
1326 
1327   PFORMAT_PARAMETERS = ^FORMAT_PARAMETERS;
1328   {$EXTERNALSYM PFORMAT_PARAMETERS}
1329   _FORMAT_PARAMETERS = record
1330     MediaType: MEDIA_TYPE;
1331     StartCylinderNumber: DWORD;
1332     EndCylinderNumber: DWORD;
1333     StartHeadNumber: DWORD;
1334     EndHeadNumber: DWORD;
1335   end;
1336   {$EXTERNALSYM _FORMAT_PARAMETERS}
1337   FORMAT_PARAMETERS = _FORMAT_PARAMETERS;
1338   {$EXTERNALSYM FORMAT_PARAMETERS}
1339   TFormatParameters = FORMAT_PARAMETERS;
1340   PFormatParameters = PFORMAT_PARAMETERS;
1341 
1342 //
1343 // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
1344 // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
1345 // what tracks were bad during formatting. The length of that array is
1346 // reported in the `Information' field of the I/O Status Block.
1347 //
1348 
1349   BAD_TRACK_NUMBER = WORD;
1350   {$EXTERNALSYM BAD_TRACK_NUMBER}
1351   PBAD_TRACK_NUMBER = ^WORD;
1352   {$EXTERNALSYM PBAD_TRACK_NUMBER}
1353 
1354 //
1355 // Define the input buffer structure for the driver, when
1356 // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
1357 //
1358 
1359   PFORMAT_EX_PARAMETERS = ^FORMAT_EX_PARAMETERS;
1360   {$EXTERNALSYM PFORMAT_EX_PARAMETERS}
1361   _FORMAT_EX_PARAMETERS = record
1362     MediaType: MEDIA_TYPE;
1363     StartCylinderNumber: DWORD;
1364     EndCylinderNumber: DWORD;
1365     StartHeadNumber: DWORD;
1366     EndHeadNumber: DWORD;
1367     FormatGapLength: WORD;
1368     SectorsPerTrack: WORD;
1369     SectorNumber: array [0..0] of WORD;
1370   end;
1371   {$EXTERNALSYM _FORMAT_EX_PARAMETERS}
1372   FORMAT_EX_PARAMETERS = _FORMAT_EX_PARAMETERS;
1373   {$EXTERNALSYM FORMAT_EX_PARAMETERS}
1374   TFormatExParameters = FORMAT_EX_PARAMETERS;
1375   PFormatExParameters = PFORMAT_EX_PARAMETERS;
1376 
1377 //
1378 // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
1379 // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
1380 // request.
1381 //
1382 
1383   PDISK_GEOMETRY = ^DISK_GEOMETRY;
1384   {$EXTERNALSYM PDISK_GEOMETRY}
1385   _DISK_GEOMETRY = record
1386     Cylinders: LARGE_INTEGER;
1387     MediaType: MEDIA_TYPE;
1388     TracksPerCylinder: DWORD;
1389     SectorsPerTrack: DWORD;
1390     BytesPerSector: DWORD;
1391   end;
1392   {$EXTERNALSYM _DISK_GEOMETRY}
1393   DISK_GEOMETRY = _DISK_GEOMETRY;
1394   {$EXTERNALSYM DISK_GEOMETRY}
1395   TDiskGeometry = DISK_GEOMETRY;
1396   PDiskGeometry = PDISK_GEOMETRY;
1397 
1398 //
1399 // This wmi guid returns a DISK_GEOMETRY structure
1400 //
1401 
1402 const
1403   WMI_DISK_GEOMETRY_GUID: TGUID = (
1404     D1:$25007f51; D2:$57c2; D3:$11d1; D4:($a5, $28, $00, $a0, $c9, $06, $29, $10));
1405   {$EXTERNALSYM WMI_DISK_GEOMETRY_GUID}
1406 
1407 //
1408 // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
1409 // and an IOCTL_DISK_GET_DRIVE_LAYOUT request.  It is also used in a request
1410 // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
1411 //
1412 
1413 type
1414   PPARTITION_INFORMATION = ^PARTITION_INFORMATION;
1415   {$EXTERNALSYM PPARTITION_INFORMATION}
1416   _PARTITION_INFORMATION = record
1417     StartingOffset: LARGE_INTEGER;
1418     PartitionLength: LARGE_INTEGER;
1419     HiddenSectors: DWORD;
1420     PartitionNumber: DWORD;
1421     PartitionType: BYTE;
1422     BootIndicator: ByteBool;
1423     RecognizedPartition: ByteBool;
1424     RewritePartition: ByteBool;
1425   end;
1426   {$EXTERNALSYM _PARTITION_INFORMATION}
1427   PARTITION_INFORMATION = _PARTITION_INFORMATION;
1428   {$EXTERNALSYM PARTITION_INFORMATION}
1429   TPartitionInformation = PARTITION_INFORMATION;
1430   PPartitionInformation = PPARTITION_INFORMATION;
1431 
1432 //
1433 // The following structure is used to change the partition type of a
1434 // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
1435 // request.
1436 //
1437 
1438   PSET_PARTITION_INFORMATION = ^SET_PARTITION_INFORMATION;
1439   {$EXTERNALSYM PSET_PARTITION_INFORMATION}
1440   _SET_PARTITION_INFORMATION = record
1441     PartitionType: BYTE;
1442   end;
1443   {$EXTERNALSYM _SET_PARTITION_INFORMATION}
1444   SET_PARTITION_INFORMATION = _SET_PARTITION_INFORMATION;
1445   {$EXTERNALSYM SET_PARTITION_INFORMATION}
1446   TSetPartitionInformation = _SET_PARTITION_INFORMATION;
1447   PSetPartitionInformation = PSET_PARTITION_INFORMATION;
1448 
1449 //
1450 // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
1451 // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
1452 //
1453 
1454   PDRIVE_LAYOUT_INFORMATION = ^DRIVE_LAYOUT_INFORMATION;
1455   {$EXTERNALSYM PDRIVE_LAYOUT_INFORMATION}
1456   _DRIVE_LAYOUT_INFORMATION = record
1457     PartitionCount: DWORD;
1458     Signature: DWORD;
1459     PartitionEntry: array [0..0] of PARTITION_INFORMATION;
1460   end;
1461   {$EXTERNALSYM _DRIVE_LAYOUT_INFORMATION}
1462   DRIVE_LAYOUT_INFORMATION = _DRIVE_LAYOUT_INFORMATION;
1463   {$EXTERNALSYM DRIVE_LAYOUT_INFORMATION}
1464   TDriveLayoutInformation = DRIVE_LAYOUT_INFORMATION;
1465   PDriveLayoutInformation = PDRIVE_LAYOUT_INFORMATION;
1466 
1467 //
1468 // The following structure is passed in on an IOCTL_DISK_VERIFY request.
1469 // The offset and length parameters are both given in bytes.
1470 //
1471 
1472   PVERIFY_INFORMATION = ^VERIFY_INFORMATION;
1473   {$EXTERNALSYM PVERIFY_INFORMATION}
1474   _VERIFY_INFORMATION = record
1475     StartingOffset: LARGE_INTEGER;
1476     Length: DWORD;
1477   end;
1478   {$EXTERNALSYM _VERIFY_INFORMATION}
1479   VERIFY_INFORMATION = _VERIFY_INFORMATION;
1480   {$EXTERNALSYM VERIFY_INFORMATION}
1481   TVerifyInformation = VERIFY_INFORMATION;
1482   PVerifyInformation = PVERIFY_INFORMATION;
1483 
1484 //
1485 // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
1486 // request.
1487 //
1488 
1489   PREASSIGN_BLOCKS = ^REASSIGN_BLOCKS;
1490   {$EXTERNALSYM PREASSIGN_BLOCKS}
1491   _REASSIGN_BLOCKS = record
1492     Reserved: WORD;
1493     Count: WORD;
1494     BlockNumber: array [0..0] of DWORD;
1495   end;
1496   {$EXTERNALSYM _REASSIGN_BLOCKS}
1497   REASSIGN_BLOCKS = _REASSIGN_BLOCKS;
1498   {$EXTERNALSYM REASSIGN_BLOCKS}
1499   TReassignBlocks = REASSIGN_BLOCKS;
1500   PReassignBlocks = PREASSIGN_BLOCKS;
1501 
1502 //
1503 // Support for GUID Partition Table (GPT) disks.
1504 //
1505 
1506 //
1507 // There are currently two ways a disk can be partitioned. With a traditional
1508 // AT-style master boot record (PARTITION_STYLE_MBR) and with a new, GPT
1509 // partition table (PARTITION_STYLE_GPT). RAW is for an unrecognizable
1510 // partition style. There are a very limited number of things you can
1511 // do with a RAW partititon.
1512 //
1513 
1514 type
1515   _PARTITION_STYLE = (
1516     PARTITION_STYLE_MBR,
1517     PARTITION_STYLE_GPT,
1518     PARTITION_STYLE_RAW);
1519   {$EXTERNALSYM _PARTITION_STYLE}
1520   PARTITION_STYLE = _PARTITION_STYLE;
1521   {$EXTERNALSYM PARTITION_STYLE}
1522   TPartitionStyle = PARTITION_STYLE;
1523 
1524 //
1525 // The following structure defines information in a GPT partition that is
1526 // not common to both GPT and MBR partitions.
1527 //
1528 
1529   PPARTITION_INFORMATION_GPT = ^PARTITION_INFORMATION_GPT;
1530   {$EXTERNALSYM PPARTITION_INFORMATION_GPT}
1531   _PARTITION_INFORMATION_GPT = record
1532     PartitionType: GUID; // Partition type. See table 16-3.
1533     PartitionId: GUID; // Unique GUID for this partition.
1534     Attributes: DWORD64; // See table 16-4.
1535     Name: array [0..35] of WCHAR; // Partition Name in Unicode.
1536   end;
1537   {$EXTERNALSYM _PARTITION_INFORMATION_GPT}
1538   PARTITION_INFORMATION_GPT = _PARTITION_INFORMATION_GPT;
1539   {$EXTERNALSYM PARTITION_INFORMATION_GPT}
1540   TPartitionInformationGpt = PARTITION_INFORMATION_GPT;
1541   PPartitionInformationGpt = PPARTITION_INFORMATION_GPT;
1542 
1543 //
1544 //  The following are GPT partition attributes applicable for any
1545 //  partition type. These attributes are not OS-specific
1546 //
1547 
1548 const
1549   GPT_ATTRIBUTE_PLATFORM_REQUIRED = $0000000000000001;
1550   {$EXTERNALSYM GPT_ATTRIBUTE_PLATFORM_REQUIRED}
1551 
1552 //
1553 // The following are GPT partition attributes applicable when the
1554 // PartitionType is PARTITION_BASIC_DATA_GUID.
1555 //
1556 
1557   GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER = DWORD($8000000000000000);
1558   {$EXTERNALSYM GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER}
1559   GPT_BASIC_DATA_ATTRIBUTE_HIDDEN          = $4000000000000000;
1560   {$EXTERNALSYM GPT_BASIC_DATA_ATTRIBUTE_HIDDEN}
1561   GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY       = $1000000000000000;
1562   {$EXTERNALSYM GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY}
1563 
1564 //
1565 // The following structure defines information in an MBR partition that is not
1566 // common to both GPT and MBR partitions.
1567 //
1568 
1569 type
1570   PPARTITION_INFORMATION_MBR = ^PARTITION_INFORMATION_MBR;
1571   {$EXTERNALSYM PPARTITION_INFORMATION_MBR}
1572   _PARTITION_INFORMATION_MBR = record
1573     PartitionType: BYTE;
1574     BootIndicator: BOOLEAN;
1575     RecognizedPartition: BOOLEAN;
1576     HiddenSectors: DWORD;
1577   end;
1578   {$EXTERNALSYM _PARTITION_INFORMATION_MBR}
1579   PARTITION_INFORMATION_MBR = _PARTITION_INFORMATION_MBR;
1580   {$EXTERNALSYM PARTITION_INFORMATION_MBR}
1581   TPartitionInformationMbr = PARTITION_INFORMATION_MBR;
1582   PPartitionInformationMbr = PPARTITION_INFORMATION_MBR;
1583 
1584 //
1585 // The structure SET_PARTITION_INFO_EX is used with the ioctl
1586 // IOCTL_SET_PARTITION_INFO_EX to set information about a specific
1587 // partition. Note that for MBR partitions, you can only set the partition
1588 // signature, whereas GPT partitions allow setting of all fields that
1589 // you can get.
1590 //
1591 
1592   SET_PARTITION_INFORMATION_MBR = SET_PARTITION_INFORMATION;
1593   {$EXTERNALSYM SET_PARTITION_INFORMATION_MBR}
1594   TSetPartitionInformationMbr = SET_PARTITION_INFORMATION_MBR;
1595   SET_PARTITION_INFORMATION_GPT = PARTITION_INFORMATION_GPT;
1596   {$EXTERNALSYM SET_PARTITION_INFORMATION_GPT}
1597   TSetPartitionInformationGpt = SET_PARTITION_INFORMATION_GPT;
1598 
1599   PSET_PARTITION_INFORMATION_EX = ^SET_PARTITION_INFORMATION_EX;
1600   {$EXTERNALSYM PSET_PARTITION_INFORMATION_EX}
1601   _SET_PARTITION_INFORMATION_EX = record
1602     PartitionStyle: PARTITION_STYLE;
1603     case Integer of
1604       0: (Mbr: SET_PARTITION_INFORMATION_MBR);
1605       1: (Gpt: SET_PARTITION_INFORMATION_GPT);
1606   end;
1607   {$EXTERNALSYM _SET_PARTITION_INFORMATION_EX}
1608   SET_PARTITION_INFORMATION_EX = _SET_PARTITION_INFORMATION_EX;
1609   {$EXTERNALSYM SET_PARTITION_INFORMATION_EX}
1610   TSetPartitionInformationEx = SET_PARTITION_INFORMATION_EX;
1611   PSetPartitionInformationEx = PSET_PARTITION_INFORMATION_EX;
1612 
1613 //
1614 // The structure CREATE_DISK_GPT with the ioctl IOCTL_DISK_CREATE_DISK
1615 // to initialize an virgin disk with an empty GPT partition table.
1616 //
1617 
1618   PCREATE_DISK_GPT = ^CREATE_DISK_GPT;
1619   {$EXTERNALSYM PCREATE_DISK_GPT}
1620   _CREATE_DISK_GPT = record
1621     DiskId: GUID; // Unique disk id for the disk.
1622     MaxPartitionCount: DWORD; // Maximim number of partitions allowable.
1623   end;
1624   {$EXTERNALSYM _CREATE_DISK_GPT}
1625   CREATE_DISK_GPT = _CREATE_DISK_GPT;
1626   {$EXTERNALSYM CREATE_DISK_GPT}
1627   TCreateDiskGpt = CREATE_DISK_GPT;
1628   PCreateDiskGpt = PCREATE_DISK_GPT;
1629 
1630 //
1631 // The structure CREATE_DISK_MBR with the ioctl IOCTL_DISK_CREATE_DISK
1632 // to initialize an virgin disk with an empty MBR partition table.
1633 //
1634 
1635   PCREATE_DISK_MBR = ^CREATE_DISK_MBR;
1636   {$EXTERNALSYM PCREATE_DISK_MBR}
1637   _CREATE_DISK_MBR = record
1638     Signature: DWORD;
1639   end;
1640   {$EXTERNALSYM _CREATE_DISK_MBR}
1641   CREATE_DISK_MBR = _CREATE_DISK_MBR;
1642   {$EXTERNALSYM CREATE_DISK_MBR}
1643   TCreateDiskMbr = CREATE_DISK_MBR;
1644   PCreateDiskMbr = PCREATE_DISK_MBR;
1645 
1646   PCREATE_DISK = ^CREATE_DISK;
1647   {$EXTERNALSYM PCREATE_DISK}
1648   _CREATE_DISK = record
1649     PartitionStyle: PARTITION_STYLE;
1650     case Integer of
1651       0: (Mbr: CREATE_DISK_MBR);
1652       1: (Gpt: CREATE_DISK_GPT);
1653   end;
1654   {$EXTERNALSYM _CREATE_DISK}
1655   CREATE_DISK = _CREATE_DISK;
1656   {$EXTERNALSYM CREATE_DISK}
1657   TCreateDisk = CREATE_DISK;
1658   PCreateDisk = PCREATE_DISK;
1659 
1660 //
1661 // The structure GET_LENGTH_INFORMATION is used with the ioctl
1662 // IOCTL_DISK_GET_LENGTH_INFO to obtain the length, in bytes, of the
1663 // disk, partition, or volume.
1664 //
1665 
1666   PGET_LENGTH_INFORMATION = ^GET_LENGTH_INFORMATION;
1667   {$EXTERNALSYM PGET_LENGTH_INFORMATION}
1668   _GET_LENGTH_INFORMATION = record
1669     Length: LARGE_INTEGER;
1670   end;
1671   {$EXTERNALSYM _GET_LENGTH_INFORMATION}
1672   GET_LENGTH_INFORMATION = _GET_LENGTH_INFORMATION;
1673   {$EXTERNALSYM GET_LENGTH_INFORMATION}
1674   TGetLengthInformation = GET_LENGTH_INFORMATION;
1675   PGetLengthInformation = PGET_LENGTH_INFORMATION;
1676 
1677 //
1678 // The PARTITION_INFORMATION_EX structure is used with the
1679 // IOCTL_DISK_GET_DRIVE_LAYOUT_EX, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
1680 // IOCTL_DISK_GET_PARTITION_INFO_EX and IOCTL_DISK_GET_PARTITION_INFO_EX calls.
1681 //
1682 
1683   PPARTITION_INFORMATION_EX = ^PARTITION_INFORMATION_EX;
1684   {$EXTERNALSYM PPARTITION_INFORMATION_EX}
1685   _PARTITION_INFORMATION_EX = record
1686     PartitionStyle: PARTITION_STYLE;
1687     StartingOffset: LARGE_INTEGER;
1688     PartitionLength: LARGE_INTEGER;
1689     PartitionNumber: DWORD;
1690     RewritePartition: BOOLEAN;
1691     case Integer of
1692       0: (Mbr: PARTITION_INFORMATION_MBR);
1693       1: (Gpt: PARTITION_INFORMATION_GPT);
1694   end;
1695   {$EXTERNALSYM _PARTITION_INFORMATION_EX}
1696   PARTITION_INFORMATION_EX = _PARTITION_INFORMATION_EX;
1697   {$EXTERNALSYM PARTITION_INFORMATION_EX}
1698   TPartitionInformationEx = PARTITION_INFORMATION_EX;
1699   PPartitionInformationEx = PPARTITION_INFORMATION_EX;
1700 
1701 //
1702 // GPT specific drive layout information.
1703 //
1704 
1705   PDRIVE_LAYOUT_INFORMATION_GPT = ^DRIVE_LAYOUT_INFORMATION_GPT;
1706   {$EXTERNALSYM PDRIVE_LAYOUT_INFORMATION_GPT}
1707   _DRIVE_LAYOUT_INFORMATION_GPT = record
1708     DiskId: GUID;
1709     StartingUsableOffset: LARGE_INTEGER;
1710     UsableLength: LARGE_INTEGER;
1711     MaxPartitionCount: DWORD;
1712   end;
1713   {$EXTERNALSYM _DRIVE_LAYOUT_INFORMATION_GPT}
1714   DRIVE_LAYOUT_INFORMATION_GPT = _DRIVE_LAYOUT_INFORMATION_GPT;
1715   {$EXTERNALSYM DRIVE_LAYOUT_INFORMATION_GPT}
1716   TDriveLayoutInformationGpt = DRIVE_LAYOUT_INFORMATION_GPT;
1717   PDriveLayoutInformationGpt = PDRIVE_LAYOUT_INFORMATION_GPT;
1718 
1719 //
1720 // MBR specific drive layout information.
1721 //
1722 
1723   PDRIVE_LAYOUT_INFORMATION_MBR = ^DRIVE_LAYOUT_INFORMATION_MBR;
1724   {$EXTERNALSYM PDRIVE_LAYOUT_INFORMATION_MBR}
1725   _DRIVE_LAYOUT_INFORMATION_MBR = record
1726     Signature: DWORD;
1727   end;
1728   {$EXTERNALSYM _DRIVE_LAYOUT_INFORMATION_MBR}
1729   DRIVE_LAYOUT_INFORMATION_MBR = _DRIVE_LAYOUT_INFORMATION_MBR;
1730   {$EXTERNALSYM DRIVE_LAYOUT_INFORMATION_MBR}
1731   TDriveLayoutInformationMbr = DRIVE_LAYOUT_INFORMATION_MBR;
1732   PDriveLayoutInformationMbr = PDRIVE_LAYOUT_INFORMATION_MBR;
1733 
1734 //
1735 // The structure DRIVE_LAYOUT_INFORMATION_EX is used with the
1736 // IOCTL_SET_DRIVE_LAYOUT_EX and IOCTL_GET_DRIVE_LAYOUT_EX calls.
1737 //
1738 
1739   PDRIVE_LAYOUT_INFORMATION_EX = ^DRIVE_LAYOUT_INFORMATION_EX;
1740   {$EXTERNALSYM PDRIVE_LAYOUT_INFORMATION_EX}
1741   _DRIVE_LAYOUT_INFORMATION_EX = record
1742     PartitionStyle: DWORD;
1743     PartitionCount: DWORD;
1744     Union: record
1745       case Integer of
1746         0: (Mbr: DRIVE_LAYOUT_INFORMATION_MBR);
1747         1: (Gpt: DRIVE_LAYOUT_INFORMATION_GPT);
1748     end;
1749     PartitionEntry: array [0..0] of PARTITION_INFORMATION_EX;
1750   end;
1751   {$EXTERNALSYM _DRIVE_LAYOUT_INFORMATION_EX}
1752   DRIVE_LAYOUT_INFORMATION_EX = _DRIVE_LAYOUT_INFORMATION_EX;
1753   {$EXTERNALSYM DRIVE_LAYOUT_INFORMATION_EX}
1754   TDriveLayoutInformationEx = DRIVE_LAYOUT_INFORMATION_EX;
1755   PDriveLayoutInformationEx = PDRIVE_LAYOUT_INFORMATION_EX;
1756 
1757 //
1758 // The DISK_GEOMETRY_EX structure is returned on issuing an
1759 // IOCTL_DISK_GET_DRIVE_GEOMETRY_EX ioctl.
1760 //
1761 
1762   _DETECTION_TYPE = (
1763     DetectNone,
1764     DetectInt13,
1765     DetectExInt13);
1766   {$EXTERNALSYM _DETECTION_TYPE}
1767   DETECTION_TYPE = _DETECTION_TYPE;
1768   {$EXTERNALSYM DETECTION_TYPE}
1769   TDetectionType = DETECTION_TYPE;
1770 
1771   PDISK_INT13_INFO = ^DISK_INT13_INFO;
1772   {$EXTERNALSYM PDISK_INT13_INFO}
1773   _DISK_INT13_INFO = record
1774     DriveSelect: WORD;
1775     MaxCylinders: DWORD;
1776     SectorsPerTrack: WORD;
1777     MaxHeads: WORD;
1778     NumberDrives: WORD;
1779   end;
1780   {$EXTERNALSYM _DISK_INT13_INFO}
1781   DISK_INT13_INFO = _DISK_INT13_INFO;
1782   {$EXTERNALSYM DISK_INT13_INFO}
1783   TDiskInt13Info = DISK_INT13_INFO;
1784   PDiskInt13Info = PDISK_INT13_INFO;
1785 
1786   PDISK_EX_INT13_INFO = ^DISK_EX_INT13_INFO;
1787   {$EXTERNALSYM PDISK_EX_INT13_INFO}
1788   _DISK_EX_INT13_INFO = record
1789     ExBufferSize: WORD;
1790     ExFlags: WORD;
1791     ExCylinders: DWORD;
1792     ExHeads: DWORD;
1793     ExSectorsPerTrack: DWORD;
1794     ExSectorsPerDrive: DWORD64;
1795     ExSectorSize: WORD;
1796     ExReserved: WORD;
1797   end;
1798   {$EXTERNALSYM _DISK_EX_INT13_INFO}
1799   DISK_EX_INT13_INFO = _DISK_EX_INT13_INFO;
1800   {$EXTERNALSYM DISK_EX_INT13_INFO}
1801   TDiskExInt13Info = DISK_EX_INT13_INFO;
1802   PDiskExInt13Info = PDISK_EX_INT13_INFO;
1803 
1804   PDISK_DETECTION_INFO = ^DISK_DETECTION_INFO;
1805   {$EXTERNALSYM PDISK_DETECTION_INFO}
1806   _DISK_DETECTION_INFO = record
1807     SizeOfDetectInfo: DWORD;
1808     DetectionType: DETECTION_TYPE;
1809     case Integer of
1810       0: (
1811         //
1812         // If DetectionType == DETECTION_INT13 then we have just the Int13
1813         // information.
1814         //
1815         Int13: DISK_INT13_INFO;
1816         //
1817         // If DetectionType == DETECTION_EX_INT13, then we have the
1818         // extended int 13 information.
1819         //
1820         ExInt13: DISK_EX_INT13_INFO); // If DetectionType == DetectExInt13
1821   end;
1822   {$EXTERNALSYM _DISK_DETECTION_INFO}
1823   DISK_DETECTION_INFO = _DISK_DETECTION_INFO;
1824   {$EXTERNALSYM DISK_DETECTION_INFO}
1825   TDiskDetectionInfo = DISK_DETECTION_INFO;
1826   PDiskDetectionInfo = PDISK_DETECTION_INFO;
1827 
1828   PDISK_PARTITION_INFO = ^DISK_PARTITION_INFO;
1829   {$EXTERNALSYM PDISK_PARTITION_INFO}
1830   _DISK_PARTITION_INFO = record
1831     SizeOfPartitionInfo: DWORD;
1832     PartitionStyle: PARTITION_STYLE; // PartitionStyle = RAW, GPT or MBR
1833     case Integer of
1834       0: (                           // If PartitionStyle == MBR
1835         Signature: DWORD; // MBR Signature
1836         CheckSum: DWORD); // MBR CheckSum
1837       1: (                           // If PartitionStyle == GPT
1838         DiskId: GUID);
1839   end;
1840   {$EXTERNALSYM _DISK_PARTITION_INFO}
1841   DISK_PARTITION_INFO = _DISK_PARTITION_INFO;
1842   {$EXTERNALSYM DISK_PARTITION_INFO}
1843   TDiskPartitionInfo = DISK_PARTITION_INFO;
1844   PDiskPartitionInfo = PDISK_PARTITION_INFO;
1845 
1846 //
1847 // The Geometry structure is a variable length structure composed of a
1848 // DISK_GEOMETRY_EX structure followed by a DISK_PARTITION_INFO structure
1849 // followed by a DISK_DETECTION_DATA structure.
1850 //
1851 
1852 type
1853   PDISK_GEOMETRY_EX = ^DISK_GEOMETRY_EX;
1854   {$EXTERNALSYM PDISK_GEOMETRY_EX}
1855   _DISK_GEOMETRY_EX = record
1856     Geometry: DISK_GEOMETRY;    // Standard disk geometry: may be faked by driver.
1857     DiskSize: LARGE_INTEGER;    // Must always be correct
1858     Data: array [0..0] of BYTE; // Partition, Detect info
1859   end;
1860   {$EXTERNALSYM _DISK_GEOMETRY_EX}
1861   DISK_GEOMETRY_EX = _DISK_GEOMETRY_EX;
1862   {$EXTERNALSYM DISK_GEOMETRY_EX}
1863   TDiskGeometryEx = DISK_GEOMETRY_EX;
1864   PDiskGeometryEx = PDISK_GEOMETRY_EX;
1865 
1866 function DiskGeometryGetPartition(Geometry: PDiskGeometryEx): PDiskPartitionInfo;
1867 {$EXTERNALSYM DiskGeometryGetPartition}
1868 
1869 function DiskGeometryGetDetect(Geometry: PDiskGeometryEx): PDiskDetectionInfo;
1870 {$EXTERNALSYM DiskGeometryGetDetect}
1871 
1872 //
1873 // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
1874 // number for the handle.  This is used to determine if a disk
1875 // is attached to the primary or secondary IDE controller.
1876 //
1877 type
1878   PDISK_CONTROLLER_NUMBER = ^DISK_CONTROLLER_NUMBER;
1879   {$EXTERNALSYM PDISK_CONTROLLER_NUMBER}
1880   _DISK_CONTROLLER_NUMBER = record
1881     ControllerNumber: DWORD;
1882     DiskNumber: DWORD;
1883   end;
1884   {$EXTERNALSYM _DISK_CONTROLLER_NUMBER}
1885   DISK_CONTROLLER_NUMBER = _DISK_CONTROLLER_NUMBER;
1886   {$EXTERNALSYM DISK_CONTROLLER_NUMBER}
1887   TDiskControllerNumber = DISK_CONTROLLER_NUMBER;
1888   PDiskControllerNumber = PDISK_CONTROLLER_NUMBER;
1889 
1890 //
1891 // IOCTL_DISK_SET_CACHE allows the caller to get or set the state of the disk
1892 // read/write caches.
1893 //
1894 // If the structure is provided as the input buffer for the ioctl the read &
1895 // write caches will be enabled or disabled depending on the parameters
1896 // provided.
1897 //
1898 // If the structure is provided as an output buffer for the ioctl the state
1899 // of the read & write caches will be returned. If both input and outut buffers
1900 // are provided the output buffer will contain the cache state BEFORE any
1901 // changes are made
1902 //
1903 
1904   DISK_CACHE_RETENTION_PRIORITY = (EqualPriority, KeepPrefetchedData, KeepReadData);
1905   {$EXTERNALSYM DISK_CACHE_RETENTION_PRIORITY}
1906   TDiskCacheRetentionPriority = DISK_CACHE_RETENTION_PRIORITY;
1907 
1908   TDCIScalarPrefetch = record
1909     Minimum: WORD;
1910     Maximum: WORD;
1911     //
1912     // The maximum number of blocks which will be prefetched - useful
1913     // with the scalar limits to set definite upper limits.
1914     //
1915     MaximumBlocks: WORD;
1916   end;
1917 
1918   TDCIBlockPrefetch = record
1919     Minimum: WORD;
1920     Maximum: WORD;
1921   end;
1922 
1923   PDISK_CACHE_INFORMATION = ^DISK_CACHE_INFORMATION;
1924   {$EXTERNALSYM PDISK_CACHE_INFORMATION}
1925   _DISK_CACHE_INFORMATION = record
1926 
1927     //
1928     // on return indicates that the device is capable of saving any parameters
1929     // in non-volatile storage.  On send indicates that the device should
1930     // save the state in non-volatile storage.
1931     //
1932 
1933     ParametersSavable: ByteBool;
1934 
1935     //
1936     // Indicates whether the write and read caches are enabled.
1937     //
1938 
1939     ReadCacheEnabled: ByteBool;
1940     WriteCacheEnabled: ByteBool;
1941 
1942     //
1943     // Controls the likelyhood of data remaining in the cache depending on how
1944     // it got there.  Data cached from a READ or WRITE operation may be given
1945     // higher, lower or equal priority to data entered into the cache for other
1946     // means (like prefetch)
1947     //
1948 
1949     ReadRetentionPriority: DISK_CACHE_RETENTION_PRIORITY;
1950     WriteRetentionPriority: DISK_CACHE_RETENTION_PRIORITY;
1951 
1952     //
1953     // Requests for a larger number of blocks than this may have prefetching
1954     // disabled.  If this value is set to 0 prefetch will be disabled.
1955     //
1956 
1957     DisablePrefetchTransferLength: WORD;
1958 
1959     //
1960     // If TRUE then ScalarPrefetch (below) will be valid.  If FALSE then
1961     // the minimum and maximum values should be treated as a block count
1962     // (BlockPrefetch)
1963     //
1964 
1965     PrefetchScalar: ByteBool;
1966 
1967     //
1968     // Contains the minimum and maximum amount of data which will be
1969     // will be prefetched into the cache on a disk operation.  This value
1970     // may either be a scalar multiplier of the transfer length of the request,
1971     // or an abolute number of disk blocks.  PrefetchScalar (above) indicates
1972     // which interpretation is used.
1973     //
1974 
1975     case Integer of
1976       0: (ScalarPrefetch: TDCIScalarPrefetch);
1977       1: (BlockPrefetch: TDCIBlockPrefetch);
1978 
1979   end;
1980   {$EXTERNALSYM _DISK_CACHE_INFORMATION}
1981   DISK_CACHE_INFORMATION = _DISK_CACHE_INFORMATION;
1982   {$EXTERNALSYM DISK_CACHE_INFORMATION}
1983   TDiskCacheInformation = DISK_CACHE_INFORMATION;
1984   PDiskCacheInformation = PDISK_CACHE_INFORMATION;
1985 
1986 //
1987 // IOCTL_DISK_GROW_PARTITION will update the size of a partition
1988 // by adding sectors to the length. The number of sectors must be
1989 // predetermined by examining PARTITION_INFORMATION.
1990 //
1991 
1992   PDISK_GROW_PARTITION = ^DISK_GROW_PARTITION;
1993   {$EXTERNALSYM PDISK_GROW_PARTITION}
1994   _DISK_GROW_PARTITION = record
1995     PartitionNumber: DWORD;
1996     BytesToGrow: LARGE_INTEGER;
1997   end;
1998   {$EXTERNALSYM _DISK_GROW_PARTITION}
1999   DISK_GROW_PARTITION = _DISK_GROW_PARTITION;
2000   {$EXTERNALSYM DISK_GROW_PARTITION}
2001   TDiskGrowPartition = DISK_GROW_PARTITION;
2002   PDiskGrowPartition = PDISK_GROW_PARTITION;
2003 
2004 ///////////////////////////////////////////////////////
2005 //                                                   //
2006 // The following structures define disk performance  //
2007 // statistics: specifically the locations of all the //
2008 // reads and writes which have occurred on the disk.  //
2009 //                                                   //
2010 // To use these structures, you must issue an IOCTL_ //
2011 // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to    //
2012 // obtain the basic histogram information. The       //
2013 // number of buckets which must allocated is part of //
2014 // this structure. Allocate the required number of   //
2015 // buckets and call an IOCTL_DISK_HIST_DATA to fill  //
2016 // in the data                                       //
2017 //                                                   //
2018 ///////////////////////////////////////////////////////
2019 
2020 const
2021   HIST_NO_OF_BUCKETS = 24;
2022   {$EXTERNALSYM HIST_NO_OF_BUCKETS}
2023 
2024 type
2025   PHISTOGRAM_BUCKET = ^HISTOGRAM_BUCKET;
2026   {$EXTERNALSYM PHISTOGRAM_BUCKET}
2027   _HISTOGRAM_BUCKET = record
2028     Reads: DWORD;
2029     Writes: DWORD;
2030   end;
2031   {$EXTERNALSYM _HISTOGRAM_BUCKET}
2032   HISTOGRAM_BUCKET = _HISTOGRAM_BUCKET;
2033   {$EXTERNALSYM HISTOGRAM_BUCKET}
2034   THistogramBucket = HISTOGRAM_BUCKET;
2035   PHistogramBucket = PHISTOGRAM_BUCKET;
2036 
2037 const
2038   HISTOGRAM_BUCKET_SIZE = SizeOf(HISTOGRAM_BUCKET);
2039   {$EXTERNALSYM HISTOGRAM_BUCKET_SIZE}
2040 
2041 type
2042   PDISK_HISTOGRAM = ^DISK_HISTOGRAM;
2043   {$EXTERNALSYM PDISK_HISTOGRAM}
2044   _DISK_HISTOGRAM = record
2045     DiskSize: LARGE_INTEGER;
2046     Start: LARGE_INTEGER;
2047     End_: LARGE_INTEGER;
2048     Average: LARGE_INTEGER;
2049     AverageRead: LARGE_INTEGER;
2050     AverageWrite: LARGE_INTEGER;
2051     Granularity: DWORD;
2052     Size: DWORD;
2053     ReadCount: DWORD;
2054     WriteCount: DWORD;
2055     Histogram: PHISTOGRAM_BUCKET;
2056   end;
2057   {$EXTERNALSYM _DISK_HISTOGRAM}
2058   DISK_HISTOGRAM = _DISK_HISTOGRAM;
2059   {$EXTERNALSYM DISK_HISTOGRAM}
2060   TDiskHistogram = DISK_HISTOGRAM;
2061   PDiskHistogram = PDISK_HISTOGRAM;
2062 
2063 const
2064   DISK_HISTOGRAM_SIZE = SizeOf(DISK_HISTOGRAM);
2065   {$EXTERNALSYM DISK_HISTOGRAM_SIZE}
2066 
2067 ///////////////////////////////////////////////////////
2068 //                                                   //
2069 // The following structures define disk debugging    //
2070 // capabilities. The IOCTLs are directed to one of   //
2071 // the two disk filter drivers.                      //
2072 //                                                   //
2073 // DISKPERF is a utilty for collecting disk request  //
2074 // statistics.                                       //
2075 //                                                   //
2076 // SIMBAD is a utility for injecting faults in       //
2077 // IO requests to disks.                             //
2078 //                                                   //
2079 ///////////////////////////////////////////////////////
2080 
2081 //
2082 // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
2083 // request. This ioctl collects summary disk request statistics used
2084 // in measuring performance.
2085 //
2086 
2087 type
2088   PDISK_PERFORMANCE = ^DISK_PERFORMANCE;
2089   {$EXTERNALSYM PDISK_PERFORMANCE}
2090   _DISK_PERFORMANCE = record
2091     BytesRead: LARGE_INTEGER;
2092     BytesWritten: LARGE_INTEGER;
2093     ReadTime: LARGE_INTEGER;
2094     WriteTime: LARGE_INTEGER;
2095     IdleTime: LARGE_INTEGER;
2096     ReadCount: DWORD;
2097     WriteCount: DWORD;
2098     QueueDepth: DWORD;
2099     SplitCount: DWORD;
2100     QueryTime: LARGE_INTEGER;
2101     StorageDeviceNumber: DWORD;
2102     StorageManagerName: array [0..7] of WCHAR;
2103   end;
2104   {$EXTERNALSYM _DISK_PERFORMANCE}
2105   DISK_PERFORMANCE = _DISK_PERFORMANCE;
2106   {$EXTERNALSYM DISK_PERFORMANCE}
2107   TDiskPerformance = DISK_PERFORMANCE;
2108   PDiskPerformance = PDISK_PERFORMANCE;
2109 
2110 //
2111 // This structure defines the disk logging record. When disk logging
2112 // is enabled, one of these is written to an internal buffer for each
2113 // disk request.
2114 //
2115 
2116   PDISK_RECORD = ^DISK_RECORD;
2117   {$EXTERNALSYM PDISK_RECORD}
2118   _DISK_RECORD = record
2119     ByteOffset: LARGE_INTEGER;
2120     StartTime: LARGE_INTEGER;
2121     EndTime: LARGE_INTEGER;
2122     VirtualAddress: PVOID;
2123     NumberOfBytes: DWORD;
2124     DeviceNumber: BYTE;
2125     ReadRequest: ByteBool;
2126   end;
2127   {$EXTERNALSYM _DISK_RECORD}
2128   DISK_RECORD = _DISK_RECORD;
2129   {$EXTERNALSYM DISK_RECORD}
2130   TDiskRecord = DISK_RECORD;
2131   PDiskRecord = PDISK_RECORD;
2132 
2133 //
2134 // The following structure is exchanged on an IOCTL_DISK_LOG request.
2135 // Not all fields are valid with each function type.
2136 //
2137 
2138   PDISK_LOGGING = ^DISK_LOGGING;
2139   {$EXTERNALSYM PDISK_LOGGING}
2140   _DISK_LOGGING = record
2141     Function_: BYTE;
2142     BufferAddress: PVOID;
2143     BufferSize: DWORD;
2144   end;
2145   {$EXTERNALSYM _DISK_LOGGING}
2146   DISK_LOGGING = _DISK_LOGGING;
2147   {$EXTERNALSYM DISK_LOGGING}
2148   TDiskLogging = DISK_LOGGING;
2149   PDiskLogging = PDISK_LOGGING;
2150 
2151 //
2152 // Disk logging functions
2153 //
2154 // Start disk logging. Only the Function and BufferSize fields are valid.
2155 //
2156 
2157 const
2158   DISK_LOGGING_START = 0;
2159   {$EXTERNALSYM DISK_LOGGING_START}
2160 
2161 //
2162 // Stop disk logging. Only the Function field is valid.
2163 //
2164 
2165   DISK_LOGGING_STOP = 1;
2166   {$EXTERNALSYM DISK_LOGGING_STOP}
2167 
2168 //
2169 // Return disk log. All fields are valid. Data will be copied from internal
2170 // buffer to buffer specified for the number of bytes requested.
2171 //
2172 
2173   DISK_LOGGING_DUMP = 2;
2174   {$EXTERNALSYM DISK_LOGGING_DUMP}
2175 
2176 //
2177 // DISK BINNING
2178 //
2179 // DISKPERF will keep counters for IO that falls in each of these ranges.
2180 // The application determines the number and size of the ranges.
2181 // Joe Lin wanted me to keep it flexible as possible, for instance, IO
2182 // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
2183 //
2184 
2185   DISK_BINNING = 3;
2186   {$EXTERNALSYM DISK_BINNING}
2187 
2188 //
2189 // Bin types
2190 //
2191 
2192 type
2193   _BIN_TYPES = (RequestSize, RequestLocation);
2194   {$EXTERNALSYM _BIN_TYPES}
2195   BIN_TYPES = _BIN_TYPES;
2196   {$EXTERNALSYM BIN_TYPES}
2197   TBinTypes = _BIN_TYPES;
2198 
2199 //
2200 // Bin ranges
2201 //
2202 
2203   PBIN_RANGE = ^BIN_RANGE;
2204   {$EXTERNALSYM PBIN_RANGE}
2205   _BIN_RANGE = record
2206     StartValue: LARGE_INTEGER;
2207     Length: LARGE_INTEGER;
2208   end;
2209   {$EXTERNALSYM _BIN_RANGE}
2210   BIN_RANGE = _BIN_RANGE;
2211   {$EXTERNALSYM BIN_RANGE}
2212   TBinRange = BIN_RANGE;
2213   PBinRange = PBIN_RANGE;
2214 
2215 //
2216 // Bin definition
2217 //
2218 
2219   PPERF_BIN = ^PERF_BIN;
2220   {$EXTERNALSYM PPERF_BIN}
2221   _PERF_BIN = record
2222     NumberOfBins: DWORD;
2223     TypeOfBin: DWORD;
2224     BinsRanges: array [0..0] of BIN_RANGE;
2225   end;
2226   {$EXTERNALSYM _PERF_BIN}
2227   PERF_BIN = _PERF_BIN;
2228   {$EXTERNALSYM PERF_BIN}
2229   TPerfBin = PERF_BIN;
2230   PPerfBin = PPERF_BIN;
2231 
2232 //
2233 // Bin count
2234 //
2235 
2236   PBIN_COUNT = ^BIN_COUNT;
2237   {$EXTERNALSYM PBIN_COUNT}
2238   _BIN_COUNT = record
2239     BinRange: BIN_RANGE;
2240     BinCount: DWORD;
2241   end;
2242   {$EXTERNALSYM _BIN_COUNT}
2243   BIN_COUNT = _BIN_COUNT;
2244   {$EXTERNALSYM BIN_COUNT}
2245   TBinCount = BIN_COUNT;
2246   PBinCount = PBIN_COUNT;
2247 
2248 //
2249 // Bin results
2250 //
2251 
2252   PBIN_RESULTS = ^BIN_RESULTS;
2253   {$EXTERNALSYM PBIN_RESULTS}
2254   _BIN_RESULTS = record
2255     NumberOfBins: DWORD;
2256     BinCounts: array [0..0] of BIN_COUNT;
2257   end;
2258   {$EXTERNALSYM _BIN_RESULTS}
2259   BIN_RESULTS = _BIN_RESULTS;
2260   {$EXTERNALSYM BIN_RESULTS}
2261   TBinResults = BIN_RESULTS;
2262   PBinResults = PBIN_RESULTS;
2263 
2264 //
2265 // Data structures for SMART drive fault prediction.
2266 //
2267 // GETVERSIONINPARAMS contains the data returned from the
2268 // Get Driver Version function.
2269 //
2270 
2271 //#include <pshpack1.h>
2272 
2273   LPGETVERSIONINPARAMS = ^GETVERSIONINPARAMS;
2274   {$EXTERNALSYM LPGETVERSIONINPARAMS}
2275   _GETVERSIONINPARAMS = packed record
2276     bVersion: BYTE;                    // Binary driver version.
2277     bRevision: BYTE;                   // Binary driver revision.
2278     bReserved: BYTE;                   // Not used.
2279     bIDEDeviceMap: BYTE;               // Bit map of IDE devices.
2280     fCapabilities: DWORD;              // Bit mask of driver capabilities.
2281     dwReserved: array [0..3] of DWORD; // For future use.
2282   end;
2283   {$EXTERNALSYM _GETVERSIONINPARAMS}
2284   GETVERSIONINPARAMS = _GETVERSIONINPARAMS;
2285   {$EXTERNALSYM GETVERSIONINPARAMS}
2286   TGetVersionInParams = GETVERSIONINPARAMS;
2287   PGetVersionInParams = LPGETVERSIONINPARAMS;
2288 
2289 //#include <poppack.h>
2290 
2291 //
2292 // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
2293 //
2294 
2295 const
2296   CAP_ATA_ID_CMD   = 1;         // ATA ID command supported
2297   {$EXTERNALSYM CAP_ATA_ID_CMD}
2298   CAP_ATAPI_ID_CMD = 2;         // ATAPI ID command supported
2299   {$EXTERNALSYM CAP_ATAPI_ID_CMD}
2300   CAP_SMART_CMD    = 4;         // SMART commannds supported
2301   {$EXTERNALSYM CAP_SMART_CMD}
2302 
2303 //
2304 // IDE registers
2305 //
2306 
2307 //#include <pshpack1.h>
2308 
2309 type
2310   LPIDEREGS = ^IDEREGS;
2311   {$EXTERNALSYM LPIDEREGS}
2312   _IDEREGS = packed record
2313     bFeaturesReg: BYTE;     // Used for specifying SMART "commands".
2314     bSectorCountReg: BYTE;  // IDE sector count register
2315     bSectorNumberReg: BYTE; // IDE sector number register
2316     bCylLowReg: BYTE;       // IDE low order cylinder value
2317     bCylHighReg: BYTE;      // IDE high order cylinder value
2318     bDriveHeadReg: BYTE;    // IDE drive/head register
2319     bCommandReg: BYTE;      // Actual IDE command.
2320     bReserved: BYTE;        // reserved for future use.  Must be zero.
2321   end;
2322   {$EXTERNALSYM _IDEREGS}
2323   IDEREGS = _IDEREGS;
2324   {$EXTERNALSYM IDEREGS}
2325   TIdeRegs = IDEREGS;
2326   PIdeRegs = LPIDEREGS;
2327 
2328 //#include <poppack.h>
2329 
2330 //
2331 // Valid values for the bCommandReg member of IDEREGS.
2332 //
2333 
2334 const
2335   ATAPI_ID_CMD = $A1;       // Returns ID sector for ATAPI.
2336   {$EXTERNALSYM ATAPI_ID_CMD}
2337   ID_CMD       = $EC;       // Returns ID sector for ATA.
2338   {$EXTERNALSYM ID_CMD}
2339   SMART_CMD    = $B0;       // Performs SMART cmd.
2340                             // Requires valid bFeaturesReg,
2341                             // bCylLowReg, and bCylHighReg
2342   {$EXTERNALSYM SMART_CMD}
2343 
2344 //
2345 // Cylinder register defines for SMART command
2346 //
2347 
2348   SMART_CYL_LOW = $4F;
2349   {$EXTERNALSYM SMART_CYL_LOW}
2350   SMART_CYL_HI  = $C2;
2351   {$EXTERNALSYM SMART_CYL_HI}
2352 
2353 //
2354 // SENDCMDINPARAMS contains the input parameters for the
2355 // Send Command to Drive function.
2356 //
2357 
2358 //#include <pshpack1.h>
2359 
2360 type
2361   LPSENDCMDINPARAMS = ^SENDCMDINPARAMS;
2362   {$EXTERNALSYM LPSENDCMDINPARAMS}
2363   _SENDCMDINPARAMS = packed record
2364     cBufferSize: DWORD;   // Buffer size in bytes
2365     irDriveRegs: IDEREGS; // Structure with drive register values.
2366     bDriveNumber: BYTE;   // Physical drive number to send
2367                           // command to (0,1,2,3).
2368     bReserved: array [0..2] of BYTE;   // Reserved for future expansion.
2369     dwReserved: array [0..3] of DWORD; // For future use.
2370     bBuffer: array [0..0] of BYTE;     // Input buffer.
2371   end;
2372   {$EXTERNALSYM _SENDCMDINPARAMS}
2373   SENDCMDINPARAMS = _SENDCMDINPARAMS;
2374   {$EXTERNALSYM SENDCMDINPARAMS}
2375   TSendCmdInParams = SENDCMDINPARAMS;
2376   PSendCmdInParams = LPSENDCMDINPARAMS;
2377 
2378 //#include <poppack.h>
2379 
2380 //
2381 // Status returned from driver
2382 //
2383 
2384 //#include <pshpack1.h>
2385 
2386   LPDRIVERSTATUS = ^DRIVERSTATUS;
2387   {$EXTERNALSYM LPDRIVERSTATUS}
2388   _DRIVERSTATUS = packed record
2389     bDriverError: BYTE; // Error code from driver,
2390                         // or 0 if no error.
2391     bIDEError: BYTE;    // Contents of IDE Error register.
2392                         // Only valid when bDriverError
2393                         // is SMART_IDE_ERROR.
2394     bReserved: array [0..1] of BYTE;   // Reserved for future expansion.
2395     dwReserved: array [0..1] of DWORD; // Reserved for future expansion.
2396   end;
2397   {$EXTERNALSYM _DRIVERSTATUS}
2398   DRIVERSTATUS = _DRIVERSTATUS;
2399   {$EXTERNALSYM DRIVERSTATUS}
2400   TDriverStatus = DRIVERSTATUS;
2401   PDriverStatus = LPDRIVERSTATUS;
2402 
2403 //#include <poppack.h>
2404 
2405 //
2406 // bDriverError values
2407 //
2408 
2409 const
2410   SMART_NO_ERROR         = 0; // No error
2411   {$EXTERNALSYM SMART_NO_ERROR}
2412   SMART_IDE_ERROR        = 1; // Error from IDE controller
2413   {$EXTERNALSYM SMART_IDE_ERROR}
2414   SMART_INVALID_FLAG     = 2; // Invalid command flag
2415   {$EXTERNALSYM SMART_INVALID_FLAG}
2416   SMART_INVALID_COMMAND  = 3; // Invalid command byte
2417   {$EXTERNALSYM SMART_INVALID_COMMAND}
2418   SMART_INVALID_BUFFER   = 4; // Bad buffer (null, invalid addr..)
2419   {$EXTERNALSYM SMART_INVALID_BUFFER}
2420   SMART_INVALID_DRIVE    = 5; // Drive number not valid
2421   {$EXTERNALSYM SMART_INVALID_DRIVE}
2422   SMART_INVALID_IOCTL    = 6; // Invalid IOCTL
2423   {$EXTERNALSYM SMART_INVALID_IOCTL}
2424   SMART_ERROR_NO_MEM     = 7; // Could not lock user's buffer
2425   {$EXTERNALSYM SMART_ERROR_NO_MEM}
2426   SMART_INVALID_REGISTER = 8; // Some IDE Register not valid
2427   {$EXTERNALSYM SMART_INVALID_REGISTER}
2428   SMART_NOT_SUPPORTED    = 9; // Invalid cmd flag set
2429   {$EXTERNALSYM SMART_NOT_SUPPORTED}
2430   SMART_NO_IDE_DEVICE    = 10; // Cmd issued to device not present
2431   {$EXTERNALSYM SMART_NO_IDE_DEVICE}
2432                                // although drive number is valid
2433 
2434 //
2435 // SMART sub commands for execute offline diags
2436 //
2437 
2438   SMART_OFFLINE_ROUTINE_OFFLINE   = 0;
2439   {$EXTERNALSYM SMART_OFFLINE_ROUTINE_OFFLINE}
2440   SMART_SHORT_SELFTEST_OFFLINE    = 1;
2441   {$EXTERNALSYM SMART_SHORT_SELFTEST_OFFLINE}
2442   SMART_EXTENDED_SELFTEST_OFFLINE = 2;
2443   {$EXTERNALSYM SMART_EXTENDED_SELFTEST_OFFLINE}
2444   SMART_ABORT_OFFLINE_SELFTEST    = 127;
2445   {$EXTERNALSYM SMART_ABORT_OFFLINE_SELFTEST}
2446   SMART_SHORT_SELFTEST_CAPTIVE    = 129;
2447   {$EXTERNALSYM SMART_SHORT_SELFTEST_CAPTIVE}
2448   SMART_EXTENDED_SELFTEST_CAPTIVE = 130;
2449   {$EXTERNALSYM SMART_EXTENDED_SELFTEST_CAPTIVE}
2450 
2451 //#include <pshpack1.h>
2452 
2453 type
2454   LPSENDCMDOUTPARAMS = ^SENDCMDOUTPARAMS;
2455   {$EXTERNALSYM LPSENDCMDOUTPARAMS}
2456   _SENDCMDOUTPARAMS = packed record
2457     cBufferSize: DWORD;            // Size of bBuffer in bytes
2458     DriverStatus: DRIVERSTATUS;    // Driver status structure.
2459     bBuffer: array [0..0] of BYTE; // Buffer of arbitrary length in which to store the data read from the                                                                                  // drive.
2460   end;
2461   {$EXTERNALSYM _SENDCMDOUTPARAMS}
2462   SENDCMDOUTPARAMS = _SENDCMDOUTPARAMS;
2463   {$EXTERNALSYM SENDCMDOUTPARAMS}
2464   TSendCmdOutParams = SENDCMDOUTPARAMS;
2465   PSendCmdOutParams = LPSENDCMDOUTPARAMS;
2466 
2467 //#include <poppack.h>
2468 
2469 const
2470   READ_ATTRIBUTE_BUFFER_SIZE = 512;
2471   {$EXTERNALSYM READ_ATTRIBUTE_BUFFER_SIZE}
2472   IDENTIFY_BUFFER_SIZE       = 512;
2473   {$EXTERNALSYM IDENTIFY_BUFFER_SIZE}
2474   READ_THRESHOLD_BUFFER_SIZE = 512;
2475   {$EXTERNALSYM READ_THRESHOLD_BUFFER_SIZE}
2476   SMART_LOG_SECTOR_SIZE      = 512;
2477   {$EXTERNALSYM SMART_LOG_SECTOR_SIZE}
2478 
2479 //
2480 // Feature register defines for SMART "sub commands"
2481 //
2482 
2483   READ_ATTRIBUTES             = $D0;
2484   {$EXTERNALSYM READ_ATTRIBUTES}
2485   READ_THRESHOLDS             = $D1;
2486   {$EXTERNALSYM READ_THRESHOLDS}
2487   ENABLE_DISABLE_AUTOSAVE     = $D2;
2488   {$EXTERNALSYM ENABLE_DISABLE_AUTOSAVE}
2489   SAVE_ATTRIBUTE_VALUES       = $D3;
2490   {$EXTERNALSYM SAVE_ATTRIBUTE_VALUES}
2491   EXECUTE_OFFLINE_DIAGS       = $D4;
2492   {$EXTERNALSYM EXECUTE_OFFLINE_DIAGS}
2493   SMART_READ_LOG              = $D5;
2494   {$EXTERNALSYM SMART_READ_LOG}
2495   SMART_WRITE_LOG             = $d6;
2496   {$EXTERNALSYM SMART_WRITE_LOG}
2497   ENABLE_SMART                = $D8;
2498   {$EXTERNALSYM ENABLE_SMART}
2499   DISABLE_SMART               = $D9;
2500   {$EXTERNALSYM DISABLE_SMART}
2501   RETURN_SMART_STATUS         = $DA;
2502   {$EXTERNALSYM RETURN_SMART_STATUS}
2503   ENABLE_DISABLE_AUTO_OFFLINE = $DB;
2504   {$EXTERNALSYM ENABLE_DISABLE_AUTO_OFFLINE}
2505 
2506   IOCTL_CHANGER_BASE = FILE_DEVICE_CHANGER;
2507   {$EXTERNALSYM IOCTL_CHANGER_BASE}
2508 
2509   IOCTL_CHANGER_GET_PARAMETERS = (
2510     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2511     ($0000 shl 2) or METHOD_BUFFERED);
2512   {$EXTERNALSYM IOCTL_CHANGER_GET_PARAMETERS}
2513 
2514   IOCTL_CHANGER_GET_STATUS = (
2515     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2516     ($0001 shl 2) or METHOD_BUFFERED);
2517   {$EXTERNALSYM IOCTL_CHANGER_GET_STATUS}
2518 
2519   IOCTL_CHANGER_GET_PRODUCT_DATA = (
2520     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2521     ($0002 shl 2) or METHOD_BUFFERED);
2522   {$EXTERNALSYM IOCTL_CHANGER_GET_PRODUCT_DATA}
2523 
2524   IOCTL_CHANGER_SET_ACCESS = (
2525     (IOCTL_CHANGER_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
2526     ($0004 shl 2) or METHOD_BUFFERED);
2527   {$EXTERNALSYM IOCTL_CHANGER_SET_ACCESS}
2528 
2529   IOCTL_CHANGER_GET_ELEMENT_STATUS = (
2530     (IOCTL_CHANGER_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
2531     ($0005 shl 2) or METHOD_BUFFERED);
2532   {$EXTERNALSYM IOCTL_CHANGER_GET_ELEMENT_STATUS}
2533 
2534   IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS = (
2535     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2536     ($0006 shl 2) or METHOD_BUFFERED);
2537   {$EXTERNALSYM IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS}
2538 
2539   IOCTL_CHANGER_SET_POSITION = (
2540     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2541     ($0007 shl 2) or METHOD_BUFFERED);
2542   {$EXTERNALSYM IOCTL_CHANGER_SET_POSITION}
2543 
2544   IOCTL_CHANGER_EXCHANGE_MEDIUM = (
2545     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2546     ($0008 shl 2) or METHOD_BUFFERED);
2547   {$EXTERNALSYM IOCTL_CHANGER_EXCHANGE_MEDIUM}
2548 
2549   IOCTL_CHANGER_MOVE_MEDIUM = (
2550     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2551     ($0009 shl 2) or METHOD_BUFFERED);
2552   {$EXTERNALSYM IOCTL_CHANGER_MOVE_MEDIUM}
2553 
2554   IOCTL_CHANGER_REINITIALIZE_TRANSPORT = (
2555     (IOCTL_CHANGER_BASE shl 16) or (FILE_READ_ACCESS shl 14) or
2556     ($000A shl 2) or METHOD_BUFFERED);
2557   {$EXTERNALSYM IOCTL_CHANGER_REINITIALIZE_TRANSPORT}
2558 
2559   IOCTL_CHANGER_QUERY_VOLUME_TAGS = (
2560     (IOCTL_CHANGER_BASE shl 16) or ((FILE_READ_ACCESS or FILE_WRITE_ACCESS) shl 14) or
2561     ($000B shl 2) or METHOD_BUFFERED);
2562   {$EXTERNALSYM IOCTL_CHANGER_QUERY_VOLUME_TAGS}
2563 
2564   MAX_VOLUME_ID_SIZE       = 36;
2565   {$EXTERNALSYM MAX_VOLUME_ID_SIZE}
2566   MAX_VOLUME_TEMPLATE_SIZE = 40;
2567   {$EXTERNALSYM MAX_VOLUME_TEMPLATE_SIZE}
2568 
2569   VENDOR_ID_LENGTH     = 8;
2570   {$EXTERNALSYM VENDOR_ID_LENGTH}
2571   PRODUCT_ID_LENGTH    = 16;
2572   {$EXTERNALSYM PRODUCT_ID_LENGTH}
2573   REVISION_LENGTH      = 4;
2574   {$EXTERNALSYM REVISION_LENGTH}
2575   SERIAL_NUMBER_LENGTH = 32;
2576   {$EXTERNALSYM SERIAL_NUMBER_LENGTH}
2577 
2578 //
2579 // Common structures describing elements.
2580 //
2581 
2582 type
2583   _ELEMENT_TYPE = (
2584     AllElements,        // As defined by SCSI
2585     ChangerTransport,   // As defined by SCSI
2586     ChangerSlot,        // As defined by SCSI
2587     ChangerIEPort,      // As defined by SCSI
2588     ChangerDrive,       // As defined by SCSI
2589     ChangerDoor,        // Front panel, used to access internal of cabinet.
2590     ChangerKeypad,      // Keypad/input on front panel.
2591     ChangerMaxElement); // Placeholder only. Not a valid type.
2592   {$EXTERNALSYM _ELEMENT_TYPE}
2593   ELEMENT_TYPE = _ELEMENT_TYPE;
2594   {$EXTERNALSYM ELEMENT_TYPE}
2595   PELEMENT_TYPE = ^ELEMENT_TYPE;
2596   {$EXTERNALSYM PELEMENT_TYPE}
2597   TElementType = ELEMENT_TYPE;
2598   PElementType = PELEMENT_TYPE;
2599 
2600   PCHANGER_ELEMENT = ^CHANGER_ELEMENT;
2601   {$EXTERNALSYM PCHANGER_ELEMENT}
2602   _CHANGER_ELEMENT = record
2603     ElementType: ELEMENT_TYPE;
2604     ElementAddress: DWORD;
2605   end;
2606   {$EXTERNALSYM _CHANGER_ELEMENT}
2607   CHANGER_ELEMENT = _CHANGER_ELEMENT;
2608   {$EXTERNALSYM CHANGER_ELEMENT}
2609   TChangerElement = CHANGER_ELEMENT;
2610   PChangerElement = PCHANGER_ELEMENT;
2611 
2612   PCHANGER_ELEMENT_LIST = ^CHANGER_ELEMENT_LIST;
2613   {$EXTERNALSYM PCHANGER_ELEMENT_LIST}
2614   _CHANGER_ELEMENT_LIST = record
2615     Element: CHANGER_ELEMENT;
2616     NumberOfElements: DWORD;
2617   end;
2618   {$EXTERNALSYM _CHANGER_ELEMENT_LIST}
2619   CHANGER_ELEMENT_LIST = _CHANGER_ELEMENT_LIST;
2620   {$EXTERNALSYM CHANGER_ELEMENT_LIST}
2621   TChangerElementList = CHANGER_ELEMENT_LIST;
2622   PChangerElementList = PCHANGER_ELEMENT_LIST;
2623 
2624 //
2625 // Definitions for  IOCTL_CHANGER_GET_PARAMETERS
2626 //
2627 
2628 //
2629 // Definitions for Features0 of GET_CHANGER_PARAMETERS
2630 //
2631 
2632 const
2633   CHANGER_BAR_CODE_SCANNER_INSTALLED  = $00000001; // The medium-changer has a bar code scanner installed.
2634   {$EXTERNALSYM CHANGER_BAR_CODE_SCANNER_INSTALLED}
2635   CHANGER_INIT_ELEM_STAT_WITH_RANGE   = $00000002; // The medium-changer has the ability to initialize elements within a specified range.
2636   {$EXTERNALSYM CHANGER_INIT_ELEM_STAT_WITH_RANGE}
2637   CHANGER_CLOSE_IEPORT                = $00000004; // The medium-changer has the ability to close the i/e port door.
2638   {$EXTERNALSYM CHANGER_CLOSE_IEPORT}
2639   CHANGER_OPEN_IEPORT                 = $00000008; // The medium-changer can open the i/e port door.
2640   {$EXTERNALSYM CHANGER_OPEN_IEPORT}
2641 
2642   CHANGER_STATUS_NON_VOLATILE         = $00000010; // The medium-changer uses non-volatile memory for element status information.
2643   {$EXTERNALSYM CHANGER_STATUS_NON_VOLATILE}
2644   CHANGER_EXCHANGE_MEDIA              = $00000020; // The medium-changer supports exchange operations.
2645   {$EXTERNALSYM CHANGER_EXCHANGE_MEDIA}
2646   CHANGER_CLEANER_SLOT                = $00000040; // The medium-changer has a fixed slot designated for cleaner cartridges.
2647   {$EXTERNALSYM CHANGER_CLEANER_SLOT}
2648   CHANGER_LOCK_UNLOCK                 = $00000080; // The medium-changer can be (un)secured to (allow)prevent media removal.
2649   {$EXTERNALSYM CHANGER_LOCK_UNLOCK}
2650 
2651   CHANGER_CARTRIDGE_MAGAZINE          = $00000100; // The medium-changer uses cartridge magazines for some storage slots.
2652   {$EXTERNALSYM CHANGER_CARTRIDGE_MAGAZINE}
2653   CHANGER_MEDIUM_FLIP                 = $00000200; // The medium-changer can flip medium.
2654   {$EXTERNALSYM CHANGER_MEDIUM_FLIP}
2655   CHANGER_POSITION_TO_ELEMENT         = $00000400; // The medium-changer can position the transport to a particular element.
2656   {$EXTERNALSYM CHANGER_POSITION_TO_ELEMENT}
2657   CHANGER_REPORT_IEPORT_STATE         = $00000800; // The medium-changer can determine whether media is present
2658   {$EXTERNALSYM CHANGER_REPORT_IEPORT_STATE}
2659                                                    // in the IE Port.
2660 
2661   CHANGER_STORAGE_DRIVE               = $00001000; // The medium-changer can use a drive as an independent storage element.
2662   {$EXTERNALSYM CHANGER_STORAGE_DRIVE}
2663   CHANGER_STORAGE_IEPORT              = $00002000; // The medium-changer can use a i/e port as an independent storage element.
2664   {$EXTERNALSYM CHANGER_STORAGE_IEPORT}
2665   CHANGER_STORAGE_SLOT                = $00004000; // The medium-changer can use a slot as an independent storage element.
2666   {$EXTERNALSYM CHANGER_STORAGE_SLOT}
2667   CHANGER_STORAGE_TRANSPORT           = $00008000; // The medium-changer can use a transport as an independent storage element.
2668   {$EXTERNALSYM CHANGER_STORAGE_TRANSPORT}
2669 
2670   CHANGER_DRIVE_CLEANING_REQUIRED     = $00010000; // The drives controlled by the medium changer require periodic cleaning
2671   {$EXTERNALSYM CHANGER_DRIVE_CLEANING_REQUIRED}
2672                                                    // initiated by an application.
2673 
2674   CHANGER_PREDISMOUNT_EJECT_REQUIRED  = $00020000; // The medium-changer requires a drive eject command to be issued, before a changer
2675   {$EXTERNALSYM CHANGER_PREDISMOUNT_EJECT_REQUIRED}
2676                                                    // move / exchange command can be issued to the drive.
2677 
2678   CHANGER_CLEANER_ACCESS_NOT_VALID    = $00040000; // The access bit in GES isn't valid for cleaner cartridges.
2679   {$EXTERNALSYM CHANGER_CLEANER_ACCESS_NOT_VALID}
2680   CHANGER_PREMOUNT_EJECT_REQUIRED     = $00080000; // The medium-changer requires a drive eject command to be issued
2681   {$EXTERNALSYM CHANGER_PREMOUNT_EJECT_REQUIRED}
2682                                                    // before a move / exchange command can be issued with the drive as src/dst.
2683 
2684   CHANGER_VOLUME_IDENTIFICATION       = $00100000; // The medium-changer supports volume identification.
2685   {$EXTERNALSYM CHANGER_VOLUME_IDENTIFICATION}
2686   CHANGER_VOLUME_SEARCH               = $00200000; // The medium-changer can search for volume information.
2687   {$EXTERNALSYM CHANGER_VOLUME_SEARCH}
2688   CHANGER_VOLUME_ASSERT               = $00400000; // The medium-changer can verify volume information.
2689   {$EXTERNALSYM CHANGER_VOLUME_ASSERT}
2690   CHANGER_VOLUME_REPLACE              = $00800000; // The medium-changer can replace volume information.
2691   {$EXTERNALSYM CHANGER_VOLUME_REPLACE}
2692   CHANGER_VOLUME_UNDEFINE             = $01000000; // The medium-changer can undefine volume information.
2693   {$EXTERNALSYM CHANGER_VOLUME_UNDEFINE}
2694 
2695   CHANGER_SERIAL_NUMBER_VALID         = $04000000; // The serial number reported in GetProductData is valid
2696   {$EXTERNALSYM CHANGER_SERIAL_NUMBER_VALID}
2697                                                    // and unique.
2698 
2699   CHANGER_DEVICE_REINITIALIZE_CAPABLE = $08000000; // The medium-changer can be issued a ChangerReinitializeUnit.
2700   {$EXTERNALSYM CHANGER_DEVICE_REINITIALIZE_CAPABLE}
2701   CHANGER_KEYPAD_ENABLE_DISABLE       = $10000000; // Indicates that the keypad can be enabled/disabled.
2702   {$EXTERNALSYM CHANGER_KEYPAD_ENABLE_DISABLE}
2703   CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS  = $20000000; // Drives must be empty before access via the door is possible.
2704   {$EXTERNALSYM CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS}
2705 
2706   CHANGER_RESERVED_BIT                = DWORD($80000000); // Will be used to indicate Features1 capability bits.
2707   {$EXTERNALSYM CHANGER_RESERVED_BIT}
2708 
2709 //
2710 // Definitions for Features1 of GET_CHANGER_PARAMETERS
2711 //
2712 
2713   CHANGER_PREDISMOUNT_ALIGN_TO_SLOT  = DWORD($80000001); // The transport must be prepositioned to the slot prior to ejecting the media.
2714   {$EXTERNALSYM CHANGER_PREDISMOUNT_ALIGN_TO_SLOT}
2715   CHANGER_PREDISMOUNT_ALIGN_TO_DRIVE = DWORD($80000002); // The transport must be prepositioned to the drive prior to ejecting the media.
2716   {$EXTERNALSYM CHANGER_PREDISMOUNT_ALIGN_TO_DRIVE}
2717   CHANGER_CLEANER_AUTODISMOUNT       = DWORD($80000004); // The device will move the cleaner cartridge back into the slot when cleaning has completed.
2718   {$EXTERNALSYM CHANGER_CLEANER_AUTODISMOUNT}
2719   CHANGER_TRUE_EXCHANGE_CAPABLE      = DWORD($80000008); // Device can do src -> dest2 exchanges.
2720   {$EXTERNALSYM CHANGER_TRUE_EXCHANGE_CAPABLE}
2721   CHANGER_SLOTS_USE_TRAYS            = DWORD($80000010); // Slots have removable trays, requiring multiple moves for inject/eject.
2722   {$EXTERNALSYM CHANGER_SLOTS_USE_TRAYS}
2723   CHANGER_RTN_MEDIA_TO_ORIGINAL_ADDR = DWORD($80000020); // Media must be returned to the slot from which it originated after a move to another element.
2724   {$EXTERNALSYM CHANGER_RTN_MEDIA_TO_ORIGINAL_ADDR}
2725   CHANGER_CLEANER_OPS_NOT_SUPPORTED  = DWORD($80000040); // Automated cleaning operations are not supported on this device.
2726   {$EXTERNALSYM CHANGER_CLEANER_OPS_NOT_SUPPORTED}
2727   CHANGER_IEPORT_USER_CONTROL_OPEN   = DWORD($80000080); // Indicates that user action is necessary to open a closed ieport.
2728   {$EXTERNALSYM CHANGER_IEPORT_USER_CONTROL_OPEN}
2729   CHANGER_IEPORT_USER_CONTROL_CLOSE  = DWORD($80000100); // Indicates that user action is necessary to close an opened ieport.
2730   {$EXTERNALSYM CHANGER_IEPORT_USER_CONTROL_CLOSE}
2731   CHANGER_MOVE_EXTENDS_IEPORT        = DWORD($80000200); // Indicates that a move media to the ieport extends the tray.
2732   {$EXTERNALSYM CHANGER_MOVE_EXTENDS_IEPORT}
2733   CHANGER_MOVE_RETRACTS_IEPORT       = DWORD($80000400); // Indicates that a move media from the ieport retracts the tray.
2734   {$EXTERNALSYM CHANGER_MOVE_RETRACTS_IEPORT}
2735 
2736 //
2737 // Definitions for MoveFrom, ExchangeFrom, and PositionCapabilities
2738 //
2739 
2740   CHANGER_TO_TRANSPORT = $01; // The device can carry out the operation to a transport from the specified element.
2741   {$EXTERNALSYM CHANGER_TO_TRANSPORT}
2742   CHANGER_TO_SLOT      = $02; // The device can carry out the operation to a slot from the specified element.
2743   {$EXTERNALSYM CHANGER_TO_SLOT}
2744   CHANGER_TO_IEPORT    = $04; // The device can carry out the operation to an IE Port from the specified element.
2745   {$EXTERNALSYM CHANGER_TO_IEPORT}
2746   CHANGER_TO_DRIVE     = $08; // The device can carry out the operation to a drive from the specified element.
2747   {$EXTERNALSYM CHANGER_TO_DRIVE}
2748 
2749 //
2750 // Definitions for LockUnlockCapabilities
2751 //
2752 
2753   LOCK_UNLOCK_IEPORT = $01; // The device can lock/unlock the ieport(s).
2754   {$EXTERNALSYM LOCK_UNLOCK_IEPORT}
2755   LOCK_UNLOCK_DOOR   = $02; // The device can lock/unlock the door(s).
2756   {$EXTERNALSYM LOCK_UNLOCK_DOOR}
2757   LOCK_UNLOCK_KEYPAD = $04; // The device can lock/unlock the keypad.
2758   {$EXTERNALSYM LOCK_UNLOCK_KEYPAD}
2759 
2760 type
2761   PGET_CHANGER_PARAMETERS = ^GET_CHANGER_PARAMETERS;
2762   {$EXTERNALSYM PGET_CHANGER_PARAMETERS}
2763   _GET_CHANGER_PARAMETERS = record
2764     //
2765     // Size of the structure. Can be used for versioning.
2766     //
2767     Size: DWORD;
2768     //
2769     // Number of N element(s) as defined by the Element Address Page (or equivalent...).
2770     //
2771     NumberTransportElements: WORD;
2772     NumberStorageElements: WORD; // for data cartridges only
2773     NumberCleanerSlots: WORD; // for cleaner cartridges
2774     NumberIEElements: WORD;
2775     NumberDataTransferElements: WORD;
2776     //
2777     // Number of doors/front panels (allows user entry into the cabinet).
2778     //
2779     NumberOfDoors: WORD;
2780     //
2781     // The device-specific address (from user manual of the device) of the first N element. Used
2782     // by the UI to relate the various elements to the user.
2783     //
2784     FirstSlotNumber: WORD;
2785     FirstDriveNumber: WORD;
2786     FirstTransportNumber: WORD;
2787     FirstIEPortNumber: WORD;
2788     FirstCleanerSlotAddress: WORD;
2789     //
2790     // Indicates the capacity of each magazine, if they exist.
2791     //
2792     MagazineSize: WORD;
2793     //
2794     // Specifies the approximate number of seconds for when a cleaning should be completed.
2795     // Only applicable if drive cleaning is supported. See Features0.
2796     //
2797     DriveCleanTimeout: DWORD;
2798     //
2799     // See features bits, above.
2800     //
2801     Features0: DWORD;
2802     Features1: DWORD;
2803     //
2804     // Bitmask defining Move from N element to element. Defined by Device Capabilities Page (or equivalent).
2805     // AND-masking with the TO_XXX values will indicate legal destinations.
2806     //
2807     MoveFromTransport: BYTE;
2808     MoveFromSlot: BYTE;
2809     MoveFromIePort: BYTE;
2810     MoveFromDrive: BYTE;
2811     //
2812     // Bitmask defining Exchange from N element to element. Defined by Device Capabilities Page (or equivalent).
2813     // AND-masking with the TO_XXX values will indicate legal destinations.
2814     //
2815     ExchangeFromTransport: BYTE;
2816     ExchangeFromSlot: BYTE;
2817     ExchangeFromIePort: BYTE;
2818     ExchangeFromDrive: BYTE;
2819     //
2820     // Bitmask defining which elements are capable of lock/unlock. Valid only if
2821     // CHANGER_LOCK_UNLOCK is set in Features0.
2822     //
2823     LockUnlockCapabilities: BYTE;
2824     //
2825     // Bitmask defining which elements valid for positioning operations. Valid only if
2826     // CHANGER_POSITION_TO_ELEMENT is set in Features0.
2827     //
2828     PositionCapabilities: BYTE;
2829     //
2830     // For future expansion.
2831     //
2832     Reserved1: array [0..1] of BYTE;
2833     Reserved2: array [0..1] of DWORD;
2834   end;
2835   {$EXTERNALSYM _GET_CHANGER_PARAMETERS}
2836   GET_CHANGER_PARAMETERS = _GET_CHANGER_PARAMETERS;
2837   {$EXTERNALSYM GET_CHANGER_PARAMETERS}
2838   TGetChangerParameters = GET_CHANGER_PARAMETERS;
2839   PGetChangerParameters = PGET_CHANGER_PARAMETERS;
2840 
2841 //
2842 // Definitions for IOCTL_CHANGER_GET_PRODUCT_DATA
2843 //
2844 
2845   PCHANGER_PRODUCT_DATA = ^CHANGER_PRODUCT_DATA;
2846   {$EXTERNALSYM PCHANGER_PRODUCT_DATA}
2847   _CHANGER_PRODUCT_DATA = record
2848     //
2849     // Device manufacturer's name - based on inquiry data
2850     //
2851     VendorId: array [0..VENDOR_ID_LENGTH - 1] of BYTE;
2852     //
2853     // Product identification as defined by the vendor - based on Inquiry data
2854     //
2855     ProductId: array [0..PRODUCT_ID_LENGTH - 1] of BYTE;
2856     //
2857     // Product revision as defined by the vendor.
2858     //
2859     Revision: array [0..REVISION_LENGTH - 1] of BYTE;
2860     //
2861     // Vendor unique value used to globally identify this device. Can
2862     // be from Vital Product Data, for example.
2863     //
2864     SerialNumber: array [0..SERIAL_NUMBER_LENGTH - 1] of BYTE;
2865     //
2866     // Indicates device type of data transports, as defined by SCSI-2.
2867     //
2868     DeviceType: BYTE;
2869   end;
2870   {$EXTERNALSYM _CHANGER_PRODUCT_DATA}
2871   CHANGER_PRODUCT_DATA = _CHANGER_PRODUCT_DATA;
2872   {$EXTERNALSYM CHANGER_PRODUCT_DATA}
2873   TChangerProductData = CHANGER_PRODUCT_DATA;
2874   PChangerProductData = PCHANGER_PRODUCT_DATA;
2875 
2876 //
2877 // Definitions for IOCTL_CHANGER_SET_ACCESS
2878 //
2879 
2880 const
2881   LOCK_ELEMENT   = 0;
2882   {$EXTERNALSYM LOCK_ELEMENT}
2883   UNLOCK_ELEMENT = 1;
2884   {$EXTERNALSYM UNLOCK_ELEMENT}
2885   EXTEND_IEPORT  = 2;
2886   {$EXTERNALSYM EXTEND_IEPORT}
2887   RETRACT_IEPORT = 3;
2888   {$EXTERNALSYM RETRACT_IEPORT}
2889 
2890 type
2891   PCHANGER_SET_ACCESS = ^CHANGER_SET_ACCESS;
2892   {$EXTERNALSYM PCHANGER_SET_ACCESS}
2893   _CHANGER_SET_ACCESS = record
2894     //
2895     // Element can be ChangerIEPort, ChangerDoor, ChangerKeypad
2896     //
2897     Element: CHANGER_ELEMENT;
2898     //
2899     // See above for possible operations.
2900     //
2901     Control: DWORD;
2902   end;
2903   {$EXTERNALSYM _CHANGER_SET_ACCESS}
2904   CHANGER_SET_ACCESS = _CHANGER_SET_ACCESS;
2905   {$EXTERNALSYM CHANGER_SET_ACCESS}
2906   TChangerSetAccess = CHANGER_SET_ACCESS;
2907   PChangerSetAccess = PCHANGER_SET_ACCESS;
2908 
2909 //
2910 // Definitions for IOCTL_CHANGER_GET_ELEMENT_STATUS
2911 //
2912 
2913 //
2914 // Input buffer.
2915 //
2916 
2917   PCHANGER_READ_ELEMENT_STATUS = ^CHANGER_READ_ELEMENT_STATUS;
2918   {$EXTERNALSYM PCHANGER_READ_ELEMENT_STATUS}
2919   _CHANGER_READ_ELEMENT_STATUS = record
2920     //
2921     // List describing the elements and range on which to return information.
2922     //
2923     ElementList: CHANGER_ELEMENT_LIST;
2924     //
2925     // Indicates whether volume tag information is to be returned.
2926     //
2927     VolumeTagInfo: ByteBool;
2928   end;
2929   {$EXTERNALSYM _CHANGER_READ_ELEMENT_STATUS}
2930   CHANGER_READ_ELEMENT_STATUS = _CHANGER_READ_ELEMENT_STATUS;
2931   {$EXTERNALSYM CHANGER_READ_ELEMENT_STATUS}
2932   TChangerReadElementStatus = CHANGER_READ_ELEMENT_STATUS;
2933   PChangerReadElementStatus = PCHANGER_READ_ELEMENT_STATUS;
2934 
2935 //
2936 // Output buffer.
2937 //
2938 
2939   PCHANGER_ELEMENT_STATUS = ^CHANGER_ELEMENT_STATUS;
2940   {$EXTERNALSYM PCHANGER_ELEMENT_STATUS}
2941   _CHANGER_ELEMENT_STATUS = record
2942     //
2943     // Element to which this structure refers.
2944     //
2945     Element: CHANGER_ELEMENT;
2946     //
2947     // Address of the element from which the media was originally moved.
2948     // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
2949     // Needs to be converted to a zero-based offset from the device-unique value.
2950     //
2951     SrcElementAddress: CHANGER_ELEMENT;
2952     //
2953     // See below.
2954     //
2955     Flags: DWORD;
2956     //
2957     // See below for possible values.
2958     //
2959     ExceptionCode: DWORD;
2960     //
2961     // Scsi Target Id of this element.
2962     // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
2963     //
2964     TargetId: BYTE;
2965     //
2966     // LogicalUnitNumber of this element.
2967     // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
2968     //
2969     Lun: BYTE;
2970     Reserved: WORD;
2971     //
2972     // Primary volume identification for the media.
2973     // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
2974     //
2975     PrimaryVolumeID: array [0..MAX_VOLUME_ID_SIZE - 1] of BYTE;
2976     //
2977     // Alternate volume identification for the media.
2978     // Valid for two-sided media only, and pertains to the id. of the inverted side.
2979     // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
2980     //
2981     AlternateVolumeID: array [0..MAX_VOLUME_ID_SIZE - 1] of BYTE;
2982   end;
2983   {$EXTERNALSYM _CHANGER_ELEMENT_STATUS}
2984   CHANGER_ELEMENT_STATUS = _CHANGER_ELEMENT_STATUS;
2985   {$EXTERNALSYM CHANGER_ELEMENT_STATUS}
2986   TChangerElementStatus = CHANGER_ELEMENT_STATUS;
2987   PChangerElementStatus = PCHANGER_ELEMENT_STATUS;
2988 
2989   PCHANGER_ELEMENT_STATUS_EX = ^CHANGER_ELEMENT_STATUS_EX;
2990   {$EXTERNALSYM PCHANGER_ELEMENT_STATUS_EX}
2991   _CHANGER_ELEMENT_STATUS_EX = record
2992     //
2993     // Element to which this structure refers.
2994     //
2995     Element: CHANGER_ELEMENT;
2996     //
2997     // Address of the element from which the media was originally moved.
2998     // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
2999     // Needs to be converted to a zero-based offset from the device-unique value.
3000     //
3001     SrcElementAddress: CHANGER_ELEMENT;
3002     //
3003     // See below.
3004     //
3005     Flags: DWORD;
3006     //
3007     // See below for possible values.
3008     //
3009     ExceptionCode: DWORD;
3010     //
3011     // Scsi Target Id of this element.
3012     // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
3013     //
3014     TargetId: BYTE;
3015     //
3016     // LogicalUnitNumber of this element.
3017     // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
3018     //
3019     Lun: BYTE;
3020     Reserved: WORD;
3021     //
3022     // Primary volume identification for the media.
3023     // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
3024     //
3025     PrimaryVolumeID: array [0..MAX_VOLUME_ID_SIZE - 1] of BYTE;
3026     //
3027     // Alternate volume identification for the media.
3028     // Valid for two-sided media only, and pertains to the id. of the inverted side.
3029     // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
3030     //
3031     AlternateVolumeID: array [0..MAX_VOLUME_ID_SIZE - 1] of BYTE;
3032     //
3033     // Vendor ID
3034     //
3035     VendorIdentification: array [0..VENDOR_ID_LENGTH - 1] of BYTE;
3036     //
3037     // Product ID
3038     //
3039     ProductIdentification: array [0..PRODUCT_ID_LENGTH - 1] of BYTE;
3040     //
3041     // Serial number
3042     //
3043     SerialNumber: array [0..SERIAL_NUMBER_LENGTH - 1] of BYTE;
3044   end;
3045   {$EXTERNALSYM _CHANGER_ELEMENT_STATUS_EX}
3046   CHANGER_ELEMENT_STATUS_EX = _CHANGER_ELEMENT_STATUS_EX;
3047   {$EXTERNALSYM CHANGER_ELEMENT_STATUS_EX}
3048   TChangerElementStatusEx = CHANGER_ELEMENT_STATUS_EX;
3049   PChangerElementStatusEx = PCHANGER_ELEMENT_STATUS_EX;
3050 
3051 //
3052 // Possible flag values
3053 //
3054 
3055 const
3056   ELEMENT_STATUS_FULL      = $00000001; // Element contains a unit of media.
3057   {$EXTERNALSYM ELEMENT_STATUS_FULL}
3058   ELEMENT_STATUS_IMPEXP    = $00000002; // Media in i/e port was placed there by an operator.
3059   {$EXTERNALSYM ELEMENT_STATUS_IMPEXP}
3060   ELEMENT_STATUS_EXCEPT    = $00000004; // Element is in an abnormal state; check ExceptionCode field for more information.
3061   {$EXTERNALSYM ELEMENT_STATUS_EXCEPT}
3062   ELEMENT_STATUS_ACCESS    = $00000008; // Access to the i/e port from the medium changer is allowed.
3063   {$EXTERNALSYM ELEMENT_STATUS_ACCESS}
3064   ELEMENT_STATUS_EXENAB    = $00000010; // Export of media is supported.
3065   {$EXTERNALSYM ELEMENT_STATUS_EXENAB}
3066   ELEMENT_STATUS_INENAB    = $00000020; // Import of media is supported.
3067   {$EXTERNALSYM ELEMENT_STATUS_INENAB}
3068 
3069   ELEMENT_STATUS_PRODUCT_DATA = $00000040; // Serial number valid for the drive
3070   {$EXTERNALSYM ELEMENT_STATUS_PRODUCT_DATA}
3071 
3072   ELEMENT_STATUS_LUN_VALID = $00001000; // Lun information is valid.
3073   {$EXTERNALSYM ELEMENT_STATUS_LUN_VALID}
3074   ELEMENT_STATUS_ID_VALID  = $00002000; // SCSI Id information is valid.
3075   {$EXTERNALSYM ELEMENT_STATUS_ID_VALID}
3076   ELEMENT_STATUS_NOT_BUS   = $00008000; // Lun and SCSI Id fields are not on same bus as medium changer.
3077   {$EXTERNALSYM ELEMENT_STATUS_NOT_BUS}
3078   ELEMENT_STATUS_INVERT    = $00400000; // Media in element was inverted (valid only if ELEMENT_STATUS_SVALID bit is set)
3079   {$EXTERNALSYM ELEMENT_STATUS_INVERT}
3080 
3081   ELEMENT_STATUS_SVALID    = $00800000; // SourceElementAddress field and ELEMENT_STATUS_INVERT bit are valid.
3082   {$EXTERNALSYM ELEMENT_STATUS_SVALID}
3083   ELEMENT_STATUS_PVOLTAG   = $10000000; // Primary volume information is valid.
3084   {$EXTERNALSYM ELEMENT_STATUS_PVOLTAG}
3085   ELEMENT_STATUS_AVOLTAG   = $20000000; // Alternate volume information is valid.
3086   {$EXTERNALSYM ELEMENT_STATUS_AVOLTAG}
3087 
3088 //
3089 // ExceptionCode values.
3090 //
3091 
3092   ERROR_LABEL_UNREADABLE    = $00000001; // Bar code scanner could not read bar code label.
3093   {$EXTERNALSYM ERROR_LABEL_UNREADABLE}
3094   ERROR_LABEL_QUESTIONABLE  = $00000002; // Label could be invalid due to unit attention condition.
3095   {$EXTERNALSYM ERROR_LABEL_QUESTIONABLE}
3096   ERROR_SLOT_NOT_PRESENT    = $00000004; // Slot is currently not addressable in the device.
3097   {$EXTERNALSYM ERROR_SLOT_NOT_PRESENT}
3098   ERROR_DRIVE_NOT_INSTALLED = $00000008; // Drive is not installed.
3099   {$EXTERNALSYM ERROR_DRIVE_NOT_INSTALLED}
3100   ERROR_TRAY_MALFUNCTION    = $00000010; // Media tray is malfunctioning/broken.
3101   {$EXTERNALSYM ERROR_TRAY_MALFUNCTION}
3102   ERROR_INIT_STATUS_NEEDED  = $00000011; // An Initialize Element Status command is needed.
3103   {$EXTERNALSYM ERROR_INIT_STATUS_NEEDED}
3104   ERROR_UNHANDLED_ERROR     = DWORD($FFFFFFFF); // Unknown error condition
3105   {$EXTERNALSYM ERROR_UNHANDLED_ERROR}
3106 
3107 //
3108 // Definitions for IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS
3109 //
3110 
3111 type
3112   PCHANGER_INITIALIZE_ELEMENT_STATUS = ^CHANGER_INITIALIZE_ELEMENT_STATUS;
3113   {$EXTERNALSYM PCHANGER_INITIALIZE_ELEMENT_STATUS}
3114   _CHANGER_INITIALIZE_ELEMENT_STATUS = record
3115     //
3116     // List describing the elements and range on which to initialize.
3117     //
3118     ElementList: CHANGER_ELEMENT_LIST;
3119     //
3120     // Indicates whether a bar code scan should be used. Only applicable if
3121     // CHANGER_BAR_CODE_SCANNER_INSTALLED is set in Features0 of CHANGER_GET_PARAMETERS.
3122     //
3123     BarCodeScan: ByteBool;
3124   end;
3125   {$EXTERNALSYM _CHANGER_INITIALIZE_ELEMENT_STATUS}
3126   CHANGER_INITIALIZE_ELEMENT_STATUS = _CHANGER_INITIALIZE_ELEMENT_STATUS;
3127   {$EXTERNALSYM CHANGER_INITIALIZE_ELEMENT_STATUS}
3128   TChangerInitializeElementStatus = CHANGER_INITIALIZE_ELEMENT_STATUS;
3129   PChangerInitializeElementStatus = PCHANGER_INITIALIZE_ELEMENT_STATUS;
3130 
3131 //
3132 // Definitions for IOCTL_CHANGER_SET_POSITION
3133 //
3134 
3135   PCHANGER_SET_POSITION = ^CHANGER_SET_POSITION;
3136   {$EXTERNALSYM PCHANGER_SET_POSITION}
3137   _CHANGER_SET_POSITION = record
3138     //
3139     // Indicates which transport to move.
3140     //
3141     Transport: CHANGER_ELEMENT;
3142     //
3143     // Indicates the final destination of the transport.
3144     //
3145     Destination: CHANGER_ELEMENT;
3146     //
3147     // Indicates whether the media currently carried by Transport, should be flipped.
3148     //
3149     Flip: ByteBool;
3150   end;
3151   {$EXTERNALSYM _CHANGER_SET_POSITION}
3152   CHANGER_SET_POSITION = _CHANGER_SET_POSITION;
3153   {$EXTERNALSYM CHANGER_SET_POSITION}
3154   TChangerSetPosition = CHANGER_SET_POSITION;
3155   PChangerSetPosition = PCHANGER_SET_POSITION;
3156 
3157 //
3158 // Definitions for IOCTL_CHANGER_EXCHANGE_MEDIUM
3159 //
3160 
3161   PCHANGER_EXCHANGE_MEDIUM = ^CHANGER_EXCHANGE_MEDIUM;
3162   {$EXTERNALSYM PCHANGER_EXCHANGE_MEDIUM}
3163   _CHANGER_EXCHANGE_MEDIUM = record
3164     //
3165     // Indicates which transport to use for the exchange operation.
3166     //
3167     Transport: CHANGER_ELEMENT;
3168     //
3169     // Indicates the source for the media that is to be moved.
3170     //
3171     Source: CHANGER_ELEMENT;
3172     //
3173     // Indicates the final destination of the media originally at Source.
3174     //
3175     Destination1: CHANGER_ELEMENT;
3176     //
3177     // Indicates the destination of the media moved from Destination1.
3178     //
3179     Destination2: CHANGER_ELEMENT;
3180     //
3181     // Indicates whether the medium should be flipped.
3182     //
3183     Flip1: ByteBool;
3184     Flip2: ByteBool;
3185   end;
3186   {$EXTERNALSYM _CHANGER_EXCHANGE_MEDIUM}
3187   CHANGER_EXCHANGE_MEDIUM = _CHANGER_EXCHANGE_MEDIUM;
3188   {$EXTERNALSYM CHANGER_EXCHANGE_MEDIUM}
3189   TChangerExchangeMedium = CHANGER_EXCHANGE_MEDIUM;
3190   PChangerExchangeMedium = PCHANGER_EXCHANGE_MEDIUM;
3191 
3192 //
3193 // Definitions for IOCTL_CHANGER_MOVE_MEDIUM
3194 //
3195 
3196   PCHANGER_MOVE_MEDIUM = ^CHANGER_MOVE_MEDIUM;
3197   {$EXTERNALSYM PCHANGER_MOVE_MEDIUM}
3198   _CHANGER_MOVE_MEDIUM = record
3199     //
3200     // Indicates which transport to use for the move operation.
3201     //
3202     Transport: CHANGER_ELEMENT;
3203     //
3204     // Indicates the source for the media that is to be moved.
3205     //
3206     Source: CHANGER_ELEMENT;
3207     //
3208     // Indicates the destination of the media originally at Source.
3209     //
3210     Destination: CHANGER_ELEMENT;
3211     //
3212     // Indicates whether the media should be flipped.
3213     //
3214     Flip: ByteBool;
3215   end;
3216   {$EXTERNALSYM _CHANGER_MOVE_MEDIUM}
3217   CHANGER_MOVE_MEDIUM = _CHANGER_MOVE_MEDIUM;
3218   {$EXTERNALSYM CHANGER_MOVE_MEDIUM}
3219   TChangerMoveMedium = CHANGER_MOVE_MEDIUM;
3220   PChangerMoveMedium = PCHANGER_MOVE_MEDIUM;
3221 
3222 //
3223 // Definitions for IOCTL_QUERY_VOLUME_TAGS
3224 //
3225 
3226 //
3227 // Input buffer.
3228 //
3229 
3230   PCHANGER_SEND_VOLUME_TAG_INFORMATION = ^CHANGER_SEND_VOLUME_TAG_INFORMATION;
3231   {$EXTERNALSYM PCHANGER_SEND_VOLUME_TAG_INFORMATION}
3232   _CHANGER_SEND_VOLUME_TAG_INFORMATION = record
3233     //
3234     // Describes the starting element for which to return information.
3235     //
3236     StartingElement: CHANGER_ELEMENT;
3237     //
3238     // Indicates the specific action to perform. See below.
3239     //
3240     ActionCode: DWORD;
3241     //
3242     // Template used by the device to search for volume ids.
3243     //
3244     VolumeIDTemplate: array [0..MAX_VOLUME_TEMPLATE_SIZE - 1] of BYTE;
3245   end;
3246   {$EXTERNALSYM _CHANGER_SEND_VOLUME_TAG_INFORMATION}
3247   CHANGER_SEND_VOLUME_TAG_INFORMATION = _CHANGER_SEND_VOLUME_TAG_INFORMATION;
3248   {$EXTERNALSYM CHANGER_SEND_VOLUME_TAG_INFORMATION}
3249   TChangerSendVolumeTagInformation = CHANGER_SEND_VOLUME_TAG_INFORMATION;
3250   PChangerSendVolumeTagInformation = PCHANGER_SEND_VOLUME_TAG_INFORMATION;
3251 
3252 //
3253 // Output buffer.
3254 //
3255 
3256   PREAD_ELEMENT_ADDRESS_INFO = ^READ_ELEMENT_ADDRESS_INFO;
3257   {$EXTERNALSYM PREAD_ELEMENT_ADDRESS_INFO}
3258   _READ_ELEMENT_ADDRESS_INFO = record
3259     //
3260     // Number of elements matching criteria set forth by ActionCode.
3261     //
3262     NumberOfElements: DWORD;
3263     //
3264     // Array of CHANGER_ELEMENT_STATUS structures, one for each element that corresponded
3265     // with the information passed in with the CHANGER_SEND_VOLUME_TAG_INFORMATION structure.
3266     //
3267     ElementStatus: array [0..0] of CHANGER_ELEMENT_STATUS;
3268   end;
3269   {$EXTERNALSYM _READ_ELEMENT_ADDRESS_INFO}
3270   READ_ELEMENT_ADDRESS_INFO = _READ_ELEMENT_ADDRESS_INFO;
3271   {$EXTERNALSYM READ_ELEMENT_ADDRESS_INFO}
3272   TReadElementAddressInfo = READ_ELEMENT_ADDRESS_INFO;
3273   PReadElementAddressInfo = PREAD_ELEMENT_ADDRESS_INFO;
3274 
3275 //
3276 // Possible ActionCode values. See Features0 of CHANGER_GET_PARAMETERS for compatibility with
3277 // the current device.
3278 //
3279 
3280 const
3281   SEARCH_ALL         = $0; // Translate - search all defined volume tags.
3282   {$EXTERNALSYM SEARCH_ALL}
3283   SEARCH_PRIMARY     = $1; // Translate - search only primary volume tags.
3284   {$EXTERNALSYM SEARCH_PRIMARY}
3285   SEARCH_ALTERNATE   = $2; // Translate - search only alternate volume tags.
3286   {$EXTERNALSYM SEARCH_ALTERNATE}
3287   SEARCH_ALL_NO_SEQ  = $4; // Translate - search all defined volume tags but ignore sequence numbers.
3288   {$EXTERNALSYM SEARCH_ALL_NO_SEQ}
3289   SEARCH_PRI_NO_SEQ  = $5; // Translate - search only primary volume tags but ignore sequence numbers.
3290   {$EXTERNALSYM SEARCH_PRI_NO_SEQ}
3291   SEARCH_ALT_NO_SEQ  = $6; // Translate - search only alternate volume tags but ignore sequence numbers.
3292   {$EXTERNALSYM SEARCH_ALT_NO_SEQ}
3293 
3294   ASSERT_PRIMARY     = $8; // Assert - as the primary volume tag - if tag now undefined.
3295   {$EXTERNALSYM ASSERT_PRIMARY}
3296   ASSERT_ALTERNATE   = $9; // Assert - as the alternate volume tag - if tag now undefined.
3297   {$EXTERNALSYM ASSERT_ALTERNATE}
3298 
3299   REPLACE_PRIMARY    = $A; // Replace - the primary volume tag - current tag ignored.
3300   {$EXTERNALSYM REPLACE_PRIMARY}
3301   REPLACE_ALTERNATE  = $B; // Replace - the alternate volume tag - current tag ignored.
3302   {$EXTERNALSYM REPLACE_ALTERNATE}
3303 
3304   UNDEFINE_PRIMARY   = $C; // Undefine - the primary volume tag - current tag ignored.
3305   {$EXTERNALSYM UNDEFINE_PRIMARY}
3306   UNDEFINE_ALTERNATE = $D; // Undefine - the alternate volume tag - current tag ignored.
3307   {$EXTERNALSYM UNDEFINE_ALTERNATE}
3308 
3309 //
3310 // Changer diagnostic test related definitions
3311 //
3312 
3313 type
3314   _CHANGER_DEVICE_PROBLEM_TYPE = (
3315    DeviceProblemNone,
3316    DeviceProblemHardware,
3317    DeviceProblemCHMError,
3318    DeviceProblemDoorOpen,
3319    DeviceProblemCalibrationError,
3320    DeviceProblemTargetFailure,
3321    DeviceProblemCHMMoveError,
3322    DeviceProblemCHMZeroError,
3323    DeviceProblemCartridgeInsertError,
3324    DeviceProblemPositionError,
3325    DeviceProblemSensorError,
3326    DeviceProblemCartridgeEjectError,
3327    DeviceProblemGripperError,
3328    DeviceProblemDriveError);
3329   {$EXTERNALSYM _CHANGER_DEVICE_PROBLEM_TYPE}
3330   CHANGER_DEVICE_PROBLEM_TYPE = _CHANGER_DEVICE_PROBLEM_TYPE;
3331   {$EXTERNALSYM CHANGER_DEVICE_PROBLEM_TYPE}
3332   PCHANGER_DEVICE_PROBLEM_TYPE = ^CHANGER_DEVICE_PROBLEM_TYPE;
3333   {$EXTERNALSYM PCHANGER_DEVICE_PROBLEM_TYPE}
3334   TChangerDeviceProblemType = CHANGER_DEVICE_PROBLEM_TYPE;
3335   PChangerDeviceProblemType = PCHANGER_DEVICE_PROBLEM_TYPE;
3336 
3337 const
3338   IOCTL_SERIAL_LSRMST_INSERT = (
3339     (FILE_DEVICE_SERIAL_PORT shl 16) or (FILE_ANY_ACCESS shl 14) or
3340     (31 shl 2) or METHOD_BUFFERED);
3341   {$EXTERNALSYM IOCTL_SERIAL_LSRMST_INSERT}
3342 
3343   IOCTL_SERENUM_EXPOSE_HARDWARE = (
3344     (FILE_DEVICE_SERENUM shl 16) or (FILE_ANY_ACCESS shl 14) or
3345     (128 shl 2) or METHOD_BUFFERED);
3346   {$EXTERNALSYM IOCTL_SERENUM_EXPOSE_HARDWARE}
3347 
3348   IOCTL_SERENUM_REMOVE_HARDWARE = (
3349     (FILE_DEVICE_SERENUM shl 16) or (FILE_ANY_ACCESS shl 14) or
3350     (129 shl 2) or METHOD_BUFFERED);
3351   {$EXTERNALSYM IOCTL_SERENUM_REMOVE_HARDWARE}
3352 
3353   IOCTL_SERENUM_PORT_DESC = (
3354     (FILE_DEVICE_SERENUM shl 16) or (FILE_ANY_ACCESS shl 14) or
3355     (130 shl 2) or METHOD_BUFFERED);
3356   {$EXTERNALSYM IOCTL_SERENUM_PORT_DESC}
3357 
3358   IOCTL_SERENUM_GET_PORT_NAME = (
3359     (FILE_DEVICE_SERENUM shl 16) or (FILE_ANY_ACCESS shl 14) or
3360     (131 shl 2) or METHOD_BUFFERED);
3361   {$EXTERNALSYM IOCTL_SERENUM_GET_PORT_NAME}
3362 
3363 //
3364 // The following values follow the escape designator in the
3365 // data stream if the LSRMST_INSERT mode has been turned on.
3366 //
3367 
3368   SERIAL_LSRMST_ESCAPE = BYTE($00);
3369   {$EXTERNALSYM SERIAL_LSRMST_ESCAPE}
3370 
3371 //
3372 // Following this value is the contents of the line status
3373 // register, and then the character in the RX hardware when
3374 // the line status register was encountered.
3375 //
3376 
3377   SERIAL_LSRMST_LSR_DATA = BYTE($01);
3378   {$EXTERNALSYM SERIAL_LSRMST_LSR_DATA}
3379 
3380 //
3381 // Following this value is the contents of the line status
3382 // register.  No error character follows
3383 //
3384 
3385   SERIAL_LSRMST_LSR_NODATA = BYTE($02);
3386   {$EXTERNALSYM SERIAL_LSRMST_LSR_NODATA}
3387 
3388 //
3389 // Following this value is the contents of the modem status
3390 // register.
3391 //
3392 
3393   SERIAL_LSRMST_MST = BYTE($03);
3394   {$EXTERNALSYM SERIAL_LSRMST_MST}
3395 
3396 //
3397 // Bit values for FIFO Control Register
3398 //
3399 
3400   SERIAL_IOC_FCR_FIFO_ENABLE      = DWORD($00000001);
3401   {$EXTERNALSYM SERIAL_IOC_FCR_FIFO_ENABLE}
3402   SERIAL_IOC_FCR_RCVR_RESET       = DWORD($00000002);
3403   {$EXTERNALSYM SERIAL_IOC_FCR_RCVR_RESET}
3404   SERIAL_IOC_FCR_XMIT_RESET       = DWORD($00000004);
3405   {$EXTERNALSYM SERIAL_IOC_FCR_XMIT_RESET}
3406   SERIAL_IOC_FCR_DMA_MODE         = DWORD($00000008);
3407   {$EXTERNALSYM SERIAL_IOC_FCR_DMA_MODE}
3408   SERIAL_IOC_FCR_RES1             = DWORD($00000010);
3409   {$EXTERNALSYM SERIAL_IOC_FCR_RES1}
3410   SERIAL_IOC_FCR_RES2             = DWORD($00000020);
3411   {$EXTERNALSYM SERIAL_IOC_FCR_RES2}
3412   SERIAL_IOC_FCR_RCVR_TRIGGER_LSB = DWORD($00000040);
3413   {$EXTERNALSYM SERIAL_IOC_FCR_RCVR_TRIGGER_LSB}
3414   SERIAL_IOC_FCR_RCVR_TRIGGER_MSB = DWORD($00000080);
3415   {$EXTERNALSYM SERIAL_IOC_FCR_RCVR_TRIGGER_MSB}
3416 
3417 //
3418 // Bit values for Modem Control Register
3419 //
3420 
3421   SERIAL_IOC_MCR_DTR  = DWORD($00000001);
3422   {$EXTERNALSYM SERIAL_IOC_MCR_DTR}
3423   SERIAL_IOC_MCR_RTS  = DWORD($00000002);
3424   {$EXTERNALSYM SERIAL_IOC_MCR_RTS}
3425   SERIAL_IOC_MCR_OUT1 = DWORD($00000004);
3426   {$EXTERNALSYM SERIAL_IOC_MCR_OUT1}
3427   SERIAL_IOC_MCR_OUT2 = DWORD($00000008);
3428   {$EXTERNALSYM SERIAL_IOC_MCR_OUT2}
3429   SERIAL_IOC_MCR_LOOP = DWORD($00000010);
3430   {$EXTERNALSYM SERIAL_IOC_MCR_LOOP}
3431 
3432 //
3433 // The following is a list of the native file system fsctls followed by
3434 // additional network file system fsctls.  Some values have been
3435 // decommissioned.
3436 //
3437 
3438   FSCTL_REQUEST_OPLOCK_LEVEL_1 = (
3439     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3440     (0 shl 2) or METHOD_BUFFERED);
3441   {$EXTERNALSYM FSCTL_REQUEST_OPLOCK_LEVEL_1}
3442 
3443   FSCTL_REQUEST_OPLOCK_LEVEL_2 = (
3444     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3445     (1 shl 2) or METHOD_BUFFERED);
3446   {$EXTERNALSYM FSCTL_REQUEST_OPLOCK_LEVEL_2}
3447 
3448   FSCTL_REQUEST_BATCH_OPLOCK = (
3449     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3450     (2 shl 2) or METHOD_BUFFERED);
3451   {$EXTERNALSYM FSCTL_REQUEST_BATCH_OPLOCK}
3452 
3453   FSCTL_OPLOCK_BREAK_ACKNOWLEDGE = (
3454     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3455     (3 shl 2) or METHOD_BUFFERED);
3456   {$EXTERNALSYM FSCTL_OPLOCK_BREAK_ACKNOWLEDGE}
3457 
3458   FSCTL_OPBATCH_ACK_CLOSE_PENDING = (
3459     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3460     (4 shl 2) or METHOD_BUFFERED);
3461   {$EXTERNALSYM FSCTL_OPBATCH_ACK_CLOSE_PENDING}
3462 
3463   FSCTL_OPLOCK_BREAK_NOTIFY = (
3464     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3465     (5 shl 2) or METHOD_BUFFERED);
3466   {$EXTERNALSYM FSCTL_OPLOCK_BREAK_NOTIFY}
3467 
3468   FSCTL_LOCK_VOLUME = (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or (6 shl 2) or METHOD_BUFFERED;
3469   {$EXTERNALSYM FSCTL_LOCK_VOLUME}
3470 
3471   FSCTL_UNLOCK_VOLUME = (
3472     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3473     (7 shl 2) or METHOD_BUFFERED);
3474   {$EXTERNALSYM FSCTL_UNLOCK_VOLUME}
3475 
3476   FSCTL_DISMOUNT_VOLUME = (
3477     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3478     (8 shl 2) or METHOD_BUFFERED);
3479   {$EXTERNALSYM FSCTL_DISMOUNT_VOLUME}
3480 
3481 // decommissioned fsctl value                                              9
3482 
3483   FSCTL_IS_VOLUME_MOUNTED = (
3484     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3485     (10 shl 2) or METHOD_BUFFERED);
3486   {$EXTERNALSYM FSCTL_IS_VOLUME_MOUNTED}
3487 
3488   FSCTL_IS_PATHNAME_VALID = (
3489     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3490     (11 shl 2) or METHOD_BUFFERED);    // PATHNAME_BUFFER,
3491   {$EXTERNALSYM FSCTL_IS_PATHNAME_VALID}
3492 
3493   FSCTL_MARK_VOLUME_DIRTY = (
3494     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3495     (12 shl 2) or METHOD_BUFFERED);
3496   {$EXTERNALSYM FSCTL_MARK_VOLUME_DIRTY}
3497 
3498 // decommissioned fsctl value                                             13
3499 
3500   FSCTL_QUERY_RETRIEVAL_POINTERS = (
3501     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3502     (14 shl 2) or METHOD_NEITHER);
3503   {$EXTERNALSYM FSCTL_QUERY_RETRIEVAL_POINTERS}
3504 
3505   FSCTL_GET_COMPRESSION = (
3506     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3507     (15 shl 2) or METHOD_BUFFERED);
3508   {$EXTERNALSYM FSCTL_GET_COMPRESSION}
3509 
3510   FSCTL_SET_COMPRESSION = (
3511     (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or
3512     (16 shl 2) or METHOD_BUFFERED);
3513   {$EXTERNALSYM FSCTL_SET_COMPRESSION}
3514 
3515 // decommissioned fsctl value                                             17
3516 // decommissioned fsctl value                                             18
3517 
3518   FSCTL_MARK_AS_SYSTEM_HIVE = (
3519     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3520     (19 shl 2) or METHOD_NEITHER);
3521   {$EXTERNALSYM FSCTL_MARK_AS_SYSTEM_HIVE}
3522 
3523   FSCTL_OPLOCK_BREAK_ACK_NO_2 = (
3524     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3525     (20 shl 2) or METHOD_BUFFERED);
3526   {$EXTERNALSYM FSCTL_OPLOCK_BREAK_ACK_NO_2}
3527 
3528   FSCTL_INVALIDATE_VOLUMES = (
3529     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3530     (21 shl 2) or METHOD_BUFFERED);
3531   {$EXTERNALSYM FSCTL_INVALIDATE_VOLUMES}
3532 
3533   FSCTL_QUERY_FAT_BPB = (
3534     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3535     (22 shl 2) or METHOD_BUFFERED); // FSCTL_QUERY_FAT_BPB_BUFFER
3536   {$EXTERNALSYM FSCTL_QUERY_FAT_BPB}
3537 
3538   FSCTL_REQUEST_FILTER_OPLOCK = (
3539     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3540     (23 shl 2) or METHOD_BUFFERED);
3541   {$EXTERNALSYM FSCTL_REQUEST_FILTER_OPLOCK}
3542 
3543   FSCTL_FILESYSTEM_GET_STATISTICS = (
3544     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3545     (24 shl 2) or METHOD_BUFFERED); // FILESYSTEM_STATISTICS
3546   {$EXTERNALSYM FSCTL_FILESYSTEM_GET_STATISTICS}
3547 
3548   FSCTL_GET_NTFS_VOLUME_DATA = (
3549     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3550     (25 shl 2) or METHOD_BUFFERED);
3551   {$EXTERNALSYM FSCTL_GET_NTFS_VOLUME_DATA}
3552 
3553   FSCTL_GET_NTFS_FILE_RECORD = (
3554     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3555     (26 shl 2) or METHOD_BUFFERED);
3556   {$EXTERNALSYM FSCTL_GET_NTFS_FILE_RECORD}
3557 
3558   FSCTL_GET_VOLUME_BITMAP = (
3559     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3560     (27 shl 2) or METHOD_NEITHER);
3561   {$EXTERNALSYM FSCTL_GET_VOLUME_BITMAP}
3562 
3563   FSCTL_GET_RETRIEVAL_POINTERS = (
3564     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3565     (28 shl 2) or METHOD_NEITHER);
3566   {$EXTERNALSYM FSCTL_GET_RETRIEVAL_POINTERS}
3567 
3568   FSCTL_MOVE_FILE = (
3569     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3570     (29 shl 2) or METHOD_BUFFERED);
3571   {$EXTERNALSYM FSCTL_MOVE_FILE}
3572 
3573   FSCTL_IS_VOLUME_DIRTY = (
3574     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3575     (30 shl 2) or METHOD_BUFFERED);
3576   {$EXTERNALSYM FSCTL_IS_VOLUME_DIRTY}
3577 
3578 // decomissioned fsctl value  31
3579 (*  FSCTL_GET_HFS_INFORMATION = (
3580     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3581     (31 shl 2) or METHOD_BUFFERED);
3582   {$EXTERNALSYM FSCTL_GET_HFS_INFORMATION}
3583 *)
3584 
3585   FSCTL_ALLOW_EXTENDED_DASD_IO = (
3586     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3587     (32 shl 2) or METHOD_NEITHER);
3588   {$EXTERNALSYM FSCTL_ALLOW_EXTENDED_DASD_IO}
3589 
3590 // decommissioned fsctl value                                             33
3591 // decommissioned fsctl value                                             34
3592 
3593 (*
3594   FSCTL_READ_PROPERTY_DATA = (
3595     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3596     (33 shl 2) or METHOD_NEITHER);
3597   {$EXTERNALSYM FSCTL_READ_PROPERTY_DATA}
3598 
3599   FSCTL_WRITE_PROPERTY_DATA = (
3600     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3601     (34 shl 2) or METHOD_NEITHER);
3602   {$EXTERNALSYM FSCTL_WRITE_PROPERTY_DATA}
3603 *)
3604 
3605   FSCTL_FIND_FILES_BY_SID = (
3606     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3607     (35 shl 2) or METHOD_NEITHER);
3608   {$EXTERNALSYM FSCTL_FIND_FILES_BY_SID}
3609 
3610 // decommissioned fsctl value                                             36
3611 // decommissioned fsctl value                                             37
3612 
3613 (*  FSCTL_DUMP_PROPERTY_DATA = (
3614     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3615     (37 shl 2) or METHOD_NEITHER);
3616   {$EXTERNALSYM FSCTL_DUMP_PROPERTY_DATA}
3617 *)
3618 
3619   FSCTL_SET_OBJECT_ID = (
3620     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3621     (38 shl 2) or METHOD_BUFFERED);
3622   {$EXTERNALSYM FSCTL_SET_OBJECT_ID}
3623 
3624   FSCTL_GET_OBJECT_ID = (
3625     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3626     (39 shl 2) or METHOD_BUFFERED);
3627   {$EXTERNALSYM FSCTL_GET_OBJECT_ID}
3628 
3629   FSCTL_DELETE_OBJECT_ID = (
3630     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3631     (40 shl 2) or METHOD_BUFFERED);
3632   {$EXTERNALSYM FSCTL_DELETE_OBJECT_ID}
3633 
3634   FSCTL_SET_REPARSE_POINT = (
3635     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3636     (41 shl 2) or METHOD_BUFFERED);
3637   {$EXTERNALSYM FSCTL_SET_REPARSE_POINT}
3638 
3639   FSCTL_GET_REPARSE_POINT = (
3640     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3641     (42 shl 2) or METHOD_BUFFERED);
3642   {$EXTERNALSYM FSCTL_GET_REPARSE_POINT}
3643 
3644   FSCTL_DELETE_REPARSE_POINT = (
3645     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3646     (43 shl 2) or METHOD_BUFFERED);
3647   {$EXTERNALSYM FSCTL_DELETE_REPARSE_POINT}
3648 
3649   FSCTL_ENUM_USN_DATA = (
3650     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3651     (44 shl 2) or METHOD_NEITHER);
3652   {$EXTERNALSYM FSCTL_ENUM_USN_DATA}
3653 
3654   FSCTL_SECURITY_ID_CHECK = (
3655     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or
3656     (45 shl 2) or METHOD_NEITHER);
3657   {$EXTERNALSYM FSCTL_SECURITY_ID_CHECK}
3658 
3659   FSCTL_READ_USN_JOURNAL = (
3660     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3661     (46 shl 2) or METHOD_NEITHER);
3662   {$EXTERNALSYM FSCTL_READ_USN_JOURNAL}
3663 
3664   FSCTL_SET_OBJECT_ID_EXTENDED = (
3665     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3666     (47 shl 2) or METHOD_BUFFERED);
3667   {$EXTERNALSYM FSCTL_SET_OBJECT_ID_EXTENDED}
3668 
3669   FSCTL_CREATE_OR_GET_OBJECT_ID = (
3670     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3671     (48 shl 2) or METHOD_BUFFERED);
3672   {$EXTERNALSYM FSCTL_CREATE_OR_GET_OBJECT_ID}
3673 
3674   FSCTL_SET_SPARSE = (
3675     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3676     (49 shl 2) or METHOD_BUFFERED);
3677   {$EXTERNALSYM FSCTL_SET_SPARSE}
3678 
3679   FSCTL_SET_ZERO_DATA = (
3680     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_WRITE_DATA shl 14) or
3681     (50 shl 2) or METHOD_BUFFERED);
3682   {$EXTERNALSYM FSCTL_SET_ZERO_DATA}
3683 
3684   FSCTL_QUERY_ALLOCATED_RANGES = (
3685     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or
3686     (51 shl 2) or METHOD_NEITHER);
3687   {$EXTERNALSYM FSCTL_QUERY_ALLOCATED_RANGES}
3688 
3689 // decommissioned fsctl value                                             52
3690 (*
3691   FSCTL_ENABLE_UPGRADE = (
3692     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_WRITE_DATA shl 14) or
3693     (52 shl 2) or METHOD_BUFFERED);
3694   {$EXTERNALSYM FSCTL_ENABLE_UPGRADE}
3695 *)
3696 
3697   FSCTL_SET_ENCRYPTION = (
3698     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3699     (53 shl 2) or METHOD_NEITHER);
3700   {$EXTERNALSYM FSCTL_SET_ENCRYPTION}
3701 
3702   FSCTL_ENCRYPTION_FSCTL_IO = (
3703     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3704     (54 shl 2) or METHOD_NEITHER);
3705   {$EXTERNALSYM FSCTL_ENCRYPTION_FSCTL_IO}
3706 
3707   FSCTL_WRITE_RAW_ENCRYPTED = (
3708     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3709     (55 shl 2) or METHOD_NEITHER);
3710   {$EXTERNALSYM FSCTL_WRITE_RAW_ENCRYPTED}
3711 
3712   FSCTL_READ_RAW_ENCRYPTED = (
3713     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3714     (56 shl 2) or METHOD_NEITHER);
3715   {$EXTERNALSYM FSCTL_READ_RAW_ENCRYPTED}
3716 
3717   FSCTL_CREATE_USN_JOURNAL = (
3718     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3719     (57 shl 2) or METHOD_NEITHER);
3720   {$EXTERNALSYM FSCTL_CREATE_USN_JOURNAL}
3721 
3722   FSCTL_READ_FILE_USN_DATA = (
3723     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3724     (58 shl 2) or METHOD_NEITHER);
3725   {$EXTERNALSYM FSCTL_READ_FILE_USN_DATA}
3726 
3727   FSCTL_WRITE_USN_CLOSE_RECORD = (
3728     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3729     (59 shl 2) or METHOD_NEITHER);
3730   {$EXTERNALSYM FSCTL_WRITE_USN_CLOSE_RECORD}
3731 
3732   FSCTL_EXTEND_VOLUME = (
3733     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3734     (60 shl 2) or METHOD_BUFFERED);
3735   {$EXTERNALSYM FSCTL_EXTEND_VOLUME}
3736 
3737   FSCTL_QUERY_USN_JOURNAL = (
3738     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3739     (61 shl 2) or METHOD_BUFFERED);
3740   {$EXTERNALSYM FSCTL_QUERY_USN_JOURNAL}
3741 
3742   FSCTL_DELETE_USN_JOURNAL = (
3743     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3744     (62 shl 2) or METHOD_BUFFERED);
3745   {$EXTERNALSYM FSCTL_DELETE_USN_JOURNAL}
3746 
3747   FSCTL_MARK_HANDLE = (
3748     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3749     (63 shl 2) or METHOD_BUFFERED);
3750   {$EXTERNALSYM FSCTL_MARK_HANDLE}
3751 
3752   FSCTL_SIS_COPYFILE = (
3753     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3754     (64 shl 2) or METHOD_BUFFERED);
3755   {$EXTERNALSYM FSCTL_SIS_COPYFILE}
3756 
3757   FSCTL_SIS_LINK_FILES = (
3758     (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or
3759     (65 shl 2) or METHOD_BUFFERED);
3760   {$EXTERNALSYM FSCTL_SIS_LINK_FILES}
3761 
3762   FSCTL_HSM_MSG = (
3763     (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or
3764     (66 shl 2) or METHOD_BUFFERED);
3765   {$EXTERNALSYM FSCTL_HSM_MSG}
3766 
3767 // decommissioned fsctl value                                             67
3768 (*
3769   FSCTL_NSS_CONTROL = (
3770     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_WRITE_DATA shl 14) or
3771     (67 shl 2) or METHOD_BUFFERED);
3772   {$EXTERNALSYM FSCTL_NSS_CONTROL}
3773 *)
3774 
3775   FSCTL_HSM_DATA = (
3776     (FILE_DEVICE_FILE_SYSTEM shl 16) or ((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or
3777     (68 shl 2) or METHOD_NEITHER);
3778   {$EXTERNALSYM FSCTL_HSM_DATA}
3779 
3780   FSCTL_RECALL_FILE = (
3781     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_ANY_ACCESS shl 14) or
3782     (69 shl 2) or METHOD_NEITHER);
3783   {$EXTERNALSYM FSCTL_RECALL_FILE}
3784 
3785 // decommissioned fsctl value                                             70
3786 (*
3787   FSCTL_NSS_RCONTROL = (
3788     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or
3789     (70 shl 2) or METHOD_BUFFERED);
3790   {$EXTERNALSYM FSCTL_NSS_RCONTROL}
3791 *)
3792 
3793   FSCTL_READ_FROM_PLEX = (
3794     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_READ_DATA shl 14) or
3795     (71 shl 2) or METHOD_OUT_DIRECT);
3796   {$EXTERNALSYM FSCTL_READ_FROM_PLEX}
3797 
3798   FSCTL_FILE_PREFETCH = (
3799     (FILE_DEVICE_FILE_SYSTEM shl 16) or (FILE_SPECIAL_ACCESS shl 14) or
3800     (72 shl 2) or METHOD_BUFFERED);
3801   {$EXTERNALSYM FSCTL_FILE_PREFETCH}
3802 
3803 //
3804 // The following long list of structs are associated with the preceeding
3805 // file system fsctls.
3806 //
3807 // Note that the structs for the property sets fsctls are not included
3808 // in this file.  They can be found in ntfsprop.h where they should stay
3809 // because of their dependency on objidl.h.
3810 //
3811 
3812 //
3813 // Structure for FSCTL_IS_PATHNAME_VALID
3814 //
3815 
3816 type
3817   PPATHNAME_BUFFER = ^PATHNAME_BUFFER;
3818   {$EXTERNALSYM PPATHNAME_BUFFER}
3819   _PATHNAME_BUFFER = record
3820     PathNameLength: DWORD;
3821     Name: array [0..0] of WCHAR;
3822   end;
3823   {$EXTERNALSYM _PATHNAME_BUFFER}
3824   PATHNAME_BUFFER = _PATHNAME_BUFFER;
3825   {$EXTERNALSYM PATHNAME_BUFFER}
3826   TPathnameBuffer = PATHNAME_BUFFER;
3827   PPathnameBuffer = PPATHNAME_BUFFER;
3828 
3829 //
3830 // Structure for FSCTL_QUERY_BPB_INFO
3831 //
3832 
3833   PFSCTL_QUERY_FAT_BPB_BUFFER = ^FSCTL_QUERY_FAT_BPB_BUFFER;
3834   {$EXTERNALSYM PFSCTL_QUERY_FAT_BPB_BUFFER}
3835   _FSCTL_QUERY_FAT_BPB_BUFFER = record
3836     First0x24BytesOfBootSector: array [0..$23] of BYTE;
3837   end;
3838   {$EXTERNALSYM _FSCTL_QUERY_FAT_BPB_BUFFER}
3839   FSCTL_QUERY_FAT_BPB_BUFFER = _FSCTL_QUERY_FAT_BPB_BUFFER;
3840   {$EXTERNALSYM FSCTL_QUERY_FAT_BPB_BUFFER}
3841   TFsctlQueryFatBpbBuffer = FSCTL_QUERY_FAT_BPB_BUFFER;
3842   PFsctlQueryFatBpbBuffer = PFSCTL_QUERY_FAT_BPB_BUFFER;
3843 
3844 //
3845 // Structures for FSCTL_GET_NTFS_VOLUME_DATA.
3846 // The user must pass the basic buffer below.  Ntfs
3847 // will return as many fields as available in the extended
3848 // buffer which follows immediately after the VOLUME_DATA_BUFFER.
3849 //
3850 
3851   PNTFS_VOLUME_DATA_BUFFER = ^NTFS_VOLUME_DATA_BUFFER;
3852   {$EXTERNALSYM PNTFS_VOLUME_DATA_BUFFER}
3853   NTFS_VOLUME_DATA_BUFFER = record
3854     VolumeSerialNumber: LARGE_INTEGER;
3855     NumberSectors: LARGE_INTEGER;
3856     TotalClusters: LARGE_INTEGER;
3857     FreeClusters: LARGE_INTEGER;
3858     TotalReserved: LARGE_INTEGER;
3859     BytesPerSector: DWORD;
3860     BytesPerCluster: DWORD;
3861     BytesPerFileRecordSegment: DWORD;
3862     ClustersPerFileRecordSegment: DWORD;
3863     MftValidDataLength: LARGE_INTEGER;
3864     MftStartLcn: LARGE_INTEGER;
3865     Mft2StartLcn: LARGE_INTEGER;
3866     MftZoneStart: LARGE_INTEGER;
3867     MftZoneEnd: LARGE_INTEGER;
3868   end;
3869   {$EXTERNALSYM NTFS_VOLUME_DATA_BUFFER}
3870   TNtfsVolumeDataBuffer = NTFS_VOLUME_DATA_BUFFER;
3871   PNtfsVolumeDataBuffer = PNTFS_VOLUME_DATA_BUFFER;
3872 
3873   PNTFS_EXTENDED_VOLUME_DATA = ^NTFS_EXTENDED_VOLUME_DATA;
3874   {$EXTERNALSYM PNTFS_EXTENDED_VOLUME_DATA}
3875   NTFS_EXTENDED_VOLUME_DATA = record
3876     ByteCount: DWORD;
3877     MajorVersion: WORD;
3878     MinorVersion: WORD;
3879   end;
3880   {$EXTERNALSYM NTFS_EXTENDED_VOLUME_DATA}
3881   TNtfsExtendedVolumeData = NTFS_EXTENDED_VOLUME_DATA;
3882   PNtfsExtendedVolumeData = PNTFS_EXTENDED_VOLUME_DATA;
3883 
3884 //
3885 // Structure for FSCTL_GET_VOLUME_BITMAP
3886 //
3887 
3888   PSTARTING_LCN_INPUT_BUFFER = ^STARTING_LCN_INPUT_BUFFER;
3889   {$EXTERNALSYM PSTARTING_LCN_INPUT_BUFFER}
3890   STARTING_LCN_INPUT_BUFFER = record
3891     StartingLcn: LARGE_INTEGER;
3892   end;
3893   {$EXTERNALSYM STARTING_LCN_INPUT_BUFFER}
3894   TStartingLcnInputBuffer = STARTING_LCN_INPUT_BUFFER;
3895   PStartingLcnInputBuffer = PSTARTING_LCN_INPUT_BUFFER;
3896 
3897   PVOLUME_BITMAP_BUFFER = ^VOLUME_BITMAP_BUFFER;
3898   {$EXTERNALSYM PVOLUME_BITMAP_BUFFER}
3899   VOLUME_BITMAP_BUFFER = record
3900     StartingLcn: LARGE_INTEGER;
3901     BitmapSize: LARGE_INTEGER;
3902     Buffer: array [0..0] of BYTE;
3903   end;
3904   {$EXTERNALSYM VOLUME_BITMAP_BUFFER}
3905   TVolumeBitmapBuffer = VOLUME_BITMAP_BUFFER;
3906   PVolumeBitmapBuffer = PVOLUME_BITMAP_BUFFER;
3907 
3908 //
3909 // Structure for FSCTL_GET_RETRIEVAL_POINTERS
3910 //
3911 
3912   PSTARTING_VCN_INPUT_BUFFER = ^STARTING_VCN_INPUT_BUFFER;
3913   {$EXTERNALSYM PSTARTING_VCN_INPUT_BUFFER}
3914   STARTING_VCN_INPUT_BUFFER = record
3915     StartingVcn: LARGE_INTEGER;
3916   end;
3917   {$EXTERNALSYM STARTING_VCN_INPUT_BUFFER}
3918   TStartingVcnInputBuffer = STARTING_VCN_INPUT_BUFFER;
3919   PStartingVcnInputBuffer = PSTARTING_VCN_INPUT_BUFFER;
3920 
3921   TRPBExtends = record
3922     NextVcn: LARGE_INTEGER;
3923     Lcn: LARGE_INTEGER;
3924   end;
3925 
3926   PRETRIEVAL_POINTERS_BUFFER = ^RETRIEVAL_POINTERS_BUFFER;
3927   {$EXTERNALSYM PRETRIEVAL_POINTERS_BUFFER}
3928   RETRIEVAL_POINTERS_BUFFER = record
3929     ExtentCount: DWORD;
3930     StartingVcn: LARGE_INTEGER;
3931     Extends: array [0..0] of TRPBExtends;
3932   end;
3933   {$EXTERNALSYM RETRIEVAL_POINTERS_BUFFER}
3934   TRetrievalPointersBuffer = RETRIEVAL_POINTERS_BUFFER;
3935   PRetrievalPointersBuffer = PRETRIEVAL_POINTERS_BUFFER;
3936 
3937 //
3938 // Structures for FSCTL_GET_NTFS_FILE_RECORD
3939 //
3940 
3941   PNTFS_FILE_RECORD_INPUT_BUFFER = ^NTFS_FILE_RECORD_INPUT_BUFFER;
3942   {$EXTERNALSYM PNTFS_FILE_RECORD_INPUT_BUFFER}
3943   NTFS_FILE_RECORD_INPUT_BUFFER = record
3944     FileReferenceNumber: LARGE_INTEGER;
3945   end;
3946   {$EXTERNALSYM NTFS_FILE_RECORD_INPUT_BUFFER}
3947   TNtfsFileRecordInputBuffer = NTFS_FILE_RECORD_INPUT_BUFFER;
3948   PNtfsFileRecordInputBuffer = PNTFS_FILE_RECORD_INPUT_BUFFER;
3949 
3950   PNTFS_FILE_RECORD_OUTPUT_BUFFER = ^NTFS_FILE_RECORD_OUTPUT_BUFFER;
3951   {$EXTERNALSYM PNTFS_FILE_RECORD_OUTPUT_BUFFER}
3952   NTFS_FILE_RECORD_OUTPUT_BUFFER = record
3953     FileReferenceNumber: LARGE_INTEGER;
3954     FileRecordLength: DWORD;
3955     FileRecordBuffer: array [0..0] of BYTE;
3956   end;
3957   {$EXTERNALSYM NTFS_FILE_RECORD_OUTPUT_BUFFER}
3958   TNtfsFileRecordOutputBuffer = NTFS_FILE_RECORD_OUTPUT_BUFFER;
3959   PNtfsFileRecordOutputBuffer = PNTFS_FILE_RECORD_OUTPUT_BUFFER;
3960 
3961 //
3962 // Structure for FSCTL_MOVE_FILE
3963 //
3964 
3965   PMOVE_FILE_DATA = ^MOVE_FILE_DATA;
3966   {$EXTERNALSYM PMOVE_FILE_DATA}
3967   MOVE_FILE_DATA = record
3968     FileHandle: HANDLE;
3969     StartingVcn: LARGE_INTEGER;
3970     StartingLcn: LARGE_INTEGER;
3971     ClusterCount: DWORD;
3972   end;
3973   {$EXTERNALSYM MOVE_FILE_DATA}
3974   TMoveFileData = MOVE_FILE_DATA;
3975   PMoveFileData = PMOVE_FILE_DATA;
3976 
3977 {$IFDEF WIN64}
3978 
3979 //
3980 //  32/64 Bit thunking support structure
3981 //
3982 
3983   _MOVE_FILE_DATA32 = record
3984     FileHandle: UINT32;
3985     StartingVcn: LARGE_INTEGER;
3986     StartingLcn: LARGE_INTEGER;
3987     ClusterCount: DWORD;
3988   end;
3989   {$EXTERNALSYM _MOVE_FILE_DATA32}
3990   MOVE_FILE_DATA32 = _MOVE_FILE_DATA32;
3991   {$EXTERNALSYM MOVE_FILE_DATA32}
3992   PMOVE_FILE_DATA32 = ^MOVE_FILE_DATA32;
3993   {$EXTERNALSYM PMOVE_FILE_DATA32}
3994   TMoveFileData32 = MOVE_FILE_DATA32;
3995   PMoveFileData32 = PMOVE_FILE_DATA32;
3996 
3997 {$ENDIF WIN64}
3998 
3999 //
4000 // Structures for FSCTL_FIND_FILES_BY_SID
4001 //
4002 
4003   PFIND_BY_SID_DATA = ^FIND_BY_SID_DATA;
4004   {$EXTERNALSYM PFIND_BY_SID_DATA}
4005   FIND_BY_SID_DATA = record
4006     Restart: DWORD;
4007     Sid: SID;
4008   end;
4009   {$EXTERNALSYM FIND_BY_SID_DATA}
4010   TFindBySidData = FIND_BY_SID_DATA;
4011   PFindBySidData = PFIND_BY_SID_DATA;
4012 
4013   FIND_BY_SID_OUTPUT = record
4014     NextEntryOffset: DWORD;
4015     FileIndex: DWORD;
4016     FileNameLength: DWORD;
4017     FileName: array [0..0] of WCHAR;
4018   end;
4019   {$EXTERNALSYM FIND_BY_SID_OUTPUT}
4020   PFIND_BY_SID_OUTPUT = ^FIND_BY_SID_OUTPUT;
4021   TFindBySidOutput = FIND_BY_SID_OUTPUT;
4022   PFindBySidOutput = PFIND_BY_SID_OUTPUT;
4023 
4024 //
4025 //  The following structures apply to Usn operations.
4026 //
4027 
4028 //
4029 // Structure for FSCTL_ENUM_USN_DATA
4030 //
4031 
4032   PMFT_ENUM_DATA = ^MFT_ENUM_DATA;
4033   {$EXTERNALSYM PMFT_ENUM_DATA}
4034   MFT_ENUM_DATA = record
4035     StartFileReferenceNumber: DWORDLONG;
4036     LowUsn: USN;
4037     HighUsn: USN;
4038   end;
4039   {$EXTERNALSYM MFT_ENUM_DATA}
4040   TMftEnumData = MFT_ENUM_DATA;
4041   PMftEnumData = PMFT_ENUM_DATA;
4042 
4043 //
4044 // Structure for FSCTL_CREATE_USN_JOURNAL
4045 //
4046 
4047   PCREATE_USN_JOURNAL_DATA = ^CREATE_USN_JOURNAL_DATA;
4048   {$EXTERNALSYM PCREATE_USN_JOURNAL_DATA}
4049   CREATE_USN_JOURNAL_DATA = record
4050     MaximumSize: DWORDLONG;
4051     AllocationDelta: DWORDLONG;
4052   end;
4053   {$EXTERNALSYM CREATE_USN_JOURNAL_DATA}
4054   TCreateUsnJournalData = CREATE_USN_JOURNAL_DATA;
4055   PCreateUsnJournalData = PCREATE_USN_JOURNAL_DATA;
4056 
4057 //
4058 // Structure for FSCTL_READ_USN_JOURNAL
4059 //
4060 
4061   PREAD_USN_JOURNAL_DATA = ^READ_USN_JOURNAL_DATA;
4062   {$EXTERNALSYM PREAD_USN_JOURNAL_DATA}
4063   READ_USN_JOURNAL_DATA = record
4064     StartUsn: USN;
4065     ReasonMask: DWORD;
4066     ReturnOnlyOnClose: DWORD;
4067     Timeout: DWORDLONG;
4068     BytesToWaitFor: DWORDLONG;
4069     UsnJournalID: DWORDLONG;
4070   end;
4071   {$EXTERNALSYM READ_USN_JOURNAL_DATA}
4072   TReadUsnJournalData = READ_USN_JOURNAL_DATA;
4073   PReadUsnJournalData = PREAD_USN_JOURNAL_DATA;
4074 
4075 //
4076 //  The initial Major.Minor version of the Usn record will be 2.0.
4077 //  In general, the MinorVersion may be changed if fields are added
4078 //  to this structure in such a way that the previous version of the
4079 //  software can still correctly the fields it knows about.  The
4080 //  MajorVersion should only be changed if the previous version of
4081 //  any software using this structure would incorrectly handle new
4082 //  records due to structure changes.
4083 //
4084 //  The first update to this will force the structure to version 2.0.
4085 //  This will add the extended information about the source as
4086 //  well as indicate the file name offset within the structure.
4087 //
4088 //  The following structure is returned with these fsctls.
4089 //
4090 //      FSCTL_READ_USN_JOURNAL
4091 //      FSCTL_READ_FILE_USN_DATA
4092 //      FSCTL_ENUM_USN_DATA
4093 //
4094 
4095   PUSN_RECORD = ^USN_RECORD;
4096   {$EXTERNALSYM PUSN_RECORD}
4097   USN_RECORD = record
4098     RecordLength: DWORD;
4099     MajorVersion: WORD;
4100     MinorVersion: WORD;
4101     FileReferenceNumber: DWORDLONG;
4102     ParentFileReferenceNumber: DWORDLONG;
4103     Usn: USN;
4104     TimeStamp: LARGE_INTEGER;
4105     Reason: DWORD;
4106     SourceInfo: DWORD;
4107     SecurityId: DWORD;
4108     FileAttributes: DWORD;
4109     FileNameLength: WORD;
4110     FileNameOffset: WORD;
4111     FileName: array [0..0] of WCHAR;
4112   end;
4113   {$EXTERNALSYM USN_RECORD}
4114   TUsnRecord = USN_RECORD;
4115   PUsnRecord = PUSN_RECORD;
4116 
4117 const
4118   USN_PAGE_SIZE = $1000;
4119   {$EXTERNALSYM USN_PAGE_SIZE}
4120 
4121   USN_REASON_DATA_OVERWRITE        = $00000001;
4122   {$EXTERNALSYM USN_REASON_DATA_OVERWRITE}
4123   USN_REASON_DATA_EXTEND           = $00000002;
4124   {$EXTERNALSYM USN_REASON_DATA_EXTEND}
4125   USN_REASON_DATA_TRUNCATION       = $00000004;
4126   {$EXTERNALSYM USN_REASON_DATA_TRUNCATION}
4127   USN_REASON_NAMED_DATA_OVERWRITE  = $00000010;
4128   {$EXTERNALSYM USN_REASON_NAMED_DATA_OVERWRITE}
4129   USN_REASON_NAMED_DATA_EXTEND     = $00000020;
4130   {$EXTERNALSYM USN_REASON_NAMED_DATA_EXTEND}
4131   USN_REASON_NAMED_DATA_TRUNCATION = $00000040;
4132   {$EXTERNALSYM USN_REASON_NAMED_DATA_TRUNCATION}
4133   USN_REASON_FILE_CREATE           = $00000100;
4134   {$EXTERNALSYM USN_REASON_FILE_CREATE}
4135   USN_REASON_FILE_DELETE           = $00000200;
4136   {$EXTERNALSYM USN_REASON_FILE_DELETE}
4137   USN_REASON_EA_CHANGE             = $00000400;
4138   {$EXTERNALSYM USN_REASON_EA_CHANGE}
4139   USN_REASON_SECURITY_CHANGE       = $00000800;
4140   {$EXTERNALSYM USN_REASON_SECURITY_CHANGE}
4141   USN_REASON_RENAME_OLD_NAME       = $00001000;
4142   {$EXTERNALSYM USN_REASON_RENAME_OLD_NAME}
4143   USN_REASON_RENAME_NEW_NAME       = $00002000;
4144   {$EXTERNALSYM USN_REASON_RENAME_NEW_NAME}
4145   USN_REASON_INDEXABLE_CHANGE      = $00004000;
4146   {$EXTERNALSYM USN_REASON_INDEXABLE_CHANGE}
4147   USN_REASON_BASIC_INFO_CHANGE     = $00008000;
4148   {$EXTERNALSYM USN_REASON_BASIC_INFO_CHANGE}
4149   USN_REASON_HARD_LINK_CHANGE      = $00010000;
4150   {$EXTERNALSYM USN_REASON_HARD_LINK_CHANGE}
4151   USN_REASON_COMPRESSION_CHANGE    = $00020000;
4152   {$EXTERNALSYM USN_REASON_COMPRESSION_CHANGE}
4153   USN_REASON_ENCRYPTION_CHANGE     = $00040000;
4154   {$EXTERNALSYM USN_REASON_ENCRYPTION_CHANGE}
4155   USN_REASON_OBJECT_ID_CHANGE      = $00080000;
4156   {$EXTERNALSYM USN_REASON_OBJECT_ID_CHANGE}
4157   USN_REASON_REPARSE_POINT_CHANGE  = $00100000;
4158   {$EXTERNALSYM USN_REASON_REPARSE_POINT_CHANGE}
4159   USN_REASON_STREAM_CHANGE         = $00200000;
4160   {$EXTERNALSYM USN_REASON_STREAM_CHANGE}
4161 
4162   USN_REASON_CLOSE = DWORD($80000000);
4163   {$EXTERNALSYM USN_REASON_CLOSE}
4164 
4165 //
4166 //  Structure for FSCTL_QUERY_USN_JOUNAL
4167 //
4168 
4169 type
4170   PUSN_JOURNAL_DATA = ^USN_JOURNAL_DATA;
4171   {$EXTERNALSYM PUSN_JOURNAL_DATA}
4172   USN_JOURNAL_DATA = record
4173     UsnJournalID: DWORDLONG;
4174     FirstUsn: USN;
4175     NextUsn: USN;
4176     LowestValidUsn: USN;
4177     MaxUsn: USN;
4178     MaximumSize: DWORDLONG;
4179     AllocationDelta: DWORDLONG;
4180   end;
4181   {$EXTERNALSYM USN_JOURNAL_DATA}
4182   TUsnJournalData = USN_JOURNAL_DATA;
4183   PUsnJournalData = PUSN_JOURNAL_DATA;
4184 
4185 //
4186 //  Structure for FSCTL_DELETE_USN_JOURNAL
4187 //
4188 
4189   PDELETE_USN_JOURNAL_DATA = ^DELETE_USN_JOURNAL_DATA;
4190   {$EXTERNALSYM PDELETE_USN_JOURNAL_DATA}
4191   DELETE_USN_JOURNAL_DATA = record
4192     UsnJournalID: DWORDLONG;
4193     DeleteFlags: DWORD;
4194   end;
4195   {$EXTERNALSYM DELETE_USN_JOURNAL_DATA}
4196   TDeleteUsnJournalData = DELETE_USN_JOURNAL_DATA;
4197   PDeleteUsnJournalData = PDELETE_USN_JOURNAL_DATA;
4198 
4199 const
4200   USN_DELETE_FLAG_DELETE = $00000001;
4201   {$EXTERNALSYM USN_DELETE_FLAG_DELETE}
4202   USN_DELETE_FLAG_NOTIFY = $00000002;
4203   {$EXTERNALSYM USN_DELETE_FLAG_NOTIFY}
4204 
4205   USN_DELETE_VALID_FLAGS = $00000003;
4206   {$EXTERNALSYM USN_DELETE_VALID_FLAGS}
4207 
4208 //
4209 //  Structure for FSCTL_MARK_HANDLE
4210 //
4211 
4212 type
4213   PMARK_HANDLE_INFO = ^MARK_HANDLE_INFO;
4214   {$EXTERNALSYM PMARK_HANDLE_INFO}
4215   MARK_HANDLE_INFO = record
4216     UsnSourceInfo: DWORD;
4217     VolumeHandle: HANDLE;
4218     HandleInfo: DWORD;
4219   end;
4220   {$EXTERNALSYM MARK_HANDLE_INFO}
4221   TMarkHandleInfo = MARK_HANDLE_INFO;
4222   PMarkHandleInfo = PMARK_HANDLE_INFO;
4223 
4224 {$IFDEF WIN64}
4225 
4226 //
4227 //  32/64 Bit thunking support structure
4228 //
4229 
4230   MARK_HANDLE_INFO32 = record
4231     UsnSourceInfo: DWORD;
4232     VolumeHandle: UINT32;
4233     HandleInfo: DWORD;
4234   end;
4235   {$EXTERNALSYM MARK_HANDLE_INFO32}
4236   PMARK_HANDLE_INFO32 = ^MARK_HANDLE_INFO32;
4237   {$EXTERNALSYM PMARK_HANDLE_INFO32}
4238   TMarkHandleInfo32 = MARK_HANDLE_INFO32;
4239   PMarkHandleInfo32 = PMARK_HANDLE_INFO32;
4240 
4241 {$ENDIF WIN64}
4242 
4243 //
4244 //  Flags for the additional source information above.
4245 //
4246 //      USN_SOURCE_DATA_MANAGEMENT - Service is not modifying the external view
4247 //          of any part of the file.  Typical case is HSM moving data to
4248 //          and from external storage.
4249 //
4250 //      USN_SOURCE_AUXILIARY_DATA - Service is not modifying the external view
4251 //          of the file with regard to the application that created this file.
4252 //          Can be used to add private data streams to a file.
4253 //
4254 //      USN_SOURCE_REPLICATION_MANAGEMENT - Service is modifying a file to match
4255 //          the contents of the same file which exists in another member of the
4256 //          replica set.
4257 //
4258 
4259 const
4260   USN_SOURCE_DATA_MANAGEMENT        = $00000001;
4261   {$EXTERNALSYM USN_SOURCE_DATA_MANAGEMENT}
4262   USN_SOURCE_AUXILIARY_DATA         = $00000002;
4263   {$EXTERNALSYM USN_SOURCE_AUXILIARY_DATA}
4264   USN_SOURCE_REPLICATION_MANAGEMENT = $00000004;
4265   {$EXTERNALSYM USN_SOURCE_REPLICATION_MANAGEMENT}
4266 
4267 //
4268 //  Flags for the HandleInfo field above
4269 //
4270 //  MARK_HANDLE_PROTECT_CLUSTERS - disallow any defragmenting (FSCTL_MOVE_FILE) until the
4271 //      the handle is closed
4272 //
4273 
4274   MARK_HANDLE_PROTECT_CLUSTERS      = $00000001;
4275   {$EXTERNALSYM MARK_HANDLE_PROTECT_CLUSTERS}
4276 
4277 //
4278 // Structure for FSCTL_SECURITY_ID_CHECK
4279 //
4280 
4281 type
4282   PBULK_SECURITY_TEST_DATA = ^BULK_SECURITY_TEST_DATA;
4283   {$EXTERNALSYM PBULK_SECURITY_TEST_DATA}
4284   BULK_SECURITY_TEST_DATA = record
4285     DesiredAccess: ACCESS_MASK;
4286     SecurityIds: array [0..0] of DWORD;
4287   end;
4288   {$EXTERNALSYM BULK_SECURITY_TEST_DATA}
4289   TBulkSecurityTestData = BULK_SECURITY_TEST_DATA;
4290   PBulkSecurityTestData = PBULK_SECURITY_TEST_DATA;
4291 
4292 //
4293 //  Output flags for the FSCTL_IS_VOLUME_DIRTY
4294 //
4295 
4296 const
4297   VOLUME_IS_DIRTY          = $00000001;
4298   {$EXTERNALSYM VOLUME_IS_DIRTY}
4299   VOLUME_UPGRADE_SCHEDULED = $00000002;
4300   {$EXTERNALSYM VOLUME_UPGRADE_SCHEDULED}
4301 
4302 //
4303 // Structures for FSCTL_FILE_PREFETCH
4304 //
4305 
4306 type
4307   _FILE_PREFETCH = record
4308     Type_: DWORD;
4309     Count: DWORD;
4310     Prefetch: array [0..0] of DWORDLONG;
4311   end;
4312   {$EXTERNALSYM _FILE_PREFETCH}
4313   FILE_PREFETCH = _FILE_PREFETCH;
4314   {$EXTERNALSYM FILE_PREFETCH}
4315   PFILE_PREFETCH = ^FILE_PREFETCH;
4316   {$EXTERNALSYM PFILE_PREFETCH}
4317   TFilePrefetch = FILE_PREFETCH;
4318   PFilePrefetch = PFILE_PREFETCH;
4319 
4320 const
4321   FILE_PREFETCH_TYPE_FOR_CREATE = $1;
4322   {$EXTERNALSYM FILE_PREFETCH_TYPE_FOR_CREATE}
4323 //
4324 // Structures for FSCTL_FILESYSTEM_GET_STATISTICS
4325 //
4326 // Filesystem performance counters
4327 //
4328 
4329 type
4330   PFILESYSTEM_STATISTICS = ^FILESYSTEM_STATISTICS;
4331   {$EXTERNALSYM PFILESYSTEM_STATISTICS}
4332   _FILESYSTEM_STATISTICS = record
4333     FileSystemType: WORD;
4334     Version: WORD;                  // currently version 1
4335     SizeOfCompleteStructure: DWORD; // must by a mutiple of 64 bytes
4336     UserFileReads: DWORD;
4337     UserFileReadBytes: DWORD;
4338     UserDiskReads: DWORD;
4339     UserFileWrites: DWORD;
4340     UserFileWriteBytes: DWORD;
4341     UserDiskWrites: DWORD;
4342     MetaDataReads: DWORD;
4343     MetaDataReadBytes: DWORD;
4344     MetaDataDiskReads: DWORD;
4345     MetaDataWrites: DWORD;
4346     MetaDataWriteBytes: DWORD;
4347     MetaDataDiskWrites: DWORD;
4348     //
4349     //  The file system's private structure is appended here.
4350     //
4351   end;
4352   {$EXTERNALSYM _FILESYSTEM_STATISTICS}
4353   FILESYSTEM_STATISTICS = _FILESYSTEM_STATISTICS;
4354   {$EXTERNALSYM FILESYSTEM_STATISTICS}
4355   TFilesystemStatistics = FILESYSTEM_STATISTICS;
4356   PFilesystemStatistics = PFILESYSTEM_STATISTICS;
4357 
4358 // values for FS_STATISTICS.FileSystemType
4359 
4360 const
4361   FILESYSTEM_STATISTICS_TYPE_NTFS = 1;
4362   {$EXTERNALSYM FILESYSTEM_STATISTICS_TYPE_NTFS}
4363   FILESYSTEM_STATISTICS_TYPE_FAT  = 2;
4364   {$EXTERNALSYM FILESYSTEM_STATISTICS_TYPE_FAT}
4365 
4366 //
4367 //  File System Specific Statistics Data
4368 //
4369 
4370 type
4371   PFAT_STATISTICS = ^FAT_STATISTICS;
4372   {$EXTERNALSYM PFAT_STATISTICS}
4373   _FAT_STATISTICS = record
4374     CreateHits: DWORD;
4375     SuccessfulCreates: DWORD;
4376     FailedCreates: DWORD;
4377     NonCachedReads: DWORD;
4378     NonCachedReadBytes: DWORD;
4379     NonCachedWrites: DWORD;
4380     NonCachedWriteBytes: DWORD;
4381     NonCachedDiskReads: DWORD;
4382     NonCachedDiskWrites: DWORD;
4383   end;
4384   {$EXTERNALSYM _FAT_STATISTICS}
4385   FAT_STATISTICS = _FAT_STATISTICS;
4386   {$EXTERNALSYM FAT_STATISTICS}
4387   TFatStatistics = FAT_STATISTICS;
4388   PFatStatistics = PFAT_STATISTICS;
4389 
4390   // NTFS Statistics
4391 
4392   TMftWritesUserLevel = record
4393     Write: WORD;
4394     Create: WORD;
4395     SetInfo: WORD;
4396     Flush: WORD;
4397   end;
4398 
4399   TMft2WritesUserLevel = record
4400     Write: WORD;
4401     Create: WORD;
4402     SetInfo: WORD;
4403     Flush: WORD;
4404   end;
4405 
4406   TBitmapWritesUserLevel = record
4407     Write: WORD;
4408     Create: WORD;
4409     SetInfo: WORD;
4410   end;
4411 
4412   TMftBitmapWritesUserLevel = record
4413     Write: WORD;
4414     Create: WORD;
4415     SetInfo: WORD;
4416     Flush: WORD;
4417   end;
4418 
4419   TAllocate = record
4420     Calls: DWORD;                // number of individual calls to allocate clusters
4421     Clusters: DWORD;             // number of clusters allocated
4422     Hints: DWORD;                // number of times a hint was specified
4423 
4424     RunsReturned: DWORD;         // number of runs used to satisify all the requests
4425 
4426     HintsHonored: DWORD;         // number of times the hint was useful
4427     HintsClusters: DWORD;        // number of clusters allocated via the hint
4428     Cache: DWORD;                // number of times the cache was useful other than the hint
4429     CacheClusters: DWORD;        // number of clusters allocated via the cache other than the hint
4430     CacheMiss: DWORD;            // number of times the cache wasn't useful
4431     CacheMissClusters: DWORD;    // number of clusters allocated without the cache
4432   end;
4433 
4434   {$EXTERNALSYM NTFS_STATISTICS}
4435   PNTFS_STATISTICS = ^NTFS_STATISTICS;
4436   _NTFS_STATISTICS  = record
4437 
4438     LogFileFullExceptions: DWORD;
4439     OtherExceptions: DWORD;
4440 
4441     //
4442     // Other meta data io's
4443     //
4444 
4445     MftReads: DWORD;
4446     MftReadBytes: DWORD;
4447     MftWrites: DWORD;
4448     MftWriteBytes: DWORD;
4449     MftWritesUserLevel: TMftWritesUserLevel;
4450 
4451     MftWritesFlushForLogFileFull: WORD;
4452     MftWritesLazyWriter: WORD;
4453     MftWritesUserRequest: WORD;
4454 
4455     Mft2Writes: DWORD;
4456     Mft2WriteBytes: DWORD;
4457     Mft2WritesUserLevel: TMft2WritesUserLevel;
4458 
4459     Mft2WritesFlushForLogFileFull: WORD;
4460     Mft2WritesLazyWriter: WORD;
4461     Mft2WritesUserRequest: WORD;
4462 
4463     RootIndexReads: DWORD;
4464     RootIndexReadBytes: DWORD;
4465     RootIndexWrites: DWORD;
4466     RootIndexWriteBytes: DWORD;
4467 
4468     BitmapReads: DWORD;
4469     BitmapReadBytes: DWORD;
4470     BitmapWrites: DWORD;
4471     BitmapWriteBytes: DWORD;
4472 
4473     BitmapWritesFlushForLogFileFull: WORD;
4474     BitmapWritesLazyWriter: WORD;
4475     BitmapWritesUserRequest: WORD;
4476 
4477     BitmapWritesUserLevel: TBitmapWritesUserLevel;
4478 
4479     MftBitmapReads: DWORD;
4480     MftBitmapReadBytes: DWORD;
4481     MftBitmapWrites: DWORD;
4482     MftBitmapWriteBytes: DWORD;
4483 
4484     MftBitmapWritesFlushForLogFileFull: WORD;
4485     MftBitmapWritesLazyWriter: WORD;
4486     MftBitmapWritesUserRequest: WORD;
4487     MftBitmapWritesUserLevel: TMftBitmapWritesUserLevel;
4488 
4489     UserIndexReads: DWORD;
4490     UserIndexReadBytes: DWORD;
4491     UserIndexWrites: DWORD;
4492     UserIndexWriteBytes: DWORD;
4493 
4494     //
4495     // Additions for NT 5.0
4496     //
4497 
4498     LogFileReads: DWORD;
4499     LogFileReadBytes: DWORD;
4500     LogFileWrites: DWORD;
4501     LogFileWriteBytes: DWORD;
4502 
4503     Allocate: TAllocate;
4504   end;
4505   {$EXTERNALSYM _NTFS_STATISTICS}
4506   NTFS_STATISTICS = _NTFS_STATISTICS;
4507   {$EXTERNALSYM PNTFS_STATISTICS}
4508   TNTFSStatistics = NTFS_STATISTICS;
4509   PNTFSStatistics = PNTFS_STATISTICS;
4510 
4511 //
4512 // Structure for FSCTL_SET_OBJECT_ID, FSCTL_GET_OBJECT_ID, and FSCTL_CREATE_OR_GET_OBJECT_ID
4513 //
4514 
4515   PFILE_OBJECTID_BUFFER = ^FILE_OBJECTID_BUFFER;
4516   {$EXTERNALSYM PFILE_OBJECTID_BUFFER}
4517   _FILE_OBJECTID_BUFFER = record
4518 
4519     //
4520     //  This is the portion of the object id that is indexed.
4521     //
4522 
4523     ObjectId: array [0..15] of BYTE;
4524 
4525     //
4526     //  This portion of the object id is not indexed, it's just
4527     //  some metadata for the user's benefit.
4528     //
4529 
4530     case Integer of
4531       0: (
4532         BirthVolumeId: array [0..15] of BYTE;
4533         BirthObjectId: array [0..15] of BYTE;
4534         DomainId: array [0..15] of BYTE);
4535       1: (
4536         ExtendedInfo: array [0..47] of BYTE);
4537   end;
4538   {$EXTERNALSYM _FILE_OBJECTID_BUFFER}
4539   FILE_OBJECTID_BUFFER = _FILE_OBJECTID_BUFFER;
4540   {$EXTERNALSYM FILE_OBJECTID_BUFFER}
4541   TFileObjectIdBuffer = FILE_OBJECTID_BUFFER;
4542   PFileObjectIdBuffer = PFILE_OBJECTID_BUFFER;
4543 
4544 //
4545 // Structure for FSCTL_SET_SPARSE
4546 //
4547 
4548   PFILE_SET_SPARSE_BUFFER = ^FILE_SET_SPARSE_BUFFER;
4549   {$EXTERNALSYM PFILE_SET_SPARSE_BUFFER}
4550   _FILE_SET_SPARSE_BUFFER = record
4551     SetSparse: ByteBool;
4552   end;
4553   {$EXTERNALSYM _FILE_SET_SPARSE_BUFFER}
4554   FILE_SET_SPARSE_BUFFER = _FILE_SET_SPARSE_BUFFER;
4555   {$EXTERNALSYM FILE_SET_SPARSE_BUFFER}
4556   TFileSetSparseBuffer = FILE_SET_SPARSE_BUFFER;
4557   PFileSetSparseBuffer = PFILE_SET_SPARSE_BUFFER;
4558 
4559 //
4560 // Structure for FSCTL_SET_ZERO_DATA
4561 //
4562 
4563   PFILE_ZERO_DATA_INFORMATION = ^FILE_ZERO_DATA_INFORMATION;
4564   {$EXTERNALSYM PFILE_ZERO_DATA_INFORMATION}
4565   _FILE_ZERO_DATA_INFORMATION = record
4566     FileOffset: LARGE_INTEGER;
4567     BeyondFinalZero: LARGE_INTEGER;
4568   end;
4569   {$EXTERNALSYM _FILE_ZERO_DATA_INFORMATION}
4570   FILE_ZERO_DATA_INFORMATION = _FILE_ZERO_DATA_INFORMATION;
4571   {$EXTERNALSYM FILE_ZERO_DATA_INFORMATION}
4572   TFileZeroDataInformation = FILE_ZERO_DATA_INFORMATION;
4573   PFileZeroDataInformation = PFILE_ZERO_DATA_INFORMATION;
4574 
4575 //
4576 // Structure for FSCTL_QUERY_ALLOCATED_RANGES
4577 //
4578 
4579 //
4580 // Querying the allocated ranges requires an output buffer to store the
4581 // allocated ranges and an input buffer to specify the range to query.
4582 // The input buffer contains a single entry, the output buffer is an
4583 // array of the following structure.
4584 //
4585 
4586   PFILE_ALLOCATED_RANGE_BUFFER = ^FILE_ALLOCATED_RANGE_BUFFER;
4587   {$EXTERNALSYM PFILE_ALLOCATED_RANGE_BUFFER}
4588   _FILE_ALLOCATED_RANGE_BUFFER = record
4589     FileOffset: LARGE_INTEGER;
4590     Length: LARGE_INTEGER;
4591   end;
4592   {$EXTERNALSYM _FILE_ALLOCATED_RANGE_BUFFER}
4593   FILE_ALLOCATED_RANGE_BUFFER = _FILE_ALLOCATED_RANGE_BUFFER;
4594   {$EXTERNALSYM FILE_ALLOCATED_RANGE_BUFFER}
4595   TFileAllocatedRangeBuffer = FILE_ALLOCATED_RANGE_BUFFER;
4596   PFileAllocatedRangeBuffer = PFILE_ALLOCATED_RANGE_BUFFER;
4597 
4598 //
4599 // Structures for FSCTL_SET_ENCRYPTION, FSCTL_WRITE_RAW_ENCRYPTED, and FSCTL_READ_RAW_ENCRYPTED
4600 //
4601 
4602 //
4603 //  The input buffer to set encryption indicates whether we are to encrypt/decrypt a file
4604 //  or an individual stream.
4605 //
4606 
4607   PENCRYPTION_BUFFER = ^ENCRYPTION_BUFFER;
4608   {$EXTERNALSYM PENCRYPTION_BUFFER}
4609   _ENCRYPTION_BUFFER = record
4610     EncryptionOperation: DWORD;
4611     Private_: array [0..0] of BYTE;
4612   end;
4613   {$EXTERNALSYM _ENCRYPTION_BUFFER}
4614   ENCRYPTION_BUFFER = _ENCRYPTION_BUFFER;
4615   {$EXTERNALSYM ENCRYPTION_BUFFER}
4616   TEncryptionBuffer = ENCRYPTION_BUFFER;
4617   PEncryptionBuffer = PENCRYPTION_BUFFER;
4618 
4619 const
4620   FILE_SET_ENCRYPTION      = $00000001;
4621   {$EXTERNALSYM FILE_SET_ENCRYPTION}
4622   FILE_CLEAR_ENCRYPTION    = $00000002;
4623   {$EXTERNALSYM FILE_CLEAR_ENCRYPTION}
4624   STREAM_SET_ENCRYPTION    = $00000003;
4625   {$EXTERNALSYM STREAM_SET_ENCRYPTION}
4626   STREAM_CLEAR_ENCRYPTION  = $00000004;
4627   {$EXTERNALSYM STREAM_CLEAR_ENCRYPTION}
4628 
4629   MAXIMUM_ENCRYPTION_VALUE = $00000004;
4630   {$EXTERNALSYM MAXIMUM_ENCRYPTION_VALUE}
4631 
4632 //
4633 //  The optional output buffer to set encryption indicates that the last encrypted
4634 //  stream in a file has been marked as decrypted.
4635 //
4636 
4637 type
4638   PDECRYPTION_STATUS_BUFFER = ^DECRYPTION_STATUS_BUFFER;
4639   {$EXTERNALSYM PDECRYPTION_STATUS_BUFFER}
4640   _DECRYPTION_STATUS_BUFFER = record
4641     NoEncryptedStreams: ByteBool;
4642   end;
4643   {$EXTERNALSYM _DECRYPTION_STATUS_BUFFER}
4644   DECRYPTION_STATUS_BUFFER = _DECRYPTION_STATUS_BUFFER;
4645   {$EXTERNALSYM DECRYPTION_STATUS_BUFFER}
4646   TDecryptionStatusBuffer = DECRYPTION_STATUS_BUFFER;
4647   PDecryptionStatusBuffer = PDECRYPTION_STATUS_BUFFER;
4648 
4649 const
4650   ENCRYPTION_FORMAT_DEFAULT = $01;
4651   {$EXTERNALSYM ENCRYPTION_FORMAT_DEFAULT}
4652 
4653   COMPRESSION_FORMAT_SPARSE = $4000;
4654   {$EXTERNALSYM COMPRESSION_FORMAT_SPARSE}
4655 
4656 //
4657 //  Request Encrypted Data structure.  This is used to indicate
4658 //  the range of the file to read.  It also describes the
4659 //  output buffer used to return the data.
4660 //
4661 
4662 type
4663   PREQUEST_RAW_ENCRYPTED_DATA = ^REQUEST_RAW_ENCRYPTED_DATA;
4664   {$EXTERNALSYM PREQUEST_RAW_ENCRYPTED_DATA}
4665   _REQUEST_RAW_ENCRYPTED_DATA = record
4666     //
4667     //  Requested file offset and requested length to read.
4668     //  The fsctl will round the starting offset down
4669     //  to a file system boundary.  It will also
4670     //  round the length up to a file system boundary.
4671     //
4672     FileOffset: LONGLONG;
4673     Length: DWORD;
4674   end;
4675   {$EXTERNALSYM _REQUEST_RAW_ENCRYPTED_DATA}
4676   REQUEST_RAW_ENCRYPTED_DATA = _REQUEST_RAW_ENCRYPTED_DATA;
4677   {$EXTERNALSYM REQUEST_RAW_ENCRYPTED_DATA}
4678   TRequestRawEncryptedData = REQUEST_RAW_ENCRYPTED_DATA;
4679   PRequestRawEncryptedData = PREQUEST_RAW_ENCRYPTED_DATA;
4680 
4681 //
4682 //  Encrypted Data Information structure.  This structure
4683 //  is used to return raw encrypted data from a file in
4684 //  order to perform off-line recovery.  The data will be
4685 //  encrypted or encrypted and compressed.  The off-line
4686 //  service will need to use the encryption and compression
4687 //  format information to recover the file data.  In the
4688 //  event that the data is both encrypted and compressed then
4689 //  the decryption must occur before decompression.  All
4690 //  the data units below must be encrypted and compressed
4691 //  with the same format.
4692 //
4693 //  The data will be returned in units.  The data unit size
4694 //  will be fixed per request.  If the data is compressed
4695 //  then the data unit size will be the compression unit size.
4696 //
4697 //  This structure is at the beginning of the buffer used to
4698 //  return the encrypted data.  The actual raw bytes from
4699 //  the file will follow this buffer.  The offset of the
4700 //  raw bytes from the beginning of this structure is
4701 //  specified in the REQUEST_RAW_ENCRYPTED_DATA structure
4702 //  described above.
4703 //
4704 
4705   PENCRYPTED_DATA_INFO = ^ENCRYPTED_DATA_INFO;
4706   {$EXTERNALSYM PENCRYPTED_DATA_INFO}
4707   _ENCRYPTED_DATA_INFO = record
4708 
4709     //
4710     //  This is the file offset for the first entry in the
4711     //  data block array.  The file system will round
4712     //  the requested start offset down to a boundary
4713     //  that is consistent with the format of the file.
4714     //
4715 
4716     StartingFileOffset: DWORDLONG;
4717 
4718     //
4719     //  Data offset in output buffer.  The output buffer
4720     //  begins with an ENCRYPTED_DATA_INFO structure.
4721     //  The file system will then store the raw bytes from
4722     //  disk beginning at the following offset within the
4723     //  output buffer.
4724     //
4725 
4726     OutputBufferOffset: DWORD;
4727 
4728     //
4729     //  The number of bytes being returned that are within
4730     //  the size of the file.  If this value is less than
4731     //  (NumberOfDataBlocks << DataUnitShift), it means the
4732     //  end of the file occurs within this transfer.  Any
4733     //  data beyond file size is invalid and was never
4734     //  passed to the encryption driver.
4735     //
4736 
4737     BytesWithinFileSize: DWORD;
4738 
4739     //
4740     //  The number of bytes being returned that are below
4741     //  valid data length.  If this value is less than
4742     //  (NumberOfDataBlocks << DataUnitShift), it means the
4743     //  end of the valid data occurs within this transfer.
4744     //  After decrypting the data from this transfer, any
4745     //  byte(s) beyond valid data length must be zeroed.
4746     //
4747 
4748     BytesWithinValidDataLength: DWORD;
4749 
4750     //
4751     //  Code for the compression format as defined in
4752     //  ntrtl.h.  Note that COMPRESSION_FORMAT_NONE
4753     //  and COMPRESSION_FORMAT_DEFAULT are invalid if
4754     //  any of the described chunks are compressed.
4755     //
4756 
4757     CompressionFormat: WORD;
4758 
4759     //
4760     //  The DataUnit is the granularity used to access the
4761     //  disk.  It will be the same as the compression unit
4762     //  size for a compressed file.  For an uncompressed
4763     //  file, it will be some cluster-aligned power of 2 that
4764     //  the file system deems convenient.  A caller should
4765     //  not expect that successive calls will have the
4766     //  same data unit shift value as the previous call.
4767     //
4768     //  Since chunks and compression units are expected to be
4769     //  powers of 2 in size, we express them log2.  So, for
4770     //  example (1 << ChunkShift) == ChunkSizeInBytes.  The
4771     //  ClusterShift indicates how much space must be saved
4772     //  to successfully compress a compression unit - each
4773     //  successfully compressed data unit must occupy
4774     //  at least one cluster less in bytes than an uncompressed
4775     //  data block unit.
4776     //
4777 
4778     DataUnitShift: BYTE;
4779     ChunkShift: BYTE;
4780     ClusterShift: BYTE;
4781 
4782     //
4783     //  The format for the encryption.
4784     //
4785 
4786     EncryptionFormat: BYTE;
4787 
4788     //
4789     //  This is the number of entries in the data block size
4790     //  array.
4791     //
4792 
4793     NumberOfDataBlocks: WORD;
4794 
4795     //
4796     //  This is an array of sizes in the data block array.  There
4797     //  must be one entry in this array for each data block
4798     //  read from disk.  The size has a different meaning
4799     //  depending on whether the file is compressed.
4800     //
4801     //  A size of zero always indicates that the final data consists entirely
4802     //  of zeroes.  There is no decryption or decompression to
4803     //  perform.
4804     //
4805     //  If the file is compressed then the data block size indicates
4806     //  whether this block is compressed.  A size equal to
4807     //  the block size indicates that the corresponding block did
4808     //  not compress.  Any other non-zero size indicates the
4809     //  size of the compressed data which needs to be
4810     //  decrypted/decompressed.
4811     //
4812     //  If the file is not compressed then the data block size
4813     //  indicates the amount of data within the block that
4814     //  needs to be decrypted.  Any other non-zero size indicates
4815     //  that the remaining bytes in the data unit within the file
4816     //  consists of zeros.  An example of this is when the
4817     //  the read spans the valid data length of the file.  There
4818     //  is no data to decrypt past the valid data length.
4819     //
4820 
4821     DataBlockSize: array [0..ANYSIZE_ARRAY - 1] of DWORD;
4822   end;
4823   {$EXTERNALSYM _ENCRYPTED_DATA_INFO}
4824   ENCRYPTED_DATA_INFO = _ENCRYPTED_DATA_INFO;
4825   {$EXTERNALSYM ENCRYPTED_DATA_INFO}
4826   TEncryptedDataInfo = ENCRYPTED_DATA_INFO;
4827   PEncryptedDataInfo = PENCRYPTED_DATA_INFO;
4828 
4829 //
4830 //  FSCTL_READ_FROM_PLEX support
4831 //  Request Plex Read Data structure.  This is used to indicate
4832 //  the range of the file to read.  It also describes
4833 //  which plex to perform the read from.
4834 //
4835 
4836   _PLEX_READ_DATA_REQUEST = record
4837 
4838     //
4839     //  Requested offset and length to read.
4840     //  The offset can be the virtual offset (vbo) in to a file,
4841     //  or a volume. In the case of a file offset,
4842     //  the fsd will round the starting offset down
4843     //  to a file system boundary.  It will also
4844     //  round the length up to a file system boundary and
4845     //  enforce any other applicable limits.
4846     //
4847 
4848     ByteOffset: LARGE_INTEGER;
4849     ByteLength: DWORD;
4850     PlexNumber: DWORD;
4851   end;
4852   {$EXTERNALSYM _PLEX_READ_DATA_REQUEST}
4853   PLEX_READ_DATA_REQUEST = _PLEX_READ_DATA_REQUEST;
4854   {$EXTERNALSYM PLEX_READ_DATA_REQUEST}
4855   PPLEX_READ_DATA_REQUEST = ^PLEX_READ_DATA_REQUEST;
4856   {$EXTERNALSYM PPLEX_READ_DATA_REQUEST}
4857   TPlexReadDataRequest = PLEX_READ_DATA_REQUEST;
4858   PPlexReadDataRequest = PPLEX_READ_DATA_REQUEST;
4859 
4860 //
4861 // FSCTL_SIS_COPYFILE support
4862 // Source and destination file names are passed in the FileNameBuffer.
4863 // Both strings are null terminated, with the source name starting at
4864 // the beginning of FileNameBuffer, and the destination name immediately
4865 // following.  Length fields include terminating nulls.
4866 //
4867 
4868   PSI_COPYFILE = ^SI_COPYFILE;
4869   {$EXTERNALSYM PSI_COPYFILE}
4870   _SI_COPYFILE = record
4871     SourceFileNameLength: DWORD;
4872     DestinationFileNameLength: DWORD;
4873     Flags: DWORD;
4874     FileNameBuffer: array [0..0] of WCHAR;
4875   end;
4876   {$EXTERNALSYM _SI_COPYFILE}
4877   SI_COPYFILE = _SI_COPYFILE;
4878   {$EXTERNALSYM SI_COPYFILE}
4879   TSiCopyfile = SI_COPYFILE;
4880   PSiCopyfile = PSI_COPYFILE;
4881 
4882 const
4883   COPYFILE_SIS_LINK    = $0001; // Copy only if source is SIS
4884   {$EXTERNALSYM COPYFILE_SIS_LINK}
4885   COPYFILE_SIS_REPLACE = $0002; // Replace destination if it exists, otherwise don't.
4886   {$EXTERNALSYM COPYFILE_SIS_REPLACE}
4887   COPYFILE_SIS_FLAGS   = $0003;
4888   {$EXTERNALSYM COPYFILE_SIS_FLAGS}
4889 
4890 //
4891 // These IOCTLs are handled by hard disk volumes.
4892 //
4893 
4894   IOCTL_VOLUME_BASE = DWORD('V');
4895   {$EXTERNALSYM IOCTL_VOLUME_BASE}
4896 
4897   IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = (
4898     (IOCTL_VOLUME_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
4899     (0 shl 2) or METHOD_BUFFERED);
4900   {$EXTERNALSYM IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS}
4901 
4902   IOCTL_VOLUME_IS_CLUSTERED = (
4903     (IOCTL_VOLUME_BASE shl 16) or (FILE_ANY_ACCESS shl 14) or
4904     (12 shl 2) or METHOD_BUFFERED);
4905   {$EXTERNALSYM IOCTL_VOLUME_IS_CLUSTERED}
4906 
4907 //
4908 // Disk extent definition.
4909 //
4910 
4911 type
4912   PDISK_EXTENT = ^DISK_EXTENT;
4913   {$EXTERNALSYM PDISK_EXTENT}
4914   _DISK_EXTENT = record
4915     DiskNumber: DWORD;
4916     StartingOffset: LARGE_INTEGER;
4917     ExtentLength: LARGE_INTEGER;
4918   end;
4919   {$EXTERNALSYM _DISK_EXTENT}
4920   DISK_EXTENT = _DISK_EXTENT;
4921   {$EXTERNALSYM DISK_EXTENT}
4922   TDiskExtent = DISK_EXTENT;
4923   PDiskExtent = PDISK_EXTENT;
4924 
4925 //
4926 // Output structure for IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.
4927 //
4928 
4929   PVOLUME_DISK_EXTENTS = ^VOLUME_DISK_EXTENTS;
4930   {$EXTERNALSYM PVOLUME_DISK_EXTENTS}
4931   _VOLUME_DISK_EXTENTS = record
4932     NumberOfDiskExtents: DWORD;
4933     Extents: array [0..0] of DISK_EXTENT;
4934   end;
4935   {$EXTERNALSYM _VOLUME_DISK_EXTENTS}
4936   VOLUME_DISK_EXTENTS = _VOLUME_DISK_EXTENTS;
4937   {$EXTERNALSYM VOLUME_DISK_EXTENTS}
4938   TVolumeDiskExtents = VOLUME_DISK_EXTENTS;
4939   PVolumeDiskExtents = PVOLUME_DISK_EXTENTS;
4940 {$ENDIF JWA_IMPLEMENTATIONSECTION}
4941 
4942 {$IFNDEF JWA_OMIT_SECTIONS}
4943 implementation
4944 //uses ...
4945 {$ENDIF JWA_OMIT_SECTIONS}
4946 
4947 {$IFNDEF JWA_INTERFACESECTION}
4948 
CTL_CODEnull4949 function CTL_CODE(DeviceType, Func, Method, Access: WORD): DWORD;
4950 begin
4951   Result := (DeviceType shl 16) or (Access shl 14) or (Func shl 2) or Method;
4952 end;
4953 
DEVICE_TYPE_FROM_CTL_CODEnull4954 function DEVICE_TYPE_FROM_CTL_CODE(CtrlCode: DWORD): WORD;
4955 begin
4956   Result := (CtrlCode and DWORD($FFFF0000)) shr 16;
4957 end;
4958 
4959 {
4960 #define IsRecognizedPartition( PartitionType ) (    \
4961      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) ||  \
4962      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) ||  \
4963      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) ||  \
4964      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) ||  \
4965      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) ||  \
4966      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) ||  \
4967      ((PartitionType) == PARTITION_FAT_12)          ||  \
4968      ((PartitionType) == PARTITION_FAT_16)          ||  \
4969      ((PartitionType) == PARTITION_IFS)             ||  \
4970      ((PartitionType) == PARTITION_HUGE)            ||  \
4971      ((PartitionType) == PARTITION_FAT32)           ||  \
4972      ((PartitionType) == PARTITION_FAT32_XINT13)    ||  \
4973      ((PartitionType) == PARTITION_XINT13) )
4974 }
4975 
IsRecognizedPartitionnull4976 function IsRecognizedPartition(PartitionType: DWORD): Boolean;
4977 begin
4978   Result :=
4979     (((PartitionType and PARTITION_NTFT) <> 0) and ((PartitionType and not $C0) = PARTITION_FAT_12)) or
4980     (((PartitionType and PARTITION_NTFT) <> 0) and ((PartitionType and not $C0) = PARTITION_IFS)) or
4981     (((PartitionType and PARTITION_NTFT) <> 0) and ((PartitionType and not $C0) = PARTITION_HUGE)) or
4982     (((PartitionType and PARTITION_NTFT) <> 0) and ((PartitionType and not $C0) = PARTITION_FAT32)) or
4983     (((PartitionType and PARTITION_NTFT) <> 0) and ((PartitionType and not $C0) = PARTITION_FAT32_XINT13)) or
4984     (((PartitionType and PARTITION_NTFT) <> 0) and ((PartitionType and not $C0) = PARTITION_XINT13)) or
4985     ((PartitionType) = PARTITION_FAT_12) or
4986     ((PartitionType) = PARTITION_FAT_16) or
4987     ((PartitionType) = PARTITION_IFS) or
4988     ((PartitionType) = PARTITION_HUGE) or
4989     ((PartitionType) = PARTITION_FAT32) or
4990     ((PartitionType) = PARTITION_FAT32_XINT13) or
4991     ((PartitionType) = PARTITION_XINT13);
4992 end;
4993 
IsContainerPartitionnull4994 function IsContainerPartition(PartitionType: DWORD): Boolean;
4995 begin
4996   Result :=
4997     (PartitionType = PARTITION_EXTENDED) or
4998     (PartitionType = PARTITION_XINT13_EXTENDED);
4999 end;
5000 
IsFTPartitionnull5001 function IsFTPartition(PartitionType: DWORD): Boolean;
5002 begin
5003   Result := ((PartitionType and PARTITION_NTFT) <> 0) and IsRecognizedPartition(PartitionType);
5004 end;
5005 
DiskGeometryGetPartitionnull5006 function DiskGeometryGetPartition(Geometry: PDiskGeometryEx): PDiskPartitionInfo;
5007 begin
5008   Result := @Geometry^.Data[0];
5009 end;
5010 
DiskGeometryGetDetectnull5011 function DiskGeometryGetDetect(Geometry: PDiskGeometryEx): PDiskDetectionInfo;
5012 var
5013   Partition: PDiskPartitionInfo;
5014 begin
5015   Partition := DiskGeometryGetPartition(Geometry);
5016   Result := PDiskDetectionInfo(PChar(Partition) + Partition^.SizeOfPartitionInfo*SizeOf(DWORD));
5017 end;
5018 
5019 {$ENDIF JWA_INTERFACESECTION}
5020 
5021 
5022 
5023 {$IFNDEF JWA_OMIT_SECTIONS}
5024 end.
5025 {$ENDIF JWA_OMIT_SECTIONS}
5026