home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / RTLWIN32.PAK / WINIOCTL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  29.9 KB  |  815 lines

  1. /*++ BUILD Version: 0013    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1990-1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     winioctl.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the 32-Bit Windows Device I/O control codes.
  12.  
  13. Revision History:
  14.  
  15. --*/
  16.  
  17. /* $Copyright: 1997$ */
  18.  
  19. #ifndef _WINIOCTL_
  20. #define _WINIOCTL_
  21. #pragma option -b
  22.  
  23.  
  24. #ifndef _DEVIOCTL_
  25. #define _DEVIOCTL_
  26.  
  27. // begin_ntddk begin_nthal begin_ntifs
  28. //
  29. // Define the various device type values.  Note that values used by Microsoft
  30. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  31. // by customers.
  32. //
  33.  
  34. #define DEVICE_TYPE DWORD
  35.  
  36. #define FILE_DEVICE_BEEP                0x00000001
  37. #define FILE_DEVICE_CD_ROM              0x00000002
  38. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
  39. #define FILE_DEVICE_CONTROLLER          0x00000004
  40. #define FILE_DEVICE_DATALINK            0x00000005
  41. #define FILE_DEVICE_DFS                 0x00000006
  42. #define FILE_DEVICE_DISK                0x00000007
  43. #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
  44. #define FILE_DEVICE_FILE_SYSTEM         0x00000009
  45. #define FILE_DEVICE_INPORT_PORT         0x0000000a
  46. #define FILE_DEVICE_KEYBOARD            0x0000000b
  47. #define FILE_DEVICE_MAILSLOT            0x0000000c
  48. #define FILE_DEVICE_MIDI_IN             0x0000000d
  49. #define FILE_DEVICE_MIDI_OUT            0x0000000e
  50. #define FILE_DEVICE_MOUSE               0x0000000f
  51. #define FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
  52. #define FILE_DEVICE_NAMED_PIPE          0x00000011
  53. #define FILE_DEVICE_NETWORK             0x00000012
  54. #define FILE_DEVICE_NETWORK_BROWSER     0x00000013
  55. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  56. #define FILE_DEVICE_NULL                0x00000015
  57. #define FILE_DEVICE_PARALLEL_PORT       0x00000016
  58. #define FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
  59. #define FILE_DEVICE_PRINTER             0x00000018
  60. #define FILE_DEVICE_SCANNER             0x00000019
  61. #define FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
  62. #define FILE_DEVICE_SERIAL_PORT         0x0000001b
  63. #define FILE_DEVICE_SCREEN              0x0000001c
  64. #define FILE_DEVICE_SOUND               0x0000001d
  65. #define FILE_DEVICE_STREAMS             0x0000001e
  66. #define FILE_DEVICE_TAPE                0x0000001f
  67. #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
  68. #define FILE_DEVICE_TRANSPORT           0x00000021
  69. #define FILE_DEVICE_UNKNOWN             0x00000022
  70. #define FILE_DEVICE_VIDEO               0x00000023
  71. #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
  72. #define FILE_DEVICE_WAVE_IN             0x00000025
  73. #define FILE_DEVICE_WAVE_OUT            0x00000026
  74. #define FILE_DEVICE_8042_PORT           0x00000027
  75. #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
  76. #define FILE_DEVICE_BATTERY             0x00000029
  77. #define FILE_DEVICE_BUS_EXTENDER        0x0000002a
  78. #define FILE_DEVICE_MODEM               0x0000002b
  79. #define FILE_DEVICE_VDM                 0x0000002c
  80. #define FILE_DEVICE_MASS_STORAGE        0x0000002d
  81.  
  82. //
  83. // Macro definition for defining IOCTL and FSCTL function control codes.  Note
  84. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  85. // 2048-4095 are reserved for customers.
  86. //
  87.  
  88. #define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
  89.     ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  90. )
  91.  
  92. //
  93. // Define the method codes for how buffers are passed for I/O and FS controls
  94. //
  95.  
  96. #define METHOD_BUFFERED                 0
  97. #define METHOD_IN_DIRECT                1
  98. #define METHOD_OUT_DIRECT               2
  99. #define METHOD_NEITHER                  3
  100.  
  101. //
  102. // Define the access check value for any access
  103. //
  104. //
  105. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  106. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  107. // constants *MUST* always be in sync.
  108. //
  109.  
  110.  
  111. #define FILE_ANY_ACCESS                 0
  112. #define FILE_READ_ACCESS          ( 0x0001 )    // file & pipe
  113. #define FILE_WRITE_ACCESS         ( 0x0002 )    // file & pipe
  114.  
  115. // end_ntddk end_nthal end_ntifs
  116.  
  117. #endif // _DEVIOCTL_
  118.  
  119.  
  120. #ifndef _NTDDSTOR_H_
  121. #define _NTDDSTOR_H_
  122.  
  123.  
  124. //
  125. // IoControlCode values for disk devices.
  126. //
  127.  
  128. #define IOCTL_STORAGE_BASE                FILE_DEVICE_MASS_STORAGE
  129.  
  130. //
  131. // The following device control codes are common for all class drivers.  They
  132. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  133. // common codes
  134. //
  135.  
  136. #define IOCTL_STORAGE_CHECK_VERIFY     CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  137. #define IOCTL_STORAGE_MEDIA_REMOVAL    CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  138. #define IOCTL_STORAGE_EJECT_MEDIA      CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  139. #define IOCTL_STORAGE_LOAD_MEDIA       CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  140. #define IOCTL_STORAGE_RESERVE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  141. #define IOCTL_STORAGE_RELEASE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  142. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  143. #define IOCTL_STORAGE_GET_MEDIA_TYPES  CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  144.  
  145. //
  146. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  147. // on a storage device that ejects media. This function
  148. // may or may not be supported on storage devices that
  149. // support removable media.
  150. //
  151. // TRUE means prevent media from being removed.
  152. // FALSE means allow media removal.
  153. //
  154.  
  155. typedef struct _PREVENT_MEDIA_REMOVAL {
  156.     BOOLEAN PreventMediaRemoval;
  157. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  158.  
  159. #endif // _NTDDSTOR_H_
  160.  
  161. //
  162. // IoControlCode values for disk devices.
  163. //
  164.  
  165. #define IOCTL_DISK_BASE                 FILE_DEVICE_DISK
  166. #define IOCTL_DISK_GET_DRIVE_GEOMETRY   CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  167. #define IOCTL_DISK_GET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  168. #define IOCTL_DISK_SET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  169. #define IOCTL_DISK_GET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  170. #define IOCTL_DISK_SET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  171. #define IOCTL_DISK_VERIFY               CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  172. #define IOCTL_DISK_FORMAT_TRACKS        CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  173. #define IOCTL_DISK_REASSIGN_BLOCKS      CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  174. #define IOCTL_DISK_PERFORMANCE          CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  175. #define IOCTL_DISK_IS_WRITABLE          CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  176. #define IOCTL_DISK_LOGGING              CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  177. #define IOCTL_DISK_FORMAT_TRACKS_EX     CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  178. #define IOCTL_DISK_HISTOGRAM_STRUCTURE  CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  179. #define IOCTL_DISK_HISTOGRAM_DATA       CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  180. #define IOCTL_DISK_HISTOGRAM_RESET      CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  181. #define IOCTL_DISK_REQUEST_STRUCTURE    CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  182. #define IOCTL_DISK_REQUEST_DATA         CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  183.  
  184. #if(_WIN32_WINNT >= 0x0400)
  185. #define IOCTL_DISK_CONTROLLER_NUMBER    CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  186.  
  187. //
  188. // IOCTL support for SMART drive fault prediction.
  189. //
  190.  
  191. #define SMART_GET_VERSION               CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  192. #define SMART_SEND_DRIVE_COMMAND        CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  193. #define SMART_RCV_DRIVE_DATA            CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  194. #endif /* _WIN32_WINNT >= 0x0400 */
  195.  
  196.  
  197. //
  198. // The following device control codes are common for all class drivers.  The
  199. // functions codes defined here must match all of the other class drivers.
  200. //
  201. // Warning: these codes will be replaced in the future by equivalent
  202. // IOCTL_STORAGE codes
  203. //
  204.  
  205. #define IOCTL_DISK_CHECK_VERIFY     CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  206. #define IOCTL_DISK_MEDIA_REMOVAL    CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  207. #define IOCTL_DISK_EJECT_MEDIA      CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  208. #define IOCTL_DISK_LOAD_MEDIA       CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  209. #define IOCTL_DISK_RESERVE          CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  210. #define IOCTL_DISK_RELEASE          CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  211. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  212. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  213.  
  214. //
  215. // Define the partition types returnable by known disk drivers.
  216. //
  217.  
  218. #define PARTITION_ENTRY_UNUSED          0x00      // Entry unused
  219. #define PARTITION_FAT_12                0x01      // 12-bit FAT entries
  220. #define PARTITION_XENIX_1               0x02      // Xenix
  221. #define PARTITION_XENIX_2               0x03      // Xenix
  222. #define PARTITION_FAT_16                0x04      // 16-bit FAT entries
  223. #define PARTITION_EXTENDED              0x05      // Extended partition entry
  224. #define PARTITION_HUGE                  0x06      // Huge partition MS-DOS V4
  225. #define PARTITION_IFS                   0x07      // IFS Partition
  226. #define PARTITION_FAT32                 0x0B      // FAT32
  227. #define PARTITION_FAT32_XINT13          0x0C      // FAT32 using extended int13 services
  228. #define PARTITION_XINT13                0x0E      // Win95 partition using extended int13 services
  229. #define PARTITION_XINT13_EXTENDED       0x0F      // Same as type 5 but uses extended int13 services
  230. #define PARTITION_PREP                  0x41      // PowerPC Reference Platform (PReP) Boot Partition
  231. #define PARTITION_UNIX                  0x63      // Unix
  232.  
  233. #define VALID_NTFT                      0xC0      // NTFT uses high order bits
  234.  
  235. //
  236. // The high bit of the partition type code indicates that a partition
  237. // is part of an NTFT mirror or striped array.
  238. //
  239.  
  240. #define PARTITION_NTFT                  0x80     // NTFT partition
  241.  
  242. //
  243. // The following macro is used to determine which partitions should be
  244. // assigned drive letters.
  245. //
  246.  
  247. //++
  248. //
  249. // BOOLEAN
  250. // IsRecognizedPartition(
  251. //     IN DWORD PartitionType
  252. //     )
  253. //
  254. // Routine Description:
  255. //
  256. //     This macro is used to determine to which partitions drive letters
  257. //     should be assigned.
  258. //
  259. // Arguments:
  260. //
  261. //     PartitionType - Supplies the type of the partition being examined.
  262. //
  263. // Return Value:
  264. //
  265. //     The return value is TRUE if the partition type is recognized,
  266. //     otherwise FALSE is returned.
  267. //
  268. //--
  269.  
  270. #define IsRecognizedPartition( PartitionType ) (       \
  271.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) ||  \
  272.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_16)) ||  \
  273.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) ||  \
  274.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) ||  \
  275.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) ||  \
  276.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) ||  \
  277.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) ||  \
  278.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_12) ||  \
  279.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_16) ||  \
  280.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_IFS)    ||  \
  281.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_HUGE)    ||  \
  282.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32)  || \
  283.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32_XINT13) || \
  284.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_XINT13) )
  285.  
  286. //++
  287. //
  288. // BOOLEAN
  289. // IsContainerPartition(
  290. //     IN DWORD PartitionType
  291. //     )
  292. //
  293. // Routine Description:
  294. //
  295. //     This macro is used to determine to which partition types are actually
  296. //     containers for other partitions (ie, extended partitions).
  297. //
  298. // Arguments:
  299. //
  300. //     PartitionType - Supplies the type of the partition being examined.
  301. //
  302. // Return Value:
  303. //
  304. //     The return value is TRUE if the partition type is a container,
  305. //     otherwise FALSE is returned.
  306. //
  307. //--
  308.  
  309. #define IsContainerPartition( PartitionType ) \
  310.     ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  311.  
  312. //
  313. // Define the media types supported by the driver.
  314. //
  315.  
  316. typedef enum _MEDIA_TYPE {
  317.     Unknown,                // Format is unknown
  318.     F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
  319.     F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
  320.     F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
  321.     F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
  322.     F3_720_512,             // 3.5",  720KB,  512 bytes/sector
  323.     F5_360_512,             // 5.25", 360KB,  512 bytes/sector
  324.     F5_320_512,             // 5.25", 320KB,  512 bytes/sector
  325.     F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
  326.     F5_180_512,             // 5.25", 180KB,  512 bytes/sector
  327.     F5_160_512,             // 5.25", 160KB,  512 bytes/sector
  328.     RemovableMedia,         // Removable media other than floppy
  329.     FixedMedia,             // Fixed hard disk media
  330.     F3_120M_512             // 3.5", 120M Floppy
  331. } MEDIA_TYPE, *PMEDIA_TYPE;
  332.  
  333. //
  334. // Define the input buffer structure for the driver, when
  335. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  336. //
  337.  
  338. typedef struct _FORMAT_PARAMETERS {
  339.    MEDIA_TYPE MediaType;
  340.    DWORD StartCylinderNumber;
  341.    DWORD EndCylinderNumber;
  342.    DWORD StartHeadNumber;
  343.    DWORD EndHeadNumber;
  344. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  345.  
  346. //
  347. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  348. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  349. // what tracks were bad during formatting. The length of that array is
  350. // reported in the `Information' field of the I/O Status Block.
  351. //
  352.  
  353. typedef WORD   BAD_TRACK_NUMBER;
  354. typedef WORD   *PBAD_TRACK_NUMBER;
  355.  
  356. //
  357. // Define the input buffer structure for the driver, when
  358. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  359. //
  360.  
  361. typedef struct _FORMAT_EX_PARAMETERS {
  362.    MEDIA_TYPE MediaType;
  363.    DWORD StartCylinderNumber;
  364.    DWORD EndCylinderNumber;
  365.    DWORD StartHeadNumber;
  366.    DWORD EndHeadNumber;
  367.    WORD   FormatGapLength;
  368.    WORD   SectorsPerTrack;
  369.    WORD   SectorNumber[1];
  370. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  371.  
  372. //
  373. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  374. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  375. // request.
  376. //
  377.  
  378. typedef struct _DISK_GEOMETRY {
  379.     LARGE_INTEGER Cylinders;
  380.     MEDIA_TYPE MediaType;
  381.     DWORD TracksPerCylinder;
  382.     DWORD SectorsPerTrack;
  383.     DWORD BytesPerSector;
  384. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  385.  
  386. //
  387. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  388. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request.  It is also used in a request
  389. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  390. //
  391.  
  392. typedef struct _PARTITION_INFORMATION {
  393.     LARGE_INTEGER StartingOffset;
  394.     LARGE_INTEGER PartitionLength;
  395.     DWORD HiddenSectors;
  396.     DWORD PartitionNumber;
  397.     BYTE  PartitionType;
  398.     BOOLEAN BootIndicator;
  399.     BOOLEAN RecognizedPartition;
  400.     BOOLEAN RewritePartition;
  401. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  402.  
  403. //
  404. // The following structure is used to change the partition type of a
  405. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  406. // request.
  407. //
  408.  
  409. typedef struct _SET_PARTITION_INFORMATION {
  410.     BYTE  PartitionType;
  411. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  412.  
  413. //
  414. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  415. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  416. //
  417.  
  418. typedef struct _DRIVE_LAYOUT_INFORMATION {
  419.     DWORD PartitionCount;
  420.     DWORD Signature;
  421.     PARTITION_INFORMATION PartitionEntry[1];
  422. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  423.  
  424. //
  425. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  426. // The offset and length parameters are both given in bytes.
  427. //
  428.  
  429. typedef struct _VERIFY_INFORMATION {
  430.     LARGE_INTEGER StartingOffset;
  431.     DWORD Length;
  432. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  433.  
  434. //
  435. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  436. // request.
  437. //
  438.  
  439. typedef struct _REASSIGN_BLOCKS {
  440.     WORD   Reserved;
  441.     WORD   Count;
  442.     DWORD BlockNumber[1];
  443. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  444.  
  445. #if(_WIN32_WINNT >= 0x0400)
  446. //
  447. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  448. // number for the handle.  This is used to determine if a disk
  449. // is attached to the primary or secondary IDE controller.
  450. //
  451.  
  452. typedef struct _DISK_CONTROLLER_NUMBER {
  453.     DWORD ControllerNumber;
  454.     DWORD DiskNumber;
  455. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  456. #endif /* _WIN32_WINNT >= 0x0400 */
  457.  
  458. ///////////////////////////////////////////////////////
  459. //                                                   //
  460. // The following structures define disk performance  //
  461. // statistics: specifically the locations of all the //
  462. // reads and writes which have occured on the disk.  //
  463. //                                                   //
  464. // To use these structures, you must issue an IOCTL_ //
  465. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to    //
  466. // obtain the basic histogram information. The       //
  467. // number of buckets which must allocated is part of //
  468. // this structure. Allocate the required number of   //
  469. // buckets and call an IOCTL_DISK_HIST_DATA to fill  //
  470. // in the data                                       //
  471. //                                                   //
  472. ///////////////////////////////////////////////////////
  473.  
  474. #define HIST_NO_OF_BUCKETS  24
  475.  
  476. typedef struct _HISTOGRAM_BUCKET {
  477.     DWORD       Reads;
  478.     DWORD       Writes;
  479. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  480.  
  481. #define HISTOGRAM_BUCKET_SIZE   sizeof(HISTOGRAM_BUCKET)
  482.  
  483. typedef struct _DISK_HISTOGRAM {
  484.     LARGE_INTEGER   DiskSize;
  485.     LARGE_INTEGER   Start;
  486.     LARGE_INTEGER   End;
  487.     LARGE_INTEGER   Average;
  488.     LARGE_INTEGER   AverageRead;
  489.     LARGE_INTEGER   AverageWrite;
  490.     DWORD           Granularity;
  491.     DWORD           Size;
  492.     DWORD           ReadCount;
  493.     DWORD           WriteCount;
  494.     PHISTOGRAM_BUCKET  Histogram;
  495. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  496.  
  497. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  498.  
  499. ///////////////////////////////////////////////////////
  500. //                                                   //
  501. // The following structures define disk debugging    //
  502. // capabilities. The IOCTLs are directed to one of   //
  503. // the two disk filter drivers.                      //
  504. //                                                   //
  505. // DISKPERF is a utilty for collecting disk request  //
  506. // statistics.                                       //
  507. //                                                   //
  508. // SIMBAD is a utility for injecting faults in       //
  509. // IO requests to disks.                             //
  510. //                                                   //
  511. ///////////////////////////////////////////////////////
  512.  
  513. //
  514. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  515. // request. This ioctl collects summary disk request statistics used
  516. // in measuring performance.
  517. //
  518.  
  519. typedef struct _DISK_PERFORMANCE {
  520.         LARGE_INTEGER BytesRead;
  521.         LARGE_INTEGER BytesWritten;
  522.         LARGE_INTEGER ReadTime;
  523.         LARGE_INTEGER WriteTime;
  524.         DWORD ReadCount;
  525.         DWORD WriteCount;
  526.         DWORD QueueDepth;
  527. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  528.  
  529. //
  530. // This structure defines the disk logging record. When disk logging
  531. // is enabled, one of these is written to an internal buffer for each
  532. // disk request.
  533. //
  534.  
  535. typedef struct _DISK_RECORD {
  536.    LARGE_INTEGER ByteOffset;
  537.    LARGE_INTEGER StartTime;
  538.    LARGE_INTEGER EndTime;
  539.    PVOID VirtualAddress;
  540.    DWORD NumberOfBytes;
  541.    BYTE  DeviceNumber;
  542.    BOOLEAN ReadRequest;
  543. } DISK_RECORD, *PDISK_RECORD;
  544.  
  545. //
  546. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  547. // Not all fields are valid with each function type.
  548. //
  549.  
  550. typedef struct _DISK_LOGGING {
  551.     BYTE  Function;
  552.     PVOID BufferAddress;
  553.     DWORD BufferSize;
  554. } DISK_LOGGING, *PDISK_LOGGING;
  555.  
  556. //
  557. // Disk logging functions
  558. //
  559. // Start disk logging. Only the Function and BufferSize fields are valid.
  560. //
  561.  
  562. #define DISK_LOGGING_START    0
  563.  
  564. //
  565. // Stop disk logging. Only the Function field is valid.
  566. //
  567.  
  568. #define DISK_LOGGING_STOP     1
  569.  
  570. //
  571. // Return disk log. All fields are valid. Data will be copied from internal
  572. // buffer to buffer specified for the number of bytes requested.
  573. //
  574.  
  575. #define DISK_LOGGING_DUMP     2
  576.  
  577. //
  578. // DISK BINNING
  579. //
  580. // DISKPERF will keep counters for IO that falls in each of these ranges.
  581. // The application determines the number and size of the ranges.
  582. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  583. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  584. //
  585.  
  586. #define DISK_BINNING          3
  587.  
  588. //
  589. // Bin types
  590. //
  591.  
  592. typedef enum _BIN_TYPES {
  593.     RequestSize,
  594.     RequestLocation
  595. } BIN_TYPES;
  596.  
  597. //
  598. // Bin ranges
  599. //
  600.  
  601. typedef struct _BIN_RANGE {
  602.     LARGE_INTEGER StartValue;
  603.     LARGE_INTEGER Length;
  604. } BIN_RANGE, *PBIN_RANGE;
  605.  
  606. //
  607. // Bin definition
  608. //
  609.  
  610. typedef struct _PERF_BIN {
  611.     DWORD NumberOfBins;
  612.     DWORD TypeOfBin;
  613.     BIN_RANGE BinsRanges[1];
  614. } PERF_BIN, *PPERF_BIN ;
  615.  
  616. //
  617. // Bin count
  618. //
  619.  
  620. typedef struct _BIN_COUNT {
  621.     BIN_RANGE BinRange;
  622.     DWORD BinCount;
  623. } BIN_COUNT, *PBIN_COUNT;
  624.  
  625. //
  626. // Bin results
  627. //
  628.  
  629. typedef struct _BIN_RESULTS {
  630.     DWORD NumberOfBins;
  631.     BIN_COUNT BinCounts[1];
  632. } BIN_RESULTS, *PBIN_RESULTS;
  633.  
  634. #if(_WIN32_WINNT >= 0x0400)
  635. //
  636. // Data structures for SMART drive fault prediction.
  637. //
  638. // GETVERSIONINPARAMS contains the data returned from the
  639. // Get Driver Version function.
  640. //
  641.  
  642. #pragma pack(1)
  643. typedef struct _GETVERSIONINPARAMS {
  644.         BYTE     bVersion;               // Binary driver version.
  645.         BYTE     bRevision;              // Binary driver revision.
  646.         BYTE     bReserved;              // Not used.
  647.         BYTE     bIDEDeviceMap;          // Bit map of IDE devices.
  648.         DWORD   fCapabilities;          // Bit mask of driver capabilities.
  649.         DWORD   dwReserved[4];          // For future use.
  650. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  651. #pragma pack()
  652.  
  653. //
  654. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  655. //
  656.  
  657. #define CAP_ATA_ID_CMD          1       // ATA ID command supported
  658. #define CAP_ATAPI_ID_CMD        2       // ATAPI ID command supported
  659. #define CAP_SMART_CMD           4       // SMART commannds supported
  660.  
  661. //
  662. // IDE registers
  663. //
  664.  
  665. #pragma pack(1)
  666. typedef struct _IDEREGS {
  667.         BYTE     bFeaturesReg;           // Used for specifying SMART "commands".
  668.         BYTE     bSectorCountReg;        // IDE sector count register
  669.         BYTE     bSectorNumberReg;       // IDE sector number register
  670.         BYTE     bCylLowReg;             // IDE low order cylinder value
  671.         BYTE     bCylHighReg;            // IDE high order cylinder value
  672.         BYTE     bDriveHeadReg;          // IDE drive/head register
  673.         BYTE     bCommandReg;            // Actual IDE command.
  674.         BYTE     bReserved;                      // reserved for future use.  Must be zero.
  675. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  676. #pragma pack()
  677.  
  678. //
  679. // Valid values for the bCommandReg member of IDEREGS.
  680. //
  681.  
  682. #define ATAPI_ID_CMD    0xA1            // Returns ID sector for ATAPI.
  683. #define ID_CMD          0xEC            // Returns ID sector for ATA.
  684. #define SMART_CMD       0xB0            // Performs SMART cmd.
  685.                                         // Requires valid bFeaturesReg,
  686.                                         // bCylLowReg, and bCylHighReg
  687.  
  688. //
  689. // Cylinder register defines for SMART command
  690. //
  691.  
  692. #define SMART_CYL_LOW   0x4F
  693. #define SMART_CYL_HI    0xC2
  694.  
  695.  
  696. //
  697. // SENDCMDINPARAMS contains the input parameters for the
  698. // Send Command to Drive function.
  699. //
  700.  
  701. #pragma pack(1)
  702. typedef struct _SENDCMDINPARAMS {
  703.         DWORD   cBufferSize;            // Buffer size in bytes
  704.         IDEREGS irDriveRegs;            // Structure with drive register values.
  705.         BYTE     bDriveNumber;           // Physical drive number to send
  706.                                                                 // command to (0,1,2,3).
  707.         BYTE     bReserved[3];           // Reserved for future expansion.
  708.         DWORD   dwReserved[4];          // For future use.
  709.         BYTE     bBuffer[1];                     // Input buffer.
  710. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  711. #pragma pack()
  712.  
  713. //
  714. // Status returned from driver
  715. //
  716.  
  717. #pragma pack(1)
  718. typedef struct _DRIVERSTATUS {
  719.         BYTE     bDriverError;           // Error code from driver,
  720.                                                                 // or 0 if no error.
  721.         BYTE     bIDEError;                      // Contents of IDE Error register.
  722.                                                                 // Only valid when bDriverError
  723.                                                                 // is SMART_IDE_ERROR.
  724.         BYTE     bReserved[2];           // Reserved for future expansion.
  725.         DWORD   dwReserved[2];          // Reserved for future expansion.
  726. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  727. #pragma pack()
  728.  
  729. //
  730. // bDriverError values
  731. //
  732.  
  733. #define SMART_NO_ERROR          0       // No error
  734. #define SMART_IDE_ERROR         1       // Error from IDE controller
  735. #define SMART_INVALID_FLAG      2       // Invalid command flag
  736. #define SMART_INVALID_COMMAND   3       // Invalid command byte
  737. #define SMART_INVALID_BUFFER    4       // Bad buffer (null, invalid addr..)
  738. #define SMART_INVALID_DRIVE     5       // Drive number not valid
  739. #define SMART_INVALID_IOCTL     6       // Invalid IOCTL
  740. #define SMART_ERROR_NO_MEM      7       // Could not lock user's buffer
  741. #define SMART_INVALID_REGISTER  8       // Some IDE Register not valid
  742. #define SMART_NOT_SUPPORTED     9       // Invalid cmd flag set
  743. #define SMART_NO_IDE_DEVICE     10      // Cmd issued to device not present
  744.                                         // although drive number is valid
  745.  
  746. #pragma pack(1)
  747. typedef struct _SENDCMDOUTPARAMS {
  748.         DWORD                   cBufferSize;            // Size of bBuffer in bytes
  749.         DRIVERSTATUS            DriverStatus;           // Driver status structure.
  750.         BYTE                    bBuffer[1];             // Buffer of arbitrary length in which to store the data read from the                                                                                  // drive.
  751. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  752. #pragma pack()
  753.  
  754.  
  755. #define READ_ATTRIBUTE_BUFFER_SIZE  512
  756. #define IDENTIFY_BUFFER_SIZE        512
  757. #define READ_THRESHOLD_BUFFER_SIZE  512
  758.  
  759. //
  760. // Feature register defines for SMART "sub commands"
  761. //
  762.  
  763. #define READ_ATTRIBUTES         0xD0
  764. #define READ_THRESHOLDS         0xD1
  765. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  766. #define SAVE_ATTRIBUTE_VALUES   0xD3
  767. #define EXECUTE_OFFLINE_DIAGS   0xD4
  768. #define ENABLE_SMART            0xD8
  769. #define DISABLE_SMART           0xD9
  770. #define RETURN_SMART_STATUS     0xDA
  771. #endif /* _WIN32_WINNT >= 0x0400 */
  772.  
  773.  
  774.  
  775. #define IOCTL_SERIAL_LSRMST_INSERT      CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  776.  
  777.  
  778. //
  779. // The following values follow the escape designator in the
  780. // data stream if the LSRMST_INSERT mode has been turned on.
  781. //
  782. #define SERIAL_LSRMST_ESCAPE     ((BYTE )0x00)
  783.  
  784. //
  785. // Following this value is the contents of the line status
  786. // register, and then the character in the RX hardware when
  787. // the line status register was encountered.
  788. //
  789. #define SERIAL_LSRMST_LSR_DATA   ((BYTE )0x01)
  790.  
  791. //
  792. // Following this value is the contents of the line status
  793. // register.  No error character follows
  794. //
  795. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  796.  
  797. //
  798. // Following this value is the contents of the modem status
  799. // register.
  800. //
  801. #define SERIAL_LSRMST_MST        ((BYTE )0x03)
  802.  
  803. #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  804. #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  805. #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  806. #define FSCTL_MOUNT_DBLS_VOLUME         CTL_CODE(FILE_DEVICE_FILE_SYSTEM,13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  807. #define FSCTL_GET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  808. #define FSCTL_SET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  809. #define FSCTL_READ_COMPRESSION          CTL_CODE(FILE_DEVICE_FILE_SYSTEM,17, METHOD_NEITHER,  FILE_READ_DATA)
  810. #define FSCTL_WRITE_COMPRESSION         CTL_CODE(FILE_DEVICE_FILE_SYSTEM,18, METHOD_NEITHER,  FILE_WRITE_DATA)
  811.  
  812. #pragma option -b.
  813. #endif // _WINIOCTL_
  814.  
  815.