home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / winioctl.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  87KB  |  2,394 lines

  1. /*++ BUILD Version: 0013    // Increment this if a change has global effects
  2.  
  3. Copyright 1990 - 1998 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     winioctl.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the 32-Bit Windows Device I/O control codes.
  12.  
  13. Revision History:
  14.  
  15. --*/
  16.  
  17. #ifndef _WINIOCTL_
  18. #define _WINIOCTL_
  19.  
  20.  
  21. #ifndef _DEVIOCTL_
  22. #define _DEVIOCTL_
  23.  
  24. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  25. //
  26. // Define the various device type values.  Note that values used by Microsoft
  27. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  28. // by customers.
  29. //
  30.  
  31. #define DEVICE_TYPE DWORD
  32.  
  33. #define FILE_DEVICE_BEEP                0x00000001
  34. #define FILE_DEVICE_CD_ROM              0x00000002
  35. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
  36. #define FILE_DEVICE_CONTROLLER          0x00000004
  37. #define FILE_DEVICE_DATALINK            0x00000005
  38. #define FILE_DEVICE_DFS                 0x00000006
  39. #define FILE_DEVICE_DISK                0x00000007
  40. #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
  41. #define FILE_DEVICE_FILE_SYSTEM         0x00000009
  42. #define FILE_DEVICE_INPORT_PORT         0x0000000a
  43. #define FILE_DEVICE_KEYBOARD            0x0000000b
  44. #define FILE_DEVICE_MAILSLOT            0x0000000c
  45. #define FILE_DEVICE_MIDI_IN             0x0000000d
  46. #define FILE_DEVICE_MIDI_OUT            0x0000000e
  47. #define FILE_DEVICE_MOUSE               0x0000000f
  48. #define FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
  49. #define FILE_DEVICE_NAMED_PIPE          0x00000011
  50. #define FILE_DEVICE_NETWORK             0x00000012
  51. #define FILE_DEVICE_NETWORK_BROWSER     0x00000013
  52. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  53. #define FILE_DEVICE_NULL                0x00000015
  54. #define FILE_DEVICE_PARALLEL_PORT       0x00000016
  55. #define FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
  56. #define FILE_DEVICE_PRINTER             0x00000018
  57. #define FILE_DEVICE_SCANNER             0x00000019
  58. #define FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
  59. #define FILE_DEVICE_SERIAL_PORT         0x0000001b
  60. #define FILE_DEVICE_SCREEN              0x0000001c
  61. #define FILE_DEVICE_SOUND               0x0000001d
  62. #define FILE_DEVICE_STREAMS             0x0000001e
  63. #define FILE_DEVICE_TAPE                0x0000001f
  64. #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
  65. #define FILE_DEVICE_TRANSPORT           0x00000021
  66. #define FILE_DEVICE_UNKNOWN             0x00000022
  67. #define FILE_DEVICE_VIDEO               0x00000023
  68. #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
  69. #define FILE_DEVICE_WAVE_IN             0x00000025
  70. #define FILE_DEVICE_WAVE_OUT            0x00000026
  71. #define FILE_DEVICE_8042_PORT           0x00000027
  72. #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
  73. #define FILE_DEVICE_BATTERY             0x00000029
  74. #define FILE_DEVICE_BUS_EXTENDER        0x0000002a
  75. #define FILE_DEVICE_MODEM               0x0000002b
  76. #define FILE_DEVICE_VDM                 0x0000002c
  77. #define FILE_DEVICE_MASS_STORAGE        0x0000002d
  78. #define FILE_DEVICE_SMB                 0x0000002e
  79. #define FILE_DEVICE_KS                  0x0000002f
  80. #define FILE_DEVICE_CHANGER             0x00000030
  81. #define FILE_DEVICE_SMARTCARD           0x00000031
  82. #define FILE_DEVICE_ACPI                0x00000032
  83. #define FILE_DEVICE_DVD                 0x00000033
  84. #define FILE_DEVICE_FULLSCREEN_VIDEO    0x00000034
  85. #define FILE_DEVICE_DFS_FILE_SYSTEM     0x00000035
  86. #define FILE_DEVICE_DFS_VOLUME          0x00000036
  87.  
  88. //
  89. // Macro definition for defining IOCTL and FSCTL function control codes.  Note
  90. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  91. // 2048-4095 are reserved for customers.
  92. //
  93.  
  94. #define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
  95.     ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  96. )
  97.  
  98. //
  99. // Define the method codes for how buffers are passed for I/O and FS controls
  100. //
  101.  
  102. #define METHOD_BUFFERED                 0
  103. #define METHOD_IN_DIRECT                1
  104. #define METHOD_OUT_DIRECT               2
  105. #define METHOD_NEITHER                  3
  106.  
  107. //
  108. // Define the access check value for any access
  109. //
  110. //
  111. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  112. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  113. // constants *MUST* always be in sync.
  114. //
  115.  
  116.  
  117. #define FILE_ANY_ACCESS                 0
  118. #define FILE_READ_ACCESS          ( 0x0001 )    // file & pipe
  119. #define FILE_WRITE_ACCESS         ( 0x0002 )    // file & pipe
  120.  
  121. // end_ntddk end_wdm end_nthal end_ntifs
  122.  
  123. #endif // _DEVIOCTL_
  124.  
  125.  
  126. #ifndef _NTDDSTOR_H_
  127. #define _NTDDSTOR_H_
  128.  
  129. #ifdef __cplusplus
  130. extern "C" {
  131. #endif
  132.  
  133. //
  134. // IoControlCode values for storage devices
  135. //
  136.  
  137. #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
  138.  
  139. //
  140. // The following device control codes are common for all class drivers.  They
  141. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  142. // common codes
  143. //
  144.  
  145. #define IOCTL_STORAGE_CHECK_VERIFY     CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  146. #define IOCTL_STORAGE_MEDIA_REMOVAL    CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  147. #define IOCTL_STORAGE_EJECT_MEDIA      CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  148. #define IOCTL_STORAGE_LOAD_MEDIA       CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  149. #define IOCTL_STORAGE_RESERVE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  150. #define IOCTL_STORAGE_RELEASE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  151. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  152.  
  153. #define IOCTL_STORAGE_GET_MEDIA_TYPES  CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  154. #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
  155.  
  156. #define IOCTL_STORAGE_RESET_BUS        CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
  157. #define IOCTL_STORAGE_RESET_DEVICE     CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
  158.  
  159. #define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
  160.  
  161.  
  162. //
  163. // IOCTL_STORAGE_GET_DEVICE_NUMBER
  164. //
  165. // input - none
  166. //
  167. // output - STORAGE_DEVICE_NUMBER structure
  168. //          The values in the STORAGE_DEVICE_NUMBER structure are guaranteed
  169. //          to remain unchanged until the system is rebooted.  They are not
  170. //          guaranteed to be persistant across boots.
  171. //
  172.  
  173. typedef struct _STORAGE_DEVICE_NUMBER {
  174.  
  175.     //
  176.     // The FILE_DEVICE_XXX type for this device.
  177.     //
  178.  
  179.     DEVICE_TYPE DeviceType;
  180.  
  181.     //
  182.     // The number of this device
  183.     //
  184.  
  185.     DWORD       DeviceNumber;
  186.  
  187.     //
  188.     // If the device is partitionable, the partition number of the device.
  189.     // Otherwise -1
  190.     //
  191.  
  192.     DWORD       PartitionNumber;
  193. } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
  194.  
  195. //
  196. // Define the structures for scsi resets
  197. //
  198.  
  199. typedef struct _STORAGE_BUS_RESET_REQUEST {
  200.     BYTE  PathId;
  201. } STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
  202.  
  203. //
  204. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  205. // on a storage device that ejects media. This function
  206. // may or may not be supported on storage devices that
  207. // support removable media.
  208. //
  209. // TRUE means prevent media from being removed.
  210. // FALSE means allow media removal.
  211. //
  212.  
  213. typedef struct _PREVENT_MEDIA_REMOVAL {
  214.     BOOLEAN PreventMediaRemoval;
  215. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  216.  
  217. // begin_ntminitape
  218.  
  219.  
  220. typedef struct _TAPE_STATISTICS {
  221.     DWORD Version;
  222.     DWORD Flags;
  223.     LARGE_INTEGER RecoveredWrites;
  224.     LARGE_INTEGER UnrecoveredWrites;
  225.     LARGE_INTEGER RecoveredReads;
  226.     LARGE_INTEGER UnrecoveredReads;
  227.     BYTE          CompressionRatioReads;
  228.     BYTE          CompressionRatioWrites;
  229. } TAPE_STATISTICS, *PTAPE_STATISTICS;
  230.  
  231. #define RECOVERED_WRITES_VALID   0x00000001
  232. #define UNRECOVERED_WRITES_VALID 0x00000002
  233. #define RECOVERED_READS_VALID    0x00000004
  234. #define UNRECOVERED_READS_VALID  0x00000008
  235. #define WRITE_COMPRESSION_INFO_VALID  0x00000010
  236. #define READ_COMPRESSION_INFO_VALID   0x00000020
  237.  
  238. typedef struct _TAPE_GET_STATISTICS {
  239.     DWORD Operation;
  240. } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
  241.  
  242. #define TAPE_RETURN_STATISTICS 0L
  243. #define TAPE_RETURN_ENV_INFO   1L
  244. #define TAPE_RESET_STATISTICS  2L
  245.  
  246. //
  247. // IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
  248. // structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
  249. //
  250.  
  251. typedef enum _STORAGE_MEDIA_TYPE {
  252.     //
  253.     // Following are defined in ntdddisk.h in the MEDIA_TYPE enum
  254.     //
  255.     // Unknown,                // Format is unknown
  256.     // F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
  257.     // F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
  258.     // F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
  259.     // F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
  260.     // F3_720_512,             // 3.5",  720KB,  512 bytes/sector
  261.     // F5_360_512,             // 5.25", 360KB,  512 bytes/sector
  262.     // F5_320_512,             // 5.25", 320KB,  512 bytes/sector
  263.     // F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
  264.     // F5_180_512,             // 5.25", 180KB,  512 bytes/sector
  265.     // F5_160_512,             // 5.25", 160KB,  512 bytes/sector
  266.     // RemovableMedia,         // Removable media other than floppy
  267.     // FixedMedia,             // Fixed hard disk media
  268.     // F3_120M_512,            // 3.5", 120M Floppy
  269.     // F3_640_512,             // 3.5" ,  640KB,  512 bytes/sector
  270.     // F5_640_512,             // 5.25",  640KB,  512 bytes/sector
  271.     // F5_720_512,             // 5.25",  720KB,  512 bytes/sector
  272.     // F3_1Pt2_512,            // 3.5" ,  1.2Mb,  512 bytes/sector
  273.     // F3_1Pt23_1024,          // 3.5" ,  1.23Mb, 1024 bytes/sector
  274.     // F5_1Pt23_1024,          // 5.25",  1.23MB, 1024 bytes/sector
  275.     // F3_128Mb_512,           // 3.5" MO 128Mb   512 bytes/sector
  276.     // F3_230Mb_512,           // 3.5" MO 230Mb   512 bytes/sector
  277.     // F8_256_128,             // 8",     256KB,  128 bytes/sector
  278.     //
  279.  
  280.     DDS_4mm = 0x20,            // Tape - DAT DDS1,2,... (all vendors)
  281.     MiniQic,                   // Tape - miniQIC Tape
  282.     Travan,                    // Tape - Travan TR-1,2,3,...
  283.     QIC,                       // Tape - QIC
  284.     MP_8mm,                    // Tape - 8mm Exabyte Metal Particle
  285.     AME_8mm,                   // Tape - 8mm Exabyte Advanced Metal Evap
  286.     AIT1_8mm,                  // Tape - 8mm Sony AIT1
  287.     DLT,                       // Tape - DLT Compact IIIxt, IV
  288.     NCTP,                      // Tape - Philips NCTP
  289.     IBM_3480,                  // Tape - IBM 3480
  290.     IBM_3490E,                 // Tape - IBM 3490E
  291.     IBM_Magstar_3590,          // Tape - IBM Magstar 3590
  292.     IBM_Magstar_MP,            // Tape - IBM Magstar MP
  293.     STK_DATA_D3,               // Tape - STK Data D3
  294.     SONY_DTF,                  // Tape - Sony DTF
  295.     DV_6mm,                    // Tape - 6mm Digital Video
  296.     DMI,                       // Tape - Exabyte DMI and compatibles
  297.     SONY_D2,                   // Tape - Sony D2S and D2L
  298.     CLEANER_CARTRIDGE,         // Cleaner - All Drive types that support Drive Cleaners
  299.     CD_ROM,                    // Opt_Disk - CD
  300.     CD_R,                      // Opt_Disk - CD-Recordable (Write Once)
  301.     CD_RW,                     // Opt_Disk - CD-Rewriteable
  302.     DVD_ROM,                   // Opt_Disk - DVD-ROM
  303.     DVD_R,                     // Opt_Disk - DVD-Recordable (Write Once)
  304.     DVD_RW,                    // Opt_Disk - DVD-Rewriteable
  305.     MO_3_RW,                   // Opt_Disk - 3.5" Rewriteable MO Disk
  306.     MO_5_WO,                   // Opt_Disk - MO 5.25" Write Once
  307.     MO_5_RW,                   // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
  308.     MO_5_LIMDOW,               // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
  309.     PC_5_WO,                   // Opt_Disk - Phase Change 5.25" Write Once Optical
  310.     PC_5_RW,                   // Opt_Disk - Phase Change 5.25" Rewriteable
  311.     PD_5_RW,                   // Opt_Disk - PhaseChange Dual Rewriteable
  312.     ABL_5_WO,                  // Opt_Disk - Ablative 5.25" Write Once Optical
  313.     PINNACLE_APEX_5_RW,        // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
  314.     SONY_12_WO,                // Opt_Disk - Sony 12" Write Once
  315.     PHILIPS_12_WO,             // Opt_Disk - Philips/LMS 12" Write Once
  316.     HITACHI_12_WO,             // Opt_Disk - Hitachi 12" Write Once
  317.     CYGNET_12_WO,              // Opt_Disk - Cygnet/ATG 12" Write Once
  318.     KODAK_14_WO,               // Opt_Disk - Kodak 14" Write Once
  319.     MO_NFR_525,                // Opt_Disk - Near Field Recording (Terastor)
  320.     NIKON_12_RW,               // Opt_Disk - Nikon 12" Rewriteable
  321.     IOMEGA_ZIP,                // Mag_Disk - Iomega Zip
  322.     IOMEGA_JAZ,                // Mag_Disk - Iomega Jaz
  323.     SYQUEST_EZ135,             // Mag_Disk - Syquest EZ135
  324.     SYQUEST_EZFLYER,           // Mag_Disk - Syquest EzFlyer
  325.     SYQUEST_SYJET,             // Mag_Disk - Syquest SyJet
  326.     AVATAR_F2,                 // Mag_Disk - 2.5" Floppy
  327.     MP2_8mm                    // Tape - 8mm Hitachi
  328. } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
  329.  
  330. #define MEDIA_ERASEABLE         0x00000001
  331. #define MEDIA_WRITE_ONCE        0x00000002
  332. #define MEDIA_READ_ONLY         0x00000004
  333. #define MEDIA_READ_WRITE        0x00000008
  334.  
  335. #define MEDIA_WRITE_PROTECTED   0x00000100
  336. #define MEDIA_CURRENTLY_MOUNTED 0x80000000
  337.  
  338. typedef struct _DEVICE_MEDIA_INFO {
  339.     union {
  340.         struct {
  341.             LARGE_INTEGER Cylinders;
  342.             STORAGE_MEDIA_TYPE MediaType;
  343.             DWORD TracksPerCylinder;
  344.             DWORD SectorsPerTrack;
  345.             DWORD BytesPerSector;
  346.             DWORD NumberMediaSides;
  347.             DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  348.         } DiskInfo;
  349.  
  350.         struct {
  351.             LARGE_INTEGER Cylinders;
  352.             STORAGE_MEDIA_TYPE MediaType;
  353.             DWORD TracksPerCylinder;
  354.             DWORD SectorsPerTrack;
  355.             DWORD BytesPerSector;
  356.             DWORD NumberMediaSides;
  357.             DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  358.         } RemovableDiskInfo;
  359.  
  360.         struct {
  361.             STORAGE_MEDIA_TYPE MediaType;
  362.             DWORD   MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  363.             DWORD   CurrentBlockSize;
  364.         } TapeInfo;
  365.     } DeviceSpecific;
  366. } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
  367.  
  368. typedef struct _GET_MEDIA_TYPES {
  369.     DWORD DeviceType;              // FILE_DEVICE_XXX values
  370.     DWORD MediaInfoCount;
  371.     DEVICE_MEDIA_INFO MediaInfo[1];
  372. } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
  373.  
  374. // end_ntminitape
  375.  
  376. #ifdef __cplusplus
  377. }
  378. #endif
  379.  
  380. #endif // _NTDDSTOR_H_
  381.  
  382. //
  383. // IoControlCode values for disk devices.
  384. //
  385.  
  386. #define IOCTL_DISK_BASE                 FILE_DEVICE_DISK
  387. #define IOCTL_DISK_GET_DRIVE_GEOMETRY   CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  388. #define IOCTL_DISK_GET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  389. #define IOCTL_DISK_SET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  390. #define IOCTL_DISK_GET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  391. #define IOCTL_DISK_SET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  392. #define IOCTL_DISK_VERIFY               CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  393. #define IOCTL_DISK_FORMAT_TRACKS        CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  394. #define IOCTL_DISK_REASSIGN_BLOCKS      CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  395. #define IOCTL_DISK_PERFORMANCE          CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  396. #define IOCTL_DISK_IS_WRITABLE          CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  397. #define IOCTL_DISK_LOGGING              CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  398. #define IOCTL_DISK_FORMAT_TRACKS_EX     CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  399. #define IOCTL_DISK_HISTOGRAM_STRUCTURE  CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  400. #define IOCTL_DISK_HISTOGRAM_DATA       CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  401. #define IOCTL_DISK_HISTOGRAM_RESET      CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  402. #define IOCTL_DISK_REQUEST_STRUCTURE    CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  403. #define IOCTL_DISK_REQUEST_DATA         CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  404.  
  405. #if(_WIN32_WINNT >= 0x0400)
  406. #define IOCTL_DISK_CONTROLLER_NUMBER    CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  407.  
  408. //
  409. // IOCTL support for SMART drive fault prediction.
  410. //
  411.  
  412. #define SMART_GET_VERSION               CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  413. #define SMART_SEND_DRIVE_COMMAND        CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  414. #define SMART_RCV_DRIVE_DATA            CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  415. #endif /* _WIN32_WINNT >= 0x0400 */
  416.  
  417.  
  418. //
  419. // The following device control codes are common for all class drivers.  The
  420. // functions codes defined here must match all of the other class drivers.
  421. //
  422. // Warning: these codes will be replaced in the future by equivalent
  423. // IOCTL_STORAGE codes
  424. //
  425.  
  426. #define IOCTL_DISK_CHECK_VERIFY     CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  427. #define IOCTL_DISK_MEDIA_REMOVAL    CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  428. #define IOCTL_DISK_EJECT_MEDIA      CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  429. #define IOCTL_DISK_LOAD_MEDIA       CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  430. #define IOCTL_DISK_RESERVE          CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  431. #define IOCTL_DISK_RELEASE          CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  432. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  433. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  434.  
  435. //
  436. // Define the partition types returnable by known disk drivers.
  437. //
  438.  
  439. #define PARTITION_ENTRY_UNUSED          0x00      // Entry unused
  440. #define PARTITION_FAT_12                0x01      // 12-bit FAT entries
  441. #define PARTITION_XENIX_1               0x02      // Xenix
  442. #define PARTITION_XENIX_2               0x03      // Xenix
  443. #define PARTITION_FAT_16                0x04      // 16-bit FAT entries
  444. #define PARTITION_EXTENDED              0x05      // Extended partition entry
  445. #define PARTITION_HUGE                  0x06      // Huge partition MS-DOS V4
  446. #define PARTITION_IFS                   0x07      // IFS Partition
  447. #define PARTITION_FAT32                 0x0B      // FAT32
  448. #define PARTITION_FAT32_XINT13          0x0C      // FAT32 using extended int13 services
  449. #define PARTITION_XINT13                0x0E      // Win95 partition using extended int13 services
  450. #define PARTITION_XINT13_EXTENDED       0x0F      // Same as type 5 but uses extended int13 services
  451. #define PARTITION_PREP                  0x41      // PowerPC Reference Platform (PReP) Boot Partition
  452. #define PARTITION_LDM                   0x42      // Logical Disk Manager partition
  453. #define PARTITION_UNIX                  0x63      // Unix
  454.  
  455. #define VALID_NTFT                      0xC0      // NTFT uses high order bits
  456.  
  457. //
  458. // The high bit of the partition type code indicates that a partition
  459. // is part of an NTFT mirror or striped array.
  460. //
  461.  
  462. #define PARTITION_NTFT                  0x80     // NTFT partition
  463.  
  464. //
  465. // The following macro is used to determine which partitions should be
  466. // assigned drive letters.
  467. //
  468.  
  469. //++
  470. //
  471. // BOOLEAN
  472. // IsRecognizedPartition(
  473. //     IN DWORD PartitionType
  474. //     )
  475. //
  476. // Routine Description:
  477. //
  478. //     This macro is used to determine to which partitions drive letters
  479. //     should be assigned.
  480. //
  481. // Arguments:
  482. //
  483. //     PartitionType - Supplies the type of the partition being examined.
  484. //
  485. // Return Value:
  486. //
  487. //     The return value is TRUE if the partition type is recognized,
  488. //     otherwise FALSE is returned.
  489. //
  490. //--
  491.  
  492. #define IsRecognizedPartition( PartitionType ) (       \
  493.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) ||  \
  494.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_16)) ||  \
  495.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) ||  \
  496.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) ||  \
  497.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) ||  \
  498.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) ||  \
  499.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) ||  \
  500.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_12) ||  \
  501.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_16) ||  \
  502.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_IFS)    ||  \
  503.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_HUGE)    ||  \
  504.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32)  || \
  505.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32_XINT13) || \
  506.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_XINT13) )
  507.  
  508. //++
  509. //
  510. // BOOLEAN
  511. // IsContainerPartition(
  512. //     IN DWORD PartitionType
  513. //     )
  514. //
  515. // Routine Description:
  516. //
  517. //     This macro is used to determine to which partition types are actually
  518. //     containers for other partitions (ie, extended partitions).
  519. //
  520. // Arguments:
  521. //
  522. //     PartitionType - Supplies the type of the partition being examined.
  523. //
  524. // Return Value:
  525. //
  526. //     The return value is TRUE if the partition type is a container,
  527. //     otherwise FALSE is returned.
  528. //
  529. //--
  530.  
  531. #define IsContainerPartition( PartitionType ) \
  532.     ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  533.  
  534. //
  535. // Define the media types supported by the driver.
  536. //
  537.  
  538. typedef enum _MEDIA_TYPE {
  539.     Unknown,                // Format is unknown
  540.     F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
  541.     F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
  542.     F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
  543.     F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
  544.     F3_720_512,             // 3.5",  720KB,  512 bytes/sector
  545.     F5_360_512,             // 5.25", 360KB,  512 bytes/sector
  546.     F5_320_512,             // 5.25", 320KB,  512 bytes/sector
  547.     F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
  548.     F5_180_512,             // 5.25", 180KB,  512 bytes/sector
  549.     F5_160_512,             // 5.25", 160KB,  512 bytes/sector
  550.     RemovableMedia,         // Removable media other than floppy
  551.     FixedMedia,             // Fixed hard disk media
  552.     F3_120M_512,            // 3.5", 120M Floppy
  553.     F3_640_512,             // 3.5" ,  640KB,  512 bytes/sector
  554.     F5_640_512,             // 5.25",  640KB,  512 bytes/sector
  555.     F5_720_512,             // 5.25",  720KB,  512 bytes/sector
  556.     F3_1Pt2_512,            // 3.5" ,  1.2Mb,  512 bytes/sector
  557.     F3_1Pt23_1024,          // 3.5" ,  1.23Mb, 1024 bytes/sector
  558.     F5_1Pt23_1024,          // 5.25",  1.23MB, 1024 bytes/sector
  559.     F3_128Mb_512,           // 3.5" MO 128Mb   512 bytes/sector
  560.     F3_230Mb_512,           // 3.5" MO 230Mb   512 bytes/sector
  561.     F8_256_128              // 8",     256KB,  128 bytes/sector
  562. } MEDIA_TYPE, *PMEDIA_TYPE;
  563.  
  564. //
  565. // Define the input buffer structure for the driver, when
  566. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  567. //
  568.  
  569. typedef struct _FORMAT_PARAMETERS {
  570.    MEDIA_TYPE MediaType;
  571.    DWORD StartCylinderNumber;
  572.    DWORD EndCylinderNumber;
  573.    DWORD StartHeadNumber;
  574.    DWORD EndHeadNumber;
  575. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  576.  
  577. //
  578. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  579. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  580. // what tracks were bad during formatting. The length of that array is
  581. // reported in the `Information' field of the I/O Status Block.
  582. //
  583.  
  584. typedef WORD   BAD_TRACK_NUMBER;
  585. typedef WORD   *PBAD_TRACK_NUMBER;
  586.  
  587. //
  588. // Define the input buffer structure for the driver, when
  589. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  590. //
  591.  
  592. typedef struct _FORMAT_EX_PARAMETERS {
  593.    MEDIA_TYPE MediaType;
  594.    DWORD StartCylinderNumber;
  595.    DWORD EndCylinderNumber;
  596.    DWORD StartHeadNumber;
  597.    DWORD EndHeadNumber;
  598.    WORD   FormatGapLength;
  599.    WORD   SectorsPerTrack;
  600.    WORD   SectorNumber[1];
  601. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  602.  
  603. //
  604. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  605. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  606. // request.
  607. //
  608.  
  609. typedef struct _DISK_GEOMETRY {
  610.     LARGE_INTEGER Cylinders;
  611.     MEDIA_TYPE MediaType;
  612.     DWORD TracksPerCylinder;
  613.     DWORD SectorsPerTrack;
  614.     DWORD BytesPerSector;
  615. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  616.  
  617. //
  618. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  619. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request.  It is also used in a request
  620. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  621. //
  622.  
  623. typedef struct _PARTITION_INFORMATION {
  624.     LARGE_INTEGER StartingOffset;
  625.     LARGE_INTEGER PartitionLength;
  626.     DWORD HiddenSectors;
  627.     DWORD PartitionNumber;
  628.     BYTE  PartitionType;
  629.     BOOLEAN BootIndicator;
  630.     BOOLEAN RecognizedPartition;
  631.     BOOLEAN RewritePartition;
  632. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  633.  
  634. //
  635. // The following structure is used to change the partition type of a
  636. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  637. // request.
  638. //
  639.  
  640. typedef struct _SET_PARTITION_INFORMATION {
  641.     BYTE  PartitionType;
  642. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  643.  
  644. //
  645. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  646. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  647. //
  648.  
  649. typedef struct _DRIVE_LAYOUT_INFORMATION {
  650.     DWORD PartitionCount;
  651.     DWORD Signature;
  652.     PARTITION_INFORMATION PartitionEntry[1];
  653. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  654.  
  655. //
  656. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  657. // The offset and length parameters are both given in bytes.
  658. //
  659.  
  660. typedef struct _VERIFY_INFORMATION {
  661.     LARGE_INTEGER StartingOffset;
  662.     DWORD Length;
  663. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  664.  
  665. //
  666. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  667. // request.
  668. //
  669.  
  670. typedef struct _REASSIGN_BLOCKS {
  671.     WORD   Reserved;
  672.     WORD   Count;
  673.     DWORD BlockNumber[1];
  674. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  675.  
  676. #if(_WIN32_WINNT >= 0x0400)
  677. //
  678. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  679. // number for the handle.  This is used to determine if a disk
  680. // is attached to the primary or secondary IDE controller.
  681. //
  682.  
  683. typedef struct _DISK_CONTROLLER_NUMBER {
  684.     DWORD ControllerNumber;
  685.     DWORD DiskNumber;
  686. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  687. #endif /* _WIN32_WINNT >= 0x0400 */
  688.  
  689. ///////////////////////////////////////////////////////
  690. //                                                   //
  691. // The following structures define disk performance  //
  692. // statistics: specifically the locations of all the //
  693. // reads and writes which have occured on the disk.  //
  694. //                                                   //
  695. // To use these structures, you must issue an IOCTL_ //
  696. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to    //
  697. // obtain the basic histogram information. The       //
  698. // number of buckets which must allocated is part of //
  699. // this structure. Allocate the required number of   //
  700. // buckets and call an IOCTL_DISK_HIST_DATA to fill  //
  701. // in the data                                       //
  702. //                                                   //
  703. ///////////////////////////////////////////////////////
  704.  
  705. #define HIST_NO_OF_BUCKETS  24
  706.  
  707. typedef struct _HISTOGRAM_BUCKET {
  708.     DWORD       Reads;
  709.     DWORD       Writes;
  710. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  711.  
  712. #define HISTOGRAM_BUCKET_SIZE   sizeof(HISTOGRAM_BUCKET)
  713.  
  714. typedef struct _DISK_HISTOGRAM {
  715.     LARGE_INTEGER   DiskSize;
  716.     LARGE_INTEGER   Start;
  717.     LARGE_INTEGER   End;
  718.     LARGE_INTEGER   Average;
  719.     LARGE_INTEGER   AverageRead;
  720.     LARGE_INTEGER   AverageWrite;
  721.     DWORD           Granularity;
  722.     DWORD           Size;
  723.     DWORD           ReadCount;
  724.     DWORD           WriteCount;
  725.     PHISTOGRAM_BUCKET  Histogram;
  726. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  727.  
  728. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  729.  
  730. ///////////////////////////////////////////////////////
  731. //                                                   //
  732. // The following structures define disk debugging    //
  733. // capabilities. The IOCTLs are directed to one of   //
  734. // the two disk filter drivers.                      //
  735. //                                                   //
  736. // DISKPERF is a utilty for collecting disk request  //
  737. // statistics.                                       //
  738. //                                                   //
  739. // SIMBAD is a utility for injecting faults in       //
  740. // IO requests to disks.                             //
  741. //                                                   //
  742. ///////////////////////////////////////////////////////
  743.  
  744. //
  745. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  746. // request. This ioctl collects summary disk request statistics used
  747. // in measuring performance.
  748. //
  749.  
  750. typedef struct _DISK_PERFORMANCE {
  751.         LARGE_INTEGER BytesRead;
  752.         LARGE_INTEGER BytesWritten;
  753.         LARGE_INTEGER ReadTime;
  754.         LARGE_INTEGER WriteTime;
  755.         DWORD ReadCount;
  756.         DWORD WriteCount;
  757.         DWORD QueueDepth;
  758. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  759.  
  760. //
  761. // This structure defines the disk logging record. When disk logging
  762. // is enabled, one of these is written to an internal buffer for each
  763. // disk request.
  764. //
  765.  
  766. typedef struct _DISK_RECORD {
  767.    LARGE_INTEGER ByteOffset;
  768.    LARGE_INTEGER StartTime;
  769.    LARGE_INTEGER EndTime;
  770.    PVOID VirtualAddress;
  771.    DWORD NumberOfBytes;
  772.    BYTE  DeviceNumber;
  773.    BOOLEAN ReadRequest;
  774. } DISK_RECORD, *PDISK_RECORD;
  775.  
  776. //
  777. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  778. // Not all fields are valid with each function type.
  779. //
  780.  
  781. typedef struct _DISK_LOGGING {
  782.     BYTE  Function;
  783.     PVOID BufferAddress;
  784.     DWORD BufferSize;
  785. } DISK_LOGGING, *PDISK_LOGGING;
  786.  
  787. //
  788. // Disk logging functions
  789. //
  790. // Start disk logging. Only the Function and BufferSize fields are valid.
  791. //
  792.  
  793. #define DISK_LOGGING_START    0
  794.  
  795. //
  796. // Stop disk logging. Only the Function field is valid.
  797. //
  798.  
  799. #define DISK_LOGGING_STOP     1
  800.  
  801. //
  802. // Return disk log. All fields are valid. Data will be copied from internal
  803. // buffer to buffer specified for the number of bytes requested.
  804. //
  805.  
  806. #define DISK_LOGGING_DUMP     2
  807.  
  808. //
  809. // DISK BINNING
  810. //
  811. // DISKPERF will keep counters for IO that falls in each of these ranges.
  812. // The application determines the number and size of the ranges.
  813. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  814. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  815. //
  816.  
  817. #define DISK_BINNING          3
  818.  
  819. //
  820. // Bin types
  821. //
  822.  
  823. typedef enum _BIN_TYPES {
  824.     RequestSize,
  825.     RequestLocation
  826. } BIN_TYPES;
  827.  
  828. //
  829. // Bin ranges
  830. //
  831.  
  832. typedef struct _BIN_RANGE {
  833.     LARGE_INTEGER StartValue;
  834.     LARGE_INTEGER Length;
  835. } BIN_RANGE, *PBIN_RANGE;
  836.  
  837. //
  838. // Bin definition
  839. //
  840.  
  841. typedef struct _PERF_BIN {
  842.     DWORD NumberOfBins;
  843.     DWORD TypeOfBin;
  844.     BIN_RANGE BinsRanges[1];
  845. } PERF_BIN, *PPERF_BIN ;
  846.  
  847. //
  848. // Bin count
  849. //
  850.  
  851. typedef struct _BIN_COUNT {
  852.     BIN_RANGE BinRange;
  853.     DWORD BinCount;
  854. } BIN_COUNT, *PBIN_COUNT;
  855.  
  856. //
  857. // Bin results
  858. //
  859.  
  860. typedef struct _BIN_RESULTS {
  861.     DWORD NumberOfBins;
  862.     BIN_COUNT BinCounts[1];
  863. } BIN_RESULTS, *PBIN_RESULTS;
  864.  
  865. #if(_WIN32_WINNT >= 0x0400)
  866. //
  867. // Data structures for SMART drive fault prediction.
  868. //
  869. // GETVERSIONINPARAMS contains the data returned from the
  870. // Get Driver Version function.
  871. //
  872.  
  873. #pragma pack(1)
  874. typedef struct _GETVERSIONINPARAMS {
  875.         BYTE     bVersion;               // Binary driver version.
  876.         BYTE     bRevision;              // Binary driver revision.
  877.         BYTE     bReserved;              // Not used.
  878.         BYTE     bIDEDeviceMap;          // Bit map of IDE devices.
  879.         DWORD   fCapabilities;          // Bit mask of driver capabilities.
  880.         DWORD   dwReserved[4];          // For future use.
  881. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  882. #pragma pack()
  883.  
  884. //
  885. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  886. //
  887.  
  888. #define CAP_ATA_ID_CMD          1       // ATA ID command supported
  889. #define CAP_ATAPI_ID_CMD        2       // ATAPI ID command supported
  890. #define CAP_SMART_CMD           4       // SMART commannds supported
  891.  
  892. //
  893. // IDE registers
  894. //
  895.  
  896. #pragma pack(1)
  897. typedef struct _IDEREGS {
  898.         BYTE     bFeaturesReg;           // Used for specifying SMART "commands".
  899.         BYTE     bSectorCountReg;        // IDE sector count register
  900.         BYTE     bSectorNumberReg;       // IDE sector number register
  901.         BYTE     bCylLowReg;             // IDE low order cylinder value
  902.         BYTE     bCylHighReg;            // IDE high order cylinder value
  903.         BYTE     bDriveHeadReg;          // IDE drive/head register
  904.         BYTE     bCommandReg;            // Actual IDE command.
  905.         BYTE     bReserved;                      // reserved for future use.  Must be zero.
  906. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  907. #pragma pack()
  908.  
  909. //
  910. // Valid values for the bCommandReg member of IDEREGS.
  911. //
  912.  
  913. #define ATAPI_ID_CMD    0xA1            // Returns ID sector for ATAPI.
  914. #define ID_CMD          0xEC            // Returns ID sector for ATA.
  915. #define SMART_CMD       0xB0            // Performs SMART cmd.
  916.                                         // Requires valid bFeaturesReg,
  917.                                         // bCylLowReg, and bCylHighReg
  918.  
  919. //
  920. // Cylinder register defines for SMART command
  921. //
  922.  
  923. #define SMART_CYL_LOW   0x4F
  924. #define SMART_CYL_HI    0xC2
  925.  
  926.  
  927. //
  928. // SENDCMDINPARAMS contains the input parameters for the
  929. // Send Command to Drive function.
  930. //
  931.  
  932. #pragma pack(1)
  933. typedef struct _SENDCMDINPARAMS {
  934.         DWORD   cBufferSize;            // Buffer size in bytes
  935.         IDEREGS irDriveRegs;            // Structure with drive register values.
  936.         BYTE     bDriveNumber;           // Physical drive number to send
  937.                                                                 // command to (0,1,2,3).
  938.         BYTE     bReserved[3];           // Reserved for future expansion.
  939.         DWORD   dwReserved[4];          // For future use.
  940.         BYTE     bBuffer[1];                     // Input buffer.
  941. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  942. #pragma pack()
  943.  
  944. //
  945. // Status returned from driver
  946. //
  947.  
  948. #pragma pack(1)
  949. typedef struct _DRIVERSTATUS {
  950.         BYTE     bDriverError;           // Error code from driver,
  951.                                                                 // or 0 if no error.
  952.         BYTE     bIDEError;                      // Contents of IDE Error register.
  953.                                                                 // Only valid when bDriverError
  954.                                                                 // is SMART_IDE_ERROR.
  955.         BYTE     bReserved[2];           // Reserved for future expansion.
  956.         DWORD   dwReserved[2];          // Reserved for future expansion.
  957. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  958. #pragma pack()
  959.  
  960. //
  961. // bDriverError values
  962. //
  963.  
  964. #define SMART_NO_ERROR          0       // No error
  965. #define SMART_IDE_ERROR         1       // Error from IDE controller
  966. #define SMART_INVALID_FLAG      2       // Invalid command flag
  967. #define SMART_INVALID_COMMAND   3       // Invalid command byte
  968. #define SMART_INVALID_BUFFER    4       // Bad buffer (null, invalid addr..)
  969. #define SMART_INVALID_DRIVE     5       // Drive number not valid
  970. #define SMART_INVALID_IOCTL     6       // Invalid IOCTL
  971. #define SMART_ERROR_NO_MEM      7       // Could not lock user's buffer
  972. #define SMART_INVALID_REGISTER  8       // Some IDE Register not valid
  973. #define SMART_NOT_SUPPORTED     9       // Invalid cmd flag set
  974. #define SMART_NO_IDE_DEVICE     10      // Cmd issued to device not present
  975.                                         // although drive number is valid
  976.  
  977. #pragma pack(1)
  978. typedef struct _SENDCMDOUTPARAMS {
  979.         DWORD                   cBufferSize;            // Size of bBuffer in bytes
  980.         DRIVERSTATUS            DriverStatus;           // Driver status structure.
  981.         BYTE                    bBuffer[1];             // Buffer of arbitrary length in which to store the data read from the                                                                                  // drive.
  982. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  983. #pragma pack()
  984.  
  985.  
  986. #define READ_ATTRIBUTE_BUFFER_SIZE  512
  987. #define IDENTIFY_BUFFER_SIZE        512
  988. #define READ_THRESHOLD_BUFFER_SIZE  512
  989.  
  990. //
  991. // Feature register defines for SMART "sub commands"
  992. //
  993.  
  994. #define READ_ATTRIBUTES         0xD0
  995. #define READ_THRESHOLDS         0xD1
  996. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  997. #define SAVE_ATTRIBUTE_VALUES   0xD3
  998. #define EXECUTE_OFFLINE_DIAGS   0xD4
  999. #define ENABLE_SMART            0xD8
  1000. #define DISABLE_SMART           0xD9
  1001. #define RETURN_SMART_STATUS     0xDA
  1002. #endif /* _WIN32_WINNT >= 0x0400 */
  1003.  
  1004.  
  1005.  
  1006. #define IOCTL_CHANGER_BASE                FILE_DEVICE_CHANGER
  1007.  
  1008. #define IOCTL_CHANGER_GET_PARAMETERS         CTL_CODE(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
  1009. #define IOCTL_CHANGER_GET_STATUS             CTL_CODE(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  1010. #define IOCTL_CHANGER_GET_PRODUCT_DATA       CTL_CODE(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
  1011. #define IOCTL_CHANGER_SET_ACCESS             CTL_CODE(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1012. #define IOCTL_CHANGER_GET_ELEMENT_STATUS     CTL_CODE(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1013. #define IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS  CTL_CODE(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
  1014. #define IOCTL_CHANGER_SET_POSITION           CTL_CODE(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
  1015. #define IOCTL_CHANGER_EXCHANGE_MEDIUM        CTL_CODE(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
  1016. #define IOCTL_CHANGER_MOVE_MEDIUM            CTL_CODE(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS)
  1017. #define IOCTL_CHANGER_REINITIALIZE_TRANSPORT CTL_CODE(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
  1018. #define IOCTL_CHANGER_QUERY_VOLUME_TAGS      CTL_CODE(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1019.  
  1020. //
  1021. // TBD - IOCTL_CHANGER_GET_ENVIRONMENTAL_DATA
  1022. // TBD - IOCTL_CHANGER_GET_STATISTICS
  1023. // TBD - IOCTL_CHANGER_WRITE_FIRMWARE
  1024. //
  1025.  
  1026.  
  1027.  
  1028. #define MAX_VOLUME_ID_SIZE       36
  1029. #define MAX_VOLUME_TEMPLATE_SIZE 40
  1030.  
  1031. #define VENDOR_ID_LENGTH          8
  1032. #define PRODUCT_ID_LENGTH        16
  1033. #define REVISION_LENGTH           4
  1034. #define SERIAL_NUMBER_LENGTH     32
  1035.  
  1036. //
  1037. // Common structures describing elements.
  1038. //
  1039.  
  1040. typedef  enum _ELEMENT_TYPE {
  1041.     AllElements,        // As defined by SCSI
  1042.     ChangerTransport,   // As defined by SCSI
  1043.     ChangerSlot,        // As defined by SCSI
  1044.     ChangerIEPort,      // As defined by SCSI
  1045.     ChangerDrive,       // As defined by SCSI
  1046.     ChangerDoor,        // Front panel, used to access internal of cabinet.
  1047.     ChangerKeypad,      // Keypad/input on front panel.
  1048.     ChangerMaxElement   // Placeholder only. Not a valid type.
  1049. } ELEMENT_TYPE, *PELEMENT_TYPE;
  1050.  
  1051. typedef  struct _CHANGER_ELEMENT {
  1052.     ELEMENT_TYPE    ElementType;
  1053.     DWORD   ElementAddress;
  1054. } CHANGER_ELEMENT, *PCHANGER_ELEMENT;
  1055.  
  1056. typedef  struct _CHANGER_ELEMENT_LIST {
  1057.     CHANGER_ELEMENT Element;
  1058.     DWORD   NumberOfElements;
  1059. } CHANGER_ELEMENT_LIST , *PCHANGER_ELEMENT_LIST;
  1060.  
  1061.  
  1062. //
  1063. // Definitions for  IOCTL_CHANGER_GET_PARAMETERS
  1064. //
  1065.  
  1066. //
  1067. // Definitions for Features0 of GET_CHANGER_PARAMETERS
  1068. //
  1069.  
  1070. #define CHANGER_BAR_CODE_SCANNER_INSTALLED  0x00000001 // The medium-changer has a bar code scanner installed.
  1071. #define CHANGER_INIT_ELEM_STAT_WITH_RANGE   0x00000002 // The medium-changer has the ability to initialize elements within a specified range.
  1072. #define CHANGER_CLOSE_IEPORT                0x00000004 // The medium-changer has the ability to close the i/e port door.
  1073. #define CHANGER_OPEN_IEPORT                 0x00000008 // The medium-changer can open the i/e port door.
  1074.  
  1075. #define CHANGER_STATUS_NON_VOLATILE         0x00000010 // The medium-changer uses non-volatile memory for element status information.
  1076. #define CHANGER_EXCHANGE_MEDIA              0x00000020 // The medium-changer supports exchange operations.
  1077. #define CHANGER_CLEANER_SLOT                0x00000040 // The medium-changer has a fixed slot designated for cleaner cartridges.
  1078. #define CHANGER_LOCK_UNLOCK                 0x00000080 // The medium-changer can be (un)secured to (allow)prevent media removal.
  1079.  
  1080. #define CHANGER_CARTRIDGE_MAGAZINE          0x00000100 // The medium-changer uses cartridge magazines for some storage slots.
  1081. #define CHANGER_MEDIUM_FLIP                 0x00000200 // The medium-changer can flip medium.
  1082. #define CHANGER_POSITION_TO_ELEMENT         0x00000400 // The medium-changer can position the transport to a particular element.
  1083. #define CHANGER_REPORT_IEPORT_STATE         0x00000800 // The medium-changer can determine whether media is present
  1084.                                                        // in the IE Port.
  1085.  
  1086. #define CHANGER_STORAGE_DRIVE               0x00001000 // The medium-changer can use a drive as an independent storage element.
  1087. #define CHANGER_STORAGE_IEPORT              0x00002000 // The medium-changer can use a i/e port as an independent storage element.
  1088. #define CHANGER_STORAGE_SLOT                0x00004000 // The medium-changer can use a slot as an independent storage element.
  1089. #define CHANGER_STORAGE_TRANSPORT           0x00008000 // The medium-changer can use a transport as an independent storage element.
  1090.  
  1091. #define CHANGER_DRIVE_CLEANING_REQUIRED     0x00010000 // The drives controlled by the medium changer require periodic cleaning
  1092.                                                        // initiated by an application.
  1093. #define CHANGER_PREDISMOUNT_EJECT_REQUIRED  0x00020000 // The medium-changer requires a drive eject command to be issued, before a changer
  1094.                                                        // move / exchange command can be issued to the drive.
  1095. #define CHANGER_CLEANER_EJECT_REQUIRED      0x00040000 // The medium-changer requires a drive eject command to be issued, before a changer
  1096.                                                        // move / exchange command can be issued to a cleaner cartridge.
  1097. #define CHANGER_PREMOUNT_EJECT_REQUIRED     0x00080000 // The medium-changer requires a drive eject command to be issued
  1098.                                                        // before a move / exchange command can be issued with the drive as src/dst.
  1099.  
  1100. #define CHANGER_VOLUME_IDENTIFICATION       0x00100000 // The medium-changer supports volume identification.
  1101. #define CHANGER_VOLUME_SEARCH               0x00200000 // The medium-changer can search for volume information.
  1102. #define CHANGER_VOLUME_ASSERT               0x00400000 // The medium-changer can verify volume information.
  1103. #define CHANGER_VOLUME_REPLACE              0x00800000 // The medium-changer can replace volume information.
  1104. #define CHANGER_VOLUME_UNDEFINE             0x01000000 // The medium-changer can undefine volume information.
  1105.  
  1106. #define CHANGER_SERIAL_NUMBER_VALID         0x04000000 // The serial number reported in GetProductData is valid
  1107.                                                        // and unique.
  1108.  
  1109. #define CHANGER_DEVICE_REINITIALIZE_CAPABLE 0x08000000 // The medium-changer must be issued a ChangerReinitializeUnit for operations.
  1110. #define CHANGER_KEYPAD_ENABLE_DISABLE       0x10000000 // Indicates that the keypad can be enabled/disabled.
  1111. #define CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS  0x20000000 // Drives must be empty before access via the door is possible.
  1112. #define CHANGER_PREDISMOUNT_ALIGN_DRIVE_TO_SLOT 0x40000000 // The drive and slot must be prepositioned prior to ejecting the media and preforming
  1113.                                                            // the move medium.
  1114. #define CHANGER_CLEANER_AUTODISMOUNT        0x80000000 // The device will move the cleaner cartridge back into the slot when cleaning has completed.
  1115.  
  1116. //
  1117. // Definitions for MoveFrom and ExchangeFrom
  1118. //
  1119.  
  1120. #define CHANGER_TO_TRANSPORT    0x01 // The device can carry out the operation to a transport from the specified element.
  1121. #define CHANGER_TO_SLOT         0x02 // The device can carry out the operation to a slot from the specified element.
  1122. #define CHANGER_TO_IEPORT       0x04 // The device can carry out the operation to an IE Port from the specified element.
  1123. #define CHANGER_TO_DRIVE        0x08 // The device can carry out the operation to a drive from the specified element.
  1124.  
  1125.  
  1126. typedef  struct _GET_CHANGER_PARAMETERS {
  1127.  
  1128.     //
  1129.     // Size of the structure. Can be used for versioning.
  1130.     //
  1131.  
  1132.     DWORD Size;
  1133.  
  1134.     //
  1135.     // Number of N element(s) as defined by the Element Address Page (or equivalent...).
  1136.     //
  1137.  
  1138.     WORD   NumberTransportElements;
  1139.     WORD   NumberStorageElements;                // for data cartridges only
  1140.     WORD   NumberCleanerSlots;                   // for cleaner cartridges
  1141.     WORD   NumberIEElements;
  1142.     WORD   NumberDataTransferElements;
  1143.  
  1144.     //
  1145.     // Number of doors/front panels (allows user entry into the cabinet).
  1146.     //
  1147.  
  1148.     WORD   NumberOfDoors;
  1149.  
  1150.     //
  1151.     // The device-specific address (from user manual of the device) of the first N element. Used
  1152.     // by the UI to relate the various elements to the user.
  1153.     //
  1154.  
  1155.     WORD   FirstSlotNumber;
  1156.     WORD   FirstDriveNumber;
  1157.     WORD   FirstTransportNumber;
  1158.     WORD   FirstIEPortNumber;
  1159.     WORD   FirstCleanerSlotAddress;
  1160.  
  1161.     //
  1162.     // Indicates the capacity of each magazine, if they exist.
  1163.     //
  1164.  
  1165.     WORD   MagazineSize;
  1166.  
  1167.     //
  1168.     // Specifies the approximate number of seconds for when a cleaning should be completed.
  1169.     // Only applicable if drive cleaning is supported. See Features0.
  1170.     //
  1171.  
  1172.     DWORD DriveCleanTimeout;
  1173.  
  1174.     //
  1175.     // See features bits, above.
  1176.     //
  1177.  
  1178.     DWORD Features0;
  1179.     DWORD Reserved;
  1180.  
  1181.     //
  1182.     // Bitmask defining Move from N element to element. Defined by Device Capabilities Page (or equivalent).
  1183.     // AND-masking with the TO_XXX values will indicate legal destinations.
  1184.     //
  1185.  
  1186.     BYTE  MoveFromTransport;
  1187.     BYTE  MoveFromSlot;
  1188.     BYTE  MoveFromIePort;
  1189.     BYTE  MoveFromDrive;
  1190.  
  1191.     //
  1192.     // Bitmask defining Exchange from N element to element. Defined by Device Capabilities Page (or equivalent).
  1193.     // AND-masking with the TO_XXX values will indicate legal destinations.
  1194.     //
  1195.  
  1196.     BYTE  ExchangeFromTransport;
  1197.     BYTE  ExchangeFromSlot;
  1198.     BYTE  ExchangeFromIePort;
  1199.     BYTE  ExchangeFromDrive;
  1200.  
  1201. } GET_CHANGER_PARAMETERS, * PGET_CHANGER_PARAMETERS;
  1202.  
  1203.  
  1204. //
  1205. // Definitions for IOCTL_CHANGER_GET_PRODUCT_DATA
  1206. //
  1207.  
  1208. typedef  struct _CHANGER_PRODUCT_DATA {
  1209.  
  1210.     //
  1211.     // Device manufacturer's name - based on inquiry data
  1212.     //
  1213.  
  1214.     BYTE  VendorId[VENDOR_ID_LENGTH];
  1215.  
  1216.     //
  1217.     // Product identification as defined by the vendor - based on Inquiry data
  1218.     //
  1219.  
  1220.     BYTE  ProductId[PRODUCT_ID_LENGTH];
  1221.  
  1222.     //
  1223.     // Product revision as defined by the vendor.
  1224.     //
  1225.  
  1226.     BYTE  Revision[REVISION_LENGTH];
  1227.  
  1228.     //
  1229.     // Vendor unique value used to globally identify this device. Can
  1230.     // be from Vital Product Data, for example.
  1231.     //
  1232.  
  1233.     BYTE  SerialNumber[SERIAL_NUMBER_LENGTH];
  1234.  
  1235.     //
  1236.     // Indicates device type of data transports, as defined by SCSI-2.
  1237.     //
  1238.  
  1239.     BYTE  DeviceType;
  1240.  
  1241. } CHANGER_PRODUCT_DATA, *PCHANGER_PRODUCT_DATA;
  1242.  
  1243.  
  1244. //
  1245. // Definitions for IOCTL_CHANGER_SET_ACCESS
  1246. //
  1247.  
  1248. #define LOCK_ELEMENT        0
  1249. #define UNLOCK_ELEMENT      1
  1250. #define EXTEND_IEPORT       2
  1251. #define RETRACT_IEPORT      3
  1252.  
  1253. typedef struct _CHANGER_SET_ACCESS {
  1254.  
  1255.     //
  1256.     // Element can be ChangerIEPort, ChangerDoor, ChangerKeypad
  1257.     //
  1258.  
  1259.     CHANGER_ELEMENT Element;
  1260.  
  1261.     //
  1262.     // See above for possible operations.
  1263.     //
  1264.  
  1265.     DWORD           Control;
  1266. } CHANGER_SET_ACCESS, *PCHANGER_SET_ACCESS;
  1267.  
  1268.  
  1269. //
  1270. // Definitions for IOCTL_CHANGER_GET_ELEMENT_STATUS
  1271. //
  1272.  
  1273. //
  1274. // Input buffer.
  1275. //
  1276.  
  1277. typedef struct _CHANGER_READ_ELEMENT_STATUS {
  1278.  
  1279.     //
  1280.     // List describing the elements and range on which to return information.
  1281.     //
  1282.  
  1283.     CHANGER_ELEMENT_LIST ElementList;
  1284.  
  1285.     //
  1286.     // Indicates whether volume tag information is to be returned.
  1287.     //
  1288.  
  1289.     BOOLEAN VolumeTagInfo;
  1290. } CHANGER_READ_ELEMENT_STATUS, *PCHANGER_READ_ELEMENT_STATUS;
  1291.  
  1292. //
  1293. // Output buffer.
  1294. //
  1295.  
  1296. typedef  struct _CHANGER_ELEMENT_STATUS {
  1297.  
  1298.     //
  1299.     // Element to which this structure refers.
  1300.     //
  1301.  
  1302.     CHANGER_ELEMENT Element;
  1303.  
  1304.     //
  1305.     // Address of the element from which the media was originally moved.
  1306.     // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
  1307.     // Needs to be converted to a zero-based offset from the device-unique value.
  1308.     //
  1309.  
  1310.     CHANGER_ELEMENT SrcElementAddress;
  1311.  
  1312.     //
  1313.     // See below.
  1314.     //
  1315.  
  1316.     DWORD Flags;
  1317.  
  1318.     //
  1319.     // See below for possible values.
  1320.     //
  1321.  
  1322.     DWORD ExceptionCode;
  1323.  
  1324.     //
  1325.     // Scsi Target Id of this element.
  1326.     // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
  1327.     //
  1328.  
  1329.     BYTE  TargetId;
  1330.  
  1331.     //
  1332.     // LogicalUnitNumber of this element.
  1333.     // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
  1334.     //
  1335.  
  1336.     BYTE  Lun;
  1337.     WORD   Reserved;
  1338.  
  1339.     //
  1340.     // Primary volume identification for the media.
  1341.     // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
  1342.     //
  1343.  
  1344.     BYTE  PrimaryVolumeID[MAX_VOLUME_ID_SIZE];
  1345.  
  1346.     //
  1347.     // Alternate volume identification for the media.
  1348.     // Valid for two-sided media only, and pertains to the id. of the inverted side.
  1349.     // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
  1350.     //
  1351.  
  1352.     BYTE  AlternateVolumeID[MAX_VOLUME_ID_SIZE];
  1353. } CHANGER_ELEMENT_STATUS, *PCHANGER_ELEMENT_STATUS;
  1354.  
  1355. //
  1356. // Possible flag values
  1357. //
  1358.  
  1359. #define ELEMENT_STATUS_FULL      0x00000001 // Element contains a unit of media.
  1360. #define ELEMENT_STATUS_IMPEXP    0x00000002 // Media in i/e port was placed there by an operator.
  1361. #define ELEMENT_STATUS_EXCEPT    0x00000004 // Element is in an abnormal state; check ExceptionCode field for more information.
  1362. #define ELEMENT_STATUS_ACCESS    0x00000008 // Access to the i/e port from the medium changer is allowed.
  1363. #define ELEMENT_STATUS_EXENAB    0x00000010 // Export of media is supported.
  1364. #define ELEMENT_STATUS_INENAB    0x00000020 // Import of media is supported.
  1365.  
  1366. #define ELEMENT_STATUS_LUN_VALID 0x00001000 // Lun information is valid.
  1367. #define ELEMENT_STATUS_ID_VALID  0x00002000 // SCSI Id information is valid.
  1368. #define ELEMENT_STATUS_NOT_BUS   0x00008000 // Lun and SCSI Id fields are not on same bus as medium changer.
  1369. #define ELEMENT_STATUS_INVERT    0x00400000 // Media in element was inverted (valid only if ELEMENT_STATUS_SVALID bit is set)
  1370. #define ELEMENT_STATUS_SVALID    0x00800000 // SourceElementAddress field and ELEMENT_STATUS_INVERT bit are valid.
  1371.  
  1372. #define ELEMENT_STATUS_PVOLTAG   0x10000000 // Primary volume information is valid.
  1373. #define ELEMENT_STATUS_AVOLTAG   0x20000000 // Alternate volume information is valid.
  1374.  
  1375. //
  1376. // ExceptionCode values.
  1377. //
  1378.  
  1379. #define ERROR_LABEL_UNREADABLE    0x00000001 // Bar code scanner could not read bar code label.
  1380. #define ERROR_LABEL_QUESTIONABLE  0x00000002 // Label could be invalid due to unit attention condition.
  1381. #define ERROR_SLOT_NOT_PRESENT    0x00000004 // Slot is currently not addressable in the device.
  1382. #define ERROR_DRIVE_NOT_INSTALLED 0x00000008 // Drive is not installed.
  1383. #define ERROR_TRAY_MALFUNCTION    0x00000010 // Media tray is malfunctioning/broken.
  1384. #define ERROR_INIT_STATUS_NEEDED  0x00000011 // An Initialize Element Status command is needed.
  1385. #define ERROR_UNHANDLED_ERROR     0xFFFFFFFF // Unknown error condition
  1386.  
  1387.  
  1388. //
  1389. // Definitions for IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS
  1390. //
  1391.  
  1392. typedef struct _CHANGER_INITIALIZE_ELEMENT_STATUS {
  1393.  
  1394.     //
  1395.     // List describing the elements and range on which to initialize.
  1396.     //
  1397.  
  1398.     CHANGER_ELEMENT_LIST ElementList;
  1399.  
  1400.     //
  1401.     // Indicates whether a bar code scan should be used. Only applicable if
  1402.     // CHANGER_BAR_CODE_SCANNER_INSTALLED is set in Features0 of CHANGER_GET_PARAMETERS.
  1403.     //
  1404.  
  1405.     BOOLEAN BarCodeScan;
  1406. } CHANGER_INITIALIZE_ELEMENT_STATUS, *PCHANGER_INITIALIZE_ELEMENT_STATUS;
  1407.  
  1408.  
  1409. //
  1410. // Definitions for IOCTL_CHANGER_SET_POSITION
  1411. //
  1412.  
  1413. typedef struct _CHANGER_SET_POSITION {
  1414.  
  1415.  
  1416.     //
  1417.     // Indicates which transport to move.
  1418.     //
  1419.  
  1420.     CHANGER_ELEMENT Transport;
  1421.  
  1422.     //
  1423.     // Indicates the final destination of the transport.
  1424.     //
  1425.  
  1426.     CHANGER_ELEMENT Destination;
  1427.  
  1428.     //
  1429.     // Indicates whether the media currently carried by Transport, should be flipped.
  1430.     //
  1431.  
  1432.     BOOLEAN         Flip;
  1433. }CHANGER_SET_POSITION, *PCHANGER_SET_POSITION;
  1434.  
  1435.  
  1436. //
  1437. // Definitions for IOCTL_CHANGER_EXCHANGE_MEDIUM
  1438. //
  1439.  
  1440. typedef struct _CHANGER_EXCHANGE_MEDIUM {
  1441.  
  1442.     //
  1443.     // Indicates which transport to use for the exchange operation.
  1444.     //
  1445.  
  1446.     CHANGER_ELEMENT Transport;
  1447.  
  1448.     //
  1449.     // Indicates the source for the media that is to be moved.
  1450.     //
  1451.  
  1452.     CHANGER_ELEMENT Source;
  1453.  
  1454.     //
  1455.     // Indicates the final destination of the media originally at Source.
  1456.     //
  1457.  
  1458.     CHANGER_ELEMENT Destination1;
  1459.  
  1460.     //
  1461.     // Indicates the destination of the media moved from Destination1.
  1462.     //
  1463.  
  1464.     CHANGER_ELEMENT Destination2;
  1465.  
  1466.     //
  1467.     // Indicates whether the medium should be flipped.
  1468.     //
  1469.  
  1470.     BOOLEAN         Flip1;
  1471.     BOOLEAN         Flip2;
  1472. }CHANGER_EXCHANGE_MEDIUM, *PCHANGER_EXCHANGE_MEDIUM;
  1473.  
  1474.  
  1475. //
  1476. // Definitions for IOCTL_CHANGER_MOVE_MEDIUM
  1477. //
  1478.  
  1479. typedef struct _CHANGER_MOVE_MEDIUM {
  1480.  
  1481.     //
  1482.     // Indicates which transport to use for the move operation.
  1483.     //
  1484.  
  1485.     CHANGER_ELEMENT Transport;
  1486.  
  1487.     //
  1488.     // Indicates the source for the media that is to be moved.
  1489.     //
  1490.  
  1491.     CHANGER_ELEMENT Source;
  1492.  
  1493.     //
  1494.     // Indicates the destination of the media originally at Source.
  1495.     //
  1496.  
  1497.     CHANGER_ELEMENT Destination;
  1498.  
  1499.     //
  1500.     // Indicates whether the media should be flipped.
  1501.     //
  1502.  
  1503.     BOOLEAN         Flip;
  1504. }CHANGER_MOVE_MEDIUM, *PCHANGER_MOVE_MEDIUM;
  1505.  
  1506.  
  1507.  
  1508. //
  1509. // Definitions for IOCTL_QUERY_VOLUME_TAGS
  1510. //
  1511.  
  1512. //
  1513. // Input buffer.
  1514. //
  1515.  
  1516. typedef  struct _CHANGER_SEND_VOLUME_TAG_INFORMATION {
  1517.  
  1518.     //
  1519.     // Describes the starting element for which to return information.
  1520.     //
  1521.  
  1522.     CHANGER_ELEMENT StartingElement;
  1523.  
  1524.     //
  1525.     // Indicates the specific action to perform. See below.
  1526.     //
  1527.  
  1528.     DWORD ActionCode;
  1529.  
  1530.     //
  1531.     // Template used by the device to search for volume ids.
  1532.     //
  1533.  
  1534.     BYTE  VolumeIDTemplate[MAX_VOLUME_TEMPLATE_SIZE];
  1535. } CHANGER_SEND_VOLUME_TAG_INFORMATION, *PCHANGER_SEND_VOLUME_TAG_INFORMATION;
  1536.  
  1537.  
  1538. //
  1539. // Output buffer.
  1540. //
  1541.  
  1542. typedef struct _READ_ELEMENT_ADDRESS_INFO {
  1543.  
  1544.     //
  1545.     // Number of elements matching criteria set forth by ActionCode.
  1546.     //
  1547.  
  1548.     DWORD NumberOfElements;
  1549.  
  1550.     //
  1551.     // Array of CHANGER_ELEMENT_STATUS structures, one for each element that corresponded
  1552.     // with the information passed in with the CHANGER_SEND_VOLUME_TAG_INFORMATION structure.
  1553.     //
  1554.  
  1555.     CHANGER_ELEMENT_STATUS ElementStatus[1];
  1556. } READ_ELEMENT_ADDRESS_INFO, *PREAD_ELEMENT_ADDRESS_INFO;
  1557.  
  1558. //
  1559. // Possible ActionCode values. See Features0 of CHANGER_GET_PARAMETERS for compatibility with
  1560. // the current device.
  1561. //
  1562.  
  1563. #define SEARCH_ALL         0x0 // Translate - search all defined volume tags.
  1564. #define SEARCH_PRIMARY     0x1 // Translate - search only primary volume tags.
  1565. #define SEARCH_ALTERNATE   0x2 // Translate - search only alternate volume tags.
  1566. #define SEARCH_ALL_NO_SEQ  0x4 // Translate - search all defined volume tags but ignore sequence numbers.
  1567. #define SEARCH_PRI_NO_SEQ  0x5 // Translate - search only primary volume tags but ignore sequence numbers.
  1568. #define SEARCH_ALT_NO_SEQ  0x6 // Translate - search only alternate volume tags but ignore sequence numbers.
  1569.  
  1570. #define ASSERT_PRIMARY     0x8 // Assert - as the primary volume tag - if tag now undefined.
  1571. #define ASSERT_ALTERNATE   0x9 // Assert - as the alternate volume tag - if tag now undefined.
  1572.  
  1573. #define REPLACE_PRIMARY    0xA // Replace - the primary volume tag - current tag ignored.
  1574. #define REPLACE_ALTERANTE  0xB // Replace - the alternate volume tag - current tag ignored.
  1575.  
  1576. #define UNDEFINE_PRIMARY   0xC // Undefine - the primary volume tag - current tag ignored.
  1577. #define UNDEFINE_ALTERNATE 0xD // Undefine - the alternate volume tag - current tag ignored.
  1578.  
  1579.  
  1580.  
  1581. #define IOCTL_SERIAL_LSRMST_INSERT      CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1582.  
  1583.  
  1584. //
  1585. // The following values follow the escape designator in the
  1586. // data stream if the LSRMST_INSERT mode has been turned on.
  1587. //
  1588. #define SERIAL_LSRMST_ESCAPE     ((BYTE )0x00)
  1589.  
  1590. //
  1591. // Following this value is the contents of the line status
  1592. // register, and then the character in the RX hardware when
  1593. // the line status register was encountered.
  1594. //
  1595. #define SERIAL_LSRMST_LSR_DATA   ((BYTE )0x01)
  1596.  
  1597. //
  1598. // Following this value is the contents of the line status
  1599. // register.  No error character follows
  1600. //
  1601. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  1602.  
  1603. //
  1604. // Following this value is the contents of the modem status
  1605. // register.
  1606. //
  1607. #define SERIAL_LSRMST_MST        ((BYTE )0x03)
  1608.  
  1609.  
  1610. #ifndef _FILESYSTEMFSCTL_
  1611. #define _FILESYSTEMFSCTL_
  1612.  
  1613. //
  1614. // The following is a list of the native file system fsctls followed by
  1615. // additional network file system fsctls.  Some values have been
  1616. // decommissioned.
  1617. //
  1618.  
  1619. #define FSCTL_REQUEST_OPLOCK_LEVEL_1    CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1620. #define FSCTL_REQUEST_OPLOCK_LEVEL_2    CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1621. #define FSCTL_REQUEST_BATCH_OPLOCK      CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1622. #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE  CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1623. #define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1624. #define FSCTL_OPLOCK_BREAK_NOTIFY       CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1625. #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1626. #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1627. #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1628. // decommissioned fsctl value                                              9
  1629. #define FSCTL_IS_VOLUME_MOUNTED         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1630. #define FSCTL_IS_PATHNAME_VALID         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) // PATHNAME_BUFFER,
  1631. #define FSCTL_MARK_VOLUME_DIRTY         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1632. // decommissioned fsctl value                                             13
  1633. #define FSCTL_QUERY_RETRIEVAL_POINTERS  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14,  METHOD_NEITHER, FILE_ANY_ACCESS)
  1634. #define FSCTL_GET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1635. #define FSCTL_SET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  1636. // decommissioned fsctl value                                             17
  1637. // decommissioned fsctl value                                             18
  1638. #define FSCTL_MARK_AS_SYSTEM_HIVE       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19,  METHOD_NEITHER, FILE_ANY_ACCESS)
  1639. #define FSCTL_OPLOCK_BREAK_ACK_NO_2     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1640. #define FSCTL_INVALIDATE_VOLUMES        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1641. #define FSCTL_QUERY_FAT_BPB             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) // , FSCTL_QUERY_FAT_BPB_BUFFER
  1642. #define FSCTL_REQUEST_FILTER_OPLOCK     CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1643. #define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS) // , FILESYSTEM_STATISTICS
  1644. #if(_WIN32_WINNT >= 0x0400)
  1645. #define FSCTL_GET_NTFS_VOLUME_DATA      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS) // , NTFS_VOLUME_DATA_BUFFER
  1646. #define FSCTL_GET_NTFS_FILE_RECORD      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS) // NTFS_FILE_RECORD_INPUT_BUFFER, NTFS_FILE_RECORD_OUTPUT_BUFFER
  1647. #define FSCTL_GET_VOLUME_BITMAP         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27,  METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_LCN_INPUT_BUFFER, VOLUME_BITMAP_BUFFER
  1648. #define FSCTL_GET_RETRIEVAL_POINTERS    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28,  METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER
  1649. #define FSCTL_MOVE_FILE                 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_ANY_ACCESS) // MOVE_FILE_DATA,
  1650. #define FSCTL_IS_VOLUME_DIRTY           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1651. #define FSCTL_GET_HFS_INFORMATION       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 31, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1652. #define FSCTL_ALLOW_EXTENDED_DASD_IO    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER,  FILE_ANY_ACCESS)
  1653. #endif /* _WIN32_WINNT >= 0x0400 */
  1654.  
  1655. #if(_WIN32_WINNT >= 0x0500)
  1656. #define FSCTL_READ_PROPERTY_DATA        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 33, METHOD_NEITHER, FILE_ANY_ACCESS)
  1657. #define FSCTL_WRITE_PROPERTY_DATA       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 34, METHOD_NEITHER, FILE_ANY_ACCESS)
  1658. #define FSCTL_FIND_FILES_BY_SID         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS)
  1659. // decommissioned fsctl value                                             36
  1660. #define FSCTL_DUMP_PROPERTY_DATA        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 37,  METHOD_NEITHER, FILE_ANY_ACCESS)
  1661. #define FSCTL_SET_OBJECT_ID             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_WRITE_DATA) // FILE_OBJECTID_BUFFER
  1662. #define FSCTL_GET_OBJECT_ID             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS) // , FILE_OBJECTID_BUFFER
  1663. #define FSCTL_DELETE_OBJECT_ID          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_WRITE_DATA)
  1664. #define FSCTL_SET_REPARSE_POINT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_WRITE_DATA) // REPARSE_DATA_BUFFER,
  1665. #define FSCTL_GET_REPARSE_POINT         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) // , REPARSE_DATA_BUFFER
  1666. #define FSCTL_DELETE_REPARSE_POINT      CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_WRITE_DATA) // REPARSE_DATA_BUFFER,
  1667. #define FSCTL_ENUM_USN_DATA             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44,  METHOD_NEITHER, FILE_READ_DATA)  // MFT_ENUM_DATA,
  1668. #define FSCTL_SECURITY_ID_CHECK         CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45,  METHOD_NEITHER, FILE_READ_DATA)  // BULK_SECURITY_TEST_DATA,
  1669. #define FSCTL_READ_USN_JOURNAL          CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46,  METHOD_NEITHER, FILE_READ_DATA)  // READ_USN_JOURNAL_DATA, USN
  1670. #define FSCTL_SET_OBJECT_ID_EXTENDED    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_WRITE_DATA)
  1671. #define FSCTL_CREATE_OR_GET_OBJECT_ID   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS) // , FILE_OBJECTID_BUFFER
  1672. #define FSCTL_SET_SPARSE                CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_WRITE_DATA)
  1673. #define FSCTL_SET_ZERO_DATA             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) // FILE_ZERO_DATA_INFORMATION,
  1674. #define FSCTL_QUERY_ALLOCATED_RANGES    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51,  METHOD_NEITHER, FILE_READ_DATA)  // FILE_ALLOCATED_RANGE_BUFFER, FILE_ALLOCATED_RANGE_BUFFER
  1675. #define FSCTL_ENABLE_UPGRADE            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_DATA)
  1676. #define FSCTL_SET_ENCRYPTION            CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_BUFFERED, FILE_ANY_ACCESS) // ENCRYPTION_BUFFER,
  1677. #define FSCTL_ENCRYPTION_FSCTL_IO       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54,  METHOD_NEITHER, FILE_ANY_ACCESS)
  1678. #define FSCTL_WRITE_RAW_ENCRYPTED       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55,  METHOD_NEITHER, FILE_ANY_ACCESS) // ENCRYPTED_DATA_INFO,
  1679. #define FSCTL_READ_RAW_ENCRYPTED        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56,  METHOD_NEITHER, FILE_ANY_ACCESS) // REQUEST_RAW_ENCRYPTED_DATA, ENCRYPTED_DATA_INFO
  1680. #define FSCTL_CREATE_USN_JOURNAL        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57,  METHOD_NEITHER, FILE_READ_DATA)  // CREATE_USN_JOUNRAL_DATA,
  1681. #define FSCTL_READ_FILE_USN_DATA        CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58,  METHOD_NEITHER, FILE_READ_DATA)  // Read the Usn Record for a file
  1682. #define FSCTL_WRITE_USN_CLOSE_RECORD    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59,  METHOD_NEITHER, FILE_READ_DATA)  // Generate Close Usn Record
  1683. #define FSCTL_EXTEND_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1684. #endif /* _WIN32_WINNT >= 0x0500 */
  1685.  
  1686. //
  1687. // The following long list of structs are associated with the preceeding
  1688. // file system fsctls.
  1689. //
  1690. // Note that the structs for the property sets fsctls are not included
  1691. // in this file.  They can be found in ntfsprop.h where they should stay
  1692. // because of their dependency on objidl.h.
  1693. //
  1694.  
  1695. //
  1696. // Structure for FSCTL_IS_PATHNAME_VALID
  1697. //
  1698.  
  1699. typedef struct _PATHNAME_BUFFER {
  1700.  
  1701.     DWORD PathNameLength;
  1702.     WCHAR Name[1];
  1703.  
  1704. } PATHNAME_BUFFER, *PPATHNAME_BUFFER;
  1705.  
  1706. //
  1707. // Structure for FSCTL_QUERY_BPB_INFO
  1708. //
  1709.  
  1710. typedef struct _FSCTL_QUERY_FAT_BPB_BUFFER {
  1711.  
  1712.     BYTE  First0x24BytesOfBootSector[0x24];
  1713.  
  1714. } FSCTL_QUERY_FAT_BPB_BUFFER, *PFSCTL_QUERY_FAT_BPB_BUFFER;
  1715.  
  1716. #if(_WIN32_WINNT >= 0x0400)
  1717. //
  1718. // Structure for FSCTL_GET_NTFS_VOLUME_DATA
  1719. //
  1720.  
  1721. typedef struct {
  1722.  
  1723.     LARGE_INTEGER VolumeSerialNumber;
  1724.     LARGE_INTEGER NumberSectors;
  1725.     LARGE_INTEGER TotalClusters;
  1726.     LARGE_INTEGER FreeClusters;
  1727.     LARGE_INTEGER TotalReserved;
  1728.     DWORD BytesPerSector;
  1729.     DWORD BytesPerCluster;
  1730.     DWORD BytesPerFileRecordSegment;
  1731.     DWORD ClustersPerFileRecordSegment;
  1732.     LARGE_INTEGER MftValidDataLength;
  1733.     LARGE_INTEGER MftStartLcn;
  1734.     LARGE_INTEGER Mft2StartLcn;
  1735.     LARGE_INTEGER MftZoneStart;
  1736.     LARGE_INTEGER MftZoneEnd;
  1737.  
  1738. } NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;
  1739. #endif /* _WIN32_WINNT >= 0x0400 */
  1740.  
  1741. #if(_WIN32_WINNT >= 0x0400)
  1742. //
  1743. // Structure for FSCTL_GET_VOLUME_BITMAP
  1744. //
  1745.  
  1746. typedef struct {
  1747.  
  1748.     LARGE_INTEGER StartingLcn;
  1749.  
  1750. } STARTING_LCN_INPUT_BUFFER, *PSTARTING_LCN_INPUT_BUFFER;
  1751.  
  1752. typedef struct {
  1753.  
  1754.     LARGE_INTEGER StartingLcn;
  1755.     LARGE_INTEGER BitmapSize;
  1756.     BYTE  Buffer[1];
  1757.  
  1758. } VOLUME_BITMAP_BUFFER, *PVOLUME_BITMAP_BUFFER;
  1759. #endif /* _WIN32_WINNT >= 0x0400 */
  1760.  
  1761. #if(_WIN32_WINNT >= 0x0400)
  1762. //
  1763. // Structure for FSCTL_GET_RETRIEVAL_POINTERS
  1764. //
  1765.  
  1766. typedef struct {
  1767.  
  1768.     LARGE_INTEGER StartingVcn;
  1769.  
  1770. } STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER;
  1771.  
  1772. typedef struct RETRIEVAL_POINTERS_BUFFER {
  1773.  
  1774.     DWORD ExtentCount;
  1775.     LARGE_INTEGER StartingVcn;
  1776.     struct {
  1777.         LARGE_INTEGER NextVcn;
  1778.         LARGE_INTEGER Lcn;
  1779.     } Extents[1];
  1780.  
  1781. } RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER;
  1782. #endif /* _WIN32_WINNT >= 0x0400 */
  1783.  
  1784. #if(_WIN32_WINNT >= 0x0400)
  1785. //
  1786. // Structures for FSCTL_GET_NTFS_FILE_RECORD
  1787. //
  1788.  
  1789. typedef struct {
  1790.  
  1791.     LARGE_INTEGER FileReferenceNumber;
  1792.  
  1793. } NTFS_FILE_RECORD_INPUT_BUFFER, *PNTFS_FILE_RECORD_INPUT_BUFFER;
  1794.  
  1795. typedef struct {
  1796.  
  1797.     LARGE_INTEGER FileReferenceNumber;
  1798.     DWORD FileRecordLength;
  1799.     BYTE  FileRecordBuffer[1];
  1800.  
  1801. } NTFS_FILE_RECORD_OUTPUT_BUFFER, *PNTFS_FILE_RECORD_OUTPUT_BUFFER;
  1802. #endif /* _WIN32_WINNT >= 0x0400 */
  1803.  
  1804. #if(_WIN32_WINNT >= 0x0400)
  1805. //
  1806. // Structure for FSCTL_MOVE_FILE
  1807. //
  1808.  
  1809. typedef struct {
  1810.  
  1811.     HANDLE FileHandle;
  1812.     LARGE_INTEGER StartingVcn;
  1813.     LARGE_INTEGER StartingLcn;
  1814.     DWORD ClusterCount;
  1815.  
  1816. } MOVE_FILE_DATA, *PMOVE_FILE_DATA;
  1817. #endif /* _WIN32_WINNT >= 0x0400 */
  1818.  
  1819. #if(_WIN32_WINNT >= 0x0400)
  1820. //
  1821. // Structure for FSCTL_GET_HFS_INFORMATION
  1822. //
  1823.  
  1824. typedef struct {
  1825.  
  1826.     BYTE  FinderInfo[32];
  1827.  
  1828. } HFS_INFORMATION_BUFFER, *PHFS_INFORMATION_BUFFER;
  1829. #endif /* _WIN32_WINNT >= 0x0400 */
  1830.  
  1831. #if(_WIN32_WINNT >= 0x0500)
  1832. //
  1833. // Structure for FSCTL_ENUM_USN_DATA
  1834. //
  1835.  
  1836. typedef struct {
  1837.  
  1838.     DWORDLONG StartFileReferenceNumber;
  1839.     USN LowUsn;
  1840.     USN HighUsn;
  1841.  
  1842. } MFT_ENUM_DATA, *PMFT_ENUM_DATA;
  1843. #endif /* _WIN32_WINNT >= 0x0500 */
  1844.  
  1845. #if(_WIN32_WINNT >= 0x0500)
  1846. //
  1847. // Structure for FSCTL_FIND_FILES_BY_SID
  1848. //
  1849.  
  1850. typedef struct {
  1851.     DWORD Restart;
  1852.     SID Sid;
  1853. } FIND_BY_SID_DATA, *PFIND_BY_SID_DATA;
  1854. #endif /* _WIN32_WINNT >= 0x0500 */
  1855.  
  1856. #if(_WIN32_WINNT >= 0x0500)
  1857. //
  1858. // Structure for FSCTL_CREATE_USN_JOURNAL
  1859. //
  1860.  
  1861. typedef struct {
  1862.  
  1863.     DWORDLONG MaximumSize;
  1864.     DWORDLONG AllocationDelta;
  1865.  
  1866. } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA;
  1867. #endif /* _WIN32_WINNT >= 0x0500 */
  1868.  
  1869. #if(_WIN32_WINNT >= 0x0500)
  1870. //
  1871. // Sturcture for FSCTL_READ_USN_JOURNAL
  1872. //
  1873. typedef struct {
  1874.  
  1875.     USN StartUsn;
  1876.     DWORD ReasonMask;
  1877.     DWORD ReturnOnlyOnClose;
  1878.     DWORDLONG Timeout;
  1879.     DWORDLONG BytesToWaitFor;
  1880.  
  1881. } READ_USN_JOURNAL_DATA, *PREAD_USN_JOURNAL_DATA;
  1882. #endif /* _WIN32_WINNT >= 0x0500 */
  1883.  
  1884. #if(_WIN32_WINNT >= 0x0500)
  1885. //
  1886. //  The initial Major.Minor version of the Usn record will be 1.0.
  1887. //  In general, the MinorVersion may be changed if fields are added
  1888. //  to this structure in such a way that the previous version of the
  1889. //  software can still correctly the fields it knows about.  The
  1890. //  MajorVersion should only be changed if the previous version of
  1891. //  any software using this structure would incorrectly handle new
  1892. //  records due to structure changes.
  1893. //
  1894.  
  1895. typedef struct {
  1896.  
  1897.     DWORD RecordLength;
  1898.     WORD   MajorVersion;
  1899.     WORD   MinorVersion;
  1900.     DWORDLONG FileReferenceNumber;
  1901.     DWORDLONG ParentFileReferenceNumber;
  1902.     USN Usn;
  1903.     LARGE_INTEGER TimeStamp;
  1904.     DWORD Reason;
  1905.     DWORD SecurityId;
  1906.     DWORD FileAttributes;
  1907.     WORD   FileNameLength;
  1908.     WCHAR FileName[1];
  1909.  
  1910. } USN_RECORD, *PUSN_RECORD;
  1911.  
  1912. #define USN_PAGE_SIZE                    (0x1000)
  1913.  
  1914. #define USN_REASON_DATA_OVERWRITE        (0x00000001)
  1915. #define USN_REASON_DATA_EXTEND           (0x00000002)
  1916. #define USN_REASON_DATA_TRUNCATION       (0x00000004)
  1917. #define USN_REASON_NAMED_DATA_OVERWRITE  (0x00000010)
  1918. #define USN_REASON_NAMED_DATA_EXTEND     (0x00000020)
  1919. #define USN_REASON_NAMED_DATA_TRUNCATION (0x00000040)
  1920. #define USN_REASON_FILE_CREATE           (0x00000100)
  1921. #define USN_REASON_FILE_DELETE           (0x00000200)
  1922. #define USN_REASON_PROPERTY_CHANGE       (0x00000400)
  1923. #define USN_REASON_SECURITY_CHANGE       (0x00000800)
  1924. #define USN_REASON_RENAME_OLD_NAME       (0x00001000)
  1925. #define USN_REASON_RENAME_NEW_NAME       (0x00002000)
  1926. #define USN_REASON_INDEXABLE_CHANGE      (0x00004000)
  1927. #define USN_REASON_BASIC_INFO_CHANGE     (0x00008000)
  1928. #define USN_REASON_HARD_LINK_CHANGE      (0x00010000)
  1929. #define USN_REASON_COMPRESSION_CHANGE    (0x00020000)
  1930. #define USN_REASON_ENCRYPTION_CHANGE     (0x00040000)
  1931. #define USN_REASON_OBJECT_ID_CHANGE      (0x00080000)
  1932. #define USN_REASON_REPARSE_POINT_CHANGE  (0x00100000)
  1933. #define USN_REASON_MOUNT_TABLE_CHANGE    (0x00200000)
  1934.  
  1935. #define USN_REASON_CLOSE                 (0x80000000)
  1936. #endif /* _WIN32_WINNT >= 0x0500 */
  1937.  
  1938. #if(_WIN32_WINNT >= 0x0500)
  1939. //
  1940. // Structure for FSCTL_SECURITY_ID_CHECK
  1941. //
  1942.  
  1943. typedef struct {
  1944.  
  1945.     ACCESS_MASK DesiredAccess;
  1946.     DWORD SecurityIds[1];
  1947.  
  1948. } BULK_SECURITY_TEST_DATA, *PBULK_SECURITY_TEST_DATA;
  1949. #endif /* _WIN32_WINNT >= 0x0500 */
  1950.  
  1951. #if(_WIN32_WINNT >= 0x0500)
  1952. //
  1953. //  Output flags for the FSCTL_IS_VOLUME_DIRTY
  1954. //
  1955.  
  1956. #define VOLUME_IS_DIRTY                  (0x00000001)
  1957. #define VOLUME_UPGRADE_SCHEDULED         (0x00000002)
  1958. #endif /* _WIN32_WINNT >= 0x0500 */
  1959.  
  1960. //
  1961. // Structures for FSCTL_FILESYSTEM_GET_STATISTICS
  1962. //
  1963.  
  1964. //
  1965. // Filesystem performance counters
  1966. //
  1967.  
  1968. typedef struct _NTFS_STATISTICS {
  1969.  
  1970.     DWORD LogFileFullExceptions;
  1971.     DWORD OtherExceptions;
  1972.  
  1973.     //
  1974.     // Other meta data io's
  1975.     //
  1976.  
  1977.     DWORD MftReads;
  1978.     DWORD MftReadBytes;
  1979.     DWORD MftWrites;
  1980.     DWORD MftWriteBytes;
  1981.     struct {
  1982.         WORD   Write;
  1983.         WORD   Create;
  1984.         WORD   SetInfo;
  1985.         WORD   Flush;
  1986.     } MftWritesUserLevel;
  1987.  
  1988.     WORD   MftWritesFlushForLogFileFull;
  1989.     WORD   MftWritesLazyWriter;
  1990.     WORD   MftWritesUserRequest;
  1991.  
  1992.     DWORD Mft2Writes;
  1993.     DWORD Mft2WriteBytes;
  1994.     struct {
  1995.         WORD   Write;
  1996.         WORD   Create;
  1997.         WORD   SetInfo;
  1998.         WORD   Flush;
  1999.     } Mft2WritesUserLevel;
  2000.  
  2001.     WORD   Mft2WritesFlushForLogFileFull;
  2002.     WORD   Mft2WritesLazyWriter;
  2003.     WORD   Mft2WritesUserRequest;
  2004.  
  2005.     DWORD RootIndexReads;
  2006.     DWORD RootIndexReadBytes;
  2007.     DWORD RootIndexWrites;
  2008.     DWORD RootIndexWriteBytes;
  2009.  
  2010.     DWORD BitmapReads;
  2011.     DWORD BitmapReadBytes;
  2012.     DWORD BitmapWrites;
  2013.     DWORD BitmapWriteBytes;
  2014.  
  2015.     WORD   BitmapWritesFlushForLogFileFull;
  2016.     WORD   BitmapWritesLazyWriter;
  2017.     WORD   BitmapWritesUserRequest;
  2018.  
  2019.     struct {
  2020.         WORD   Write;
  2021.         WORD   Create;
  2022.         WORD   SetInfo;
  2023.     } BitmapWritesUserLevel;
  2024.  
  2025.     DWORD MftBitmapReads;
  2026.     DWORD MftBitmapReadBytes;
  2027.     DWORD MftBitmapWrites;
  2028.     DWORD MftBitmapWriteBytes;
  2029.  
  2030.     WORD   MftBitmapWritesFlushForLogFileFull;
  2031.     WORD   MftBitmapWritesLazyWriter;
  2032.     WORD   MftBitmapWritesUserRequest;
  2033.  
  2034.     struct {
  2035.         WORD   Write;
  2036.         WORD   Create;
  2037.         WORD   SetInfo;
  2038.         WORD   Flush;
  2039.     } MftBitmapWritesUserLevel;
  2040.  
  2041.     DWORD UserIndexReads;
  2042.     DWORD UserIndexReadBytes;
  2043.     DWORD UserIndexWrites;
  2044.     DWORD UserIndexWriteBytes;
  2045.  
  2046.     //
  2047.     // Additions for NT 5.0
  2048.     //
  2049.  
  2050.     DWORD LogFileReads;
  2051.     DWORD LogFileReadBytes;
  2052.     DWORD LogFileWrites;
  2053.     DWORD LogFileWriteBytes;
  2054.  
  2055.     struct {
  2056.         DWORD Calls;                // number of individual calls to allocate clusters
  2057.         DWORD Clusters;             // number of clusters allocated
  2058.         DWORD Hints;                // number of times a hint was specified
  2059.  
  2060.         DWORD RunsReturned;         // number of runs used to satisify all the requests
  2061.  
  2062.         DWORD HintsHonored;         // number of times the hint was useful
  2063.         DWORD HintsClusters;        // number of clusters allocated via the hint
  2064.         DWORD Cache;                // number of times the cache was useful other than the hint
  2065.         DWORD CacheClusters;        // number of clusters allocated via the cache other than the hint
  2066.         DWORD CacheMiss;            // number of times the cache wasn't useful
  2067.         DWORD CacheMissClusters;    // number of clusters allocated without the cache
  2068.     } Allocate;
  2069.  
  2070. } NTFS_STATISTICS, *PNTFS_STATISTICS;
  2071.  
  2072. typedef struct _FAT_STATISTICS {
  2073.     DWORD CreateHits;
  2074.     DWORD SuccessfulCreates;
  2075.     DWORD FailedCreates;
  2076.  
  2077.     DWORD NonCachedReads;
  2078.     DWORD NonCachedReadBytes;
  2079.     DWORD NonCachedWrites;
  2080.     DWORD NonCachedWriteBytes;
  2081.  
  2082.     DWORD NonCachedDiskReads;
  2083.     DWORD NonCachedDiskWrites;
  2084.  
  2085. } FAT_STATISTICS, *PFAT_STATISTICS;
  2086.  
  2087. typedef struct _FILESYSTEM_STATISTICS {
  2088.  
  2089.     union {
  2090.  
  2091.         struct {
  2092.  
  2093.             WORD   FileSystemType;
  2094.             WORD   Version;                     // currently version 1
  2095.  
  2096.             DWORD UserFileReads;
  2097.             DWORD UserFileReadBytes;
  2098.             DWORD UserDiskReads;
  2099.             DWORD UserFileWrites;
  2100.             DWORD UserFileWriteBytes;
  2101.             DWORD UserDiskWrites;
  2102.  
  2103.             DWORD MetaDataReads;
  2104.             DWORD MetaDataReadBytes;
  2105.             DWORD MetaDataDiskReads;
  2106.             DWORD MetaDataWrites;
  2107.             DWORD MetaDataWriteBytes;
  2108.             DWORD MetaDataDiskWrites;
  2109.  
  2110.             union {
  2111.                 NTFS_STATISTICS Ntfs;
  2112.                 FAT_STATISTICS Fat;
  2113.             };
  2114.         };
  2115.  
  2116.         DWORDLONG ForceSizeAndAlignment[32];  // pad to a multiple of 64 bytes
  2117.     };
  2118.  
  2119.  
  2120. } FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS;
  2121.  
  2122. // values for FS_STATISTICS.FileSystemType
  2123.  
  2124. #define FILESYSTEM_STATISTICS_TYPE_NTFS     1
  2125. #define FILESYSTEM_STATISTICS_TYPE_FAT      2
  2126.  
  2127. #if(_WIN32_WINNT >= 0x0500)
  2128. //
  2129. // Structure for FSCTL_SET_OBJECT_ID, FSCTL_GET_OBJECT_ID, and FSCTL_CREATE_OR_GET_OBJECT_ID
  2130. //
  2131.  
  2132. typedef struct _FILE_OBJECTID_BUFFER {
  2133.  
  2134.     //
  2135.     //  This is the portion of the object id that is indexed.
  2136.     //
  2137.  
  2138.     BYTE  ObjectId[16];
  2139.  
  2140.     //
  2141.     //  This portion of the object id is not indexed, it's just
  2142.     //  some metadata for the user's benefit.
  2143.     //
  2144.  
  2145.     union {
  2146.         struct {
  2147.             BYTE  BirthVolumeId[16];
  2148.             BYTE  BirthObjectId[16];
  2149.             BYTE  DomainId[16];
  2150.         } ;
  2151.         BYTE  ExtendedInfo[48];
  2152.     };
  2153.  
  2154. } FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER;
  2155. #endif /* _WIN32_WINNT >= 0x0500 */
  2156.  
  2157. #if(_WIN32_WINNT >= 0x0500)
  2158. //
  2159. // Structure for FSCTL_SET_ZERO_DATA
  2160. //
  2161.  
  2162. typedef struct _FILE_ZERO_DATA_INFORMATION {
  2163.  
  2164.     LARGE_INTEGER FileOffset;
  2165.     LARGE_INTEGER BeyondFinalZero;
  2166.  
  2167. } FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION;
  2168. #endif /* _WIN32_WINNT >= 0x0500 */
  2169.  
  2170. #if(_WIN32_WINNT >= 0x0500)
  2171. //
  2172. // Structure for FSCTL_QUERY_ALLOCATED_RANGES
  2173. //
  2174.  
  2175. //
  2176. // Querying the allocated ranges requires an output buffer to store the
  2177. // allocated ranges and an input buffer to specify the range to query.
  2178. // The input buffer contains a single entry, the output buffer is an
  2179. // array of the following structure.
  2180. //
  2181.  
  2182. typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
  2183.  
  2184.     LARGE_INTEGER FileOffset;
  2185.     LARGE_INTEGER Length;
  2186.  
  2187. } FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
  2188. #endif /* _WIN32_WINNT >= 0x0500 */
  2189.  
  2190. #if(_WIN32_WINNT >= 0x0500)
  2191. //
  2192. // Structures for FSCTL_SET_ENCRYPTION, FSCTL_WRITE_RAW_ENCRYPTED, and FSCTL_READ_RAW_ENCRYPTED
  2193. //
  2194.  
  2195. //
  2196. //  The input buffer to set encryption indicates whether we are to encrypt/decrypt a file
  2197. //  or an individual stream.
  2198. //
  2199.  
  2200. typedef struct _ENCRYPTION_BUFFER {
  2201.  
  2202.     DWORD EncryptionOperation;
  2203.     BYTE  Private[1];
  2204.  
  2205. } ENCRYPTION_BUFFER, *PENCRYPTION_BUFFER;
  2206.  
  2207. #define FILE_SET_ENCRYPTION         0x00000001
  2208. #define FILE_CLEAR_ENCRYPTION       0x00000002
  2209. #define STREAM_SET_ENCRYPTION       0x00000003
  2210. #define STREAM_CLEAR_ENCRYPTION     0x00000004
  2211.  
  2212. #define MAXIMUM_ENCRYPTION_VALUE    0x00000004
  2213.  
  2214. //
  2215. //  The following is returned in the information field when the last encrypted
  2216. //  stream in a file is marked as decrypted.
  2217. //
  2218.  
  2219. #define INFO_NO_ENCRYPTED_STREAMS   0x1
  2220.  
  2221. #define ENCRYPTION_FORMAT_DEFAULT        (0x01)
  2222.  
  2223. #define COMPRESSION_FORMAT_SPARSE        (0x4000)
  2224.  
  2225. //
  2226. //  Request Encrypted Data structure.  This is used to indicate
  2227. //  the range of the file to read.  It also describes the
  2228. //  output buffer used to return the data.
  2229. //
  2230.  
  2231. typedef struct _REQUEST_RAW_ENCRYPTED_DATA {
  2232.  
  2233.     //
  2234.     //  Requested file offset and requested length to read.
  2235.     //  The fsctrl will round the starting offset down
  2236.     //  to a file system boundary.  It will also
  2237.     //  round the length up to a file system boundary.
  2238.     //
  2239.  
  2240.     LONGLONG FileOffset;
  2241.     DWORD Length;
  2242.  
  2243. } REQUEST_RAW_ENCRYPTED_DATA, *PREQUEST_RAW_ENCRYPTED_DATA;
  2244.  
  2245. //
  2246. //  Encrypted Data Information structure.  This structure
  2247. //  is used to return raw encrypted data from a file in
  2248. //  order to perform off-line recovery.  The data will be
  2249. //  encrypted or encrypted and compressed.  The off-line
  2250. //  service will need to use the encryption and compression
  2251. //  format information to recover the file data.  In the
  2252. //  event that the data is both encrypted and compressed then
  2253. //  the decryption must occur before decompression.  All
  2254. //  the data units below must be encrypted and compressed
  2255. //  with the same format.
  2256. //
  2257. //  The data will be returned in units.  The data unit size
  2258. //  will be fixed per request.  If the data is compressed
  2259. //  then the data unit size will be the compression unit size.
  2260. //
  2261. //  This structure is at the beginning of the buffer used to
  2262. //  return the encrypted data.  The actual raw bytes from
  2263. //  the file will follow this buffer.  The offset of the
  2264. //  raw bytes from the beginning of this structure is
  2265. //  specified in the REQUEST_RAW_ENCRYPTED_DATA structure
  2266. //  described above.
  2267. //
  2268.  
  2269. typedef struct _ENCRYPTED_DATA_INFO {
  2270.  
  2271.     //
  2272.     //  This is the file offset for the first entry in the
  2273.     //  data block array.  The file system will round
  2274.     //  the requested start offset down to a boundary
  2275.     //  that is consistent with the format of the file.
  2276.     //
  2277.  
  2278.     DWORDLONG StartingFileOffset;
  2279.  
  2280.     //
  2281.     //  Data offset in output buffer.  The output buffer
  2282.     //  begins with an ENCRYPTED_DATA_INFO structure.
  2283.     //  The file system will then store the raw bytes from
  2284.     //  disk beginning at the following offset within the
  2285.     //  output buffer.
  2286.     //
  2287.  
  2288.     DWORD OutputBufferOffset;
  2289.  
  2290.     //
  2291.     //  The number of bytes being returned that are within
  2292.     //  the size of the file.  If this value is less than
  2293.     //  (NumberOfDataBlocks << DataUnitShift), it means the
  2294.     //  end of the file occurs within this transfer.  Any
  2295.     //  data beyond file size is invalid and was never
  2296.     //  passed to the encryption driver.
  2297.     //
  2298.  
  2299.     DWORD BytesWithinFileSize;
  2300.  
  2301.     //
  2302.     //  The number of bytes being returned that are below
  2303.     //  valid data length.  If this value is less than
  2304.     //  (NumberOfDataBlocks << DataUnitShift), it means the
  2305.     //  end of the valid data occurs within this transfer.
  2306.     //  After decrypting the data from this transfer, any
  2307.     //  byte(s) beyond valid data length must be zeroed.
  2308.     //
  2309.  
  2310.     DWORD BytesWithinValidDataLength;
  2311.  
  2312.     //
  2313.     //  Code for the compression format as defined in
  2314.     //  ntrtl.h.  Note that COMPRESSION_FORMAT_NONE
  2315.     //  and COMPRESSION_FORMAT_DEFAULT are invalid if
  2316.     //  any of the described chunks are compressed.
  2317.     //
  2318.  
  2319.     WORD   CompressionFormat;
  2320.  
  2321.     //
  2322.     //  The DataUnit is the granularity used to access the
  2323.     //  disk.  It will be the same as the compression unit
  2324.     //  size for a compressed file.  For an uncompressed
  2325.     //  file, it will be some cluster-aligned power of 2 that
  2326.     //  the file system deems convenient.  A caller should
  2327.     //  not expect that successive calls will have the
  2328.     //  same data unit shift value as the previous call.
  2329.     //
  2330.     //  Since chunks and compression units are expected to be
  2331.     //  powers of 2 in size, we express them log2.  So, for
  2332.     //  example (1 << ChunkShift) == ChunkSizeInBytes.  The
  2333.     //  ClusterShift indicates how much space must be saved
  2334.     //  to successfully compress a compression unit - each
  2335.     //  successfully compressed data unit must occupy
  2336.     //  at least one cluster less in bytes than an uncompressed
  2337.     //  data block unit.
  2338.     //
  2339.  
  2340.     BYTE  DataUnitShift;
  2341.     BYTE  ChunkShift;
  2342.     BYTE  ClusterShift;
  2343.  
  2344.     //
  2345.     //  The format for the encryption.
  2346.     //
  2347.  
  2348.     BYTE  EncryptionFormat;
  2349.  
  2350.     //
  2351.     //  This is the number of entries in the data block size
  2352.     //  array.
  2353.     //
  2354.  
  2355.     WORD   NumberOfDataBlocks;
  2356.  
  2357.     //
  2358.     //  This is an array of sizes in the data block array.  There
  2359.     //  must be one entry in this array for each data block
  2360.     //  read from disk.  The size has a different meaning
  2361.     //  depending on whether the file is compressed.
  2362.     //
  2363.     //  A size of zero always indicates that the final data consists entirely
  2364.     //  of zeroes.  There is no decryption or decompression to
  2365.     //  perform.
  2366.     //
  2367.     //  If the file is compressed then the data block size indicates
  2368.     //  whether this block is compressed.  A size equal to
  2369.     //  the block size indicates that the corresponding block did
  2370.     //  not compress.  Any other non-zero size indicates the
  2371.     //  size of the compressed data which needs to be
  2372.     //  decrypted/decompressed.
  2373.     //
  2374.     //  If the file is not compressed then the data block size
  2375.     //  indicates the amount of data within the block that
  2376.     //  needs to be decrypted.  Any other non-zero size indicates
  2377.     //  that the remaining bytes in the data unit within the file
  2378.     //  consists of zeros.  An example of this is when the
  2379.     //  the read spans the valid data length of the file.  There
  2380.     //  is no data to decrypt past the valid data length.
  2381.     //
  2382.  
  2383.     DWORD DataBlockSize[ANYSIZE_ARRAY];
  2384.  
  2385. } ENCRYPTED_DATA_INFO;
  2386. typedef ENCRYPTED_DATA_INFO *PENCRYPTED_DATA_INFO;
  2387. #endif /* _WIN32_WINNT >= 0x0500 */
  2388.  
  2389. #endif // _FILESYSTEMFSCTL_
  2390.  
  2391.  
  2392. #endif // _WINIOCTL_
  2393.  
  2394.