Unit WinIoCtl |
------------------------------------------------------------------ IOCTL Header Port for Delphi ------------------------------------------------------------------ Based upon Microsoft's IOCTL header file in C & DEC's Modula (yes, Modula!) interface port. (c) 1998 Daniel Polistchuck ------------------------------------------------------------------ This source code is freeware, feel free to use it as you wish - either commercially or not. The author shall not be held responsible for any damage made by the use or misuse of this software material. Please, if any changes or corrections are made, send me a copy at danpol@pobox.com. ------------------------------------------------------------------ Observations: Most DeviceIOControl Functions on Fixed or Logical drives work only with Windows NT. Part of the functionality conatined here is also available to Win95/98 through the use of the function Win95IOCtl provided in this unit. At least in Windows 98, the INT 21, Subfunction 440Dh examples provided by Microsoft's SDK Help file that comes with Delphi 3.02 may cause the appearance of the dreaded "blue screen". Instead of directly coding in assembly, the developer should use the Win95IOCTL function provided here. Good Luck! P.S. The SDK Examples may be found by creating an index on the Windows API help files and searching for the 440D Keyword. ------------------------------------------------------------------ Version history: v1.0 - Added Win95IOCtl. (first public release) v0.9 - Initial port (private)
Classes |
Functions |
FSCTL_DISMOUNT_VOLUME -
FSCTL_GET_COMPRESSION -
FSCTL_LOCK_VOLUME -
FSCTL_MOUNT_DBLS_VOLUME -
FSCTL_READ_COMPRESSION -
FSCTL_SET_COMPRESSION -
FSCTL_UNLOCK_VOLUME -
FSCTL_WRITE_COMPRESSION -
IOCTL_DISK_CHECK_VERIFY - The following device control codes are common for all class
drivers.
IOCTL_DISK_EJECT_MEDIA -
IOCTL_DISK_FIND_NEW_DEVICES -
IOCTL_DISK_FORMAT_TRACKS -
IOCTL_DISK_FORMAT_TRACKS_EX -
IOCTL_DISK_GET_DRIVE_GEOMETRY -
IOCTL_DISK_GET_DRIVE_LAYOUT -
IOCTL_DISK_GET_MEDIA_TYPES -
IOCTL_DISK_GET_PARTITION_INFO -
IOCTL_DISK_HISTOGRAM_DATA -
IOCTL_DISK_HISTOGRAM_RESET -
IOCTL_DISK_HISTOGRAM_STRUCTURE -
IOCTL_DISK_IS_WRITABLE -
IOCTL_DISK_LOAD_MEDIA -
IOCTL_DISK_LOGGING -
IOCTL_DISK_MEDIA_REMOVAL -
IOCTL_DISK_PERFORMANCE -
IOCTL_DISK_REASSIGN_BLOCKS -
IOCTL_DISK_RELEASE -
IOCTL_DISK_REMOVE_DEVICE -
IOCTL_DISK_REQUEST_DATA -
IOCTL_DISK_REQUEST_STRUCTURE -
IOCTL_DISK_RESERVE -
IOCTL_DISK_SET_DRIVE_LAYOUT -
IOCTL_DISK_SET_PARTITION_INFO -
IOCTL_DISK_VERIFY -
IOCTL_SERIAL_LSRMST_INSERT -
Win95IOCTL - Win95 IOCTL
Types |
BAD_TRACK_NUMBER
BIN_COUNT
BIN_RANGE
BIN_RESULTS
BIN_TYPES
DEVICE_TYPE
DEVIOCTL_REGISTERS
DISK_GEOMETRY
DISK_HISTOGRAM
DISK_LOGGING
DISK_PERFORMANCE
DISK_RECORD
DRIVE_LAYOUT_INFORMATION
FORMAT_EX_PARAMETERS
FORMAT_PARAMETERS
HISTOGRAM_BUCKET
MEDIA_TYPE
PARTITION_INFORMATION
PBAD_TRACK_NUMBER
PBIN_COUNT
PBIN_RANGE
PBIN_RESULTS
PDEVIOCTL_REGISTERS
PDISK_GEOMETRY
PDISK_HISTOGRAM
PDISK_LOGGING
PDISK_PERFORMANCE
PDISK_RECORD
PDRIVE_LAYOUT_INFORMATION
PERF_BIN
PFORMAT_EX_PARAMETERS
PFORMAT_PARAMETERS
PHISTOGRAM_BUCKET
PMEDIA_TYPE
PPARTITION_INFORMATION
PPERF_BIN
PPREVENT_MEDIA_REMOVAL
PREASSIGN_BLOCKS
PREVENT_MEDIA_REMOVAL
PSET_PARTITION_INFORMATION
PVERIFY_INFORMATION
REASSIGN_BLOCKS
SET_PARTITION_INFORMATION
VERIFY_INFORMATION
Constants |
DISK_BINNING
DISK_HISTOGRAM_SIZE
DISK_LOGGING_DUMP
DISK_LOGGING_START
DISK_LOGGING_STOP
FILE_ANY_ACCESS
FILE_DEVICE_8042_PORT
FILE_DEVICE_BATTERY
FILE_DEVICE_BEEP
FILE_DEVICE_BUS_EXTENDER
FILE_DEVICE_CD_ROM
FILE_DEVICE_CD_ROM_FILE_SYSTEM
FILE_DEVICE_CONTROLLER
FILE_DEVICE_DATALINK
FILE_DEVICE_DFS
FILE_DEVICE_DISK
FILE_DEVICE_DISK_FILE_SYSTEM
FILE_DEVICE_FILE_SYSTEM
FILE_DEVICE_INPORT_PORT
FILE_DEVICE_KEYBOARD
FILE_DEVICE_MAILSLOT
FILE_DEVICE_MIDI_IN
FILE_DEVICE_MIDI_OUT
FILE_DEVICE_MOUSE
FILE_DEVICE_MULTI_UNC_PROVIDER
FILE_DEVICE_NAMED_PIPE
FILE_DEVICE_NETWORK
FILE_DEVICE_NETWORK_BROWSER
FILE_DEVICE_NETWORK_FILE_SYSTEM
FILE_DEVICE_NETWORK_REDIRECTOR
FILE_DEVICE_NULL
FILE_DEVICE_PARALLEL_PORT
FILE_DEVICE_PHYSICAL_NETCARD
FILE_DEVICE_PRINTER
FILE_DEVICE_SCANNER
FILE_DEVICE_SCREEN
FILE_DEVICE_SERIAL_MOUSE_PORT
FILE_DEVICE_SERIAL_PORT
FILE_DEVICE_SOUND
FILE_DEVICE_STREAMS
FILE_DEVICE_TAPE
FILE_DEVICE_TAPE_FILE_SYSTEM
FILE_DEVICE_TRANSPORT
FILE_DEVICE_UNKNOWN
FILE_DEVICE_VIDEO
FILE_DEVICE_VIRTUAL_DISK
FILE_DEVICE_WAVE_IN
FILE_DEVICE_WAVE_OUT
FILE_READ_ACCESS
FILE_READ_DATA
FILE_WRITE_ACCESS
FILE_WRITE_DATA
HISTOGRAM_BUCKET_SIZE
HIST_NO_OF_BUCKETS
IOCTL_DISK_BASE
IOCTL_USER_CODES
METHOD_BUFFERED
METHOD_IN_DIRECT
METHOD_NEITHER
METHOD_OUT_DIRECT
PARTITION_ENTRY_UNUSED
PARTITION_EXTENDED
PARTITION_FAT_12
PARTITION_FAT_16
PARTITION_HUGE
PARTITION_IFS
PARTITION_NTFT
PARTITION_PREP
PARTITION_UNIX
PARTITION_XENIX_1
PARTITION_XENIX_2
SERIAL_LSRMST_ESCAPE
SERIAL_LSRMST_LSR_DATA
SERIAL_LSRMST_LSR_NODATA
SERIAL_LSRMST_MST
VALID_NTFT
VWIN32_DIOC_DOS_IOCTL
Variables |
Functions |
The following device control codes are common for all class drivers. The functions codes defined here must match all of the other class drivers.
Types |
BAD_TRACK_NUMBER = WORDDefine 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.
BIN_COUNT = record
BinRange : BIN_RANGE;
BinCount : DWORD;
end;
BIN_RANGE = record
StartValue : TLargeInteger;
Length : TLargeInteger;
end;
BIN_RESULTS = record
NumberOfBins : DWORD;
BinCounts : ARRAY[0..0] OF BIN_COUNT;
end;
BIN_TYPES = ( RequestSize, RequestLocation );Bin types
DEVICE_TYPE = DWORD
DEVIOCTL_REGISTERS = record
reg_EBX : DWORD
reg_EDX : DWORD
reg_ECX : DWORD
reg_EAX : DWORD
reg_EDI : DWORD
reg_ESI : DWORD
reg_Flags : DWORD
end;
DISK_GEOMETRY = record
Cylinders : TLARGEINTEGER;
MediaType : MEDIA_TYPE;
TracksPerCylinder : DWORD;
SectorsPerTrack : DWORD;
BytesPerSector : DWORD;
end;
DISK_HISTOGRAM = record
DiskSize : TLargeInteger;
Start : TLargeInteger;
_End : TLargeInteger;
Average : TLargeInteger;
AverageRead : TLargeInteger;
AverageWrite : TLargeInteger;
Granularity : DWORD;
Size : DWORD;
ReadCount : DWORD;
WriteCount : DWORD;
Histogram : PHISTOGRAM_BUCKET;
end;
DISK_LOGGING = record
_Function : BYTE;
BufferAddress : Pointer;
BufferSize : DWORD;
end;
DISK_PERFORMANCE = record
BytesRead : TLargeInteger;
BytesWritten : TLargeInteger;
ReadTime : TLargeInteger;
WriteTime : TLargeInteger;
ReadCount : DWORD;
WriteCount : DWORD;
QueueDepth : DWORD;
end;
DISK_RECORD = record
ByteOffset : TLargeInteger;
StartTime : TLargeInteger;
EndTime : TLargeInteger;
VirtualAddress : Pointer;
NumberOfBytes : DWORD;
DeviceNumber : BYTE;
ReadRequest : WordBool;
end;
DRIVE_LAYOUT_INFORMATION = record
PartitionCount : DWORD;
Signature : DWORD;
PartitionEntry : ARRAY [0..0] OF PARTITION_INFORMATION;
end;
FORMAT_EX_PARAMETERS = record
MediaType : MEDIA_TYPE;
StartCylinderNumber : DWORD;
EndCylinderNumber : DWORD;
StartHeadNumber : DWORD;
EndHeadNumber : DWORD;
FormatGapLength : WORD;
SectorsPerTrack : WORD;
SectorNumber : ARRAY [0..0] OF WORD;
end;
FORMAT_PARAMETERS = record
MediaType : MEDIA_TYPE;
StartCylinderNumber : DWORD;
EndCylinderNumber : DWORD;
StartHeadNumber : DWORD;
EndHeadNumber : DWORD;
end;
HISTOGRAM_BUCKET = record
Reads : DWORD;
Writes : DWORD;
end;
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 *) );
PARTITION_INFORMATION = record
StartingOffset : TLargeInteger;
PartitionLength : TLargeInteger;
HiddenSectors : DWORD;
PartitionNumber : DWORD;
PartitionType : BYTE;
BootIndicator : WordBool;
RecognizedPartition : WordBool;
RewritePartition : WordBool;
end;
PBAD_TRACK_NUMBER = ^BAD_TRACK_NUMBER
PBIN_COUNT = ^BIN_COUNTBin count
PBIN_RANGE = ^BIN_RANGEBin ranges
PBIN_RESULTS = ^BIN_RESULTSBin results
PDEVIOCTL_REGISTERS=^DEVIOCTL_REGISTERS
PDISK_GEOMETRY = ^DISK_GEOMETRYThe 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.
PDISK_HISTOGRAM = ^DISK_HISTOGRAM
PDISK_LOGGING = ^DISK_LOGGINGThe following structure is exchanged on an
IOCTL_DISK_LOG
request.
Not all fields are valid with each function type.
PDISK_PERFORMANCE = ^DISK_PERFORMANCEThe 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.
PDISK_RECORD = ^DISK_RECORDThis structure defines the disk logging record. When disk logging is enabled, one of these is written to an internal buffer for each disk request.
PDRIVE_LAYOUT_INFORMATION = ^DRIVE_LAYOUT_INFORMATIONThe following structures is returned on an
IOCTL_DISK_GET_DRIVE_LAYOUT
request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT
request.
PERF_BIN = record
NumberOfBins : DWORD;
TypeOfBin : DWORD;
BinsRanges : ARRAY [0..0] OF BIN_RANGE;
end;
PFORMAT_EX_PARAMETERS = ^FORMAT_EX_PARAMETERSDefine the input buffer structure for the driver, when it is called with IOCTL_DISK_FORMAT_TRACKS_EX<.
PFORMAT_PARAMETERS = ^FORMAT_PARAMETERSDefine the input buffer structure for the driver, when it is called with IOCTL_DISK_FORMAT_TRACKS.
PHISTOGRAM_BUCKET = ^HISTOGRAM_BUCKET
PMEDIA_TYPE = ^MEDIA_TYPENTFT partition *) {Define the media types supported by the driver.
PPARTITION_INFORMATION = ^PARTITION_INFORMATIONThe 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
.
PPERF_BIN = ^PERF_BINBin definition
PPREVENT_MEDIA_REMOVAL = ^PREVENT_MEDIA_REMOVAL
IOCTL_DISK_MEDIA_REMOVAL
disables the mechanism on a SCSI device
that ejects media. This function may or may not be supported on
SCSI devices that support removable media. PreventMediaRemove
is TRUE
if and only if media should be prevented from being
removed.
PREASSIGN_BLOCKS = ^REASSIGN_BLOCKSThe following structure is passed in on an
IOCTL_DISK_REASSIGN_BLOCKS
request.
PREVENT_MEDIA_REMOVAL = record
PreventMediaRemoval : WordBool;
end;
PSET_PARTITION_INFORMATION = ^SET_PARTITION_INFORMATIONThe following structure is used to change the partition type of a specified disk partition using an
IOCTL_DISK_SET_PARTITION_INFO
request.
PVERIFY_INFORMATION = ^VERIFY_INFORMATIONThe following structure is passed in on an
IOCTL_DISK_VERIFY
request.
The offset and length parameters are both given in bytes.
REASSIGN_BLOCKS = record
Reserved : WORD;
Count : WORD;
BlockNumber : ARRAY [0..0] OF DWORD;
end;
SET_PARTITION_INFORMATION = record
PartitionType : BYTE;
end;
VERIFY_INFORMATION = record
StartingOffset : TLargeInteger;
Length : DWORD;
end;
Constants |
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+.
Start disk logging. Only the Function
and BufferSize
fields are
valid.
Function
field is valid.
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.
LSRMST_INSERT
mode has been turned on.
Variables |