diff --git a/DiscImageChef.Devices/ChangeLog b/DiscImageChef.Devices/ChangeLog index 68add6c6..1de05a37 100644 --- a/DiscImageChef.Devices/ChangeLog +++ b/DiscImageChef.Devices/ChangeLog @@ -1,3 +1,10 @@ +2015-10-06 Natalia Portillo + + * Windows/Enums.cs: + * Windows/Extern.cs: + * Windows/Structs.cs: + Completed Windows enumerations. + 2015-10-06 Natalia Portillo * Enums.cs: diff --git a/DiscImageChef.Devices/Windows/Enums.cs b/DiscImageChef.Devices/Windows/Enums.cs index 5f9ebc16..5a33ef0c 100644 --- a/DiscImageChef.Devices/Windows/Enums.cs +++ b/DiscImageChef.Devices/Windows/Enums.cs @@ -1,24 +1,243 @@ using System; +using System.Runtime.InteropServices; namespace DiscImageChef.Devices.Windows { - static class Enums + [Flags] + enum FileAttributes : uint { - internal const uint FILE_SHARE_READ = 0x1; - internal const uint FILE_SHARE_WRITE = 0x1; - - internal const uint OPEN_EXISTING = 0x3; - - internal const uint FILE_ATTRIBUTE_NORMAL = 0x80; - - internal const uint GENERIC_READ = 0x80000000; - internal const uint GENERIC_WRITE = 0x40000000; - - internal const byte SCSI_IOCTL_DATA_OUT = 0; //Give data to SCSI device (e.g. for writing) - internal const byte SCSI_IOCTL_DATA_IN = 1; //Get data from SCSI device (e.g. for reading) - internal const byte SCSI_IOCTL_DATA_UNSPECIFIED = 2; //No data (e.g. for ejecting) - - internal const uint IOCTL_SCSI_PASS_THROUGH_DIRECT = 0x4D014; + /// + /// 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 } + + [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 + { + /// + /// ScsiPassThrough + /// + IOCTL_SCSI_PASS_THROUGH = 0x4D004, + /// + /// ScsiPassThroughDirect + /// + IOCTL_SCSI_PASS_THROUGH_DIRECT = 0x4D014, + /// + /// ScsiGetAddress + /// + IOCTL_SCSI_GET_ADDRESS = 0x41018 + } + /// + /// AAAAA + /// } diff --git a/DiscImageChef.Devices/Windows/Extern.cs b/DiscImageChef.Devices/Windows/Extern.cs index f625da69..bd84956c 100644 --- a/DiscImageChef.Devices/Windows/Extern.cs +++ b/DiscImageChef.Devices/Windows/Extern.cs @@ -9,15 +9,12 @@ namespace DiscImageChef.Devices.Windows [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern SafeFileHandle CreateFile( [MarshalAs(UnmanagedType.LPTStr)] string filename, - // [MarshalAs(UnmanagedType.U4)] FileAccess access, - uint access, - //[MarshalAs(UnmanagedType.U4)] FileShare share, - uint share, + [MarshalAs(UnmanagedType.U4)] FileAccess access, + [MarshalAs(UnmanagedType.U4)] FileShare share, IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero //[MarshalAs(UnmanagedType.U4)] FileMode creationDisposition, uint creationDisposition, - //[MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes, - uint flagsAndAttributes, + [MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes, IntPtr templateFile); [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] diff --git a/DiscImageChef.Devices/Windows/Structs.cs b/DiscImageChef.Devices/Windows/Structs.cs index c620a184..c5f7b186 100644 --- a/DiscImageChef.Devices/Windows/Structs.cs +++ b/DiscImageChef.Devices/Windows/Structs.cs @@ -15,7 +15,8 @@ namespace DiscImageChef.Devices.Windows public byte Lun; public byte CdbLength; public byte SenseInfoLength; - public byte DataIn; + [MarshalAs(UnmanagedType.U1)] + public ScsiIoctlDirection DataIn; public uint DataTransferLength; public uint TimeOutValue; public IntPtr DataBuffer;