diff --git a/PInvoke/Kernel32/WinIOCtl.Structs.cs b/PInvoke/Kernel32/WinIOCtl.Structs.cs index 2e909289..dcb5b6b8 100644 --- a/PInvoke/Kernel32/WinIOCtl.Structs.cs +++ b/PInvoke/Kernel32/WinIOCtl.Structs.cs @@ -6,6 +6,74 @@ namespace Vanara.PInvoke { public static partial class Kernel32 { + /// + /// The data partition type that is created and recognized by Windows. + /// + /// Only partitions of this type can be assigned drive letters, receive volume GUID paths, host mounted folders (also called volume + /// mount points), and be enumerated by calls to FindFirstVolume and FindNextVolume. + /// + /// + /// This value can be set only for basic disks, with one exception. If both PARTITION_BASIC_DATA_GUID and + /// GPT_ATTRIBUTE_PLATFORM_REQUIRED are set for a partition on a basic disk that is subsequently converted to a dynamic disk, the + /// partition remains a basic partition, even though the rest of the disk is a dynamic disk.This is because the partition is + /// considered to be an OEM partition on a GPT disk. + /// + /// + public static readonly Guid PARTITION_BASIC_DATA_GUID = new Guid(0xEBD0A0A2, 0xB9E5, 0x4433, 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7); + + /// BSP partition + public static readonly Guid PARTITION_BSP_GUID = new Guid(0x57434F53, 0x4DF9, 0x45B9, 0x8E, 0x9E, 0x23, 0x70, 0xF0, 0x06, 0x45, 0x7C); + + /// Cluster metadata partition + public static readonly Guid PARTITION_CLUSTER_GUID = new Guid(0xDB97DBA9, 0x0840, 0x4BAE, 0x97, 0xF0, 0xFF, 0xB9, 0xA3, 0x27, 0xC7, 0xE1); + + /// DPP partition + public static readonly Guid PARTITION_DPP_GUID = new Guid(0x57434F53, 0x94CB, 0x43F0, 0xA5, 0x33, 0xD7, 0x3C, 0x10, 0xCF, 0xA5, 0x7D); + + /// There is no partition. This value can be set for basic and dynamic disks. + public static readonly Guid PARTITION_ENTRY_UNUSED_GUID = new Guid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + + /// The partition is an LDM data partition on a dynamic disk. This value can be set only for dynamic disks. + public static readonly Guid PARTITION_LDM_DATA_GUID = new Guid(0xAF9B60A0, 0x1431, 0x4F62, 0xBC, 0x68, 0x33, 0x11, 0x71, 0x4A, 0x69, 0xAD); + + /// + /// The partition is a Logical Disk Manager (LDM) metadata partition on a dynamic disk. This value can be set only for dynamic disks. + /// + public static readonly Guid PARTITION_LDM_METADATA_GUID = new Guid(0x5808C8AA, 0x7E8F, 0x42E0, 0x85, 0xD2, 0xE1, 0xE9, 0x04, 0x34, 0xCF, 0xB3); + + /// Main OS partition + public static readonly Guid PARTITION_MAIN_OS_GUID = new Guid(0x57434F53, 0x8F45, 0x405E, 0x8A, 0x23, 0x18, 0x6D, 0x8A, 0x43, 0x30, 0xD3); + + /// The partition is a Microsoft recovery partition. This value can be set for basic and dynamic disks. + public static readonly Guid PARTITION_MSFT_RECOVERY_GUID = new Guid(0xDE94BBA4, 0x06D1, 0x4D40, 0xA1, 0x6A, 0xBF, 0xD5, 0x01, 0x79, 0xD6, 0xAC); + + /// The partition is a Microsoft reserved partition. This value can be set for basic and dynamic disks. + public static readonly Guid PARTITION_MSFT_RESERVED_GUID = new Guid(0xE3C9E316, 0x0B5C, 0x4DB8, 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE); + + /// Microsoft shadow copy partition + public static readonly Guid PARTITION_MSFT_SNAPSHOT_GUID = new Guid(0xCADDEBF1, 0x4400, 0x4DE8, 0xB1, 0x03, 0x12, 0x11, 0x7D, 0xCF, 0x3C, 0xCF); + + /// OS data partition + public static readonly Guid PARTITION_OS_DATA_GUID = new Guid(0x57434F53, 0x23F2, 0x44D5, 0xA8, 0x30, 0x67, 0xBB, 0xDA, 0xA6, 0x09, 0xF9); + + /// Patch partition + public static readonly Guid PARTITION_PATCH_GUID = new Guid(0x8967A686, 0x96AA, 0x6AA8, 0x95, 0x89, 0xA8, 0x42, 0x56, 0x54, 0x10, 0x90); + + /// PreInstalled partition + public static readonly Guid PARTITION_PRE_INSTALLED_GUID = new Guid(0x57434F53, 0x7FE0, 0x4196, 0x9B, 0x42, 0x42, 0x7B, 0x51, 0x64, 0x34, 0x84); + + /// Storage Spaces protective partition + public static readonly Guid PARTITION_SPACES_DATA_GUID = new Guid(0xE7ADDCB4, 0xDC34, 0x4539, 0x9A, 0x76, 0xEB, 0xBD, 0x07, 0xBE, 0x6F, 0x7E); + + /// Storage Spaces protective partition + public static readonly Guid PARTITION_SPACES_GUID = new Guid(0xE75CAF8F, 0xF680, 0x4CEE, 0xAF, 0xA3, 0xB0, 0x01, 0xE5, 0x6E, 0xFC, 0x2D); + + /// The partition is an EFI system partition. This value can be set for basic and dynamic disks. + public static readonly Guid PARTITION_SYSTEM_GUID = new Guid(0xC12A7328, 0xF81F, 0x11D2, 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B); + + /// Windows system partition + public static readonly Guid PARTITION_WINDOWS_SYSTEM_GUID = new Guid(0x57434F53, 0xE3E3, 0x4631, 0xA5, 0xC5, 0x26, 0xD2, 0x24, 0x38, 0x73, 0xAA); + /// The detected partition type. [PInvokeData("winioctl.h", MSDNShortId = "57ca68f4-f748-4bc4-90c3-13d545716d87")] public enum DETECTION_TYPE @@ -37,6 +105,188 @@ namespace Vanara.PInvoke KeepReadData } + /// + /// Specifies the partition entry attributes used for diagnostics, recovery tools, and other firmware essential to the operation of + /// the device. + /// + [PInvokeData("winioctl.h", MSDNShortId = "373b4eb3-af6d-4112-9787-f14c19972189")] + [Flags] + public enum GPT_ATTRIBUTE : ulong + { + /// + /// If this attribute is set, the partition is required by a computer to function properly. + /// + /// For example, this attribute must be set for OEM partitions. Note that if this attribute is set, you can use the DiskPart.exe + /// utility to perform partition operations such as deleting the partition. However, because the partition is not a volume, you + /// cannot use the DiskPart.exe utility to perform volume operations on the partition. + /// + /// + /// This attribute can be set for basic and dynamic disks. If it is set for a partition on a basic disk and the disk is converted + /// to a dynamic disk, the partition remains a basic partition, even though the rest of the disk is a dynamic disk. This is + /// because the partition is considered to be an OEM partition on a GPT disk. + /// + /// + GPT_ATTRIBUTE_PLATFORM_REQUIRED = 0x0000000000000001, + + /// + /// If this attribute is set, the partition does not receive a drive letter by default when the disk is moved to another computer + /// or when the disk is seen for the first time by a computer. + /// This attribute is useful in storage area network (SAN) environments. + /// Despite its name, this attribute can be set for basic and dynamic disks. + /// + GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER = 0x8000000000000000, + + /// + /// If this attribute is set, the partition is not detected by the Mount Manager. + /// + /// As a result, the partition does not receive a drive letter, does not receive a volume GUID path, does not host mounted + /// folders (also called volume mount points), and is not enumerated by calls to FindFirstVolume and FindNextVolume.This ensures + /// that applications such as Disk Defragmenter do not access the partition. The Volume Shadow Copy Service (VSS) uses this attribute. + /// + /// Despite its name, this attribute can be set for basic and dynamic disks. + /// + GPT_BASIC_DATA_ATTRIBUTE_HIDDEN = 0x4000000000000000, + + /// + /// If this attribute is set, the partition is a shadow copy of another partition. + /// + /// VSS uses this attribute. This attribute is an indication for file system filter driver-based software (such as antivirus + /// programs) to avoid attaching to the volume. + /// + /// + /// An application can use the attribute to differentiate a shadow copy volume from a production volume.An application that does + /// a fast recovery, for example, will break a shadow copy LUN and clear the read-only and hidden attributes and this + /// attribute.This attribute is set when the shadow copy is created and cleared when the shadow copy is broken. + /// + /// Despite its name, this attribute can be set for basic and dynamic disks. + /// Windows Server 2003: This attribute is not supported before Windows Server 2003 with SP1. + /// + GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY = 0x2000000000000000, + + /// + /// If this attribute is set, the partition is read-only. + /// + /// Writes to the partition will fail. IOCTL_DISK_IS_WRITABLE will fail with the ERROR_WRITE_PROTECT Win32 error code, which + /// causes the file system to mount as read only, if a file system is present. + /// + /// VSS uses this attribute. + /// + /// Do not set this attribute for dynamic disks. Setting it can cause I/O errors and prevent the file system from mounting properly. + /// + /// + GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY = 0x1000000000000000, + + /// Undocumented. + GPT_BASIC_DATA_ATTRIBUTE_OFFLINE = 0x0800000000000000, + + /// Undocumented. + GPT_BASIC_DATA_ATTRIBUTE_DAX = 0x0400000000000000, + + /// Undocumented. + GPT_BASIC_DATA_ATTRIBUTE_SERVICE = 0x0200000000000000, + + /// Undocumented. + GPT_SPACES_ATTRIBUTE_NO_METADATA = 0x8000000000000000, + } + + /// Partition types. + [PInvokeData("winioctl.h")] + public enum PartitionType : byte + { + /// Unused entry + PARTITION_ENTRY_UNUSED = 0, + + /// Specifies a partition with 12-bit FAT entries + PARTITION_FAT_12, + + /// Specifies a XENIX Type 1 partition + PARTITION_XENIX_1, + + /// Specifies a XENIX Type 2 partition + PARTITION_XENIX_2, + + /// Specifies a partition with 16-bit FAT entries. + PARTITION_FAT_16, + + /// Specifies an MS-DOS V4 extended partition + PARTITION_EXTENDED, + + /// Specifies an MS-DOS V4 huge partition + PARTITION_HUGE, + + /// Specifies an IFS partition + PARTITION_IFS, + + /// OS/2 Boot Manager/OPUS/Coherent swap + PARTITION_OS2BOOTMGR = 0x0A, + + /// Specifies a FAT32 partition + PARTITION_FAT32, + + /// Win95 partition using extended int13 services + PARTITION_XINT13 = 0x0E, + + /// Windows 95/98: Specifies a partition that uses extended INT 13 services + PARTITION_FAT32_XINT13, + + /// Windows 95/98: Same as PARTITION_EXTENDED, but uses extended INT 13 services + PARTITION_XINT13_EXTENDED, + + /// Microsoft recovery partition + PARTITION_MSFT_RECOVERY = 0x27, + + /// Main OS partition + PARTITION_MAIN_OS = 0x28, + + /// OS data partition + PARTIITON_OS_DATA = 0x29, + + /// PreInstalled partition + PARTITION_PRE_INSTALLED = 0x2a, + + /// BSP partition + PARTITION_BSP = 0x2b, + + /// DPP partition + PARTITION_DPP = 0x2c, + + /// Windows system partition + PARTITION_WINDOWS_SYSTEM = 0x2d, + + /// Specifies a PowerPC Reference Platform partition + PARTITION_PREP = 0x41, + + /// Specifies a logical disk manager partition + PARTITION_LDM, + + /// OnTrack Disk Manager partition + PARTITION_DM = 0x54, + + /// EZ-Drive partition + PARTITION_EZDRIVE = 0x55, + + /// Specifies a UNIX partition + PARTITION_UNIX = 0x63, + + /// Storage Spaces protective partition + PARTITION_SPACES_DATA = 0xD7, + + /// Storage Spaces protective partition + PARTITION_SPACES = 0xE7, + + /// Gpt protective partition + PARTITION_GPT = 0xEE, + + /// System partition + PARTITION_SYSTEM = 0xEF, + + /// + /// Specifies an NTFT partition. This value is used in combination (that is, bitwise logically ORed) with the other values in + /// this table + /// + PARTITION_NTFT = 0x80, + } + /// /// /// The flags that identify reasons for changes that have accumulated in this file or directory journal record since the file or @@ -244,6 +494,151 @@ namespace Vanara.PInvoke public uint NumberOfElements; } + /// + /// Contains information that the IOCTL_DISK_CREATE_DISK control code uses to initialize GUID partition table (GPT), master boot + /// record (MBR), or raw disks. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-create_disk typedef struct _CREATE_DISK { PARTITION_STYLE + // PartitionStyle; union { CREATE_DISK_MBR Mbr; CREATE_DISK_GPT Gpt; } DUMMYUNIONNAME; } CREATE_DISK, *PCREATE_DISK; + [PInvokeData("winioctl.h", MSDNShortId = "ec4a1ef9-ff2e-41b3-951b-241c545f256b")] + [StructLayout(LayoutKind.Explicit)] + public struct CREATE_DISK + { + /// + /// The format of a partition. + /// For more information, see PARTITION_STYLE. + /// + [FieldOffset(0)] + public PARTITION_STYLE PartitionStyle; + + /// A CREATE_DISK_MBR structure that contains disk information when an MBR disk is to be initialized. + [FieldOffset(4)] + public CREATE_DISK_MBR Mbr; + + /// A CREATE_DISK_GPT structure that contains disk information when a GPT disk is to be initialized. + [FieldOffset(4)] + public CREATE_DISK_GPT Gpt; + } + + /// Contains information used by the IOCTL_DISK_CREATE_DISK control code to initialize GUID partition table (GPT) disks. + /// + /// The CREATE_DISK_GPT structure is defined as part of the CREATE_DISK structure. + /// + /// If a maximum partition count of less than 128 is specified, it will be reset to 128. This is in compliance with the EFI specification. + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-create_disk_gpt typedef struct _CREATE_DISK_GPT { GUID + // DiskId; DWORD MaxPartitionCount; } CREATE_DISK_GPT, *PCREATE_DISK_GPT; + [PInvokeData("winioctl.h", MSDNShortId = "526a265b-e15e-4cd2-adaf-c955a8cb92e5")] + [StructLayout(LayoutKind.Sequential)] + public struct CREATE_DISK_GPT + { + /// The disk identifier (GUID) of the GPT disk to be initialized. + public Guid DiskId; + + /// The maximum number of partitions allowed on the GPT disk to be initialized without repartitioning the disk. + public uint MaxPartitionCount; + } + + /// Contains information that the IOCTL_DISK_CREATE_DISK control code uses to initialize master boot record (MBR) disks. + /// The CREATE_DISK_MBR structure is part of the CREATE_DISK structure. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-create_disk_mbr typedef struct _CREATE_DISK_MBR { DWORD + // Signature; } CREATE_DISK_MBR, *PCREATE_DISK_MBR; + [PInvokeData("winioctl.h", MSDNShortId = "6b475622-371d-4097-9de1-6ef31af76322")] + [StructLayout(LayoutKind.Sequential)] + public struct CREATE_DISK_MBR + { + /// The disk signature of the MBR disk to be initialized. + public uint Signature; + } + + /// Contains information that describes an update sequence number (USN) change journal. + /// For more information, see Creating, Modifying, and Deleting a Change Journal. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-create_usn_journal_data typedef struct { DWORDLONG + // MaximumSize; DWORDLONG AllocationDelta; } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA; + [PInvokeData("winioctl.h", MSDNShortId = "84d00427-c6eb-41aa-a594-8c57bdd56202")] + [StructLayout(LayoutKind.Sequential)] + public struct CREATE_USN_JOURNAL_DATA + { + /// + /// The target maximum size that the NTFS file system allocates for the change journal, in bytes. + /// + /// The change journal can grow larger than this value, but it is then truncated at the next NTFS file system checkpoint to less + /// than this value. + /// + /// + public ulong MaximumSize; + + /// + /// The size of memory allocation that is added to the end and removed from the beginning of the change journal, in bytes. + /// + /// The change journal can grow to more than the sum of the values of MaximumSize and AllocationDelta before being trimmed. + /// + /// + public ulong AllocationDelta; + } + + /// + /// Contains information on the deletion of an update sequence number (USN) change journal using the FSCTL_DELETE_USN_JOURNAL control code. + /// + /// For more information, see Creating, Modifying, and Deleting a Change Journal. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-delete_usn_journal_data typedef struct { DWORDLONG + // UsnJournalID; DWORD DeleteFlags; } DELETE_USN_JOURNAL_DATA, *PDELETE_USN_JOURNAL_DATA; + [PInvokeData("winioctl.h", MSDNShortId = "06db4b46-fc91-40e0-ab0b-1e014622ae22")] + [StructLayout(LayoutKind.Sequential)] + public struct DELETE_USN_JOURNAL_DATA + { + /// + /// The identifier of the change journal to be deleted. + /// + /// If the journal is active and deletion is requested by setting the USN_DELETE_FLAG_DELETE flag in the DeleteFlags + /// member, then this identifier must specify the change journal for the current volume. Use FSCTL_QUERY_USN_JOURNAL to retrieve + /// the identifier of this change journal. If in this case the identifier is not for the current volume's change journal, + /// FSCTL_DELETE_USN_JOURNAL fails. + /// + /// + /// If notification instead of deletion is requested by setting only the USN_DELETE_FLAG_NOTIFY flag in DeleteFlags, + /// UsnJournalID is ignored. + /// + /// + public ulong UsnJournalID; + + /// + /// + /// Indicates whether deletion or notification regarding deletion is performed, or both. The DeleteFlags member must + /// contain one or both of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// USN_DELETE_FLAG_DELETE 0x00000001 + /// + /// If this flag is set and the USN_DELETE_FLAG_NOTIFY flag is not set, the FSCTL_DELETE_USN_JOURNAL operation starts the journal + /// deletion process and returns immediately. The journal deletion process continues, if necessary, across system restarts. If + /// this flag is set and the USN_DELETE_FLAG_NOTIFY flag is also set, both deletion and notification occur. If this flag is set + /// and the journal is active, you must provide the identifier for the change journal for the current volume in UsnJournalID or + /// the operation fails. If the journal is not active, then UsnJournalID is ignored and the journal is deleted. + /// + /// + /// + /// USN_DELETE_FLAG_NOTIFY 0x00000002 + /// + /// If this flag is set, the call sets up notification about when deletion is complete. The journal deletion request is completed + /// when the journal deletion process is complete. If this flag is set and the USN_DELETE_FLAG_DELETE flag is not set, then the + /// call sets up notification of a deletion that may already be in progress. For example, when your application starts, it might + /// use this flag to determine if a deletion is in progress. If this flag is set and the USN_DELETE_FLAG_DELETE flag is also set, + /// both deletion and notification occur. The notification is performed using an I/O completion port or another mechanism for + /// asynchronous event notification. + /// + /// + /// + /// + public uint DeleteFlags; + } + /// /// Provides information about the disk cache.This structure is used by the IOCTL_DISK_GET_CACHE_INFORMATION and /// IOCTL_DISK_SET_CACHE_INFORMATION control codes. @@ -637,6 +1032,431 @@ namespace Vanara.PInvoke public string StorageManagerName; } + /// + /// Contains information about the partitions of a drive. + /// NoteDRIVE_LAYOUT_INFORMATION is superseded by the DRIVE_LAYOUT_INFORMATION_EX structure. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-drive_layout_information typedef struct + // _DRIVE_LAYOUT_INFORMATION { DWORD PartitionCount; DWORD Signature; PARTITION_INFORMATION PartitionEntry[1]; } + // DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION; + [PInvokeData("winioctl.h", MSDNShortId = "e67ccaa7-a735-4695-8385-28f57b41821c")] + [StructLayout(LayoutKind.Sequential)] + public struct DRIVE_LAYOUT_INFORMATION + { + /// + /// The number of partitions on a drive. + /// + /// On disks with the MBR layout, this value is always a multiple of 4. Any partitions that are unused have a partition type of + /// PARTITION_ENTRY_UNUSED (0). + /// + /// + public uint PartitionCount; + + /// The drive signature value. + public uint Signature; + + /// A variable-sized array of PARTITION_INFORMATION structures, one structure for each partition on a drive. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] + public PARTITION_INFORMATION[] PartitionEntry; + } + + /// Contains extended information about a drive's partitions. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-drive_layout_information_ex typedef struct + // _DRIVE_LAYOUT_INFORMATION_EX { DWORD PartitionStyle; DWORD PartitionCount; union { DRIVE_LAYOUT_INFORMATION_MBR Mbr; + // DRIVE_LAYOUT_INFORMATION_GPT Gpt; } DUMMYUNIONNAME; PARTITION_INFORMATION_EX PartitionEntry[1]; } DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX; + [PInvokeData("winioctl.h", MSDNShortId = "381c87a8-fe40-4251-a4df-dddc9e2a126d")] + [StructLayout(LayoutKind.Explicit)] + public struct DRIVE_LAYOUT_INFORMATION_EX + { + /// + /// The style of the partitions on the drive enumerated by the PARTITION_STYLE enumeration. + /// + /// + /// Value + /// Meaning + /// + /// + /// PARTITION_STYLE_MBR 0 + /// Master boot record (MBR) format. + /// + /// + /// PARTITION_STYLE_GPT 1 + /// GUID Partition Table (GPT) format. + /// + /// + /// PARTITION_STYLE_RAW 2 + /// Partition not formatted in either of the recognized formats—MBR or GPT. + /// + /// + /// + [FieldOffset(0)] + public uint PartitionStyle; + + /// + /// The number of partitions on the drive. On hard disks with the MBR layout, this value will always be a multiple of 4. Any + /// partitions that are actually unused will have a partition type of PARTITION_ENTRY_UNUSED (0) set in the + /// PartitionType member of the PARTITION_INFORMATION_MBR structure of the Mbr member of the + /// PARTITION_INFORMATION_EX structure of the PartitionEntry member of this structure. + /// + [FieldOffset(4)] + public uint PartitionCount; + + /// + /// A DRIVE_LAYOUT_INFORMATION_MBR structure containing information about the master boot record type partitioning on the drive. + /// + [FieldOffset(8)] + public DRIVE_LAYOUT_INFORMATION_MBR Mbr; + + /// + /// A DRIVE_LAYOUT_INFORMATION_GPT structure containing information about the GUID disk partition type partitioning on the drive. + /// + [FieldOffset(8)] + public DRIVE_LAYOUT_INFORMATION_GPT Gpt; + + /// A variable-sized array of PARTITION_INFORMATION_EX structures, one structure for each partition on the drive. + [FieldOffset(48)] + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] + public PARTITION_INFORMATION_EX[] PartitionEntry; + } + + /// Contains information about a drive's GUID partition table (GPT) partitions. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-drive_layout_information_gpt typedef struct + // _DRIVE_LAYOUT_INFORMATION_GPT { GUID DiskId; LARGE_INTEGER StartingUsableOffset; LARGE_INTEGER UsableLength; DWORD + // MaxPartitionCount; } DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT; + [PInvokeData("winioctl.h", MSDNShortId = "763b0d64-6dcc-411c-aca1-3beea0890124")] + [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 40)] + public struct DRIVE_LAYOUT_INFORMATION_GPT + { + /// The GUID of the disk. + public Guid DiskId; + + /// The starting byte offset of the first usable block. + public long StartingUsableOffset; + + /// The size of the usable blocks on the disk, in bytes. + public long UsableLength; + + /// The maximum number of partitions that can be defined in the usable block. + public uint MaxPartitionCount; + } + + /// Provides information about a drive's master boot record (MBR) partitions. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-drive_layout_information_mbr typedef struct + // _DRIVE_LAYOUT_INFORMATION_MBR { DWORD Signature; DWORD CheckSum; } DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR; + [PInvokeData("winioctl.h", MSDNShortId = "71c361fe-8c85-4915-9776-8ad3f5837e11")] + [StructLayout(LayoutKind.Sequential)] + public struct DRIVE_LAYOUT_INFORMATION_MBR + { + /// The signature of the drive. + public uint Signature; + + /// + public uint CheckSum; + } + + /// Contains statistical information from the exFAT file system. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-exfat_statistics typedef struct _EXFAT_STATISTICS { DWORD + // CreateHits; DWORD SuccessfulCreates; DWORD FailedCreates; DWORD NonCachedReads; DWORD NonCachedReadBytes; DWORD NonCachedWrites; + // DWORD NonCachedWriteBytes; DWORD NonCachedDiskReads; DWORD NonCachedDiskWrites; } EXFAT_STATISTICS, *PEXFAT_STATISTICS; + [PInvokeData("winioctl.h", MSDNShortId = "fc33e967-fbc0-4f98-9b6c-2d6ac103a256")] + [StructLayout(LayoutKind.Sequential)] + public struct EXFAT_STATISTICS + { + /// The number of create operations. + public uint CreateHits; + + /// The number of successful create operations. + public uint SuccessfulCreates; + + /// The number of failed create operations. + public uint FailedCreates; + + /// The number of read operations that were not cached. + public uint NonCachedReads; + + /// The number of bytes read from a file that were not cached. + public uint NonCachedReadBytes; + + /// The number of write operations that were not cached. + public uint NonCachedWrites; + + /// The number of bytes written to a file that were not cached. + public uint NonCachedWriteBytes; + + /// The number of read operations that were not cached. This value includes sub-read operations. + public uint NonCachedDiskReads; + + /// The number of write operations that were not cached. This value includes sub-write operations. + public uint NonCachedDiskWrites; + } + + /// Contains statistical information from the FAT file system. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-fat_statistics typedef struct _FAT_STATISTICS { DWORD + // CreateHits; DWORD SuccessfulCreates; DWORD FailedCreates; DWORD NonCachedReads; DWORD NonCachedReadBytes; DWORD NonCachedWrites; + // DWORD NonCachedWriteBytes; DWORD NonCachedDiskReads; DWORD NonCachedDiskWrites; } FAT_STATISTICS, *PFAT_STATISTICS; + [PInvokeData("winioctl.h", MSDNShortId = "98d293e8-e708-48f5-99b1-603f27e6ef16")] + [StructLayout(LayoutKind.Sequential)] + public struct FAT_STATISTICS + { + /// The number of create operations. + public uint CreateHits; + + /// The number of successful create operations. + public uint SuccessfulCreates; + + /// The number of failed create operations. + public uint FailedCreates; + + /// The number of read operations that were not cached. + public uint NonCachedReads; + + /// The number of bytes read from a file that were not cached. + public uint NonCachedReadBytes; + + /// The number of write operations that were not cached. + public uint NonCachedWrites; + + /// The number of bytes written to a file that were not cached. + public uint NonCachedWriteBytes; + + /// The number of read operations that were not cached. This value includes sub-read operations. + public uint NonCachedDiskReads; + + /// The number of write operations that were not cached. This value includes sub-write operations. + public uint NonCachedDiskWrites; + } + + /// + /// Contains statistical information from the file system. + /// Tip Applications targeting Windows 10 can access additional statistics through FILESYSTEM_STATISTICS_EX. + /// + /// + /// + /// There are two types of files: user and metadata. User files are available for the user. Metadata files are system files that + /// contain information, which the file system uses for its internal organization. + /// + /// The number of read and write operations measured is the number of paging operations. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-filesystem_statistics typedef struct + // _FILESYSTEM_STATISTICS { WORD FileSystemType; WORD Version; DWORD SizeOfCompleteStructure; DWORD UserFileReads; DWORD + // UserFileReadBytes; DWORD UserDiskReads; DWORD UserFileWrites; DWORD UserFileWriteBytes; DWORD UserDiskWrites; DWORD MetaDataReads; + // DWORD MetaDataReadBytes; DWORD MetaDataDiskReads; DWORD MetaDataWrites; DWORD MetaDataWriteBytes; DWORD MetaDataDiskWrites; } + // FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS; + [PInvokeData("winioctl.h", MSDNShortId = "ff8c7dfe-da7f-4ee2-9a54-613e0cd3e1e2")] + [StructLayout(LayoutKind.Sequential)] + public struct FILESYSTEM_STATISTICS + { + /// + /// The type of file system. + /// This member can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// FILESYSTEM_STATISTICS_TYPE_EXFAT 3 + /// + /// The file system is an exFAT file system. If this value is set, this structure is followed by an EXFAT_STATISTICS structure. + /// Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Vista with SP1. + /// + /// + /// + /// FILESYSTEM_STATISTICS_TYPE_FAT 2 + /// The file system is a FAT file system. If this value is set, this structure is followed by a FAT_STATISTICS structure. + /// + /// + /// FILESYSTEM_STATISTICS_TYPE_NTFS 1 + /// The file system is the NTFS file system. If this value is set, this structure is followed by an NTFS_STATISTICS structure. + /// + /// + /// + public ushort FileSystemType; + + /// This member is set to 1 (one). + public ushort Version; + + /// + /// + /// The size of this structure plus the size of the file system-specific structure that follows this structure, multiplied by the + /// number of processors. + /// + /// + /// This value must be a multiple of 64. For example, if the size of FILESYSTEM_STATISTICS is 0x38, the size of + /// NTFS_STATISTICS is 0xD8, and if there are 2 processors, the buffer allocated must be 0x280. + /// + /// sizeof( FILESYSTEM_STATISTICS) = 0x38 + /// sizeof(NTFS_STATISTICS) = 0xD8 + /// Total Size = 0x110 + /// size of the complete structure = 0x140 (which is the aligned length, a multiple of 64) + /// multiplied by 2 (the number of processors) = 0x280 + /// + public uint SizeOfCompleteStructure; + + /// The number of read operations on user files. + public uint UserFileReads; + + /// The number of bytes read from user files. + public uint UserFileReadBytes; + + /// + /// The number of read operations on user files. + /// This value includes sub-read operations. + /// + public uint UserDiskReads; + + /// The number of write operations on user files. + public uint UserFileWrites; + + /// The number of bytes written to user files. + public uint UserFileWriteBytes; + + /// + /// The number of write operations on user files. + /// This value includes sub-write operations. + /// + public uint UserDiskWrites; + + /// The number of read operations on metadata files. + public uint MetaDataReads; + + /// The number of bytes read from metadata files. + public uint MetaDataReadBytes; + + /// + /// The number of read operations on metadata files. + /// This value includes sub-read operations. + /// + public uint MetaDataDiskReads; + + /// The number of write operations on metadata files. + public uint MetaDataWrites; + + /// The number of bytes written to metadata files. + public uint MetaDataWriteBytes; + + /// + /// The number of write operations on metadata files. + /// This value includes sub-write operations. + /// + public uint MetaDataDiskWrites; + } + + /// Contains statistical information from the file system.Support for this structure started with Windows 10. + /// + /// + /// There are two types of files: user and metadata. User files are available for the user. Metadata files are system files that + /// contain information, which the file system uses for its internal organization. + /// + /// The number of read and write operations measured is the number of paging operations. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-filesystem_statistics_ex typedef struct + // _FILESYSTEM_STATISTICS_EX { WORD FileSystemType; WORD Version; DWORD SizeOfCompleteStructure; DWORDLONG UserFileReads; DWORDLONG + // UserFileReadBytes; DWORDLONG UserDiskReads; DWORDLONG UserFileWrites; DWORDLONG UserFileWriteBytes; DWORDLONG UserDiskWrites; + // DWORDLONG MetaDataReads; DWORDLONG MetaDataReadBytes; DWORDLONG MetaDataDiskReads; DWORDLONG MetaDataWrites; DWORDLONG + // MetaDataWriteBytes; DWORDLONG MetaDataDiskWrites; } FILESYSTEM_STATISTICS_EX, *PFILESYSTEM_STATISTICS_EX; + [PInvokeData("winioctl.h", MSDNShortId = "E869CF11-E321-478A-948F-226B04D61492")] + [StructLayout(LayoutKind.Sequential)] + public struct FILESYSTEM_STATISTICS_EX + { + /// + /// The type of file system. + /// This member can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// FILESYSTEM_STATISTICS_TYPE_EXFAT 3 + /// + /// The file system is an exFAT file system. If this value is set, this structure is followed by an EXFAT_STATISTICS structure. + /// Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Vista with SP1. + /// + /// + /// + /// FILESYSTEM_STATISTICS_TYPE_FAT 2 + /// The file system is a FAT file system. If this value is set, this structure is followed by a FAT_STATISTICS structure. + /// + /// + /// FILESYSTEM_STATISTICS_TYPE_NTFS 1 + /// + /// The file system is the NTFS file system. If this value is set, this structure is followed by an NTFS_STATISTICS_EX structure. + /// + /// + /// + /// + public ushort FileSystemType; + + /// This member is set to 1 (one). + public ushort Version; + + /// + /// + /// The size of this structure plus the size of the file system-specific structure that follows this structure, multiplied by the + /// number of processors. + /// + /// + /// This value must be a multiple of 64. For example, if the size of FILESYSTEM_STATISTICS_EX is 0x68, the size of + /// NTFS_STATISTICS_EX is 0x1D8, and if there are 2 processors, the buffer allocated must be 0x480. + /// + /// sizeof( FILESYSTEM_STATISTICS_EX) = 0x68 + /// sizeof(NTFS_STATISTICS_EX) = 0x1D8 + /// Total Size = 0x240 + /// size of the complete structure = 0x240 (which is the aligned length, a multiple of 64) + /// multiplied by 2 (the number of processors) = 0x480 + /// + public uint SizeOfCompleteStructure; + + /// The number of read operations on user files. + public ulong UserFileReads; + + /// The number of bytes read from user files. + public ulong UserFileReadBytes; + + /// + /// The number of read operations on user files. + /// This value includes sub-read operations. + /// + public ulong UserDiskReads; + + /// The number of write operations on user files. + public ulong UserFileWrites; + + /// The number of bytes written to user files. + public ulong UserFileWriteBytes; + + /// + /// The number of write operations on user files. + /// This value includes sub-write operations. + /// + public ulong UserDiskWrites; + + /// The number of read operations on metadata files. + public ulong MetaDataReads; + + /// The number of bytes read from metadata files. + public ulong MetaDataReadBytes; + + /// + /// The number of read operations on metadata files. + /// This value includes sub-read operations. + /// + public ulong MetaDataDiskReads; + + /// The number of write operations on metadata files. + public ulong MetaDataWrites; + + /// The number of bytes written to metadata files. + public ulong MetaDataWriteBytes; + + /// + /// The number of write operations on metadata files. + /// This value includes sub-write operations. + /// + public ulong MetaDataDiskWrites; + } + /// /// Contains information defining the boundaries for and starting place of an enumeration of update sequence number (USN) change /// journal records. It is used as the input buffer for the FSCTL_ENUM_USN_DATA control code. Prior to Windows Server 2012 this @@ -720,6 +1540,1371 @@ namespace Vanara.PInvoke public ushort MaxMajorVersion; } + /// + /// Contains statistical information from the NTFS file system. + /// Tip Applications targeting Windows 10 can access additional statistics through NTFS_STATISTICS_EX. + /// + /// + /// + /// The MFT, MFT mirror, root index, user index, bitmap, and MFT bitmap are counted as metadata files. The log file is not counted as + /// a metadata file. + /// + /// The number of read and write operations measured is the number of paging operations. + /// For additional statistics that are only available with Windows 10, use NTFS_STATISTICS_EX. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-ntfs_statistics typedef struct _NTFS_STATISTICS { DWORD + // LogFileFullExceptions; DWORD OtherExceptions; DWORD MftReads; DWORD MftReadBytes; DWORD MftWrites; DWORD MftWriteBytes; struct { + // WORD Write; WORD Create; WORD SetInfo; WORD Flush; } MftWritesUserLevel; WORD MftWritesFlushForLogFileFull; WORD + // MftWritesLazyWriter; WORD MftWritesUserRequest; DWORD Mft2Writes; DWORD Mft2WriteBytes; struct { WORD Write; WORD Create; WORD + // SetInfo; WORD Flush; } Mft2WritesUserLevel; WORD Mft2WritesFlushForLogFileFull; WORD Mft2WritesLazyWriter; WORD + // Mft2WritesUserRequest; DWORD RootIndexReads; DWORD RootIndexReadBytes; DWORD RootIndexWrites; DWORD RootIndexWriteBytes; DWORD + // BitmapReads; DWORD BitmapReadBytes; DWORD BitmapWrites; DWORD BitmapWriteBytes; WORD BitmapWritesFlushForLogFileFull; WORD + // BitmapWritesLazyWriter; WORD BitmapWritesUserRequest; struct { WORD Write; WORD Create; WORD SetInfo; } BitmapWritesUserLevel; + // DWORD MftBitmapReads; DWORD MftBitmapReadBytes; DWORD MftBitmapWrites; DWORD MftBitmapWriteBytes; WORD + // MftBitmapWritesFlushForLogFileFull; WORD MftBitmapWritesLazyWriter; WORD MftBitmapWritesUserRequest; struct { WORD Write; WORD + // Create; WORD SetInfo; WORD Flush; } MftBitmapWritesUserLevel; DWORD UserIndexReads; DWORD UserIndexReadBytes; DWORD + // UserIndexWrites; DWORD UserIndexWriteBytes; DWORD LogFileReads; DWORD LogFileReadBytes; DWORD LogFileWrites; DWORD + // LogFileWriteBytes; struct { DWORD Calls; DWORD Clusters; DWORD Hints; DWORD RunsReturned; DWORD HintsHonored; DWORD HintsClusters; + // DWORD Cache; DWORD CacheClusters; DWORD CacheMiss; DWORD CacheMissClusters; } Allocate; DWORD DiskResourcesExhausted; } + // NTFS_STATISTICS, *PNTFS_STATISTICS; + [PInvokeData("winioctl.h", MSDNShortId = "9b5cffc5-386d-4333-9a37-cc27b8f9b187")] + [StructLayout(LayoutKind.Sequential)] + public struct NTFS_STATISTICS + { + /// The number of exceptions generated due to the log file being full. + public uint LogFileFullExceptions; + + /// The number of other exceptions generated. + public uint OtherExceptions; + + /// The number of read operations on the master file table (MFT). + public uint MftReads; + + /// The number of bytes read from the MFT. + public uint MftReadBytes; + + /// The number of write operations on the MFT. + public uint MftWrites; + + /// The number of bytes written to the MFT. + public uint MftWriteBytes; + + /// + public MFTWRITESUSERLEVEL MftWritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct MFTWRITESUSERLEVEL + { + /// The number of MFT writes due to a write operation. + public ushort Write; + + /// The number of MFT writes due to a create operation. + public ushort Create; + + /// The number of MFT writes due to setting file information. + public ushort SetInfo; + + /// The number of MFT writes due to a flush operation. + public ushort Flush; + } + + /// The number of flushes of the MFT performed because the log file was full. + public ushort MftWritesFlushForLogFileFull; + + /// The number of MFT write operations performed by the lazy writer thread. + public ushort MftWritesLazyWriter; + + /// Reserved. + public ushort MftWritesUserRequest; + + /// The number of write operations on the MFT mirror. + public uint Mft2Writes; + + /// The number of bytes written to the MFT mirror. + public uint Mft2WriteBytes; + + /// + public MFT2WRITESUSERLEVEL Mft2WritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct MFT2WRITESUSERLEVEL + { + /// The number of MFT mirror writes due to a write operation. + public ushort Write; + + /// The number of MFT mirror writes due to a create operation. + public ushort Create; + + /// The number of MFT mirror writes due to setting file information. + public ushort SetInfo; + + /// The number of MFT mirror writes due to a flush operation. + public ushort Flush; + } + + /// The number of flushes of the MFT mirror performed because the log file was full. + public ushort Mft2WritesFlushForLogFileFull; + + /// The number of MFT mirror write operations performed by the lazy writer thread. + public ushort Mft2WritesLazyWriter; + + /// Reserved. + public ushort Mft2WritesUserRequest; + + /// The number of read operations on the root index. + public uint RootIndexReads; + + /// The number of bytes read from the root index. + public uint RootIndexReadBytes; + + /// The number of write operations on the root index. + public uint RootIndexWrites; + + /// The number of bytes written to the root index. + public uint RootIndexWriteBytes; + + /// The number of read operations on the cluster allocation bitmap. + public uint BitmapReads; + + /// The number of bytes read from the cluster allocation bitmap. + public uint BitmapReadBytes; + + /// The number of write operations on the cluster allocation bitmap. + public uint BitmapWrites; + + /// The number of bytes written to the cluster allocation bitmap. + public uint BitmapWriteBytes; + + /// The number of flushes of the bitmap performed because the log file was full. + public ushort BitmapWritesFlushForLogFileFull; + + /// The number of bitmap write operations performed by the lazy writer thread. + public ushort BitmapWritesLazyWriter; + + /// Reserved. + public ushort BitmapWritesUserRequest; + + /// + public BITMAPWRITESUSERLEVEL BitmapWritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct BITMAPWRITESUSERLEVEL + { + /// The number of bitmap writes due to a write operation. + public ushort Write; + + /// The number of bitmap writes due to a create operation. + public ushort Create; + + /// The number of bitmap writes due to setting file information. + public ushort SetInfo; + } + + /// The number of read operations on the MFT bitmap. + public uint MftBitmapReads; + + /// The number of bytes read from the MFT bitmap. + public uint MftBitmapReadBytes; + + /// The number of write operations on the MFT bitmap. + public uint MftBitmapWrites; + + /// The number of bytes written to the MFT bitmap. + public uint MftBitmapWriteBytes; + + /// The number of flushes of the MFT bitmap performed because the log file was full. + public ushort MftBitmapWritesFlushForLogFileFull; + + /// The number of MFT bitmap write operations performed by the lazy writer thread. + public ushort MftBitmapWritesLazyWriter; + + /// Reserved. + public ushort MftBitmapWritesUserRequest; + + /// + public MFTBITMAPWRITESUSERLEVEL MftBitmapWritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct MFTBITMAPWRITESUSERLEVEL + { + /// The number of MFT bitmap writes due to a write operation. + public ushort Write; + + /// The number of bitmap writes due to a create operation. + public ushort Create; + + /// The number of bitmap writes due to setting file information. + public ushort SetInfo; + + /// The number of bitmap writes due to a flush operation. + public ushort Flush; + } + + /// The number of read operations on the user index. + public uint UserIndexReads; + + /// The number of bytes read from the user index. + public uint UserIndexReadBytes; + + /// The number of write operations on the user index. + public uint UserIndexWrites; + + /// The number of bytes written to the user index. + public uint UserIndexWriteBytes; + + /// The number of read operations on the log file. + public uint LogFileReads; + + /// The number of bytes read from the log file. + public uint LogFileReadBytes; + + /// The number of write operations on the log file. + public uint LogFileWrites; + + /// The number of bytes written to the log file. + public uint LogFileWriteBytes; + + /// + public ALLOCATE Allocate; + + [StructLayout(LayoutKind.Sequential)] + public struct ALLOCATE + { + /// The number of individual calls to allocate clusters. + public uint Calls; + + /// The number of clusters allocated. + public uint Clusters; + + /// The number of times a hint was specified. + public uint Hints; + + /// The number of runs used to satisfy all the requests. + public uint RunsReturned; + + /// The number of times the hint was useful. + public uint HintsHonored; + + /// The number of clusters allocated through the hint. + public uint HintsClusters; + + /// The number of times the cache was useful other than the hint. + public uint Cache; + + /// The number of clusters allocated through the cache other than the hint. + public uint CacheClusters; + + /// The number of times the cache was not useful. + public uint CacheMiss; + + /// The number of clusters allocated without the cache. + public uint CacheMissClusters; + } + + /// + /// The number of failed attempts made to acquire a slab of storage for use on the current thinly provisioned volume. + /// Support for this member started with Windows 8.1. + /// + public uint DiskResourcesExhausted; + } + + /// + /// + /// [Some information relates to pre-released product which may be substantially modified before it's commercially released. + /// Microsoft makes no warranties, express or implied, with respect to the information provided here.] + /// + /// Contains statistical information from the NTFS file system.Support for this structure started with Windows 10. + /// + /// + /// + /// The MFT, MFT mirror, root index, user index, bitmap, and MFT bitmap are counted as metadata files. The log file is not counted as + /// a metadata file. + /// + /// The number of read and write operations measured is the number of paging operations. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-ntfs_statistics_ex typedef struct _NTFS_STATISTICS_EX { + // DWORD LogFileFullExceptions; DWORD OtherExceptions; DWORDLONG MftReads; DWORDLONG MftReadBytes; DWORDLONG MftWrites; DWORDLONG + // MftWriteBytes; struct { DWORD Write; DWORD Create; DWORD SetInfo; DWORD Flush; } MftWritesUserLevel; DWORD + // MftWritesFlushForLogFileFull; DWORD MftWritesLazyWriter; DWORD MftWritesUserRequest; DWORDLONG Mft2Writes; DWORDLONG + // Mft2WriteBytes; struct { DWORD Write; DWORD Create; DWORD SetInfo; DWORD Flush; } Mft2WritesUserLevel; DWORD + // Mft2WritesFlushForLogFileFull; DWORD Mft2WritesLazyWriter; DWORD Mft2WritesUserRequest; DWORDLONG RootIndexReads; DWORDLONG + // RootIndexReadBytes; DWORDLONG RootIndexWrites; DWORDLONG RootIndexWriteBytes; DWORDLONG BitmapReads; DWORDLONG BitmapReadBytes; + // DWORDLONG BitmapWrites; DWORDLONG BitmapWriteBytes; DWORD BitmapWritesFlushForLogFileFull; DWORD BitmapWritesLazyWriter; DWORD + // BitmapWritesUserRequest; struct { DWORD Write; DWORD Create; DWORD SetInfo; DWORD Flush; } BitmapWritesUserLevel; DWORDLONG + // MftBitmapReads; DWORDLONG MftBitmapReadBytes; DWORDLONG MftBitmapWrites; DWORDLONG MftBitmapWriteBytes; DWORD + // MftBitmapWritesFlushForLogFileFull; DWORD MftBitmapWritesLazyWriter; DWORD MftBitmapWritesUserRequest; struct { DWORD Write; DWORD + // Create; DWORD SetInfo; DWORD Flush; } MftBitmapWritesUserLevel; DWORDLONG UserIndexReads; DWORDLONG UserIndexReadBytes; DWORDLONG + // UserIndexWrites; DWORDLONG UserIndexWriteBytes; DWORDLONG LogFileReads; DWORDLONG LogFileReadBytes; DWORDLONG LogFileWrites; + // DWORDLONG LogFileWriteBytes; struct { DWORD Calls; DWORD RunsReturned; DWORD Hints; DWORD HintsHonored; DWORD Cache; DWORD + // CacheMiss; DWORDLONG Clusters; DWORDLONG HintsClusters; DWORDLONG CacheClusters; DWORDLONG CacheMissClusters; } Allocate; DWORD + // DiskResourcesExhausted; DWORDLONG VolumeTrimCount; DWORDLONG VolumeTrimTime; DWORDLONG VolumeTrimByteCount; DWORDLONG + // FileLevelTrimCount; DWORDLONG FileLevelTrimTime; DWORDLONG FileLevelTrimByteCount; DWORDLONG VolumeTrimSkippedCount; DWORDLONG + // VolumeTrimSkippedByteCount; DWORDLONG NtfsFillStatInfoFromMftRecordCalledCount; DWORDLONG + // NtfsFillStatInfoFromMftRecordBailedBecauseOfAttributeListCount; DWORDLONG + // NtfsFillStatInfoFromMftRecordBailedBecauseOfNonResReparsePointCount; } NTFS_STATISTICS_EX, *PNTFS_STATISTICS_EX; + [PInvokeData("winioctl.h", MSDNShortId = "D1A6995C-A4BA-4ECC-892A-196581FA41CE")] + [StructLayout(LayoutKind.Sequential)] + public struct NTFS_STATISTICS_EX + { + /// The number of exceptions generated due to the log file being full. + public uint LogFileFullExceptions; + + /// The number of other exceptions generated. + public uint OtherExceptions; + + /// The number of read operations on the master file table (MFT). + public ulong MftReads; + + /// The number of bytes read from the MFT. + public ulong MftReadBytes; + + /// The number of write operations on the MFT. + public ulong MftWrites; + + /// The number of bytes written to the MFT. + public ulong MftWriteBytes; + + /// + public MFTWRITESUSERLEVEL MftWritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct MFTWRITESUSERLEVEL + { + /// The number of MFT writes due to a write operation. + public uint Write; + + /// The number of MFT writes due to a create operation. + public uint Create; + + /// The number of MFT writes due to setting file information. + public uint SetInfo; + + /// The number of MFT writes due to a flush operation. + public uint Flush; + } + + /// The number of flushes of the MFT performed because the log file was full. + public uint MftWritesFlushForLogFileFull; + + /// The number of MFT write operations performed by the lazy writer thread. + public uint MftWritesLazyWriter; + + /// Reserved. + public uint MftWritesUserRequest; + + /// The number of write operations on the MFT mirror. + public ulong Mft2Writes; + + /// The number of bytes written to the MFT mirror. + public ulong Mft2WriteBytes; + + /// + public MFT2WRITESUSERLEVEL Mft2WritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct MFT2WRITESUSERLEVEL + { + /// The number of MFT mirror writes due to a write operation. + public uint Write; + + /// The number of MFT mirror writes due to a create operation. + public uint Create; + + /// The number of MFT mirror writes due to setting file information. + public uint SetInfo; + + /// The number of MFT mirror writes due to a flush operation. + public uint Flush; + } + + /// The number of flushes of the MFT mirror performed because the log file was full. + public uint Mft2WritesFlushForLogFileFull; + + /// The number of MFT mirror write operations performed by the lazy writer thread. + public uint Mft2WritesLazyWriter; + + /// Reserved. + public uint Mft2WritesUserRequest; + + /// The number of read operations on the root index. + public ulong RootIndexReads; + + /// The number of bytes read from the root index. + public ulong RootIndexReadBytes; + + /// The number of write operations on the root index. + public ulong RootIndexWrites; + + /// The number of bytes written to the root index. + public ulong RootIndexWriteBytes; + + /// The number of read operations on the cluster allocation bitmap. + public ulong BitmapReads; + + /// The number of bytes read from the cluster allocation bitmap. + public ulong BitmapReadBytes; + + /// The number of write operations on the cluster allocation bitmap. + public ulong BitmapWrites; + + /// The number of bytes written to the cluster allocation bitmap. + public ulong BitmapWriteBytes; + + /// The number of flushes of the bitmap performed because the log file was full. + public uint BitmapWritesFlushForLogFileFull; + + /// The number of bitmap write operations performed by the lazy writer thread. + public uint BitmapWritesLazyWriter; + + /// Reserved. + public uint BitmapWritesUserRequest; + + /// + public BITMAPWRITESUSERLEVEL BitmapWritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct BITMAPWRITESUSERLEVEL + { + /// The number of bitmap writes due to a write operation. + public uint Write; + + /// The number of bitmap writes due to a create operation. + public uint Create; + + /// The number of bitmap writes due to setting file information. + public uint SetInfo; + + /// The number of bitmap writes due to a flush operation. + public uint Flush; + } + + /// The number of read operations on the MFT bitmap. + public ulong MftBitmapReads; + + /// The number of bytes read from the MFT bitmap. + public ulong MftBitmapReadBytes; + + /// The number of write operations on the MFT bitmap. + public ulong MftBitmapWrites; + + /// The number of bytes written to the MFT bitmap. + public ulong MftBitmapWriteBytes; + + /// The number of flushes of the MFT bitmap performed because the log file was full. + public uint MftBitmapWritesFlushForLogFileFull; + + /// The number of MFT bitmap write operations performed by the lazy writer thread. + public uint MftBitmapWritesLazyWriter; + + /// Reserved. + public uint MftBitmapWritesUserRequest; + + /// + public MFTBITMAPWRITESUSERLEVEL MftBitmapWritesUserLevel; + + [StructLayout(LayoutKind.Sequential)] + public struct MFTBITMAPWRITESUSERLEVEL + { + /// The number of MFT bitmap writes due to a write operation. + public uint Write; + + /// The number of bitmap writes due to a create operation. + public uint Create; + + /// The number of bitmap writes due to setting file information. + public uint SetInfo; + + /// The number of bitmap writes due to a flush operation. + public uint Flush; + } + + /// The number of read operations on the user index. + public ulong UserIndexReads; + + /// The number of bytes read from the user index. + public ulong UserIndexReadBytes; + + /// The number of write operations on the user index. + public ulong UserIndexWrites; + + /// The number of bytes written to the user index. + public ulong UserIndexWriteBytes; + + /// The number of read operations on the log file. + public ulong LogFileReads; + + /// The number of bytes read from the log file. + public ulong LogFileReadBytes; + + /// The number of write operations on the log file. + public ulong LogFileWrites; + + /// The number of bytes written to the log file. + public ulong LogFileWriteBytes; + + /// + public ALLOCATE Allocate; + + [StructLayout(LayoutKind.Sequential)] + public struct ALLOCATE + { + /// The number of individual calls to allocate clusters. + public uint Calls; + + /// The number of runs used to satisfy all the requests. + public uint RunsReturned; + + /// The number of times a hint was specified. + public uint Hints; + + /// The number of times the hint was useful. + public uint HintsHonored; + + /// The number of times the cache was useful other than the hint. + public uint Cache; + + /// The number of times the cache was not useful. + public uint CacheMiss; + + /// The number of clusters allocated. + public ulong Clusters; + + /// The number of clusters allocated through the hint. + public ulong HintsClusters; + + /// The number of clusters allocated through the cache other than the hint. + public ulong CacheClusters; + + /// The number of clusters allocated without the cache. + public ulong CacheMissClusters; + } + + /// The number of failed attempts made to acquire a slab of storage for use on the current thinly provisioned volume. + public uint DiskResourcesExhausted; + + /// The number of volume level trim operations issued. + public ulong VolumeTrimCount; + + /// + /// The total time elapsed during all volume level trim operations. This value, divided by the frequency value from + /// QueryPerformanceFrequency or KeQueryPerformanceCounter, will give the time in seconds. + /// + public ulong VolumeTrimTime; + + /// The total number of bytes issued by all volume level trim operations. + public ulong VolumeTrimByteCount; + + /// The number of file level trim operations issued. + public ulong FileLevelTrimCount; + + /// + /// The total time elapsed during all file level trim operations. This value, divided by the frequency value from + /// QueryPerformanceFrequency or KeQueryPerformanceCounter, will give the time in seconds. + /// + public ulong FileLevelTrimTime; + + /// The total number of bytes issued by all file level trim operations. + public ulong FileLevelTrimByteCount; + + /// The number of times a volume level trim operation was aborted before being sent down through the storage stack. + public ulong VolumeTrimSkippedCount; + + /// The number of bytes that were not sent through a volume level trim operation because they were skipped. + public ulong VolumeTrimSkippedByteCount; + + /// + public ulong NtfsFillStatInfoFromMftRecordCalledCount; + + /// + public ulong NtfsFillStatInfoFromMftRecordBailedBecauseOfAttributeListCount; + + /// + public ulong NtfsFillStatInfoFromMftRecordBailedBecauseOfNonResReparsePointCount; + } + + /// + /// Contains information about a disk partition. + /// NotePARTITION_INFORMATION has been superseded by the PARTITION_INFORMATION_EX structure. + /// + /// + /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more + /// information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-partition_information typedef struct + // _PARTITION_INFORMATION { LARGE_INTEGER StartingOffset; LARGE_INTEGER PartitionLength; DWORD HiddenSectors; DWORD PartitionNumber; + // BYTE PartitionType; BOOLEAN BootIndicator; BOOLEAN RecognizedPartition; BOOLEAN RewritePartition; } PARTITION_INFORMATION, *PPARTITION_INFORMATION; + [PInvokeData("winioctl.h", MSDNShortId = "2c8fa83a-0694-4e17-a9e4-87f839a0d458")] + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct PARTITION_INFORMATION + { + /// The starting offset of the partition. + public long StartingOffset; + + /// The length of the partition, in bytes. + public long PartitionLength; + + /// The number of hidden sectors in the partition. + public uint HiddenSectors; + + /// The number of the partition (1-based). + public uint PartitionNumber; + + /// The type of partition. For a list of values, see Disk Partition Types. + public PartitionType PartitionType; + + /// If this member is TRUE, the partition is bootable. + [MarshalAs(UnmanagedType.U1)] public bool BootIndicator; + + /// If this member is TRUE, the partition is of a recognized type. + [MarshalAs(UnmanagedType.U1)] public bool RecognizedPartition; + + /// + /// If this member is TRUE, the partition information has changed. When you change a partition (with + /// IOCTL_DISK_SET_DRIVE_LAYOUT), the system uses this member to determine which partitions have changed and need their + /// information rewritten. + /// + [MarshalAs(UnmanagedType.U1)] public bool RewritePartition; + } + + /// + /// Contains partition information for standard AT-style master boot record (MBR) and Extensible Firmware Interface (EFI) disks. + /// + /// + /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more + /// information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-partition_information_ex typedef struct + // _PARTITION_INFORMATION_EX { PARTITION_STYLE PartitionStyle; LARGE_INTEGER StartingOffset; LARGE_INTEGER PartitionLength; DWORD + // PartitionNumber; BOOLEAN RewritePartition; BOOLEAN IsServicePartition; union { PARTITION_INFORMATION_MBR Mbr; + // PARTITION_INFORMATION_GPT Gpt; } DUMMYUNIONNAME; } PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX; + [PInvokeData("winioctl.h", MSDNShortId = "3c88ebae-274e-403a-8f57-58fdf863f511")] + [StructLayout(LayoutKind.Explicit)] + public struct PARTITION_INFORMATION_EX + { + /// The format of the partition. For a list of values, see PARTITION_STYLE. + [FieldOffset(0)] + public PARTITION_STYLE PartitionStyle; + + /// The starting offset of the partition. + [FieldOffset(8)] + public long StartingOffset; + + /// The size of the partition, in bytes. + [FieldOffset(16)] + public long PartitionLength; + + /// The number of the partition (1-based). + [FieldOffset(24)] + public uint PartitionNumber; + + /// If this member is TRUE, the partition is rewritable. The value of this parameter should be set to TRUE. + [FieldOffset(28)] + [MarshalAs(UnmanagedType.U1)] public bool RewritePartition; + + /// + [FieldOffset(29)] + [MarshalAs(UnmanagedType.U1)] public bool IsServicePartition; + + /// + /// A PARTITION_INFORMATION_MBR structure that specifies partition information specific to master boot record (MBR) disks. The + /// MBR partition format is the standard AT-style format. + /// + [FieldOffset(32)] + public PARTITION_INFORMATION_MBR Mbr; + + /// + /// A PARTITION_INFORMATION_GPT structure that specifies partition information specific to GUID partition table (GPT) disks. The + /// GPT format corresponds to the EFI partition format. + /// + [FieldOffset(32)] + public PARTITION_INFORMATION_GPT Gpt; + } + + /// Contains GUID partition table (GPT) partition information. + /// + /// + /// The GPT partition format is required for disks that are used to boot computers that use Extended Firmware Interface (EFI) + /// firmware. GPT data disks can reside on x86, x64, and Itanium-based architectures. + /// + /// Starting with Windows Server 2003 with SP1, GPT is supported on all Windows platforms, not only platforms that use EFI. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-partition_information_gpt typedef struct + // _PARTITION_INFORMATION_GPT { GUID PartitionType; GUID PartitionId; DWORD64 Attributes; WCHAR Name[36]; } + // PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT; + [PInvokeData("winioctl.h", MSDNShortId = "373b4eb3-af6d-4112-9787-f14c19972189")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct PARTITION_INFORMATION_GPT + { + /// + /// A GUID that identifies the partition type. + /// + /// Each partition type that the EFI specification supports is identified by its own GUID, which is published by the + /// developer of the partition. + /// + /// This member can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// PARTITION_BASIC_DATA_GUID ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 + /// + /// The data partition type that is created and recognized by Windows. Only partitions of this type can be assigned drive + /// letters, receive volume GUID paths, host mounted folders (also called volume mount points), and be enumerated by calls to + /// FindFirstVolume and FindNextVolume. This value can be set only for basic disks, with one exception. If both + /// PARTITION_BASIC_DATA_GUID and GPT_ATTRIBUTE_PLATFORM_REQUIRED are set for a partition on a basic disk that is subsequently + /// converted to a dynamic disk, the partition remains a basic partition, even though the rest of the disk is a dynamic disk. + /// This is because the partition is considered to be an OEM partition on a GPT disk. + /// + /// + /// + /// PARTITION_ENTRY_UNUSED_GUID 00000000-0000-0000-0000-000000000000 + /// There is no partition. This value can be set for basic and dynamic disks. + /// + /// + /// PARTITION_SYSTEM_GUID c12a7328-f81f-11d2-ba4b-00a0c93ec93b + /// The partition is an EFI system partition. This value can be set for basic and dynamic disks. + /// + /// + /// PARTITION_MSFT_RESERVED_GUID e3c9e316-0b5c-4db8-817d-f92df00215ae + /// The partition is a Microsoft reserved partition. This value can be set for basic and dynamic disks. + /// + /// + /// PARTITION_LDM_METADATA_GUID 5808c8aa-7e8f-42e0-85d2-e1e90434cfb3 + /// + /// The partition is a Logical Disk Manager (LDM) metadata partition on a dynamic disk. This value can be set only for dynamic disks. + /// + /// + /// + /// PARTITION_LDM_DATA_GUID af9b60a0-1431-4f62-bc68-3311714a69ad + /// The partition is an LDM data partition on a dynamic disk. This value can be set only for dynamic disks. + /// + /// + /// PARTITION_MSFT_RECOVERY_GUID de94bba4-06d1-4d40-a16a-bfd50179d6ac + /// The partition is a Microsoft recovery partition. This value can be set for basic and dynamic disks. + /// + /// + /// + public Guid PartitionType; + + /// The GUID of the partition. + public Guid PartitionId; + + /// + /// The Extensible Firmware Interface (EFI) attributes of the partition. + /// This member can be one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// GPT_ATTRIBUTE_PLATFORM_REQUIRED 0x0000000000000001 + /// + /// If this attribute is set, the partition is required by a computer to function properly. For example, this attribute must be + /// set for OEM partitions. Note that if this attribute is set, you can use the DiskPart.exe utility to perform partition + /// operations such as deleting the partition. However, because the partition is not a volume, you cannot use the DiskPart.exe + /// utility to perform volume operations on the partition. This attribute can be set for basic and dynamic disks. If it is set + /// for a partition on a basic disk and the disk is converted to a dynamic disk, the partition remains a basic partition, even + /// though the rest of the disk is a dynamic disk. This is because the partition is considered to be an OEM partition on a GPT disk. + /// + /// + /// + /// GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER 0x8000000000000000 + /// + /// If this attribute is set, the partition does not receive a drive letter by default when the disk is moved to another computer + /// or when the disk is seen for the first time by a computer. This attribute is useful in storage area network (SAN) + /// environments. Despite its name, this attribute can be set for basic and dynamic disks. + /// + /// + /// + /// GPT_BASIC_DATA_ATTRIBUTE_HIDDEN 0x4000000000000000 + /// + /// If this attribute is set, the partition is not detected by the Mount Manager. As a result, the partition does not receive a + /// drive letter, does not receive a volume GUID path, does not host mounted folders (also called volume mount points), and is + /// not enumerated by calls to FindFirstVolume and FindNextVolume. This ensures that applications such as Disk Defragmenter do + /// not access the partition. The Volume Shadow Copy Service (VSS) uses this attribute. Despite its name, this attribute can be + /// set for basic and dynamic disks. + /// + /// + /// + /// GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY 0x2000000000000000 + /// + /// If this attribute is set, the partition is a shadow copy of another partition. VSS uses this attribute. This attribute is an + /// indication for file system filter driver-based software (such as antivirus programs) to avoid attaching to the volume. An + /// application can use the attribute to differentiate a shadow copy volume from a production volume. An application that does a + /// fast recovery, for example, will break a shadow copy LUN and clear the read-only and hidden attributes and this attribute. + /// This attribute is set when the shadow copy is created and cleared when the shadow copy is broken. Despite its name, this + /// attribute can be set for basic and dynamic disks. Windows Server 2003: This attribute is not supported before Windows Server + /// 2003 with SP1. + /// + /// + /// + /// GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY 0x1000000000000000 + /// + /// If this attribute is set, the partition is read-only. Writes to the partition will fail. IOCTL_DISK_IS_WRITABLE will fail + /// with the ERROR_WRITE_PROTECT Win32 error code, which causes the file system to mount as read only, if a file system is + /// present. VSS uses this attribute. Do not set this attribute for dynamic disks. Setting it can cause I/O errors and prevent + /// the file system from mounting properly. + /// + /// + /// + /// + public GPT_ATTRIBUTE Attributes; + + /// A wide-character string that describes the partition. + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 36)] + public string Name; + } + + /// Contains partition information specific to master boot record (MBR) disks. + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-partition_information_mbr typedef struct + // _PARTITION_INFORMATION_MBR { BYTE PartitionType; BOOLEAN BootIndicator; BOOLEAN RecognizedPartition; DWORD HiddenSectors; GUID + // PartitionId; } PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR; + [PInvokeData("winioctl.h", MSDNShortId = "5b74b06f-ef4c-44ab-95c6-49c050faf1f4")] + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct PARTITION_INFORMATION_MBR + { + /// The type of partition. For a list of values, see Disk Partition Types. + public PartitionType PartitionType; + + /// + /// If the member is TRUE, the partition is a boot partition. When this structure is used with the + /// IOCTL_DISK_SET_PARTITION_INFO_EX control code, the value of this parameter is ignored. + /// + [MarshalAs(UnmanagedType.U1)] public bool BootIndicator; + + /// + /// If this member is TRUE, the partition is of a recognized type. When this structure is used with the + /// IOCTL_DISK_SET_PARTITION_INFO_EX control code, the value of this parameter is ignored. + /// + [MarshalAs(UnmanagedType.U1)] public bool RecognizedPartition; + + /// The number of hidden sectors to be allocated when the partition table is created. + public uint HiddenSectors; + + /// + public Guid PartitionId; + } + + /// + /// Specifies the versions of the update sequence number (USN) change journal supported by the application. This structure is the + /// input structure to the FSCTL_READ_FILE_USN_DATA control code. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-read_file_usn_data typedef struct { WORD MinMajorVersion; + // WORD MaxMajorVersion; } READ_FILE_USN_DATA, *PREAD_FILE_USN_DATA; + [PInvokeData("winioctl.h", MSDNShortId = "8c403eec-7504-4a69-9f05-7a3a164557a6")] + [StructLayout(LayoutKind.Sequential)] + public struct READ_FILE_USN_DATA + { + /// + /// The lowest version of the USN change journal accepted by the application. If the input buffer is not specified this defaults + /// to 2. + /// + public ushort MinMajorVersion; + + /// + /// The highest version of the USN change journal accepted by the application. If the input buffer is not specified this defaults + /// to 2. To support 128-bit file identifiers used by ReFS this must be 3 or higher. + /// + public ushort MaxMajorVersion; + } + + /// + /// Contains information defining a set of update sequence number (USN) change journal records to return to the calling process. It + /// is used by the FSCTL_QUERY_USN_JOURNAL and FSCTL_READ_USN_JOURNAL control codes. Prior to Windows 8 and Windows Server 2012 this + /// structure was named READ_USN_JOURNAL_DATA. Use that name to compile with older SDKs and compilers. Windows Server 2012 + /// introduced READ_USN_JOURNAL_DATA_V1 to support 128-bit file identifiers used by ReFS. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-read_usn_journal_data_v0 typedef struct { USN StartUsn; + // DWORD ReasonMask; DWORD ReturnOnlyOnClose; DWORDLONG Timeout; DWORDLONG BytesToWaitFor; DWORDLONG UsnJournalID; } + // READ_USN_JOURNAL_DATA_V0, *PREAD_USN_JOURNAL_DATA_V0; + [PInvokeData("winioctl.h", MSDNShortId = "f88e71ba-6099-4928-9d71-732a4ca809bc")] + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct READ_USN_JOURNAL_DATA_V0 + { + /// + /// The USN at which to begin reading the change journal. + /// + /// To start the read operation at the first record in the journal, set the StartUsn member to zero. Because a USN is + /// contained in every journal record, the output buffer tells at which record the read operation actually started. + /// + /// To start the read operation at a specific record, set StartUsn to that record USN. + /// + /// If a nonzero USN is specified that is less than the first USN in the change journal, then an error occurs and the + /// ERROR_JOURNAL_ENTRY_DELETED error code is returned. This code may indicate a case in which the specified USN is valid + /// at one time but has since been deleted. + /// + /// + /// For more information on navigating the change journal buffer returned in READ_USN_JOURNAL_DATA_V0, see Walking a + /// Buffer of Change Journal Records. + /// + /// + public int StartUsn; + + /// + /// + /// A mask of flags, each flag noting a change for which the file or directory has a record in the change journal. To be returned + /// in a FSCTL_READ_USN_JOURNAL operation, a change journal record must have at least one of these flags set. + /// + /// The list of valid flags is as follows. Unused bits are reserved. + /// + /// + /// Value + /// Meaning + /// + /// + /// USN_REASON_BASIC_INFO_CHANGE 0x00008000 + /// + /// A user has either changed one or more file or directory attributes (such as the read-only, hidden, system, archive, or sparse + /// attribute), or one or more time stamps. + /// + /// + /// + /// USN_REASON_CLOSE 0x80000000 + /// The file or directory is closed. + /// + /// + /// USN_REASON_COMPRESSION_CHANGE 0x00020000 + /// The compression state of the file or directory is changed from or to compressed. + /// + /// + /// USN_REASON_DATA_EXTEND 0x00000002 + /// The file or directory is added to. + /// + /// + /// USN_REASON_DATA_OVERWRITE 0x00000001 + /// Data in the file or directory is overwritten. + /// + /// + /// USN_REASON_DATA_TRUNCATION 0x00000004 + /// The file or directory is truncated. + /// + /// + /// USN_REASON_EA_CHANGE 0x00000400 + /// + /// The user makes a change to the file or directory extended attributes. These NTFS file system attributes are not accessible to + /// Windows-based applications. + /// + /// + /// + /// USN_REASON_ENCRYPTION_CHANGE 0x00040000 + /// The file or directory is encrypted or decrypted. + /// + /// + /// USN_REASON_FILE_CREATE 0x00000100 + /// The file or directory is created for the first time. + /// + /// + /// USN_REASON_FILE_DELETE 0x00000200 + /// The file or directory is deleted. + /// + /// + /// USN_REASON_HARD_LINK_CHANGE 0x00010000 + /// + /// An NTFS file system hard link is added to or removed from the file or directory. An NTFS file system hard link, similar to a + /// POSIX hard link, is one of several directory entries that see the same file or directory. + /// + /// + /// + /// USN_REASON_INDEXABLE_CHANGE 0x00004000 + /// + /// A user changed the FILE_ATTRIBUTE_NOT_CONTENT_INDEXED attribute. That is, the user changed the file or directory from one + /// that can be content indexed to one that cannot, or vice versa. (Content indexing permits rapid searching of data by building + /// a database of selected content.) + /// + /// + /// + /// USN_REASON_NAMED_DATA_EXTEND 0x00000020 + /// One or more named data streams for the file were added to. + /// + /// + /// USN_REASON_NAMED_DATA_OVERWRITE 0x00000010 + /// Data in one or more named data streams for the file is overwritten. + /// + /// + /// USN_REASON_NAMED_DATA_TRUNCATION 0x00000040 + /// One or more named data streams for the file is truncated. + /// + /// + /// USN_REASON_OBJECT_ID_CHANGE 0x00080000 + /// The object identifier of the file or directory is changed. + /// + /// + /// USN_REASON_RENAME_NEW_NAME 0x00002000 + /// + /// The file or directory is renamed, and the file name in the USN_RECORD_V2 or USN_RECORD_V3 structure holding this journal + /// record is the new name. + /// + /// + /// + /// USN_REASON_RENAME_OLD_NAME 0x00001000 + /// + /// The file or directory is renamed, and the file name in the USN_RECORD_V2 or USN_RECORD_V3 structure holding this journal + /// record is the previous name. + /// + /// + /// + /// USN_REASON_REPARSE_POINT_CHANGE 0x00100000 + /// + /// The reparse point contained in the file or directory is changed, or a reparse point is added to or deleted from the file or directory. + /// + /// + /// + /// USN_REASON_SECURITY_CHANGE 0x00000800 + /// A change is made in the access permissions to the file or directory. + /// + /// + /// USN_REASON_STREAM_CHANGE 0x00200000 + /// A named stream is added to or removed from the file or directory, or a named stream is renamed. + /// + /// + /// + public uint ReasonMask; + + /// + /// A value that specifies when to return change journal records. + /// + /// To receive notification when the final handle for the changed file or directory is closed, rather than at the time a change + /// occurs, set ReturnOnlyOnClose to any nonzero value and specify the USN_REASON_CLOSE flag in the + /// ReasonMask member. + /// + /// + /// All changes indicated by ReasonMask flags eventually generate a call to the change journal software when the file is + /// closed. If your DeviceIoControl call is waiting for the file to be closed, that call in turn will allow your + /// DeviceIoControl call to return. In the event that a file or directory is not closed prior to a volume failure, + /// operating system failure, or shutdown, a cleanup call to the change journal software occurs the next time the volume is + /// mounted. The call occurs even if there is an intervening system restart. + /// + /// + /// To receive notification the first time each change is logged, as well as at cleanup, set ReturnOnlyOnClose to zero. + /// + /// + /// Whether ReturnOnlyOnClose is zero or nonzero, the records generated at cleanup log within the change journal all + /// reasons for USN changes that occurred to the file or directory. Each time a final close operation occurs for an item, a USN + /// close record is written to the change journal, and the ReasonMask flags for the item are all reset. + /// + /// + /// For a file or directory for which no user data exists (for example, a mounted folder), the final close operation occurs when + /// the CloseHandle function is called on the last user handle to the item. + /// + /// + public uint ReturnOnlyOnClose; + + /// + /// + /// The time-out value, in seconds, used with the BytesToWaitFor member to tell the operating system what to do if the + /// FSCTL_READ_USN_JOURNAL operation requests more data than exists in the change journal. + /// + /// + /// If Timeout is zero and BytesToWaitFor is nonzero, and the FSCTL_READ_USN_JOURNAL operation call reaches the end + /// of the change journal without finding data to return, FSCTL_READ_USN_JOURNAL waits until BytesToWaitFor bytes + /// of unfiltered data have been added to the change journal and then retrieves the specified records. + /// + /// + /// If Timeout is nonzero and BytesToWaitFor is nonzero, and the FSCTL_READ_USN_JOURNAL operation call reaches the + /// end of the change journal without finding data to return, FSCTL_READ_USN_JOURNAL waits Timeout seconds and then + /// attempts to return the specified records. After Timeout seconds, FSCTL_READ_USN_JOURNAL retrieves any records + /// available within the specified range. + /// + /// + /// In either case, after the time-out period any new data appended to the change journal is processed. If there are still no + /// records to return from the specified set, the time-out period is repeated. In this mode, FSCTL_READ_USN_JOURNAL remains + /// outstanding until at least one record is returned or I/O is canceled. + /// + /// + /// If BytesToWaitFor is zero, then Timeout is ignored. Timeout is also ignored for asynchronously opened handles. + /// + /// + public ulong Timeout; + + /// + /// + /// The number of bytes of unfiltered data added to the change journal. Use this value with Timeout to tell the operating + /// system what to do if the FSCTL_READ_USN_JOURNAL operation requests more data than exists in the change journal. + /// + /// + /// If BytesToWaitFor is zero, then Timeout is ignored. In this case, the FSCTL_READ_USN_JOURNAL operation always + /// returns successfully when the end of the change journal file is encountered. It also retrieves the USN that should be used + /// for the next FSCTL_READ_USN_JOURNAL operation. When the returned next USN is the same as the StartUsn supplied, + /// there are no records available. The calling process should not use FSCTL_READ_USN_JOURNAL again immediately. + /// + /// + /// Because the amount of data returned cannot be predicted when BytesToWaitFor is zero, you run a risk of overflowing the + /// output buffer. To reduce this risk, specify a nonzero BytesToWaitFor value in repeated FSCTL_READ_USN_JOURNAL + /// operations until all records in the change journal are exhausted. Then specify zero to await new records. + /// + /// + /// Alternatively, use the lpBytesReturned parameter of DeviceIoControl in the FSCTL_READ_USN_JOURNAL operation call to determine + /// the amount of data available, reallocate the output buffer (with room to spare for new records), and call + /// DeviceIoControl again. + /// + /// + public ulong BytesToWaitFor; + + /// + /// The identifier for the instance of the journal that is current for the volume. + /// + /// The NTFS file system can miss putting events in the change journal if the change journal is stopped and restarted or deleted + /// and re-created. If either of these events occurs, the NTFS file system gives the journal a new identifier. If the journal + /// identifier does not agree with the current journal identifier, the call to DeviceIoControl fails and returns an appropriate + /// error code. To retrieve the new journal identifier, call DeviceIoControl with the FSCTL_QUERY_USN_JOURNAL operation. + /// + /// + public ulong UsnJournalID; + } + + /// + /// Contains information defining a set of update sequence number (USN) change journal records to return to the calling process. It + /// is used by the FSCTL_QUERY_USN_JOURNAL and FSCTL_READ_USN_JOURNAL control codes. Prior to Windows 8 and Windows Server 2012 this + /// structure was named READ_USN_JOURNAL_DATA. Use that name to compile with older SDKs and compilers. Windows Server 2012 + /// introduced READ_USN_JOURNAL_DATA_V1 to support 128-bit file identifiers used by ReFS. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-read_usn_journal_data_v1 typedef struct { USN StartUsn; + // DWORD ReasonMask; DWORD ReturnOnlyOnClose; DWORDLONG Timeout; DWORDLONG BytesToWaitFor; DWORDLONG UsnJournalID; WORD + // MinMajorVersion; WORD MaxMajorVersion; } READ_USN_JOURNAL_DATA_V1, *PREAD_USN_JOURNAL_DATA_V1; + [PInvokeData("winioctl.h", MSDNShortId = "f88e71ba-6099-4928-9d71-732a4ca809bc")] + [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 48)] + public struct READ_USN_JOURNAL_DATA_V1 + { + /// + /// The USN at which to begin reading the change journal. + /// + /// To start the read operation at the first record in the journal, set the StartUsn member to zero. Because a USN is + /// contained in every journal record, the output buffer tells at which record the read operation actually started. + /// + /// To start the read operation at a specific record, set StartUsn to that record USN. + /// + /// If a nonzero USN is specified that is less than the first USN in the change journal, then an error occurs and the + /// ERROR_JOURNAL_ENTRY_DELETED error code is returned. This code may indicate a case in which the specified USN is valid + /// at one time but has since been deleted. + /// + /// + /// For more information on navigating the change journal buffer returned in READ_USN_JOURNAL_DATA_V0, see Walking a + /// Buffer of Change Journal Records. + /// + /// + public int StartUsn; + + /// + /// + /// A mask of flags, each flag noting a change for which the file or directory has a record in the change journal. To be returned + /// in a FSCTL_READ_USN_JOURNAL operation, a change journal record must have at least one of these flags set. + /// + /// The list of valid flags is as follows. Unused bits are reserved. + /// + /// + /// Value + /// Meaning + /// + /// + /// USN_REASON_BASIC_INFO_CHANGE 0x00008000 + /// + /// A user has either changed one or more file or directory attributes (such as the read-only, hidden, system, archive, or sparse + /// attribute), or one or more time stamps. + /// + /// + /// + /// USN_REASON_CLOSE 0x80000000 + /// The file or directory is closed. + /// + /// + /// USN_REASON_COMPRESSION_CHANGE 0x00020000 + /// The compression state of the file or directory is changed from or to compressed. + /// + /// + /// USN_REASON_DATA_EXTEND 0x00000002 + /// The file or directory is added to. + /// + /// + /// USN_REASON_DATA_OVERWRITE 0x00000001 + /// Data in the file or directory is overwritten. + /// + /// + /// USN_REASON_DATA_TRUNCATION 0x00000004 + /// The file or directory is truncated. + /// + /// + /// USN_REASON_EA_CHANGE 0x00000400 + /// + /// The user makes a change to the file or directory extended attributes. These NTFS file system attributes are not accessible to + /// Windows-based applications. + /// + /// + /// + /// USN_REASON_ENCRYPTION_CHANGE 0x00040000 + /// The file or directory is encrypted or decrypted. + /// + /// + /// USN_REASON_FILE_CREATE 0x00000100 + /// The file or directory is created for the first time. + /// + /// + /// USN_REASON_FILE_DELETE 0x00000200 + /// The file or directory is deleted. + /// + /// + /// USN_REASON_HARD_LINK_CHANGE 0x00010000 + /// + /// An NTFS file system hard link is added to or removed from the file or directory. An NTFS file system hard link, similar to a + /// POSIX hard link, is one of several directory entries that see the same file or directory. + /// + /// + /// + /// USN_REASON_INDEXABLE_CHANGE 0x00004000 + /// + /// A user changed the FILE_ATTRIBUTE_NOT_CONTENT_INDEXED attribute. That is, the user changed the file or directory from one + /// that can be content indexed to one that cannot, or vice versa. (Content indexing permits rapid searching of data by building + /// a database of selected content.) + /// + /// + /// + /// USN_REASON_NAMED_DATA_EXTEND 0x00000020 + /// One or more named data streams for the file were added to. + /// + /// + /// USN_REASON_NAMED_DATA_OVERWRITE 0x00000010 + /// Data in one or more named data streams for the file is overwritten. + /// + /// + /// USN_REASON_NAMED_DATA_TRUNCATION 0x00000040 + /// One or more named data streams for the file is truncated. + /// + /// + /// USN_REASON_OBJECT_ID_CHANGE 0x00080000 + /// The object identifier of the file or directory is changed. + /// + /// + /// USN_REASON_RENAME_NEW_NAME 0x00002000 + /// + /// The file or directory is renamed, and the file name in the USN_RECORD_V2 or USN_RECORD_V3 structure holding this journal + /// record is the new name. + /// + /// + /// + /// USN_REASON_RENAME_OLD_NAME 0x00001000 + /// + /// The file or directory is renamed, and the file name in the USN_RECORD_V2 or USN_RECORD_V3 structure holding this journal + /// record is the previous name. + /// + /// + /// + /// USN_REASON_REPARSE_POINT_CHANGE 0x00100000 + /// + /// The reparse point contained in the file or directory is changed, or a reparse point is added to or deleted from the file or directory. + /// + /// + /// + /// USN_REASON_SECURITY_CHANGE 0x00000800 + /// A change is made in the access permissions to the file or directory. + /// + /// + /// USN_REASON_STREAM_CHANGE 0x00200000 + /// A named stream is added to or removed from the file or directory, or a named stream is renamed. + /// + /// + /// + public uint ReasonMask; + + /// + /// A value that specifies when to return change journal records. + /// + /// To receive notification when the final handle for the changed file or directory is closed, rather than at the time a change + /// occurs, set ReturnOnlyOnClose to any nonzero value and specify the USN_REASON_CLOSE flag in the + /// ReasonMask member. + /// + /// + /// All changes indicated by ReasonMask flags eventually generate a call to the change journal software when the file is + /// closed. If your DeviceIoControl call is waiting for the file to be closed, that call in turn will allow your + /// DeviceIoControl call to return. In the event that a file or directory is not closed prior to a volume failure, + /// operating system failure, or shutdown, a cleanup call to the change journal software occurs the next time the volume is + /// mounted. The call occurs even if there is an intervening system restart. + /// + /// + /// To receive notification the first time each change is logged, as well as at cleanup, set ReturnOnlyOnClose to zero. + /// + /// + /// Whether ReturnOnlyOnClose is zero or nonzero, the records generated at cleanup log within the change journal all + /// reasons for USN changes that occurred to the file or directory. Each time a final close operation occurs for an item, a USN + /// close record is written to the change journal, and the ReasonMask flags for the item are all reset. + /// + /// + /// For a file or directory for which no user data exists (for example, a mounted folder), the final close operation occurs when + /// the CloseHandle function is called on the last user handle to the item. + /// + /// + public uint ReturnOnlyOnClose; + + /// + /// + /// The time-out value, in seconds, used with the BytesToWaitFor member to tell the operating system what to do if the + /// FSCTL_READ_USN_JOURNAL operation requests more data than exists in the change journal. + /// + /// + /// If Timeout is zero and BytesToWaitFor is nonzero, and the FSCTL_READ_USN_JOURNAL operation call reaches the end + /// of the change journal without finding data to return, FSCTL_READ_USN_JOURNAL waits until BytesToWaitFor bytes + /// of unfiltered data have been added to the change journal and then retrieves the specified records. + /// + /// + /// If Timeout is nonzero and BytesToWaitFor is nonzero, and the FSCTL_READ_USN_JOURNAL operation call reaches the + /// end of the change journal without finding data to return, FSCTL_READ_USN_JOURNAL waits Timeout seconds and then + /// attempts to return the specified records. After Timeout seconds, FSCTL_READ_USN_JOURNAL retrieves any records + /// available within the specified range. + /// + /// + /// In either case, after the time-out period any new data appended to the change journal is processed. If there are still no + /// records to return from the specified set, the time-out period is repeated. In this mode, FSCTL_READ_USN_JOURNAL remains + /// outstanding until at least one record is returned or I/O is canceled. + /// + /// + /// If BytesToWaitFor is zero, then Timeout is ignored. Timeout is also ignored for asynchronously opened handles. + /// + /// + public ulong Timeout; + + /// + /// + /// The number of bytes of unfiltered data added to the change journal. Use this value with Timeout to tell the operating + /// system what to do if the FSCTL_READ_USN_JOURNAL operation requests more data than exists in the change journal. + /// + /// + /// If BytesToWaitFor is zero, then Timeout is ignored. In this case, the FSCTL_READ_USN_JOURNAL operation always + /// returns successfully when the end of the change journal file is encountered. It also retrieves the USN that should be used + /// for the next FSCTL_READ_USN_JOURNAL operation. When the returned next USN is the same as the StartUsn supplied, + /// there are no records available. The calling process should not use FSCTL_READ_USN_JOURNAL again immediately. + /// + /// + /// Because the amount of data returned cannot be predicted when BytesToWaitFor is zero, you run a risk of overflowing the + /// output buffer. To reduce this risk, specify a nonzero BytesToWaitFor value in repeated FSCTL_READ_USN_JOURNAL + /// operations until all records in the change journal are exhausted. Then specify zero to await new records. + /// + /// + /// Alternatively, use the lpBytesReturned parameter of DeviceIoControl in the FSCTL_READ_USN_JOURNAL operation call to determine + /// the amount of data available, reallocate the output buffer (with room to spare for new records), and call + /// DeviceIoControl again. + /// + /// + public ulong BytesToWaitFor; + + /// + /// The identifier for the instance of the journal that is current for the volume. + /// + /// The NTFS file system can miss putting events in the change journal if the change journal is stopped and restarted or deleted + /// and re-created. If either of these events occurs, the NTFS file system gives the journal a new identifier. If the journal + /// identifier does not agree with the current journal identifier, the call to DeviceIoControl fails and returns an appropriate + /// error code. To retrieve the new journal identifier, call DeviceIoControl with the FSCTL_QUERY_USN_JOURNAL operation. + /// + /// + public ulong UsnJournalID; + + /// + public ushort MinMajorVersion; + + /// + public ushort MaxMajorVersion; + } + /// /// Represents an update sequence number (USN) change journal, its records, and its capacity. This structure is the output buffer for /// the FSCTL_QUERY_USN_JOURNAL control code. Prior to Windows 8 and Windows Server 2012 this structure was named @@ -1972,7 +4157,6 @@ CLASS_MEDIA_CHANGE_CONTEXT : 8 CREATE_DISK : 24 CREATE_DISK_GPT : 20 CREATE_DISK_MBR : 4 -CREATE_USN_JOURNAL_DATA : 16 CSV_CONTROL_PARAM : 16 CSV_IS_OWNED_BY_CSVFS : 1 CSV_NAMESPACE_INFO : 24 @@ -1980,7 +4164,6 @@ CSV_QUERY_FILE_REVISION : 32 CSV_QUERY_MDS_PATH : 16 CSV_QUERY_REDIRECT_STATE : 12 CSV_QUERY_VETO_FILE_DIRECT_IO_OUTPUT : 528 -DELETE_USN_JOURNAL_DATA : 16 DEVICE_COPY_OFFLOAD_DESCRIPTOR : 48 DEVICE_DATA_SET_LB_PROVISIONING_STATE : 32 DEVICE_DATA_SET_RANGE : 16 @@ -2052,9 +4235,6 @@ PARTITION_INFORMATION_MBR : 24 PLEX_READ_DATA_REQUEST : 16 PREVENT_MEDIA_REMOVAL : 1 READ_ELEMENT_ADDRESS_INFO : 104 -READ_FILE_USN_DATA : 4 -READ_USN_JOURNAL_DATA_V0 : 40 -READ_USN_JOURNAL_DATA_V1 : 48 REASSIGN_BLOCKS : 8 REASSIGN_BLOCKS_EX : 12 REPAIR_COPIES_INPUT : 32 @@ -2112,16 +4292,6 @@ TXFS_QUERY_RM_INFORMATION : 176 TXFS_READ_BACKUP_INFORMATION_OUT : 4 TXFS_TRANSACTION_ACTIVE_INFO : 1 TXFS_WRITE_BACKUP_INFORMATION : 1 -USN_JOURNAL_DATA_V0 : 56 -USN_JOURNAL_DATA_V1 : 64 -USN_JOURNAL_DATA_V2 : 80 -USN_RANGE_TRACK_OUTPUT : 8 -USN_RECORD_COMMON_HEADER : 8 -USN_RECORD_EXTENT : 16 -USN_RECORD_V2 : 64 -USN_RECORD_V3 : 80 -USN_RECORD_V4 : 80 -USN_TRACK_MODIFIED_RANGES : 24 VERIFY_INFORMATION : 16 VOLUME_BITMAP_BUFFER : 24 VOLUME_DISK_EXTENTS : 32 @@ -2138,10 +4308,6 @@ winioctl_CHANGER_SEND_VOLUME_TAG_INFORMATION Contains information that the IOCTL winioctl_CHANGER_SET_ACCESS Contains information that the IOCTL_CHANGER_SET_ACCESS control code needs to set the state of the device's insert/eject port, door, or keypad. winioctl_CHANGER_SET_POSITION Contains information needed by the IOCTL_CHANGER_SET_POSITION control code to set the changer's robotic transport mechanism to the specified element address. winioctl_CLASS_MEDIA_CHANGE_CONTEXT Contains information associated with a media change event. -winioctl_CREATE_DISK Contains information that the IOCTL_DISK_CREATE_DISK control code uses to initialize GUID partition table (GPT), master boot record (MBR), or raw disks. -winioctl_CREATE_DISK_GPT Contains information used by the IOCTL_DISK_CREATE_DISK control code to initialize GUID partition table (GPT) disks. -winioctl_CREATE_DISK_MBR Contains information that the IOCTL_DISK_CREATE_DISK control code uses to initialize master boot record (MBR) disks. -winioctl_CREATE_USN_JOURNAL_DATA Contains information that describes an update sequence number (USN) change journal. winioctl_CSV_CONTROL_PARAM Represents a type of CSV control operation. winioctl_CSV_IS_OWNED_BY_CSVFS Contains the output for the FSCTL_IS_VOLUME_OWNED_BYCSVFS control code that determines whether a volume is owned by CSVFS. winioctl_CSV_NAMESPACE_INFO Contains the output for the FSCTL_IS_CSV_FILE control code that retrieves namespace information for a file. @@ -2149,7 +4315,6 @@ winioctl_CSV_QUERY_FILE_REVISION Contains information about whether files in a s winioctl_CSV_QUERY_MDS_PATH Contains the path that is used by CSV to communicate to the MDS. winioctl_CSV_QUERY_REDIRECT_STATE Contains information about whether files in a stream have been redirected. winioctl_CSV_QUERY_VETO_FILE_DIRECT_IO_OUTPUT Contains troubleshooting information about why a volume is in redirected mode. -winioctl_DELETE_USN_JOURNAL_DATA Contains information on the deletion of an update sequence number (USN) change journal using the FSCTL_DELETE_USN_JOURNAL control code. winioctl_DEVICE_COPY_OFFLOAD_DESCRIPTOR Contains the copy offload capabilities for a storage device. winioctl_DEVICE_DATA_SET_LB_PROVISIONING_STATE Output structure for the DeviceDsmAction_Allocation action of the IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES control code. winioctl_DEVICE_DATA_SET_RANGE Provides data set range information for use with the IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES control code. @@ -2165,13 +4330,7 @@ winioctl_DEVICE_POWER_DESCRIPTOR The DEVICE_POWER_DESCRIPTOR structure describes winioctl_DEVICE_SEEK_PENALTY_DESCRIPTOR Used in conjunction with the IOCTL_STORAGE_QUERY_PROPERTY request to retrieve the seek penalty descriptor data for a device. winioctl_DEVICE_TRIM_DESCRIPTOR Used in conjunction with the IOCTL_STORAGE_QUERY_PROPERTY request to retrieve the trim descriptor data for a device. winioctl_DEVICE_WRITE_AGGREGATION_DESCRIPTOR Reserved for system use. -winioctl_DRIVE_LAYOUT_INFORMATION Contains information about the partitions of a drive. -winioctl_DRIVE_LAYOUT_INFORMATION_EX Contains extended information about a drive's partitions. -winioctl_DRIVE_LAYOUT_INFORMATION_GPT Contains information about a drive's GUID partition table (GPT) partitions. -winioctl_DRIVE_LAYOUT_INFORMATION_MBR Provides information about a drive's master boot record (MBR) partitions. winioctl_DUPLICATE_EXTENTS_DATA Contains parameters for the FSCTL_DUPLICATE_EXTENTS control code that performs the Block Cloning operation. -winioctl_EXFAT_STATISTICS Contains statistical information from the exFAT file system. -winioctl_FAT_STATISTICS Contains statistical information from the FAT file system. winioctl_FILE_ALLOCATED_RANGE_BUFFER Indicates a range of bytes in a file. winioctl_FILE_LEVEL_TRIM Used as input to the FSCTL_FILE_LEVEL_TRIM control code. winioctl_FILE_LEVEL_TRIM_OUTPUT Used as output to the FSCTL_FILE_LEVEL_TRIM control code. @@ -2186,8 +4345,6 @@ winioctl_FILE_STORAGE_TIER Represents an identifier for the storage tier relativ winioctl_FILE_STORAGE_TIER_REGION Describes a single storage tier region. winioctl_FILE_SYSTEM_RECOGNITION_INFORMATION Contains file system recognition information retrieved by the FSCTL_QUERY_FILE_SYSTEM_RECOGNITION control code. winioctl_FILE_ZERO_DATA_INFORMATION Contains a range of a file to set to zeros. -winioctl_FILESYSTEM_STATISTICS Contains statistical information from the file system. -winioctl_FILESYSTEM_STATISTICS_EX Contains statistical information from the file system.Support for this structure started with Windows 10. winioctl_FIND_BY_SID_DATA Contains data for the FSCTL_FIND_FILES_BY_SID control code. winioctl_FIND_BY_SID_OUTPUT Represents a file name. winioctl_FORMAT_EX_PARAMETERS Contains information used in formatting a contiguous set of disk tracks. It is used by the IOCTL_DISK_FORMAT_TRACKS_EX control code. @@ -2210,19 +4367,10 @@ winioctl_MOVE_FILE_DATA Contains input data for the FSCTL_MOVE_FILE control code winioctl_NTFS_EXTENDED_VOLUME_DATA Represents volume data. winioctl_NTFS_FILE_RECORD_INPUT_BUFFER Contains data for the FSCTL_GET_NTFS_FILE_RECORD control code. winioctl_NTFS_FILE_RECORD_OUTPUT_BUFFER Receives output data from the FSCTL_GET_NTFS_FILE_RECORD control code. -winioctl_NTFS_STATISTICS Contains statistical information from the NTFS file system. -winioctl_NTFS_STATISTICS_EX Contains statistical information from the NTFS file system.Support for this structure started with Windows 10. winioctl_NTFS_VOLUME_DATA_BUFFER Represents volume data. -winioctl_PARTITION_INFORMATION Contains information about a disk partition. -winioctl_PARTITION_INFORMATION_EX Contains partition information for standard AT-style master boot record (MBR) and Extensible Firmware Interface (EFI) disks. -winioctl_PARTITION_INFORMATION_GPT Contains GUID partition table (GPT) partition information. -winioctl_PARTITION_INFORMATION_MBR Contains partition information specific to master boot record (MBR) disks. winioctl_PLEX_READ_DATA_REQUEST Indicates the range of the read operation to perform and the plex from which to read. winioctl_PREVENT_MEDIA_REMOVAL Provides removable media locking data. It is used by the IOCTL_STORAGE_MEDIA_REMOVAL control code. winioctl_READ_ELEMENT_ADDRESS_INFO Represents the volume tag information. It is used by the IOCTL_CHANGER_QUERY_VOLUME_TAGS control code. -winioctl_READ_FILE_USN_DATA Specifies the versions of the update sequence number (USN) change journal supported by the application. -winioctl_READ_USN_JOURNAL_DATA_V0 Contains information defining a set of update sequence number (USN) change journal records to return to the calling process. -winioctl_READ_USN_JOURNAL_DATA_V1 Contains information defining a set of update sequence number (USN) change journal records to return to the calling process. winioctl_REASSIGN_BLOCKS Contains disk block reassignment data. winioctl_REASSIGN_BLOCKS_EX Contains disk block reassignment data. winioctl_REPAIR_COPIES_INPUT Input structure for the FSCTL_REPAIR_COPIES control code. diff --git a/PInvoke/Kernel32/WinIOCtl.cs b/PInvoke/Kernel32/WinIOCtl.cs index 919a1b5e..dd70b688 100644 --- a/PInvoke/Kernel32/WinIOCtl.cs +++ b/PInvoke/Kernel32/WinIOCtl.cs @@ -130,23 +130,87 @@ namespace Vanara.PInvoke METHOD_NEITHER = 3, } - /// - /// Represents IO control codes. - /// + /// Represents IO control codes. [PInvokeData("WinIOCtl.h")] public static class IOControlCode { - private const ushort IOCTL_SCMBUS_DEVICE_FUNCTION_BASE = 0x0; private const ushort IOCTL_SCM_LOGICAL_DEVICE_FUNCTION_BASE = 0x300; private const ushort IOCTL_SCM_PHYSICAL_DEVICE_FUNCTION_BASE = 0x600; - + private const ushort IOCTL_SCMBUS_DEVICE_FUNCTION_BASE = 0x0; public static uint FSCTL_ADD_OVERLAY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 204, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); public static uint FSCTL_ADVANCE_FILE_ID => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 177, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_ALLOW_EXTENDED_DASD_IO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 32, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_CLEAN_VOLUME_METADATA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 223, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_CORRUPTION_HANDLING => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 152, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_CREATE_OR_GET_OBJECT_ID => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 48, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + + /// + /// + /// Creates an update sequence number (USN) change journal stream on a target volume, or modifies an existing change journal stream. + /// + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic. + /// + /// You can use FSCTL_CREATE_USN_JOURNAL to create a new change journal stream for a volume. After the creation of the + /// stream, the NTFS file system maintains a change journal for that volume. + /// + /// + /// You can also use FSCTL_CREATE_USN_JOURNAL to modify an existing change journal stream. If a change journal stream + /// already exists, FSCTL_CREATE_USN_JOURNAL sets it to the characteristics provided in the CREATE_USN_JOURNAL_DATA + /// structure. The change journal stream eventually gets larger or is trimmed to the new size limit that CREATE_USN_JOURNAL_DATA imposes. + /// + /// For more information, see Creating, Modifying, and Deleting a Change Journal. + /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: + /// \.<i>X: + /// + /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS 3.0 or + /// later. To obtain the NTFS version of a volume, open a command prompt with Administrator access rights and execute the + /// following command: + /// + /// fsutil fsinfo ntfsinfo X : + /// where X is the drive letter of the volume. + /// In Windows Server 2012, this function is supported by the following technologies. + /// + /// + /// Technology + /// Supported + /// + /// + /// Server Message Block (SMB) 3.0 protocol + /// No + /// + /// + /// SMB 3.0 Transparent Failover (TFO) + /// No + /// + /// + /// SMB 3.0 with Scale-out File Shares (SO) + /// No + /// + /// + /// Cluster Shared Volume File System (CsvFS) + /// Yes + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_create_usn_journal?redirectedfrom=MSDN + [PInvokeData("winioctl.h", MSDNShortId = "92e737e6-dba6-47f1-a077-e303039e12eb")] + [CorrespondingType(typeof(CREATE_USN_JOURNAL_DATA), CorrespondingAction.Get)] public static uint FSCTL_CREATE_USN_JOURNAL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 57, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_CSC_INTERNAL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 107, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_CSV_CONTROL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 181, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 149, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -163,7 +227,88 @@ namespace Vanara.PInvoke public static uint FSCTL_DELETE_EXTERNAL_BACKING => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 197, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_DELETE_OBJECT_ID => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 40, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_DELETE_REPARSE_POINT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 43, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + + /// + /// Deletes the update sequence number (USN) change journal on a volume, or waits for notification of change journal deletion. + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic. + /// + /// You can use FSCTL_DELETE_USN_JOURNAL to delete a change journal. The NTFS file system starts a deletion operation and + /// returns immediately to the calling process, unless the USN_DELETE_FLAG_NOTIFY flag is set in the DeleteFlags + /// member of DELETE_USN_JOURNAL_DATA. + /// + /// + /// If the USN_DELETE_FLAG_NOTIFY and USN_DELETE_FLAG_DELETE flags are both set, a call to + /// FSCTL_DELETE_USN_JOURNAL begins the deletion process. Then the call either blocks the calling thread and waits for the + /// deletion (on a synchronous or non-overlapped call), or sets up event notification by using an I/O completion port or other + /// mechanism, and returns (on an asynchronous or overlapped call). + /// + /// + /// You can also use FSCTL_DELETE_USN_JOURNAL to receive notification that a change journal deletion is complete, by + /// setting only USN_DELETE_FLAG_NOTIFY. If you do so, the FSCTL_DELETE_USN_JOURNAL operation either waits until + /// the deletion completes before returning (on a synchronous or non-overlapped call), or sets up event notification by using an + /// I/O completion port or other mechanism (on an asynchronous or overlapped call). + /// + /// + /// The deletion on which an application receives notification may have been initiated by the current process, or some other + /// process. For example, when an application is started, it can use FSCTL_DELETE_USN_JOURNAL to determine if a deletion + /// started by some other process is in progress and if it is, exit. + /// + /// + /// Complete deletion of a change journal requires a scan of the volume where the change journal resides, which may take a long + /// time on a volume with many files. The operation continues to completion even across system restarts. Attempts to create, + /// modify, delete, or query the change journal while deletion is in progress fail and return the error code ERROR_JOURNAL_DELETE_IN_PROGRESS. + /// + /// + /// The FSCTL_DELETE_USN_JOURNAL operation has a significant performance cost, so it should be used sparingly. An + /// administrator should delete a journal when the current USN value approaches that of the maximum possible USN value. + /// + /// For more information, see Creating, Modifying, and Deleting a Change Journal. + /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: + /// \.<i>X: + /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS. + /// In Windows 8 and Windows Server 2012, this code is supported by the following technologies. + /// + /// + /// Technology + /// Supported + /// + /// + /// Server Message Block (SMB) 3.0 protocol + /// No + /// + /// + /// SMB 3.0 Transparent Failover (TFO) + /// No + /// + /// + /// SMB 3.0 with Scale-out File Shares (SO) + /// No + /// + /// + /// Cluster Shared Volume File System (CsvFS) + /// Yes + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_delete_usn_journal + [PInvokeData("winioctl.h", MSDNShortId = "6c85464d-019b-4923-9acf-152b4ee8c31b")] + [CorrespondingType(typeof(DELETE_USN_JOURNAL_DATA), CorrespondingAction.Get)] public static uint FSCTL_DELETE_USN_JOURNAL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 62, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_DFSR_SET_GHOST_HANDLE_STATE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 110, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_DISABLE_LOCAL_BUFFERING => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 174, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_DISMOUNT_VOLUME => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 8, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -177,7 +322,9 @@ namespace Vanara.PInvoke public static uint FSCTL_ENUM_OVERLAY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 199, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); /// - /// Enumerates the update sequence number (USN) data between two specified boundaries to obtain master file table (MFT) records. + /// + /// Enumerates the update sequence number (USN) data between two specified boundaries to obtain master file table (MFT) records. + /// /// To perform this operation, call the DeviceIoControl function with the following parameters. /// Major Code /// IRP_MJ_DEVICE_CONTROL @@ -194,7 +341,11 @@ namespace Vanara.PInvoke /// /// /// For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic. - /// To enumerate files on a volume, use the FSCTL_ENUM_USN_DATA operation one or more times. On the first call, set the starting point, the StartFileReferenceNumber member of the MFT_ENUM_DATA structure, to . Each call to FSCTL_ENUM_USN_DATA retrieves the starting point for the subsequent call as the first entry in the output buffer. + /// + /// To enumerate files on a volume, use the FSCTL_ENUM_USN_DATA operation one or more times. On the first call, set the + /// starting point, the StartFileReferenceNumber member of the MFT_ENUM_DATA structure, to . Each call to + /// FSCTL_ENUM_USN_DATA retrieves the starting point for the subsequent call as the first entry in the output buffer. + /// /// By comparing To identify recent changes to a volume, use the FSCTL_READ_USN_JOURNAL control code. /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: /// \.<i>X: @@ -228,12 +379,13 @@ namespace Vanara.PInvoke [CorrespondingType(typeof(MFT_ENUM_DATA_V0), CorrespondingAction.Get)] [CorrespondingType(typeof(MFT_ENUM_DATA_V1), CorrespondingAction.Get)] public static uint FSCTL_ENUM_USN_DATA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 44, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_EXTEND_VOLUME => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 60, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); - public static uint FSCTL_FILESYSTEM_GET_STATISTICS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 24, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); - public static uint FSCTL_FILESYSTEM_GET_STATISTICS_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 227, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_FILE_LEVEL_TRIM => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 130, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); public static uint FSCTL_FILE_PREFETCH => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 72, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_FILE_TYPE_NOTIFICATION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 129, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_FILESYSTEM_GET_STATISTICS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 24, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_FILESYSTEM_GET_STATISTICS_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 227, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_FIND_FILES_BY_SID => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 35, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); /// @@ -281,6 +433,7 @@ namespace Vanara.PInvoke [PInvokeData("winioctl.h", MSDNShortId = "5739354b-5342-4be9-ac50-bb983d51587c")] [CorrespondingType(typeof(BOOT_AREA_INFO), CorrespondingAction.Get)] public static uint FSCTL_GET_BOOT_AREA_INFO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 140, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_GET_COMPRESSION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 15, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_EXTERNAL_BACKING => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 196, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_INTEGRITY_INFORMATION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 159, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -290,10 +443,10 @@ namespace Vanara.PInvoke public static uint FSCTL_GET_REFS_VOLUME_DATA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 182, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_REPAIR => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 103, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_REPARSE_POINT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 42, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); - public static uint FSCTL_GET_RETRIEVAL_POINTERS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 28, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); - public static uint FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 244, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_RETRIEVAL_POINTER_BASE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 141, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_RETRIEVAL_POINTER_COUNT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 266, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_GET_RETRIEVAL_POINTERS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 28, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 244, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_VOLUME_BITMAP => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 27, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GET_WOF_VERSION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 218, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_GHOST_FILE_EXTENTS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 235, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); @@ -320,8 +473,8 @@ namespace Vanara.PInvoke public static uint FSCTL_OFFLOAD_READ => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 153, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_OFFLOAD_WRITE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 154, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); public static uint FSCTL_OPBATCH_ACK_CLOSE_PENDING => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 4, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); - public static uint FSCTL_OPLOCK_BREAK_ACKNOWLEDGE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 3, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_OPLOCK_BREAK_ACK_NO_2 => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 20, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_OPLOCK_BREAK_ACKNOWLEDGE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 3, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_OPLOCK_BREAK_NOTIFY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 5, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_QUERY_ALLOCATED_RANGES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 51, IOMethod.METHOD_NEITHER, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_QUERY_BAD_RANGES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 251, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -367,7 +520,10 @@ namespace Vanara.PInvoke /// For more information, see Creating, Modifying, and Deleting a Change Journal. /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: /// \.<i>X: - /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be formatted with the NTFS filesystem. + /// + /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be formatted with + /// the NTFS filesystem. + /// /// In Windows 8 and Windows Server 2012, this code is supported by the following technologies. /// /// @@ -398,14 +554,137 @@ namespace Vanara.PInvoke [CorrespondingType(typeof(USN_JOURNAL_DATA_V0), CorrespondingAction.Get)] [CorrespondingType(typeof(USN_JOURNAL_DATA_V1), CorrespondingAction.Get)] [CorrespondingType(typeof(USN_JOURNAL_DATA_V2), CorrespondingAction.Get)] + [CorrespondingType(typeof(READ_USN_JOURNAL_DATA_V0), CorrespondingAction.Get)] + [CorrespondingType(typeof(READ_USN_JOURNAL_DATA_V1), CorrespondingAction.Get)] public static uint FSCTL_QUERY_USN_JOURNAL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 61, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_QUERY_VOLUME_CONTAINER_STATE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 228, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_QUERY_VOLUME_NUMA_INFO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 245, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + + /// + /// Retrieves the update sequence number (USN) change-journal information for the specified file or directory. + /// To perform this operation, call the DeviceIoControl function with the following parameters. + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// + /// If the call succeeds, the members of the returned USN_RECORD_V2 or USN_RECORD_V3 structure are valid except for the following + /// members: TimeStamp, Reason, and SourceInfo. The Usn member represents the last USN written to the + /// journal for this file or directory. + /// + /// For more information, see Creating, Modifying, and Deleting a Change Journal. + /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: + /// \.<i>X: + /// + /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be ReFS or NTFS + /// 3.0 or later. To obtain the NTFS version of a volume, open a command prompt with Administrator access rights and execute the + /// following command: + /// + /// FSUtil.exe FSInfo NTFSInfo X : + /// where X is the drive letter of the volume. + /// In Windows 8 and Windows Server 2012, this code is supported by the following technologies. + /// + /// + /// Technology + /// Supported + /// + /// + /// Server Message Block (SMB) 3.0 protocol + /// No + /// + /// + /// SMB 3.0 Transparent Failover (TFO) + /// No + /// + /// + /// SMB 3.0 with Scale-out File Shares (SO) + /// No + /// + /// + /// Cluster Shared Volume File System (CsvFS) + /// Yes + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_read_file_usn_data?redirectedfrom=MSDN + [PInvokeData("winioctl.h", MSDNShortId = "22c797c8-87c8-4d45-b163-4573e6ed17e1")] + [CorrespondingType(typeof(READ_FILE_USN_DATA), CorrespondingAction.Get)] public static uint FSCTL_READ_FILE_USN_DATA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 58, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_READ_FROM_PLEX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 71, IOMethod.METHOD_OUT_DIRECT, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_READ_RAW_ENCRYPTED => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 56, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_READ_UNPRIVILEGED_USN_JOURNAL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 234, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + + /// + /// Retrieves the set of update sequence number (USN) change journal records between two specified USN values. + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic. + /// + /// There are two DeviceIoControl control codes that return USN records, FSCTL_READ_USN_JOURNAL and FSCTL_ENUM_USN_DATA. + /// Use the latter when you want a listing (enumeration) of the USN records between two USNs. Use the former when you want to + /// select by USN. + /// + /// For more information, see Creating, Modifying, and Deleting a Change Journal. + /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: + /// \.<i>X: + /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS. + /// In Windows 8 and Windows Server 2012, this code is supported by the following technologies. + /// + /// + /// Technology + /// Supported + /// + /// + /// Server Message Block (SMB) 3.0 protocol + /// No + /// + /// + /// SMB 3.0 Transparent Failover (TFO) + /// No + /// + /// + /// SMB 3.0 with Scale-out File Shares (SO) + /// No + /// + /// + /// Cluster Shared Volume File System (CsvFS) + /// See comment + /// + /// + /// An application may experience false positives on CsvFs pause/resume. + /// Examples + /// For an example, see Walking a Buffer of Change Journal Records. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_read_usn_journal + [PInvokeData("winioctl.h", MSDNShortId = "205de464-7e96-477b-9115-e819719b160e")] + [CorrespondingType(typeof(READ_USN_JOURNAL_DATA_V0), CorrespondingAction.Get)] + [CorrespondingType(typeof(READ_USN_JOURNAL_DATA_V1), CorrespondingAction.Get)] public static uint FSCTL_READ_USN_JOURNAL => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 46, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_REARRANGE_FILE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 264, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); public static uint FSCTL_RECALL_FILE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 69, IOMethod.METHOD_NEITHER, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_REFS_DEALLOCATE_RANGES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 246, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -464,8 +743,8 @@ namespace Vanara.PInvoke public static uint FSCTL_TXFS_CREATE_SECONDARY_RM => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 90, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); public static uint FSCTL_TXFS_GET_METADATA_INFO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 91, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_TXFS_GET_TRANSACTED_VERSION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 92, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); - public static uint FSCTL_TXFS_LIST_TRANSACTIONS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 121, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 120, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); + public static uint FSCTL_TXFS_LIST_TRANSACTIONS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 121, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_TXFS_MODIFY_RM => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 81, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); public static uint FSCTL_TXFS_QUERY_RM_INFORMATION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 82, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint FSCTL_TXFS_READ_BACKUP_INFORMATION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 88, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); @@ -483,7 +762,10 @@ namespace Vanara.PInvoke public static uint FSCTL_UPDATE_OVERLAY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 206, IOMethod.METHOD_BUFFERED, IOAccess.FILE_WRITE_ACCESS); /// - /// Enables range tracking feature for update sequence number (USN) change journal stream on a target volume, or modifies already enabled range tracking parameters. + /// + /// Enables range tracking feature for update sequence number (USN) change journal stream on a target volume, or modifies already + /// enabled range tracking parameters. + /// /// Major Code /// IRP_MJ_DEVICE_CONTROL /// Input Buffer @@ -499,12 +781,25 @@ namespace Vanara.PInvoke /// /// /// For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic. - /// You can use FSCTL_USN_TRACK_MODIFIED_RANGES to enable range tracking for the first time for a volume. After the enabling range tracking, the state and parameters will be persisted for that volume and on next reboot the range tracking will be initialized read from the persisted parameters. - /// You can also use FSCTL_USN_TRACK_MODIFIED_RANGES to modify an existing change journal stream range track parameter. If range tracking is already exists, FSCTL_USN_TRACK_MODIFIED_RANGES sets it to the parameters provided in the USN_TRACK_MODIFIED_RANGES structure. The chunk size or file size threshold can only be lowered from previous values. Once enabled, range tracking feature cannot be disabled unless the journal is deleted. + /// + /// You can use FSCTL_USN_TRACK_MODIFIED_RANGES to enable range tracking for the first time for a volume. After the + /// enabling range tracking, the state and parameters will be persisted for that volume and on next reboot the range tracking + /// will be initialized read from the persisted parameters. + /// + /// + /// You can also use FSCTL_USN_TRACK_MODIFIED_RANGES to modify an existing change journal stream range track parameter. If + /// range tracking is already exists, FSCTL_USN_TRACK_MODIFIED_RANGES sets it to the parameters provided in the + /// USN_TRACK_MODIFIED_RANGES structure. The chunk size or file size threshold can only be lowered from previous values. Once + /// enabled, range tracking feature cannot be disabled unless the journal is deleted. + /// /// To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form: /// \.\X: - /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS 3.0 or later. To obtain the NTFS version of a volume, open a command prompt with Administrator access rights and execute the following command: - /// fsutil fsinfo ntfsinfo X: + /// + /// In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be NTFS 3.0 or + /// later. To obtain the NTFS version of a volume, open a command prompt with Administrator access rights and execute the + /// following command: + /// + /// fsutil fsinfo ntfsinfo X : /// where X is the drive letter of the volume. /// // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_usn_track_modified_ranges @@ -512,6 +807,7 @@ namespace Vanara.PInvoke [CorrespondingType(typeof(USN_RANGE_TRACK_OUTPUT), CorrespondingAction.Get)] [CorrespondingType(typeof(USN_TRACK_MODIFIED_RANGES), CorrespondingAction.Get)] public static uint FSCTL_USN_TRACK_MODIFIED_RANGES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 189, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint FSCTL_VIRTUAL_STORAGE_PASSTHROUGH => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 265, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_VIRTUAL_STORAGE_QUERY_PROPERTY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 226, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint FSCTL_VIRTUAL_STORAGE_SET_BEHAVIOR => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_FILE_SYSTEM, 258, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -535,7 +831,33 @@ namespace Vanara.PInvoke public static uint IOCTL_CHANGER_SET_POSITION => CTL_CODE(DEVICE_TYPE.IOCTL_CHANGER_BASE, 0x0007, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint IOCTL_DISK_CHECK_VERIFY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0200, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint IOCTL_DISK_CONTROLLER_NUMBER => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0011, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + + /// + /// Initializes the specified disk and disk partition table using the information in the CREATE_DISK structure. + /// To perform this operation, call the DeviceIoControl function with the following parameters. + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// When specifying a GUID partition table (GPT) as the PARTITION_STYLE of the CREATE_DISK structure, an application should wait + /// for the MSR partition arrival before sending the IOCTL_DISK_SET_DRIVE_LAYOUT_EX control code. For more information about + /// device notification, see RegisterDeviceNotification. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_create_disk + [PInvokeData("winioctl.h", MSDNShortId = "c8215a00-ea39-4268-bb66-68cf3d37baef")] + [CorrespondingType(typeof(CREATE_DISK), CorrespondingAction.Get)] public static uint IOCTL_DISK_CREATE_DISK => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0016, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + public static uint IOCTL_DISK_DELETE_DRIVE_LAYOUT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0040, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); public static uint IOCTL_DISK_EJECT_MEDIA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0202, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint IOCTL_DISK_FIND_NEW_DEVICES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0206, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); @@ -564,11 +886,18 @@ namespace Vanara.PInvoke [PInvokeData("winioctl.h", MSDNShortId = "025a92e8-6169-4d7e-9029-f22acb2bdc9f")] [CorrespondingType(typeof(DISK_CACHE_INFORMATION), CorrespondingAction.Get)] public static uint IOCTL_DISK_GET_CACHE_INFORMATION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0035, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); + public static uint IOCTL_DISK_GET_DISK_ATTRIBUTES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x003c, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); /// - /// Retrieves information about the physical disk's geometry: type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector. - /// Note IOCTL_DISK_GET_DRIVE_GEOMETRY has been superseded by IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, which retrieves additional information. + /// + /// Retrieves information about the physical disk's geometry: type, number of cylinders, tracks per cylinder, sectors per track, + /// and bytes per sector. + /// + /// + /// NoteIOCTL_DISK_GET_DRIVE_GEOMETRY has been superseded by IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, which retrieves + /// additional information. + /// /// To perform this operation, call the DeviceIoControl function with the following parameters. /// Major Code /// IRP_MJ_DEVICE_CONTROL @@ -589,7 +918,10 @@ namespace Vanara.PInvoke public static uint IOCTL_DISK_GET_DRIVE_GEOMETRY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0000, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); /// - /// Retrieves extended information about the physical disk's geometry: type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector. + /// + /// Retrieves extended information about the physical disk's geometry: type, number of cylinders, tracks per cylinder, sectors + /// per track, and bytes per sector. + /// /// Major Code /// IRP_MJ_DEVICE_CONTROL /// Input Buffer @@ -603,13 +935,73 @@ namespace Vanara.PInvoke /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. /// For more information, see NTSTATUS Values. /// - /// When specifying a GUID partition table (GPT) as the PARTITION_STYLE of the CREATE_DISK structure, an application should wait for the MSR partition arrival before sending the IOCTL_DISK_SET_DRIVE_LAYOUT_EX control code. For more information about device notification, see RegisterDeviceNotification. + /// + /// When specifying a GUID partition table (GPT) as the PARTITION_STYLE of the CREATE_DISK structure, an application should wait + /// for the MSR partition arrival before sending the IOCTL_DISK_SET_DRIVE_LAYOUT_EX control code. For more information about + /// device notification, see RegisterDeviceNotification. + /// // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_get_drive_geometry_ex [PInvokeData("winioctl.h", MSDNShortId = "8a0667c8-b182-4851-af8e-411d95da0e3b")] [CorrespondingType(typeof(DISK_GEOMETRY_EX), CorrespondingAction.Get)] public static uint IOCTL_DISK_GET_DRIVE_GEOMETRY_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0028, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + + /// + /// Retrieves information for each entry in the partition tables for a disk. + /// + /// NoteIOCTL_DISK_GET_DRIVE_LAYOUT has been superseded by IOCTL_DISK_GET_DRIVE_LAYOUT_EX, which retrieves layout + /// information for AT and EFI (Extensible Firmware Interface) partitions. + /// + /// + /// To perform this operation, call the DeviceIoControl function with the following parameters. You must have read access to the + /// drive in order to use this control code. + /// + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// This operation retrieves information for each primary partition as well as each logical drive. To determine whether the entry + /// is an extended or unused partition, check the disk partition type. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_get_drive_layout + [PInvokeData("winioctl.h", MSDNShortId = "6c1bc445-3cd1-4f86-a36b-f74ad8f4d2e5")] + [CorrespondingType(typeof(DRIVE_LAYOUT_INFORMATION), CorrespondingAction.Get)] public static uint IOCTL_DISK_GET_DRIVE_LAYOUT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0003, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); + + /// + /// Retrieves extended information for each entry in the partition tables for a disk. + /// To perform this operation, call the DeviceIoControl function with the following parameters. + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// This operation retrieves information for each primary partition as well as each logical drive. To determine whether the entry + /// is an extended or unused partition, check the disk partition type. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_get_drive_layout_ex + [PInvokeData("winioctl.h", MSDNShortId = "21507182-5a33-4e58-b5ed-3724feefa4ed")] + [CorrespondingType(typeof(DRIVE_LAYOUT_INFORMATION_EX), CorrespondingAction.Get)] public static uint IOCTL_DISK_GET_DRIVE_LAYOUT_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0014, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint IOCTL_DISK_GET_LENGTH_INFO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0017, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); public static uint IOCTL_DISK_GET_MEDIA_TYPES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0300, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -630,7 +1022,11 @@ namespace Vanara.PInvoke /// For more information, see NTSTATUS Values. /// /// - /// The IOCTL_DISK_GET_PARTITION_INFO_EX control code is supported on basic disks. It is only supported on dynamic disks that are boot or system disks, or have retained entries in the partition table. The DiskPart.exe command RETAIN can be used to do this for other dynamic simple partitions. + /// + /// The IOCTL_DISK_GET_PARTITION_INFO_EX control code is supported on basic disks. It is only supported on dynamic disks + /// that are boot or system disks, or have retained entries in the partition table. The DiskPart.exe command RETAIN can be + /// used to do this for other dynamic simple partitions. + /// /// The disk support can be summarized as follows. /// /// @@ -670,11 +1066,14 @@ namespace Vanara.PInvoke /// /// /// Currently, GPT is supported only on 64-bit systems. - /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// + /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more + /// information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// /// // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_get_partition_info_ex [PInvokeData("winioctl.h", MSDNShortId = "f84f8be6-2b01-4a20-8669-cb1a55c32907")] - //[CorrespondingType(typeof(PARTITION_INFO), CorrespondingAction.Get)] + [CorrespondingType(typeof(PARTITION_INFORMATION), CorrespondingAction.Get)] public static uint IOCTL_DISK_GET_PARTITION_INFO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0001, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); /// @@ -694,7 +1093,11 @@ namespace Vanara.PInvoke /// For more information, see NTSTATUS Values. /// /// - /// The IOCTL_DISK_GET_PARTITION_INFO_EX control code is supported on basic disks. It is only supported on dynamic disks that are boot or system disks, or have retained entries in the partition table. The DiskPart.exe command RETAIN can be used to do this for other dynamic simple partitions. + /// + /// The IOCTL_DISK_GET_PARTITION_INFO_EX control code is supported on basic disks. It is only supported on dynamic disks + /// that are boot or system disks, or have retained entries in the partition table. The DiskPart.exe command RETAIN can be + /// used to do this for other dynamic simple partitions. + /// /// The disk support can be summarized as follows. /// /// @@ -734,12 +1137,16 @@ namespace Vanara.PInvoke /// /// /// Currently, GPT is supported only on 64-bit systems. - /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// + /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more + /// information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// /// // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_get_partition_info_ex [PInvokeData("winioctl.h", MSDNShortId = "f84f8be6-2b01-4a20-8669-cb1a55c32907")] - //[CorrespondingType(typeof(PARTITION_INFO_EX), CorrespondingAction.Get)] + [CorrespondingType(typeof(PARTITION_INFORMATION_EX), CorrespondingAction.Get)] public static uint IOCTL_DISK_GET_PARTITION_INFO_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0012, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint IOCTL_DISK_GET_WRITE_CACHE_STATE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0037, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); /// @@ -760,13 +1167,17 @@ namespace Vanara.PInvoke /// /// /// You can extend or shrink a live partition, and the partition can be open for sharing during the extend or shrink operation. - /// You do not need to lock a partition that you are extending, nor do you need to shut down other applications or services during the extend operation. + /// + /// You do not need to lock a partition that you are extending, nor do you need to shut down other applications or services + /// during the extend operation. + /// /// For more information, see DISK_GROW_PARTITION. /// // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_grow_partition [PInvokeData("winioctl.h", MSDNShortId = "bbcb0bee-a507-4abb-83df-328f3aa6caaa")] [CorrespondingType(typeof(DISK_GROW_PARTITION), CorrespondingAction.Get)] public static uint IOCTL_DISK_GROW_PARTITION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0034, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + public static uint IOCTL_DISK_HISTOGRAM_DATA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x000d, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_DISK_HISTOGRAM_RESET => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x000e, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_DISK_HISTOGRAM_STRUCTURE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x000c, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -791,11 +1202,14 @@ namespace Vanara.PInvoke /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. /// For more information, see NTSTATUS Values. /// - /// To disable the performance counters enabled by this control code, use the IOCTL_DISK_PERFORMANCE_OFF control code. + /// + /// To disable the performance counters enabled by this control code, use the IOCTL_DISK_PERFORMANCE_OFF control code. + /// // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_performance [PInvokeData("winioctl.h", MSDNShortId = "e182282c-17e9-442a-8742-437052cfed03")] [CorrespondingType(typeof(DISK_PERFORMANCE), CorrespondingAction.Get)] public static uint IOCTL_DISK_PERFORMANCE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0008, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); + public static uint IOCTL_DISK_PERFORMANCE_OFF => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0018, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_DISK_REASSIGN_BLOCKS => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0007, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); public static uint IOCTL_DISK_REASSIGN_BLOCKS_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0029, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); @@ -807,10 +1221,130 @@ namespace Vanara.PInvoke public static uint IOCTL_DISK_SENSE_DEVICE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x00f8, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_DISK_SET_CACHE_INFORMATION => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0036, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); public static uint IOCTL_DISK_SET_DISK_ATTRIBUTES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x003d, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + + /// + /// Partitions a disk as specified by drive layout and partition information data. + /// To perform this operation, call the DeviceIoControl function with the parameters specified below. + /// + /// IOCTL_DISK_SET_DRIVE_LAYOUT has been superseded by IOCTL_DISK_SET_DRIVE_LAYOUT_EX, which retrieves layout information + /// for AT and EFI (Extensible Firmware Interface) partitions. + /// + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals cannot exceed 2 TB per MBR + /// disk. For example, a disk of type MBR can have a single 2-TB partition, two 1-TB partitions, or any combination that does not + /// total more than 2 TB. If more space is required, a disk formatted as type GUID partition table (GPT) should be used. If + /// third-party partitioning tools are used to work around this limitation on disks of type MBR larger than 2 TB, configuration + /// operations via the disk partitioning IOCTL control codes will be limited. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_set_drive_layout + [PInvokeData("winioctl.h", MSDNShortId = "8cace6a5-666a-4d35-a557-6bf0564dbe58")] + [CorrespondingType(typeof(DRIVE_LAYOUT_INFORMATION), CorrespondingAction.Get)] public static uint IOCTL_DISK_SET_DRIVE_LAYOUT => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0004, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + + /// + /// Partitions a disk according to the specified drive layout and partition information data. + /// To perform this operation, call the DeviceIoControl function with the following parameters. + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// Input Buffer Length + /// Output Buffer + /// Output Buffer Length + /// Input / Output Buffer + /// Input / Output Buffer Length + /// Status Block + /// Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful. + /// Otherwise, Status to the appropriate error condition as a NTSTATUS code. + /// For more information, see NTSTATUS Values. + /// + /// + /// + /// When specifying a GUID partition table (GPT) as the PARTITION_STYLE of the CREATE_DISK structure, an application + /// should wait for the MSR partition arrival before sending the IOCTL_DISK_SET_DRIVE_LAYOUT_EX control code. For more + /// information about device notification, see RegisterDeviceNotification. + /// + /// + /// When creating and manipulating an Extended Boot Record (EBR), the first entry of the EBR should point to the logical drive + /// that immediately follows the EBR and the next EBR should lie after the end of the current logical drive and before the start + /// of the next logical drive. + /// + /// + /// If the partition is on a disk formatted as type master boot record (MBR), partition size totals are limited. For more + /// information, see the Remarks section of IOCTL_DISK_SET_DRIVE_LAYOUT. + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-ioctl_disk_set_drive_layout_ex + [PInvokeData("winioctl.h", MSDNShortId = "a600e841-c692-4aa4-bea2-a33931d9b007")] + [CorrespondingType(typeof(DRIVE_LAYOUT_INFORMATION_EX), CorrespondingAction.Get)] public static uint IOCTL_DISK_SET_DRIVE_LAYOUT_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0015, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + + /// + /// Changes the partition type of the specified disk partition. (Floppy drivers need not handle this request.) + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// The buffer at Irp->AssociatedIrp.SystemBuffer contains the SET_PARTITION_INFORMATION to be set. + /// Input Buffer Length + /// + /// Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size, in bytes, of the + /// buffer, which must be >= sizeof(SET_PARTITION_INFORMATION). + /// + /// Output Buffer + /// None. + /// Output Buffer Length + /// None. + /// Status Block + /// + /// The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to + /// STATUS_INVALID_PARAMETER, STATUS_INVALID_DEVICE_REQUEST, STATUS_UNSUCCESSFUL, STATUS_INFO_LENGTH_MISMATCH, + /// STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL. + /// + /// + // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntdddisk/ni-ntdddisk-ioctl_disk_set_partition_info + [PInvokeData("ntdddisk.h", MSDNShortId = "3ff5a328-04b0-4de9-abe1-759c36f31899")] + [CorrespondingType(typeof(PARTITION_INFORMATION), CorrespondingAction.Set)] public static uint IOCTL_DISK_SET_PARTITION_INFO => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0002, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + + /// + /// Changes the partition type of the specified disk partition. (Floppy drivers need not handle this request.) + /// Major Code + /// IRP_MJ_DEVICE_CONTROL + /// Input Buffer + /// The buffer at Irp->AssociatedIrp.SystemBuffer contains the SET_PARTITION_INFORMATION_EX to be set. + /// Input Buffer Length + /// + /// Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size, in bytes, of the + /// buffer, which must be >= sizeof(SET_PARTITION_INFORMATION_EX). + /// + /// Output Buffer + /// None. + /// Output Buffer Length + /// None. + /// Status Block + /// + /// The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to + /// STATUS_INVALID_PARAMETER, STATUS_INVALID_DEVICE_REQUEST, STATUS_UNSUCCESSFUL, STATUS_INFO_LENGTH_MISMATCH, + /// STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL. + /// + /// + // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntdddisk/ni-ntdddisk-ioctl_disk_set_partition_info_ex + [PInvokeData("ntdddisk.h", MSDNShortId = "80558175-4d34-4011-a5b3-b6475b5e0d15")] + [CorrespondingType(typeof(PARTITION_INFORMATION_EX), CorrespondingAction.Set)] public static uint IOCTL_DISK_SET_PARTITION_INFO_EX => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0013, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); + public static uint IOCTL_DISK_UPDATE_DRIVE_SIZE => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0032, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); public static uint IOCTL_DISK_UPDATE_PROPERTIES => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0050, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_DISK_VERIFY => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0005, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -839,8 +1373,8 @@ namespace Vanara.PInvoke public static uint IOCTL_STORAGE_DEVICE_TELEMETRY_NOTIFY => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0471, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_WRITE_ACCESS); public static uint IOCTL_STORAGE_DEVICE_TELEMETRY_QUERY_CAPS => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0472, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_WRITE_ACCESS); public static uint IOCTL_STORAGE_DIAGNOSTIC => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0728, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); - public static uint IOCTL_STORAGE_EJECTION_CONTROL => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0250, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_STORAGE_EJECT_MEDIA => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0202, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS); + public static uint IOCTL_STORAGE_EJECTION_CONTROL => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0250, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_STORAGE_ENABLE_IDLE_POWER => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0720, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_STORAGE_EVENT_NOTIFICATION => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0724, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); public static uint IOCTL_STORAGE_FAILURE_PREDICTION_CONFIG => CTL_CODE(DEVICE_TYPE.IOCTL_STORAGE_BASE, 0x0441, IOMethod.METHOD_BUFFERED, IOAccess.FILE_ANY_ACCESS); @@ -894,9 +1428,11 @@ namespace Vanara.PInvoke public static uint SMART_RCV_DRIVE_DATA => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0022, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); public static uint SMART_SEND_DRIVE_COMMAND => CTL_CODE(DEVICE_TYPE.FILE_DEVICE_DISK, 0x0021, IOMethod.METHOD_BUFFERED, IOAccess.FILE_READ_ACCESS | IOAccess.FILE_WRITE_ACCESS); - private static ushort SCMBUS_FUNCTION(ushort x) => (ushort)(IOCTL_SCMBUS_DEVICE_FUNCTION_BASE + x); private static ushort SCM_LOGICAL_DEVICE_FUNCTION(ushort x) => (ushort)(IOCTL_SCM_LOGICAL_DEVICE_FUNCTION_BASE + x); + private static ushort SCM_PHYSICAL_DEVICE_FUNCTION(ushort x) => (ushort)(IOCTL_SCM_PHYSICAL_DEVICE_FUNCTION_BASE + x); + + private static ushort SCMBUS_FUNCTION(ushort x) => (ushort)(IOCTL_SCMBUS_DEVICE_FUNCTION_BASE + x); } } } \ No newline at end of file