home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / winioctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  103.2 KB  |  2,901 lines

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