mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added IOCTL skeletons.
This commit is contained in:
24
DiscImageChef.Devices/Windows/Enums.cs
Normal file
24
DiscImageChef.Devices/Windows/Enums.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace DiscImageChef.Devices.Windows
|
||||
{
|
||||
static class Enums
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
39
DiscImageChef.Devices/Windows/Extern.cs
Normal file
39
DiscImageChef.Devices/Windows/Extern.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
namespace DiscImageChef.Devices.Windows
|
||||
{
|
||||
static class Extern
|
||||
{
|
||||
[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,
|
||||
IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero
|
||||
//[MarshalAs(UnmanagedType.U4)] FileMode creationDisposition,
|
||||
uint creationDisposition,
|
||||
//[MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes,
|
||||
uint flagsAndAttributes,
|
||||
IntPtr templateFile);
|
||||
|
||||
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool DeviceIoControl(
|
||||
SafeFileHandle hDevice,
|
||||
uint IoControlCode,
|
||||
ref Structs.SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER InBuffer,
|
||||
uint nInBufferSize,
|
||||
ref Structs.SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER OutBuffer,
|
||||
uint nOutBufferSize,
|
||||
ref uint pBytesReturned,
|
||||
IntPtr Overlapped
|
||||
);
|
||||
|
||||
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool CloseHandle(SafeFileHandle hDevice);
|
||||
}
|
||||
}
|
||||
|
||||
35
DiscImageChef.Devices/Windows/Structs.cs
Normal file
35
DiscImageChef.Devices/Windows/Structs.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscImageChef.Devices.Windows
|
||||
{
|
||||
static class Structs
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SCSI_PASS_THROUGH_DIRECT
|
||||
{
|
||||
public ushort Length;
|
||||
public byte ScsiStatus;
|
||||
public byte PathId;
|
||||
public byte TargetId;
|
||||
public byte Lun;
|
||||
public byte CdbLength;
|
||||
public byte SenseInfoLength;
|
||||
public byte DataIn;
|
||||
public uint DataTransferLength;
|
||||
public uint TimeOutValue;
|
||||
public IntPtr DataBuffer;
|
||||
public uint SenseInfoOffset;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] Cdb;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER {
|
||||
public SCSI_PASS_THROUGH_DIRECT sptd;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public byte[] SenseBuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user