2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2015-10-12 06:39:31 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Structs.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Windows direct device access.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Contains structures necessary for directly interfacing devices under
|
|
|
|
|
// Windows.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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
|
2015-10-12 06:39:31 +01:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2015-10-12 06:39:31 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-12-22 03:13:43 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2015-10-05 21:20:25 +01:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Devices.Windows
|
|
|
|
|
{
|
2015-10-06 18:29:15 +01:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2015-10-06 18:29:15 +01:00
|
|
|
struct ScsiPassThroughDirect
|
2015-10-05 21:20:25 +01:00
|
|
|
{
|
2015-10-06 18:29:15 +01:00
|
|
|
public ushort Length;
|
|
|
|
|
public byte ScsiStatus;
|
|
|
|
|
public byte PathId;
|
|
|
|
|
public byte TargetId;
|
|
|
|
|
public byte Lun;
|
|
|
|
|
public byte CdbLength;
|
|
|
|
|
public byte SenseInfoLength;
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.U1)] public ScsiIoctlDirection DataIn;
|
2015-10-06 18:29:15 +01:00
|
|
|
public uint DataTransferLength;
|
|
|
|
|
public uint TimeOutValue;
|
|
|
|
|
public IntPtr DataBuffer;
|
|
|
|
|
public uint SenseInfoOffset;
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Cdb;
|
2017-12-21 02:53:52 +00:00
|
|
|
}
|
2015-10-05 21:20:25 +01:00
|
|
|
|
2015-10-06 18:29:15 +01:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2015-10-07 02:15:31 +01:00
|
|
|
struct ScsiPassThroughDirectAndSenseBuffer
|
|
|
|
|
{
|
2015-10-06 18:29:15 +01:00
|
|
|
public ScsiPassThroughDirect sptd;
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] SenseBuf;
|
2015-10-05 21:20:25 +01:00
|
|
|
}
|
2015-10-07 02:15:31 +01:00
|
|
|
|
2017-08-22 03:40:43 +01:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2015-10-07 02:15:31 +01:00
|
|
|
struct AtaPassThroughDirect
|
|
|
|
|
{
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Length in bytes of this structure
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public ushort Length;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Indicates transfer direction and kind of operation
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.U2)] public AtaFlags AtaFlags;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Indicates IDE port or bus, set by driver
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public byte PathId;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Indicates target device on bus, set by driver
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public byte TargetId;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Indicates logical unit number of device, set by driver
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public byte Lun;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reserved
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public byte ReservedAsUchar;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Data transfer length in bytes
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public uint DataTransferLength;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Timeout value in seconds
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public uint TimeOutValue;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Reserved
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public uint ReservedAsUlong;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Pointer to data buffer relative to start of this structure
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public IntPtr DataBuffer;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Previous ATA registers, for LBA48
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public AtaTaskFile PreviousTaskFile;
|
2017-08-21 04:28:16 +01:00
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// ATA registers
|
2017-08-21 04:28:16 +01:00
|
|
|
/// </summary>
|
2015-10-07 02:15:31 +01:00
|
|
|
public AtaTaskFile CurrentTaskFile;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-07 16:48:25 +01:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-09-07 16:48:25 +01:00
|
|
|
struct AtaPassThroughDirectWithBuffer
|
|
|
|
|
{
|
|
|
|
|
public AtaPassThroughDirect aptd;
|
|
|
|
|
public uint filler;
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64 * 512)] public byte[] dataBuffer;
|
2017-09-07 16:48:25 +01:00
|
|
|
}
|
|
|
|
|
|
2015-10-07 02:15:31 +01:00
|
|
|
[StructLayout(LayoutKind.Explicit)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2015-10-07 02:15:31 +01:00
|
|
|
struct AtaTaskFile
|
|
|
|
|
{
|
|
|
|
|
// Fields for commands sent
|
2017-12-19 20:33:03 +00:00
|
|
|
[FieldOffset(0)] public byte Features;
|
|
|
|
|
[FieldOffset(6)] public byte Command;
|
2015-10-07 02:15:31 +01:00
|
|
|
|
|
|
|
|
// Fields on command return
|
2017-12-19 20:33:03 +00:00
|
|
|
[FieldOffset(0)] public byte Error;
|
|
|
|
|
[FieldOffset(6)] public byte Status;
|
2015-10-07 02:15:31 +01:00
|
|
|
|
|
|
|
|
// Common fields
|
2017-12-19 20:33:03 +00:00
|
|
|
[FieldOffset(1)] public byte SectorCount;
|
|
|
|
|
[FieldOffset(2)] public byte SectorNumber;
|
|
|
|
|
[FieldOffset(3)] public byte CylinderLow;
|
|
|
|
|
[FieldOffset(4)] public byte CylinderHigh;
|
|
|
|
|
[FieldOffset(5)] public byte DeviceHead;
|
|
|
|
|
[FieldOffset(7)] public byte Reserved;
|
2015-10-07 02:15:31 +01:00
|
|
|
}
|
2017-08-22 03:40:43 +01:00
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
struct StoragePropertyQuery
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.U4)] public StoragePropertyId PropertyId;
|
|
|
|
|
[MarshalAs(UnmanagedType.U4)] public StorageQueryType QueryType;
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] AdditionalParameters;
|
2017-08-22 03:40:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-08-22 03:40:43 +01:00
|
|
|
struct StorageDescriptorHeader
|
|
|
|
|
{
|
|
|
|
|
public uint Version;
|
|
|
|
|
public uint Size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
struct StorageDeviceDescriptor
|
|
|
|
|
{
|
|
|
|
|
public uint Version;
|
|
|
|
|
public uint Size;
|
|
|
|
|
public byte DeviceType;
|
|
|
|
|
public byte DeviceTypeModifier;
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.U1)] public bool RemovableMedia;
|
|
|
|
|
[MarshalAs(UnmanagedType.U1)] public bool CommandQueueing;
|
2017-12-20 18:41:50 +01:00
|
|
|
public int VendorIdOffset;
|
|
|
|
|
public int ProductIdOffset;
|
|
|
|
|
public int ProductRevisionOffset;
|
|
|
|
|
public int SerialNumberOffset;
|
2017-08-22 03:40:43 +01:00
|
|
|
public StorageBusType BusType;
|
|
|
|
|
public uint RawPropertiesLength;
|
|
|
|
|
public byte[] RawDeviceProperties;
|
|
|
|
|
}
|
2017-09-10 23:20:59 +01:00
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
struct IdePassThroughDirect
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// ATA registers
|
2017-09-10 23:20:59 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public AtaTaskFile CurrentTaskFile;
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Size of data buffer
|
2017-09-10 23:20:59 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public uint DataBufferSize;
|
|
|
|
|
/// <summary>
|
2017-12-23 20:04:36 +00:00
|
|
|
/// Data buffer
|
2017-09-10 23:20:59 +01:00
|
|
|
/// </summary>
|
2017-12-19 20:33:03 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] DataBuffer;
|
2017-09-10 23:20:59 +01:00
|
|
|
}
|
2017-12-06 13:46:35 +00:00
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-06 13:46:35 +00:00
|
|
|
struct StorageDeviceNumber
|
|
|
|
|
{
|
|
|
|
|
public int deviceType;
|
|
|
|
|
public int deviceNumber;
|
|
|
|
|
public int partitionNumber;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 13:46:35 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-06 13:46:35 +00:00
|
|
|
struct DeviceInfoData
|
|
|
|
|
{
|
|
|
|
|
public int cbSize;
|
|
|
|
|
public Guid classGuid;
|
|
|
|
|
public uint devInst;
|
|
|
|
|
public IntPtr reserved;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 13:46:35 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-06 13:46:35 +00:00
|
|
|
struct DeviceInterfaceData
|
|
|
|
|
{
|
|
|
|
|
public int cbSize;
|
|
|
|
|
public Guid interfaceClassGuid;
|
|
|
|
|
public uint flags;
|
2017-12-20 17:46:47 +00:00
|
|
|
IntPtr reserved;
|
2017-12-06 13:46:35 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 19:30:03 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-20 17:15:26 +00:00
|
|
|
struct UsbSetupPacket
|
2017-12-06 19:30:03 +00:00
|
|
|
{
|
|
|
|
|
public byte bmRequest;
|
|
|
|
|
public byte bRequest;
|
|
|
|
|
public short wValue;
|
|
|
|
|
public short wIndex;
|
|
|
|
|
public short wLength;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 19:30:03 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-20 17:15:26 +00:00
|
|
|
struct UsbDescriptorRequest
|
2017-12-06 19:30:03 +00:00
|
|
|
{
|
|
|
|
|
public int ConnectionIndex;
|
2017-12-20 17:15:26 +00:00
|
|
|
public UsbSetupPacket SetupPacket;
|
2017-12-06 19:30:03 +00:00
|
|
|
//public byte[] Data;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 23:05:59 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-06 23:05:59 +00:00
|
|
|
struct SffdiskQueryDeviceProtocolData
|
|
|
|
|
{
|
|
|
|
|
public ushort size;
|
|
|
|
|
public ushort reserved;
|
|
|
|
|
public Guid protocolGuid;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 23:05:59 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2017-12-22 03:13:43 +00:00
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2017-12-06 23:05:59 +00:00
|
|
|
struct SffdiskDeviceCommandData
|
|
|
|
|
{
|
|
|
|
|
public ushort size;
|
|
|
|
|
public ushort reserved;
|
|
|
|
|
public SffdiskDcmd command;
|
|
|
|
|
public ushort protocolArgumentSize;
|
|
|
|
|
public uint deviceDataBufferSize;
|
|
|
|
|
public uint information;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-06 23:05:59 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
struct SdCmdDescriptor
|
|
|
|
|
{
|
|
|
|
|
public byte commandCode;
|
|
|
|
|
public SdCommandClass cmdClass;
|
|
|
|
|
public SdTransferDirection transferDirection;
|
|
|
|
|
public SdTransferType transferType;
|
|
|
|
|
public SdResponseType responseType;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|