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:
@@ -1,3 +1,8 @@
|
||||
2015-10-05 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* DiscImageChef.sln:
|
||||
Added IOCTL skeletons.
|
||||
|
||||
2015-10-05 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* DiscImageChef.sln:
|
||||
|
||||
13
DiscImageChef.Devices/ChangeLog
Normal file
13
DiscImageChef.Devices/ChangeLog
Normal file
@@ -0,0 +1,13 @@
|
||||
2015-10-05 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Enums.cs:
|
||||
* Linux/Enums.cs:
|
||||
* Linux/Extern.cs:
|
||||
* Linux/Structs.cs:
|
||||
* Windows/Enums.cs:
|
||||
* Windows/Extern.cs:
|
||||
* Windows/Structs.cs:
|
||||
* Properties/AssemblyInfo.cs:
|
||||
* DiscImageChef.Devices.csproj:
|
||||
Added IOCTL skeletons.
|
||||
|
||||
60
DiscImageChef.Devices/DiscImageChef.Devices.csproj
Normal file
60
DiscImageChef.Devices/DiscImageChef.Devices.csproj
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>DiscImageChef.Devices</RootNamespace>
|
||||
<AssemblyName>DiscImageChef.Devices</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<ReleaseVersion>2.2</ReleaseVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Linux\Extern.cs" />
|
||||
<Compile Include="Linux\Structs.cs" />
|
||||
<Compile Include="Linux\Enums.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="Windows\Extern.cs" />
|
||||
<Compile Include="Windows\Structs.cs" />
|
||||
<Compile Include="Windows\Enums.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="Linux\" />
|
||||
<Folder Include="Windows\" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
13
DiscImageChef.Devices/Enums.cs
Normal file
13
DiscImageChef.Devices/Enums.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace DiscImageChef.Devices
|
||||
{
|
||||
public class Enums
|
||||
{
|
||||
public enum ScsiCommands : byte
|
||||
{
|
||||
Inquiry = 0x12
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
DiscImageChef.Devices/Linux/Enums.cs
Normal file
20
DiscImageChef.Devices/Linux/Enums.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace DiscImageChef.Devices.Linux
|
||||
{
|
||||
static class Enums
|
||||
{
|
||||
internal const int O_RDONLY = 0;
|
||||
internal const int O_RDWR = 2;
|
||||
|
||||
internal const ulong SG_GET_VERSION_NUM = 0x2282;
|
||||
internal const ulong SG_IO = 0x2285;
|
||||
|
||||
internal const int SG_DXFER_FROM_DEV = -3;
|
||||
|
||||
internal const uint SG_INFO_OK_MASK = 0x1;
|
||||
internal const uint SG_INFO_OK = 0x0; /* no sense, host nor driver "noise" */
|
||||
internal const uint SG_INFO_CHECK = 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
20
DiscImageChef.Devices/Linux/Extern.cs
Normal file
20
DiscImageChef.Devices/Linux/Extern.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscImageChef.Devices.Linux
|
||||
{
|
||||
static class Extern
|
||||
{
|
||||
[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
internal static extern int open(string pathname, int flags);
|
||||
|
||||
[DllImport("libc")]
|
||||
internal static extern int close(int fd);
|
||||
|
||||
[DllImport("libc", EntryPoint="ioctl", SetLastError = true)]
|
||||
internal static extern int ioctlInt(int fd, ulong request, out int value);
|
||||
|
||||
[DllImport("libc", EntryPoint="ioctl", SetLastError = true)]
|
||||
internal static extern int ioctlSg(int fd, ulong request, ref Structs.sg_io_hdr_t value);
|
||||
}
|
||||
}
|
||||
|
||||
39
DiscImageChef.Devices/Linux/Structs.cs
Normal file
39
DiscImageChef.Devices/Linux/Structs.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscImageChef.Devices.Linux
|
||||
{
|
||||
static class Structs
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct sg_io_hdr_t
|
||||
{
|
||||
/// <summary>
|
||||
/// Always 'S' for SG v3
|
||||
/// </summary>
|
||||
public int interface_id; /* [i] 'S' (required) */
|
||||
public int dxfer_direction; /* [i] */
|
||||
public byte cmd_len; /* [i] */
|
||||
public byte mx_sb_len; /* [i] */
|
||||
public ushort iovec_count; /* [i] */
|
||||
public uint dxfer_len; /* [i] */
|
||||
public IntPtr dxferp; /* [i], [*io] */
|
||||
public IntPtr cmdp; /* [i], [*i] */
|
||||
public IntPtr sbp; /* [i], [*o] */
|
||||
public uint timeout; /* [i] unit: millisecs */
|
||||
public uint flags; /* [i] */
|
||||
public int pack_id; /* [i->o] */
|
||||
public IntPtr usr_ptr; /* [i->o] */
|
||||
public byte status; /* [o] */
|
||||
public byte masked_status;/* [o] */
|
||||
public byte msg_status; /* [o] */
|
||||
public byte sb_len_wr; /* [o] */
|
||||
public ushort host_status; /* [o] */
|
||||
public ushort driver_status;/* [o] */
|
||||
public int resid; /* [o] */
|
||||
public uint duration; /* [o] */
|
||||
public uint info; /* [o] */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
DiscImageChef.Devices/Properties/AssemblyInfo.cs
Normal file
27
DiscImageChef.Devices/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("DiscImageChef.Devices")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Claunia.com")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("© Claunia.com")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Filesystems",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Decoders", "DiscImageChef.Decoders\DiscImageChef.Decoders.csproj", "{0BEB3088-B634-4289-AE17-CDF2D25D00D5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Devices", "DiscImageChef.Devices\DiscImageChef.Devices.csproj", "{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
@@ -31,6 +33,10 @@ Global
|
||||
{0BEB3088-B634-4289-AE17-CDF2D25D00D5}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{0BEB3088-B634-4289-AE17-CDF2D25D00D5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0BEB3088-B634-4289-AE17-CDF2D25D00D5}.Release|x86.Build.0 = Release|Any CPU
|
||||
{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5DEA2811-2FFA-4959-830B-CAD3ACACABEB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5DEA2811-2FFA-4959-830B-CAD3ACACABEB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5DEA2811-2FFA-4959-830B-CAD3ACACABEB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
|
||||
Reference in New Issue
Block a user