// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Enums.cs // Author(s) : Natalia Portillo // // Component : Windows direct device access. // // --[ Description ] ---------------------------------------------------------- // // Contains enumerations necessary for directly interfacing devices under // Windows. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ // ReSharper disable UnusedMember.Global namespace Aaru.Devices.Windows; using System; using System.Diagnostics.CodeAnalysis; [Flags] enum FileAttributes : uint { /// FILE_ATTRIBUTE_ARCHIVE Archive = 0x20, /// FILE_ATTRIBUTE_COMPRESSED Compressed = 0x800, /// FILE_ATTRIBUTE_DEVICE Device = 0x40, /// FILE_ATTRIBUTE_DIRECTORY Directory = 0x10, /// FILE_ATTRIBUTE_ENCRYPTED Encrypted = 0x4000, /// FILE_ATTRIBUTE_HIDDEN Hidden = 0x02, /// FILE_ATTRIBUTE_INTEGRITY_STREAM IntegrityStream = 0x8000, /// FILE_ATTRIBUTE_NORMAL Normal = 0x80, /// FILE_ATTRIBUTE_NOT_CONTENT_INDEXED NotContentIndexed = 0x2000, /// FILE_ATTRIBUTE_NO_SCRUB_DATA NoScrubData = 0x20000, /// FILE_ATTRIBUTE_OFFLINE Offline = 0x1000, /// FILE_ATTRIBUTE_READONLY Readonly = 0x01, /// FILE_ATTRIBUTE_REPARSE_POINT ReparsePoint = 0x400, /// FILE_ATTRIBUTE_SPARSE_FILE SparseFile = 0x200, /// FILE_ATTRIBUTE_SYSTEM System = 0x04, /// FILE_ATTRIBUTE_TEMPORARY Temporary = 0x100, /// FILE_ATTRIBUTE_VIRTUAL Virtual = 0x10000, /// FILE_FLAG_BACKUP_SEMANTICS BackupSemantics = 0x02000000, /// FILE_FLAG_DELETE_ON_CLOSE DeleteOnClose = 0x04000000, /// FILE_FLAG_NO_BUFFERING NoBuffering = 0x20000000, /// FILE_FLAG_OPEN_NO_RECALL OpenNoRecall = 0x00100000, /// FILE_FLAG_OPEN_REPARSE_POINT OpenReparsePoint = 0x00200000, /// FILE_FLAG_OVERLAPPED Overlapped = 0x40000000, /// FILE_FLAG_POSIX_SEMANTICS PosixSemantics = 0x0100000, /// FILE_FLAG_RANDOM_ACCESS RandomAccess = 0x10000000, /// FILE_FLAG_SESSION_AWARE SessionAware = 0x00800000, /// FILE_FLAG_SEQUENTIAL_SCAN SequentialScan = 0x08000000, /// FILE_FLAG_WRITE_THROUGH WriteThrough = 0x80000000 } [Flags] enum FileAccess : uint { /// FILE_READ_DATA ReadData = 0x0001, /// FILE_LIST_DIRECTORY ListDirectory = ReadData, /// FILE_WRITE_DATA WriteData = 0x0002, /// FILE_ADD_FILE AddFile = WriteData, /// FILE_APPEND_DATA AppendData = 0x0004, /// FILE_ADD_SUBDIRECTORY AddSubdirectory = AppendData, /// FILE_CREATE_PIPE_INSTANCE CreatePipeInstance = AppendData, /// FILE_READ_EA ReadEa = 0x0008, /// FILE_WRITE_EA WriteEa = 0x0010, /// FILE_EXECUTE Execute = 0x0020, /// FILE_TRAVERSE Traverse = Execute, /// FILE_DELETE_CHILD DeleteChild = 0x0040, /// FILE_READ_ATTRIBUTES ReadAttributes = 0x0080, /// FILE_WRITE_ATTRIBUTES WriteAttributes = 0x0100, /// GENERIC_READ GenericRead = 0x80000000, /// GENERIC_WRITE GenericWrite = 0x40000000, /// GENERIC_EXECUTE GenericExecute = 0x20000000, /// GENERIC_ALL GenericAll = 0x10000000 } [Flags] enum FileShare : uint { /// FILE_SHARE_NONE None = 0x00, /// FILE_SHARE_READ Read = 0x01, /// FILE_SHARE_WRITE Write = 0x02, /// FILE_SHARE_DELETE Delete = 0x03 } [Flags] enum FileMode : uint { /// NEW New = 0x01, /// CREATE_ALWAYS CreateAlways = 0x02, /// OPEN_EXISTING OpenExisting = 0x03, /// OPEN_ALWAYS OpenAlways = 0x04, /// TRUNCATE_EXISTING TruncateExisting = 0x05 } /// Direction of SCSI transfer enum ScsiIoctlDirection : byte { /// From host to device SCSI_IOCTL_DATA_OUT Out = 0, /// From device to host SCSI_IOCTL_DATA_IN In = 1, /// Unspecified direction, or bidirectional, or no data SCSI_IOCTL_DATA_UNSPECIFIED Unspecified = 2 } enum WindowsIoctl : uint { IoctlAtaPassThrough = 0x4D02C, IoctlAtaPassThroughDirect = 0x4D030, /// ScsiPassThrough IoctlScsiPassThrough = 0x4D004, /// ScsiPassThroughDirect IoctlScsiPassThroughDirect = 0x4D014, /// ScsiGetAddress IoctlScsiGetAddress = 0x41018, IoctlStorageQueryProperty = 0x2D1400, IoctlIdePassThrough = 0x4D028, IoctlStorageGetDeviceNumber = 0x2D1080, IoctlSffdiskQueryDeviceProtocol = 0x71E80, IoctlSffdiskDeviceCommand = 0x79E84 } [Flags] enum AtaFlags : ushort { /// ATA_FLAGS_DRDY_REQUIRED DrdyRequired = 0x01, /// ATA_FLAGS_DATA_IN DataIn = 0x02, /// ATA_FLAGS_DATA_OUT DataOut = 0x04, /// ATA_FLAGS_48BIT_COMMAND ExtendedCommand = 0x08, /// ATA_FLAGS_USE_DMA Dma = 0x10, /// ATA_FLAGS_NO_MULTIPLE NoMultiple = 0x20 } enum StoragePropertyId { Device = 0, Adapter = 1, Id = 2, UniqueId = 3, WriteCache = 4, Miniport = 5, AccessAlignment = 6, SeekPenalty = 7, Trim = 8, WriteAggregation = 9, Telemetry = 10, LbProvisioning = 11, Power = 12, Copyoffload = 13, Resiliency = 14 } enum StorageQueryType { Standard = 0, Exists = 1, Mask = 2, Max = 3 } [SuppressMessage("ReSharper", "InconsistentNaming")] enum StorageBusType { Unknown = 0, SCSI = 1, ATAPI = 2, ATA = 3, FireWire = 4, SSA = 5, Fibre = 6, USB = 7, RAID = 8, iSCSI = 9, SAS = 0xA, SATA = 0xB, SecureDigital = 0xC, MultiMediaCard = 0xD, Virtual = 0xE, FileBackedVirtual = 0xF, Spaces = 16, SCM = 18, UFS = 19, Max = 20, MaxReserved = 127, NVMe = 0x11 } [Flags] enum DeviceGetClassFlags : uint { /// DIGCF_DEFAULT Default = 0x01, /// DIGCF_PRESENT Present = 0x02, /// DIGCF_ALLCLASSES AllClasses = 0x04, /// DIGCF_PROFILE Profile = 0x08, /// DIGCF_DEVICEINTERFACE DeviceInterface = 0x10 } enum SdCommandClass : uint { Standard, AppCmd } enum SdTransferDirection : uint { Unspecified, Read, Write } enum SdTransferType : uint { Unspecified, CmdOnly, SingleBlock, MultiBlock, MultiBlockNoCmd12 } [SuppressMessage("ReSharper", "InconsistentNaming")] enum SdResponseType : uint { Unspecified, None, R1, R1b, R2, R3, R4, R5, R5b, R6 } enum SffdiskDcmd : uint { GetVersion, LockChannel, UnlockChannel, DeviceCommand } static class Consts { public static Guid GuidSffProtocolSd = new("AD7536A8-D055-4C40-AA4D-96312DDB6B38"); public static Guid GuidSffProtocolMmc = new("77274D3F-2365-4491-A030-8BB44AE60097"); public static Guid GuidDevinterfaceDisk = new(0x53F56307, 0xB6BF, 0x11D0, 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B); } enum MoveMethod : uint { Begin = 0, Current = 1, End = 2 }