mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added ATA IOCTLs.
This commit is contained in:
@@ -223,6 +223,8 @@ namespace DiscImageChef.Devices.Windows
|
||||
|
||||
enum WindowsIoctl : uint
|
||||
{
|
||||
IOCTL_ATA_PASS_THROUGH = 0x4D02C,
|
||||
IOCTL_ATA_PASS_THROUGH_DIRECT = 0x4D030,
|
||||
/// <summary>
|
||||
/// ScsiPassThrough
|
||||
/// </summary>
|
||||
@@ -236,5 +238,33 @@ namespace DiscImageChef.Devices.Windows
|
||||
/// </summary>
|
||||
IOCTL_SCSI_GET_ADDRESS = 0x41018
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum AtaFlags : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// ATA_FLAGS_DRDY_REQUIRED
|
||||
/// </summary>
|
||||
DrdyRequired = 0x01,
|
||||
/// <summary>
|
||||
/// ATA_FLAGS_DATA_IN
|
||||
/// </summary>
|
||||
DataIn = 0x02,
|
||||
/// <summary>
|
||||
/// ATA_FLAGS_DATA_OUT
|
||||
/// </summary>
|
||||
DataOut = 0x04,
|
||||
/// <summary>
|
||||
/// ATA_FLAGS_48BIT_COMMAND
|
||||
/// </summary>
|
||||
ExtendedCommand = 0x08,
|
||||
/// <summary>
|
||||
/// ATA_FLAGS_USE_DMA
|
||||
/// </summary>
|
||||
DMA = 0x10,
|
||||
/// <summary>
|
||||
/// ATA_FLAGS_NO_MULTIPLE
|
||||
/// </summary>
|
||||
NoMultiple = 0x20
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace DiscImageChef.Devices.Windows
|
||||
[MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes,
|
||||
IntPtr templateFile);
|
||||
|
||||
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool DeviceIoControl(
|
||||
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint="ioctl", CharSet = CharSet.Auto)]
|
||||
public static extern bool DeviceIoControlScsi(
|
||||
SafeFileHandle hDevice,
|
||||
uint IoControlCode,
|
||||
ref ScsiPassThroughDirectAndSenseBuffer InBuffer,
|
||||
@@ -28,6 +28,18 @@ namespace DiscImageChef.Devices.Windows
|
||||
IntPtr Overlapped
|
||||
);
|
||||
|
||||
[DllImport("Kernel32.dll", SetLastError = true, EntryPoint="ioctl", CharSet = CharSet.Auto)]
|
||||
public static extern bool DeviceIoControlAta(
|
||||
SafeFileHandle hDevice,
|
||||
uint IoControlCode,
|
||||
ref AtaPassThroughDirect InBuffer,
|
||||
uint nInBufferSize,
|
||||
ref AtaPassThroughDirect OutBuffer,
|
||||
uint nOutBufferSize,
|
||||
ref uint pBytesReturned,
|
||||
IntPtr Overlapped
|
||||
);
|
||||
|
||||
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool CloseHandle(SafeFileHandle hDevice);
|
||||
}
|
||||
|
||||
@@ -20,14 +20,51 @@ namespace DiscImageChef.Devices.Windows
|
||||
public IntPtr DataBuffer;
|
||||
public uint SenseInfoOffset;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] Cdb;
|
||||
public byte[] Cdb;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct ScsiPassThroughDirectAndSenseBuffer {
|
||||
struct ScsiPassThroughDirectAndSenseBuffer
|
||||
{
|
||||
public ScsiPassThroughDirect sptd;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public byte[] SenseBuf;
|
||||
}
|
||||
|
||||
struct AtaPassThroughDirect
|
||||
{
|
||||
public ushort Length;
|
||||
public AtaFlags AtaFlags;
|
||||
public byte PathId;
|
||||
public byte TargetId;
|
||||
public byte Lun;
|
||||
public byte ReservedAsUchar;
|
||||
public uint DataTransferLength;
|
||||
public uint TimeOutValue;
|
||||
public uint ReservedAsUlong;
|
||||
public IntPtr DataBuffer;
|
||||
public AtaTaskFile PreviousTaskFile;
|
||||
public AtaTaskFile CurrentTaskFile;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
struct AtaTaskFile
|
||||
{
|
||||
// Fields for commands sent
|
||||
[FieldOffset(0)] public byte Features;
|
||||
[FieldOffset(6)] public byte Command;
|
||||
|
||||
// Fields on command return
|
||||
[FieldOffset(0)] public byte Error;
|
||||
[FieldOffset(6)] public byte Status;
|
||||
|
||||
// Common fields
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user