mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Open remote host for devices starting with dic://
This commit is contained in:
@@ -40,7 +40,6 @@ using DiscImageChef.CommonTypes.Interop;
|
|||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.Decoders.ATA;
|
||||||
using DiscImageChef.Decoders.SCSI;
|
using DiscImageChef.Decoders.SCSI;
|
||||||
using DiscImageChef.Decoders.SCSI.MMC;
|
using DiscImageChef.Decoders.SCSI.MMC;
|
||||||
using DiscImageChef.Decoders.SecureDigital;
|
|
||||||
using DiscImageChef.Devices.FreeBSD;
|
using DiscImageChef.Devices.FreeBSD;
|
||||||
using DiscImageChef.Devices.Windows;
|
using DiscImageChef.Devices.Windows;
|
||||||
using Microsoft.Win32.SafeHandles;
|
using Microsoft.Win32.SafeHandles;
|
||||||
@@ -68,7 +67,19 @@ namespace DiscImageChef.Devices
|
|||||||
Error = false;
|
Error = false;
|
||||||
IsRemovable = false;
|
IsRemovable = false;
|
||||||
|
|
||||||
switch(PlatformId)
|
if (devicePath.StartsWith("dic://"))
|
||||||
|
{
|
||||||
|
devicePath = devicePath.Substring(6);
|
||||||
|
var pieces = devicePath.Split('/');
|
||||||
|
var host = pieces[0];
|
||||||
|
devicePath = devicePath.Substring(host.Length);
|
||||||
|
|
||||||
|
remote = new Remote.Remote(host);
|
||||||
|
|
||||||
|
throw new NotImplementedException("Remote devices not yet implemented...");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (PlatformId)
|
||||||
{
|
{
|
||||||
case PlatformID.Win32NT:
|
case PlatformID.Win32NT:
|
||||||
{
|
{
|
||||||
@@ -77,7 +88,7 @@ namespace DiscImageChef.Devices
|
|||||||
FileMode.OpenExisting,
|
FileMode.OpenExisting,
|
||||||
FileAttributes.Normal, IntPtr.Zero);
|
FileAttributes.Normal, IntPtr.Zero);
|
||||||
|
|
||||||
if(((SafeFileHandle)FileHandle).IsInvalid)
|
if (((SafeFileHandle) FileHandle).IsInvalid)
|
||||||
{
|
{
|
||||||
Error = true;
|
Error = true;
|
||||||
LastError = Marshal.GetLastWin32Error();
|
LastError = Marshal.GetLastWin32Error();
|
||||||
@@ -91,20 +102,23 @@ namespace DiscImageChef.Devices
|
|||||||
Linux.Extern.open(devicePath,
|
Linux.Extern.open(devicePath,
|
||||||
FileFlags.ReadWrite | FileFlags.NonBlocking | FileFlags.CreateNew);
|
FileFlags.ReadWrite | FileFlags.NonBlocking | FileFlags.CreateNew);
|
||||||
|
|
||||||
if((int)FileHandle < 0)
|
if ((int) FileHandle < 0)
|
||||||
{
|
{
|
||||||
LastError = Marshal.GetLastWin32Error();
|
LastError = Marshal.GetLastWin32Error();
|
||||||
|
|
||||||
if(LastError == 13 || LastError == 30) // EACCES or EROFS
|
if (LastError == 13 || LastError == 30) // EACCES or EROFS
|
||||||
{
|
{
|
||||||
FileHandle = Linux.Extern.open(devicePath, FileFlags.Readonly | FileFlags.NonBlocking);
|
FileHandle = Linux.Extern.open(devicePath, FileFlags.Readonly | FileFlags.NonBlocking);
|
||||||
if((int)FileHandle < 0)
|
if ((int) FileHandle < 0)
|
||||||
{
|
{
|
||||||
Error = true;
|
Error = true;
|
||||||
LastError = Marshal.GetLastWin32Error();
|
LastError = Marshal.GetLastWin32Error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else Error = true;
|
else
|
||||||
|
{
|
||||||
|
Error = true;
|
||||||
|
}
|
||||||
|
|
||||||
LastError = Marshal.GetLastWin32Error();
|
LastError = Marshal.GetLastWin32Error();
|
||||||
}
|
}
|
||||||
@@ -115,24 +129,25 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
FileHandle = FreeBSD.Extern.cam_open_device(devicePath, FreeBSD.FileFlags.ReadWrite);
|
FileHandle = FreeBSD.Extern.cam_open_device(devicePath, FreeBSD.FileFlags.ReadWrite);
|
||||||
|
|
||||||
if(((IntPtr)FileHandle).ToInt64() == 0)
|
if (((IntPtr) FileHandle).ToInt64() == 0)
|
||||||
{
|
{
|
||||||
Error = true;
|
Error = true;
|
||||||
LastError = Marshal.GetLastWin32Error();
|
LastError = Marshal.GetLastWin32Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
CamDevice camDevice = (CamDevice)Marshal.PtrToStructure((IntPtr)FileHandle, typeof(CamDevice));
|
var camDevice = (CamDevice) Marshal.PtrToStructure((IntPtr) FileHandle, typeof(CamDevice));
|
||||||
|
|
||||||
if(StringHandlers.CToString(camDevice.SimName) == "ata")
|
if (StringHandlers.CToString(camDevice.SimName) == "ata")
|
||||||
throw new
|
throw new
|
||||||
InvalidOperationException("Parallel ATA devices are not supported on FreeBSD due to upstream bug #224250.");
|
InvalidOperationException(
|
||||||
|
"Parallel ATA devices are not supported on FreeBSD due to upstream bug #224250.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: throw new InvalidOperationException($"Platform {PlatformId} not yet supported.");
|
default: throw new InvalidOperationException($"Platform {PlatformId} not yet supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Error) throw new SystemException($"Error {LastError} opening device.");
|
if (Error) throw new SystemException($"Error {LastError} opening device.");
|
||||||
|
|
||||||
Type = DeviceType.Unknown;
|
Type = DeviceType.Unknown;
|
||||||
ScsiType = PeripheralDeviceTypes.UnknownDevice;
|
ScsiType = PeripheralDeviceTypes.UnknownDevice;
|
||||||
@@ -140,37 +155,37 @@ namespace DiscImageChef.Devices
|
|||||||
byte[] ataBuf;
|
byte[] ataBuf;
|
||||||
byte[] inqBuf = null;
|
byte[] inqBuf = null;
|
||||||
|
|
||||||
if(Error) throw new SystemException($"Error {LastError} trying device.");
|
if (Error) throw new SystemException($"Error {LastError} trying device.");
|
||||||
|
|
||||||
bool scsiSense = true;
|
var scsiSense = true;
|
||||||
|
|
||||||
// Windows is answering SCSI INQUIRY for all device types so it needs to be detected first
|
// Windows is answering SCSI INQUIRY for all device types so it needs to be detected first
|
||||||
switch(PlatformId)
|
switch (PlatformId)
|
||||||
{
|
{
|
||||||
case PlatformID.Win32NT:
|
case PlatformID.Win32NT:
|
||||||
StoragePropertyQuery query = new StoragePropertyQuery();
|
var query = new StoragePropertyQuery();
|
||||||
query.PropertyId = StoragePropertyId.Device;
|
query.PropertyId = StoragePropertyId.Device;
|
||||||
query.QueryType = StorageQueryType.Standard;
|
query.QueryType = StorageQueryType.Standard;
|
||||||
query.AdditionalParameters = new byte[1];
|
query.AdditionalParameters = new byte[1];
|
||||||
|
|
||||||
IntPtr descriptorPtr = Marshal.AllocHGlobal(1000);
|
var descriptorPtr = Marshal.AllocHGlobal(1000);
|
||||||
byte[] descriptorB = new byte[1000];
|
var descriptorB = new byte[1000];
|
||||||
|
|
||||||
uint returned = 0;
|
uint returned = 0;
|
||||||
int error = 0;
|
var error = 0;
|
||||||
|
|
||||||
bool hasError = !Extern.DeviceIoControlStorageQuery((SafeFileHandle)FileHandle,
|
var hasError = !Extern.DeviceIoControlStorageQuery((SafeFileHandle) FileHandle,
|
||||||
WindowsIoctl.IoctlStorageQueryProperty,
|
WindowsIoctl.IoctlStorageQueryProperty,
|
||||||
ref query, (uint)Marshal.SizeOf(query),
|
ref query, (uint) Marshal.SizeOf(query),
|
||||||
descriptorPtr, 1000, ref returned, IntPtr.Zero);
|
descriptorPtr, 1000, ref returned, IntPtr.Zero);
|
||||||
|
|
||||||
if(hasError) error = Marshal.GetLastWin32Error();
|
if (hasError) error = Marshal.GetLastWin32Error();
|
||||||
|
|
||||||
Marshal.Copy(descriptorPtr, descriptorB, 0, 1000);
|
Marshal.Copy(descriptorPtr, descriptorB, 0, 1000);
|
||||||
|
|
||||||
if(!hasError && error == 0)
|
if (!hasError && error == 0)
|
||||||
{
|
{
|
||||||
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor
|
var descriptor = new StorageDeviceDescriptor
|
||||||
{
|
{
|
||||||
Version = BitConverter.ToUInt32(descriptorB, 0),
|
Version = BitConverter.ToUInt32(descriptorB, 0),
|
||||||
Size = BitConverter.ToUInt32(descriptorB, 4),
|
Size = BitConverter.ToUInt32(descriptorB, 4),
|
||||||
@@ -182,13 +197,13 @@ namespace DiscImageChef.Devices
|
|||||||
ProductIdOffset = BitConverter.ToInt32(descriptorB, 16),
|
ProductIdOffset = BitConverter.ToInt32(descriptorB, 16),
|
||||||
ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20),
|
ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20),
|
||||||
SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24),
|
SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24),
|
||||||
BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28),
|
BusType = (StorageBusType) BitConverter.ToUInt32(descriptorB, 28),
|
||||||
RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32)
|
RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32)
|
||||||
};
|
};
|
||||||
descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength];
|
descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength];
|
||||||
Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength);
|
Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength);
|
||||||
|
|
||||||
switch(descriptor.BusType)
|
switch (descriptor.BusType)
|
||||||
{
|
{
|
||||||
case StorageBusType.SCSI:
|
case StorageBusType.SCSI:
|
||||||
case StorageBusType.SSA:
|
case StorageBusType.SSA:
|
||||||
@@ -223,23 +238,26 @@ namespace DiscImageChef.Devices
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(Type)
|
switch (Type)
|
||||||
{
|
{
|
||||||
case DeviceType.SCSI:
|
case DeviceType.SCSI:
|
||||||
case DeviceType.ATAPI:
|
case DeviceType.ATAPI:
|
||||||
scsiSense = ScsiInquiry(out inqBuf, out _);
|
scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
break;
|
break;
|
||||||
case DeviceType.ATA:
|
case DeviceType.ATA:
|
||||||
bool atapiSense = AtapiIdentify(out ataBuf, out _);
|
var atapiSense = AtapiIdentify(out ataBuf, out _);
|
||||||
|
|
||||||
if(!atapiSense)
|
if (!atapiSense)
|
||||||
{
|
{
|
||||||
Type = DeviceType.ATAPI;
|
Type = DeviceType.ATAPI;
|
||||||
Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf);
|
var ataid = Identify.Decode(ataBuf);
|
||||||
|
|
||||||
if(ataid.HasValue) scsiSense = ScsiInquiry(out inqBuf, out _);
|
if (ataid.HasValue) scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Manufacturer = "ATA";
|
||||||
}
|
}
|
||||||
else Manufacturer = "ATA";
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -247,17 +265,17 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
Marshal.FreeHGlobal(descriptorPtr);
|
Marshal.FreeHGlobal(descriptorPtr);
|
||||||
|
|
||||||
if(Windows.Command.IsSdhci((SafeFileHandle)FileHandle))
|
if (Windows.Command.IsSdhci((SafeFileHandle) FileHandle))
|
||||||
{
|
{
|
||||||
byte[] sdBuffer = new byte[16];
|
var sdBuffer = new byte[16];
|
||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle) FileHandle, MmcCommands.SendCsd,
|
||||||
false, false,
|
false, false,
|
||||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
||||||
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _,
|
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _,
|
||||||
out _, out bool sense);
|
out _, out var sense);
|
||||||
|
|
||||||
if(!sense)
|
if (!sense)
|
||||||
{
|
{
|
||||||
cachedCsd = new byte[16];
|
cachedCsd = new byte[16];
|
||||||
Array.Copy(sdBuffer, 0, cachedCsd, 0, 16);
|
Array.Copy(sdBuffer, 0, cachedCsd, 0, 16);
|
||||||
@@ -265,13 +283,13 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
sdBuffer = new byte[16];
|
sdBuffer = new byte[16];
|
||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle) FileHandle, MmcCommands.SendCid,
|
||||||
false, false,
|
false, false,
|
||||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
||||||
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _,
|
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _,
|
||||||
out _, out sense);
|
out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if (!sense)
|
||||||
{
|
{
|
||||||
cachedCid = new byte[16];
|
cachedCid = new byte[16];
|
||||||
Array.Copy(sdBuffer, 0, cachedCid, 0, 16);
|
Array.Copy(sdBuffer, 0, cachedCid, 0, 16);
|
||||||
@@ -279,31 +297,31 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
sdBuffer = new byte[8];
|
sdBuffer = new byte[8];
|
||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle) FileHandle,
|
||||||
(MmcCommands)SecureDigitalCommands.SendScr, false,
|
(MmcCommands) SecureDigitalCommands.SendScr, false,
|
||||||
true,
|
true,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 |
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 |
|
||||||
MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer, out _,
|
MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer, out _,
|
||||||
out _, out sense);
|
out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if (!sense)
|
||||||
{
|
{
|
||||||
cachedScr = new byte[8];
|
cachedScr = new byte[8];
|
||||||
Array.Copy(sdBuffer, 0, cachedScr, 0, 8);
|
Array.Copy(sdBuffer, 0, cachedScr, 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cachedScr != null)
|
if (cachedScr != null)
|
||||||
{
|
{
|
||||||
sdBuffer = new byte[4];
|
sdBuffer = new byte[4];
|
||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle) FileHandle,
|
||||||
(MmcCommands)SecureDigitalCommands
|
(MmcCommands) SecureDigitalCommands
|
||||||
.SendOperatingCondition, false, true,
|
.SendOperatingCondition, false, true,
|
||||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
|
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
|
||||||
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
|
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
|
||||||
out _, out _, out sense);
|
out _, out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if (!sense)
|
||||||
{
|
{
|
||||||
cachedScr = new byte[4];
|
cachedScr = new byte[4];
|
||||||
Array.Copy(sdBuffer, 0, cachedScr, 0, 4);
|
Array.Copy(sdBuffer, 0, cachedScr, 0, 4);
|
||||||
@@ -313,13 +331,13 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
sdBuffer = new byte[4];
|
sdBuffer = new byte[4];
|
||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle) FileHandle,
|
||||||
MmcCommands.SendOpCond, false, true,
|
MmcCommands.SendOpCond, false, true,
|
||||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
|
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
|
||||||
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
|
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
|
||||||
out _, out _, out sense);
|
out _, out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if (!sense)
|
||||||
{
|
{
|
||||||
cachedScr = new byte[4];
|
cachedScr = new byte[4];
|
||||||
Array.Copy(sdBuffer, 0, cachedScr, 0, 4);
|
Array.Copy(sdBuffer, 0, cachedScr, 0, 4);
|
||||||
@@ -329,40 +347,42 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case PlatformID.Linux:
|
case PlatformID.Linux:
|
||||||
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
scsiSense = ScsiInquiry(out inqBuf, out _);
|
scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
|
}
|
||||||
// MultiMediaCard and SecureDigital go here
|
// MultiMediaCard and SecureDigital go here
|
||||||
else if(devicePath.StartsWith("/dev/mmcblk", StringComparison.Ordinal))
|
else if (devicePath.StartsWith("/dev/mmcblk", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
string devPath = devicePath.Substring(5);
|
var devPath = devicePath.Substring(5);
|
||||||
if(File.Exists("/sys/block/" + devPath + "/device/csd"))
|
if (File.Exists("/sys/block/" + devPath + "/device/csd"))
|
||||||
{
|
{
|
||||||
int len =
|
var len =
|
||||||
ConvertFromHexAscii("/sys/block/" + devPath + "/device/csd", out cachedCsd);
|
ConvertFromHexAscii("/sys/block/" + devPath + "/device/csd", out cachedCsd);
|
||||||
if(len == 0) cachedCsd = null;
|
if (len == 0) cachedCsd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(File.Exists("/sys/block/" + devPath + "/device/cid"))
|
if (File.Exists("/sys/block/" + devPath + "/device/cid"))
|
||||||
{
|
{
|
||||||
int len =
|
var len =
|
||||||
ConvertFromHexAscii("/sys/block/" + devPath + "/device/cid", out cachedCid);
|
ConvertFromHexAscii("/sys/block/" + devPath + "/device/cid", out cachedCid);
|
||||||
if(len == 0) cachedCid = null;
|
if (len == 0) cachedCid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(File.Exists("/sys/block/" + devPath + "/device/scr"))
|
if (File.Exists("/sys/block/" + devPath + "/device/scr"))
|
||||||
{
|
{
|
||||||
int len =
|
var len =
|
||||||
ConvertFromHexAscii("/sys/block/" + devPath + "/device/scr", out cachedScr);
|
ConvertFromHexAscii("/sys/block/" + devPath + "/device/scr", out cachedScr);
|
||||||
if(len == 0) cachedScr = null;
|
if (len == 0) cachedScr = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(File.Exists("/sys/block/" + devPath + "/device/ocr"))
|
if (File.Exists("/sys/block/" + devPath + "/device/ocr"))
|
||||||
{
|
{
|
||||||
int len =
|
var len =
|
||||||
ConvertFromHexAscii("/sys/block/" + devPath + "/device/ocr", out cachedOcr);
|
ConvertFromHexAscii("/sys/block/" + devPath + "/device/ocr", out cachedOcr);
|
||||||
if(len == 0) cachedOcr = null;
|
if (len == 0) cachedOcr = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,15 +393,16 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region SecureDigital / MultiMediaCard
|
#region SecureDigital / MultiMediaCard
|
||||||
if(cachedCid != null)
|
|
||||||
|
if (cachedCid != null)
|
||||||
{
|
{
|
||||||
ScsiType = PeripheralDeviceTypes.DirectAccess;
|
ScsiType = PeripheralDeviceTypes.DirectAccess;
|
||||||
IsRemovable = false;
|
IsRemovable = false;
|
||||||
|
|
||||||
if(cachedScr != null)
|
if (cachedScr != null)
|
||||||
{
|
{
|
||||||
Type = DeviceType.SecureDigital;
|
Type = DeviceType.SecureDigital;
|
||||||
CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(cachedCid);
|
var decoded = Decoders.SecureDigital.Decoders.DecodeCID(cachedCid);
|
||||||
Manufacturer = VendorString.Prettify(decoded.Manufacturer);
|
Manufacturer = VendorString.Prettify(decoded.Manufacturer);
|
||||||
Model = decoded.ProductName;
|
Model = decoded.ProductName;
|
||||||
Revision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}";
|
Revision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}";
|
||||||
@@ -390,47 +411,49 @@ namespace DiscImageChef.Devices
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Type = DeviceType.MMC;
|
Type = DeviceType.MMC;
|
||||||
Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(cachedCid);
|
var decoded = Decoders.MMC.Decoders.DecodeCID(cachedCid);
|
||||||
Manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer);
|
Manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer);
|
||||||
Model = decoded.ProductName;
|
Model = decoded.ProductName;
|
||||||
Revision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}";
|
Revision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}";
|
||||||
Serial = $"{decoded.ProductSerialNumber}";
|
Serial = $"{decoded.ProductSerialNumber}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion SecureDigital / MultiMediaCard
|
#endregion SecureDigital / MultiMediaCard
|
||||||
|
|
||||||
#region USB
|
#region USB
|
||||||
switch(PlatformId)
|
|
||||||
|
switch (PlatformId)
|
||||||
{
|
{
|
||||||
case PlatformID.Linux:
|
case PlatformID.Linux:
|
||||||
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
string devPath = devicePath.Substring(5);
|
var devPath = devicePath.Substring(5);
|
||||||
if(Directory.Exists("/sys/block/" + devPath))
|
if (Directory.Exists("/sys/block/" + devPath))
|
||||||
{
|
{
|
||||||
string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
||||||
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
||||||
if(!string.IsNullOrEmpty(resolvedLink))
|
if (!string.IsNullOrEmpty(resolvedLink))
|
||||||
while(resolvedLink.Contains("usb"))
|
while (resolvedLink.Contains("usb"))
|
||||||
{
|
{
|
||||||
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
||||||
if(!File.Exists(resolvedLink + "/descriptors") ||
|
if (!File.Exists(resolvedLink + "/descriptors") ||
|
||||||
!File.Exists(resolvedLink + "/idProduct") ||
|
!File.Exists(resolvedLink + "/idProduct") ||
|
||||||
!File.Exists(resolvedLink + "/idVendor")) continue;
|
!File.Exists(resolvedLink + "/idVendor")) continue;
|
||||||
|
|
||||||
FileStream usbFs = new FileStream(resolvedLink + "/descriptors",
|
var usbFs = new FileStream(resolvedLink + "/descriptors",
|
||||||
System.IO.FileMode.Open,
|
System.IO.FileMode.Open,
|
||||||
System.IO.FileAccess.Read);
|
System.IO.FileAccess.Read);
|
||||||
byte[] usbBuf = new byte[65536];
|
var usbBuf = new byte[65536];
|
||||||
int usbCount = usbFs.Read(usbBuf, 0, 65536);
|
var usbCount = usbFs.Read(usbBuf, 0, 65536);
|
||||||
UsbDescriptors = new byte[usbCount];
|
UsbDescriptors = new byte[usbCount];
|
||||||
Array.Copy(usbBuf, 0, UsbDescriptors, 0, usbCount);
|
Array.Copy(usbBuf, 0, UsbDescriptors, 0, usbCount);
|
||||||
usbFs.Close();
|
usbFs.Close();
|
||||||
|
|
||||||
StreamReader usbSr = new StreamReader(resolvedLink + "/idProduct");
|
var usbSr = new StreamReader(resolvedLink + "/idProduct");
|
||||||
string usbTemp = usbSr.ReadToEnd();
|
var usbTemp = usbSr.ReadToEnd();
|
||||||
ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture,
|
ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture,
|
||||||
out usbProduct);
|
out usbProduct);
|
||||||
usbSr.Close();
|
usbSr.Close();
|
||||||
@@ -441,21 +464,21 @@ namespace DiscImageChef.Devices
|
|||||||
out usbVendor);
|
out usbVendor);
|
||||||
usbSr.Close();
|
usbSr.Close();
|
||||||
|
|
||||||
if(File.Exists(resolvedLink + "/manufacturer"))
|
if (File.Exists(resolvedLink + "/manufacturer"))
|
||||||
{
|
{
|
||||||
usbSr = new StreamReader(resolvedLink + "/manufacturer");
|
usbSr = new StreamReader(resolvedLink + "/manufacturer");
|
||||||
UsbManufacturerString = usbSr.ReadToEnd().Trim();
|
UsbManufacturerString = usbSr.ReadToEnd().Trim();
|
||||||
usbSr.Close();
|
usbSr.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(File.Exists(resolvedLink + "/product"))
|
if (File.Exists(resolvedLink + "/product"))
|
||||||
{
|
{
|
||||||
usbSr = new StreamReader(resolvedLink + "/product");
|
usbSr = new StreamReader(resolvedLink + "/product");
|
||||||
UsbProductString = usbSr.ReadToEnd().Trim();
|
UsbProductString = usbSr.ReadToEnd().Trim();
|
||||||
usbSr.Close();
|
usbSr.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(File.Exists(resolvedLink + "/serial"))
|
if (File.Exists(resolvedLink + "/serial"))
|
||||||
{
|
{
|
||||||
usbSr = new StreamReader(resolvedLink + "/serial");
|
usbSr = new StreamReader(resolvedLink + "/serial");
|
||||||
UsbSerialString = usbSr.ReadToEnd().Trim();
|
UsbSerialString = usbSr.ReadToEnd().Trim();
|
||||||
@@ -473,20 +496,20 @@ namespace DiscImageChef.Devices
|
|||||||
Usb.UsbDevice usbDevice = null;
|
Usb.UsbDevice usbDevice = null;
|
||||||
|
|
||||||
// I have to search for USB disks, floppies and CD-ROMs as separate device types
|
// I have to search for USB disks, floppies and CD-ROMs as separate device types
|
||||||
foreach(string devGuid in new[]
|
foreach (var devGuid in new[]
|
||||||
{
|
{
|
||||||
Usb.GuidDevinterfaceFloppy, Usb.GuidDevinterfaceCdrom, Usb.GuidDevinterfaceDisk
|
Usb.GuidDevinterfaceFloppy, Usb.GuidDevinterfaceCdrom, Usb.GuidDevinterfaceDisk
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
usbDevice = Usb.FindDrivePath(devicePath, devGuid);
|
usbDevice = Usb.FindDrivePath(devicePath, devGuid);
|
||||||
if(usbDevice != null) break;
|
if (usbDevice != null) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(usbDevice != null)
|
if (usbDevice != null)
|
||||||
{
|
{
|
||||||
UsbDescriptors = usbDevice.BinaryDescriptors;
|
UsbDescriptors = usbDevice.BinaryDescriptors;
|
||||||
usbVendor = (ushort)usbDevice.DeviceDescriptor.idVendor;
|
usbVendor = (ushort) usbDevice.DeviceDescriptor.idVendor;
|
||||||
usbProduct = (ushort)usbDevice.DeviceDescriptor.idProduct;
|
usbProduct = (ushort) usbDevice.DeviceDescriptor.idProduct;
|
||||||
UsbManufacturerString = usbDevice.Manufacturer;
|
UsbManufacturerString = usbDevice.Manufacturer;
|
||||||
UsbProductString = usbDevice.Product;
|
UsbProductString = usbDevice.Product;
|
||||||
UsbSerialString =
|
UsbSerialString =
|
||||||
@@ -498,29 +521,31 @@ namespace DiscImageChef.Devices
|
|||||||
IsUsb = false;
|
IsUsb = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion USB
|
#endregion USB
|
||||||
|
|
||||||
#region FireWire
|
#region FireWire
|
||||||
if(PlatformId == PlatformID.Linux)
|
|
||||||
|
if (PlatformId == PlatformID.Linux)
|
||||||
{
|
{
|
||||||
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
string devPath = devicePath.Substring(5);
|
var devPath = devicePath.Substring(5);
|
||||||
if(Directory.Exists("/sys/block/" + devPath))
|
if (Directory.Exists("/sys/block/" + devPath))
|
||||||
{
|
{
|
||||||
string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
||||||
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
||||||
if(!string.IsNullOrEmpty(resolvedLink))
|
if (!string.IsNullOrEmpty(resolvedLink))
|
||||||
while(resolvedLink.Contains("firewire"))
|
while (resolvedLink.Contains("firewire"))
|
||||||
{
|
{
|
||||||
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
||||||
if(!File.Exists(resolvedLink + "/model") || !File.Exists(resolvedLink + "/vendor") ||
|
if (!File.Exists(resolvedLink + "/model") || !File.Exists(resolvedLink + "/vendor") ||
|
||||||
!File.Exists(resolvedLink + "/guid")) continue;
|
!File.Exists(resolvedLink + "/guid")) continue;
|
||||||
|
|
||||||
StreamReader fwSr = new StreamReader(resolvedLink + "/model");
|
var fwSr = new StreamReader(resolvedLink + "/model");
|
||||||
string fwTemp = fwSr.ReadToEnd();
|
var fwTemp = fwSr.ReadToEnd();
|
||||||
uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture,
|
uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture,
|
||||||
out firewireModel);
|
out firewireModel);
|
||||||
fwSr.Close();
|
fwSr.Close();
|
||||||
@@ -537,14 +562,14 @@ namespace DiscImageChef.Devices
|
|||||||
out firewireGuid);
|
out firewireGuid);
|
||||||
fwSr.Close();
|
fwSr.Close();
|
||||||
|
|
||||||
if(File.Exists(resolvedLink + "/model_name"))
|
if (File.Exists(resolvedLink + "/model_name"))
|
||||||
{
|
{
|
||||||
fwSr = new StreamReader(resolvedLink + "/model_name");
|
fwSr = new StreamReader(resolvedLink + "/model_name");
|
||||||
FireWireModelName = fwSr.ReadToEnd().Trim();
|
FireWireModelName = fwSr.ReadToEnd().Trim();
|
||||||
fwSr.Close();
|
fwSr.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(File.Exists(resolvedLink + "/vendor_name"))
|
if (File.Exists(resolvedLink + "/vendor_name"))
|
||||||
{
|
{
|
||||||
fwSr = new StreamReader(resolvedLink + "/vendor_name");
|
fwSr = new StreamReader(resolvedLink + "/vendor_name");
|
||||||
FireWireVendorName = fwSr.ReadToEnd().Trim();
|
FireWireVendorName = fwSr.ReadToEnd().Trim();
|
||||||
@@ -558,41 +583,46 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Implement for other operating systems
|
// TODO: Implement for other operating systems
|
||||||
else IsFireWire = false;
|
else
|
||||||
|
{
|
||||||
|
IsFireWire = false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion FireWire
|
#endregion FireWire
|
||||||
|
|
||||||
#region PCMCIA
|
#region PCMCIA
|
||||||
if(PlatformId == PlatformID.Linux)
|
|
||||||
|
if (PlatformId == PlatformID.Linux)
|
||||||
{
|
{
|
||||||
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
||||||
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
string devPath = devicePath.Substring(5);
|
var devPath = devicePath.Substring(5);
|
||||||
if(Directory.Exists("/sys/block/" + devPath))
|
if (Directory.Exists("/sys/block/" + devPath))
|
||||||
{
|
{
|
||||||
string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
||||||
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
||||||
if(!string.IsNullOrEmpty(resolvedLink))
|
if (!string.IsNullOrEmpty(resolvedLink))
|
||||||
while(resolvedLink.Contains("/sys/devices"))
|
while (resolvedLink.Contains("/sys/devices"))
|
||||||
{
|
{
|
||||||
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
||||||
if(!Directory.Exists(resolvedLink + "/pcmcia_socket")) continue;
|
if (!Directory.Exists(resolvedLink + "/pcmcia_socket")) continue;
|
||||||
|
|
||||||
string[] subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket",
|
var subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket",
|
||||||
"pcmcia_socket*",
|
"pcmcia_socket*",
|
||||||
SearchOption.TopDirectoryOnly);
|
SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
if(subdirs.Length <= 0) continue;
|
if (subdirs.Length <= 0) continue;
|
||||||
|
|
||||||
string possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
|
var possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
|
||||||
if(!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis"))
|
if (!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FileStream cisFs = new FileStream(possibleDir + "/cis", System.IO.FileMode.Open,
|
var cisFs = new FileStream(possibleDir + "/cis", System.IO.FileMode.Open,
|
||||||
System.IO.FileAccess.Read);
|
System.IO.FileAccess.Read);
|
||||||
byte[] cisBuf = new byte[65536];
|
var cisBuf = new byte[65536];
|
||||||
int cisCount = cisFs.Read(cisBuf, 0, 65536);
|
var cisCount = cisFs.Read(cisBuf, 0, 65536);
|
||||||
Cis = new byte[cisCount];
|
Cis = new byte[cisCount];
|
||||||
Array.Copy(cisBuf, 0, Cis, 0, cisCount);
|
Array.Copy(cisBuf, 0, Cis, 0, cisCount);
|
||||||
cisFs.Close();
|
cisFs.Close();
|
||||||
@@ -604,57 +634,64 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Implement for other operating systems
|
// TODO: Implement for other operating systems
|
||||||
else IsPcmcia = false;
|
else
|
||||||
#endregion PCMCIA
|
|
||||||
|
|
||||||
if(!scsiSense)
|
|
||||||
{
|
{
|
||||||
Inquiry.SCSIInquiry? inquiry = Inquiry.Decode(inqBuf);
|
IsPcmcia = false;
|
||||||
|
|
||||||
Type = DeviceType.SCSI;
|
|
||||||
bool serialSense = ScsiInquiry(out inqBuf, out _, 0x80);
|
|
||||||
if(!serialSense) Serial = EVPD.DecodePage80(inqBuf);
|
|
||||||
|
|
||||||
if(inquiry.HasValue)
|
|
||||||
{
|
|
||||||
string tmp = StringHandlers.CToString(inquiry.Value.ProductRevisionLevel);
|
|
||||||
if(tmp != null) Revision = tmp.Trim();
|
|
||||||
tmp = StringHandlers.CToString(inquiry.Value.ProductIdentification);
|
|
||||||
if(tmp != null) Model = tmp.Trim();
|
|
||||||
tmp = StringHandlers.CToString(inquiry.Value.VendorIdentification);
|
|
||||||
if(tmp != null) Manufacturer = tmp.Trim();
|
|
||||||
IsRemovable = inquiry.Value.RMB;
|
|
||||||
|
|
||||||
ScsiType = (PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool atapiSense = AtapiIdentify(out ataBuf, out _);
|
#endregion PCMCIA
|
||||||
|
|
||||||
if(!atapiSense)
|
if (!scsiSense)
|
||||||
|
{
|
||||||
|
var inquiry = Inquiry.Decode(inqBuf);
|
||||||
|
|
||||||
|
Type = DeviceType.SCSI;
|
||||||
|
var serialSense = ScsiInquiry(out inqBuf, out _, 0x80);
|
||||||
|
if (!serialSense) Serial = EVPD.DecodePage80(inqBuf);
|
||||||
|
|
||||||
|
if (inquiry.HasValue)
|
||||||
|
{
|
||||||
|
var tmp = StringHandlers.CToString(inquiry.Value.ProductRevisionLevel);
|
||||||
|
if (tmp != null) Revision = tmp.Trim();
|
||||||
|
tmp = StringHandlers.CToString(inquiry.Value.ProductIdentification);
|
||||||
|
if (tmp != null) Model = tmp.Trim();
|
||||||
|
tmp = StringHandlers.CToString(inquiry.Value.VendorIdentification);
|
||||||
|
if (tmp != null) Manufacturer = tmp.Trim();
|
||||||
|
IsRemovable = inquiry.Value.RMB;
|
||||||
|
|
||||||
|
ScsiType = (PeripheralDeviceTypes) inquiry.Value.PeripheralDeviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
var atapiSense = AtapiIdentify(out ataBuf, out _);
|
||||||
|
|
||||||
|
if (!atapiSense)
|
||||||
{
|
{
|
||||||
Type = DeviceType.ATAPI;
|
Type = DeviceType.ATAPI;
|
||||||
Identify.IdentifyDevice? ataId = Identify.Decode(ataBuf);
|
var ataId = Identify.Decode(ataBuf);
|
||||||
|
|
||||||
if(ataId.HasValue) Serial = ataId.Value.SerialNumber;
|
if (ataId.HasValue) Serial = ataId.Value.SerialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastError = 0;
|
LastError = 0;
|
||||||
Error = false;
|
Error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA")
|
if (scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA")
|
||||||
{
|
{
|
||||||
bool ataSense = AtaIdentify(out ataBuf, out _);
|
var ataSense = AtaIdentify(out ataBuf, out _);
|
||||||
if(!ataSense)
|
if (!ataSense)
|
||||||
{
|
{
|
||||||
Type = DeviceType.ATA;
|
Type = DeviceType.ATA;
|
||||||
Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf);
|
var ataid = Identify.Decode(ataBuf);
|
||||||
|
|
||||||
if(ataid.HasValue)
|
if (ataid.HasValue)
|
||||||
{
|
{
|
||||||
string[] separated = ataid.Value.Model.Split(' ');
|
var separated = ataid.Value.Model.Split(' ');
|
||||||
|
|
||||||
if(separated.Length == 1) Model = separated[0];
|
if (separated.Length == 1)
|
||||||
|
{
|
||||||
|
Model = separated[0];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Manufacturer = separated[0];
|
Manufacturer = separated[0];
|
||||||
@@ -666,7 +703,7 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
ScsiType = PeripheralDeviceTypes.DirectAccess;
|
ScsiType = PeripheralDeviceTypes.DirectAccess;
|
||||||
|
|
||||||
if((ushort)ataid.Value.GeneralConfiguration != 0x848A)
|
if ((ushort) ataid.Value.GeneralConfiguration != 0x848A)
|
||||||
IsRemovable |=
|
IsRemovable |=
|
||||||
(ataid.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) ==
|
(ataid.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) ==
|
||||||
Identify.GeneralConfigurationBit.Removable;
|
Identify.GeneralConfigurationBit.Removable;
|
||||||
@@ -675,7 +712,7 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Type == DeviceType.Unknown)
|
if (Type == DeviceType.Unknown)
|
||||||
{
|
{
|
||||||
Manufacturer = null;
|
Manufacturer = null;
|
||||||
Model = null;
|
Model = null;
|
||||||
@@ -683,61 +720,64 @@ namespace DiscImageChef.Devices
|
|||||||
Serial = null;
|
Serial = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsUsb)
|
if (IsUsb)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(Manufacturer)) Manufacturer = UsbManufacturerString;
|
if (string.IsNullOrEmpty(Manufacturer)) Manufacturer = UsbManufacturerString;
|
||||||
if(string.IsNullOrEmpty(Model)) Model = UsbProductString;
|
if (string.IsNullOrEmpty(Model)) Model = UsbProductString;
|
||||||
if(string.IsNullOrEmpty(Serial)) Serial = UsbSerialString;
|
if (string.IsNullOrEmpty(Serial)) Serial = UsbSerialString;
|
||||||
else
|
else
|
||||||
foreach(char c in Serial.Where(char.IsControl))
|
foreach (var c in Serial.Where(char.IsControl))
|
||||||
Serial = UsbSerialString;
|
Serial = UsbSerialString;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsFireWire)
|
if (IsFireWire)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(Manufacturer)) Manufacturer = FireWireVendorName;
|
if (string.IsNullOrEmpty(Manufacturer)) Manufacturer = FireWireVendorName;
|
||||||
if(string.IsNullOrEmpty(Model)) Model = FireWireModelName;
|
if (string.IsNullOrEmpty(Model)) Model = FireWireModelName;
|
||||||
if(string.IsNullOrEmpty(Serial)) Serial = $"{firewireGuid:X16}";
|
if (string.IsNullOrEmpty(Serial)) Serial = $"{firewireGuid:X16}";
|
||||||
else
|
else
|
||||||
foreach(char c in Serial.Where(char.IsControl))
|
foreach (var c in Serial.Where(char.IsControl))
|
||||||
Serial = $"{firewireGuid:X16}";
|
Serial = $"{firewireGuid:X16}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some optical drives are not getting the correct serial, and IDENTIFY PACKET DEVICE is blocked without
|
// Some optical drives are not getting the correct serial, and IDENTIFY PACKET DEVICE is blocked without
|
||||||
// administrator privileges
|
// administrator privileges
|
||||||
if(ScsiType != PeripheralDeviceTypes.MultiMediaDevice) return;
|
if (ScsiType != PeripheralDeviceTypes.MultiMediaDevice) return;
|
||||||
|
|
||||||
bool featureSense = GetConfiguration(out byte[] featureBuffer, out _, 0x0108, MmcGetConfigurationRt.Single,
|
var featureSense = GetConfiguration(out var featureBuffer, out _, 0x0108, MmcGetConfigurationRt.Single,
|
||||||
Timeout, out _);
|
Timeout, out _);
|
||||||
|
|
||||||
if(featureSense) return;
|
if (featureSense) return;
|
||||||
|
|
||||||
Features.SeparatedFeatures features = Features.Separate(featureBuffer);
|
var features = Features.Separate(featureBuffer);
|
||||||
if(features.Descriptors?.Length != 1 || features.Descriptors[0].Code != 0x0108) return;
|
if (features.Descriptors?.Length != 1 || features.Descriptors[0].Code != 0x0108) return;
|
||||||
|
|
||||||
Feature_0108? serialFeature = Features.Decode_0108(features.Descriptors[0].Data);
|
var serialFeature = Features.Decode_0108(features.Descriptors[0].Data);
|
||||||
|
|
||||||
if(serialFeature is null) return;
|
if (serialFeature is null) return;
|
||||||
|
|
||||||
Serial = serialFeature.Value.Serial;
|
Serial = serialFeature.Value.Serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ConvertFromHexAscii(string file, out byte[] outBuf)
|
private static int ConvertFromHexAscii(string file, out byte[] outBuf)
|
||||||
{
|
{
|
||||||
StreamReader sr = new StreamReader(file);
|
var sr = new StreamReader(file);
|
||||||
string ins = sr.ReadToEnd().Trim();
|
var ins = sr.ReadToEnd().Trim();
|
||||||
outBuf = new byte[ins.Length / 2];
|
outBuf = new byte[ins.Length / 2];
|
||||||
int count = 0;
|
var count = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for(int i = 0; i < ins.Length; i += 2)
|
for (var i = 0; i < ins.Length; i += 2)
|
||||||
{
|
{
|
||||||
outBuf[i / 2] = Convert.ToByte(ins.Substring(i, 2), 16);
|
outBuf[i / 2] = Convert.ToByte(ins.Substring(i, 2), 16);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { count = 0; }
|
catch
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
sr.Close();
|
sr.Close();
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
@@ -38,18 +38,18 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
public partial class Device
|
public partial class Device
|
||||||
{
|
{
|
||||||
readonly ushort usbVendor;
|
private readonly ushort usbVendor;
|
||||||
readonly ushort usbProduct;
|
private readonly ushort usbProduct;
|
||||||
readonly ulong firewireGuid;
|
private readonly ulong firewireGuid;
|
||||||
readonly uint firewireModel;
|
private readonly uint firewireModel;
|
||||||
readonly uint firewireVendor;
|
private readonly uint firewireVendor;
|
||||||
|
|
||||||
// MMC and SecureDigital, values that need to be get with card idle, something that may
|
// MMC and SecureDigital, values that need to be get with card idle, something that may
|
||||||
// not be possible to do but usually is already done by the SDHCI driver.
|
// not be possible to do but usually is already done by the SDHCI driver.
|
||||||
readonly byte[] cachedCsd;
|
private readonly byte[] cachedCsd;
|
||||||
readonly byte[] cachedCid;
|
private readonly byte[] cachedCid;
|
||||||
readonly byte[] cachedScr;
|
private readonly byte[] cachedScr;
|
||||||
readonly byte[] cachedOcr;
|
private readonly byte[] cachedOcr;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Platform ID for this device
|
/// Gets the Platform ID for this device
|
||||||
@@ -217,5 +217,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Contains the PCMCIA CIS if applicable
|
/// Contains the PCMCIA CIS if applicable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[] Cis { get; }
|
public byte[] Cis { get; }
|
||||||
|
|
||||||
|
private readonly Remote.Remote remote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user