1155 lines
43 KiB
C
1155 lines
43 KiB
C
|
/*++ BUILD Version: 0011 // Increment this if a change has global effects
|
||
|
|
||
|
Copyright (c) 1990-2001 Microsoft Corporation
|
||
|
|
||
|
Module Name:
|
||
|
|
||
|
winioctl.h
|
||
|
|
||
|
Abstract:
|
||
|
|
||
|
This module defines the 32-Bit Windows Device I/O control codes.
|
||
|
|
||
|
Revision History:
|
||
|
|
||
|
--*/
|
||
|
|
||
|
|
||
|
//
|
||
|
// Interface GUIDs
|
||
|
//
|
||
|
// need these GUIDs outside conditional includes so that user can
|
||
|
// #include <winioctl.h> in precompiled header
|
||
|
// #include <initguid.h> in a single source file
|
||
|
// #include <winioctl.h> in that source file a second time to instantiate the GUIDs
|
||
|
//
|
||
|
#ifdef DEFINE_GUID
|
||
|
//
|
||
|
// Make sure FAR is defined...
|
||
|
//
|
||
|
#ifndef FAR
|
||
|
#ifdef _WIN32
|
||
|
#define FAR
|
||
|
#else
|
||
|
#define FAR _far
|
||
|
#endif
|
||
|
#endif
|
||
|
|
||
|
DEFINE_GUID(DiskClassGuid, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(CdRomClassGuid, 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(PartitionClassGuid, 0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(TapeClassGuid, 0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(WriteOnceDiskClassGuid, 0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(VolumeClassGuid, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(MediumChangerClassGuid, 0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(FloppyClassGuid, 0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(CdChangerClassGuid, 0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
DEFINE_GUID(StoragePortClassGuid, 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||
|
#endif // DEFINE_GUID
|
||
|
|
||
|
#ifndef _WINIOCTL_
|
||
|
#define _WINIOCTL_
|
||
|
|
||
|
|
||
|
#ifndef _DEVIOCTL_
|
||
|
#define _DEVIOCTL_
|
||
|
|
||
|
// begin_ntddk begin_wdm begin_nthal begin_ntifs
|
||
|
//
|
||
|
// Define the various device type values. Note that values used by Microsoft
|
||
|
// Corporation are in the range 0-32767, and 32768-65535 are reserved for use
|
||
|
// by customers.
|
||
|
//
|
||
|
|
||
|
#define DEVICE_TYPE DWORD
|
||
|
|
||
|
#define FILE_DEVICE_BEEP 0x00000001
|
||
|
#define FILE_DEVICE_CD_ROM 0x00000002
|
||
|
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
|
||
|
#define FILE_DEVICE_CONTROLLER 0x00000004
|
||
|
#define FILE_DEVICE_DATALINK 0x00000005
|
||
|
#define FILE_DEVICE_DFS 0x00000006
|
||
|
#define FILE_DEVICE_DISK 0x00000007
|
||
|
#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
|
||
|
#define FILE_DEVICE_FILE_SYSTEM 0x00000009
|
||
|
#define FILE_DEVICE_INPORT_PORT 0x0000000a
|
||
|
#define FILE_DEVICE_KEYBOARD 0x0000000b
|
||
|
#define FILE_DEVICE_MAILSLOT 0x0000000c
|
||
|
#define FILE_DEVICE_MIDI_IN 0x0000000d
|
||
|
#define FILE_DEVICE_MIDI_OUT 0x0000000e
|
||
|
#define FILE_DEVICE_MOUSE 0x0000000f
|
||
|
#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
|
||
|
#define FILE_DEVICE_NAMED_PIPE 0x00000011
|
||
|
#define FILE_DEVICE_NETWORK 0x00000012
|
||
|
#define FILE_DEVICE_NETWORK_BROWSER 0x00000013
|
||
|
#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
|
||
|
#define FILE_DEVICE_NULL 0x00000015
|
||
|
#define FILE_DEVICE_PARALLEL_PORT 0x00000016
|
||
|
#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
|
||
|
#define FILE_DEVICE_PRINTER 0x00000018
|
||
|
#define FILE_DEVICE_SCANNER 0x00000019
|
||
|
#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
|
||
|
#define FILE_DEVICE_SERIAL_PORT 0x0000001b
|
||
|
#define FILE_DEVICE_SCREEN 0x0000001c
|
||
|
#define FILE_DEVICE_SOUND 0x0000001d
|
||
|
#define FILE_DEVICE_STREAMS 0x0000001e
|
||
|
#define FILE_DEVICE_TAPE 0x0000001f
|
||
|
#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
|
||
|
#define FILE_DEVICE_TRANSPORT 0x00000021
|
||
|
#define FILE_DEVICE_UNKNOWN 0x00000022
|
||
|
#define FILE_DEVICE_VIDEO 0x00000023
|
||
|
#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
|
||
|
#define FILE_DEVICE_WAVE_IN 0x00000025
|
||
|
#define FILE_DEVICE_WAVE_OUT 0x00000026
|
||
|
#define FILE_DEVICE_8042_PORT 0x00000027
|
||
|
#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
|
||
|
#define FILE_DEVICE_BATTERY 0x00000029
|
||
|
#define FILE_DEVICE_BUS_EXTENDER 0x0000002a
|
||
|
#define FILE_DEVICE_MODEM 0x0000002b
|
||
|
#define FILE_DEVICE_VDM 0x0000002c
|
||
|
#define FILE_DEVICE_MASS_STORAGE 0x0000002d
|
||
|
#define FILE_DEVICE_SMB 0x0000002e
|
||
|
#define FILE_DEVICE_KS 0x0000002f
|
||
|
#define FILE_DEVICE_CHANGER 0x00000030
|
||
|
#define FILE_DEVICE_SMARTCARD 0x00000031
|
||
|
#define FILE_DEVICE_ACPI 0x00000032
|
||
|
#define FILE_DEVICE_DVD 0x00000033
|
||
|
#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
|
||
|
#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
|
||
|
#define FILE_DEVICE_DFS_VOLUME 0x00000036
|
||
|
#define FILE_DEVICE_SERENUM 0x00000037
|
||
|
#define FILE_DEVICE_TERMSRV 0x00000038
|
||
|
#define FILE_DEVICE_KSEC 0x00000039
|
||
|
#define FILE_DEVICE_MEMORY_UNIT 0x0000003a
|
||
|
#define FILE_DEVICE_MEDIA_BOARD 0x0000003b
|
||
|
|
||
|
//
|
||
|
// Macro definition for defining IOCTL and FSCTL function control codes. Note
|
||
|
// that function codes 0-2047 are reserved for Microsoft Corporation, and
|
||
|
// 2048-4095 are reserved for customers.
|
||
|
//
|
||
|
|
||
|
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
|
||
|
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
|
||
|
)
|
||
|
|
||
|
//
|
||
|
// Macro to extract device type out of the device io control code
|
||
|
//
|
||
|
#define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((DWORD)(ctrlCode & 0xffff0000)) >> 16)
|
||
|
|
||
|
//
|
||
|
// Define the method codes for how buffers are passed for I/O and FS controls
|
||
|
//
|
||
|
|
||
|
#define METHOD_BUFFERED 0
|
||
|
#define METHOD_IN_DIRECT 1
|
||
|
#define METHOD_OUT_DIRECT 2
|
||
|
#define METHOD_NEITHER 3
|
||
|
|
||
|
//
|
||
|
// Define the access check value for any access
|
||
|
//
|
||
|
//
|
||
|
// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
|
||
|
// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
|
||
|
// constants *MUST* always be in sync.
|
||
|
//
|
||
|
//
|
||
|
// FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS.
|
||
|
// The file systems, however, may add additional access checks for I/O and FS controls
|
||
|
// that use this value.
|
||
|
//
|
||
|
|
||
|
|
||
|
#define FILE_ANY_ACCESS 0
|
||
|
#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS)
|
||
|
#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
|
||
|
#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
|
||
|
|
||
|
// end_ntddk end_wdm end_nthal end_ntifs
|
||
|
|
||
|
#endif // _DEVIOCTL_
|
||
|
|
||
|
|
||
|
#ifndef _NTDDSTOR_H_
|
||
|
#define _NTDDSTOR_H_
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
//
|
||
|
// IoControlCode values for storage devices
|
||
|
//
|
||
|
|
||
|
#define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
|
||
|
|
||
|
//
|
||
|
// The following device control codes are common for all class drivers. They
|
||
|
// should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
|
||
|
// common codes
|
||
|
//
|
||
|
|
||
|
#define IOCTL_STORAGE_CHECK_VERIFY CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_CHECK_VERIFY2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_STORAGE_MEDIA_REMOVAL CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_EJECT_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_LOAD_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_LOAD_MEDIA2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_STORAGE_RESERVE CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_RELEASE CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
|
||
|
#define IOCTL_STORAGE_EJECTION_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_STORAGE_MCN_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
#define IOCTL_STORAGE_GET_MEDIA_TYPES CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
#define IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
|
||
|
#define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
#define IOCTL_STORAGE_PREDICT_FAILURE CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
|
||
|
//
|
||
|
// These ioctl codes are obsolete. They are defined here to avoid resuing them
|
||
|
// and to allow class drivers to respond to them more easily.
|
||
|
//
|
||
|
|
||
|
#define OBSOLETE_IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define OBSOLETE_IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
|
||
|
//
|
||
|
// IOCTL_STORAGE_GET_DEVICE_NUMBER
|
||
|
//
|
||
|
// input - none
|
||
|
//
|
||
|
// output - STORAGE_DEVICE_NUMBER structure
|
||
|
// The values in the STORAGE_DEVICE_NUMBER structure are guaranteed
|
||
|
// to remain unchanged until the system is rebooted. They are not
|
||
|
// guaranteed to be persistant across boots.
|
||
|
//
|
||
|
|
||
|
typedef struct _STORAGE_DEVICE_NUMBER {
|
||
|
|
||
|
//
|
||
|
// The FILE_DEVICE_XXX type for this device.
|
||
|
//
|
||
|
|
||
|
DEVICE_TYPE DeviceType;
|
||
|
|
||
|
//
|
||
|
// The number of this device
|
||
|
//
|
||
|
|
||
|
DWORD DeviceNumber;
|
||
|
|
||
|
//
|
||
|
// If the device is partitionable, the partition number of the device.
|
||
|
// Otherwise -1
|
||
|
//
|
||
|
|
||
|
DWORD PartitionNumber;
|
||
|
} STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
|
||
|
|
||
|
//
|
||
|
// Define the structures for scsi resets
|
||
|
//
|
||
|
|
||
|
typedef struct _STORAGE_BUS_RESET_REQUEST {
|
||
|
BYTE PathId;
|
||
|
} STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
|
||
|
|
||
|
//
|
||
|
// IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
|
||
|
// on a storage device that ejects media. This function
|
||
|
// may or may not be supported on storage devices that
|
||
|
// support removable media.
|
||
|
//
|
||
|
// TRUE means prevent media from being removed.
|
||
|
// FALSE means allow media removal.
|
||
|
//
|
||
|
|
||
|
typedef struct _PREVENT_MEDIA_REMOVAL {
|
||
|
BOOLEAN PreventMediaRemoval;
|
||
|
} PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
|
||
|
|
||
|
// begin_ntminitape
|
||
|
|
||
|
|
||
|
typedef struct _TAPE_STATISTICS {
|
||
|
DWORD Version;
|
||
|
DWORD Flags;
|
||
|
LARGE_INTEGER RecoveredWrites;
|
||
|
LARGE_INTEGER UnrecoveredWrites;
|
||
|
LARGE_INTEGER RecoveredReads;
|
||
|
LARGE_INTEGER UnrecoveredReads;
|
||
|
BYTE CompressionRatioReads;
|
||
|
BYTE CompressionRatioWrites;
|
||
|
} TAPE_STATISTICS, *PTAPE_STATISTICS;
|
||
|
|
||
|
#define RECOVERED_WRITES_VALID 0x00000001
|
||
|
#define UNRECOVERED_WRITES_VALID 0x00000002
|
||
|
#define RECOVERED_READS_VALID 0x00000004
|
||
|
#define UNRECOVERED_READS_VALID 0x00000008
|
||
|
#define WRITE_COMPRESSION_INFO_VALID 0x00000010
|
||
|
#define READ_COMPRESSION_INFO_VALID 0x00000020
|
||
|
|
||
|
typedef struct _TAPE_GET_STATISTICS {
|
||
|
DWORD Operation;
|
||
|
} TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
|
||
|
|
||
|
#define TAPE_RETURN_STATISTICS 0L
|
||
|
#define TAPE_RETURN_ENV_INFO 1L
|
||
|
#define TAPE_RESET_STATISTICS 2L
|
||
|
|
||
|
//
|
||
|
// IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
|
||
|
// structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
|
||
|
//
|
||
|
|
||
|
typedef enum _STORAGE_MEDIA_TYPE {
|
||
|
//
|
||
|
// Following are defined in ntdddisk.h in the MEDIA_TYPE enum
|
||
|
//
|
||
|
// Unknown, // Format is unknown
|
||
|
// F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
|
||
|
// F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
|
||
|
// F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
|
||
|
// F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
|
||
|
// F3_720_512, // 3.5", 720KB, 512 bytes/sector
|
||
|
// F5_360_512, // 5.25", 360KB, 512 bytes/sector
|
||
|
// F5_320_512, // 5.25", 320KB, 512 bytes/sector
|
||
|
// F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
|
||
|
// F5_180_512, // 5.25", 180KB, 512 bytes/sector
|
||
|
// F5_160_512, // 5.25", 160KB, 512 bytes/sector
|
||
|
// RemovableMedia, // Removable media other than floppy
|
||
|
// FixedMedia, // Fixed hard disk media
|
||
|
// F3_120M_512, // 3.5", 120M Floppy
|
||
|
// F3_640_512, // 3.5" , 640KB, 512 bytes/sector
|
||
|
// F5_640_512, // 5.25", 640KB, 512 bytes/sector
|
||
|
// F5_720_512, // 5.25", 720KB, 512 bytes/sector
|
||
|
// F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
|
||
|
// F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
|
||
|
// F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
|
||
|
// F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
|
||
|
// F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
|
||
|
// F8_256_128, // 8", 256KB, 128 bytes/sector
|
||
|
//
|
||
|
|
||
|
DDS_4mm = 0x20, // Tape - DAT DDS1,2,... (all vendors)
|
||
|
MiniQic, // Tape - miniQIC Tape
|
||
|
Travan, // Tape - Travan TR-1,2,3,...
|
||
|
QIC, // Tape - QIC
|
||
|
MP_8mm, // Tape - 8mm Exabyte Metal Particle
|
||
|
AME_8mm, // Tape - 8mm Exabyte Advanced Metal Evap
|
||
|
AIT1_8mm, // Tape - 8mm Sony AIT1
|
||
|
DLT, // Tape - DLT Compact IIIxt, IV
|
||
|
NCTP, // Tape - Philips NCTP
|
||
|
IBM_3480, // Tape - IBM 3480
|
||
|
IBM_3490E, // Tape - IBM 3490E
|
||
|
IBM_Magstar_3590, // Tape - IBM Magstar 3590
|
||
|
IBM_Magstar_MP, // Tape - IBM Magstar MP
|
||
|
STK_DATA_D3, // Tape - STK Data D3
|
||
|
SONY_DTF, // Tape - Sony DTF
|
||
|
DV_6mm, // Tape - 6mm Digital Video
|
||
|
DMI, // Tape - Exabyte DMI and compatibles
|
||
|
SONY_D2, // Tape - Sony D2S and D2L
|
||
|
CLEANER_CARTRIDGE, // Cleaner - All Drive types that support Drive Cleaners
|
||
|
CD_ROM, // Opt_Disk - CD
|
||
|
CD_R, // Opt_Disk - CD-Recordable (Write Once)
|
||
|
CD_RW, // Opt_Disk - CD-Rewriteable
|
||
|
DVD_ROM, // Opt_Disk - DVD-ROM
|
||
|
DVD_R, // Opt_Disk - DVD-Recordable (Write Once)
|
||
|
DVD_RW, // Opt_Disk - DVD-Rewriteable
|
||
|
MO_3_RW, // Opt_Disk - 3.5" Rewriteable MO Disk
|
||
|
MO_5_WO, // Opt_Disk - MO 5.25" Write Once
|
||
|
MO_5_RW, // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
|
||
|
MO_5_LIMDOW, // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
|
||
|
PC_5_WO, // Opt_Disk - Phase Change 5.25" Write Once Optical
|
||
|
PC_5_RW, // Opt_Disk - Phase Change 5.25" Rewriteable
|
||
|
PD_5_RW, // Opt_Disk - PhaseChange Dual Rewriteable
|
||
|
ABL_5_WO, // Opt_Disk - Ablative 5.25" Write Once Optical
|
||
|
PINNACLE_APEX_5_RW, // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
|
||
|
SONY_12_WO, // Opt_Disk - Sony 12" Write Once
|
||
|
PHILIPS_12_WO, // Opt_Disk - Philips/LMS 12" Write Once
|
||
|
HITACHI_12_WO, // Opt_Disk - Hitachi 12" Write Once
|
||
|
CYGNET_12_WO, // Opt_Disk - Cygnet/ATG 12" Write Once
|
||
|
KODAK_14_WO, // Opt_Disk - Kodak 14" Write Once
|
||
|
MO_NFR_525, // Opt_Disk - Near Field Recording (Terastor)
|
||
|
NIKON_12_RW, // Opt_Disk - Nikon 12" Rewriteable
|
||
|
IOMEGA_ZIP, // Mag_Disk - Iomega Zip
|
||
|
IOMEGA_JAZ, // Mag_Disk - Iomega Jaz
|
||
|
SYQUEST_EZ135, // Mag_Disk - Syquest EZ135
|
||
|
SYQUEST_EZFLYER, // Mag_Disk - Syquest EzFlyer
|
||
|
SYQUEST_SYJET, // Mag_Disk - Syquest SyJet
|
||
|
AVATAR_F2, // Mag_Disk - 2.5" Floppy
|
||
|
MP2_8mm, // Tape - 8mm Hitachi
|
||
|
DST_S, // Ampex DST Small Tapes
|
||
|
DST_M, // Ampex DST Medium Tapes
|
||
|
DST_L, // Ampex DST Large Tapes
|
||
|
VXATape_1, // Ecrix 8mm Tape
|
||
|
VXATape_2, // Ecrix 8mm Tape
|
||
|
STK_EAGLE, // STK Eagle
|
||
|
LTO_Ultrium, // IBM, HP, Seagate LTO Ultrium
|
||
|
LTO_Accelis // IBM, HP, Seagate LTO Accelis
|
||
|
} STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
|
||
|
|
||
|
#define MEDIA_ERASEABLE 0x00000001
|
||
|
#define MEDIA_WRITE_ONCE 0x00000002
|
||
|
#define MEDIA_READ_ONLY 0x00000004
|
||
|
#define MEDIA_READ_WRITE 0x00000008
|
||
|
|
||
|
#define MEDIA_WRITE_PROTECTED 0x00000100
|
||
|
#define MEDIA_CURRENTLY_MOUNTED 0x80000000
|
||
|
|
||
|
//
|
||
|
// Define the different storage bus types
|
||
|
// Bus types below 128 (0x80) are reserved for Microsoft use
|
||
|
//
|
||
|
|
||
|
typedef enum _STORAGE_BUS_TYPE {
|
||
|
BusTypeUnknown = 0x00,
|
||
|
BusTypeScsi,
|
||
|
BusTypeAtapi,
|
||
|
BusTypeAta,
|
||
|
BusType1394,
|
||
|
BusTypeSsa,
|
||
|
BusTypeFibre,
|
||
|
BusTypeUsb,
|
||
|
BusTypeRAID,
|
||
|
BusTypeMaxReserved = 0x7F
|
||
|
} STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
|
||
|
|
||
|
typedef struct _DEVICE_MEDIA_INFO {
|
||
|
union {
|
||
|
struct {
|
||
|
LARGE_INTEGER Cylinders;
|
||
|
STORAGE_MEDIA_TYPE MediaType;
|
||
|
DWORD TracksPerCylinder;
|
||
|
DWORD SectorsPerTrack;
|
||
|
DWORD BytesPerSector;
|
||
|
DWORD NumberMediaSides;
|
||
|
DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
|
||
|
} DiskInfo;
|
||
|
|
||
|
struct {
|
||
|
LARGE_INTEGER Cylinders;
|
||
|
STORAGE_MEDIA_TYPE MediaType;
|
||
|
DWORD TracksPerCylinder;
|
||
|
DWORD SectorsPerTrack;
|
||
|
DWORD BytesPerSector;
|
||
|
DWORD NumberMediaSides;
|
||
|
DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
|
||
|
} RemovableDiskInfo;
|
||
|
|
||
|
struct {
|
||
|
STORAGE_MEDIA_TYPE MediaType;
|
||
|
DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
|
||
|
DWORD CurrentBlockSize;
|
||
|
STORAGE_BUS_TYPE BusType;
|
||
|
|
||
|
//
|
||
|
// Bus specific information describing the medium supported.
|
||
|
//
|
||
|
|
||
|
union {
|
||
|
struct {
|
||
|
BYTE MediumType;
|
||
|
BYTE DensityCode;
|
||
|
} ScsiInformation;
|
||
|
} BusSpecificData;
|
||
|
|
||
|
} TapeInfo;
|
||
|
} DeviceSpecific;
|
||
|
} DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
|
||
|
|
||
|
typedef struct _GET_MEDIA_TYPES {
|
||
|
DWORD DeviceType; // FILE_DEVICE_XXX values
|
||
|
DWORD MediaInfoCount;
|
||
|
DEVICE_MEDIA_INFO MediaInfo[1];
|
||
|
} GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
|
||
|
|
||
|
|
||
|
//
|
||
|
// IOCTL_STORAGE_PREDICT_FAILURE
|
||
|
//
|
||
|
// input - none
|
||
|
//
|
||
|
// output - STORAGE_PREDICT_FAILURE structure
|
||
|
// PredictFailure returns zero if no failure predicted and non zero
|
||
|
// if a failure is predicted.
|
||
|
//
|
||
|
// VendorSpecific returns 512 bytes of vendor specific information
|
||
|
// if a failure is predicted
|
||
|
//
|
||
|
typedef struct _STORAGE_PREDICT_FAILURE
|
||
|
{
|
||
|
DWORD PredictFailure;
|
||
|
BYTE VendorSpecific[512];
|
||
|
} STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
|
||
|
|
||
|
// end_ntminitape
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif // _NTDDSTOR_H_
|
||
|
|
||
|
//
|
||
|
// IoControlCode values for disk devices.
|
||
|
//
|
||
|
|
||
|
#define IOCTL_DISK_BASE FILE_DEVICE_DISK
|
||
|
#define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_FORMAT_TRACKS_EX CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_HISTOGRAM_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_HISTOGRAM_DATA CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_HISTOGRAM_RESET CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_REQUEST_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define IOCTL_DISK_REQUEST_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
|
||
|
#if(_WIN32_WINNT >= 0x0400)
|
||
|
#define IOCTL_DISK_CONTROLLER_NUMBER CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
//
|
||
|
// IOCTL support for SMART drive fault prediction.
|
||
|
//
|
||
|
|
||
|
#define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
|
||
|
|
||
|
#endif /* _WIN32_WINNT >= 0x0400 */
|
||
|
|
||
|
#if(_WIN32_WINNT >= 0x0500)
|
||
|
#define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_GROW_PARTITION CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
|
||
|
#define IOCTL_DISK_GET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_SET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
|
||
|
#define IOCTL_DISK_DELETE_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
|
||
|
//
|
||
|
// Special IOCTLs needed to support PC-98 machines in Japan
|
||
|
//
|
||
|
|
||
|
#define IOCTL_DISK_FORMAT_DRIVE CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||
|
#define IOCTL_DISK_SENSE_DEVICE CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
#endif /* _WIN32_WINNT >= 0x0500 */
|
||
|
|
||
|
//
|
||
|
// The following device control codes are common for all class drivers. The
|
||
|
// functions codes defined here must match all of the other class drivers.
|
||
|
//
|
||
|
// Warning: these codes will be replaced in the future by equivalent
|
||
|
// IOCTL_STORAGE codes
|
||
|
//
|
||
|
|
||
|
#define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
|
||
|
//
|
||
|
// Define the partition types returnable by known disk drivers.
|
||
|
//
|
||
|
|
||
|
#define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
|
||
|
#define PARTITION_FAT_12 0x01 // 12-bit FAT entries
|
||
|
#define PARTITION_XENIX_1 0x02 // Xenix
|
||
|
#define PARTITION_XENIX_2 0x03 // Xenix
|
||
|
#define PARTITION_FAT_16 0x04 // 16-bit FAT entries
|
||
|
#define PARTITION_EXTENDED 0x05 // Extended partition entry
|
||
|
#define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
|
||
|
#define PARTITION_IFS 0x07 // IFS Partition
|
||
|
#define PARTITION_FAT32 0x0B // FAT32
|
||
|
#define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
|
||
|
#define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
|
||
|
#define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
|
||
|
#define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
|
||
|
#define PARTITION_LDM 0x42 // Logical Disk Manager partition
|
||
|
#define PARTITION_UNIX 0x63 // Unix
|
||
|
|
||
|
#define VALID_NTFT 0xC0 // NTFT uses high order bits
|
||
|
|
||
|
//
|
||
|
// The high bit of the partition type code indicates that a partition
|
||
|
// is part of an NTFT mirror or striped array.
|
||
|
//
|
||
|
|
||
|
#define PARTITION_NTFT 0x80 // NTFT partition
|
||
|
|
||
|
//
|
||
|
// The following macro is used to determine which partitions should be
|
||
|
// assigned drive letters.
|
||
|
//
|
||
|
|
||
|
//++
|
||
|
//
|
||
|
// BOOLEAN
|
||
|
// IsRecognizedPartition(
|
||
|
// IN DWORD PartitionType
|
||
|
// )
|
||
|
//
|
||
|
// Routine Description:
|
||
|
//
|
||
|
// This macro is used to determine to which partitions drive letters
|
||
|
// should be assigned.
|
||
|
//
|
||
|
// Arguments:
|
||
|
//
|
||
|
// PartitionType - Supplies the type of the partition being examined.
|
||
|
//
|
||
|
// Return Value:
|
||
|
//
|
||
|
// The return value is TRUE if the partition type is recognized,
|
||
|
// otherwise FALSE is returned.
|
||
|
//
|
||
|
//--
|
||
|
|
||
|
#define IsRecognizedPartition( PartitionType ) ( \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) || \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_16)) || \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) || \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) || \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) || \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) || \
|
||
|
((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_12) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_16) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_IFS) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_HUGE) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32_XINT13) || \
|
||
|
((PartitionType & ~PARTITION_NTFT) == PARTITION_XINT13) )
|
||
|
|
||
|
//++
|
||
|
//
|
||
|
// BOOLEAN
|
||
|
// IsContainerPartition(
|
||
|
// IN DWORD PartitionType
|
||
|
// )
|
||
|
//
|
||
|
// Routine Description:
|
||
|
//
|
||
|
// This macro is used to determine to which partition types are actually
|
||
|
// containers for other partitions (ie, extended partitions).
|
||
|
//
|
||
|
// Arguments:
|
||
|
//
|
||
|
// PartitionType - Supplies the type of the partition being examined.
|
||
|
//
|
||
|
// Return Value:
|
||
|
//
|
||
|
// The return value is TRUE if the partition type is a container,
|
||
|
// otherwise FALSE is returned.
|
||
|
//
|
||
|
//--
|
||
|
|
||
|
#define IsContainerPartition( PartitionType ) \
|
||
|
((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
|
||
|
|
||
|
//
|
||
|
// Define the media types supported by the driver.
|
||
|
//
|
||
|
|
||
|
typedef enum _MEDIA_TYPE {
|
||
|
Unknown, // Format is unknown
|
||
|
F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
|
||
|
F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
|
||
|
F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
|
||
|
F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
|
||
|
F3_720_512, // 3.5", 720KB, 512 bytes/sector
|
||
|
F5_360_512, // 5.25", 360KB, 512 bytes/sector
|
||
|
F5_320_512, // 5.25", 320KB, 512 bytes/sector
|
||
|
F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
|
||
|
F5_180_512, // 5.25", 180KB, 512 bytes/sector
|
||
|
F5_160_512, // 5.25", 160KB, 512 bytes/sector
|
||
|
RemovableMedia, // Removable media other than floppy
|
||
|
FixedMedia, // Fixed hard disk media
|
||
|
F3_120M_512, // 3.5", 120M Floppy
|
||
|
F3_640_512, // 3.5" , 640KB, 512 bytes/sector
|
||
|
F5_640_512, // 5.25", 640KB, 512 bytes/sector
|
||
|
F5_720_512, // 5.25", 720KB, 512 bytes/sector
|
||
|
F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
|
||
|
F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
|
||
|
F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
|
||
|
F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
|
||
|
F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
|
||
|
F8_256_128 // 8", 256KB, 128 bytes/sector
|
||
|
} MEDIA_TYPE, *PMEDIA_TYPE;
|
||
|
|
||
|
//
|
||
|
// Define the input buffer structure for the driver, when
|
||
|
// it is called with IOCTL_DISK_FORMAT_TRACKS.
|
||
|
//
|
||
|
|
||
|
typedef struct _FORMAT_PARAMETERS {
|
||
|
MEDIA_TYPE MediaType;
|
||
|
DWORD StartCylinderNumber;
|
||
|
DWORD EndCylinderNumber;
|
||
|
DWORD StartHeadNumber;
|
||
|
DWORD EndHeadNumber;
|
||
|
} FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
|
||
|
|
||
|
//
|
||
|
// Define the BAD_TRACK_NUMBER type. An array of elements of this type is
|
||
|
// returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
|
||
|
// what tracks were bad during formatting. The length of that array is
|
||
|
// reported in the `Information' field of the I/O Status Block.
|
||
|
//
|
||
|
|
||
|
typedef WORD BAD_TRACK_NUMBER;
|
||
|
typedef WORD *PBAD_TRACK_NUMBER;
|
||
|
|
||
|
//
|
||
|
// Define the input buffer structure for the driver, when
|
||
|
// it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
|
||
|
//
|
||
|
|
||
|
typedef struct _FORMAT_EX_PARAMETERS {
|
||
|
MEDIA_TYPE MediaType;
|
||
|
DWORD StartCylinderNumber;
|
||
|
DWORD EndCylinderNumber;
|
||
|
DWORD StartHeadNumber;
|
||
|
DWORD EndHeadNumber;
|
||
|
WORD FormatGapLength;
|
||
|
WORD SectorsPerTrack;
|
||
|
WORD SectorNumber[1];
|
||
|
} FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
|
||
|
|
||
|
//
|
||
|
// The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
|
||
|
// request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
|
||
|
// request.
|
||
|
//
|
||
|
|
||
|
typedef struct _DISK_GEOMETRY {
|
||
|
LARGE_INTEGER Cylinders;
|
||
|
MEDIA_TYPE MediaType;
|
||
|
DWORD TracksPerCylinder;
|
||
|
DWORD SectorsPerTrack;
|
||
|
DWORD BytesPerSector;
|
||
|
} DISK_GEOMETRY, *PDISK_GEOMETRY;
|
||
|
|
||
|
|
||
|
//
|
||
|
// This wmi guid returns a DISK_GEOMETRY structure
|
||
|
//
|
||
|
#define WMI_DISK_GEOMETRY_GUID { 0x25007f51, 0x57c2, 0x11d1, { 0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10 } }
|
||
|
|
||
|
|
||
|
|
||
|
//
|
||
|
// The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
|
||
|
// and an IOCTL_DISK_GET_DRIVE_LAYOUT request. It is also used in a request
|
||
|
// to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
|
||
|
//
|
||
|
|
||
|
typedef struct _PARTITION_INFORMATION {
|
||
|
LARGE_INTEGER StartingOffset;
|
||
|
LARGE_INTEGER PartitionLength;
|
||
|
DWORD HiddenSectors;
|
||
|
DWORD PartitionNumber;
|
||
|
BYTE PartitionType;
|
||
|
BOOLEAN BootIndicator;
|
||
|
BOOLEAN RecognizedPartition;
|
||
|
BOOLEAN RewritePartition;
|
||
|
} PARTITION_INFORMATION, *PPARTITION_INFORMATION;
|
||
|
|
||
|
//
|
||
|
// The following structure is used to change the partition type of a
|
||
|
// specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
|
||
|
// request.
|
||
|
//
|
||
|
|
||
|
typedef struct _SET_PARTITION_INFORMATION {
|
||
|
BYTE PartitionType;
|
||
|
} SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
|
||
|
|
||
|
//
|
||
|
// The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
|
||
|
// request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
|
||
|
//
|
||
|
|
||
|
typedef struct _DRIVE_LAYOUT_INFORMATION {
|
||
|
DWORD PartitionCount;
|
||
|
DWORD Signature;
|
||
|
PARTITION_INFORMATION PartitionEntry[1];
|
||
|
} DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
|
||
|
|
||
|
//
|
||
|
// The following structure is passed in on an IOCTL_DISK_VERIFY request.
|
||
|
// The offset and length parameters are both given in bytes.
|
||
|
//
|
||
|
|
||
|
typedef struct _VERIFY_INFORMATION {
|
||
|
LARGE_INTEGER StartingOffset;
|
||
|
DWORD Length;
|
||
|
} VERIFY_INFORMATION, *PVERIFY_INFORMATION;
|
||
|
|
||
|
//
|
||
|
// The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
|
||
|
// request.
|
||
|
//
|
||
|
|
||
|
typedef struct _REASSIGN_BLOCKS {
|
||
|
WORD Reserved;
|
||
|
WORD Count;
|
||
|
DWORD BlockNumber[1];
|
||
|
} REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
|
||
|
|
||
|
#if(_WIN32_WINNT >= 0x0400)
|
||
|
//
|
||
|
// IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
|
||
|
// number for the handle. This is used to determine if a disk
|
||
|
// is attached to the primary or secondary IDE controller.
|
||
|
//
|
||
|
|
||
|
typedef struct _DISK_CONTROLLER_NUMBER {
|
||
|
DWORD ControllerNumber;
|
||
|
DWORD DiskNumber;
|
||
|
} DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
|
||
|
#endif /* _WIN32_WINNT >= 0x0400 */
|
||
|
|
||
|
#if(_WIN32_WINNT >= 0x0500)
|
||
|
|
||
|
|
||
|
//
|
||
|
// IOCTL_DISK_SET_CACHE allows the caller to get or set the state of the disk
|
||
|
// read/write caches.
|
||
|
//
|
||
|
// If the structure is provided as the input buffer for the ioctl the read &
|
||
|
// write caches will be enabled or disabled depending on the parameters
|
||
|
// provided.
|
||
|
//
|
||
|
// If the structure is provided as an output buffer for the ioctl the state
|
||
|
// of the read & write caches will be returned. If both input and outut buffers
|
||
|
// are provided the output buffer will contain the cache state BEFORE any
|
||
|
// changes are made
|
||
|
//
|
||
|
|
||
|
typedef enum {
|
||
|
EqualPriority,
|
||
|
KeepPrefetchedData,
|
||
|
KeepReadData
|
||
|
} DISK_CACHE_RETENTION_PRIORITY;
|
||
|
|
||
|
|
||
|
typedef struct _DISK_CACHE_INFORMATION {
|
||
|
|
||
|
//
|
||
|
// on return indicates that the device is capable of saving any parameters
|
||
|
// in non-volatile storage. On send indicates that the device should
|
||
|
// save the state in non-volatile storage.
|
||
|
//
|
||
|
|
||
|
BOOLEAN ParametersSavable;
|
||
|
|
||
|
//
|
||
|
// Indicates whether the write and read caches are enabled.
|
||
|
//
|
||
|
|
||
|
BOOLEAN ReadCacheEnabled;
|
||
|
BOOLEAN WriteCacheEnabled;
|
||
|
|
||
|
//
|
||
|
// Controls the likelyhood of data remaining in the cache depending on how
|
||
|
// it got there. Data cached from a READ or WRITE operation may be given
|
||
|
// higher, lower or equal priority to data entered into the cache for other
|
||
|
// means (like prefetch)
|
||
|
//
|
||
|
|
||
|
DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority;
|
||
|
DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority;
|
||
|
|
||
|
//
|
||
|
// Requests for a larger number of blocks than this may have prefetching
|
||
|
// disabled. If this value is set to 0 prefetch will be disabled.
|
||
|
//
|
||
|
|
||
|
WORD DisablePrefetchTransferLength;
|
||
|
|
||
|
//
|
||
|
// If TRUE then ScalarPrefetch (below) will be valid. If FALSE then
|
||
|
// the minimum and maximum values should be treated as a block count
|
||
|
// (BlockPrefetch)
|
||
|
//
|
||
|
|
||
|
BOOLEAN PrefetchScalar;
|
||
|
|
||
|
//
|
||
|
// Contains the minimum and maximum amount of data which will be
|
||
|
// will be prefetched into the cache on a disk operation. This value
|
||
|
// may either be a scalar multiplier of the transfer length of the request,
|
||
|
// or an abolute number of disk blocks. PrefetchScalar (above) indicates
|
||
|
// which interpretation is used.
|
||
|
//
|
||
|
|
||
|
union {
|
||
|
struct {
|
||
|
WORD Minimum;
|
||
|
WORD Maximum;
|
||
|
|
||
|
//
|
||
|
// The maximum number of blocks which will be prefetched - useful
|
||
|
// with the scalar limits to set definite upper limits.
|
||
|
//
|
||
|
|
||
|
WORD MaximumBlocks;
|
||
|
} ScalarPrefetch;
|
||
|
|
||
|
struct {
|
||
|
WORD Minimum;
|
||
|
WORD Maximum;
|
||
|
} BlockPrefetch;
|
||
|
};
|
||
|
|
||
|
} DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION;
|
||
|
|
||
|
//
|
||
|
// IOCTL_DISK_GROW_PARTITION will update the size of a partition
|
||
|
// by adding sectors to the length. The number of sectors must be
|
||
|
// predetermined by examining PARTITION_INFORMATION.
|
||
|
//
|
||
|
|
||
|
typedef struct _DISK_GROW_PARTITION {
|
||
|
DWORD PartitionNumber;
|
||
|
LARGE_INTEGER BytesToGrow;
|
||
|
} DISK_GROW_PARTITION, *PDISK_GROW_PARTITION;
|
||
|
#endif /* _WIN32_WINNT >= 0x0500 */
|
||
|
|
||
|
///////////////////////////////////////////////////////
|
||
|
// //
|
||
|
// The following structures define disk performance //
|
||
|
// statistics: specifically the locations of all the //
|
||
|
// reads and writes which have occured on the disk. //
|
||
|
// //
|
||
|
// To use these structures, you must issue an IOCTL_ //
|
||
|
// DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to //
|
||
|
// obtain the basic histogram information. The //
|
||
|
// number of buckets which must allocated is part of //
|
||
|
// this structure. Allocate the required number of //
|
||
|
// buckets and call an IOCTL_DISK_HIST_DATA to fill //
|
||
|
// in the data //
|
||
|
// //
|
||
|
///////////////////////////////////////////////////////
|
||
|
|
||
|
#define HIST_NO_OF_BUCKETS 24
|
||
|
|
||
|
typedef struct _HISTOGRAM_BUCKET {
|
||
|
DWORD Reads;
|
||
|
DWORD Writes;
|
||
|
} HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
|
||
|
|
||
|
#define HISTOGRAM_BUCKET_SIZE sizeof(HISTOGRAM_BUCKET)
|
||
|
|
||
|
typedef struct _DISK_HISTOGRAM {
|
||
|
LARGE_INTEGER DiskSize;
|
||
|
LARGE_INTEGER Start;
|
||
|
LARGE_INTEGER End;
|
||
|
LARGE_INTEGER Average;
|
||
|
LARGE_INTEGER AverageRead;
|
||
|
LARGE_INTEGER AverageWrite;
|
||
|
DWORD Granularity;
|
||
|
DWORD Size;
|
||
|
DWORD ReadCount;
|
||
|
DWORD WriteCount;
|
||
|
PHISTOGRAM_BUCKET Histogram;
|
||
|
} DISK_HISTOGRAM, *PDISK_HISTOGRAM;
|
||
|
|
||
|
#define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
|
||
|
|
||
|
///////////////////////////////////////////////////////
|
||
|
// //
|
||
|
// The following structures define disk debugging //
|
||
|
// capabilities. The IOCTLs are directed to one of //
|
||
|
// the two disk filter drivers. //
|
||
|
// //
|
||
|
// DISKPERF is a utilty for collecting disk request //
|
||
|
// statistics. //
|
||
|
// //
|
||
|
// SIMBAD is a utility for injecting faults in //
|
||
|
// IO requests to disks. //
|
||
|
// //
|
||
|
///////////////////////////////////////////////////////
|
||
|
|
||
|
//
|
||
|
// The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
|
||
|
// request. This ioctl collects summary disk request statistics used
|
||
|
// in measuring performance.
|
||
|
//
|
||
|
|
||
|
typedef struct _DISK_PERFORMANCE {
|
||
|
LARGE_INTEGER BytesRead;
|
||
|
LARGE_INTEGER BytesWritten;
|
||
|
LARGE_INTEGER ReadTime;
|
||
|
LARGE_INTEGER WriteTime;
|
||
|
LARGE_INTEGER IdleTime;
|
||
|
DWORD ReadCount;
|
||
|
DWORD WriteCount;
|
||
|
DWORD QueueDepth;
|
||
|
DWORD SplitCount;
|
||
|
LARGE_INTEGER QueryTime;
|
||
|
DWORD StorageDeviceNumber;
|
||
|
WCHAR StorageManagerName[8];
|
||
|
} DISK_PERFORMANCE, *PDISK_PERFORMANCE;
|
||
|
|
||
|
//
|
||
|
// This structure defines the disk logging record. When disk logging
|
||
|
// is enabled, one of these is written to an internal buffer for each
|
||
|
// disk request.
|
||
|
//
|
||
|
|
||
|
typedef struct _DISK_RECORD {
|
||
|
LARGE_INTEGER ByteOffset;
|
||
|
LARGE_INTEGER StartTime;
|
||
|
LARGE_INTEGER EndTime;
|
||
|
PVOID VirtualAddress;
|
||
|
DWORD NumberOfBytes;
|
||
|
BYTE DeviceNumber;
|
||
|
BOOLEAN ReadRequest;
|
||
|
} DISK_RECORD, *PDISK_RECORD;
|
||
|
|
||
|
//
|
||
|
// The following structure is exchanged on an IOCTL_DISK_LOG request.
|
||
|
// Not all fields are valid with each function type.
|
||
|
//
|
||
|
|
||
|
typedef struct _DISK_LOGGING {
|
||
|
BYTE Function;
|
||
|
PVOID BufferAddress;
|
||
|
DWORD BufferSize;
|
||
|
} DISK_LOGGING, *PDISK_LOGGING;
|
||
|
|
||
|
//
|
||
|
// Disk logging functions
|
||
|
//
|
||
|
// Start disk logging. Only the Function and BufferSize fields are valid.
|
||
|
//
|
||
|
|
||
|
#define DISK_LOGGING_START 0
|
||
|
|
||
|
//
|
||
|
// Stop disk logging. Only the Function field is valid.
|
||
|
//
|
||
|
|
||
|
#define DISK_LOGGING_STOP 1
|
||
|
|
||
|
//
|
||
|
// Return disk log. All fields are valid. Data will be copied from internal
|
||
|
// buffer to buffer specified for the number of bytes requested.
|
||
|
//
|
||
|
|
||
|
#define DISK_LOGGING_DUMP 2
|
||
|
|
||
|
//
|
||
|
// DISK BINNING
|
||
|
//
|
||
|
// DISKPERF will keep counters for IO that falls in each of these ranges.
|
||
|
// The application determines the number and size of the ranges.
|
||
|
// Joe Lin wanted me to keep it flexible as possible, for instance, IO
|
||
|
// sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
|
||
|
//
|
||
|
|
||
|
#define DISK_BINNING 3
|
||
|
|
||
|
//
|
||
|
// Bin types
|
||
|
//
|
||
|
|
||
|
typedef enum _BIN_TYPES {
|
||
|
RequestSize,
|
||
|
RequestLocation
|
||
|
} BIN_TYPES;
|
||
|
|
||
|
//
|
||
|
// Bin ranges
|
||
|
//
|
||
|
|
||
|
typedef struct _BIN_RANGE {
|
||
|
LARGE_INTEGER StartValue;
|
||
|
LARGE_INTEGER Length;
|
||
|
} BIN_RANGE, *PBIN_RANGE;
|
||
|
|
||
|
//
|
||
|
// Bin definition
|
||
|
//
|
||
|
|
||
|
typedef struct _PERF_BIN {
|
||
|
DWORD NumberOfBins;
|
||
|
DWORD TypeOfBin;
|
||
|
BIN_RANGE BinsRanges[1];
|
||
|
} PERF_BIN, *PPERF_BIN ;
|
||
|
|
||
|
//
|
||
|
// Bin count
|
||
|
//
|
||
|
|
||
|
typedef struct _BIN_COUNT {
|
||
|
BIN_RANGE BinRange;
|
||
|
DWORD BinCount;
|
||
|
} BIN_COUNT, *PBIN_COUNT;
|
||
|
|
||
|
//
|
||
|
// Bin results
|
||
|
//
|
||
|
|
||
|
typedef struct _BIN_RESULTS {
|
||
|
DWORD NumberOfBins;
|
||
|
BIN_COUNT BinCounts[1];
|
||
|
} BIN_RESULTS, *PBIN_RESULTS;
|
||
|
|
||
|
#ifndef _FILESYSTEMFSCTL_
|
||
|
#define _FILESYSTEMFSCTL_
|
||
|
|
||
|
//
|
||
|
// The following is a list of the native file system fsctls followed by
|
||
|
// additional network file system fsctls. Some values have been
|
||
|
// decommissioned.
|
||
|
//
|
||
|
|
||
|
#define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||
|
#define FSCTL_READ_VOLUME_METADATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||
|
#define FSCTL_WRITE_VOLUME_METADATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||
|
|
||
|
//
|
||
|
// Structure for FSCTL_READ_VOLUME_METADATA and FSCTL_WRITE_VOLUME_METADATA.
|
||
|
//
|
||
|
|
||
|
typedef struct _FSCTL_VOLUME_METADATA {
|
||
|
DWORD ByteOffset;
|
||
|
DWORD TransferLength;
|
||
|
PVOID TransferBuffer;
|
||
|
} FSCTL_VOLUME_METADATA, *PFSCTL_VOLUME_METADATA;
|
||
|
|
||
|
#endif // _FILESYSTEMFSCTL_
|
||
|
|
||
|
|
||
|
#endif // _WINIOCTL_
|
||
|
|