ifdef DEFINE_GUID

DEFINE_GUID(GUID_DEVINTERFACE_DISK,		      0x53f56307, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_CDROM,		      0x53f56308, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_PARTITION,	      0x53f5630a, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_TAPE,		      0x53f5630b, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK,	      0x53f5630c, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_VOLUME,		      0x53f5630d, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER,	      0x53f56310, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY,		      0x53f56311, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER,	      0x53f56312, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT,	      0x2accfe60, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b)
DEFINE_GUID(GUID_DEVINTERFACE_VMLUN,		      0x6f416619, 0x9f29, 0x42a5, 0xb2, 0x0b, 0x37, 0xe2, 0x19, 0xca, 0x02, 0xb0)
DEFINE_GUID(GUID_DEVINTERFACE_SES,		      0x1790c9ec, 0x47d5, 0x4df3, 0xb5, 0xaf, 0x9a, 0xdf, 0x3c, 0xf2, 0x3e, 0x48)

WDI_STORAGE_PREDICT_FAILURE_DPS_GUID equ <{0xe9f2d03a, 0x747c, 0x41c2, {0xbb, 0x9a, 0x02, 0xc6, 0x2b, 0x6d, 0x5f, 0xcb}}>

DEFINE_GUID(GUID_DEVINTERFACE_HIDDEN_VOLUME,	      0x7f108a28, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62)
DEFINE_GUID(GUID_DEVINTERFACE_COMPORT,		      0x86e0d1e0, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73)
DEFINE_GUID(GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18)

DiskClassGuid		equ <GUID_DEVINTERFACE_DISK>
CdRomClassGuid		equ <GUID_DEVINTERFACE_CDROM>
PartitionClassGuid	equ <GUID_DEVINTERFACE_PARTITION>
TapeClassGuid		equ <GUID_DEVINTERFACE_TAPE>
WriteOnceDiskClassGuid	equ <GUID_DEVINTERFACE_WRITEONCEDISK>
VolumeClassGuid		equ <GUID_DEVINTERFACE_VOLUME>
MediumChangerClassGuid	equ <GUID_DEVINTERFACE_MEDIUMCHANGER>
FloppyClassGuid		equ <GUID_DEVINTERFACE_FLOPPY>
CdChangerClassGuid	equ <GUID_DEVINTERFACE_CDCHANGER>
StoragePortClassGuid	equ <GUID_DEVINTERFACE_STORAGEPORT>

HiddenVolumeClassGuid	equ <GUID_DEVINTERFACE_HIDDEN_VOLUME>

GUID_CLASS_COMPORT	equ <GUID_DEVINTERFACE_COMPORT>
GUID_SERENUM_BUS_ENUMERATOR equ <GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR>

endif

ifdef DEFINE_DEVPROPKEY

DEFINE_DEVPROPKEY(DEVPKEY_Storage_Portable,	      0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 2)
DEFINE_DEVPROPKEY(DEVPKEY_Storage_Removable_Media,    0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 3)
DEFINE_DEVPROPKEY(DEVPKEY_Storage_System_Critical,    0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 4)

endif

ifndef _WINIOCTL_
_WINIOCTL_ equ 1


ifndef _DEVIOCTL_
_DEVIOCTL_ equ 1

DEVICE_TYPE		typedef DWORD

FILE_DEVICE_BEEP	equ 0x00000001
FILE_DEVICE_CD_ROM	equ 0x00000002
FILE_DEVICE_CD_ROM_FILE_SYSTEM equ 0x00000003
FILE_DEVICE_CONTROLLER	equ 0x00000004
FILE_DEVICE_DATALINK	equ 0x00000005
FILE_DEVICE_DFS		equ 0x00000006
FILE_DEVICE_DISK	equ 0x00000007
FILE_DEVICE_DISK_FILE_SYSTEM equ 0x00000008
FILE_DEVICE_FILE_SYSTEM equ 0x00000009
FILE_DEVICE_INPORT_PORT equ 0x0000000a
FILE_DEVICE_KEYBOARD	equ 0x0000000b
FILE_DEVICE_MAILSLOT	equ 0x0000000c
FILE_DEVICE_MIDI_IN	equ 0x0000000d
FILE_DEVICE_MIDI_OUT	equ 0x0000000e
FILE_DEVICE_MOUSE	equ 0x0000000f
FILE_DEVICE_MULTI_UNC_PROVIDER equ 0x00000010
FILE_DEVICE_NAMED_PIPE	equ 0x00000011
FILE_DEVICE_NETWORK	equ 0x00000012
FILE_DEVICE_NETWORK_BROWSER equ 0x00000013
FILE_DEVICE_NETWORK_FILE_SYSTEM equ 0x00000014
FILE_DEVICE_NULL	equ 0x00000015
FILE_DEVICE_PARALLEL_PORT equ 0x00000016
FILE_DEVICE_PHYSICAL_NETCARD equ 0x00000017
FILE_DEVICE_PRINTER	equ 0x00000018
FILE_DEVICE_SCANNER	equ 0x00000019
FILE_DEVICE_SERIAL_MOUSE_PORT equ 0x0000001a
FILE_DEVICE_SERIAL_PORT equ 0x0000001b
FILE_DEVICE_SCREEN	equ 0x0000001c
FILE_DEVICE_SOUND	equ 0x0000001d
FILE_DEVICE_STREAMS	equ 0x0000001e
FILE_DEVICE_TAPE	equ 0x0000001f
FILE_DEVICE_TAPE_FILE_SYSTEM equ 0x00000020
FILE_DEVICE_TRANSPORT	equ 0x00000021
FILE_DEVICE_UNKNOWN	equ 0x00000022
FILE_DEVICE_VIDEO	equ 0x00000023
FILE_DEVICE_VIRTUAL_DISK equ 0x00000024
FILE_DEVICE_WAVE_IN	equ 0x00000025
FILE_DEVICE_WAVE_OUT	equ 0x00000026
FILE_DEVICE_8042_PORT	equ 0x00000027
FILE_DEVICE_NETWORK_REDIRECTOR equ 0x00000028
FILE_DEVICE_BATTERY	equ 0x00000029
FILE_DEVICE_BUS_EXTENDER equ 0x0000002a
FILE_DEVICE_MODEM	equ 0x0000002b
FILE_DEVICE_VDM		equ 0x0000002c
FILE_DEVICE_MASS_STORAGE equ 0x0000002d
FILE_DEVICE_SMB		equ 0x0000002e
FILE_DEVICE_KS		equ 0x0000002f
FILE_DEVICE_CHANGER	equ 0x00000030
FILE_DEVICE_SMARTCARD	equ 0x00000031
FILE_DEVICE_ACPI	equ 0x00000032
FILE_DEVICE_DVD		equ 0x00000033
FILE_DEVICE_FULLSCREEN_VIDEO equ 0x00000034
FILE_DEVICE_DFS_FILE_SYSTEM equ 0x00000035
FILE_DEVICE_DFS_VOLUME	equ 0x00000036
FILE_DEVICE_SERENUM	equ 0x00000037
FILE_DEVICE_TERMSRV	equ 0x00000038
FILE_DEVICE_KSEC	equ 0x00000039
FILE_DEVICE_FIPS	equ 0x0000003A
FILE_DEVICE_INFINIBAND	equ 0x0000003B
FILE_DEVICE_VMBUS	equ 0x0000003E
FILE_DEVICE_CRYPT_PROVIDER equ 0x0000003F
FILE_DEVICE_WPD		equ 0x00000040
FILE_DEVICE_BLUETOOTH	equ 0x00000041
FILE_DEVICE_MT_COMPOSITE equ 0x00000042
FILE_DEVICE_MT_TRANSPORT equ 0x00000043
FILE_DEVICE_BIOMETRIC	equ 0x00000044
FILE_DEVICE_PMI		equ 0x00000045
FILE_DEVICE_EHSTOR	equ 0x00000046
FILE_DEVICE_DEVAPI	equ 0x00000047
FILE_DEVICE_GPIO	equ 0x00000048
FILE_DEVICE_USBEX	equ 0x00000049
FILE_DEVICE_CONSOLE	equ 0x00000050
FILE_DEVICE_NFP		equ 0x00000051
FILE_DEVICE_SYSENV	equ 0x00000052
FILE_DEVICE_VIRTUAL_BLOCK equ 0x00000053
FILE_DEVICE_POINT_OF_SERVICE equ 0x00000054

CTL_CODE macro DeviceType, Function, Method, Access
	exitm<(((DeviceType) shl 16) or ((Access) shl 14) or ((Function) shl 2) or (Method))>
	endm

DEVICE_TYPE_FROM_CTL_CODE macro ctrlCode
	exitm<(((ctrlCode AND 0xffff0000)) SHR 16)>
	endm

METHOD_FROM_CTL_CODE macro ctrlCode
	exitm<((ctrlCode AND 3))>
	endm

METHOD_BUFFERED		equ 0
METHOD_IN_DIRECT	equ 1
METHOD_OUT_DIRECT	equ 2
METHOD_NEITHER		equ 3

METHOD_DIRECT_TO_HARDWARE equ METHOD_IN_DIRECT
METHOD_DIRECT_FROM_HARDWARE equ METHOD_OUT_DIRECT

FILE_ANY_ACCESS		equ 0
FILE_SPECIAL_ACCESS	equ FILE_ANY_ACCESS
FILE_READ_ACCESS	equ 0x0001
FILE_WRITE_ACCESS	equ 0x0002

endif


ifndef _NTDDSTOR_H_
_NTDDSTOR_H_ equ 1

IOCTL_STORAGE_BASE	equ FILE_DEVICE_MASS_STORAGE

IOCTL_STORAGE_CHECK_VERIFY equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_CHECK_VERIFY2 equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_MEDIA_REMOVAL equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_EJECT_MEDIA equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_LOAD_MEDIA equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_LOAD_MEDIA2 equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_RESERVE	equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_RELEASE	equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_FIND_NEW_DEVICES equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)

IOCTL_STORAGE_EJECTION_CONTROL equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_MCN_CONTROL equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)

IOCTL_STORAGE_GET_MEDIA_TYPES equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_GET_MEDIA_TYPES_EX equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_GET_HOTPLUG_INFO equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_SET_HOTPLUG_INFO equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

IOCTL_STORAGE_RESET_BUS equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_RESET_DEVICE equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_BREAK_RESERVATION equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_PERSISTENT_RESERVE_IN equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0406, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_PERSISTENT_RESERVE_OUT equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0407, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

IOCTL_STORAGE_GET_DEVICE_NUMBER equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_PREDICT_FAILURE equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_FAILURE_PREDICTION_CONFIG equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0441, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_READ_CAPACITY equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS)

IOCTL_STORAGE_GET_DEVICE_TELEMETRY equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0470, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_STORAGE_DEVICE_TELEMETRY_NOTIFY equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0471, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_STORAGE_DEVICE_TELEMETRY_QUERY_CAPS equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0472, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_STORAGE_GET_DEVICE_TELEMETRY_RAW equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0473, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)


IOCTL_STORAGE_QUERY_PROPERTY equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0501, METHOD_BUFFERED, FILE_WRITE_ACCESS)
IOCTL_STORAGE_GET_LB_PROVISIONING_MAP_RESOURCES equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0502, METHOD_BUFFERED, FILE_READ_ACCESS)

IOCTL_STORAGE_GET_BC_PROPERTIES equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0600, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_STORAGE_ALLOCATE_BC_STREAM equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0601, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_STORAGE_FREE_BC_STREAM equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0602, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0620, METHOD_BUFFERED, FILE_ANY_ACCESS)

IOCTL_STORAGE_START_DATA_INTEGRITY_CHECK equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0621, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_STORAGE_STOP_DATA_INTEGRITY_CHECK equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0622, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

OBSOLETE_IOCTL_STORAGE_RESET_BUS equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
OBSOLETE_IOCTL_STORAGE_RESET_DEVICE equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

IOCTL_STORAGE_ENABLE_IDLE_POWER equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0720, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_GET_IDLE_POWERUP_REASON equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0721, METHOD_BUFFERED, FILE_ANY_ACCESS)

IOCTL_STORAGE_POWER_ACTIVE equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0722, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_STORAGE_POWER_IDLE equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0723, METHOD_BUFFERED, FILE_ANY_ACCESS)

IOCTL_STORAGE_EVENT_NOTIFICATION equ CTL_CODE(IOCTL_STORAGE_BASE, 0x0724, METHOD_BUFFERED, FILE_ANY_ACCESS)

STORAGE_HOTPLUG_INFO	STRUC
Size			dd ?
MediaRemovable		BOOLEAN ?
MediaHotplug		BOOLEAN ?
DeviceHotplug		BOOLEAN ?
WriteCacheEnableOverride BOOLEAN ?
STORAGE_HOTPLUG_INFO	ENDS
PSTORAGE_HOTPLUG_INFO	typedef ptr STORAGE_HOTPLUG_INFO

STORAGE_DEVICE_NUMBER	STRUC
DeviceType		DEVICE_TYPE ?
DeviceNumber		dd ?
PartitionNumber		dd ?
STORAGE_DEVICE_NUMBER	ENDS
PSTORAGE_DEVICE_NUMBER	typedef ptr STORAGE_DEVICE_NUMBER

STORAGE_BUS_RESET_REQUEST  STRUC
PathId			db ?
STORAGE_BUS_RESET_REQUEST ENDS
PSTORAGE_BUS_RESET_REQUEST typedef ptr STORAGE_BUS_RESET_REQUEST

STORAGE_BREAK_RESERVATION_REQUEST  STRUC
Length			dd ?
unused			db ?
PathId			db ?
TargetId		db ?
Lun			db ?
STORAGE_BREAK_RESERVATION_REQUEST ENDS
PSTORAGE_BREAK_RESERVATION_REQUEST typedef ptr STORAGE_BREAK_RESERVATION_REQUEST

PREVENT_MEDIA_REMOVAL	STRUC
PreventMediaRemoval	BOOLEAN ?
PREVENT_MEDIA_REMOVAL	ENDS
PPREVENT_MEDIA_REMOVAL	typedef ptr PREVENT_MEDIA_REMOVAL

CLASS_MEDIA_CHANGE_CONTEXT  STRUC
MediaChangeCount	dd ?
NewState		dd ?
CLASS_MEDIA_CHANGE_CONTEXT ENDS
PCLASS_MEDIA_CHANGE_CONTEXT typedef ptr CLASS_MEDIA_CHANGE_CONTEXT

TAPE_STATISTICS		STRUC
Version			dd ?
Flags			dd ?
RecoveredWrites		LARGE_INTEGER <>
UnrecoveredWrites	LARGE_INTEGER <>
RecoveredReads		LARGE_INTEGER <>
UnrecoveredReads	LARGE_INTEGER <>
CompressionRatioReads	db ?
CompressionRatioWrites	db ?
TAPE_STATISTICS		ENDS
PTAPE_STATISTICS	typedef ptr TAPE_STATISTICS

RECOVERED_WRITES_VALID	equ 0x00000001
UNRECOVERED_WRITES_VALID equ 0x00000002
RECOVERED_READS_VALID	equ 0x00000004
UNRECOVERED_READS_VALID equ 0x00000008
WRITE_COMPRESSION_INFO_VALID equ 0x00000010
READ_COMPRESSION_INFO_VALID equ 0x00000020

TAPE_GET_STATISTICS	STRUC
Operation		dd ?
TAPE_GET_STATISTICS	ENDS
PTAPE_GET_STATISTICS	typedef ptr TAPE_GET_STATISTICS

TAPE_RETURN_STATISTICS	equ 0
TAPE_RETURN_ENV_INFO	equ 1
TAPE_RESET_STATISTICS	equ 2

STORAGE_MEDIA_TYPE	typedef SDWORD
DDS_4mm			equ 0x20
MiniQic			equ 1 + DDS_4mm
Travan			equ 2 + DDS_4mm
QIC			equ 3 + DDS_4mm
MP_8mm			equ 4 + DDS_4mm
AME_8mm			equ 5 + DDS_4mm
AIT1_8mm		equ 6 + DDS_4mm
DLT			equ 7 + DDS_4mm
NCTP			equ 8 + DDS_4mm
IBM_3480		equ 9 + DDS_4mm
IBM_3490E		equ 10 + DDS_4mm
IBM_Magstar_3590	equ 11 + DDS_4mm
IBM_Magstar_MP		equ 12 + DDS_4mm
STK_DATA_D3		equ 13 + DDS_4mm
SONY_DTF		equ 14 + DDS_4mm
DV_6mm			equ 15 + DDS_4mm
DMI			equ 16 + DDS_4mm
SONY_D2			equ 17 + DDS_4mm
CLEANER_CARTRIDGE	equ 18 + DDS_4mm
CD_ROM			equ 19 + DDS_4mm
CD_R			equ 20 + DDS_4mm
CD_RW			equ 21 + DDS_4mm
DVD_ROM			equ 22 + DDS_4mm
DVD_R			equ 23 + DDS_4mm
DVD_RW			equ 24 + DDS_4mm
MO_3_RW			equ 25 + DDS_4mm
MO_5_WO			equ 26 + DDS_4mm
MO_5_RW			equ 27 + DDS_4mm
MO_5_LIMDOW		equ 28 + DDS_4mm
PC_5_WO			equ 29 + DDS_4mm
PC_5_RW			equ 30 + DDS_4mm
PD_5_RW			equ 31 + DDS_4mm
ABL_5_WO		equ 32 + DDS_4mm
PINNACLE_APEX_5_RW	equ 33 + DDS_4mm
SONY_12_WO		equ 34 + DDS_4mm
PHILIPS_12_WO		equ 35 + DDS_4mm
HITACHI_12_WO		equ 36 + DDS_4mm
CYGNET_12_WO		equ 37 + DDS_4mm
KODAK_14_WO		equ 38 + DDS_4mm
MO_NFR_525		equ 39 + DDS_4mm
NIKON_12_RW		equ 40 + DDS_4mm
IOMEGA_ZIP		equ 41 + DDS_4mm
IOMEGA_JAZ		equ 42 + DDS_4mm
SYQUEST_EZ135		equ 43 + DDS_4mm
SYQUEST_EZFLYER		equ 44 + DDS_4mm
SYQUEST_SYJET		equ 45 + DDS_4mm
AVATAR_F2		equ 46 + DDS_4mm
MP2_8mm			equ 47 + DDS_4mm
DST_S			equ 48 + DDS_4mm
DST_M			equ 49 + DDS_4mm
DST_L			equ 50 + DDS_4mm
VXATape_1		equ 51 + DDS_4mm
VXATape_2		equ 52 + DDS_4mm
if (NTDDI_VERSION LT NTDDI_WINXP)
STK_EAGLE		equ 53 + DDS_4mm
else
STK_9840		equ 53 + DDS_4mm
endif
LTO_Ultrium		equ 54 + DDS_4mm
LTO_Accelis		equ 55 + DDS_4mm
DVD_RAM			equ 56 + DDS_4mm
AIT_8mm			equ 57 + DDS_4mm
ADR_1			equ 58 + DDS_4mm
ADR_2			equ 59 + DDS_4mm
STK_9940		equ 60 + DDS_4mm
SAIT			equ 61 + DDS_4mm
VXATape			equ 62 + DDS_4mm

MEDIA_ERASEABLE		equ 0x00000001
MEDIA_WRITE_ONCE	equ 0x00000002
MEDIA_READ_ONLY		equ 0x00000004
MEDIA_READ_WRITE	equ 0x00000008

MEDIA_WRITE_PROTECTED	equ 0x00000100
MEDIA_CURRENTLY_MOUNTED equ 0x80000000

STORAGE_BUS_TYPE	typedef SDWORD
BusTypeUnknown		equ 0x00
BusTypeScsi		equ 1
BusTypeAtapi		equ 2
BusTypeAta		equ 3
BusType1394		equ 4
BusTypeSsa		equ 5
BusTypeFibre		equ 6
BusTypeUsb		equ 7
BusTypeRAID		equ 8
BusTypeiScsi		equ 9
BusTypeSas		equ 10
BusTypeSata		equ 11
BusTypeSd		equ 12
BusTypeMmc		equ 13
BusTypeVirtual		equ 14
BusTypeFileBackedVirtual equ 15
BusTypeSpaces		equ 16
BusTypeNvme		equ 17
BusTypeMax		equ 18
BusTypeMaxReserved	equ 0x7F


SupportsDeviceSharing macro BusType
	if ( (BusType eq BusTypeScsi) or \
	     (BusType eq BusTypeFibre) or \
	     (BusType eq BusTypeiScsi) or \
	     (BusType eq BusTypeSas) or \
	     (BusType eq BusTypeSpaces) )
	    exitm<1>
	endif
	exitm<0>
	endm

DEVICE_MEDIA_INFO	STRUC
UNION DeviceSpecific
 STRUC DiskInfo
  Cylinders		LARGE_INTEGER <>
  MediaType		STORAGE_MEDIA_TYPE ?
  TracksPerCylinder	dd ?
  SectorsPerTrack	dd ?
  BytesPerSector	dd ?
  NumberMediaSides	dd ?
  MediaCharacteristics	dd ?
 ENDS
 STRUC RemovableDiskInfo
  Cylinders		LARGE_INTEGER <>
  MediaType		STORAGE_MEDIA_TYPE ?
  TracksPerCylinder	dd ?
  SectorsPerTrack	dd ?
  BytesPerSector	dd ?
  NumberMediaSides	dd ?
  MediaCharacteristics	dd ?
 ENDS
 STRUC TapeInfo
  MediaType		STORAGE_MEDIA_TYPE ?
  MediaCharacteristics	dd ?
  CurrentBlockSize	dd ?
  BusType		STORAGE_BUS_TYPE ?
  UNION BusSpecificData
   STRUC ScsiInformation
    MediumType		db ?
    DensityCode		db ?
   ENDS
  ENDS
 ENDS
ENDS
DEVICE_MEDIA_INFO	ENDS
PDEVICE_MEDIA_INFO	typedef ptr DEVICE_MEDIA_INFO

GET_MEDIA_TYPES		STRUC
DeviceType		dd ?
MediaInfoCount		dd ?
MediaInfo		DEVICE_MEDIA_INFO 1 dup(<>)
GET_MEDIA_TYPES		ENDS
PGET_MEDIA_TYPES	typedef ptr GET_MEDIA_TYPES

STORAGE_PREDICT_FAILURE STRUC
PredictFailure		dd ?
VendorSpecific		db 512 dup(?)
STORAGE_PREDICT_FAILURE ENDS
PSTORAGE_PREDICT_FAILURE typedef ptr STORAGE_PREDICT_FAILURE

STORAGE_FAILURE_PREDICTION_CONFIG  STRUC
Version			dd ?
Size			dd ?
Set			BOOLEAN ?
Enabled			BOOLEAN ?
Reserved		dw ?
STORAGE_FAILURE_PREDICTION_CONFIG ENDS
PSTORAGE_FAILURE_PREDICTION_CONFIG typedef ptr STORAGE_FAILURE_PREDICTION_CONFIG

STORAGE_FAILURE_PREDICTION_CONFIG_V1 equ 1

STORAGE_QUERY_TYPE	typedef SDWORD
PropertyStandardQuery	equ 0
PropertyExistsQuery	equ 1
PropertyMaskQuery	equ 2
PropertyQueryMaxDefined equ 3

STORAGE_PROPERTY_ID	typedef SDWORD
StorageDeviceProperty	equ 0
StorageAdapterProperty	equ 1
StorageDeviceIdProperty equ 2
StorageDeviceUniqueIdProperty equ 3
StorageDeviceWriteCacheProperty equ 4
StorageMiniportProperty equ 5
StorageAccessAlignmentProperty equ 6
StorageDeviceSeekPenaltyProperty equ 7
StorageDeviceTrimProperty equ 8
StorageDeviceWriteAggregationProperty equ 9
StorageDeviceDeviceTelemetryProperty equ 10
StorageDeviceLBProvisioningProperty equ 11
StorageDevicePowerProperty equ 12
StorageDeviceCopyOffloadProperty equ 13
StorageDeviceResiliencyProperty equ 14
StorageDeviceMediumProductType equ 15

STORAGE_PROPERTY_QUERY	STRUC
PropertyId		STORAGE_PROPERTY_ID ?
QueryType		STORAGE_QUERY_TYPE ?
AdditionalParameters	db 1 dup(?)
STORAGE_PROPERTY_QUERY	ENDS
PSTORAGE_PROPERTY_QUERY typedef ptr STORAGE_PROPERTY_QUERY

STORAGE_DESCRIPTOR_HEADER STRUC
Version			dd ?
Size			dd ?
STORAGE_DESCRIPTOR_HEADER ENDS
PSTORAGE_DESCRIPTOR_HEADER typedef ptr STORAGE_DESCRIPTOR_HEADER

STORAGE_DEVICE_DESCRIPTOR STRUC
Version			dd ?
Size			dd ?
DeviceType		db ?
DeviceTypeModifier	db ?
RemovableMedia		BOOLEAN ?
CommandQueueing		BOOLEAN ?
VendorIdOffset		dd ?
ProductIdOffset		dd ?
ProductRevisionOffset	dd ?
SerialNumberOffset	dd ?
BusType			STORAGE_BUS_TYPE ?
RawPropertiesLength	dd ?
RawDeviceProperties	db 1 dup(?)
STORAGE_DEVICE_DESCRIPTOR ENDS
PSTORAGE_DEVICE_DESCRIPTOR typedef ptr STORAGE_DEVICE_DESCRIPTOR

STORAGE_ADAPTER_DESCRIPTOR STRUC
Version			dd ?
Size			dd ?
MaximumTransferLength	dd ?
MaximumPhysicalPages	dd ?
AlignmentMask		dd ?
AdapterUsesPio		BOOLEAN ?
AdapterScansDown	BOOLEAN ?
CommandQueueing		BOOLEAN ?
AcceleratedTransfer	BOOLEAN ?
if (NTDDI_VERSION LT NTDDI_WINXP)
BusType			BOOLEAN ?
else
BusType			db ?
endif
BusMajorVersion		dw ?
BusMinorVersion		dw ?
if (NTDDI_VERSION GE NTDDI_WIN8)
SrbType			db ?
AddressType		db ?
endif
STORAGE_ADAPTER_DESCRIPTOR ENDS
PSTORAGE_ADAPTER_DESCRIPTOR typedef ptr STORAGE_ADAPTER_DESCRIPTOR


if (NTDDI_VERSION GE NTDDI_WIN8)

NO_SRBTYPE_ADAPTER_DESCRIPTOR_SIZE equ FIELD_OFFSET(STORAGE_ADAPTER_DESCRIPTOR, SrbType)

if NOT defined(SRB_TYPE_SCSI_REQUEST_BLOCK)
SRB_TYPE_SCSI_REQUEST_BLOCK equ 0
endif

if NOT defined(SRB_TYPE_STORAGE_REQUEST_BLOCK)
SRB_TYPE_STORAGE_REQUEST_BLOCK equ 1
endif

if NOT defined(STORAGE_ADDRESS_TYPE_BTL8)
STORAGE_ADDRESS_TYPE_BTL8 equ 0
endif

endif

STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR STRUC
Version			dd ?
Size			dd ?
BytesPerCacheLine	dd ?
BytesOffsetForCacheAlignment dd ?
BytesPerLogicalSector	dd ?
BytesPerPhysicalSector	dd ?
BytesOffsetForSectorAlignment dd ?
STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR ENDS
PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR typedef ptr STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR

STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR STRUC
Version			dd ?
Size			dd ?
MediumProductType	dd ?
STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR ENDS
PSTORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR typedef ptr STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR

STORAGE_PORT_CODE_SET	typedef SDWORD
StoragePortCodeSetReserved equ 0
StoragePortCodeSetStorport equ 1
StoragePortCodeSetSCSIport equ 2
StoragePortCodeSetSpaceport equ 3
StoragePortCodeSetATAport equ 4
StoragePortCodeSetUSBport equ 5
StoragePortCodeSetSBP2port equ 6
StoragePortCodeSetSDport equ 7

if (NTDDI_VERSION GE NTDDI_WIN8)
STORAGE_MINIPORT_DESCRIPTOR_V1_SIZE equ RTL_SIZEOF_THROUGH_FIELD(STORAGE_MINIPORT_DESCRIPTOR, IoTimeoutValue)
endif

STORAGE_MINIPORT_DESCRIPTOR  STRUC
Version			dd ?
Size			dd ?
Portdriver		STORAGE_PORT_CODE_SET ?
LUNResetSupported	BOOLEAN ?
TargetResetSupported	BOOLEAN ?
if (NTDDI_VERSION GE NTDDI_WIN8)
IoTimeoutValue		dw ?
endif
if (NTDDI_VERSION GE NTDDI_WINBLUE)
ExtraIoInfoSupported	BOOLEAN ?
Reserved0		db 3 dup(?)
Reserved1		dd ?
endif
STORAGE_MINIPORT_DESCRIPTOR ENDS
PSTORAGE_MINIPORT_DESCRIPTOR typedef ptr STORAGE_MINIPORT_DESCRIPTOR

STORAGE_IDENTIFIER_CODE_SET typedef SDWORD
StorageIdCodeSetReserved equ 0
StorageIdCodeSetBinary	equ 1
StorageIdCodeSetAscii	equ 2
StorageIdCodeSetUtf8	equ 3

STORAGE_IDENTIFIER_TYPE typedef SDWORD
StorageIdTypeVendorSpecific equ 0
StorageIdTypeVendorId	equ 1
StorageIdTypeEUI64	equ 2
StorageIdTypeFCPHName	equ 3
StorageIdTypePortRelative equ 4
StorageIdTypeTargetPortGroup equ 5
StorageIdTypeLogicalUnitGroup equ 6
StorageIdTypeMD5LogicalUnitIdentifier equ 7
StorageIdTypeScsiNameString equ 8

StorageIdTypeNAA	equ StorageIdTypeFCPHName

STORAGE_ID_NAA_FORMAT	typedef SDWORD
StorageIdNAAFormatIEEEExtended equ 2
StorageIdNAAFormatIEEERegistered equ 3
StorageIdNAAFormatIEEEERegisteredExtended equ 5

STORAGE_ASSOCIATION_TYPE typedef SDWORD
StorageIdAssocDevice	equ 0
StorageIdAssocPort	equ 1
StorageIdAssocTarget	equ 2

STORAGE_IDENTIFIER	STRUC
CodeSet			STORAGE_IDENTIFIER_CODE_SET ?
Type			STORAGE_IDENTIFIER_TYPE ?
IdentifierSize		dw ?
NextOffset		dw ?
Association		STORAGE_ASSOCIATION_TYPE ?
Identifier		db 1 dup(?)
STORAGE_IDENTIFIER	ENDS
PSTORAGE_IDENTIFIER	typedef ptr STORAGE_IDENTIFIER

STORAGE_DEVICE_ID_DESCRIPTOR STRUC
Version			dd ?
Size			dd ?
NumberOfIdentifiers	dd ?
Identifiers		db 1 dup(?)
STORAGE_DEVICE_ID_DESCRIPTOR ENDS
PSTORAGE_DEVICE_ID_DESCRIPTOR typedef ptr STORAGE_DEVICE_ID_DESCRIPTOR

DEVICE_SEEK_PENALTY_DESCRIPTOR	STRUC
Version			dd ?
Size			dd ?
IncursSeekPenalty	BOOLEAN ?
DEVICE_SEEK_PENALTY_DESCRIPTOR ENDS
PDEVICE_SEEK_PENALTY_DESCRIPTOR typedef ptr DEVICE_SEEK_PENALTY_DESCRIPTOR

DEVICE_WRITE_AGGREGATION_DESCRIPTOR  STRUC
Version			dd ?
Size			dd ?
BenefitsFromWriteAggregation BOOLEAN ?
DEVICE_WRITE_AGGREGATION_DESCRIPTOR ENDS
PDEVICE_WRITE_AGGREGATION_DESCRIPTOR typedef ptr DEVICE_WRITE_AGGREGATION_DESCRIPTOR

DEVICE_TRIM_DESCRIPTOR	STRUC
Version			dd ?
Size			dd ?
TrimEnabled		BOOLEAN ?
DEVICE_TRIM_DESCRIPTOR	ENDS
PDEVICE_TRIM_DESCRIPTOR typedef ptr DEVICE_TRIM_DESCRIPTOR

DEVICE_LB_PROVISIONING_DESCRIPTOR  STRUC
Version			dd ?
Size			dd ?
flags			db ?
;ThinProvisioningEnabled : 1 db ?
;ThinProvisioningReadZeros : 1 db ?
;AnchorSupported : 3	 db ?
;UnmapGranularityAlignmentValid : 1 db ?
;Reserved0 : 2		db ?
Reserved1		db 7 dup(?)
OptimalUnmapGranularity dd ?
UnmapGranularityAlignment dd ?
if (NTDDI_VERSION GE NTDDI_WINBLUE)
MaxUnmapLbaCount	dd ?
MaxUnmapBlockDescriptorCount dd ?
endif
DEVICE_LB_PROVISIONING_DESCRIPTOR ENDS
PDEVICE_LB_PROVISIONING_DESCRIPTOR typedef ptr DEVICE_LB_PROVISIONING_DESCRIPTOR

DEVICE_LB_PROVISIONING_DESCRIPTOR_V1_SIZE equ RTL_SIZEOF_THROUGH_FIELD(DEVICE_LB_PROVISIONING_DESCRIPTOR, UnmapGranularityAlignment)

STORAGE_LB_PROVISIONING_MAP_RESOURCES  STRUC
Size			dd ?
Version			dd ?
flags			db ?
if 0
AvailableMappingResourcesValid : 1 db ?
UsedMappingResourcesValid : 1 db ?
Reserved0 : 6		db ?
endif
Reserved1		db 3 dup(?)
flags2			db ?
if 0
AvailableMappingResourcesScope : 2 db ?
UsedMappingResourcesScope : 2 db ?
Reserved2 : 4		db ?
endif
Reserved3		db 3 dup(?)
AvailableMappingResources dd ?
UsedMappingResources	dd ?
STORAGE_LB_PROVISIONING_MAP_RESOURCES ENDS
PSTORAGE_LB_PROVISIONING_MAP_RESOURCES typedef ptr STORAGE_LB_PROVISIONING_MAP_RESOURCES

DEVICE_POWER_DESCRIPTOR	 STRUC
Version			dd ?
Size			dd ?
DeviceAttentionSupported BOOLEAN ?
AsynchronousNotificationSupported BOOLEAN ?
IdlePowerManagementEnabled BOOLEAN ?
D3ColdEnabled		BOOLEAN ?
D3ColdSupported		BOOLEAN ?
NoVerifyDuringIdlePower BOOLEAN ?
Reserved		db 2 dup(?)
IdleTimeoutInMS		dd ?
DEVICE_POWER_DESCRIPTOR ENDS
PDEVICE_POWER_DESCRIPTOR typedef ptr DEVICE_POWER_DESCRIPTOR

DEVICE_COPY_OFFLOAD_DESCRIPTOR	STRUC
Version			dd ?
Size			dd ?
MaximumTokenLifetime	dd ?
DefaultTokenLifetime	dd ?
MaximumTransferSize	dd ?
OptimalTransferCount	dd ?
MaximumDataDescriptors	dd ?
MaximumTransferLengthPerDescriptor dd ?
OptimalTransferLengthPerDescriptor dd ?
OptimalTransferLengthGranularity dw ?
Reserved		db 2 dup(?)
DEVICE_COPY_OFFLOAD_DESCRIPTOR ENDS
PDEVICE_COPY_OFFLOAD_DESCRIPTOR typedef ptr DEVICE_COPY_OFFLOAD_DESCRIPTOR

STORAGE_DEVICE_RESILIENCY_DESCRIPTOR STRUC
Version			dd ?
Size			dd ?
NameOffset		dd ?
NumberOfLogicalCopies	dd ?
NumberOfPhysicalCopies	dd ?
PhysicalDiskRedundancy	dd ?
NumberOfColumns		dd ?
Interleave		dd ?
STORAGE_DEVICE_RESILIENCY_DESCRIPTOR ENDS
PSTORAGE_DEVICE_RESILIENCY_DESCRIPTOR typedef ptr STORAGE_DEVICE_RESILIENCY_DESCRIPTOR

DeviceDsmActionFlag_NonDestructive equ 0x80000000

IsDsmActionNonDestructive macro _Action
	exitm<(_Action AND DeviceDsmActionFlag_NonDestructive)>
	endm

DEVICE_DATA_MANAGEMENT_SET_ACTION typedef DWORD

DeviceDsmAction_None	equ 0
DeviceDsmAction_Trim	equ 1
DeviceDsmAction_Notification equ ( 2 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_OffloadRead equ ( 3 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_OffloadWrite equ 4
DeviceDsmAction_Allocation equ ( 5 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_Repair	equ ( 6 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_Scrub	equ ( 7 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_DrtQuery equ ( 8 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_DrtClear equ ( 9 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_DrtDisable equ (10 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_Map	equ (12 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_RegenerateParity equ (13 OR DeviceDsmActionFlag_NonDestructive)

DeviceDsmAction_NvCache_Change_Priority equ (14 OR DeviceDsmActionFlag_NonDestructive)
DeviceDsmAction_NvCache_Evict equ (15 OR DeviceDsmActionFlag_NonDestructive)

DEVICE_DSM_FLAG_ENTIRE_DATA_SET_RANGE equ 0x00000001
DEVICE_DSM_FLAG_TRIM_NOT_FS_ALLOCATED equ 0x80000000
DEVICE_DSM_FLAG_ALLOCATION_CONSOLIDATEABLE_ONLY equ 0x40000000
DEVICE_DSM_FLAG_SCRUB_SKIP_IN_SYNC equ 0x10000000
DEVICE_DSM_FLAG_SCRUB_OUTPUT_PARITY_EXTENT equ 0x20000000
DEVICE_DSM_FLAG_REPAIR_OUTPUT_PARITY_EXTENT equ 0x20000000

DEVICE_DATA_SET_RANGE	STRUC
StartingOffset		LONGLONG ?
LengthInBytes		dd ?
DEVICE_DATA_SET_RANGE	ENDS
PDEVICE_DATA_SET_RANGE	typedef ptr DEVICE_DATA_SET_RANGE

DEVICE_MANAGE_DATA_SET_ATTRIBUTES  STRUC
Size			dd ?
Action			DEVICE_DATA_MANAGEMENT_SET_ACTION ?
Flags			dd ?
ParameterBlockOffset	dd ?
ParameterBlockLength	dd ?
DataSetRangesOffset	dd ?
DataSetRangesLength	dd ?
DEVICE_MANAGE_DATA_SET_ATTRIBUTES ENDS
PDEVICE_MANAGE_DATA_SET_ATTRIBUTES typedef ptr DEVICE_MANAGE_DATA_SET_ATTRIBUTES

DEVICE_DSM_NOTIFICATION_PARAMETERS  STRUC
Size			dd ?
Flags			dd ?
NumFileTypeIDs		dd ?
FileTypeID		GUID 1 dup(<>)
DEVICE_DSM_NOTIFICATION_PARAMETERS ENDS
PDEVICE_DSM_NOTIFICATION_PARAMETERS typedef ptr DEVICE_DSM_NOTIFICATION_PARAMETERS

DEVICE_DSM_NOTIFY_FLAG_BEGIN equ 0x00000001
DEVICE_DSM_NOTIFY_FLAG_END equ 0x00000002

DEVICE_DSM_NVCACHE_CHANGE_PRIORITY_PARAMETERS  STRUC
Size			dd ?
TargetPriority		db ?
Reserved		db 3 dup(?)
DEVICE_DSM_NVCACHE_CHANGE_PRIORITY_PARAMETERS ENDS
PDEVICE_DSM_NVCACHE_CHANGE_PRIORITY_PARAMETERS typedef ptr DEVICE_DSM_NVCACHE_CHANGE_PRIORITY_PARAMETERS

STORAGE_OFFLOAD_MAX_TOKEN_LENGTH equ 512
STORAGE_OFFLOAD_TOKEN_ID_LENGTH equ 0x1F8
STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA equ 0xFFFF0001

STORAGE_OFFLOAD_TOKEN	STRUC
TokenType		db 4 dup(?)
Reserved		db 2 dup(?)
TokenIdLength		db 2 dup(?)
UNION
 STRUC StorageOffloadZeroDataToken
  Reserved2		db STORAGE_OFFLOAD_TOKEN_ID_LENGTH dup(?)
 ENDS
 Token			db STORAGE_OFFLOAD_TOKEN_ID_LENGTH dup(?)
ENDS
STORAGE_OFFLOAD_TOKEN	ENDS
PSTORAGE_OFFLOAD_TOKEN	typedef ptr STORAGE_OFFLOAD_TOKEN

MAKE_ZERO_TOKEN macro T
	exitm<..>
	endm

IS_ZERO_TOKEN macro T
	exitm<..>
	endm

DEVICE_DSM_OFFLOAD_READ_PARAMETERS  STRUC
Flags			dd ?
TimeToLive		dd ?
Reserved		dd 2 dup(?)
DEVICE_DSM_OFFLOAD_READ_PARAMETERS ENDS
PDEVICE_DSM_OFFLOAD_READ_PARAMETERS typedef ptr DEVICE_DSM_OFFLOAD_READ_PARAMETERS

DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS  STRUC
Flags			dd ?
Reserved		dd ?
TokenOffset		dd ?
Token			STORAGE_OFFLOAD_TOKEN <>
DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS ENDS
PDEVICE_DSM_OFFLOAD_WRITE_PARAMETERS typedef ptr DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS

DEVICE_DATA_SET_REPAIR_PARAMETERS  STRUC
NumberOfRepairCopies	dd ?
SourceCopy		dd ?
RepairCopies		dd ANYSIZE_ARRAY dup(?)
DEVICE_DATA_SET_REPAIR_PARAMETERS ENDS
PDEVICE_DATA_SET_REPAIR_PARAMETERS typedef ptr DEVICE_DATA_SET_REPAIR_PARAMETERS

if (NTDDI_VERSION GE NTDDI_WINBLUE)

DEVICE_DATA_SET_LBP_STATE_PARAMETERS  STRUC
Version			dd ?
Size			dd ?
Flags			dd ?
OutputVersion		dd ?
DEVICE_DATA_SET_LBP_STATE_PARAMETERS ENDS
PDEVICE_DATA_SET_LBP_STATE_PARAMETERS typedef ptr DEVICE_DATA_SET_LBP_STATE_PARAMETERS

DEVICE_DATA_SET_LBP_STATE_PARAMETERS_VERSION_V1 equ 1

endif

DEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT  STRUC
Size			dd ?
Action			DEVICE_DATA_MANAGEMENT_SET_ACTION ?
Flags			dd ?
OperationStatus		dd ?
ExtendedError		dd ?
TargetDetailedError	dd ?
ReservedStatus		dd ?
OutputBlockOffset	dd ?
OutputBlockLength	dd ?
DEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT ENDS
PDEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT typedef ptr DEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT

DEVICE_DATA_SET_LB_PROVISIONING_STATE  STRUC
Size			dd ?
Version			dd ?
SlabSizeInBytes		dd ?
SlabOffsetDeltaInBytes	dd ?
SlabAllocationBitMapBitCount dd ?
SlabAllocationBitMapLength dd ?
SlabAllocationBitMap	dd ANYSIZE_ARRAY dup(?)
DEVICE_DATA_SET_LB_PROVISIONING_STATE ENDS
PDEVICE_DATA_SET_LB_PROVISIONING_STATE typedef ptr DEVICE_DATA_SET_LB_PROVISIONING_STATE

DEVICE_DATA_SET_LB_PROVISIONING_STATE_VERSION_V1 equ (DEVICE_DATA_SET_LB_PROVISIONING_STATE)

if (NTDDI_VERSION GE NTDDI_WINBLUE)

DEVICE_DATA_SET_LB_PROVISIONING_STATE_V2 STRUC
Size			dd ?
Version			dd ?
SlabSizeInBytes		dd ?
SlabOffsetDeltaInBytes	dd ?
SlabAllocationBitMapBitCount dd ?
SlabAllocationBitMapLength dd ?
SlabAllocationBitMap	dd ANYSIZE_ARRAY dup(?)
DEVICE_DATA_SET_LB_PROVISIONING_STATE_V2 ENDS
PDEVICE_DATA_SET_LB_PROVISIONING_STATE_V2 typedef ptr DEVICE_DATA_SET_LB_PROVISIONING_STATE_V2

DEVICE_DATA_SET_LB_PROVISIONING_STATE_VERSION_V2 equ (DEVICE_DATA_SET_LB_PROVISIONING_STATE_V2)

endif

STORAGE_OFFLOAD_READ_OUTPUT STRUC
OffloadReadFlags	dd ?
Reserved		dd ?
LengthProtected		dd ?
TokenLength		dd ?
Token			STORAGE_OFFLOAD_TOKEN <>
STORAGE_OFFLOAD_READ_OUTPUT ENDS
PSTORAGE_OFFLOAD_READ_OUTPUT typedef ptr STORAGE_OFFLOAD_READ_OUTPUT

STORAGE_OFFLOAD_READ_RANGE_TRUNCATED equ (0x0001)

STORAGE_OFFLOAD_WRITE_OUTPUT STRUC
OffloadWriteFlags	dd ?
Reserved		dd ?
LengthCopied		dd ?
STORAGE_OFFLOAD_WRITE_OUTPUT ENDS
PSTORAGE_OFFLOAD_WRITE_OUTPUT typedef ptr STORAGE_OFFLOAD_WRITE_OUTPUT

STORAGE_OFFLOAD_WRITE_RANGE_TRUNCATED equ (0x0001)
STORAGE_OFFLOAD_TOKEN_INVALID equ (0x0002)

DEVICE_DATA_SET_SCRUB_OUTPUT STRUC
BytesProcessed		dd ?
BytesRepaired		dd ?
BytesFailed		dd ?
DEVICE_DATA_SET_SCRUB_OUTPUT ENDS
PDEVICE_DATA_SET_SCRUB_OUTPUT typedef ptr DEVICE_DATA_SET_SCRUB_OUTPUT

DEVICE_DATA_SET_SCRUB_EX_OUTPUT STRUC
BytesProcessed		dd ?
BytesRepaired		dd ?
BytesFailed		dd ?
ParityExtent		DEVICE_DATA_SET_RANGE <>
DEVICE_DATA_SET_SCRUB_EX_OUTPUT ENDS
PDEVICE_DATA_SET_SCRUB_EX_OUTPUT typedef ptr DEVICE_DATA_SET_SCRUB_EX_OUTPUT

DEVICE_DATA_SET_REPAIR_OUTPUT STRUC
ParityExtent		DEVICE_DATA_SET_RANGE <>
DEVICE_DATA_SET_REPAIR_OUTPUT ENDS
PDEVICE_DATA_SET_REPAIR_OUTPUT typedef ptr DEVICE_DATA_SET_REPAIR_OUTPUT

STORAGE_GET_BC_PROPERTIES_OUTPUT STRUC
MaximumRequestsPerPeriod dd ?
MinimumPeriod		dd ?
MaximumRequestSize	dd ?
EstimatedTimePerRequest dd ?
NumOutStandingRequests	dd ?
RequestSize		dd ?
STORAGE_GET_BC_PROPERTIES_OUTPUT ENDS
PSTORAGE_GET_BC_PROPERTIES_OUTPUT typedef ptr STORAGE_GET_BC_PROPERTIES_OUTPUT

IOCTL_STORAGE_BC_VERSION equ 1

STORAGE_ALLOCATE_BC_STREAM_INPUT STRUC
Version			dd ?
RequestsPerPeriod	dd ?
Period			dd ?
RetryFailures		BOOLEAN ?
Discardable		BOOLEAN ?
Reserved1		BOOLEAN 2 dup(?)
AccessType		dd ?
AccessMode		dd ?
STORAGE_ALLOCATE_BC_STREAM_INPUT ENDS
PSTORAGE_ALLOCATE_BC_STREAM_INPUT typedef ptr STORAGE_ALLOCATE_BC_STREAM_INPUT

STORAGE_ALLOCATE_BC_STREAM_OUTPUT STRUC
RequestSize		dd ?
NumOutStandingRequests	dd ?
STORAGE_ALLOCATE_BC_STREAM_OUTPUT ENDS
PSTORAGE_ALLOCATE_BC_STREAM_OUTPUT typedef ptr STORAGE_ALLOCATE_BC_STREAM_OUTPUT

STORAGE_PRIORITY_HINT_SUPPORTED equ 0x0001

STORAGE_PRIORITY_HINT_SUPPORT  STRUC
SupportFlags		dd ?
STORAGE_PRIORITY_HINT_SUPPORT ENDS
PSTORAGE_PRIORITY_HINT_SUPPORT typedef ptr STORAGE_PRIORITY_HINT_SUPPORT

ifdef _MSC_EXTENSIONS

STORAGE_MEDIA_SERIAL_NUMBER_DATA STRUC
Reserved		dw ?
SerialNumberLength	dw ?
SerialNumber		db 0 dup(?)
STORAGE_MEDIA_SERIAL_NUMBER_DATA ENDS
PSTORAGE_MEDIA_SERIAL_NUMBER_DATA typedef ptr STORAGE_MEDIA_SERIAL_NUMBER_DATA

endif

STORAGE_READ_CAPACITY	STRUC
Version			dd ?
Size			dd ?
BlockLength		dd ?
NumberOfBlocks		LARGE_INTEGER <>
DiskLength		LARGE_INTEGER <>
STORAGE_READ_CAPACITY	ENDS
PSTORAGE_READ_CAPACITY	typedef ptr STORAGE_READ_CAPACITY

WRITE_CACHE_TYPE	typedef SDWORD
WriteCacheTypeUnknown	equ 0
WriteCacheTypeNone	equ 1
WriteCacheTypeWriteBack equ 2
WriteCacheTypeWriteThrough equ 3

WRITE_CACHE_ENABLE	typedef SDWORD
WriteCacheEnableUnknown equ 0
WriteCacheDisabled	equ 1
WriteCacheEnabled	equ 2

WRITE_CACHE_CHANGE	typedef SDWORD
WriteCacheChangeUnknown equ 0
WriteCacheNotChangeable equ 1
WriteCacheChangeable	equ 2

WRITE_THROUGH		typedef SDWORD
WriteThroughUnknown	equ 0
WriteThroughNotSupported equ 1
WriteThroughSupported	equ 2

STORAGE_WRITE_CACHE_PROPERTY STRUC
Version			dd ?
Size			dd ?
WriteCacheType		WRITE_CACHE_TYPE ?
WriteCacheEnabled	WRITE_CACHE_ENABLE ?
WriteCacheChangeable	WRITE_CACHE_CHANGE ?
WriteThroughSupported	WRITE_THROUGH ?
FlushCacheSupported	BOOLEAN ?
UserDefinedPowerProtection BOOLEAN ?
NVCacheEnabled		BOOLEAN ?
STORAGE_WRITE_CACHE_PROPERTY ENDS
PSTORAGE_WRITE_CACHE_PROPERTY typedef ptr STORAGE_WRITE_CACHE_PROPERTY

ifdef _MSC_EXTENSIONS

PERSISTENT_RESERVE_COMMAND STRUC
Version			dd ?
Size			dd ?
UNION
 STRUC PR_IN
  RECORD
   ServiceAction	db : 5 ?
   Reserved1		db : 3 ?
  ENDS
  AllocationLength	dw ?
 ENDS
 STRUC PR_OUT
  RECORD
   ServiceAction	db : 5 ?
   Reserved1		db : 3 ?
  ENDS
  RECORD
   Type			db : 4 ?
   Scope		db : 4 ?
  ENDS
  ParameterList		db 0 dup(?)
 ENDS
ENDS
PERSISTENT_RESERVE_COMMAND ENDS
PPERSISTENT_RESERVE_COMMAND typedef ptr PERSISTENT_RESERVE_COMMAND

endif

DEVICEDUMP_STRUCTURE_VERSION_V1 equ 1

DEVICEDUMP_MAX_IDSTRING equ 32
MAX_FW_BUCKET_ID_LENGTH equ 132

STORAGE_CRASH_TELEMETRY_REGKEY equ <L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\CrashControl\\StorageTelemetry">
STORAGE_DEVICE_TELEMETRY_REGKEY equ <L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Storage\\StorageTelemetry">

DEVICEDUMP_COLLECTION_TYPE typedef SDWORD
TCCollectionBugCheck	equ 1
TCCollectionApplicationRequested equ 1
TCCollectionDeviceRequested equ 2

DDUMP_FLAG_DATA_READ_FROM_DEVICE equ 0x0001

FW_ISSUEID_NO_ISSUE	equ 0x00000000
FW_ISSUEID_UNKNOWN	equ 0xFFFFFFFF

.pragma pack(push, 1)

DEVICEDUMP_SUBSECTION_POINTER STRUC
dwSize			dd ?
dwFlags			dd ?
dwOffset		dd ?
DEVICEDUMP_SUBSECTION_POINTER ENDS
PDEVICEDUMP_SUBSECTION_POINTER typedef ptr DEVICEDUMP_SUBSECTION_POINTER

DEVICEDUMP_STRUCTURE_VERSION  STRUC
dwSignature		dd ?
dwVersion		dd ?
dwSize			dd ?
DEVICEDUMP_STRUCTURE_VERSION ENDS
PDEVICEDUMP_STRUCTURE_VERSION typedef ptr DEVICEDUMP_STRUCTURE_VERSION

DEVICEDUMP_SECTION_HEADER STRUC
guidDeviceDataId	GUID <>
sOrganizationID		db 16 dup(?)
dwFirmwareRevision	dd ?
sModelNumber		db DEVICEDUMP_MAX_IDSTRING dup(?)
szDeviceManufacturingID db DEVICEDUMP_MAX_IDSTRING dup(?)
dwFlags			dd ?
bRestrictedPrivateDataVersion dd ?
dwFirmwareIssueId	dd ?
szIssueDescriptionString db MAX_FW_BUCKET_ID_LENGTH dup(?)
DEVICEDUMP_SECTION_HEADER ENDS
PDEVICEDUMP_SECTION_HEADER typedef ptr DEVICEDUMP_SECTION_HEADER

TC_PUBLIC_DEVICEDUMP_CONTENT_SMART equ 0x01
TC_PUBLIC_DEVICEDUMP_CONTENT_GPLOG equ 0x02
TC_PUBLIC_DEVICEDUMP_CONTENT_GPLOG_MAX equ 16
TC_DEVICEDUMP_SUBSECTION_DESC_LENGTH equ 16

TC_PUBLIC_DATA_TYPE_ATAGP equ <"ATAGPLogPages">
TC_PUBLIC_DATA_TYPE_ATASMART equ <"ATASMARTPages">

GP_LOG_PAGE_DESCRIPTOR	STRUC
LogAddress		dw ?
LogSectors		dw ?
GP_LOG_PAGE_DESCRIPTOR	ENDS
PGP_LOG_PAGE_DESCRIPTOR typedef ptr GP_LOG_PAGE_DESCRIPTOR

DEVICEDUMP_PUBLIC_SUBSECTION STRUC
dwFlags			dd ?
GPLogTable		GP_LOG_PAGE_DESCRIPTOR TC_PUBLIC_DEVICEDUMP_CONTENT_GPLOG_MAX dup(<>)
szDescription		sbyte TC_DEVICEDUMP_SUBSECTION_DESC_LENGTH dup(?)
bData			db ANYSIZE_ARRAY dup(?)
DEVICEDUMP_PUBLIC_SUBSECTION ENDS
PDEVICEDUMP_PUBLIC_SUBSECTION typedef ptr DEVICEDUMP_PUBLIC_SUBSECTION

DEVICEDUMP_RESTRICTED_SUBSECTION  STRUC
bData			db ANYSIZE_ARRAY dup(?)
DEVICEDUMP_RESTRICTED_SUBSECTION ENDS
PDEVICEDUMP_RESTRICTED_SUBSECTION typedef ptr DEVICEDUMP_RESTRICTED_SUBSECTION

DEVICEDUMP_PRIVATE_SUBSECTION  STRUC
dwFlags			dd ?
GPLogId			GP_LOG_PAGE_DESCRIPTOR <>
bData			db ANYSIZE_ARRAY dup(?)
DEVICEDUMP_PRIVATE_SUBSECTION ENDS
PDEVICEDUMP_PRIVATE_SUBSECTION typedef ptr DEVICEDUMP_PRIVATE_SUBSECTION

DEVICEDUMP_STORAGEDEVICE_DATA STRUC
Descriptor		DEVICEDUMP_STRUCTURE_VERSION <>
SectionHeader		DEVICEDUMP_SECTION_HEADER <>
dwBufferSize		dd ?
dwReasonForCollection	dd ?
PublicData		DEVICEDUMP_SUBSECTION_POINTER <>
RestrictedData		DEVICEDUMP_SUBSECTION_POINTER <>
PrivateData		DEVICEDUMP_SUBSECTION_POINTER <>
DEVICEDUMP_STORAGEDEVICE_DATA ENDS
PDEVICEDUMP_STORAGEDEVICE_DATA typedef ptr DEVICEDUMP_STORAGEDEVICE_DATA

CDB_SIZE		equ 16
TELEMETRY_COMMAND_SIZE	equ 16

TCRecordStorportSrbFunction equ Command[0]

DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD STRUC
Cdb			db CDB_SIZE dup(?)
Command			db TELEMETRY_COMMAND_SIZE dup(?)
StartTime		dd ?
EndTime			dd ?
OperationStatus		dd ?
OperationError		dd ?
UNION StackSpecific
 STRUC ExternalStack
  dwReserved		dd ?
 ENDS
 STRUC AtaPort
  dwAtaPortSpecific	dd ?
 ENDS
 STRUC StorPort
  SrbTag		dd ?
 ENDS
ENDS
DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD ENDS
PDEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD typedef ptr DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD

DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP STRUC
Descriptor		DEVICEDUMP_STRUCTURE_VERSION <>
dwReasonForCollection	dd ?
cDriverName		db 16 dup(?)
uiNumRecords		dd ?
RecordArray		DEVICEDUMP_STORAGESTACK_PUBLIC_STATE_RECORD ANYSIZE_ARRAY dup(<>)
DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP ENDS
PDEVICEDUMP_STORAGESTACK_PUBLIC_DUMP typedef ptr DEVICEDUMP_STORAGESTACK_PUBLIC_DUMP

.pragma pack(pop)

DEVICEDUMP_CAP_PRIVATE_SECTION equ 0x00000001
DEVICEDUMP_CAP_RESTRICTED_SECTION equ 0x00000002

STORAGE_IDLE_POWER	STRUC
Version			dd ?
Size			dd ?
flags			dd ?
;WakeCapableHint : 1	 dd ?
;D3ColdSupported : 1	 dd ?
;Reserved : 30		dd ?
D3IdleTimeout		dd ?
STORAGE_IDLE_POWER	ENDS
PSTORAGE_IDLE_POWER	typedef ptr STORAGE_IDLE_POWER

STORAGE_POWERUP_REASON_TYPE typedef SDWORD
StoragePowerupUnknown	equ 0
StoragePowerupIO	equ 1
StoragePowerupDeviceAttention equ 2

STORAGE_IDLE_POWERUP_REASON STRUC
Version			dd ?
Size			dd ?
PowerupReason		STORAGE_POWERUP_REASON_TYPE ?
STORAGE_IDLE_POWERUP_REASON ENDS
PSTORAGE_IDLE_POWERUP_REASON typedef ptr STORAGE_IDLE_POWERUP_REASON

STORAGE_IDLE_POWERUP_REASON_VERSION_V1 equ 1

STORAGE_EVENT_NOTIFICATION STRUC
Version			dd ?
Size			dd ?
Events			dd ?
STORAGE_EVENT_NOTIFICATION ENDS
PSTORAGE_EVENT_NOTIFICATION typedef ptr STORAGE_EVENT_NOTIFICATION

STORAGE_EVENT_NOTIFICATION_VERSION_V1 equ 1

STORAGE_EVENT_MEDIA_STATUS equ 0x0000000000000001
STORAGE_EVENT_DEVICE_STATUS equ 0x0000000000000002
STORAGE_EVENT_DEVICE_OPERATION equ 0x0000000000000004

STORAGE_EVENT_ALL	equ (STORAGE_EVENT_MEDIA_STATUS OR STORAGE_EVENT_DEVICE_STATUS OR STORAGE_EVENT_DEVICE_OPERATION)

READ_COPY_NUMBER_KEY	equ 0x52434e00

IsKeyReadCopyNumber macro _k
	exitm<(((_k) AND 0xFFFFFF00) EQ READ_COPY_NUMBER_KEY)>
	endm

ReadCopyNumberToKey macro _c
	exitm<(READ_COPY_NUMBER_KEY OR (_c))>
	endm
ReadCopyNumberFromKey macro _k
	exitm<((_k) AND 0x000000FF)>
	endm


endif

ifndef _NTDDDISK_H_
_NTDDDISK_H_ equ 1

include winapifamily.inc

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

IOCTL_DISK_BASE		equ FILE_DEVICE_DISK
IOCTL_DISK_GET_DRIVE_GEOMETRY equ CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_GET_PARTITION_INFO equ CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_SET_PARTITION_INFO equ CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_GET_DRIVE_LAYOUT equ CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_SET_DRIVE_LAYOUT equ CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_VERIFY	equ CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_FORMAT_TRACKS equ CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_REASSIGN_BLOCKS equ CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_PERFORMANCE	equ CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_IS_WRITABLE	equ CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_LOGGING	equ CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_FORMAT_TRACKS_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_HISTOGRAM_STRUCTURE equ CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_HISTOGRAM_DATA equ CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_HISTOGRAM_RESET equ CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_REQUEST_STRUCTURE equ CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_REQUEST_DATA equ CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_PERFORMANCE_OFF equ CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS)

if(_WIN32_WINNT GE 0x0400)
IOCTL_DISK_CONTROLLER_NUMBER equ CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)

SMART_GET_VERSION	equ CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
SMART_SEND_DRIVE_COMMAND equ CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
SMART_RCV_DRIVE_DATA	equ CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

endif

if (_WIN32_WINNT GE 0x500)
IOCTL_DISK_GET_PARTITION_INFO_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_SET_PARTITION_INFO_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_GET_DRIVE_LAYOUT_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_SET_DRIVE_LAYOUT_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_CREATE_DISK	equ CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_GET_LENGTH_INFO equ CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_GET_DRIVE_GEOMETRY_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE 0x0502)
IOCTL_DISK_REASSIGN_BLOCKS_EX equ CTL_CODE(IOCTL_DISK_BASE, 0x0029, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
endif

if(_WIN32_WINNT GE 0x0500)
IOCTL_DISK_UPDATE_DRIVE_SIZE equ CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_GROW_PARTITION equ CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_GET_CACHE_INFORMATION equ CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_SET_CACHE_INFORMATION equ CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
if (NTDDI_VERSION LT NTDDI_WS03)
IOCTL_DISK_GET_WRITE_CACHE_STATE equ CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS)
else
OBSOLETE_DISK_GET_WRITE_CACHE_STATE equ CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS)
endif
IOCTL_DISK_DELETE_DRIVE_LAYOUT equ CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_UPDATE_PROPERTIES equ CTL_CODE(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_FORMAT_DRIVE equ CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_DISK_SENSE_DEVICE equ CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

IOCTL_DISK_CHECK_VERIFY equ CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_MEDIA_REMOVAL equ CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_EJECT_MEDIA	equ CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_LOAD_MEDIA	equ CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_RESERVE	equ CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_RELEASE	equ CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_FIND_NEW_DEVICES equ CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_DISK_GET_MEDIA_TYPES equ CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)

PARTITION_ENTRY_UNUSED	equ 0x00
PARTITION_FAT_12	equ 0x01
PARTITION_XENIX_1	equ 0x02
PARTITION_XENIX_2	equ 0x03
PARTITION_FAT_16	equ 0x04
PARTITION_EXTENDED	equ 0x05
PARTITION_HUGE		equ 0x06
PARTITION_IFS		equ 0x07
PARTITION_OS2BOOTMGR	equ 0x0A
PARTITION_FAT32		equ 0x0B
PARTITION_FAT32_XINT13	equ 0x0C
PARTITION_XINT13	equ 0x0E
PARTITION_XINT13_EXTENDED equ 0x0F
PARTITION_PREP		equ 0x41
PARTITION_LDM		equ 0x42
PARTITION_UNIX		equ 0x63
PARTITION_SPACES	equ 0xE7

VALID_NTFT		equ 0xC0

PARTITION_NTFT		equ 0x80

if (NTDDI_VERSION LT NTDDI_VISTA)

IsRecognizedPartition proto fastcall :UCHAR {
    xor eax,eax
    and dl,not 0xC0
    .if ((cl & PARTITION_NTFT) && ( \
	(dl == PARTITION_HUGE)		|| \
	(dl == PARTITION_IFS)		|| \
	(dl == PARTITION_FAT32)		|| \
	(dl == PARTITION_FAT32_XINT13)) || \
	(cl == PARTITION_FAT_12)	|| \
	(cl == PARTITION_FAT_16)	|| \
	(cl == PARTITION_HUGE)		|| \
	(cl == PARTITION_IFS)		|| \
	(cl == PARTITION_FAT32)		|| \
	(cl == PARTITION_FAT32_XINT13)	|| \
	(cl == PARTITION_XINT13) )
	inc eax
    .endif
    }
else
IsRecognizedPartition proto fastcall :UCHAR {
    xor eax,eax
    .if((cl == PARTITION_FAT_12)	|| \
	(cl == PARTITION_FAT_16)	|| \
	(cl == PARTITION_HUGE)		|| \
	(cl == PARTITION_IFS)		|| \
	(cl == PARTITION_FAT32)		|| \
	(cl == PARTITION_FAT32_XINT13)	|| \
	(cl == PARTITION_XINT13))
	inc eax
    .endif
    }
endif

IsContainerPartition macro PartitionType
	exitm<((PartitionType eq PARTITION_EXTENDED) or (PartitionType eq PARTITION_XINT13_EXTENDED))>
	endm

IsFTPartition macro PartitionType
	exitm<..>
	endm

MEDIA_TYPE		typedef SDWORD
Unknown			equ 0
F5_1Pt2_512		equ 1
F3_1Pt44_512		equ 2
F3_2Pt88_512		equ 3
F3_20Pt8_512		equ 4
F3_720_512		equ 5
F5_360_512		equ 6
F5_320_512		equ 7
F5_320_1024		equ 8
F5_180_512		equ 9
F5_160_512		equ 10
RemovableMedia		equ 11
FixedMedia		equ 12
F3_120M_512		equ 13
F3_640_512		equ 14
F5_640_512		equ 15
F5_720_512		equ 16
F3_1Pt2_512		equ 17
F3_1Pt23_1024		equ 18
F5_1Pt23_1024		equ 19
F3_128Mb_512		equ 20
F3_230Mb_512		equ 21
F8_256_128		equ 22
F3_200Mb_512		equ 23
F3_240M_512		equ 24
F3_32M_512		equ 25

FORMAT_PARAMETERS	STRUC
MediaType		MEDIA_TYPE ?
StartCylinderNumber	dd ?
EndCylinderNumber	dd ?
StartHeadNumber		dd ?
EndHeadNumber		dd ?
FORMAT_PARAMETERS	ENDS
PFORMAT_PARAMETERS	typedef ptr FORMAT_PARAMETERS

BAD_TRACK_NUMBER	typedef WORD
PBAD_TRACK_NUMBER	typedef ptr WORD

FORMAT_EX_PARAMETERS	STRUC
MediaType		MEDIA_TYPE ?
StartCylinderNumber	dd ?
EndCylinderNumber	dd ?
StartHeadNumber		dd ?
EndHeadNumber		dd ?
FormatGapLength		dw ?
SectorsPerTrack		dw ?
SectorNumber		dw 1 dup(?)
FORMAT_EX_PARAMETERS	ENDS
PFORMAT_EX_PARAMETERS	typedef ptr FORMAT_EX_PARAMETERS

DISK_GEOMETRY		STRUC
Cylinders		LARGE_INTEGER <>
MediaType		MEDIA_TYPE ?
TracksPerCylinder	dd ?
SectorsPerTrack		dd ?
BytesPerSector		dd ?
DISK_GEOMETRY		ENDS
PDISK_GEOMETRY		typedef ptr DISK_GEOMETRY

WMI_DISK_GEOMETRY_GUID	equ <{ 0x25007f51, 0x57c2, 0x11d1, { 0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10 } }>

PARTITION_INFORMATION	STRUC
StartingOffset		LARGE_INTEGER <>
PartitionLength		LARGE_INTEGER <>
HiddenSectors		dd ?
PartitionNumber		dd ?
PartitionType		db ?
BootIndicator		BOOLEAN ?
RecognizedPartition	BOOLEAN ?
RewritePartition	BOOLEAN ?
PARTITION_INFORMATION	ENDS
PPARTITION_INFORMATION	typedef ptr PARTITION_INFORMATION

SET_PARTITION_INFORMATION  STRUC
PartitionType		db ?
SET_PARTITION_INFORMATION ENDS
PSET_PARTITION_INFORMATION typedef ptr SET_PARTITION_INFORMATION

DRIVE_LAYOUT_INFORMATION  STRUC
PartitionCount		dd ?
Signature		dd ?
PartitionEntry		PARTITION_INFORMATION 1 dup(<>)
DRIVE_LAYOUT_INFORMATION ENDS
PDRIVE_LAYOUT_INFORMATION typedef ptr DRIVE_LAYOUT_INFORMATION

VERIFY_INFORMATION	STRUC
StartingOffset		LARGE_INTEGER <>
Length			dd ?
VERIFY_INFORMATION	ENDS
PVERIFY_INFORMATION	typedef ptr VERIFY_INFORMATION

REASSIGN_BLOCKS		STRUC
Reserved		dw ?
Count			dw ?
BlockNumber		dd 1 dup(?)
REASSIGN_BLOCKS		ENDS
PREASSIGN_BLOCKS	typedef ptr REASSIGN_BLOCKS

.pragma pack(push, 1)

REASSIGN_BLOCKS_EX	STRUC
Reserved		dw ?
Count			dw ?
BlockNumber		LARGE_INTEGER 1 dup(<>)
REASSIGN_BLOCKS_EX	ENDS
PREASSIGN_BLOCKS_EX	typedef ptr REASSIGN_BLOCKS_EX
.pragma pack(pop)

if(_WIN32_WINNT GE 0x500)

PARTITION_STYLE		typedef SDWORD
PARTITION_STYLE_MBR	equ 0
PARTITION_STYLE_GPT	equ 1
PARTITION_STYLE_RAW	equ 2

PARTITION_INFORMATION_GPT STRUC
PartitionType		GUID <>
PartitionId		GUID <>
Attributes		dd ?
Name			WCHAR 36 dup(?)
PARTITION_INFORMATION_GPT ENDS
PPARTITION_INFORMATION_GPT typedef ptr PARTITION_INFORMATION_GPT

GPT_ATTRIBUTE_PLATFORM_REQUIRED equ (0x0000000000000001)
GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER equ (0x8000000000000000)
GPT_BASIC_DATA_ATTRIBUTE_HIDDEN equ (0x4000000000000000)
GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY equ (0x2000000000000000)
GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY equ (0x1000000000000000)

PARTITION_INFORMATION_MBR STRUC
PartitionType		db ?
BootIndicator		BOOLEAN ?
RecognizedPartition	BOOLEAN ?
HiddenSectors		dd ?
PARTITION_INFORMATION_MBR ENDS
PPARTITION_INFORMATION_MBR typedef ptr PARTITION_INFORMATION_MBR

SET_PARTITION_INFORMATION_MBR typedef SET_PARTITION_INFORMATION
SET_PARTITION_INFORMATION_GPT typedef PARTITION_INFORMATION_GPT

SET_PARTITION_INFORMATION_EX STRUC
PartitionStyle		PARTITION_STYLE ?
UNION
 Mbr			SET_PARTITION_INFORMATION_MBR <>
 Gpt			SET_PARTITION_INFORMATION_GPT <>
ENDS
SET_PARTITION_INFORMATION_EX ENDS
PSET_PARTITION_INFORMATION_EX typedef ptr SET_PARTITION_INFORMATION_EX

CREATE_DISK_GPT		STRUC
DiskId			GUID <>
MaxPartitionCount	dd ?
CREATE_DISK_GPT		ENDS
PCREATE_DISK_GPT	typedef ptr CREATE_DISK_GPT

CREATE_DISK_MBR		STRUC
Signature		dd ?
CREATE_DISK_MBR		ENDS
PCREATE_DISK_MBR	typedef ptr CREATE_DISK_MBR

CREATE_DISK		STRUC
PartitionStyle		PARTITION_STYLE ?
UNION
 Mbr			CREATE_DISK_MBR <>
 Gpt			CREATE_DISK_GPT <>
ENDS
CREATE_DISK		ENDS
PCREATE_DISK		typedef ptr CREATE_DISK

GET_LENGTH_INFORMATION	STRUC
Length			LARGE_INTEGER <>
GET_LENGTH_INFORMATION	ENDS
PGET_LENGTH_INFORMATION typedef ptr GET_LENGTH_INFORMATION

PARTITION_INFORMATION_EX  STRUC
PartitionStyle		PARTITION_STYLE ?
StartingOffset		LARGE_INTEGER <>
PartitionLength		LARGE_INTEGER <>
PartitionNumber		dd ?
RewritePartition	BOOLEAN ?
UNION
 Mbr			PARTITION_INFORMATION_MBR <>
 Gpt			PARTITION_INFORMATION_GPT <>
ENDS
PARTITION_INFORMATION_EX ENDS
PPARTITION_INFORMATION_EX typedef ptr PARTITION_INFORMATION_EX

DRIVE_LAYOUT_INFORMATION_GPT STRUC
DiskId			GUID <>
StartingUsableOffset	LARGE_INTEGER <>
UsableLength		LARGE_INTEGER <>
MaxPartitionCount	dd ?
DRIVE_LAYOUT_INFORMATION_GPT ENDS
PDRIVE_LAYOUT_INFORMATION_GPT typedef ptr DRIVE_LAYOUT_INFORMATION_GPT

DRIVE_LAYOUT_INFORMATION_MBR  STRUC
Signature		dd ?
DRIVE_LAYOUT_INFORMATION_MBR ENDS
PDRIVE_LAYOUT_INFORMATION_MBR typedef ptr DRIVE_LAYOUT_INFORMATION_MBR

DRIVE_LAYOUT_INFORMATION_EX  STRUC
PartitionStyle		dd ?
PartitionCount		dd ?
UNION
 Mbr			DRIVE_LAYOUT_INFORMATION_MBR <>
 Gpt			DRIVE_LAYOUT_INFORMATION_GPT <>
ENDS
PartitionEntry		PARTITION_INFORMATION_EX 1 dup(<>)
DRIVE_LAYOUT_INFORMATION_EX ENDS
PDRIVE_LAYOUT_INFORMATION_EX typedef ptr DRIVE_LAYOUT_INFORMATION_EX

endif

if(_WIN32_WINNT GE 0x0500)

DETECTION_TYPE		typedef SDWORD
DetectNone		equ 0
DetectInt13		equ 1
DetectExInt13		equ 2

DISK_INT13_INFO		STRUC
DriveSelect		dw ?
MaxCylinders		dd ?
SectorsPerTrack		dw ?
MaxHeads		dw ?
NumberDrives		dw ?
DISK_INT13_INFO		ENDS
PDISK_INT13_INFO	typedef ptr DISK_INT13_INFO

DISK_EX_INT13_INFO	STRUC
ExBufferSize		dw ?
ExFlags			dw ?
ExCylinders		dd ?
ExHeads			dd ?
ExSectorsPerTrack	dd ?
ExSectorsPerDrive	dd ?
ExSectorSize		dw ?
ExReserved		dw ?
DISK_EX_INT13_INFO	ENDS
PDISK_EX_INT13_INFO	typedef ptr DISK_EX_INT13_INFO

DISK_DETECTION_INFO	STRUC
SizeOfDetectInfo	dd ?
DetectionType		DETECTION_TYPE ?
UNION
 STRUC
  Int13			DISK_INT13_INFO <>
  ExInt13		DISK_EX_INT13_INFO <>
 ENDS
ENDS
DISK_DETECTION_INFO	ENDS
PDISK_DETECTION_INFO	typedef ptr DISK_DETECTION_INFO

DISK_PARTITION_INFO	STRUC
SizeOfPartitionInfo	dd ?
PartitionStyle		PARTITION_STYLE ?
UNION
 STRUC Mbr
  Signature		 dd ?
  CheckSum		 dd ?
 ENDS
 STRUC Gpt
  DiskId		 GUID <>
 ENDS
ENDS
DISK_PARTITION_INFO	ENDS
PDISK_PARTITION_INFO	typedef ptr DISK_PARTITION_INFO

if (NTDDI_VERSION LT NTDDI_WS03)
DiskGeometryGetPartition macro Geometry
	exitm<1>
	endm
DiskGeometryGetDetect macro Geometry
	exitm<1>
	endm
else
DiskGeometryGetPartition macro Geometry
	exitm<1>
	endm
DiskGeometryGetDetect macro Geometry
	exitm<1>
	endm
endif
DISK_GEOMETRY_EX	STRUC
Geometry		DISK_GEOMETRY <>
DiskSize		LARGE_INTEGER <>
Data			db 1 dup(?)
DISK_GEOMETRY_EX	ENDS
PDISK_GEOMETRY_EX	typedef ptr DISK_GEOMETRY_EX

endif

if(_WIN32_WINNT GE 0x0400)

DISK_CONTROLLER_NUMBER	STRUC
ControllerNumber	dd ?
DiskNumber		dd ?
DISK_CONTROLLER_NUMBER	ENDS
PDISK_CONTROLLER_NUMBER typedef ptr DISK_CONTROLLER_NUMBER
endif

if(_WIN32_WINNT GE 0x0500)

DISK_CACHE_RETENTION_PRIORITY typedef sdword
EqualPriority		equ 0
KeepPrefetchedData	equ 1
KeepReadData		equ 2

if (OSVER(NTDDI_VERSION) EQ NTDDI_WINXP)
DISK_WRITE_CACHE_STATE	typedef SDWORD
DiskWriteCacheNormal	equ 0
DiskWriteCacheForceDisable equ 1
DiskWriteCacheDisableNotSupported equ 2
endif

DISK_CACHE_INFORMATION	STRUC
ParametersSavable	BOOLEAN ?
ReadCacheEnabled	BOOLEAN ?
WriteCacheEnabled	BOOLEAN ?
ReadRetentionPriority	DISK_CACHE_RETENTION_PRIORITY ?
WriteRetentionPriority	DISK_CACHE_RETENTION_PRIORITY ?
DisablePrefetchTransferLength dw ?
PrefetchScalar		BOOLEAN ?
UNION
 STRUC ScalarPrefetch
  Minimum		dw ?
  Maximum		dw ?
  MaximumBlocks		dw ?
 ENDS
 STRUC BlockPrefetch
  Minimum		dw ?
  Maximum		dw ?
 ENDS
ENDS
DISK_CACHE_INFORMATION	ENDS
PDISK_CACHE_INFORMATION typedef ptr DISK_CACHE_INFORMATION


DISK_GROW_PARTITION	STRUC
PartitionNumber		dd ?
BytesToGrow		LARGE_INTEGER <>
DISK_GROW_PARTITION	ENDS
PDISK_GROW_PARTITION	typedef ptr DISK_GROW_PARTITION

endif

HIST_NO_OF_BUCKETS	equ 24

HISTOGRAM_BUCKET	STRUC
Reads			dd ?
Writes			dd ?
HISTOGRAM_BUCKET	ENDS
PHISTOGRAM_BUCKET	typedef ptr HISTOGRAM_BUCKET

HISTOGRAM_BUCKET_SIZE	equ HISTOGRAM_BUCKET

DISK_HISTOGRAM		STRUC
DiskSize		LARGE_INTEGER <>
Start			LARGE_INTEGER <>
_End			LARGE_INTEGER <>
Average			LARGE_INTEGER <>
AverageRead		LARGE_INTEGER <>
AverageWrite		LARGE_INTEGER <>
Granularity		dd ?
Size			dd ?
ReadCount		dd ?
WriteCount		dd ?
Histogram		PHISTOGRAM_BUCKET ?
DISK_HISTOGRAM		ENDS
PDISK_HISTOGRAM		typedef ptr DISK_HISTOGRAM

DISK_HISTOGRAM_SIZE	equ DISK_HISTOGRAM

DISK_PERFORMANCE	STRUC
BytesRead		LARGE_INTEGER <>
BytesWritten		LARGE_INTEGER <>
ReadTime		LARGE_INTEGER <>
WriteTime		LARGE_INTEGER <>
IdleTime		LARGE_INTEGER <>
ReadCount		dd ?
WriteCount		dd ?
QueueDepth		dd ?
SplitCount		dd ?
QueryTime		LARGE_INTEGER <>
StorageDeviceNumber	dd ?
StorageManagerName	WCHAR 8 dup(?)
DISK_PERFORMANCE	ENDS
PDISK_PERFORMANCE	typedef ptr DISK_PERFORMANCE

DISK_RECORD		STRUC
ByteOffset		LARGE_INTEGER <>
StartTime		LARGE_INTEGER <>
EndTime			LARGE_INTEGER <>
VirtualAddress		PVOID ?
NumberOfBytes		dd ?
DeviceNumber		db ?
ReadRequest		BOOLEAN ?
DISK_RECORD		ENDS
PDISK_RECORD		typedef ptr DISK_RECORD

DISK_LOGGING		STRUC
Function		db ?
BufferAddress		PVOID ?
BufferSize		dd ?
DISK_LOGGING		ENDS
PDISK_LOGGING		typedef ptr DISK_LOGGING

DISK_LOGGING_START	equ 0
DISK_LOGGING_STOP	equ 1
DISK_LOGGING_DUMP	equ 2
DISK_BINNING		equ 3

BIN_TYPES		typedef SDWORD
RequestSize		equ 0
RequestLocation		equ 1

BIN_RANGE		STRUC
StartValue		LARGE_INTEGER <>
Length			LARGE_INTEGER <>
BIN_RANGE		ENDS
PBIN_RANGE		typedef ptr BIN_RANGE

PERF_BIN		STRUC
NumberOfBins		dd ?
TypeOfBin		dd ?
BinsRanges		BIN_RANGE 1 dup(<>)
PERF_BIN		ENDS
PPERF_BIN		typedef ptr PERF_BIN

BIN_COUNT		STRUC
BinRange		BIN_RANGE <>
BinCount		dd ?
BIN_COUNT		ENDS
PBIN_COUNT		typedef ptr BIN_COUNT

BIN_RESULTS		STRUC
NumberOfBins		dd ?
BinCounts		BIN_COUNT 1 dup(<>)
BIN_RESULTS		ENDS
PBIN_RESULTS		typedef ptr BIN_RESULTS

if(_WIN32_WINNT GE 0x0400)

.pragma pack(push, 1)

GETVERSIONINPARAMS	STRUC
bVersion		db ?
bRevision		db ?
bReserved		db ?
bIDEDeviceMap		db ?
fCapabilities		dd ?
dwReserved		dd 4 dup(?)
GETVERSIONINPARAMS	ENDS
PGETVERSIONINPARAMS	typedef ptr GETVERSIONINPARAMS
LPGETVERSIONINPARAMS	typedef ptr GETVERSIONINPARAMS
.pragma pack(pop)

CAP_ATA_ID_CMD		equ 1
CAP_ATAPI_ID_CMD	equ 2
CAP_SMART_CMD		equ 4

.pragma pack(push, 1)

IDEREGS			STRUC
bFeaturesReg		db ?
bSectorCountReg		db ?
bSectorNumberReg	db ?
bCylLowReg		db ?
bCylHighReg		db ?
bDriveHeadReg		db ?
bCommandReg		db ?
bReserved		db ?
IDEREGS			ENDS
PIDEREGS		typedef ptr IDEREGS
LPIDEREGS		typedef ptr IDEREGS
.pragma pack(pop)

ATAPI_ID_CMD		equ 0xA1
ID_CMD			equ 0xEC
SMART_CMD		equ 0xB0

SMART_CYL_LOW		equ 0x4F
SMART_CYL_HI		equ 0xC2

.pragma pack(push, 1)

SENDCMDINPARAMS		STRUC
cBufferSize		dd ?
irDriveRegs		IDEREGS <>
bDriveNumber		db ?
bReserved		db 3 dup(?)
dwReserved		dd 4 dup(?)
bBuffer			db 1 dup(?)
SENDCMDINPARAMS		ENDS
PSENDCMDINPARAMS	typedef ptr SENDCMDINPARAMS
LPSENDCMDINPARAMS	typedef ptr SENDCMDINPARAMS
.pragma pack(pop)

.pragma pack(push, 1)

DRIVERSTATUS		STRUC
bDriverError		db ?
bIDEError		db ?
bReserved		db 2 dup(?)
dwReserved		dd 2 dup(?)
DRIVERSTATUS		ENDS
PDRIVERSTATUS		typedef ptr DRIVERSTATUS
LPDRIVERSTATUS		typedef ptr DRIVERSTATUS
.pragma pack(pop)

SMART_NO_ERROR		equ 0
SMART_IDE_ERROR		equ 1
SMART_INVALID_FLAG	equ 2
SMART_INVALID_COMMAND	equ 3
SMART_INVALID_BUFFER	equ 4
SMART_INVALID_DRIVE	equ 5
SMART_INVALID_IOCTL	equ 6
SMART_ERROR_NO_MEM	equ 7
SMART_INVALID_REGISTER	equ 8
SMART_NOT_SUPPORTED	equ 9
SMART_NO_IDE_DEVICE	equ 10

SMART_OFFLINE_ROUTINE_OFFLINE equ 0
SMART_SHORT_SELFTEST_OFFLINE equ 1
SMART_EXTENDED_SELFTEST_OFFLINE equ 2
SMART_ABORT_OFFLINE_SELFTEST equ 127
SMART_SHORT_SELFTEST_CAPTIVE equ 129
SMART_EXTENDED_SELFTEST_CAPTIVE equ 130

.pragma pack(push, 1)

SENDCMDOUTPARAMS	STRUC
cBufferSize		dd ?
DriverStatus		DRIVERSTATUS <>
bBuffer			db 1 dup(?)
SENDCMDOUTPARAMS	ENDS
PSENDCMDOUTPARAMS	typedef ptr SENDCMDOUTPARAMS
LPSENDCMDOUTPARAMS	typedef ptr SENDCMDOUTPARAMS
.pragma pack(pop)

READ_ATTRIBUTE_BUFFER_SIZE equ 512
IDENTIFY_BUFFER_SIZE	equ 512
READ_THRESHOLD_BUFFER_SIZE equ 512
SMART_LOG_SECTOR_SIZE	equ 512

READ_ATTRIBUTES		equ 0xD0
READ_THRESHOLDS		equ 0xD1
ENABLE_DISABLE_AUTOSAVE equ 0xD2
SAVE_ATTRIBUTE_VALUES	equ 0xD3
EXECUTE_OFFLINE_DIAGS	equ 0xD4
SMART_READ_LOG		equ 0xD5
SMART_WRITE_LOG		equ 0xd6
ENABLE_SMART		equ 0xD8
DISABLE_SMART		equ 0xD9
RETURN_SMART_STATUS	equ <0xDA>
ENABLE_DISABLE_AUTO_OFFLINE equ 0xDB
endif

IOCTL_DISK_GET_DISK_ATTRIBUTES equ CTL_CODE(IOCTL_DISK_BASE, 0x003c, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_DISK_SET_DISK_ATTRIBUTES equ CTL_CODE(IOCTL_DISK_BASE, 0x003d, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

DISK_ATTRIBUTE_OFFLINE	equ 0x0000000000000001
DISK_ATTRIBUTE_READ_ONLY equ 0x0000000000000002

GET_DISK_ATTRIBUTES	STRUC
Version			dd ?
Reserved1		dd ?
Attributes		dd ?
GET_DISK_ATTRIBUTES	ENDS
PGET_DISK_ATTRIBUTES	typedef ptr GET_DISK_ATTRIBUTES

SET_DISK_ATTRIBUTES	STRUC
Version			dd ?
Persist			BOOLEAN ?
Reserved1		db 3 dup(?)
Attributes		dd ?
AttributesMask		dd ?
Reserved2		dd 4 dup(?)
SET_DISK_ATTRIBUTES	ENDS
PSET_DISK_ATTRIBUTES	typedef ptr SET_DISK_ATTRIBUTES

IOCTL_DISK_RESET_SNAPSHOT_INFO equ CTL_CODE(IOCTL_DISK_BASE, 0x0084, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

endif
endif


IOCTL_CHANGER_BASE	equ FILE_DEVICE_CHANGER

IOCTL_CHANGER_GET_PARAMETERS equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_GET_STATUS equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_GET_PRODUCT_DATA equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_SET_ACCESS equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_CHANGER_GET_ELEMENT_STATUS equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_SET_POSITION equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_EXCHANGE_MEDIUM equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_MOVE_MEDIUM equ CTL_CODE(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_REINITIALIZE_TRANSPORT equ CTL_CODE(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
IOCTL_CHANGER_QUERY_VOLUME_TAGS equ CTL_CODE(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

MAX_VOLUME_ID_SIZE	equ 36
MAX_VOLUME_TEMPLATE_SIZE equ 40

VENDOR_ID_LENGTH	equ 8
PRODUCT_ID_LENGTH	equ 16
REVISION_LENGTH		equ 4
SERIAL_NUMBER_LENGTH	equ 32

ELEMENT_TYPE		typedef sdword
PELEMENT_TYPE		typedef ptr ELEMENT_TYPE
AllElements		equ 0
ChangerTransport	equ 1
ChangerSlot		equ 2
ChangerIEPort		equ 3
ChangerDrive		equ 4
ChangerDoor		equ 5
ChangerKeypad		equ 6
ChangerMaxElement	equ 7

CHANGER_ELEMENT		STRUC
ElementType		ELEMENT_TYPE ?
ElementAddress		dd ?
CHANGER_ELEMENT		ENDS
PCHANGER_ELEMENT	typedef ptr CHANGER_ELEMENT

CHANGER_ELEMENT_LIST	STRUC
Element			CHANGER_ELEMENT <>
NumberOfElements	dd ?
CHANGER_ELEMENT_LIST	ENDS
PCHANGER_ELEMENT_LIST	typedef ptr CHANGER_ELEMENT_LIST

CHANGER_BAR_CODE_SCANNER_INSTALLED equ 0x00000001
CHANGER_INIT_ELEM_STAT_WITH_RANGE equ 0x00000002
CHANGER_CLOSE_IEPORT	equ 0x00000004
CHANGER_OPEN_IEPORT	equ 0x00000008

CHANGER_STATUS_NON_VOLATILE equ 0x00000010
CHANGER_EXCHANGE_MEDIA	equ 0x00000020
CHANGER_CLEANER_SLOT	equ 0x00000040
CHANGER_LOCK_UNLOCK	equ 0x00000080

CHANGER_CARTRIDGE_MAGAZINE equ 0x00000100
CHANGER_MEDIUM_FLIP	equ 0x00000200
CHANGER_POSITION_TO_ELEMENT equ 0x00000400
CHANGER_REPORT_IEPORT_STATE equ 0x00000800

CHANGER_STORAGE_DRIVE	equ 0x00001000
CHANGER_STORAGE_IEPORT	equ 0x00002000
CHANGER_STORAGE_SLOT	equ 0x00004000
CHANGER_STORAGE_TRANSPORT equ 0x00008000

CHANGER_DRIVE_CLEANING_REQUIRED equ 0x00010000
CHANGER_PREDISMOUNT_EJECT_REQUIRED equ 0x00020000

CHANGER_CLEANER_ACCESS_NOT_VALID equ 0x00040000
CHANGER_PREMOUNT_EJECT_REQUIRED equ 0x00080000

CHANGER_VOLUME_IDENTIFICATION equ 0x00100000
CHANGER_VOLUME_SEARCH	equ 0x00200000
CHANGER_VOLUME_ASSERT	equ 0x00400000
CHANGER_VOLUME_REPLACE	equ 0x00800000
CHANGER_VOLUME_UNDEFINE equ 0x01000000

CHANGER_SERIAL_NUMBER_VALID equ 0x04000000

CHANGER_DEVICE_REINITIALIZE_CAPABLE equ 0x08000000
CHANGER_KEYPAD_ENABLE_DISABLE equ 0x10000000
CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS equ 0x20000000

CHANGER_RESERVED_BIT	equ 0x80000000

CHANGER_PREDISMOUNT_ALIGN_TO_SLOT equ 0x80000001
CHANGER_PREDISMOUNT_ALIGN_TO_DRIVE equ 0x80000002
CHANGER_CLEANER_AUTODISMOUNT equ 0x80000004
CHANGER_TRUE_EXCHANGE_CAPABLE equ 0x80000008
CHANGER_SLOTS_USE_TRAYS equ 0x80000010
CHANGER_RTN_MEDIA_TO_ORIGINAL_ADDR equ 0x80000020
CHANGER_CLEANER_OPS_NOT_SUPPORTED equ 0x80000040
CHANGER_IEPORT_USER_CONTROL_OPEN equ 0x80000080
CHANGER_IEPORT_USER_CONTROL_CLOSE equ 0x80000100
CHANGER_MOVE_EXTENDS_IEPORT equ 0x80000200
CHANGER_MOVE_RETRACTS_IEPORT equ 0x80000400

CHANGER_TO_TRANSPORT	equ 0x01
CHANGER_TO_SLOT		equ 0x02
CHANGER_TO_IEPORT	equ 0x04
CHANGER_TO_DRIVE	equ 0x08

LOCK_UNLOCK_IEPORT	equ 0x01
LOCK_UNLOCK_DOOR	equ 0x02
LOCK_UNLOCK_KEYPAD	equ 0x04

GET_CHANGER_PARAMETERS	STRUC
Size			dd ?
NumberTransportElements dw ?
NumberStorageElements	dw ?
NumberCleanerSlots	dw ?
NumberIEElements	dw ?
NumberDataTransferElements dw ?
NumberOfDoors		dw ?
FirstSlotNumber		dw ?
FirstDriveNumber	dw ?
FirstTransportNumber	dw ?
FirstIEPortNumber	dw ?
FirstCleanerSlotAddress dw ?
MagazineSize		dw ?
DriveCleanTimeout	dd ?
Features0		dd ?
Features1		dd ?
MoveFromTransport	db ?
MoveFromSlot		db ?
MoveFromIePort		db ?
MoveFromDrive		db ?
ExchangeFromTransport	db ?
ExchangeFromSlot	db ?
ExchangeFromIePort	db ?
ExchangeFromDrive	db ?
LockUnlockCapabilities	db ?
PositionCapabilities	db ?
Reserved1		db 2 dup(?)
Reserved2		dd 2 dup(?)
GET_CHANGER_PARAMETERS	ENDS
PGET_CHANGER_PARAMETERS typedef ptr GET_CHANGER_PARAMETERS

CHANGER_PRODUCT_DATA	STRUC
VendorId		db VENDOR_ID_LENGTH dup(?)
ProductId		db PRODUCT_ID_LENGTH dup(?)
Revision		db REVISION_LENGTH dup(?)
SerialNumber		db SERIAL_NUMBER_LENGTH dup(?)
DeviceType		db ?
CHANGER_PRODUCT_DATA	ENDS
PCHANGER_PRODUCT_DATA	typedef ptr CHANGER_PRODUCT_DATA

LOCK_ELEMENT		equ 0
UNLOCK_ELEMENT		equ 1
EXTEND_IEPORT		equ 2
RETRACT_IEPORT		equ 3

CHANGER_SET_ACCESS	STRUC
Element			CHANGER_ELEMENT <>
Control			dd ?
CHANGER_SET_ACCESS	ENDS
PCHANGER_SET_ACCESS	typedef ptr CHANGER_SET_ACCESS

CHANGER_READ_ELEMENT_STATUS  STRUC
ElementList		CHANGER_ELEMENT_LIST <>
VolumeTagInfo		BOOLEAN ?
CHANGER_READ_ELEMENT_STATUS ENDS
PCHANGER_READ_ELEMENT_STATUS typedef ptr CHANGER_READ_ELEMENT_STATUS

CHANGER_ELEMENT_STATUS	STRUC
Element			CHANGER_ELEMENT <>
SrcElementAddress	CHANGER_ELEMENT <>
Flags			dd ?
ExceptionCode		dd ?
TargetId		db ?
Lun			db ?
Reserved		dw ?
PrimaryVolumeID		db MAX_VOLUME_ID_SIZE dup(?)
AlternateVolumeID	db MAX_VOLUME_ID_SIZE dup(?)
CHANGER_ELEMENT_STATUS	ENDS
PCHANGER_ELEMENT_STATUS typedef ptr CHANGER_ELEMENT_STATUS

CHANGER_ELEMENT_STATUS_EX STRUC
Element			CHANGER_ELEMENT <>
SrcElementAddress	CHANGER_ELEMENT <>
Flags			dd ?
ExceptionCode		dd ?
TargetId		db ?
Lun			db ?
Reserved		dw ?
PrimaryVolumeID		db MAX_VOLUME_ID_SIZE dup(?)
AlternateVolumeID	db MAX_VOLUME_ID_SIZE dup(?)
VendorIdentification	db VENDOR_ID_LENGTH dup(?)
ProductIdentification	db PRODUCT_ID_LENGTH dup(?)
SerialNumber		db SERIAL_NUMBER_LENGTH dup(?)
CHANGER_ELEMENT_STATUS_EX ENDS
PCHANGER_ELEMENT_STATUS_EX typedef ptr CHANGER_ELEMENT_STATUS_EX

ELEMENT_STATUS_FULL	equ 0x00000001
ELEMENT_STATUS_IMPEXP	equ 0x00000002
ELEMENT_STATUS_EXCEPT	equ 0x00000004
ELEMENT_STATUS_ACCESS	equ 0x00000008
ELEMENT_STATUS_EXENAB	equ 0x00000010
ELEMENT_STATUS_INENAB	equ 0x00000020

ELEMENT_STATUS_PRODUCT_DATA equ 0x00000040

ELEMENT_STATUS_LUN_VALID equ 0x00001000
ELEMENT_STATUS_ID_VALID equ 0x00002000
ELEMENT_STATUS_NOT_BUS	equ 0x00008000
ELEMENT_STATUS_INVERT	equ 0x00400000
ELEMENT_STATUS_SVALID	equ 0x00800000

ELEMENT_STATUS_PVOLTAG	equ 0x10000000
ELEMENT_STATUS_AVOLTAG	equ 0x20000000


ERROR_LABEL_UNREADABLE	equ 0x00000001
ERROR_LABEL_QUESTIONABLE equ 0x00000002
ERROR_SLOT_NOT_PRESENT	equ 0x00000004
ERROR_DRIVE_NOT_INSTALLED equ 0x00000008
ERROR_TRAY_MALFUNCTION	equ 0x00000010
ERROR_INIT_STATUS_NEEDED equ 0x00000011
ERROR_UNHANDLED_ERROR	equ 0xFFFFFFFF

CHANGER_INITIALIZE_ELEMENT_STATUS  STRUC
ElementList		CHANGER_ELEMENT_LIST <>
BarCodeScan		BOOLEAN ?
CHANGER_INITIALIZE_ELEMENT_STATUS ENDS
PCHANGER_INITIALIZE_ELEMENT_STATUS typedef ptr CHANGER_INITIALIZE_ELEMENT_STATUS

CHANGER_SET_POSITION	STRUC
Transport		CHANGER_ELEMENT <>
Destination		CHANGER_ELEMENT <>
Flip			BOOLEAN ?
CHANGER_SET_POSITION	ENDS
PCHANGER_SET_POSITION	typedef ptr CHANGER_SET_POSITION

CHANGER_EXCHANGE_MEDIUM	 STRUC
Transport		CHANGER_ELEMENT <>
Source			CHANGER_ELEMENT <>
Destination1		CHANGER_ELEMENT <>
Destination2		CHANGER_ELEMENT <>
Flip1			BOOLEAN ?
Flip2			BOOLEAN ?
CHANGER_EXCHANGE_MEDIUM ENDS
PCHANGER_EXCHANGE_MEDIUM typedef ptr CHANGER_EXCHANGE_MEDIUM

CHANGER_MOVE_MEDIUM	STRUC
Transport		CHANGER_ELEMENT <>
Source			CHANGER_ELEMENT <>
Destination		CHANGER_ELEMENT <>
Flip			BOOLEAN ?
CHANGER_MOVE_MEDIUM	ENDS
PCHANGER_MOVE_MEDIUM	typedef ptr CHANGER_MOVE_MEDIUM

CHANGER_SEND_VOLUME_TAG_INFORMATION STRUC
StartingElement		CHANGER_ELEMENT <>
ActionCode		dd ?
VolumeIDTemplate	db MAX_VOLUME_TEMPLATE_SIZE dup(?)
CHANGER_SEND_VOLUME_TAG_INFORMATION ENDS
PCHANGER_SEND_VOLUME_TAG_INFORMATION typedef ptr CHANGER_SEND_VOLUME_TAG_INFORMATION

READ_ELEMENT_ADDRESS_INFO  STRUC
NumberOfElements	dd ?
ElementStatus		CHANGER_ELEMENT_STATUS 1 dup(<>)
READ_ELEMENT_ADDRESS_INFO ENDS
PREAD_ELEMENT_ADDRESS_INFO typedef ptr READ_ELEMENT_ADDRESS_INFO

SEARCH_ALL		equ 0x0
SEARCH_PRIMARY		equ 0x1
SEARCH_ALTERNATE	equ 0x2
SEARCH_ALL_NO_SEQ	equ 0x4
SEARCH_PRI_NO_SEQ	equ 0x5
SEARCH_ALT_NO_SEQ	equ 0x6

ASSERT_PRIMARY		equ 0x8
ASSERT_ALTERNATE	equ 0x9

REPLACE_PRIMARY		equ <0xA
REPLACE_ALTERNATE	equ 0xB

UNDEFINE_PRIMARY	equ 0xC
UNDEFINE_ALTERNATE	equ 0xD

CHANGER_DEVICE_PROBLEM_TYPE typedef SDWORD
DeviceProblemNone	equ 0
DeviceProblemHardware	equ 1
DeviceProblemCHMError	equ 2
DeviceProblemDoorOpen	equ 3
DeviceProblemCalibrationError equ 4
DeviceProblemTargetFailure equ 5
DeviceProblemCHMMoveError equ 6
DeviceProblemCHMZeroError equ 7
DeviceProblemCartridgeInsertError equ 8
DeviceProblemPositionError equ 9
DeviceProblemSensorError equ 10
DeviceProblemCartridgeEjectError equ 11
DeviceProblemGripperError equ 12
DeviceProblemDriveError equ 13

IOCTL_SERIAL_LSRMST_INSERT equ CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)

IOCTL_SERENUM_EXPOSE_HARDWARE equ CTL_CODE(FILE_DEVICE_SERENUM,128,METHOD_BUFFERED,FILE_ANY_ACCESS)
IOCTL_SERENUM_REMOVE_HARDWARE equ CTL_CODE(FILE_DEVICE_SERENUM,129,METHOD_BUFFERED,FILE_ANY_ACCESS)
IOCTL_SERENUM_PORT_DESC equ CTL_CODE(FILE_DEVICE_SERENUM,130,METHOD_BUFFERED,FILE_ANY_ACCESS)
IOCTL_SERENUM_GET_PORT_NAME equ CTL_CODE(FILE_DEVICE_SERENUM,131,METHOD_BUFFERED,FILE_ANY_ACCESS)


SERIAL_LSRMST_ESCAPE	 equ 0x00
SERIAL_LSRMST_LSR_DATA	 equ 0x01
SERIAL_LSRMST_LSR_NODATA equ 0x02
SERIAL_LSRMST_MST	 equ 0x03

SERIAL_IOC_FCR_FIFO_ENABLE equ (0x00000001)
SERIAL_IOC_FCR_RCVR_RESET equ (0x00000002)
SERIAL_IOC_FCR_XMIT_RESET equ (0x00000004)
SERIAL_IOC_FCR_DMA_MODE equ (0x00000008)
SERIAL_IOC_FCR_RES1	equ (0x00000010)
SERIAL_IOC_FCR_RES2	equ (0x00000020)
SERIAL_IOC_FCR_RCVR_TRIGGER_LSB equ (0x00000040)
SERIAL_IOC_FCR_RCVR_TRIGGER_MSB equ (0x00000080)

SERIAL_IOC_MCR_DTR	equ (0x00000001)
SERIAL_IOC_MCR_RTS	equ (0x00000002)
SERIAL_IOC_MCR_OUT1	equ (0x00000004)
SERIAL_IOC_MCR_OUT2	equ (0x00000008)
SERIAL_IOC_MCR_LOOP	equ (0x00000010)

ifndef _FILESYSTEMFSCTL_
_FILESYSTEMFSCTL_ equ 1


FSCTL_REQUEST_OPLOCK_LEVEL_1 equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  0, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_REQUEST_OPLOCK_LEVEL_2 equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  1, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_REQUEST_BATCH_OPLOCK equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  2, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_OPLOCK_BREAK_ACKNOWLEDGE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  3, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_OPBATCH_ACK_CLOSE_PENDING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  4, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_OPLOCK_BREAK_NOTIFY equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,	 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_LOCK_VOLUME	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  6, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_UNLOCK_VOLUME	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DISMOUNT_VOLUME	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_IS_VOLUME_MOUNTED equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_IS_PATHNAME_VALID equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_MARK_VOLUME_DIRTY equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_RETRIEVAL_POINTERS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_GET_COMPRESSION	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SET_COMPRESSION	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA OR FILE_WRITE_DATA)
FSCTL_SET_BOOTLOADER_ACCESSED equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19,	 METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_MARK_AS_SYSTEM_HIVE equ FSCTL_SET_BOOTLOADER_ACCESSED
FSCTL_OPLOCK_BREAK_ACK_NO_2 equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_INVALIDATE_VOLUMES equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_FAT_BPB	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_REQUEST_FILTER_OPLOCK equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_FILESYSTEM_GET_STATISTICS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)

if (_WIN32_WINNT GE _WIN32_WINNT_NT4)
FSCTL_GET_NTFS_VOLUME_DATA equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_GET_NTFS_FILE_RECORD equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_GET_VOLUME_BITMAP equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_GET_RETRIEVAL_POINTERS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28,	METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_MOVE_FILE		equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_IS_VOLUME_DIRTY	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_ALLOW_EXTENDED_DASD_IO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER,	FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)
FSCTL_FIND_FILES_BY_SID equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_SET_OBJECT_ID	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_GET_OBJECT_ID	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DELETE_OBJECT_ID	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_SET_REPARSE_POINT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_GET_REPARSE_POINT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DELETE_REPARSE_POINT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_ENUM_USN_DATA	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_SECURITY_ID_CHECK equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45,  METHOD_NEITHER, FILE_READ_DATA)
FSCTL_READ_USN_JOURNAL	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_SET_OBJECT_ID_EXTENDED equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_CREATE_OR_GET_OBJECT_ID equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SET_SPARSE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_SET_ZERO_DATA	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_QUERY_ALLOCATED_RANGES equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51,	METHOD_NEITHER, FILE_READ_DATA)
FSCTL_ENABLE_UPGRADE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_SET_ENCRYPTION	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_ENCRYPTION_FSCTL_IO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_WRITE_RAW_ENCRYPTED equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55,  METHOD_NEITHER, FILE_SPECIAL_ACCESS)
FSCTL_READ_RAW_ENCRYPTED equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56,  METHOD_NEITHER, FILE_SPECIAL_ACCESS)
FSCTL_CREATE_USN_JOURNAL equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_READ_FILE_USN_DATA equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58,  METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_WRITE_USN_CLOSE_RECORD equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59,	METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_EXTEND_VOLUME	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_USN_JOURNAL equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DELETE_USN_JOURNAL equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_MARK_HANDLE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SIS_COPYFILE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SIS_LINK_FILES	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA OR FILE_WRITE_DATA)
FSCTL_RECALL_FILE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_READ_FROM_PLEX	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA)
FSCTL_FILE_PREFETCH	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_VISTA)
FSCTL_MAKE_MEDIA_COMPATIBLE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_SET_DEFECT_MANAGEMENT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_QUERY_SPARING_INFO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_ON_DISK_VOLUME_INFO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SET_VOLUME_COMPRESSION_STATE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_TXFS_MODIFY_RM	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_QUERY_RM_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, FILE_READ_DATA)
FSCTL_TXFS_ROLLFORWARD_REDO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_ROLLFORWARD_UNDO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_START_RM	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_SHUTDOWN_RM	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_READ_BACKUP_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, FILE_READ_DATA)
FSCTL_TXFS_WRITE_BACKUP_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_CREATE_SECONDARY_RM equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_GET_METADATA_INFO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, FILE_READ_DATA)
FSCTL_TXFS_GET_TRANSACTED_VERSION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, FILE_READ_DATA)
FSCTL_TXFS_SAVEPOINT_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_CREATE_MINIVERSION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_TXFS_TRANSACTION_ACTIVE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, FILE_READ_DATA)
FSCTL_SET_ZERO_ON_DEALLOCATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_SET_REPAIR	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_GET_REPAIR	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_WAIT_FOR_REPAIR	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_INITIATE_REPAIR	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSC_INTERNAL	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_SHRINK_VOLUME	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_SET_SHORT_NAME_BEHAVIOR equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DFSR_SET_GHOST_HANDLE_STATE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS)

define FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_READ_DATA)
define FSCTL_TXFS_LIST_TRANSACTIONS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, FILE_READ_DATA)
define FSCTL_QUERY_PAGEFILE_ENCRYPTION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_VISTA)
FSCTL_RESET_VOLUME_ALLOCATION_HINTS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
FSCTL_QUERY_DEPENDENT_VOLUME equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SD_GLOBAL_CHANGE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_VISTA)
FSCTL_TXFS_READ_BACKUP_INFORMATION2 equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
FSCTL_LOOKUP_STREAM_FROM_CLUSTER equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_TXFS_WRITE_BACKUP_INFORMATION2 equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_FILE_TYPE_NOTIFICATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
FSCTL_FILE_LEVEL_TRIM	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, FILE_WRITE_DATA)
endif


if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
FSCTL_GET_BOOT_AREA_INFO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_GET_RETRIEVAL_POINTER_BASE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SET_PERSISTENT_VOLUME_STATE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_PERSISTENT_VOLUME_STATE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, FILE_ANY_ACCESS)

FSCTL_REQUEST_OPLOCK	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS)

FSCTL_CSV_TUNNEL_REQUEST equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_IS_CSV_FILE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, FILE_ANY_ACCESS)

FSCTL_QUERY_FILE_SYSTEM_RECOGNITION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_GET_VOLUME_PATH_NAME equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 150,  METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_IS_FILE_ON_CSV_VOLUME equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 151,	METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
FSCTL_CORRUPTION_HANDLING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_OFFLOAD_READ	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS)
FSCTL_OFFLOAD_WRITE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
FSCTL_CSV_INTERNAL	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 155,  METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
FSCTL_SET_PURGE_FAILURE_MODE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_FILE_LAYOUT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_IS_VOLUME_OWNED_BYCSVFS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 158,  METHOD_BUFFERED, FILE_ANY_ACCESS)

FSCTL_GET_INTEGRITY_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SET_INTEGRITY_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA OR FILE_WRITE_DATA)

FSCTL_QUERY_FILE_REGIONS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS)

endif


if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
FSCTL_DEDUP_FILE	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DEDUP_QUERY_FILE_HASHES equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 166, METHOD_NEITHER, FILE_READ_DATA)
FSCTL_DEDUP_QUERY_RANGE_STATE equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 167, METHOD_NEITHER, FILE_READ_DATA)
FSCTL_DEDUP_QUERY_REPARSE_INFO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 168, METHOD_NEITHER, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
FSCTL_RKF_INTERNAL	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER, FILE_ANY_ACCESS)

FSCTL_SCRUB_DATA	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_REPAIR_COPIES	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, FILE_READ_DATA OR FILE_WRITE_DATA)
FSCTL_DISABLE_LOCAL_BUFFERING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_MGMT_LOCK	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_ADVANCE_FILE_ID	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_SYNC_TUNNEL_REQUEST equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_WRITE_USN_REASON	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_CONTROL	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_GET_REFS_VOLUME_DATA equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_CSV_H_BREAKING_SYNC_TUNNEL_REQUEST equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 185, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WINBLUE)
FSCTL_QUERY_STORAGE_CLASSES equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 187, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_QUERY_REGION_INFO equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 188, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_USN_TRACK_MODIFIED_RANGES equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 189, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif
if (_WIN32_WINNT GE _WIN32_WINNT_WINBLUE)
FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 192, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SVHDX_SYNC_TUNNEL_REQUEST equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 193, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_SVHDX_SET_INITIATOR_INFORMATION equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 194, METHOD_BUFFERED, FILE_ANY_ACCESS)
endif
if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
FSCTL_SET_EXTERNAL_BACKING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 195, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_GET_EXTERNAL_BACKING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 196, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_DELETE_EXTERNAL_BACKING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 197, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
FSCTL_ENUM_EXTERNAL_BACKING equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 198, METHOD_BUFFERED, FILE_ANY_ACCESS)
FSCTL_ENUM_OVERLAY	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 199, METHOD_NEITHER, FILE_ANY_ACCESS)
FSCTL_ADD_OVERLAY	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 204, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_REMOVE_OVERLAY	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 205, METHOD_BUFFERED, FILE_WRITE_DATA)
FSCTL_UPDATE_OVERLAY	equ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 206, METHOD_BUFFERED, FILE_WRITE_DATA)
endif

IOCTL_AVIO_ALLOCATE_STREAM equ CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
IOCTL_AVIO_FREE_STREAM	equ CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
IOCTL_AVIO_MODIFY_STREAM equ CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)

PATHNAME_BUFFER		STRUC
PathNameLength		dd ?
Name			WCHAR 1 dup(?)
PATHNAME_BUFFER		ENDS
PPATHNAME_BUFFER	typedef ptr PATHNAME_BUFFER

FSCTL_QUERY_FAT_BPB_BUFFER  STRUC
First0x24BytesOfBootSector db 0x24 dup(?)
FSCTL_QUERY_FAT_BPB_BUFFER ENDS
PFSCTL_QUERY_FAT_BPB_BUFFER typedef ptr FSCTL_QUERY_FAT_BPB_BUFFER

if (_WIN32_WINNT GE _WIN32_WINNT_NT4)

NTFS_VOLUME_DATA_BUFFER STRUC
VolumeSerialNumber	LARGE_INTEGER <>
NumberSectors		LARGE_INTEGER <>
TotalClusters		LARGE_INTEGER <>
FreeClusters		LARGE_INTEGER <>
TotalReserved		LARGE_INTEGER <>
BytesPerSector		dd ?
BytesPerCluster		dd ?
BytesPerFileRecordSegment dd ?
ClustersPerFileRecordSegment dd ?
MftValidDataLength	LARGE_INTEGER <>
MftStartLcn		LARGE_INTEGER <>
Mft2StartLcn		LARGE_INTEGER <>
MftZoneStart		LARGE_INTEGER <>
MftZoneEnd		LARGE_INTEGER <>
NTFS_VOLUME_DATA_BUFFER ENDS
PNTFS_VOLUME_DATA_BUFFER typedef ptr NTFS_VOLUME_DATA_BUFFER

NTFS_EXTENDED_VOLUME_DATA STRUC
ByteCount		dd ?
MajorVersion		dw ?
MinorVersion		dw ?
BytesPerPhysicalSector	dd ?
LfsMajorVersion		dw ?
LfsMinorVersion		dw ?
NTFS_EXTENDED_VOLUME_DATA ENDS
PNTFS_EXTENDED_VOLUME_DATA typedef ptr NTFS_EXTENDED_VOLUME_DATA
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)

REFS_VOLUME_DATA_BUFFER STRUC
ByteCount		dd ?
MajorVersion		dd ?
MinorVersion		dd ?
BytesPerPhysicalSector	dd ?
VolumeSerialNumber	LARGE_INTEGER <>
NumberSectors		LARGE_INTEGER <>
TotalClusters		LARGE_INTEGER <>
FreeClusters		LARGE_INTEGER <>
TotalReserved		LARGE_INTEGER <>
BytesPerSector		dd ?
BytesPerCluster		dd ?
MaximumSizeOfResidentFile LARGE_INTEGER <>
Reserved		LARGE_INTEGER 10 dup(?)
REFS_VOLUME_DATA_BUFFER ENDS
PREFS_VOLUME_DATA_BUFFER typedef ptr REFS_VOLUME_DATA_BUFFER

endif


if (_WIN32_WINNT GE _WIN32_WINNT_NT4)

STARTING_LCN_INPUT_BUFFER STRUC
StartingLcn		LARGE_INTEGER <>
STARTING_LCN_INPUT_BUFFER ENDS
PSTARTING_LCN_INPUT_BUFFER typedef ptr STARTING_LCN_INPUT_BUFFER

VOLUME_BITMAP_BUFFER	STRUC
StartingLcn		LARGE_INTEGER <>
BitmapSize		LARGE_INTEGER <>
Buffer			db 1 dup(?)
VOLUME_BITMAP_BUFFER	ENDS
PVOLUME_BITMAP_BUFFER	typedef ptr VOLUME_BITMAP_BUFFER
endif

if (_WIN32_WINNT GE _WIN32_WINNT_NT4)

STARTING_VCN_INPUT_BUFFER STRUC
StartingVcn		LARGE_INTEGER <>
STARTING_VCN_INPUT_BUFFER ENDS
PSTARTING_VCN_INPUT_BUFFER typedef ptr STARTING_VCN_INPUT_BUFFER

RETRIEVAL_POINTERS_BUFFER  STRUC
ExtentCount		dd ?
StartingVcn		LARGE_INTEGER <>
STRUC Extents
 NextVcn		LARGE_INTEGER <>
 Lcn			LARGE_INTEGER <>
ENDS
RETRIEVAL_POINTERS_BUFFER ENDS
PRETRIEVAL_POINTERS_BUFFER typedef ptr RETRIEVAL_POINTERS_BUFFER
endif

if (_WIN32_WINNT GE _WIN32_WINNT_NT4)

NTFS_FILE_RECORD_INPUT_BUFFER STRUC
FileReferenceNumber	LARGE_INTEGER <>
NTFS_FILE_RECORD_INPUT_BUFFER ENDS
PNTFS_FILE_RECORD_INPUT_BUFFER typedef ptr NTFS_FILE_RECORD_INPUT_BUFFER

NTFS_FILE_RECORD_OUTPUT_BUFFER STRUC
FileReferenceNumber	LARGE_INTEGER <>
FileRecordLength	dd ?
FileRecordBuffer	db 1 dup(?)
NTFS_FILE_RECORD_OUTPUT_BUFFER ENDS
PNTFS_FILE_RECORD_OUTPUT_BUFFER typedef ptr NTFS_FILE_RECORD_OUTPUT_BUFFER
endif

if (_WIN32_WINNT GE _WIN32_WINNT_NT4)

MOVE_FILE_DATA		STRUC
FileHandle		HANDLE ?
StartingVcn		LARGE_INTEGER <>
StartingLcn		LARGE_INTEGER <>
ClusterCount		dd ?
MOVE_FILE_DATA		ENDS
PMOVE_FILE_DATA		typedef ptr MOVE_FILE_DATA

MOVE_FILE_RECORD_DATA	STRUC
FileHandle		HANDLE ?
SourceFileRecord	LARGE_INTEGER <>
TargetFileRecord	LARGE_INTEGER <>
MOVE_FILE_RECORD_DATA	ENDS
PMOVE_FILE_RECORD_DATA	typedef ptr MOVE_FILE_RECORD_DATA

if defined(_WIN64)

MOVE_FILE_DATA32	STRUC
FileHandle		UINT32 ?
StartingVcn		LARGE_INTEGER <>
StartingLcn		LARGE_INTEGER <>
ClusterCount		dd ?
MOVE_FILE_DATA32	ENDS
PMOVE_FILE_DATA32	typedef ptr MOVE_FILE_DATA32
endif
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

FIND_BY_SID_DATA	STRUC
Restart			dd ?
Sid			SID <>
FIND_BY_SID_DATA	ENDS
PFIND_BY_SID_DATA	typedef ptr FIND_BY_SID_DATA

FIND_BY_SID_OUTPUT	STRUC
NextEntryOffset		dd ?
FileIndex		dd ?
FileNameLength		dd ?
FileName		WCHAR 1 dup(?)
FIND_BY_SID_OUTPUT	ENDS
PFIND_BY_SID_OUTPUT	typedef ptr FIND_BY_SID_OUTPUT

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)


MFT_ENUM_DATA_V0	STRUC
StartFileReferenceNumber dd ?
LowUsn			USN ?
HighUsn			USN ?
MFT_ENUM_DATA_V0	ENDS
PMFT_ENUM_DATA_V0	typedef ptr MFT_ENUM_DATA_V0

MFT_ENUM_DATA_V1	STRUC
StartFileReferenceNumber dd ?
LowUsn			USN ?
HighUsn			USN ?
MinMajorVersion		dw ?
MaxMajorVersion		dw ?
MFT_ENUM_DATA_V1	ENDS
PMFT_ENUM_DATA_V1	typedef ptr MFT_ENUM_DATA_V1

if (NTDDI_VERSION GE NTDDI_WIN8)
MFT_ENUM_DATA		typedef MFT_ENUM_DATA_V1
PMFT_ENUM_DATA		typedef ptr MFT_ENUM_DATA_V1
else
MFT_ENUM_DATA		typedef MFT_ENUM_DATA_V0
PMFT_ENUM_DATA		typedef ptr MFT_ENUM_DATA_V0
endif

CREATE_USN_JOURNAL_DATA STRUC
MaximumSize		dd ?
AllocationDelta		dd ?
CREATE_USN_JOURNAL_DATA ENDS
PCREATE_USN_JOURNAL_DATA typedef ptr CREATE_USN_JOURNAL_DATA

READ_FILE_USN_DATA	STRUC
MinMajorVersion		dw ?
MaxMajorVersion		dw ?
READ_FILE_USN_DATA	ENDS
PREAD_FILE_USN_DATA	typedef ptr READ_FILE_USN_DATA

READ_USN_JOURNAL_DATA_V0 STRUC
StartUsn		USN ?
ReasonMask		dd ?
ReturnOnlyOnClose	dd ?
Timeout			dd ?
BytesToWaitFor		dd ?
UsnJournalID		dd ?
READ_USN_JOURNAL_DATA_V0 ENDS
PREAD_USN_JOURNAL_DATA_V0 typedef ptr READ_USN_JOURNAL_DATA_V0

READ_USN_JOURNAL_DATA_V1 STRUC
StartUsn		USN ?
ReasonMask		dd ?
ReturnOnlyOnClose	dd ?
Timeout			dd ?
BytesToWaitFor		dd ?
UsnJournalID		dd ?
MinMajorVersion		dw ?
MaxMajorVersion		dw ?
READ_USN_JOURNAL_DATA_V1 ENDS
PREAD_USN_JOURNAL_DATA_V1 typedef ptr READ_USN_JOURNAL_DATA_V1

if (NTDDI_VERSION GE NTDDI_WIN8)
READ_USN_JOURNAL_DATA	typedef READ_USN_JOURNAL_DATA_V1
PREAD_USN_JOURNAL_DATA	typedef ptr READ_USN_JOURNAL_DATA_V1
else
READ_USN_JOURNAL_DATA	typedef READ_USN_JOURNAL_DATA_V0
PREAD_USN_JOURNAL_DATA	typedef ptr READ_USN_JOURNAL_DATA_V0
endif

USN_TRACK_MODIFIED_RANGES STRUC
Flags			dd ?
Unused			dd ?
ChunkSize		dd ?
FileSizeThreshold	LONGLONG ?
USN_TRACK_MODIFIED_RANGES ENDS
PUSN_TRACK_MODIFIED_RANGES typedef ptr USN_TRACK_MODIFIED_RANGES

USN_RANGE_TRACK_OUTPUT	STRUC
Usn			USN ?
USN_RANGE_TRACK_OUTPUT	ENDS
PUSN_RANGE_TRACK_OUTPUT typedef ptr USN_RANGE_TRACK_OUTPUT

FLAG_USN_TRACK_MODIFIED_RANGES_ENABLE equ 0x00000001

USN_RECORD_V2		STRUC
RecordLength		dd ?
MajorVersion		dw ?
MinorVersion		dw ?
FileReferenceNumber	dd ?
ParentFileReferenceNumber dd ?
Usn			USN ?
TimeStamp		LARGE_INTEGER <>
Reason			dd ?
SourceInfo		dd ?
SecurityId		dd ?
FileAttributes		dd ?
FileNameLength		dw ?
FileNameOffset		dw ?
FileName		WCHAR 1 dup(?)
USN_RECORD_V2		ENDS
PUSN_RECORD_V2		typedef ptr USN_RECORD_V2

USN_RECORD_V3		STRUC
RecordLength		dd ?
MajorVersion		dw ?
MinorVersion		dw ?
FileReferenceNumber	FILE_ID_128 <>
ParentFileReferenceNumber FILE_ID_128 <>
Usn			USN ?
TimeStamp		LARGE_INTEGER <>
Reason			dd ?
SourceInfo		dd ?
SecurityId		dd ?
FileAttributes		dd ?
FileNameLength		dw ?
FileNameOffset		dw ?
FileName		WCHAR 1 dup(?)
USN_RECORD_V3		ENDS
PUSN_RECORD_V3		typedef ptr USN_RECORD_V3

USN_RECORD		typedef USN_RECORD_V2
PUSN_RECORD		typedef ptr USN_RECORD_V2

USN_RECORD_COMMON_HEADER STRUC
RecordLength		dd ?
MajorVersion		dw ?
MinorVersion		dw ?
USN_RECORD_COMMON_HEADER ENDS
PUSN_RECORD_COMMON_HEADER typedef ptr USN_RECORD_COMMON_HEADER

USN_RECORD_EXTENT	STRUC
_Offset			LONGLONG ?
Length			LONGLONG ?
USN_RECORD_EXTENT	ENDS
PUSN_RECORD_EXTENT	typedef ptr USN_RECORD_EXTENT

USN_RECORD_V4		STRUC
Header			USN_RECORD_COMMON_HEADER <>
FileReferenceNumber	FILE_ID_128 <>
ParentFileReferenceNumber FILE_ID_128 <>
Usn			USN ?
Reason			dd ?
SourceInfo		dd ?
RemainingExtents	dd ?
NumberOfExtents		dw ?
ExtentSize		dw ?
Extents			USN_RECORD_EXTENT 1 dup(<>)
USN_RECORD_V4		ENDS
PUSN_RECORD_V4		typedef ptr USN_RECORD_V4

USN_RECORD_UNION	UNION
Header			USN_RECORD_COMMON_HEADER <>
V2			USN_RECORD_V2 <>
V3			USN_RECORD_V3 <>
V4			USN_RECORD_V4 <>
USN_RECORD_UNION	ENDS
PUSN_RECORD_UNION	typedef ptr USN_RECORD_UNION

USN_PAGE_SIZE		equ (0x1000)

USN_REASON_DATA_OVERWRITE equ (0x00000001)
USN_REASON_DATA_EXTEND	equ (0x00000002)
USN_REASON_DATA_TRUNCATION equ (0x00000004)
USN_REASON_NAMED_DATA_OVERWRITE equ (0x00000010)
USN_REASON_NAMED_DATA_EXTEND equ (0x00000020)
USN_REASON_NAMED_DATA_TRUNCATION equ (0x00000040)
USN_REASON_FILE_CREATE	equ (0x00000100)
USN_REASON_FILE_DELETE	equ (0x00000200)
USN_REASON_EA_CHANGE	equ (0x00000400)
USN_REASON_SECURITY_CHANGE equ (0x00000800)
USN_REASON_RENAME_OLD_NAME equ (0x00001000)
USN_REASON_RENAME_NEW_NAME equ (0x00002000)
USN_REASON_INDEXABLE_CHANGE equ (0x00004000)
USN_REASON_BASIC_INFO_CHANGE equ (0x00008000)
USN_REASON_HARD_LINK_CHANGE equ (0x00010000)
USN_REASON_COMPRESSION_CHANGE equ (0x00020000)
USN_REASON_ENCRYPTION_CHANGE equ (0x00040000)
USN_REASON_OBJECT_ID_CHANGE equ (0x00080000)
USN_REASON_REPARSE_POINT_CHANGE equ (0x00100000)
USN_REASON_STREAM_CHANGE equ (0x00200000)
USN_REASON_TRANSACTED_CHANGE equ (0x00400000)
USN_REASON_INTEGRITY_CHANGE equ (0x00800000)
USN_REASON_CLOSE	equ (0x80000000)

USN_JOURNAL_DATA_V0	STRUC
UsnJournalID		dd ?
FirstUsn		USN ?
NextUsn			USN ?
LowestValidUsn		USN ?
MaxUsn			USN ?
MaximumSize		dd ?
AllocationDelta		dd ?
USN_JOURNAL_DATA_V0	ENDS
PUSN_JOURNAL_DATA_V0	typedef ptr USN_JOURNAL_DATA_V0

USN_JOURNAL_DATA_V1	STRUC
UsnJournalID		dd ?
FirstUsn		USN ?
NextUsn			USN ?
LowestValidUsn		USN ?
MaxUsn			USN ?
MaximumSize		dd ?
AllocationDelta		dd ?
MinSupportedMajorVersion dw ?
MaxSupportedMajorVersion dw ?
USN_JOURNAL_DATA_V1	ENDS
PUSN_JOURNAL_DATA_V1	typedef ptr USN_JOURNAL_DATA_V1

USN_JOURNAL_DATA_V2	STRUC
UsnJournalID		dd ?
FirstUsn		USN ?
NextUsn			USN ?
LowestValidUsn		USN ?
MaxUsn			USN ?
MaximumSize		dd ?
AllocationDelta		dd ?
MinSupportedMajorVersion dw ?
MaxSupportedMajorVersion dw ?
Flags			dd ?
RangeTrackChunkSize	dd ?
RangeTrackFileSizeThreshold LONGLONG ?
USN_JOURNAL_DATA_V2	ENDS
PUSN_JOURNAL_DATA_V2	typedef ptr USN_JOURNAL_DATA_V2

if (NTDDI_VERSION GE NTDDI_WIN8)
USN_JOURNAL_DATA	typedef USN_JOURNAL_DATA_V1
PUSN_JOURNAL_DATA	typedef ptr USN_JOURNAL_DATA_V1
else
USN_JOURNAL_DATA	typedef USN_JOURNAL_DATA_V0
PUSN_JOURNAL_DATA	typedef ptr USN_JOURNAL_DATA_V0
endif

DELETE_USN_JOURNAL_DATA STRUC
UsnJournalID		dd ?
DeleteFlags		dd ?
DELETE_USN_JOURNAL_DATA ENDS
PDELETE_USN_JOURNAL_DATA typedef ptr DELETE_USN_JOURNAL_DATA

USN_DELETE_FLAG_DELETE	equ (0x00000001)
USN_DELETE_FLAG_NOTIFY	equ (0x00000002)
USN_DELETE_VALID_FLAGS	equ (0x00000003)

MARK_HANDLE_INFO	STRUC
if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
UNION
UsnSourceInfo		dd ?
CopyNumber		dd ?
ENDS
else
UsnSourceInfo		dd ?
endif
VolumeHandle		HANDLE ?
HandleInfo		dd ?
MARK_HANDLE_INFO	ENDS
PMARK_HANDLE_INFO	typedef ptr MARK_HANDLE_INFO

if defined(_WIN64)

MARK_HANDLE_INFO32	STRUC
if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
UNION ; {
UsnSourceInfo		dd ?
CopyNumber		dd ?
ENDS ;
else
UsnSourceInfo		dd ?
endif
VolumeHandle		UINT32 ?
HandleInfo		dd ?
MARK_HANDLE_INFO32	ENDS
PMARK_HANDLE_INFO32	typedef ptr MARK_HANDLE_INFO32
endif

USN_SOURCE_DATA_MANAGEMENT equ (0x00000001)
USN_SOURCE_AUXILIARY_DATA equ (0x00000002)
USN_SOURCE_REPLICATION_MANAGEMENT equ (0x00000004)
USN_SOURCE_CLIENT_REPLICATION_MANAGEMENT equ (0x00000008)
USN_SOURCE_VALID_FLAGS	equ (USN_SOURCE_DATA_MANAGEMENT OR USN_SOURCE_AUXILIARY_DATA OR USN_SOURCE_REPLICATION_MANAGEMENT)

MARK_HANDLE_PROTECT_CLUSTERS equ (0x00000001)
MARK_HANDLE_TXF_SYSTEM_LOG equ (0x00000004)
MARK_HANDLE_NOT_TXF_SYSTEM_LOG equ (0x00000008)

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
MARK_HANDLE_REALTIME	equ (0x00000020)
MARK_HANDLE_NOT_REALTIME equ (0x00000040)
endif
if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
MARK_HANDLE_READ_COPY	equ (0x00000080)
MARK_HANDLE_NOT_READ_COPY equ (0x00000100)
endif
MARK_HANDLE_FILTER_METADATA equ (0x00000200)

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
NO_8DOT3_NAME_PRESENT	equ (0x00000001)
REMOVED_8DOT3_NAME	equ (0x00000002)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

BULK_SECURITY_TEST_DATA STRUC
DesiredAccess		ACCESS_MASK ?
SecurityIds		dd 1 dup(?)
BULK_SECURITY_TEST_DATA ENDS
PBULK_SECURITY_TEST_DATA typedef ptr BULK_SECURITY_TEST_DATA
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

VOLUME_IS_DIRTY		equ (0x00000001)
VOLUME_UPGRADE_SCHEDULED equ (0x00000002)
VOLUME_SESSION_OPEN	equ (0x00000004)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

FILE_PREFETCH		STRUC
Type			dd ?
Count			dd ?
_Prefetch		dd 1 dup(?)
FILE_PREFETCH		ENDS
PFILE_PREFETCH		typedef ptr FILE_PREFETCH

FILE_PREFETCH_EX	STRUC
Type			dd ?
Count			dd ?
Context			PVOID ?
_Prefetch		dd 1 dup(?)
FILE_PREFETCH_EX	ENDS
PFILE_PREFETCH_EX	typedef ptr FILE_PREFETCH_EX

FILE_PREFETCH_TYPE_FOR_CREATE equ 0x1
FILE_PREFETCH_TYPE_FOR_DIRENUM equ 0x2
FILE_PREFETCH_TYPE_FOR_CREATE_EX equ 0x3
FILE_PREFETCH_TYPE_FOR_DIRENUM_EX equ 0x4

FILE_PREFETCH_TYPE_MAX	equ 0x4

endif

FILESYSTEM_STATISTICS	STRUC
FileSystemType		dw ?
Version			dw ?
SizeOfCompleteStructure dd ?
UserFileReads		dd ?
UserFileReadBytes	dd ?
UserDiskReads		dd ?
UserFileWrites		dd ?
UserFileWriteBytes	dd ?
UserDiskWrites		dd ?
MetaDataReads		dd ?
MetaDataReadBytes	dd ?
MetaDataDiskReads	dd ?
MetaDataWrites		dd ?
MetaDataWriteBytes	dd ?
MetaDataDiskWrites	dd ?
FILESYSTEM_STATISTICS	ENDS
PFILESYSTEM_STATISTICS	typedef ptr FILESYSTEM_STATISTICS

FILESYSTEM_STATISTICS_TYPE_NTFS equ 1
FILESYSTEM_STATISTICS_TYPE_FAT equ 2
FILESYSTEM_STATISTICS_TYPE_EXFAT equ 3
FILESYSTEM_STATISTICS_TYPE_REFS equ 4

FAT_STATISTICS		STRUC
CreateHits		dd ?
SuccessfulCreates	dd ?
FailedCreates		dd ?
NonCachedReads		dd ?
NonCachedReadBytes	dd ?
NonCachedWrites		dd ?
NonCachedWriteBytes	dd ?
NonCachedDiskReads	dd ?
NonCachedDiskWrites	dd ?
FAT_STATISTICS		ENDS
PFAT_STATISTICS		typedef ptr FAT_STATISTICS

EXFAT_STATISTICS	STRUC
CreateHits		dd ?
SuccessfulCreates	dd ?
FailedCreates		dd ?
NonCachedReads		dd ?
NonCachedReadBytes	dd ?
NonCachedWrites		dd ?
NonCachedWriteBytes	dd ?
NonCachedDiskReads	dd ?
NonCachedDiskWrites	dd ?
EXFAT_STATISTICS	ENDS
PEXFAT_STATISTICS	typedef ptr EXFAT_STATISTICS

NTFS_STATISTICS		STRUC
LogFileFullExceptions	dd ?
OtherExceptions		dd ?
MftReads		dd ?
MftReadBytes		dd ?
MftWrites		dd ?
MftWriteBytes		dd ?
STRUC MftWritesUserLevel
 Write			dw ?
 Create			dw ?
 SetInfo		dw ?
 Flush			dw ?
ENDS
MftWritesFlushForLogFileFull dw ?
MftWritesLazyWriter	dw ?
MftWritesUserRequest	dw ?
Mft2Writes		dd ?
Mft2WriteBytes		dd ?
STRUC Mft2WritesUserLevel
 Write			dw ?
 Create			dw ?
 SetInfo		dw ?
 Flush			dw ?
ENDS
Mft2WritesFlushForLogFileFull dw ?
Mft2WritesLazyWriter	dw ?
Mft2WritesUserRequest	dw ?
RootIndexReads		dd ?
RootIndexReadBytes	dd ?
RootIndexWrites		dd ?
RootIndexWriteBytes	dd ?
BitmapReads		dd ?
BitmapReadBytes		dd ?
BitmapWrites		dd ?
BitmapWriteBytes	dd ?
BitmapWritesFlushForLogFileFull dw ?
BitmapWritesLazyWriter	dw ?
BitmapWritesUserRequest dw ?
STRUC BitmapWritesUserLevel
 Write			dw ?
 Create			dw ?
 SetInfo		dw ?
ENDS
MftBitmapReads		dd ?
MftBitmapReadBytes	dd ?
MftBitmapWrites		dd ?
MftBitmapWriteBytes	dd ?
MftBitmapWritesFlushForLogFileFull dw ?
MftBitmapWritesLazyWriter dw ?
MftBitmapWritesUserRequest dw ?
STRUC MftBitmapWritesUserLevel
 Write			dw ?
 Create			dw ?
 SetInfo		dw ?
 Flush			dw ?
ENDS
UserIndexReads		dd ?
UserIndexReadBytes	dd ?
UserIndexWrites		dd ?
UserIndexWriteBytes	dd ?
LogFileReads		dd ?
LogFileReadBytes	dd ?
LogFileWrites		dd ?
LogFileWriteBytes	dd ?
STRUC Allocate
 Calls			dd ?
 Clusters		dd ?
 Hints			dd ?
 RunsReturned		dd ?
 HintsHonored		dd ?
 HintsClusters		dd ?
 Cache			dd ?
 CacheClusters		dd ?
 CacheMiss		dd ?
 CacheMissClusters	dd ?
ENDS
DiskResourcesExhausted	dd ?
VolumeTrimCount		dd ?
VolumeTrimTime		dd ?
VolumeTrimByteCount	dd ?
FileLevelTrimCount	dd ?
FileLevelTrimTime	dd ?
FileLevelTrimByteCount	dd ?
NTFS_STATISTICS		ENDS
PNTFS_STATISTICS	typedef ptr NTFS_STATISTICS

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

FILE_OBJECTID_BUFFER	STRUC
ObjectId		db 16 dup(?)
UNION
 STRUC
  BirthVolumeId		db 16 dup(?)
  BirthObjectId		db 16 dup(?)
  DomainId		db 16 dup(?)
 ENDS
 ExtendedInfo		db 48 dup(?)
ENDS
FILE_OBJECTID_BUFFER	ENDS
PFILE_OBJECTID_BUFFER	typedef ptr FILE_OBJECTID_BUFFER

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)
FILE_SET_SPARSE_BUFFER	STRUC
SetSparse		BOOLEAN ?
FILE_SET_SPARSE_BUFFER	ENDS
PFILE_SET_SPARSE_BUFFER typedef ptr FILE_SET_SPARSE_BUFFER
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)
FILE_ZERO_DATA_INFORMATION STRUC
FileOffset		LARGE_INTEGER <>
BeyondFinalZero		LARGE_INTEGER <>
FILE_ZERO_DATA_INFORMATION ENDS
PFILE_ZERO_DATA_INFORMATION typedef ptr FILE_ZERO_DATA_INFORMATION
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)
FILE_ALLOCATED_RANGE_BUFFER STRUC
FileOffset		LARGE_INTEGER <>
Length			LARGE_INTEGER <>
FILE_ALLOCATED_RANGE_BUFFER ENDS
PFILE_ALLOCATED_RANGE_BUFFER typedef ptr FILE_ALLOCATED_RANGE_BUFFER
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

ENCRYPTION_BUFFER	STRUC
EncryptionOperation	dd ?
Private			db 1 dup(?)
ENCRYPTION_BUFFER	ENDS
PENCRYPTION_BUFFER	typedef ptr ENCRYPTION_BUFFER

FILE_SET_ENCRYPTION	equ 0x00000001
FILE_CLEAR_ENCRYPTION	equ 0x00000002
STREAM_SET_ENCRYPTION	equ 0x00000003
STREAM_CLEAR_ENCRYPTION equ 0x00000004

MAXIMUM_ENCRYPTION_VALUE equ 0x00000004

DECRYPTION_STATUS_BUFFER  STRUC
NoEncryptedStreams	BOOLEAN ?
DECRYPTION_STATUS_BUFFER ENDS
PDECRYPTION_STATUS_BUFFER typedef ptr DECRYPTION_STATUS_BUFFER

ENCRYPTION_FORMAT_DEFAULT equ (0x01)

REQUEST_RAW_ENCRYPTED_DATA  STRUC
FileOffset		LONGLONG ?
Length			dd ?
REQUEST_RAW_ENCRYPTED_DATA ENDS
PREQUEST_RAW_ENCRYPTED_DATA typedef ptr REQUEST_RAW_ENCRYPTED_DATA

ENCRYPTED_DATA_INFO	STRUC
StartingFileOffset	dd ?
OutputBufferOffset	dd ?
BytesWithinFileSize	dd ?
BytesWithinValidDataLength dd ?
CompressionFormat	dw ?
DataUnitShift		db ?
ChunkShift		db ?
ClusterShift		db ?
EncryptionFormat	db ?
NumberOfDataBlocks	dw ?
DataBlockSize		dd ANYSIZE_ARRAY dup(?)
ENCRYPTED_DATA_INFO	ENDS
PENCRYPTED_DATA_INFO	typedef ptr ENCRYPTED_DATA_INFO
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)

ENCRYPTED_DATA_INFO_SPARSE_FILE equ 1

EXTENDED_ENCRYPTED_DATA_INFO  STRUC
ExtendedCode		dd ?
Length			dd ?
Flags			dd ?
Reserved		dd ?
EXTENDED_ENCRYPTED_DATA_INFO ENDS
PEXTENDED_ENCRYPTED_DATA_INFO typedef ptr EXTENDED_ENCRYPTED_DATA_INFO
endif


if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

PLEX_READ_DATA_REQUEST	STRUC
ByteOffset		LARGE_INTEGER <>
ByteLength		dd ?
PlexNumber		dd ?
PLEX_READ_DATA_REQUEST	ENDS
PPLEX_READ_DATA_REQUEST typedef ptr PLEX_READ_DATA_REQUEST
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN2K)

SI_COPYFILE		STRUC
SourceFileNameLength	dd ?
DestinationFileNameLength dd ?
Flags			dd ?
FileNameBuffer		WCHAR 1 dup(?)
SI_COPYFILE		ENDS
PSI_COPYFILE		typedef ptr SI_COPYFILE

COPYFILE_SIS_LINK	equ 0x0001
COPYFILE_SIS_REPLACE	equ 0x0002
COPYFILE_SIS_FLAGS	equ 0x0003
endif

if (_WIN32_WINNT GE _WIN32_WINNT_VISTA)

FILE_MAKE_COMPATIBLE_BUFFER STRUC
CloseDisc		BOOLEAN ?
FILE_MAKE_COMPATIBLE_BUFFER ENDS
PFILE_MAKE_COMPATIBLE_BUFFER typedef ptr FILE_MAKE_COMPATIBLE_BUFFER

FILE_SET_DEFECT_MGMT_BUFFER STRUC
Disable			BOOLEAN ?
FILE_SET_DEFECT_MGMT_BUFFER ENDS
PFILE_SET_DEFECT_MGMT_BUFFER typedef ptr FILE_SET_DEFECT_MGMT_BUFFER

FILE_QUERY_SPARING_BUFFER STRUC
SparingUnitBytes	dd ?
SoftwareSparing		BOOLEAN ?
TotalSpareBlocks	dd ?
FreeSpareBlocks		dd ?
FILE_QUERY_SPARING_BUFFER ENDS
PFILE_QUERY_SPARING_BUFFER typedef ptr FILE_QUERY_SPARING_BUFFER


FILE_QUERY_ON_DISK_VOL_INFO_BUFFER STRUC
DirectoryCount		LARGE_INTEGER <>
FileCount		LARGE_INTEGER <>
FsFormatMajVersion	dw ?
FsFormatMinVersion	dw ?
FsFormatName		WCHAR 12 dup(?)
FormatTime		LARGE_INTEGER <>
LastUpdateTime		LARGE_INTEGER <>
CopyrightInfo		WCHAR 34 dup(?)
AbstractInfo		WCHAR 34 dup(?)
FormattingImplementationInfo WCHAR 34 dup(?)
LastModifyingImplementationInfo WCHAR 34 dup(?)
FILE_QUERY_ON_DISK_VOL_INFO_BUFFER ENDS
PFILE_QUERY_ON_DISK_VOL_INFO_BUFFER typedef ptr FILE_QUERY_ON_DISK_VOL_INFO_BUFFER

SET_REPAIR_ENABLED	equ (0x00000001)
SET_REPAIR_WARN_ABOUT_DATA_LOSS equ (0x00000008)
SET_REPAIR_DISABLED_AND_BUGCHECK_ON_CORRUPT equ (0x00000010)
SET_REPAIR_VALID_MASK	equ (0x00000019)

FILE_INITIATE_REPAIR_HINT1_FILE_RECORD_NOT_IN_USE equ (0x0000000000000001)
FILE_INITIATE_REPAIR_HINT1_FILE_RECORD_REUSED equ (0x0000000000000002)
FILE_INITIATE_REPAIR_HINT1_FILE_RECORD_NOT_EXIST equ (0x0000000000000004)
FILE_INITIATE_REPAIR_HINT1_FILE_RECORD_NOT_BASE_RECORD equ (0x0000000000000008)
FILE_INITIATE_REPAIR_HINT1_SYSTEM_FILE equ (0x0000000000000010)
FILE_INITIATE_REPAIR_HINT1_NOT_IMPLEMENTED equ (0x0000000000000020)
FILE_INITIATE_REPAIR_HINT1_UNABLE_TO_REPAIR equ (0x0000000000000040)
FILE_INITIATE_REPAIR_HINT1_REPAIR_DISABLED equ (0x0000000000000080)
FILE_INITIATE_REPAIR_HINT1_RECURSIVELY_CORRUPTED equ (0x0000000000000100)
FILE_INITIATE_REPAIR_HINT1_ORPHAN_GENERATED equ (0x0000000000000200)
FILE_INITIATE_REPAIR_HINT1_REPAIRED equ (0x0000000000000400)
FILE_INITIATE_REPAIR_HINT1_NOTHING_WRONG equ (0x0000000000000800)
FILE_INITIATE_REPAIR_HINT1_ATTRIBUTE_NOT_FOUND equ (0x0000000000001000)
FILE_INITIATE_REPAIR_HINT1_POTENTIAL_CROSSLINK equ (0x0000000000002000)
FILE_INITIATE_REPAIR_HINT1_STALE_INFORMATION equ (0x0000000000004000)
FILE_INITIATE_REPAIR_HINT1_CLUSTERS_ALREADY_IN_USE equ (0x0000000000008000)
FILE_INITIATE_REPAIR_HINT1_LCN_NOT_EXIST equ (0x0000000000010000)
FILE_INITIATE_REPAIR_HINT1_INVALID_RUN_LENGTH equ (0x0000000000020000)
FILE_INITIATE_REPAIR_HINT1_FILE_RECORD_NOT_ORPHAN equ (0x0000000000040000)
FILE_INITIATE_REPAIR_HINT1_FILE_RECORD_IS_BASE_RECORD equ (0x0000000000080000)
FILE_INITIATE_REPAIR_HINT1_INVALID_ARRAY_LENGTH_COUNT equ (0x0000000000100000)
FILE_INITIATE_REPAIR_HINT1_SID_VALID equ (0x0000000000200000)
FILE_INITIATE_REPAIR_HINT1_SID_MISMATCH equ (0x0000000000400000)
FILE_INITIATE_REPAIR_HINT1_INVALID_PARENT equ (0x0000000000800000)
FILE_INITIATE_REPAIR_HINT1_PARENT_FILE_RECORD_NOT_IN_USE equ (0x0000000001000000)
FILE_INITIATE_REPAIR_HINT1_PARENT_FILE_RECORD_REUSED equ (0x0000000002000000)
FILE_INITIATE_REPAIR_HINT1_PARENT_FILE_RECORD_NOT_EXIST equ (0x0000000004000000)
FILE_INITIATE_REPAIR_HINT1_PARENT_FILE_RECORD_NOT_BASE_RECORD equ (0x0000000008000000)
FILE_INITIATE_REPAIR_HINT1_PARENT_FILE_RECORD_NOT_INDEX equ (0x0000000010000000)
FILE_INITIATE_REPAIR_HINT1_VALID_INDEX_ENTRY equ (0x0000000020000000)
FILE_INITIATE_REPAIR_HINT1_OUT_OF_GENERIC_NAMES equ (0x0000000040000000)
FILE_INITIATE_REPAIR_HINT1_OUT_OF_RESOURCE equ (0x0000000080000000)
FILE_INITIATE_REPAIR_HINT1_INVALID_LCN equ (0x0000000100000000)
FILE_INITIATE_REPAIR_HINT1_INVALID_VCN equ (0x0000000200000000)
FILE_INITIATE_REPAIR_HINT1_NAME_CONFLICT equ (0x0000000400000000)
FILE_INITIATE_REPAIR_HINT1_ORPHAN equ (0x0000000800000000)
FILE_INITIATE_REPAIR_HINT1_ATTRIBUTE_TOO_SMALL equ (0x0000001000000000)
FILE_INITIATE_REPAIR_HINT1_ATTRIBUTE_NON_RESIDENT equ (0x0000002000000000)
FILE_INITIATE_REPAIR_HINT1_DENY_DEFRAG equ (0x0000004000000000)
FILE_INITIATE_REPAIR_HINT1_PREVIOUS_PARENT_STILL_VALID equ (0x0000008000000000)
FILE_INITIATE_REPAIR_HINT1_INDEX_ENTRY_MISMATCH equ (0x0000010000000000)
FILE_INITIATE_REPAIR_HINT1_INVALID_ORPHAN_RECOVERY_NAME equ (0x0000020000000000)
FILE_INITIATE_REPAIR_HINT1_MULTIPLE_FILE_NAME_ATTRIBUTES equ (0x0000040000000000)

CLSN			typedef DWORDLONG

FILE_INITIATE_REPAIR_OUTPUT_BUFFER STRUC
Hint1			dd ?
Hint2			dd ?
Clsn			CLSN ?
Status			dd ?
FILE_INITIATE_REPAIR_OUTPUT_BUFFER ENDS
PFILE_INITIATE_REPAIR_OUTPUT_BUFFER typedef ptr FILE_INITIATE_REPAIR_OUTPUT_BUFFER

SHRINK_VOLUME_REQUEST_TYPES typedef SDWORD
ShrinkPrepare		equ 1
ShrinkCommit		equ 1
ShrinkAbort		equ 2

SHRINK_VOLUME_INFORMATION STRUC
ShrinkRequestType	SHRINK_VOLUME_REQUEST_TYPES ?
Flags			dd ?
NewNumberOfSectors	LONGLONG ?

SHRINK_VOLUME_INFORMATION ENDS
PSHRINK_VOLUME_INFORMATION typedef ptr SHRINK_VOLUME_INFORMATION


TXFS_RM_FLAG_LOGGING_MODE equ 0x00000001
TXFS_RM_FLAG_RENAME_RM	equ 0x00000002
TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MAX equ 0x00000004
TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MIN equ 0x00000008
TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS equ 0x00000010
TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT equ 0x00000020
TXFS_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE equ 0x00000040
TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX equ 0x00000080
TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN equ 0x00000100
TXFS_RM_FLAG_GROW_LOG	equ 0x00000400
TXFS_RM_FLAG_SHRINK_LOG equ 0x00000800
TXFS_RM_FLAG_ENFORCE_MINIMUM_SIZE equ 0x00001000
TXFS_RM_FLAG_PRESERVE_CHANGES equ 0x00002000
TXFS_RM_FLAG_RESET_RM_AT_NEXT_START equ 0x00004000
TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START equ 0x00008000
TXFS_RM_FLAG_PREFER_CONSISTENCY equ 0x00010000
TXFS_RM_FLAG_PREFER_AVAILABILITY equ 0x00020000

TXFS_LOGGING_MODE_SIMPLE equ (0x0001)
TXFS_LOGGING_MODE_FULL	equ (0x0002)

TXFS_TRANSACTION_STATE_NONE equ 0x00
TXFS_TRANSACTION_STATE_ACTIVE equ 0x01
TXFS_TRANSACTION_STATE_PREPARED equ 0x02
TXFS_TRANSACTION_STATE_NOTACTIVE equ 0x03

TXFS_MODIFY_RM_VALID_FLAGS equ \
		(TXFS_RM_FLAG_LOGGING_MODE			    OR \
		 TXFS_RM_FLAG_RENAME_RM				    OR \
		 TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MAX		    OR \
		 TXFS_RM_FLAG_LOG_CONTAINER_COUNT_MIN		    OR \
		 TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS   OR \
		 TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT	    OR \
		 TXFS_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE	    OR \
		 TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX	    OR \
		 TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN	    OR \
		 TXFS_RM_FLAG_SHRINK_LOG			    OR \
		 TXFS_RM_FLAG_GROW_LOG				    OR \
		 TXFS_RM_FLAG_ENFORCE_MINIMUM_SIZE		    OR \
		 TXFS_RM_FLAG_PRESERVE_CHANGES			    OR \
		 TXFS_RM_FLAG_RESET_RM_AT_NEXT_START		    OR \
		 TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START	    OR \
		 TXFS_RM_FLAG_PREFER_CONSISTENCY		    OR \
		 TXFS_RM_FLAG_PREFER_AVAILABILITY)

TXFS_MODIFY_RM		STRUC
Flags			dd ?
LogContainerCountMax	dd ?
LogContainerCountMin	dd ?
LogContainerCount	dd ?
LogGrowthIncrement	dd ?
LogAutoShrinkPercentage dd ?
Reserved		dd ?
LoggingMode		dw ?
TXFS_MODIFY_RM		ENDS

TXFS_RM_STATE_NOT_STARTED equ 0
TXFS_RM_STATE_STARTING	equ 1
TXFS_RM_STATE_ACTIVE	equ 2
TXFS_RM_STATE_SHUTTING_DOWN equ 3

TXFS_QUERY_RM_INFORMATION_VALID_FLAGS equ \
		(TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS   OR \
		 TXFS_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT	    OR \
		 TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX	    OR \
		 TXFS_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN	    OR \
		 TXFS_RM_FLAG_RESET_RM_AT_NEXT_START		    OR \
		 TXFS_RM_FLAG_DO_NOT_RESET_RM_AT_NEXT_START	    OR \
		 TXFS_RM_FLAG_PREFER_CONSISTENCY		    OR \
		 TXFS_RM_FLAG_PREFER_AVAILABILITY)

TXFS_QUERY_RM_INFORMATION  STRUC
BytesRequired		dd ?
TailLsn			dd ?
CurrentLsn		dd ?
ArchiveTailLsn		dd ?
LogContainerSize	dd ?
HighestVirtualClock	LARGE_INTEGER <>
LogContainerCount	dd ?
LogContainerCountMax	dd ?
LogContainerCountMin	dd ?
LogGrowthIncrement	dd ?
LogAutoShrinkPercentage dd ?
Flags			dd ?
LoggingMode		dw ?
Reserved		dw ?
RmState			dd ?
LogCapacity		dd ?
LogFree			dd ?
TopsSize		dd ?
TopsUsed		dd ?
TransactionCount	dd ?
OnePCCount		dd ?
TwoPCCount		dd ?
NumberLogFileFull	dd ?
OldestTransactionAge	dd ?
RMName			GUID <>
TmLogPathOffset		dd ?
TXFS_QUERY_RM_INFORMATION ENDS

TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_REDO_LSN equ 0x01
TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_VIRTUAL_CLOCK equ 0x02
TXFS_ROLLFORWARD_REDO_VALID_FLAGS equ (TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_REDO_LSN OR TXFS_ROLLFORWARD_REDO_FLAG_USE_LAST_VIRTUAL_CLOCK)

TXFS_ROLLFORWARD_REDO_INFORMATION  STRUC
LastVirtualClock	LARGE_INTEGER <>
LastRedoLsn		dd ?
HighestRecoveryLsn	dd ?
Flags			dd ?
TXFS_ROLLFORWARD_REDO_INFORMATION ENDS

TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MAX equ 0x00000001
TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MIN equ 0x00000002
TXFS_START_RM_FLAG_LOG_CONTAINER_SIZE equ 0x00000004
TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS equ 0x00000008
TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT equ 0x00000010
TXFS_START_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE equ 0x00000020
TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX equ 0x00000040
TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MIN equ 0x00000080
TXFS_START_RM_FLAG_RECOVER_BEST_EFFORT equ 0x00000200
TXFS_START_RM_FLAG_LOGGING_MODE equ 0x00000400
TXFS_START_RM_FLAG_PRESERVE_CHANGES equ 0x00000800
TXFS_START_RM_FLAG_PREFER_CONSISTENCY equ 0x00001000
TXFS_START_RM_FLAG_PREFER_AVAILABILITY equ 0x00002000
TXFS_START_RM_VALID_FLAGS equ \
		(TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MAX		OR \
		 TXFS_START_RM_FLAG_LOG_CONTAINER_COUNT_MIN		OR \
		 TXFS_START_RM_FLAG_LOG_CONTAINER_SIZE			OR \
		 TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_NUM_CONTAINERS OR \
		 TXFS_START_RM_FLAG_LOG_GROWTH_INCREMENT_PERCENT	OR \
		 TXFS_START_RM_FLAG_LOG_AUTO_SHRINK_PERCENTAGE		OR \
		 TXFS_START_RM_FLAG_RECOVER_BEST_EFFORT			OR \
		 TXFS_START_RM_FLAG_LOG_NO_CONTAINER_COUNT_MAX		OR \
		 TXFS_START_RM_FLAG_LOGGING_MODE			OR \
		 TXFS_START_RM_FLAG_PRESERVE_CHANGES			OR \
		 TXFS_START_RM_FLAG_PREFER_CONSISTENCY			OR \
		 TXFS_START_RM_FLAG_PREFER_AVAILABILITY)

TXFS_START_RM_INFORMATION  STRUC
Flags			dd ?
LogContainerSize	dd ?
LogContainerCountMin	dd ?
LogContainerCountMax	dd ?
LogGrowthIncrement	dd ?
LogAutoShrinkPercentage dd ?
TmLogPathOffset		dd ?
TmLogPathLength		dw ?
LoggingMode		dw ?
LogPathLength		dw ?
Reserved		dw ?
LogPath			WCHAR 1 dup(?)
TXFS_START_RM_INFORMATION ENDS

TXFS_GET_METADATA_INFO_OUT  STRUC
STRUC TxfFileId
 LowPart		LONGLONG ?
 HighPart		LONGLONG ?
ENDS
LockingTransaction	GUID <>
LastLsn			dd ?
TransactionState	dd ?
TXFS_GET_METADATA_INFO_OUT ENDS
PTXFS_GET_METADATA_INFO_OUT typedef ptr TXFS_GET_METADATA_INFO_OUT

TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY_FLAG_CREATED equ 0x00000001
TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY_FLAG_DELETED equ 0x00000002

TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY STRUC
_Offset			dd ?
NameFlags		dd ?
FileId			LONGLONG ?
Reserved1		dd ?
Reserved2		dd ?
Reserved3		LONGLONG ?
FileName		WCHAR 1 dup(?)
TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY ENDS
PTXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY typedef ptr TXFS_LIST_TRANSACTION_LOCKED_FILES_ENTRY


TXFS_LIST_TRANSACTION_LOCKED_FILES STRUC
KtmTransaction		GUID <>
NumberOfFiles		dd ?
BufferSizeRequired	dd ?
_Offset			dd ?
TXFS_LIST_TRANSACTION_LOCKED_FILES ENDS
PTXFS_LIST_TRANSACTION_LOCKED_FILES typedef ptr TXFS_LIST_TRANSACTION_LOCKED_FILES


TXFS_LIST_TRANSACTIONS_ENTRY STRUC
TransactionId		GUID <>
TransactionState	dd ?
Reserved1		dd ?
Reserved2		dd ?
Reserved3		LONGLONG ?
TXFS_LIST_TRANSACTIONS_ENTRY ENDS
PTXFS_LIST_TRANSACTIONS_ENTRY typedef ptr TXFS_LIST_TRANSACTIONS_ENTRY

TXFS_LIST_TRANSACTIONS	STRUC
NumberOfTransactions	dd ?
BufferSizeRequired	dd ?
TXFS_LIST_TRANSACTIONS	ENDS
PTXFS_LIST_TRANSACTIONS typedef ptr TXFS_LIST_TRANSACTIONS

TXFS_READ_BACKUP_INFORMATION_OUT STRUC
UNION
BufferLength		dd ?
Buffer			db 1 dup(?)
ENDS
TXFS_READ_BACKUP_INFORMATION_OUT ENDS
PTXFS_READ_BACKUP_INFORMATION_OUT typedef ptr TXFS_READ_BACKUP_INFORMATION_OUT

TXFS_WRITE_BACKUP_INFORMATION  STRUC
Buffer			db 1 dup(?)
TXFS_WRITE_BACKUP_INFORMATION ENDS
PTXFS_WRITE_BACKUP_INFORMATION typedef ptr TXFS_WRITE_BACKUP_INFORMATION

TXFS_TRANSACTED_VERSION_NONTRANSACTED equ 0xFFFFFFFE
TXFS_TRANSACTED_VERSION_UNCOMMITTED equ 0xFFFFFFFF

TXFS_GET_TRANSACTED_VERSION STRUC
ThisBaseVersion		dd ?
LatestVersion		dd ?
ThisMiniVersion		dw ?
FirstMiniVersion	dw ?
LatestMiniVersion	dw ?
TXFS_GET_TRANSACTED_VERSION ENDS
PTXFS_GET_TRANSACTED_VERSION typedef ptr TXFS_GET_TRANSACTED_VERSION

TXFS_SAVEPOINT_SET	equ 0x00000001
TXFS_SAVEPOINT_ROLLBACK equ 0x00000002
TXFS_SAVEPOINT_CLEAR	equ 0x00000004
TXFS_SAVEPOINT_CLEAR_ALL equ 0x00000010

TXFS_SAVEPOINT_INFORMATION  STRUC
KtmTransaction		HANDLE ?
ActionCode		dd ?
SavepointId		dd ?
TXFS_SAVEPOINT_INFORMATION ENDS
PTXFS_SAVEPOINT_INFORMATION typedef ptr TXFS_SAVEPOINT_INFORMATION

TXFS_CREATE_MINIVERSION_INFO STRUC
StructureVersion	dw ?
StructureLength		dw ?
BaseVersion		dd ?
MiniVersion		dw ?
TXFS_CREATE_MINIVERSION_INFO ENDS
PTXFS_CREATE_MINIVERSION_INFO typedef ptr TXFS_CREATE_MINIVERSION_INFO

TXFS_TRANSACTION_ACTIVE_INFO  STRUC
TransactionsActiveAtSnapshot BOOLEAN ?
TXFS_TRANSACTION_ACTIVE_INFO ENDS
PTXFS_TRANSACTION_ACTIVE_INFO typedef ptr TXFS_TRANSACTION_ACTIVE_INFO

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)

BOOT_AREA_INFO		STRUC
BootSectorCount		dd ?
STRUC BootSectors
_Offset			LARGE_INTEGER <>
ENDS
BOOT_AREA_INFO		ENDS
PBOOT_AREA_INFO		typedef ptr BOOT_AREA_INFO

RETRIEVAL_POINTER_BASE	STRUC
FileAreaOffset		LARGE_INTEGER <>
RETRIEVAL_POINTER_BASE	ENDS
PRETRIEVAL_POINTER_BASE typedef ptr RETRIEVAL_POINTER_BASE

FILE_FS_PERSISTENT_VOLUME_INFORMATION  STRUC
VolumeFlags		dd ?
FlagMask		dd ?
Version			dd ?
Reserved		dd ?
FILE_FS_PERSISTENT_VOLUME_INFORMATION ENDS
PFILE_FS_PERSISTENT_VOLUME_INFORMATION typedef ptr FILE_FS_PERSISTENT_VOLUME_INFORMATION

PERSISTENT_VOLUME_STATE_SHORT_NAME_CREATION_DISABLED equ (0x00000001)

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)
PERSISTENT_VOLUME_STATE_VOLUME_SCRUB_DISABLED equ (0x00000002)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WINBLUE)
PERSISTENT_VOLUME_STATE_GLOBAL_METADATA_NO_SEEK_PENALTY equ (0x00000004)
PERSISTENT_VOLUME_STATE_LOCAL_METADATA_NO_SEEK_PENALTY equ (0x00000008)
PERSISTENT_VOLUME_STATE_NO_HEAT_GATHERING equ (0x00000010)
endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)
PERSISTENT_VOLUME_STATE_CONTAINS_BACKING_WIM equ (0x00000020)
PERSISTENT_VOLUME_STATE_BACKED_BY_WIM equ (0x00000040)
endif

FILE_SYSTEM_RECOGNITION_INFORMATION  STRUC
FileSystem		CHAR 9 dup(?)
FILE_SYSTEM_RECOGNITION_INFORMATION ENDS
PFILE_SYSTEM_RECOGNITION_INFORMATION typedef ptr FILE_SYSTEM_RECOGNITION_INFORMATION

OPLOCK_LEVEL_CACHE_READ equ (0x00000001)
OPLOCK_LEVEL_CACHE_HANDLE equ (0x00000002)
OPLOCK_LEVEL_CACHE_WRITE equ (0x00000004)

REQUEST_OPLOCK_INPUT_FLAG_REQUEST equ (0x00000001)
REQUEST_OPLOCK_INPUT_FLAG_ACK equ (0x00000002)
REQUEST_OPLOCK_INPUT_FLAG_COMPLETE_ACK_ON_CLOSE equ (0x00000004)
REQUEST_OPLOCK_CURRENT_VERSION equ 1

REQUEST_OPLOCK_INPUT_BUFFER  STRUC
StructureVersion	dw ?
StructureLength		dw ?
RequestedOplockLevel	dd ?
Flags			dd ?
REQUEST_OPLOCK_INPUT_BUFFER ENDS
PREQUEST_OPLOCK_INPUT_BUFFER typedef ptr REQUEST_OPLOCK_INPUT_BUFFER

REQUEST_OPLOCK_OUTPUT_FLAG_ACK_REQUIRED equ (0x00000001)
REQUEST_OPLOCK_OUTPUT_FLAG_MODES_PROVIDED equ (0x00000002)

REQUEST_OPLOCK_OUTPUT_BUFFER  STRUC
StructureVersion	dw ?
StructureLength		dw ?
OriginalOplockLevel	dd ?
NewOplockLevel		dd ?
Flags			dd ?
AccessMode		ACCESS_MASK ?
ShareMode		dw ?
REQUEST_OPLOCK_OUTPUT_BUFFER ENDS
PREQUEST_OPLOCK_OUTPUT_BUFFER typedef ptr REQUEST_OPLOCK_OUTPUT_BUFFER

ifndef _VIRTUAL_STORAGE_TYPE_DEFINED
_VIRTUAL_STORAGE_TYPE_DEFINED equ 1
VIRTUAL_STORAGE_TYPE	STRUC
DeviceId		dd ?
VendorId		GUID <>
VIRTUAL_STORAGE_TYPE	ENDS
PVIRTUAL_STORAGE_TYPE	typedef ptr VIRTUAL_STORAGE_TYPE
endif

STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST	STRUC
RequestLevel		dd ?
RequestFlags		dd ?
STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST ENDS
PSTORAGE_QUERY_DEPENDENT_VOLUME_REQUEST typedef ptr STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST

QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_HOST_VOLUMES equ 0x1
QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_GUEST_VOLUMES equ 0x2

STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY  STRUC
EntryLength		dd ?
DependencyTypeFlags	dd ?
ProviderSpecificFlags	dd ?
VirtualStorageType	VIRTUAL_STORAGE_TYPE <>
STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY ENDS
PSTORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY typedef ptr STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY

STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY  STRUC
EntryLength		dd ?
DependencyTypeFlags	dd ?
ProviderSpecificFlags	dd ?
VirtualStorageType	VIRTUAL_STORAGE_TYPE <>
AncestorLevel		dd ?
HostVolumeNameOffset	dd ?
HostVolumeNameSize	dd ?
DependentVolumeNameOffset dd ?
DependentVolumeNameSize dd ?
RelativePathOffset	dd ?
RelativePathSize	dd ?
DependentDeviceNameOffset dd ?
DependentDeviceNameSize dd ?
STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY ENDS
PSTORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY typedef ptr STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY

STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE STRUC
ResponseLevel		dd ?
NumberEntries		dd ?
UNION
 Lev1Depends		STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY <>
 Lev2Depends		STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY <>
ENDS
STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE ENDS
PSTORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE typedef ptr STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE

SD_GLOBAL_CHANGE_TYPE_MACHINE_SID equ 1
SD_GLOBAL_CHANGE_TYPE_QUERY_STATS equ (1 SHL 16)
SD_GLOBAL_CHANGE_TYPE_ENUM_SDS equ (2 SHL 16)

SD_CHANGE_MACHINE_SID_INPUT  STRUC
CurrentMachineSIDOffset dw ?
CurrentMachineSIDLength dw ?
NewMachineSIDOffset	dw ?
NewMachineSIDLength	dw ?
SD_CHANGE_MACHINE_SID_INPUT ENDS
PSD_CHANGE_MACHINE_SID_INPUT typedef ptr SD_CHANGE_MACHINE_SID_INPUT

SD_CHANGE_MACHINE_SID_OUTPUT  STRUC
NumSDChangedSuccess	dd ?
NumSDChangedFail	dd ?
NumSDUnused		dd ?
NumSDTotal		dd ?
NumMftSDChangedSuccess	dd ?
NumMftSDChangedFail	dd ?
NumMftSDTotal		dd ?
SD_CHANGE_MACHINE_SID_OUTPUT ENDS
PSD_CHANGE_MACHINE_SID_OUTPUT typedef ptr SD_CHANGE_MACHINE_SID_OUTPUT

SD_QUERY_STATS_INPUT	STRUC
Reserved		dd ?
SD_QUERY_STATS_INPUT	ENDS
PSD_QUERY_STATS_INPUT	typedef ptr SD_QUERY_STATS_INPUT
SD_QUERY_STATS_OUTPUT	STRUC
SdsStreamSize		dd ?
SdsAllocationSize	dd ?
SiiStreamSize		dd ?
SiiAllocationSize	dd ?
SdhStreamSize		dd ?
SdhAllocationSize	dd ?
NumSDTotal		dd ?
NumSDUnused		dd ?
SD_QUERY_STATS_OUTPUT	ENDS
PSD_QUERY_STATS_OUTPUT	typedef ptr SD_QUERY_STATS_OUTPUT

SD_ENUM_SDS_INPUT	STRUC
StartingOffset		dd ?
MaxSDEntriesToReturn	dd ?
SD_ENUM_SDS_INPUT	ENDS
PSD_ENUM_SDS_INPUT	typedef ptr SD_ENUM_SDS_INPUT

SD_ENUM_SDS_ENTRY	STRUC
Hash			dd ?
SecurityId		dd ?
_Offset			dd ?
Length			dd ?
Descriptor		db 1 dup(?)
SD_ENUM_SDS_ENTRY	ENDS
PSD_ENUM_SDS_ENTRY	typedef ptr SD_ENUM_SDS_ENTRY

SD_ENUM_SDS_OUTPUT	STRUC
NextOffset		dd ?
NumSDEntriesReturned	dd ?
NumSDBytesReturned	dd ?
SDEntry			SD_ENUM_SDS_ENTRY 1 dup(<>)
SD_ENUM_SDS_OUTPUT	ENDS
PSD_ENUM_SDS_OUTPUT	typedef ptr SD_ENUM_SDS_OUTPUT

SD_GLOBAL_CHANGE_INPUT	STRUC
Flags			dd ?
ChangeType		dd ?
UNION ; {
SdChange		SD_CHANGE_MACHINE_SID_INPUT <>
SdQueryStats		SD_QUERY_STATS_INPUT <>
SdEnumSds		SD_ENUM_SDS_INPUT <>
ENDS ;
SD_GLOBAL_CHANGE_INPUT	ENDS
PSD_GLOBAL_CHANGE_INPUT typedef ptr SD_GLOBAL_CHANGE_INPUT

SD_GLOBAL_CHANGE_OUTPUT STRUC
Flags			dd ?
ChangeType		dd ?
UNION ; {
SdChange		SD_CHANGE_MACHINE_SID_OUTPUT <>
SdQueryStats		SD_QUERY_STATS_OUTPUT <>
SdEnumSds		SD_ENUM_SDS_OUTPUT <>
ENDS ;
SD_GLOBAL_CHANGE_OUTPUT ENDS
PSD_GLOBAL_CHANGE_OUTPUT typedef ptr SD_GLOBAL_CHANGE_OUTPUT

LOOKUP_STREAM_FROM_CLUSTER_INPUT  STRUC
Flags			dd ?
NumberOfClusters	dd ?
Cluster			LARGE_INTEGER 1 dup(<>)
LOOKUP_STREAM_FROM_CLUSTER_INPUT ENDS
PLOOKUP_STREAM_FROM_CLUSTER_INPUT typedef ptr LOOKUP_STREAM_FROM_CLUSTER_INPUT

LOOKUP_STREAM_FROM_CLUSTER_OUTPUT  STRUC
_Offset			dd ?
NumberOfMatches		dd ?
BufferSizeRequired	dd ?
LOOKUP_STREAM_FROM_CLUSTER_OUTPUT ENDS
PLOOKUP_STREAM_FROM_CLUSTER_OUTPUT typedef ptr LOOKUP_STREAM_FROM_CLUSTER_OUTPUT

LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_PAGE_FILE equ 0x00000001
LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_DENY_DEFRAG_SET equ 0x00000002
LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_FS_SYSTEM_FILE equ 0x00000004
LOOKUP_STREAM_FROM_CLUSTER_ENTRY_FLAG_TXF_SYSTEM_FILE equ 0x00000008

LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_MASK equ 0xff000000
LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_DATA equ 0x01000000
LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_INDEX equ 0x02000000
LOOKUP_STREAM_FROM_CLUSTER_ENTRY_ATTRIBUTE_SYSTEM equ 0x03000000

LOOKUP_STREAM_FROM_CLUSTER_ENTRY  STRUC
OffsetToNext		dd ?
Flags			dd ?
Reserved		LARGE_INTEGER <>
Cluster			LARGE_INTEGER <>
FileName		WCHAR 1 dup(?)
LOOKUP_STREAM_FROM_CLUSTER_ENTRY ENDS
PLOOKUP_STREAM_FROM_CLUSTER_ENTRY typedef ptr LOOKUP_STREAM_FROM_CLUSTER_ENTRY

FILE_TYPE_NOTIFICATION_INPUT  STRUC
Flags			dd ?
NumFileTypeIDs		dd ?
FileTypeID		GUID 1 dup(<>)
FILE_TYPE_NOTIFICATION_INPUT ENDS
PFILE_TYPE_NOTIFICATION_INPUT typedef ptr FILE_TYPE_NOTIFICATION_INPUT

FILE_TYPE_NOTIFICATION_FLAG_USAGE_BEGIN equ 0x00000001
FILE_TYPE_NOTIFICATION_FLAG_USAGE_END equ 0x00000002

DEFINE_GUID( FILE_TYPE_NOTIFICATION_GUID_PAGE_FILE,	    0x0d0a64a1, 0x38fc, 0x4db8, 0x9f, 0xe7, 0x3f, 0x43, 0x52, 0xcd, 0x7c, 0x5c );
DEFINE_GUID( FILE_TYPE_NOTIFICATION_GUID_HIBERNATION_FILE,  0xb7624d64, 0xb9a3, 0x4cf8, 0x80, 0x11, 0x5b, 0x86, 0xc9, 0x40, 0xe7, 0xb7 );
DEFINE_GUID( FILE_TYPE_NOTIFICATION_GUID_CRASHDUMP_FILE,    0x9d453eb7, 0xd2a6, 0x4dbd, 0xa2, 0xe3, 0xfb, 0xd0, 0xed, 0x91, 0x09, 0xa9 );

CSV_MGMTLOCK_CHECK_VOLUME_REDIRECTED equ 0x00000001
CSV_MGMT_LOCK		STRUC
Flags			dd ?
CSV_MGMT_LOCK		ENDS
PCSV_MGMT_LOCK		typedef ptr CSV_MGMT_LOCK

CSV_NAMESPACE_INFO	STRUC
Version			dd ?
DeviceNumber		dd ?
StartingOffset		LARGE_INTEGER <>
SectorSize		dd ?
CSV_NAMESPACE_INFO	ENDS
PCSV_NAMESPACE_INFO	typedef ptr CSV_NAMESPACE_INFO

CSV_NAMESPACE_INFO_V1	equ (CSV_NAMESPACE_INFO)
CSV_INVALID_DEVICE_NUMBER equ 0xFFFFFFFF

CSV_CONTROL_OP		typedef SDWORD
CsvControlStartRedirectFile equ 0x02
CsvControlStopRedirectFile equ 0x03
CsvControlQueryRedirectState equ 0x04
CsvControlQueryFileRevision equ 0x06
CsvControlQueryMdsPath	equ 0x08
CsvControlQueryFileRevisionFileId128 equ 0x09
CsvControlQueryVolumeRedirectState equ 0x0a
CsvControlEnableUSNRangeModificationTracking equ 0x0d
CsvControlMarkHandleLocalVolumeMount equ 0x0e
CsvControlUnmarkHandleLocalVolumeMount equ 0x0f

CSV_CONTROL_PARAM	STRUC
Operation		CSV_CONTROL_OP ?
Unused			LONGLONG ?
CSV_CONTROL_PARAM	ENDS
PCSV_CONTROL_PARAM	typedef ptr CSV_CONTROL_PARAM

CSV_QUERY_REDIRECT_STATE  STRUC
MdsNodeId		dd ?
DsNodeId		dd ?
FileRedirected		BOOLEAN ?
CSV_QUERY_REDIRECT_STATE ENDS
PCSV_QUERY_REDIRECT_STATE typedef ptr CSV_QUERY_REDIRECT_STATE

CSV_QUERY_FILE_REVISION	 STRUC
FileId			LONGLONG ?
FileRevision		LONGLONG 3 dup(?)
CSV_QUERY_FILE_REVISION ENDS
PCSV_QUERY_FILE_REVISION typedef ptr CSV_QUERY_FILE_REVISION

CSV_QUERY_FILE_REVISION_FILE_ID_128 STRUC
FileId			FILE_ID_128 <>
FileRevision		LONGLONG 3 dup(?)
CSV_QUERY_FILE_REVISION_FILE_ID_128 ENDS
PCSV_QUERY_FILE_REVISION_FILE_ID_128 typedef ptr CSV_QUERY_FILE_REVISION_FILE_ID_128

CSV_QUERY_MDS_PATH	STRUC
MdsNodeId		dd ?
DsNodeId		dd ?
PathLength		dd ?
Path			WCHAR 1 dup(?)
CSV_QUERY_MDS_PATH	ENDS
PCSV_QUERY_MDS_PATH	typedef ptr CSV_QUERY_MDS_PATH

CSVFS_DISK_CONNECTIVITY typedef SDWORD
CsvFsDiskConnectivityNone equ 0
CsvFsDiskConnectivityMdsNodeOnly equ 1
CsvFsDiskConnectivitySubsetOfNodes equ 2
CsvFsDiskConnectivityAllNodes equ 3

CSV_QUERY_VOLUME_REDIRECT_STATE	 STRUC
MdsNodeId		dd ?
DsNodeId		dd ?
IsDiskConnected		BOOLEAN ?
ClusterEnableDirectIo	BOOLEAN ?
DiskConnectivity	CSVFS_DISK_CONNECTIVITY ?
CSV_QUERY_VOLUME_REDIRECT_STATE ENDS
PCSV_QUERY_VOLUME_REDIRECT_STATE typedef ptr CSV_QUERY_VOLUME_REDIRECT_STATE

CSV_QUERY_VETO_FILE_DIRECT_IO_OUTPUT  STRUC
VetoedFromAltitudeIntegral dd ?
VetoedFromAltitudeDecimal dd ?
Reason			WCHAR 256 dup(?)
CSV_QUERY_VETO_FILE_DIRECT_IO_OUTPUT ENDS
PCSV_QUERY_VETO_FILE_DIRECT_IO_OUTPUT typedef ptr CSV_QUERY_VETO_FILE_DIRECT_IO_OUTPUT

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)

CSV_IS_OWNED_BY_CSVFS	STRUC
OwnedByCSVFS		BOOLEAN ?
CSV_IS_OWNED_BY_CSVFS	ENDS
PCSV_IS_OWNED_BY_CSVFS	typedef ptr CSV_IS_OWNED_BY_CSVFS

FILE_LEVEL_TRIM_RANGE	STRUC
Offset			dd ?
Length			dd ?
FILE_LEVEL_TRIM_RANGE	ENDS
PFILE_LEVEL_TRIM_RANGE	typedef ptr FILE_LEVEL_TRIM_RANGE

FILE_LEVEL_TRIM		STRUC
Key			dd ?
NumRanges		dd ?
Ranges			FILE_LEVEL_TRIM_RANGE 1 dup(?)
FILE_LEVEL_TRIM		ENDS
PFILE_LEVEL_TRIM	typedef ptr FILE_LEVEL_TRIM

FILE_LEVEL_TRIM_OUTPUT	STRUC
NumRangesProcessed	dd ?
FILE_LEVEL_TRIM_OUTPUT	ENDS
PFILE_LEVEL_TRIM_OUTPUT typedef ptr FILE_LEVEL_TRIM_OUTPUT

QUERY_FILE_LAYOUT_RESTART equ (0x00000001)
QUERY_FILE_LAYOUT_INCLUDE_NAMES equ (0x00000002)
QUERY_FILE_LAYOUT_INCLUDE_STREAMS equ (0x00000004)
QUERY_FILE_LAYOUT_INCLUDE_EXTENTS equ (0x00000008)
QUERY_FILE_LAYOUT_INCLUDE_EXTRA_INFO equ (0x00000010)
QUERY_FILE_LAYOUT_INCLUDE_STREAMS_WITH_NO_CLUSTERS_ALLOCATED equ (0x00000020)
QUERY_FILE_LAYOUT_FILTER_TYPE typedef SDWORD
QUERY_FILE_LAYOUT_FILTER_TYPE_NONE equ 0
QUERY_FILE_LAYOUT_FILTER_TYPE_CLUSTERS equ 1
QUERY_FILE_LAYOUT_FILTER_TYPE_FILEID equ 2
QUERY_FILE_LAYOUT_NUM_FILTER_TYPES equ 3

CLUSTER_RANGE		STRUC
StartingCluster		LARGE_INTEGER <>
ClusterCount		LARGE_INTEGER <>
CLUSTER_RANGE		ENDS
PCLUSTER_RANGE		typedef ptr CLUSTER_RANGE

FILE_REFERENCE_RANGE	STRUC
StartingFileReferenceNumber dd ?
EndingFileReferenceNumber dd ?
FILE_REFERENCE_RANGE	ENDS
PFILE_REFERENCE_RANGE	typedef ptr FILE_REFERENCE_RANGE

QUERY_FILE_LAYOUT_INPUT	 STRUC
NumberOfPairs		dd ?
Flags			dd ?
FilterType		QUERY_FILE_LAYOUT_FILTER_TYPE ?
Reserved		dd ?
UNION Filter
ClusterRanges		CLUSTER_RANGE 1 dup(?)
FileReferenceRanges	FILE_REFERENCE_RANGE 1 dup(?)
ENDS
QUERY_FILE_LAYOUT_INPUT ENDS
PQUERY_FILE_LAYOUT_INPUT typedef ptr QUERY_FILE_LAYOUT_INPUT

QUERY_FILE_LAYOUT_SINGLE_INSTANCED equ (0x00000001)

QUERY_FILE_LAYOUT_OUTPUT  STRUC
FileEntryCount		dd ?
FirstFileOffset		dd ?
Flags			dd ?
Reserved		dd ?
QUERY_FILE_LAYOUT_OUTPUT ENDS
PQUERY_FILE_LAYOUT_OUTPUT typedef ptr QUERY_FILE_LAYOUT_OUTPUT

FILE_LAYOUT_ENTRY	STRUC
Version			dd ?
NextFileOffset		dd ?
Flags			dd ?
FileAttributes		dd ?
FileReferenceNumber	dd ?
FirstNameOffset		dd ?
FirstStreamOffset	dd ?
ExtraInfoOffset		dd ?
Reserved		dd ?
FILE_LAYOUT_ENTRY	ENDS
PFILE_LAYOUT_ENTRY	typedef ptr FILE_LAYOUT_ENTRY

FILE_LAYOUT_NAME_ENTRY_PRIMARY equ (0x00000001)
FILE_LAYOUT_NAME_ENTRY_DOS equ (0x00000002)

FILE_LAYOUT_NAME_ENTRY	STRUC
NextNameOffset		dd ?
Flags			dd ?
ParentFileReferenceNumber dd ?
FileNameLength		dd ?
Reserved		dd ?
FileName		WCHAR 1 dup(?)
FILE_LAYOUT_NAME_ENTRY	ENDS
PFILE_LAYOUT_NAME_ENTRY typedef ptr FILE_LAYOUT_NAME_ENTRY

FILE_LAYOUT_INFO_ENTRY	STRUC
STRUC BasicInformation
 CreationTime		LARGE_INTEGER <>
 LastAccessTime		LARGE_INTEGER <>
 LastWriteTime		LARGE_INTEGER <>
 ChangeTime		LARGE_INTEGER <>
 FileAttributes		dd ?
ENDS
OwnerId			dd ?
SecurityId		dd ?
Usn			USN ?
FILE_LAYOUT_INFO_ENTRY	ENDS
PFILE_LAYOUT_INFO_ENTRY typedef ptr FILE_LAYOUT_INFO_ENTRY

STREAM_LAYOUT_ENTRY_IMMOVABLE equ (0x00000001)
STREAM_LAYOUT_ENTRY_PINNED equ (0x00000002)
STREAM_LAYOUT_ENTRY_RESIDENT equ (0x00000004)
STREAM_LAYOUT_ENTRY_NO_CLUSTERS_ALLOCATED equ (0x00000008)

STREAM_LAYOUT_ENTRY	STRUC
Version			dd ?
NextStreamOffset	dd ?
Flags			dd ?
ExtentInformationOffset dd ?
AllocationSize		LARGE_INTEGER <>
EndOfFile		LARGE_INTEGER <>
Reserved		dd ?
AttributeFlags		dd ?
StreamIdentifierLength	dd ?
StreamIdentifier	WCHAR 1 dup(?)
STREAM_LAYOUT_ENTRY	ENDS
PSTREAM_LAYOUT_ENTRY	typedef ptr STREAM_LAYOUT_ENTRY

STREAM_EXTENT_ENTRY_AS_RETRIEVAL_POINTERS equ (0x00000001)
STREAM_EXTENT_ENTRY_ALL_EXTENTS equ (0x00000002)

STREAM_EXTENT_ENTRY	STRUC
Flags			dd ?
UNION ExtentInformation
 RetrievalPointers	RETRIEVAL_POINTERS_BUFFER ?
ENDS
STREAM_EXTENT_ENTRY	ENDS
PSTREAM_EXTENT_ENTRY	typedef ptr STREAM_EXTENT_ENTRY

CHECKSUM_TYPE_UNCHANGED equ (-1)

CHECKSUM_TYPE_NONE	equ (0)
CHECKSUM_TYPE_CRC32	equ (1)
CHECKSUM_TYPE_CRC64	equ (2)
CHECKSUM_TYPE_ECC	equ (3)
CHECKSUM_TYPE_FIRST_UNUSED_TYPE equ (4)

FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF equ (1)

FSCTL_GET_INTEGRITY_INFORMATION_BUFFER	STRUC
ChecksumAlgorithm	dw ?
Reserved		dw ?
Flags			dd ?
ChecksumChunkSizeInBytes dd ?
ClusterSizeInBytes	dd ?
FSCTL_GET_INTEGRITY_INFORMATION_BUFFER ENDS
PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER typedef ptr FSCTL_GET_INTEGRITY_INFORMATION_BUFFER

FSCTL_SET_INTEGRITY_INFORMATION_BUFFER	STRUC
ChecksumAlgorithm	dw ?
Reserved		dw ?
Flags			dd ?
FSCTL_SET_INTEGRITY_INFORMATION_BUFFER ENDS
PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER typedef ptr FSCTL_SET_INTEGRITY_INFORMATION_BUFFER

FSCTL_OFFLOAD_READ_INPUT STRUC
Size			dd ?
Flags			dd ?
TokenTimeToLive		dd ?
Reserved		dd ?
FileOffset		dd ?
CopyLength		dd ?
FSCTL_OFFLOAD_READ_INPUT ENDS
PFSCTL_OFFLOAD_READ_INPUT typedef ptr FSCTL_OFFLOAD_READ_INPUT

FSCTL_OFFLOAD_READ_OUTPUT STRUC
Size			dd ?
Flags			dd ?
TransferLength		dd ?
Token			db 512 dup(?)
FSCTL_OFFLOAD_READ_OUTPUT ENDS
PFSCTL_OFFLOAD_READ_OUTPUT typedef ptr FSCTL_OFFLOAD_READ_OUTPUT

OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND_CURRENT_RANGE equ (1)

FSCTL_OFFLOAD_WRITE_INPUT STRUC
Size			dd ?
Flags			dd ?
FileOffset		dd ?
CopyLength		dd ?
TransferOffset		dd ?
Token			db 512 dup(?)
FSCTL_OFFLOAD_WRITE_INPUT ENDS
PFSCTL_OFFLOAD_WRITE_INPUT typedef ptr FSCTL_OFFLOAD_WRITE_INPUT

FSCTL_OFFLOAD_WRITE_OUTPUT STRUC
Size			dd ?
Flags			dd ?
LengthWritten		dd ?
FSCTL_OFFLOAD_WRITE_OUTPUT ENDS
PFSCTL_OFFLOAD_WRITE_OUTPUT typedef ptr FSCTL_OFFLOAD_WRITE_OUTPUT

SET_PURGE_FAILURE_MODE_INPUT STRUC
Flags			dd ?
SET_PURGE_FAILURE_MODE_INPUT ENDS
PSET_PURGE_FAILURE_MODE_INPUT typedef ptr SET_PURGE_FAILURE_MODE_INPUT

SET_PURGE_FAILURE_MODE_ENABLED equ 0x00000001
SET_PURGE_FAILURE_MODE_DISABLED equ 0x00000002

DEDUP_QUERY_FILE_HASHES_INPUT_BUFFER STRUC
Version			dd ?
QueryFlags		dd ?
HashAlgorithm		dd ?
RangeOffsetInFile	LARGE_INTEGER <>
RangeLength		LARGE_INTEGER <>
DEDUP_QUERY_FILE_HASHES_INPUT_BUFFER ENDS
PDEDUP_QUERY_FILE_HASHES_INPUT_BUFFER typedef ptr DEDUP_QUERY_FILE_HASHES_INPUT_BUFFER

DEDUP_CHUNK_INFORMATION_HASH32	STRUC
ChunkFlags		dd ?
ChunkOffsetInFile	LONGLONG ?
ChunkSize		LONGLONG ?
HashVal			db 32 dup(?)
DEDUP_CHUNK_INFORMATION_HASH32 ENDS
PDEDUP_CHUNK_INFORMATION_HASH32 typedef ptr DEDUP_CHUNK_INFORMATION_HASH32

DEDUP_FILE_OPERATION	STRUC
Code			dd ?
DEDUP_FILE_OPERATION	ENDS
PDEDUP_FILE_OPERATION	typedef ptr DEDUP_FILE_OPERATION

DEDUP_FILE_OP_NOTIFY_OPTIMIZATION equ 0xc0000013
DEDUP_FILE_OP_SET_ZERO_DATA equ 0xc0000002
DEDUP_FILE_RECALL	equ 0xc0000009
DEDUP_FILE_OP_SET_REPARSE_POINT equ 0xc0000001

REPAIR_COPIES_INPUT	STRUC
Size			dd ?
Flags			dd ?
FileOffset		LARGE_INTEGER <>
Length			dd ?
SourceCopy		dd ?
NumberOfRepairCopies	dd ?
RepairCopies		dd ANYSIZE_ARRAY dup(?)
REPAIR_COPIES_INPUT	ENDS
PREPAIR_COPIES_INPUT	typedef ptr REPAIR_COPIES_INPUT

REPAIR_COPIES_OUTPUT	STRUC
Size			dd ?
Status			dd ?
ResumeFileOffset	LARGE_INTEGER <>
REPAIR_COPIES_OUTPUT	ENDS
PREPAIR_COPIES_OUTPUT	typedef ptr REPAIR_COPIES_OUTPUT

FILE_REGION_USAGE_VALID_CACHED_DATA equ 0x00000001
FILE_REGION_USAGE_VALID_NONCACHED_DATA equ 0x00000002

FILE_REGION_INFO	STRUC
FileOffset		LONGLONG ?
Length			LONGLONG ?
Usage			dd ?
Reserved		dd ?
FILE_REGION_INFO	ENDS
PFILE_REGION_INFO	typedef ptr FILE_REGION_INFO

FILE_REGION_OUTPUT	STRUC
Flags			dd ?
TotalRegionEntryCount	dd ?
RegionEntryCount	dd ?
Reserved		dd ?
Region			FILE_REGION_INFO 1 dup(?)
FILE_REGION_OUTPUT	ENDS
PFILE_REGION_OUTPUT	typedef ptr FILE_REGION_OUTPUT

FILE_REGION_INPUT	STRUC
FileOffset		LONGLONG ?
Length			LONGLONG ?
DesiredUsage		dd ?
FILE_REGION_INPUT	ENDS
PFILE_REGION_INPUT	typedef ptr FILE_REGION_INPUT

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN8)

VALID_WRITE_USN_REASON_MASK equ (USN_REASON_DATA_OVERWRITE OR USN_REASON_CLOSE)

WRITE_USN_REASON_INPUT	STRUC
Flags			dd ?
UsnReasonToWrite	dd ?
WRITE_USN_REASON_INPUT	ENDS
PWRITE_USN_REASON_INPUT typedef ptr WRITE_USN_REASON_INPUT

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WINBLUE)

FILE_STORAGE_TIER_NAME_LENGTH equ (256)
FILE_STORAGE_TIER_DESCRIPTION_LENGTH equ (512)

FILE_STORAGE_TIER_FLAG_NO_SEEK_PENALTY equ (0x00020000)
FILE_STORAGE_TIER_FLAG_WRITE_BACK_CACHE equ (0x00200000)

FILE_STORAGE_TIER_MEDIA_TYPE typedef SDWORD
FileStorageTierMediaTypeUnspecified equ 0
FileStorageTierMediaTypeDisk equ 1
FileStorageTierMediaTypeSsd equ 2

FILE_STORAGE_TIER	STRUC
Id			GUID<>
Name			WCHAR FILE_STORAGE_TIER_NAME_LENGTH dup(?)
Description		WCHAR FILE_STORAGE_TIER_NAME_LENGTH dup(?)
Flags			dd ?
ProvisionedCapacity	dd ?
MediaType		FILE_STORAGE_TIER_MEDIA_TYPE ?
FILE_STORAGE_TIER	ENDS
PFILE_STORAGE_TIER	typedef ptr FILE_STORAGE_TIER

QUERY_STORAGE_CLASSES_FLAGS_MEASURE_WRITE equ 0x80000000
QUERY_STORAGE_CLASSES_FLAGS_MEASURE_READ equ 0x40000000

FSCTL_QUERY_STORAGE_CLASSES_OUTPUT STRUC
Version			dd ?
Size			dd ?
Flags			dd ?
TotalNumberOfTiers	dd ?
NumberOfTiersReturned	dd ?
Tiers			FILE_STORAGE_TIER ANYSIZE_ARRAY dup(?)
FSCTL_QUERY_STORAGE_CLASSES_OUTPUT ENDS
PFSCTL_QUERY_STORAGE_CLASSES_OUTPUT typedef ptr FSCTL_QUERY_STORAGE_CLASSES_OUTPUT

FSCTL_QUERY_STORAGE_CLASSES_OUTPUT_VERSION equ FSCTL_QUERY_STORAGE_CLASSES_OUTPUT

FSCTL_QUERY_REGION_INFO_INPUT STRUC
Version			dd ?
Size			dd ?
Flags			dd ?
NumberOfTierIds		dd ?
TierIds			GUID ANYSIZE_ARRAY dup(<>)
FSCTL_QUERY_REGION_INFO_INPUT ENDS
PFSCTL_QUERY_REGION_INFO_INPUT typedef ptr FSCTL_QUERY_REGION_INFO_INPUT

FSCTL_QUERY_REGION_INFO_INPUT_VERSION equ FSCTL_QUERY_REGION_INFO_INPUT

FILE_STORAGE_TIER_REGION  STRUC
TierId			GUID <>
Offset			dd ?
Length			dd ?
FILE_STORAGE_TIER_REGION ENDS
PFILE_STORAGE_TIER_REGION typedef ptr FILE_STORAGE_TIER_REGION

FSCTL_QUERY_REGION_INFO_OUTPUT	STRUC
Version			dd ?
Size			dd ?
Flags			dd ?
Reserved		dd ?
Alignment		dd ?
TotalNumberOfRegions	dd ?
NumberOfRegionsReturned dd ?
Regions			FILE_STORAGE_TIER_REGION ANYSIZE_ARRAY dup(?)
FSCTL_QUERY_REGION_INFO_OUTPUT ENDS
PFSCTL_QUERY_REGION_INFO_OUTPUT typedef ptr FSCTL_QUERY_REGION_INFO_OUTPUT

FSCTL_QUERY_REGION_INFO_OUTPUT_VERSION equ FSCTL_QUERY_REGION_INFO_OUTPUT

endif

if (_WIN32_WINNT GE _WIN32_WINNT_WIN7)

WOF_CURRENT_VERSION	equ (0x00000001)
WOF_PROVIDER_WIM	equ (0x00000001)

WOF_EXTERNAL_INFO	STRUC
Version			dd ?
Provider		dd ?
WOF_EXTERNAL_INFO	ENDS
PWOF_EXTERNAL_INFO	typedef ptr WOF_EXTERNAL_INFO

WOF_EXTERNAL_FILE_ID	STRUC
FileId			FILE_ID_128 <>
WOF_EXTERNAL_FILE_ID	ENDS
PWOF_EXTERNAL_FILE_ID	typedef ptr WOF_EXTERNAL_FILE_ID

ifndef WIM_PROVIDER_HASH_SIZE
WIM_PROVIDER_HASH_SIZE	equ 20
endif

WIM_PROVIDER_CURRENT_VERSION equ (0x00000001)

WIM_PROVIDER_EXTERNAL_FLAG_NOT_ACTIVE equ (0x00000001)
WIM_PROVIDER_EXTERNAL_FLAG_SUSPENDED equ (0x00000002)

WIM_PROVIDER_EXTERNAL_INFO  STRUC
Version			dd ?
Flags			dd ?
DataSourceId		LARGE_INTEGER <>
ResourceHash		db WIM_PROVIDER_HASH_SIZE dup(?)
WIM_PROVIDER_EXTERNAL_INFO ENDS
PWIM_PROVIDER_EXTERNAL_INFO typedef ptr WIM_PROVIDER_EXTERNAL_INFO

WIM_BOOT_OS_WIM		equ (0x00000001)
WIM_BOOT_NOT_OS_WIM	equ (0x00000000)

WIM_PROVIDER_ADD_OVERLAY_INPUT	STRUC
WimType			dd ?
WimIndex		dd ?
WimFileNameOffset	dd ?
WimFileNameLength	dd ?
WIM_PROVIDER_ADD_OVERLAY_INPUT ENDS
PWIM_PROVIDER_ADD_OVERLAY_INPUT typedef ptr WIM_PROVIDER_ADD_OVERLAY_INPUT

WIM_PROVIDER_UPDATE_OVERLAY_INPUT  STRUC
DataSourceId		LARGE_INTEGER <>
WimFileNameOffset	dd ?
WimFileNameLength	dd ?
WIM_PROVIDER_UPDATE_OVERLAY_INPUT ENDS
PWIM_PROVIDER_UPDATE_OVERLAY_INPUT typedef ptr WIM_PROVIDER_UPDATE_OVERLAY_INPUT

WIM_PROVIDER_REMOVE_OVERLAY_INPUT  STRUC
DataSourceId		LARGE_INTEGER <>
WIM_PROVIDER_REMOVE_OVERLAY_INPUT ENDS
PWIM_PROVIDER_REMOVE_OVERLAY_INPUT typedef ptr WIM_PROVIDER_REMOVE_OVERLAY_INPUT

WIM_PROVIDER_OVERLAY_ENTRY  STRUC
NextEntryOffset		dd ?
DataSourceId		LARGE_INTEGER <>
WimGuid			GUID <>
WimFileNameOffset	dd ?
WimType			dd ?
WimIndex		dd ?
Flags			dd ?
WIM_PROVIDER_OVERLAY_ENTRY ENDS
PWIM_PROVIDER_OVERLAY_ENTRY typedef ptr WIM_PROVIDER_OVERLAY_ENTRY

endif

endif

IOCTL_VOLUME_BASE	equ 0x00000056

if (NTDDI_VERSION GE NTDDI_WIN2K)

IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS equ CTL_CODE(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)

DISK_EXTENT		STRUC
DiskNumber		dd ?
StartingOffset		LARGE_INTEGER <>
ExtentLength		LARGE_INTEGER <>
DISK_EXTENT		ENDS
PDISK_EXTENT		typedef ptr DISK_EXTENT

VOLUME_DISK_EXTENTS	STRUC
NumberOfDiskExtents	dd ?
Extents			DISK_EXTENT ANYSIZE_ARRAY dup(<>)
VOLUME_DISK_EXTENTS	ENDS
PVOLUME_DISK_EXTENTS	typedef ptr VOLUME_DISK_EXTENTS

IOCTL_VOLUME_ONLINE	equ CTL_CODE(IOCTL_VOLUME_BASE, 2, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)
IOCTL_VOLUME_OFFLINE	equ CTL_CODE(IOCTL_VOLUME_BASE, 3, METHOD_BUFFERED, FILE_READ_ACCESS OR FILE_WRITE_ACCESS)

endif

if (NTDDI_VERSION GE NTDDI_WINXP)

IOCTL_VOLUME_IS_CLUSTERED equ CTL_CODE(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
IOCTL_VOLUME_GET_GPT_ATTRIBUTES equ CTL_CODE(IOCTL_VOLUME_BASE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)

VOLUME_GET_GPT_ATTRIBUTES_INFORMATION  STRUC
GptAttributes		dd ?
VOLUME_GET_GPT_ATTRIBUTES_INFORMATION ENDS
PVOLUME_GET_GPT_ATTRIBUTES_INFORMATION typedef ptr VOLUME_GET_GPT_ATTRIBUTES_INFORMATION

endif

endif

