mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: All refactor in DiscImageChef.Devices.
This commit is contained in:
@@ -41,14 +41,12 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBuffer};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadBuffer;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration);
|
||||||
@@ -60,13 +58,11 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBufferDma};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadBufferDma;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
|
||||||
ref buffer, timeout, false, out duration, out sense);
|
ref buffer, timeout, false, out duration, out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER DMA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER DMA took {0} ms.", duration);
|
||||||
@@ -83,22 +79,21 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||||
byte count, uint timeout, out double duration)
|
byte count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 256];
|
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
{
|
||||||
bool sense;
|
SectorCount = count,
|
||||||
|
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||||
|
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||||
|
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||||
|
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||||
|
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
|
||||||
|
};
|
||||||
|
|
||||||
if(retry) registers.Command = (byte)AtaCommands.ReadDmaRetry;
|
|
||||||
else registers.Command = (byte)AtaCommands.ReadDma;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
|
||||||
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
|
||||||
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
|
|
||||||
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||||
ref buffer, timeout, true, out duration, out sense);
|
ref buffer, timeout, true, out duration, out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
||||||
@@ -109,22 +104,22 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 256];
|
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
{
|
||||||
bool sense;
|
Command = (byte)AtaCommands.ReadMultiple,
|
||||||
|
SectorCount = count,
|
||||||
|
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||||
|
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||||
|
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||||
|
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadMultiple;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
|
||||||
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
|
||||||
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
|
|
||||||
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
||||||
@@ -137,15 +132,13 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
lba = 0;
|
lba = 0;
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadNativeMaxAddress};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadNativeMaxAddress;
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if((statusRegisters.Status & 0x23) == 0)
|
if((statusRegisters.Status & 0x23) == 0)
|
||||||
@@ -171,23 +164,22 @@ namespace DiscImageChef.Devices
|
|||||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||||
byte count, uint timeout, out double duration)
|
byte count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 256];
|
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
{
|
||||||
bool sense;
|
SectorCount = count,
|
||||||
|
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||||
|
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||||
|
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||||
|
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||||
|
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read
|
||||||
|
};
|
||||||
|
|
||||||
if(retry) registers.Command = (byte)AtaCommands.ReadRetry;
|
|
||||||
else registers.Command = (byte)AtaCommands.Read;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
|
||||||
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
|
||||||
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
|
|
||||||
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
||||||
@@ -205,21 +197,21 @@ namespace DiscImageChef.Devices
|
|||||||
uint blockSize, uint timeout, out double duration)
|
uint blockSize, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[blockSize];
|
buffer = new byte[blockSize];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
SectorCount = 1,
|
||||||
|
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||||
|
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||||
|
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||||
|
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||||
|
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong
|
||||||
|
};
|
||||||
|
|
||||||
if(retry) registers.Command = (byte)AtaCommands.ReadLongRetry;
|
|
||||||
else registers.Command = (byte)AtaCommands.ReadLong;
|
|
||||||
registers.SectorCount = 1;
|
|
||||||
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
|
||||||
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
|
||||||
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
|
|
||||||
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
||||||
@@ -230,19 +222,20 @@ namespace DiscImageChef.Devices
|
|||||||
public bool Seek(out AtaErrorRegistersLba28 statusRegisters, uint lba, uint timeout, out double duration)
|
public bool Seek(out AtaErrorRegistersLba28 statusRegisters, uint lba, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Seek,
|
||||||
|
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||||
|
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||||
|
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||||
|
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Seek;
|
|
||||||
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
|
||||||
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
|
||||||
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
|
|
||||||
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
||||||
|
|||||||
@@ -41,16 +41,14 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
lba = 0;
|
lba = 0;
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
|
||||||
bool sense;
|
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
|
AtaRegistersLba48 registers =
|
||||||
|
new AtaRegistersLba48 {Command = (byte)AtaCommands.NativeMaxAddress, Feature = 0x0000};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.NativeMaxAddress;
|
|
||||||
registers.Feature = 0x0000;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if((statusRegisters.Status & 0x23) == 0)
|
if((statusRegisters.Status & 0x23) == 0)
|
||||||
@@ -69,20 +67,20 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 65536];
|
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
{
|
||||||
bool sense;
|
Command = (byte)AtaCommands.ReadDmaExt,
|
||||||
|
SectorCount = count,
|
||||||
|
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||||
|
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||||
|
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadDmaExt;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
|
|
||||||
registers.LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
|
|
||||||
registers.LbaLow = (ushort)((lba & 0xFFFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||||
ref buffer, timeout, true, out duration, out sense);
|
ref buffer, timeout, true, out duration, out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ DMA EXT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ DMA EXT took {0} ms.", duration);
|
||||||
@@ -94,18 +92,19 @@ namespace DiscImageChef.Devices
|
|||||||
ushort pageNumber, ushort count, uint timeout, out double duration)
|
ushort pageNumber, ushort count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512 * count];
|
buffer = new byte[512 * count];
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.ReadLogExt,
|
||||||
|
SectorCount = count,
|
||||||
|
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
|
||||||
|
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadLogExt;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.LbaLow = (ushort)((pageNumber & 0xFF) * 0x100);
|
|
||||||
registers.LbaLow += logAddress;
|
registers.LbaLow += logAddress;
|
||||||
registers.LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ LOG EXT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ LOG EXT took {0} ms.", duration);
|
||||||
@@ -117,17 +116,18 @@ namespace DiscImageChef.Devices
|
|||||||
ushort pageNumber, ushort count, uint timeout, out double duration)
|
ushort pageNumber, ushort count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512 * count];
|
buffer = new byte[512 * count];
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.ReadLogDmaExt,
|
||||||
|
SectorCount = count,
|
||||||
|
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
|
||||||
|
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadLogDmaExt;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.LbaLow = (ushort)((pageNumber & 0xFF) * 0x100);
|
|
||||||
registers.LbaLow += logAddress;
|
registers.LbaLow += logAddress;
|
||||||
registers.LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||||
ref buffer, timeout, true, out duration, out sense);
|
ref buffer, timeout, true, out duration, out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ LOG DMA EXT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ LOG DMA EXT took {0} ms.", duration);
|
||||||
@@ -138,21 +138,21 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 65536];
|
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
{
|
||||||
bool sense;
|
Command = (byte)AtaCommands.ReadMultipleExt,
|
||||||
|
SectorCount = count,
|
||||||
|
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||||
|
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||||
|
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadMultipleExt;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
|
|
||||||
registers.LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
|
|
||||||
registers.LbaLow = (ushort)((lba & 0xFFFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE EXT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE EXT took {0} ms.", duration);
|
||||||
@@ -165,15 +165,13 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
lba = 0;
|
lba = 0;
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
AtaRegistersLba48 registers = new AtaRegistersLba48 {Command = (byte)AtaCommands.ReadNativeMaxAddressExt};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadNativeMaxAddressExt;
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if((statusRegisters.Status & 0x23) == 0)
|
if((statusRegisters.Status & 0x23) == 0)
|
||||||
@@ -192,21 +190,21 @@ namespace DiscImageChef.Devices
|
|||||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 65536];
|
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||||
AtaRegistersLba48 registers = new AtaRegistersLba48();
|
{
|
||||||
bool sense;
|
Command = (byte)AtaCommands.ReadExt,
|
||||||
|
SectorCount = count,
|
||||||
|
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||||
|
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||||
|
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadExt;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000);
|
|
||||||
registers.LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000);
|
|
||||||
registers.LbaLow = (ushort)((lba & 0xFFFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS EXT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS EXT took {0} ms.", duration);
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// <param name="timeout">Timeout.</param>
|
/// <param name="timeout">Timeout.</param>
|
||||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
|
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
|
||||||
{
|
{
|
||||||
double duration;
|
return AtaIdentify(out buffer, out statusRegisters, timeout, out _);
|
||||||
return AtaIdentify(out buffer, out statusRegisters, timeout, out duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -85,14 +84,12 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyDevice};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.IdentifyDevice;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "IDENTIFY DEVICE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "IDENTIFY DEVICE took {0} ms.", duration);
|
||||||
@@ -109,21 +106,20 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
||||||
byte head, byte sector, byte count, uint timeout, out double duration)
|
byte head, byte sector, byte count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 256];
|
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersChs registers = new AtaRegistersChs
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
{
|
||||||
bool sense;
|
SectorCount = count,
|
||||||
|
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||||
|
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||||
|
DeviceHead = (byte)(head & 0x0F),
|
||||||
|
Sector = sector,
|
||||||
|
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
|
||||||
|
};
|
||||||
|
|
||||||
if(retry) registers.Command = (byte)AtaCommands.ReadDmaRetry;
|
|
||||||
else registers.Command = (byte)AtaCommands.ReadDma;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
|
||||||
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead = (byte)(head & 0x0F);
|
|
||||||
registers.Sector = sector;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||||
ref buffer, timeout, true, out duration, out sense);
|
ref buffer, timeout, true, out duration, out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
||||||
@@ -134,21 +130,21 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
||||||
byte head, byte sector, byte count, uint timeout, out double duration)
|
byte head, byte sector, byte count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 256];
|
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersChs registers = new AtaRegistersChs
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
{
|
||||||
bool sense;
|
Command = (byte)AtaCommands.ReadMultiple,
|
||||||
|
SectorCount = count,
|
||||||
|
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||||
|
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||||
|
DeviceHead = (byte)(head & 0x0F),
|
||||||
|
Sector = sector
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.ReadMultiple;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
|
||||||
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead = (byte)(head & 0x0F);
|
|
||||||
registers.Sector = sector;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
||||||
@@ -165,22 +161,21 @@ namespace DiscImageChef.Devices
|
|||||||
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
||||||
byte head, byte sector, byte count, uint timeout, out double duration)
|
byte head, byte sector, byte count, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(count == 0) buffer = new byte[512 * 256];
|
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||||
else buffer = new byte[512 * count];
|
AtaRegistersChs registers = new AtaRegistersChs
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
{
|
||||||
bool sense;
|
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read,
|
||||||
|
SectorCount = count,
|
||||||
|
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||||
|
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||||
|
DeviceHead = (byte)(head & 0x0F),
|
||||||
|
Sector = sector
|
||||||
|
};
|
||||||
|
|
||||||
if(retry) registers.Command = (byte)AtaCommands.ReadRetry;
|
|
||||||
else registers.Command = (byte)AtaCommands.Read;
|
|
||||||
registers.SectorCount = count;
|
|
||||||
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
|
||||||
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead = (byte)(head & 0x0F);
|
|
||||||
registers.Sector = sector;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
||||||
@@ -199,20 +194,20 @@ namespace DiscImageChef.Devices
|
|||||||
byte head, byte sector, uint blockSize, uint timeout, out double duration)
|
byte head, byte sector, uint blockSize, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[blockSize];
|
buffer = new byte[blockSize];
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
AtaRegistersChs registers = new AtaRegistersChs
|
||||||
bool sense;
|
{
|
||||||
|
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong,
|
||||||
|
SectorCount = 1,
|
||||||
|
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||||
|
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||||
|
DeviceHead = (byte)(head & 0x0F),
|
||||||
|
Sector = sector
|
||||||
|
};
|
||||||
|
|
||||||
if(retry) registers.Command = (byte)AtaCommands.ReadLongRetry;
|
|
||||||
else registers.Command = (byte)AtaCommands.ReadLong;
|
|
||||||
registers.SectorCount = 1;
|
|
||||||
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
|
||||||
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead = (byte)(head & 0x0F);
|
|
||||||
registers.Sector = sector;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
||||||
@@ -224,18 +219,19 @@ namespace DiscImageChef.Devices
|
|||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
AtaRegistersChs registers = new AtaRegistersChs
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Seek,
|
||||||
|
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||||
|
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||||
|
DeviceHead = (byte)(head & 0x0F),
|
||||||
|
Sector = sector
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Seek;
|
|
||||||
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
|
||||||
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead = (byte)(head & 0x0F);
|
|
||||||
registers.Sector = sector;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// <param name="timeout">Timeout.</param>
|
/// <param name="timeout">Timeout.</param>
|
||||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
|
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
|
||||||
{
|
{
|
||||||
double duration;
|
return AtapiIdentify(out buffer, out statusRegisters, timeout, out _);
|
||||||
return AtapiIdentify(out buffer, out statusRegisters, timeout, out duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -85,14 +84,12 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyPacketDevice};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.IdentifyPacketDevice;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "IDENTIFY PACKET DEVICE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "IDENTIFY PACKET DEVICE took {0} ms.", duration);
|
||||||
|
|||||||
@@ -41,19 +41,20 @@ namespace DiscImageChef.Devices
|
|||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.TranslateSector,
|
||||||
|
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||||
|
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||||
|
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||||
|
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.TranslateSector;
|
|
||||||
registers.DeviceHead = (byte)((lba & 0xF000000) / 0x1000000);
|
|
||||||
registers.LbaHigh = (byte)((lba & 0xFF0000) / 0x10000);
|
|
||||||
registers.LbaMid = (byte)((lba & 0xFF00) / 0x100);
|
|
||||||
registers.LbaLow = (byte)((lba & 0xFF) / 0x1);
|
|
||||||
registers.DeviceHead += 0x40;
|
registers.DeviceHead += 0x40;
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
|
||||||
@@ -65,18 +66,19 @@ namespace DiscImageChef.Devices
|
|||||||
byte head, byte sector, uint timeout, out double duration)
|
byte head, byte sector, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
AtaRegistersChs registers = new AtaRegistersChs
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.TranslateSector,
|
||||||
|
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||||
|
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||||
|
Sector = sector,
|
||||||
|
DeviceHead = (byte)(head & 0x0F)
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.TranslateSector;
|
|
||||||
registers.CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100);
|
|
||||||
registers.CylinderLow = (byte)((cylinder & 0xFF) / 0x1);
|
|
||||||
registers.Sector = sector;
|
|
||||||
registers.DeviceHead = (byte)(head & 0x0F);
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
|
||||||
@@ -88,14 +90,12 @@ namespace DiscImageChef.Devices
|
|||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.RequestSense};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.RequestSense;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
errorCode = statusRegisters.Error;
|
errorCode = statusRegisters.Error;
|
||||||
|
|||||||
@@ -53,15 +53,13 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersChs registers = new AtaRegistersChs();
|
AtaRegistersChs registers =
|
||||||
bool sense;
|
new AtaRegistersChs {Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.CheckMediaCardType;
|
|
||||||
registers.Feature = feature;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration);
|
||||||
|
|||||||
@@ -40,17 +40,18 @@ namespace DiscImageChef.Devices
|
|||||||
public bool SmartDisable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
public bool SmartDisable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.Disable,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.Disable;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE OPERATIONS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE OPERATIONS took {0} ms.", duration);
|
||||||
@@ -62,18 +63,19 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F,
|
||||||
|
SectorCount = 0xF1
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
registers.SectorCount = 0xF1;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
|
||||||
@@ -85,17 +87,18 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
|
||||||
@@ -106,17 +109,18 @@ namespace DiscImageChef.Devices
|
|||||||
public bool SmartEnable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
public bool SmartEnable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.Enable,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.Enable;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE OPERATIONS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE OPERATIONS took {0} ms.", duration);
|
||||||
@@ -128,18 +132,19 @@ namespace DiscImageChef.Devices
|
|||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F,
|
||||||
|
LbaLow = subcommand
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
registers.LbaLow = subcommand;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART EXECUTE OFF-LINE IMMEDIATE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART EXECUTE OFF-LINE IMMEDIATE took {0} ms.", duration);
|
||||||
@@ -151,17 +156,18 @@ namespace DiscImageChef.Devices
|
|||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.ReadData,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.ReadData;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART READ DATA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART READ DATA took {0} ms.", duration);
|
||||||
@@ -173,18 +179,19 @@ namespace DiscImageChef.Devices
|
|||||||
uint timeout, out double duration)
|
uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.ReadLog,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F,
|
||||||
|
LbaLow = logAddress
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.ReadLog;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
registers.LbaLow = logAddress;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART READ LOG took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART READ LOG took {0} ms.", duration);
|
||||||
@@ -195,17 +202,18 @@ namespace DiscImageChef.Devices
|
|||||||
public bool SmartReturnStatus(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
public bool SmartReturnStatus(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersLba28 registers = new AtaRegistersLba28();
|
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||||
bool sense;
|
{
|
||||||
|
Command = (byte)AtaCommands.Smart,
|
||||||
|
Feature = (byte)AtaSmartSubCommands.ReturnStatus,
|
||||||
|
LbaHigh = 0xC2,
|
||||||
|
LbaMid = 0x4F
|
||||||
|
};
|
||||||
|
|
||||||
registers.Command = (byte)AtaCommands.Smart;
|
|
||||||
registers.Feature = (byte)AtaSmartSubCommands.ReturnStatus;
|
|
||||||
registers.LbaHigh = 0xC2;
|
|
||||||
registers.LbaMid = 0x4F;
|
|
||||||
|
|
||||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "SMART RETURN STATUS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("ATA Device", "SMART RETURN STATUS took {0} ms.", duration);
|
||||||
|
|||||||
@@ -31,10 +31,12 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.Decoders.ATA;
|
||||||
|
|
||||||
namespace DiscImageChef.Devices
|
namespace DiscImageChef.Devices
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
public partial class Device
|
public partial class Device
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -125,16 +125,12 @@ namespace DiscImageChef.Devices
|
|||||||
Type = DeviceType.Unknown;
|
Type = DeviceType.Unknown;
|
||||||
ScsiType = PeripheralDeviceTypes.UnknownDevice;
|
ScsiType = PeripheralDeviceTypes.UnknownDevice;
|
||||||
|
|
||||||
AtaErrorRegistersChs errorRegisters;
|
|
||||||
|
|
||||||
byte[] ataBuf;
|
byte[] ataBuf;
|
||||||
byte[] senseBuf;
|
|
||||||
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;
|
bool scsiSense = true;
|
||||||
string ntDevicePath;
|
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -163,19 +159,21 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
if(!hasError && error == 0)
|
if(!hasError && error == 0)
|
||||||
{
|
{
|
||||||
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor();
|
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor
|
||||||
descriptor.Version = BitConverter.ToUInt32(descriptorB, 0);
|
{
|
||||||
descriptor.Size = BitConverter.ToUInt32(descriptorB, 4);
|
Version = BitConverter.ToUInt32(descriptorB, 0),
|
||||||
descriptor.DeviceType = descriptorB[8];
|
Size = BitConverter.ToUInt32(descriptorB, 4),
|
||||||
descriptor.DeviceTypeModifier = descriptorB[9];
|
DeviceType = descriptorB[8],
|
||||||
descriptor.RemovableMedia = descriptorB[10] > 0;
|
DeviceTypeModifier = descriptorB[9],
|
||||||
descriptor.CommandQueueing = descriptorB[11] > 0;
|
RemovableMedia = descriptorB[10] > 0,
|
||||||
descriptor.VendorIdOffset = BitConverter.ToInt32(descriptorB, 12);
|
CommandQueueing = descriptorB[11] > 0,
|
||||||
descriptor.ProductIdOffset = BitConverter.ToInt32(descriptorB, 16);
|
VendorIdOffset = BitConverter.ToInt32(descriptorB, 12),
|
||||||
descriptor.ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20);
|
ProductIdOffset = BitConverter.ToInt32(descriptorB, 16),
|
||||||
descriptor.SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24);
|
ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20),
|
||||||
descriptor.BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28);
|
SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24),
|
||||||
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32);
|
BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28),
|
||||||
|
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);
|
||||||
|
|
||||||
@@ -216,36 +214,35 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
switch(Type) {
|
switch(Type) {
|
||||||
case DeviceType.SCSI:
|
case DeviceType.SCSI:
|
||||||
case DeviceType.ATAPI: scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
|
case DeviceType.ATAPI: scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
break;
|
break;
|
||||||
case DeviceType.ATA:
|
case DeviceType.ATA:
|
||||||
bool atapiSense = AtapiIdentify(out ataBuf, out errorRegisters);
|
bool atapiSense = AtapiIdentify(out ataBuf, out _);
|
||||||
|
|
||||||
if(!atapiSense)
|
if(!atapiSense)
|
||||||
{
|
{
|
||||||
Type = DeviceType.ATAPI;
|
Type = DeviceType.ATAPI;
|
||||||
Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf);
|
Identify.IdentifyDevice? ataid = Identify.Decode(ataBuf);
|
||||||
|
|
||||||
if(ataid.HasValue) scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
|
if(ataid.HasValue) scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
}
|
}
|
||||||
else Manufacturer = "ATA";
|
else Manufacturer = "ATA";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)FileHandle);
|
string ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)FileHandle);
|
||||||
DicConsole.DebugWriteLine("Windows devices", "NT device path: {0}", ntDevicePath);
|
DicConsole.DebugWriteLine("Windows devices", "NT device path: {0}", ntDevicePath);
|
||||||
Marshal.FreeHGlobal(descriptorPtr);
|
Marshal.FreeHGlobal(descriptorPtr);
|
||||||
|
|
||||||
if(Windows.Command.IsSdhci((SafeFileHandle)FileHandle))
|
if(Windows.Command.IsSdhci((SafeFileHandle)FileHandle))
|
||||||
{
|
{
|
||||||
byte[] sdBuffer = new byte[16];
|
byte[] sdBuffer = new byte[16];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd, false, false,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd, false, false,
|
||||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
||||||
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer,
|
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer,
|
||||||
out uint[] response, out double duration, out sense, 0);
|
out _, out _, out bool sense);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
@@ -257,8 +254,8 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid, false, false,
|
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid, false, false,
|
||||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
|
||||||
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out response,
|
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _,
|
||||||
out duration, out sense, 0);
|
out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
@@ -272,7 +269,7 @@ namespace DiscImageChef.Devices
|
|||||||
(MmcCommands)SecureDigitalCommands.SendScr, false, true,
|
(MmcCommands)SecureDigitalCommands.SendScr, false, true,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 |
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 |
|
||||||
MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer,
|
MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer,
|
||||||
out response, out duration, out sense, 0);
|
out _, out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
@@ -289,7 +286,7 @@ namespace DiscImageChef.Devices
|
|||||||
.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 response, out duration, out sense, 0);
|
out _, out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
@@ -305,7 +302,7 @@ namespace DiscImageChef.Devices
|
|||||||
true,
|
true,
|
||||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
|
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
|
||||||
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
|
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
|
||||||
out response, out duration, out sense, 0);
|
out _, out _, out sense);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
@@ -319,7 +316,7 @@ namespace DiscImageChef.Devices
|
|||||||
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 senseBuf);
|
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))
|
||||||
{
|
{
|
||||||
@@ -346,7 +343,7 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
|
default: scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,21 +394,17 @@ namespace DiscImageChef.Devices
|
|||||||
!File.Exists(resolvedLink + "/idProduct") ||
|
!File.Exists(resolvedLink + "/idProduct") ||
|
||||||
!File.Exists(resolvedLink + "/idVendor")) continue;
|
!File.Exists(resolvedLink + "/idVendor")) continue;
|
||||||
|
|
||||||
FileStream usbFs;
|
FileStream usbFs = new FileStream(resolvedLink + "/descriptors",
|
||||||
StreamReader usbSr;
|
System.IO.FileMode.Open,
|
||||||
string usbTemp;
|
System.IO.FileAccess.Read);
|
||||||
|
|
||||||
usbFs = new FileStream(resolvedLink + "/descriptors",
|
|
||||||
System.IO.FileMode.Open,
|
|
||||||
System.IO.FileAccess.Read);
|
|
||||||
byte[] usbBuf = new byte[65536];
|
byte[] usbBuf = new byte[65536];
|
||||||
int usbCount = usbFs.Read(usbBuf, 0, 65536);
|
int 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();
|
||||||
|
|
||||||
usbSr = new StreamReader(resolvedLink + "/idProduct");
|
StreamReader usbSr = new StreamReader(resolvedLink + "/idProduct");
|
||||||
usbTemp = usbSr.ReadToEnd();
|
string usbTemp = usbSr.ReadToEnd();
|
||||||
ushort.TryParse(usbTemp, NumberStyles.HexNumber,
|
ushort.TryParse(usbTemp, NumberStyles.HexNumber,
|
||||||
CultureInfo.InvariantCulture, out usbProduct);
|
CultureInfo.InvariantCulture, out usbProduct);
|
||||||
usbSr.Close();
|
usbSr.Close();
|
||||||
@@ -500,11 +493,8 @@ namespace DiscImageChef.Devices
|
|||||||
!File.Exists(resolvedLink + "/vendor") ||
|
!File.Exists(resolvedLink + "/vendor") ||
|
||||||
!File.Exists(resolvedLink + "/guid")) continue;
|
!File.Exists(resolvedLink + "/guid")) continue;
|
||||||
|
|
||||||
StreamReader fwSr;
|
StreamReader fwSr = new StreamReader(resolvedLink + "/model");
|
||||||
string fwTemp;
|
string fwTemp = fwSr.ReadToEnd();
|
||||||
|
|
||||||
fwSr = new StreamReader(resolvedLink + "/model");
|
|
||||||
fwTemp = fwSr.ReadToEnd();
|
|
||||||
uint.TryParse(fwTemp, NumberStyles.HexNumber,
|
uint.TryParse(fwTemp, NumberStyles.HexNumber,
|
||||||
CultureInfo.InvariantCulture, out firewireModel);
|
CultureInfo.InvariantCulture, out firewireModel);
|
||||||
fwSr.Close();
|
fwSr.Close();
|
||||||
@@ -576,11 +566,9 @@ namespace DiscImageChef.Devices
|
|||||||
if(!File.Exists(possibleDir + "/card_type") ||
|
if(!File.Exists(possibleDir + "/card_type") ||
|
||||||
!File.Exists(possibleDir + "/cis")) continue;
|
!File.Exists(possibleDir + "/cis")) continue;
|
||||||
|
|
||||||
FileStream cisFs;
|
FileStream cisFs = new FileStream(possibleDir + "/cis",
|
||||||
|
System.IO.FileMode.Open,
|
||||||
cisFs = new FileStream(possibleDir + "/cis",
|
System.IO.FileAccess.Read);
|
||||||
System.IO.FileMode.Open,
|
|
||||||
System.IO.FileAccess.Read);
|
|
||||||
byte[] cisBuf = new byte[65536];
|
byte[] cisBuf = new byte[65536];
|
||||||
int cisCount = cisFs.Read(cisBuf, 0, 65536);
|
int cisCount = cisFs.Read(cisBuf, 0, 65536);
|
||||||
Cis = new byte[cisCount];
|
Cis = new byte[cisCount];
|
||||||
@@ -602,7 +590,7 @@ namespace DiscImageChef.Devices
|
|||||||
Inquiry.SCSIInquiry? inquiry = Inquiry.Decode(inqBuf);
|
Inquiry.SCSIInquiry? inquiry = Inquiry.Decode(inqBuf);
|
||||||
|
|
||||||
Type = DeviceType.SCSI;
|
Type = DeviceType.SCSI;
|
||||||
bool serialSense = ScsiInquiry(out inqBuf, out senseBuf, 0x80);
|
bool serialSense = ScsiInquiry(out inqBuf, out _, 0x80);
|
||||||
if(!serialSense) Serial = EVPD.DecodePage80(inqBuf);
|
if(!serialSense) Serial = EVPD.DecodePage80(inqBuf);
|
||||||
|
|
||||||
if(inquiry.HasValue)
|
if(inquiry.HasValue)
|
||||||
@@ -618,7 +606,7 @@ namespace DiscImageChef.Devices
|
|||||||
ScsiType = (PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType;
|
ScsiType = (PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool atapiSense = AtapiIdentify(out ataBuf, out errorRegisters);
|
bool atapiSense = AtapiIdentify(out ataBuf, out _);
|
||||||
|
|
||||||
if(!atapiSense)
|
if(!atapiSense)
|
||||||
{
|
{
|
||||||
@@ -636,7 +624,7 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
if(scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA")
|
if(scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA")
|
||||||
{
|
{
|
||||||
bool ataSense = AtaIdentify(out ataBuf, out errorRegisters);
|
bool ataSense = AtaIdentify(out ataBuf, out _);
|
||||||
if(!ataSense)
|
if(!ataSense)
|
||||||
{
|
{
|
||||||
Type = DeviceType.ATA;
|
Type = DeviceType.ATA;
|
||||||
@@ -680,7 +668,7 @@ namespace DiscImageChef.Devices
|
|||||||
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 foreach(char c in Serial.Where(c => char.IsControl(c))) Serial = UsbSerialString;
|
else foreach(char c in Serial.Where(char.IsControl)) Serial = UsbSerialString;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IsFireWire) return;
|
if(!IsFireWire) return;
|
||||||
@@ -688,7 +676,7 @@ namespace DiscImageChef.Devices
|
|||||||
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 foreach(char c in Serial.Where(c => char.IsControl(c))) Serial = $"{firewireGuid:X16}";
|
else foreach(char c in Serial.Where(char.IsControl)) Serial = $"{firewireGuid:X16}";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ConvertFromHexAscii(string file, out byte[] outBuf)
|
static int ConvertFromHexAscii(string file, out byte[] outBuf)
|
||||||
|
|||||||
@@ -39,11 +39,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[16];
|
buffer = new byte[16];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(MmcCommands.SendCsd, false, false,
|
LastError = SendMmcCommand(MmcCommands.SendCsd, false, false,
|
||||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("MMC Device", "SEND_CSD took {0} ms.", duration);
|
DicConsole.DebugWriteLine("MMC Device", "SEND_CSD took {0} ms.", duration);
|
||||||
@@ -54,11 +53,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadCid(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadCid(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[16];
|
buffer = new byte[16];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(MmcCommands.SendCid, false, false,
|
LastError = SendMmcCommand(MmcCommands.SendCid, false, false,
|
||||||
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("MMC Device", "SEND_CID took {0} ms.", duration);
|
DicConsole.DebugWriteLine("MMC Device", "SEND_CID took {0} ms.", duration);
|
||||||
@@ -69,11 +67,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadOcr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadOcr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[4];
|
buffer = new byte[4];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true,
|
LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true,
|
||||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_OP_COND took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_OP_COND took {0} ms.", duration);
|
||||||
@@ -84,11 +81,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadExtendedCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadExtendedCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false,
|
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1,
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("MMC Device", "SEND_EXT_CSD took {0} ms.", duration);
|
DicConsole.DebugWriteLine("MMC Device", "SEND_EXT_CSD took {0} ms.", duration);
|
||||||
@@ -99,11 +95,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool SetBlockLength(uint length, out uint[] response, uint timeout, out double duration)
|
public bool SetBlockLength(uint length, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false,
|
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0,
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0,
|
||||||
0, ref buffer, out response, out duration, out sense, timeout);
|
0, ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("MMC Device", "SET_BLOCKLEN took {0} ms.", duration);
|
DicConsole.DebugWriteLine("MMC Device", "SET_BLOCKLEN took {0} ms.", duration);
|
||||||
@@ -115,18 +110,15 @@ namespace DiscImageChef.Devices
|
|||||||
bool byteAddressed, uint timeout, out double duration)
|
bool byteAddressed, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[transferLength * blockSize];
|
buffer = new byte[transferLength * blockSize];
|
||||||
bool sense;
|
|
||||||
uint address;
|
uint address;
|
||||||
if(byteAddressed) address = lba * blockSize;
|
if(byteAddressed) address = lba * blockSize;
|
||||||
else address = lba;
|
else address = lba;
|
||||||
|
|
||||||
MmcCommands command;
|
MmcCommands command = transferLength > 1 ? MmcCommands.ReadMultipleBlock : MmcCommands.ReadSingleBlock;
|
||||||
if(transferLength > 1) command = MmcCommands.ReadMultipleBlock;
|
|
||||||
else command = MmcCommands.ReadSingleBlock;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(command, false, false,
|
LastError = SendMmcCommand(command, false, false,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address,
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address,
|
||||||
blockSize, transferLength, ref buffer, out response, out duration, out sense,
|
blockSize, transferLength, ref buffer, out response, out duration, out bool sense,
|
||||||
timeout);
|
timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
@@ -135,7 +127,7 @@ namespace DiscImageChef.Devices
|
|||||||
byte[] foo = new byte[0];
|
byte[] foo = new byte[0];
|
||||||
SendMmcCommand(MmcCommands.StopTransmission, false, false,
|
SendMmcCommand(MmcCommands.StopTransmission, false, false,
|
||||||
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0, 0, 0, ref foo,
|
MmcFlags.ResponseR1B | MmcFlags.ResponseSpiR1B | MmcFlags.CommandAc, 0, 0, 0, ref foo,
|
||||||
out uint[] responseStop, out double stopDuration, out bool stopSense, timeout);
|
out _, out double stopDuration, out bool _, timeout);
|
||||||
duration += stopDuration;
|
duration += stopDuration;
|
||||||
DicConsole.DebugWriteLine("MMC Device", "READ_MULTIPLE_BLOCK took {0} ms.", duration);
|
DicConsole.DebugWriteLine("MMC Device", "READ_MULTIPLE_BLOCK took {0} ms.", duration);
|
||||||
}
|
}
|
||||||
@@ -147,11 +139,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[4];
|
buffer = new byte[4];
|
||||||
bool sense = false;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand(MmcCommands.SendStatus, false, true,
|
LastError = SendMmcCommand(MmcCommands.SendStatus, false, true,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1,
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_STATUS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_STATUS took {0} ms.", duration);
|
||||||
|
|||||||
@@ -39,11 +39,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadSdStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadSdStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[64];
|
buffer = new byte[64];
|
||||||
bool sense = false;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true,
|
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 64, 1,
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 64, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SecureDigital Device", "SD_STATUS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SecureDigital Device", "SD_STATUS took {0} ms.", duration);
|
||||||
@@ -54,11 +53,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadSdocr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadSdocr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[4];
|
buffer = new byte[4];
|
||||||
bool sense = false;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true,
|
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true,
|
||||||
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SecureDigital Device", "SD_SEND_OP_COND took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SecureDigital Device", "SD_SEND_OP_COND took {0} ms.", duration);
|
||||||
@@ -69,11 +67,10 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadScr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
public bool ReadScr(out byte[] buffer, out uint[] response, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
bool sense = false;
|
|
||||||
|
|
||||||
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true,
|
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true,
|
||||||
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1,
|
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1,
|
||||||
ref buffer, out response, out duration, out sense, timeout);
|
ref buffer, out response, out duration, out bool sense, timeout);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_SCR took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_SCR took {0} ms.", duration);
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
|
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
|
||||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||||
@@ -76,7 +75,7 @@ namespace DiscImageChef.Devices
|
|||||||
if(drive1) cdb[1] += 0x20;
|
if(drive1) cdb[1] += 0x20;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC TRANSLATE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC TRANSLATE took {0} ms.", duration);
|
||||||
@@ -113,14 +112,13 @@ namespace DiscImageChef.Devices
|
|||||||
buffer[0] = threshold;
|
buffer[0] = threshold;
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.AdaptecSetErrorThreshold;
|
cdb[0] = (byte)ScsiCommands.AdaptecSetErrorThreshold;
|
||||||
if(drive1) cdb[1] += 0x20;
|
if(drive1) cdb[1] += 0x20;
|
||||||
cdb[4] = 1;
|
cdb[4] = 1;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC SET ERROR THRESHOLD took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC SET ERROR THRESHOLD took {0} ms.", duration);
|
||||||
@@ -155,14 +153,13 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[9];
|
buffer = new byte[9];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
|
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
|
||||||
if(drive1) cdb[1] += 0x20;
|
if(drive1) cdb[1] += 0x20;
|
||||||
cdb[4] = (byte)buffer.Length;
|
cdb[4] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ/RESET USAGE COUNTER took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ/RESET USAGE COUNTER took {0} ms.", duration);
|
||||||
@@ -180,17 +177,15 @@ namespace DiscImageChef.Devices
|
|||||||
public bool AdaptecWriteBuffer(byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
public bool AdaptecWriteBuffer(byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] oneKBuffer = new byte[1024];
|
byte[] oneKBuffer = new byte[1024];
|
||||||
if(buffer.Length < 1024) Array.Copy(buffer, 0, oneKBuffer, 0, buffer.Length);
|
Array.Copy(buffer, 0, oneKBuffer, 0, buffer.Length < 1024 ? buffer.Length : 1024);
|
||||||
else Array.Copy(buffer, 0, oneKBuffer, 0, 1024);
|
|
||||||
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer;
|
cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
LastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC WRITE DATA BUFFER took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC WRITE DATA BUFFER took {0} ms.", duration);
|
||||||
@@ -210,12 +205,11 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[1024];
|
buffer = new byte[1024];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer;
|
cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ DATA BUFFER took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ DATA BUFFER took {0} ms.", duration);
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[3];
|
buffer = new byte[3];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress;
|
cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress;
|
||||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||||
@@ -59,7 +58,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = 3;
|
cdb[4] = 3;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. REQUEST BLOCK ADDRESS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. REQUEST BLOCK ADDRESS took {0} ms.", duration);
|
||||||
@@ -93,7 +92,6 @@ namespace DiscImageChef.Devices
|
|||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock;
|
cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock;
|
||||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||||
@@ -102,7 +100,7 @@ namespace DiscImageChef.Devices
|
|||||||
if(immediate) cdb[1] += 0x01;
|
if(immediate) cdb[1] += 0x01;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. SEEK BLOCK took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. SEEK BLOCK took {0} ms.", duration);
|
||||||
|
|||||||
@@ -30,10 +30,12 @@
|
|||||||
// Copyright © 2011-2018 Natalia Portillo
|
// Copyright © 2011-2018 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
|
||||||
namespace DiscImageChef.Devices
|
namespace DiscImageChef.Devices
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
public partial class Device
|
public partial class Device
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -70,13 +72,12 @@ namespace DiscImageChef.Devices
|
|||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;
|
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;
|
||||||
if(park) cdb[4] = 1;
|
if(park) cdb[4] = 1;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "CERTANCE PARK UNPARK took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "CERTANCE PARK UNPARK took {0} ms.", duration);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ namespace DiscImageChef.Devices
|
|||||||
bool displayLen = false;
|
bool displayLen = false;
|
||||||
bool halfMsg = false;
|
bool halfMsg = false;
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(firstHalf))
|
if(!string.IsNullOrWhiteSpace(firstHalf))
|
||||||
{
|
{
|
||||||
@@ -67,10 +66,7 @@ namespace DiscImageChef.Devices
|
|||||||
displayLen = true;
|
displayLen = true;
|
||||||
else if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
|
else if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
|
||||||
ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
|
ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
|
||||||
{
|
|
||||||
displayLen = false;
|
|
||||||
halfMsg = true;
|
halfMsg = true;
|
||||||
}
|
|
||||||
|
|
||||||
buffer[0] = (byte)((byte)mode << 5);
|
buffer[0] = (byte)((byte)mode << 5);
|
||||||
if(displayLen) buffer[0] += 0x10;
|
if(displayLen) buffer[0] += 0x10;
|
||||||
@@ -85,7 +81,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[6] = (byte)buffer.Length;
|
cdb[6] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "FUJITSU DISPLAY took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "FUJITSU DISPLAY took {0} ms.", duration);
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
buffer = new byte[2064 * transferLength];
|
buffer = new byte[2064 * transferLength];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
|
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
|
||||||
cdb[1] = 0x48;
|
cdb[1] = 0x48;
|
||||||
@@ -67,7 +66,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[11] = (byte)(buffer.Length & 0xFF);
|
cdb[11] = (byte)(buffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "HL-DT-ST READ DVD (RAW) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "HL-DT-ST READ DVD (RAW) took {0} ms.", duration);
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadLong;
|
cdb[0] = (byte)ScsiCommands.ReadLong;
|
||||||
if(relAddr) cdb[1] += 0x01;
|
if(relAddr) cdb[1] += 0x01;
|
||||||
@@ -88,11 +87,10 @@ namespace DiscImageChef.Devices
|
|||||||
if(pba) cdb[9] += 0x80;
|
if(pba) cdb[9] += 0x80;
|
||||||
if(sectorCount) cdb[9] += 0x40;
|
if(sectorCount) cdb[9] += 0x40;
|
||||||
|
|
||||||
if(sectorCount) buffer = new byte[blockBytes * transferLen];
|
buffer = sectorCount ? new byte[blockBytes * transferLen] : new byte[transferLen];
|
||||||
else buffer = new byte[transferLen];
|
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "HP READ LONG took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "HP READ LONG took {0} ms.", duration);
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
||||||
cdb[1] = 0x08;
|
cdb[1] = 0x08;
|
||||||
@@ -57,7 +56,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[3] = 0x01;
|
cdb[3] = 0x01;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "KREON DEPRECATED UNLOCK took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "KREON DEPRECATED UNLOCK took {0} ms.", duration);
|
||||||
@@ -114,7 +113,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
||||||
cdb[1] = 0x08;
|
cdb[1] = 0x08;
|
||||||
@@ -123,7 +121,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = (byte)state;
|
cdb[4] = (byte)state;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "KREON SET LOCK STATE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "KREON SET LOCK STATE took {0} ms.", duration);
|
||||||
@@ -145,7 +143,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[26];
|
byte[] buffer = new byte[26];
|
||||||
bool sense;
|
|
||||||
features = 0;
|
features = 0;
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
cdb[0] = (byte)ScsiCommands.KreonCommand;
|
||||||
@@ -154,7 +151,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[3] = 0x10;
|
cdb[3] = 0x10;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "KREON GET FEATURE LIST took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "KREON GET FEATURE LIST took {0} ms.", duration);
|
||||||
@@ -222,7 +219,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[2048];
|
buffer = new byte[2048];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
|
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
|
||||||
cdb[1] = 0x00;
|
cdb[1] = 0x00;
|
||||||
@@ -238,7 +234,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[11] = 0xC0;
|
cdb[11] = 0xC0;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "KREON EXTRACT SS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "KREON EXTRACT SS took {0} ms.", duration);
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.GetConfiguration;
|
cdb[0] = (byte)ScsiCommands.GetConfiguration;
|
||||||
cdb[1] = (byte)((byte)rt & 0x03);
|
cdb[1] = (byte)((byte)rt & 0x03);
|
||||||
@@ -94,7 +93,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = 0;
|
cdb[9] = 0;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -134,7 +133,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
|
cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
|
||||||
cdb[1] = (byte)((byte)mediaType & 0x0F);
|
cdb[1] = (byte)((byte)mediaType & 0x0F);
|
||||||
@@ -149,7 +147,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[10] = (byte)((agid & 0x03) << 6);
|
cdb[10] = (byte)((agid & 0x03) << 6);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -297,11 +295,8 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
byte[] tmpBuffer;
|
|
||||||
bool sense;
|
|
||||||
|
|
||||||
if((format & 0x0F) == 5) tmpBuffer = new byte[32768];
|
byte[] tmpBuffer = (format & 0x0F) == 5 ? new byte[32768] : new byte[1024];
|
||||||
else tmpBuffer = new byte[1024];
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
|
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
|
||||||
if(msf) cdb[1] = 0x02;
|
if(msf) cdb[1] = 0x02;
|
||||||
@@ -311,7 +306,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||||
@@ -364,7 +359,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
byte[] tmpBuffer = new byte[804];
|
byte[] tmpBuffer = new byte[804];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadDiscInformation;
|
cdb[0] = (byte)ScsiCommands.ReadDiscInformation;
|
||||||
cdb[1] = (byte)dataType;
|
cdb[1] = (byte)dataType;
|
||||||
@@ -372,7 +366,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||||
@@ -411,7 +405,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCd;
|
cdb[0] = (byte)ScsiCommands.ReadCd;
|
||||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||||
@@ -434,7 +427,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[blockSize * transferLength];
|
buffer = new byte[blockSize * transferLength];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ CD took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ CD took {0} ms.", duration);
|
||||||
@@ -468,7 +461,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
|
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
|
||||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||||
@@ -491,7 +483,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[blockSize * transferLength];
|
buffer = new byte[blockSize * transferLength];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ CD MSF took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ CD MSF took {0} ms.", duration);
|
||||||
@@ -515,14 +507,13 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||||
if(prevent) cdb[4] += 0x01;
|
if(prevent) cdb[4] += 0x01;
|
||||||
if(persistent) cdb[4] += 0x02;
|
if(persistent) cdb[4] += 0x02;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
|
||||||
@@ -556,7 +547,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.StartStopUnit;
|
cdb[0] = (byte)ScsiCommands.StartStopUnit;
|
||||||
if(immediate) cdb[1] += 0x01;
|
if(immediate) cdb[1] += 0x01;
|
||||||
@@ -573,7 +563,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] += (byte)((powerConditions & 0x0F) << 4);
|
cdb[4] += (byte)((powerConditions & 0x0F) << 4);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "START STOP UNIT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "START STOP UNIT took {0} ms.", duration);
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.NecReadCdDa;
|
cdb[0] = (byte)ScsiCommands.NecReadCdDa;
|
||||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||||
@@ -64,7 +63,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[2352 * transferLength];
|
buffer = new byte[2352 * transferLength];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration);
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
||||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||||
@@ -69,7 +68,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[blockSize * transferLength];
|
buffer = new byte[blockSize * transferLength];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA took {0} ms.", duration);
|
||||||
@@ -94,7 +93,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
|
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
|
||||||
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
|
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
|
||||||
@@ -109,7 +107,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[blockSize * transferLength];
|
buffer = new byte[blockSize * transferLength];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA MSF took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA MSF took {0} ms.", duration);
|
||||||
@@ -134,7 +132,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCdXa;
|
cdb[0] = (byte)ScsiCommands.ReadCdXa;
|
||||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||||
@@ -162,7 +159,7 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-XA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-XA took {0} ms.", duration);
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation;
|
cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation;
|
||||||
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
cdb[2] = (byte)((address & 0xFF000000) >> 24);
|
||||||
@@ -104,7 +103,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLASMON READ SECTOR LOCATION took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLASMON READ SECTOR LOCATION took {0} ms.", duration);
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
cdb[0] = (byte)ScsiCommands.ReadCdDa;
|
||||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||||
@@ -71,7 +70,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[blockSize * transferLength];
|
buffer = new byte[blockSize * transferLength];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration);
|
||||||
@@ -95,7 +94,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
buffer = new byte[2064 * transferLength];
|
buffer = new byte[2064 * transferLength];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadBuffer;
|
cdb[0] = (byte)ScsiCommands.ReadBuffer;
|
||||||
cdb[1] = 0x02;
|
cdb[1] = 0x02;
|
||||||
@@ -107,7 +105,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[5] = (byte)(buffer.Length & 0xFF);
|
cdb[5] = (byte)(buffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "Plextor READ DVD (RAW) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "Plextor READ DVD (RAW) took {0} ms.", duration);
|
||||||
@@ -128,13 +126,12 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[256];
|
buffer = new byte[256];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
|
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
|
||||||
cdb[8] = 1;
|
cdb[8] = 1;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
|
||||||
@@ -155,13 +152,12 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[512];
|
buffer = new byte[512];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
|
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
|
||||||
cdb[8] = 2;
|
cdb[8] = 2;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
|
||||||
@@ -185,7 +181,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[blockSize];
|
buffer = new byte[blockSize];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
|
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
|
||||||
cdb[1] = 1;
|
cdb[1] = 1;
|
||||||
@@ -194,7 +189,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = (byte)(blockSize & 0xFF);
|
cdb[9] = (byte)(blockSize & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
|
||||||
@@ -218,7 +213,6 @@ namespace DiscImageChef.Devices
|
|||||||
byte[] buf = new byte[10];
|
byte[] buf = new byte[10];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
selected = 0;
|
selected = 0;
|
||||||
max = 0;
|
max = 0;
|
||||||
@@ -228,7 +222,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = (byte)buf.Length;
|
cdb[9] = (byte)buf.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
|
||||||
@@ -258,7 +252,6 @@ namespace DiscImageChef.Devices
|
|||||||
byte[] buf = new byte[8];
|
byte[] buf = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
speed = 0;
|
speed = 0;
|
||||||
@@ -268,7 +261,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = (byte)buf.Length;
|
cdb[9] = (byte)buf.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
|
||||||
@@ -295,7 +288,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -304,7 +296,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[10] = (byte)buffer.Length;
|
cdb[10] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SILENT MODE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SILENT MODE took {0} ms.", duration);
|
||||||
@@ -325,7 +317,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -333,7 +324,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[10] = (byte)buffer.Length;
|
cdb[10] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET GIGAREC took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET GIGAREC took {0} ms.", duration);
|
||||||
@@ -356,7 +347,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -367,7 +357,7 @@ namespace DiscImageChef.Devices
|
|||||||
else cdb[3] = 0x02;
|
else cdb[3] = 0x02;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET VARIREC took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET VARIREC took {0} ms.", duration);
|
||||||
@@ -388,14 +378,13 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[2] = (byte)PlextorSubCommands.SecuRec;
|
cdb[2] = (byte)PlextorSubCommands.SecuRec;
|
||||||
cdb[10] = (byte)buffer.Length;
|
cdb[10] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SECUREC took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SECUREC took {0} ms.", duration);
|
||||||
@@ -416,7 +405,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -424,7 +412,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[10] = (byte)buffer.Length;
|
cdb[10] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SPEEDREAD took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SPEEDREAD took {0} ms.", duration);
|
||||||
@@ -445,7 +433,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -453,7 +440,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = (byte)buffer.Length;
|
cdb[9] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SINGLE-SESSION / HIDE CD-R took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SINGLE-SESSION / HIDE CD-R took {0} ms.", duration);
|
||||||
@@ -476,7 +463,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -487,7 +473,7 @@ namespace DiscImageChef.Devices
|
|||||||
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
|
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET BOOK BITSETTING took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET BOOK BITSETTING took {0} ms.", duration);
|
||||||
@@ -509,7 +495,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
cdb[0] = (byte)ScsiCommands.PlextorExtend;
|
||||||
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
cdb[1] = (byte)PlextorSubCommands.GetMode;
|
||||||
@@ -517,7 +502,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[10] = (byte)buffer.Length;
|
cdb[10] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET TEST WRITE DVD+ took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET TEST WRITE DVD+ took {0} ms.", duration);
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read6;
|
cdb[0] = (byte)ScsiCommands.Read6;
|
||||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||||
@@ -81,7 +80,7 @@ namespace DiscImageChef.Devices
|
|||||||
else buffer = new byte[transferLength * blockSize];
|
else buffer = new byte[transferLength * blockSize];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
|
||||||
@@ -112,7 +111,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read10;
|
cdb[0] = (byte)ScsiCommands.Read10;
|
||||||
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
||||||
@@ -131,7 +129,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[transferLength * blockSize];
|
buffer = new byte[transferLength * blockSize];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ (10) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ (10) took {0} ms.", duration);
|
||||||
@@ -163,7 +161,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read12;
|
cdb[0] = (byte)ScsiCommands.Read12;
|
||||||
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
cdb[1] = (byte)((rdprotect & 0x07) << 5);
|
||||||
@@ -185,7 +182,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[transferLength * blockSize];
|
buffer = new byte[transferLength * blockSize];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ (12) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ (12) took {0} ms.", duration);
|
||||||
@@ -216,7 +213,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[16];
|
byte[] cdb = new byte[16];
|
||||||
bool sense;
|
|
||||||
byte[] lbaBytes = BitConverter.GetBytes(lba);
|
byte[] lbaBytes = BitConverter.GetBytes(lba);
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read16;
|
cdb[0] = (byte)ScsiCommands.Read16;
|
||||||
@@ -242,7 +238,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[transferLength * blockSize];
|
buffer = new byte[transferLength * blockSize];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
|
||||||
@@ -267,7 +263,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadLong;
|
cdb[0] = (byte)ScsiCommands.ReadLong;
|
||||||
if(correct) cdb[1] += 0x02;
|
if(correct) cdb[1] += 0x02;
|
||||||
@@ -282,7 +277,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[transferBytes];
|
buffer = new byte[transferBytes];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (10) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (10) took {0} ms.", duration);
|
||||||
@@ -306,7 +301,6 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[16];
|
byte[] cdb = new byte[16];
|
||||||
bool sense;
|
|
||||||
byte[] lbaBytes = BitConverter.GetBytes(lba);
|
byte[] lbaBytes = BitConverter.GetBytes(lba);
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
|
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
|
||||||
@@ -326,7 +320,7 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[transferBytes];
|
buffer = new byte[transferBytes];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (16) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (16) took {0} ms.", duration);
|
||||||
@@ -346,7 +340,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Seek6;
|
cdb[0] = (byte)ScsiCommands.Seek6;
|
||||||
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||||
@@ -354,7 +347,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[3] = (byte)(lba & 0xFF);
|
cdb[3] = (byte)(lba & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "SEEK (6) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "SEEK (6) took {0} ms.", duration);
|
||||||
@@ -374,7 +367,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Seek10;
|
cdb[0] = (byte)ScsiCommands.Seek10;
|
||||||
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
|
||||||
@@ -383,7 +375,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[5] = (byte)(lba & 0xFF);
|
cdb[5] = (byte)(lba & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "SEEK (10) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "SEEK (10) took {0} ms.", duration);
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[256];
|
buffer = new byte[256];
|
||||||
byte[] cdb = new byte[16];
|
byte[] cdb = new byte[16];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadAttribute;
|
cdb[0] = (byte)ScsiCommands.ReadAttribute;
|
||||||
cdb[1] = (byte)((byte)action & 0x1F);
|
cdb[1] = (byte)((byte)action & 0x1F);
|
||||||
@@ -75,7 +74,7 @@ namespace DiscImageChef.Devices
|
|||||||
if(cache) cdb[14] += 0x01;
|
if(cache) cdb[14] += 0x01;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
|
|||||||
@@ -31,11 +31,13 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using PlatformID = DiscImageChef.Interop.PlatformID;
|
using PlatformID = DiscImageChef.Interop.PlatformID;
|
||||||
|
|
||||||
namespace DiscImageChef.Devices
|
namespace DiscImageChef.Devices
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
public partial class Device
|
public partial class Device
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -70,8 +72,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, uint timeout)
|
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, uint timeout)
|
||||||
{
|
{
|
||||||
double duration;
|
return ScsiInquiry(out buffer, out senseBuffer, timeout, out _);
|
||||||
return ScsiInquiry(out buffer, out senseBuffer, timeout, out duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -87,10 +88,9 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[36];
|
buffer = new byte[36];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = {(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0};
|
byte[] cdb = {(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -145,8 +145,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// <param name="page">The Extended Vital Product Data</param>
|
/// <param name="page">The Extended Vital Product Data</param>
|
||||||
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, byte page, uint timeout)
|
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, byte page, uint timeout)
|
||||||
{
|
{
|
||||||
double duration;
|
return ScsiInquiry(out buffer, out senseBuffer, page, timeout, out _);
|
||||||
return ScsiInquiry(out buffer, out senseBuffer, page, timeout, out duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -163,10 +162,9 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[36];
|
buffer = new byte[36];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = {(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0};
|
byte[] cdb = {(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0};
|
||||||
bool sense;
|
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -200,11 +198,10 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
|
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
|
||||||
bool sense;
|
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "TEST UNIT READY took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "TEST UNIT READY took {0} ms.", duration);
|
||||||
@@ -262,7 +259,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
buffer = new byte[255];
|
buffer = new byte[255];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ModeSense;
|
cdb[0] = (byte)ScsiCommands.ModeSense;
|
||||||
if(dbd) cdb[1] = 0x08;
|
if(dbd) cdb[1] = 0x08;
|
||||||
@@ -273,7 +269,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[5] = 0;
|
cdb[5] = 0;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -349,7 +345,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
buffer = new byte[4096];
|
buffer = new byte[4096];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ModeSense10;
|
cdb[0] = (byte)ScsiCommands.ModeSense10;
|
||||||
if(llbaa) cdb[1] |= 0x10;
|
if(llbaa) cdb[1] |= 0x10;
|
||||||
@@ -362,7 +357,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = 0;
|
cdb[9] = 0;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -437,14 +432,13 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
bool sense;
|
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||||
cdb[4] = (byte)((byte)preventMode & 0x03);
|
cdb[4] = (byte)((byte)preventMode & 0x03);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
|
||||||
@@ -482,7 +476,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
buffer = new byte[8];
|
buffer = new byte[8];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadCapacity;
|
cdb[0] = (byte)ScsiCommands.ReadCapacity;
|
||||||
|
|
||||||
@@ -498,7 +491,7 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY took {0} ms.", duration);
|
||||||
@@ -535,7 +528,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[16];
|
byte[] cdb = new byte[16];
|
||||||
buffer = new byte[32];
|
buffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
|
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
|
||||||
cdb[1] = (byte)ScsiServiceActions.ReadCapacity16;
|
cdb[1] = (byte)ScsiServiceActions.ReadCapacity16;
|
||||||
@@ -560,7 +552,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[13] = (byte)(buffer.Length & 0xFF);
|
cdb[13] = (byte)(buffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY(16) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY(16) took {0} ms.", duration);
|
||||||
@@ -581,7 +573,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[12];
|
byte[] cdb = new byte[12];
|
||||||
buffer = new byte[4];
|
buffer = new byte[4];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadSerialNumber;
|
cdb[0] = (byte)ScsiCommands.ReadSerialNumber;
|
||||||
cdb[1] = 0x01;
|
cdb[1] = 0x01;
|
||||||
@@ -591,7 +582,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[9] = (byte)(buffer.Length & 0xFF);
|
cdb[9] = (byte)(buffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -748,7 +739,6 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ModeSelect;
|
cdb[0] = (byte)ScsiCommands.ModeSelect;
|
||||||
if(pageFormat) cdb[1] += 0x10;
|
if(pageFormat) cdb[1] += 0x10;
|
||||||
@@ -756,7 +746,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = (byte)buffer.Length;
|
cdb[4] = (byte)buffer.Length;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(6) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(6) took {0} ms.", duration);
|
||||||
@@ -793,7 +783,6 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ModeSelect10;
|
cdb[0] = (byte)ScsiCommands.ModeSelect10;
|
||||||
if(pageFormat) cdb[1] += 0x10;
|
if(pageFormat) cdb[1] += 0x10;
|
||||||
@@ -802,7 +791,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(10) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(10) took {0} ms.", duration);
|
||||||
@@ -817,10 +806,8 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
public bool RequestSense(bool descriptor, out byte[] buffer, uint timeout, out double duration)
|
public bool RequestSense(bool descriptor, out byte[] buffer, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] senseBuffer = new byte[32];
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
buffer = new byte[252];
|
buffer = new byte[252];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.RequestSense;
|
cdb[0] = (byte)ScsiCommands.RequestSense;
|
||||||
if(descriptor) cdb[1] = 0x01;
|
if(descriptor) cdb[1] = 0x01;
|
||||||
@@ -829,8 +816,8 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = (byte)buffer.Length;
|
cdb[4] = (byte)buffer.Length;
|
||||||
cdb[5] = 0;
|
cdb[5] = 0;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out _, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "REQUEST SENSE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "REQUEST SENSE took {0} ms.", duration);
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.LoadUnload;
|
cdb[0] = (byte)ScsiCommands.LoadUnload;
|
||||||
if(immediate) cdb[1] = 0x01;
|
if(immediate) cdb[1] = 0x01;
|
||||||
@@ -89,7 +88,7 @@ namespace DiscImageChef.Devices
|
|||||||
if(hold) cdb[4] += 0x08;
|
if(hold) cdb[4] += 0x08;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "LOAD UNLOAD (6) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "LOAD UNLOAD (6) took {0} ms.", duration);
|
||||||
@@ -167,7 +166,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Locate;
|
cdb[0] = (byte)ScsiCommands.Locate;
|
||||||
if(immediate) cdb[1] += 0x01;
|
if(immediate) cdb[1] += 0x01;
|
||||||
@@ -180,7 +178,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[8] = partition;
|
cdb[8] = partition;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (10) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (10) took {0} ms.", duration);
|
||||||
@@ -263,7 +261,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[16];
|
byte[] cdb = new byte[16];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
byte[] idBytes = BitConverter.GetBytes(identifier);
|
byte[] idBytes = BitConverter.GetBytes(identifier);
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Locate16;
|
cdb[0] = (byte)ScsiCommands.Locate16;
|
||||||
@@ -283,7 +280,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[11] = idBytes[0];
|
cdb[11] = idBytes[0];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (16) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (16) took {0} ms.", duration);
|
||||||
@@ -335,11 +332,9 @@ namespace DiscImageChef.Devices
|
|||||||
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, uint transferLen,
|
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, uint transferLen,
|
||||||
uint blockSize, uint timeout, out double duration)
|
uint blockSize, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(fixedLen) buffer = new byte[blockSize * transferLen];
|
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
||||||
else buffer = new byte[transferLen];
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read6;
|
cdb[0] = (byte)ScsiCommands.Read6;
|
||||||
if(fixedLen) cdb[1] += 0x01;
|
if(fixedLen) cdb[1] += 0x01;
|
||||||
@@ -349,7 +344,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = (byte)(transferLen & 0xFF);
|
cdb[4] = (byte)(transferLen & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
|
||||||
@@ -445,11 +440,9 @@ namespace DiscImageChef.Devices
|
|||||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, byte partition,
|
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, byte partition,
|
||||||
ulong objectId, uint transferLen, uint objectSize, uint timeout, out double duration)
|
ulong objectId, uint transferLen, uint objectSize, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(fixedLen) buffer = new byte[objectSize * transferLen];
|
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
|
||||||
else buffer = new byte[transferLen];
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
byte[] idBytes = BitConverter.GetBytes(objectId);
|
byte[] idBytes = BitConverter.GetBytes(objectId);
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read16;
|
cdb[0] = (byte)ScsiCommands.Read16;
|
||||||
@@ -469,7 +462,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[14] = (byte)(transferLen & 0xFF);
|
cdb[14] = (byte)(transferLen & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
|
||||||
@@ -489,12 +482,11 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[6];
|
buffer = new byte[6];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadBlockLimits;
|
cdb[0] = (byte)ScsiCommands.ReadBlockLimits;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ BLOCK LIMITS took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ BLOCK LIMITS took {0} ms.", duration);
|
||||||
@@ -580,7 +572,6 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadPosition;
|
cdb[0] = (byte)ScsiCommands.ReadPosition;
|
||||||
cdb[1] = (byte)((byte)responseForm & 0x1F);
|
cdb[1] = (byte)((byte)responseForm & 0x1F);
|
||||||
@@ -591,7 +582,7 @@ namespace DiscImageChef.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ POSITION took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ POSITION took {0} ms.", duration);
|
||||||
@@ -647,11 +638,9 @@ namespace DiscImageChef.Devices
|
|||||||
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili, bool fixedLen,
|
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili, bool fixedLen,
|
||||||
uint transferLen, uint blockSize, uint timeout, out double duration)
|
uint transferLen, uint blockSize, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(fixedLen) buffer = new byte[blockSize * transferLen];
|
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
||||||
else buffer = new byte[transferLen];
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReadReverse;
|
cdb[0] = (byte)ScsiCommands.ReadReverse;
|
||||||
if(fixedLen) cdb[1] += 0x01;
|
if(fixedLen) cdb[1] += 0x01;
|
||||||
@@ -662,7 +651,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = (byte)(transferLen & 0xFF);
|
cdb[4] = (byte)(transferLen & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (6) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (6) took {0} ms.", duration);
|
||||||
@@ -760,11 +749,9 @@ namespace DiscImageChef.Devices
|
|||||||
byte partition, ulong objectId, uint transferLen, uint objectSize, uint timeout,
|
byte partition, ulong objectId, uint transferLen, uint objectSize, uint timeout,
|
||||||
out double duration)
|
out double duration)
|
||||||
{
|
{
|
||||||
if(fixedLen) buffer = new byte[objectSize * transferLen];
|
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
|
||||||
else buffer = new byte[transferLen];
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
byte[] idBytes = BitConverter.GetBytes(objectId);
|
byte[] idBytes = BitConverter.GetBytes(objectId);
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Read16;
|
cdb[0] = (byte)ScsiCommands.Read16;
|
||||||
@@ -785,7 +772,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[14] = (byte)(transferLen & 0xFF);
|
cdb[14] = (byte)(transferLen & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (16) took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "READ REVERSE (16) took {0} ms.", duration);
|
||||||
@@ -840,11 +827,9 @@ namespace DiscImageChef.Devices
|
|||||||
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
|
||||||
uint transferLen, uint blockSize, uint timeout, out double duration)
|
uint transferLen, uint blockSize, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
if(fixedLen) buffer = new byte[blockSize * transferLen];
|
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
|
||||||
else buffer = new byte[transferLen];
|
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.RecoverBufferedData;
|
cdb[0] = (byte)ScsiCommands.RecoverBufferedData;
|
||||||
if(fixedLen) cdb[1] += 0x01;
|
if(fixedLen) cdb[1] += 0x01;
|
||||||
@@ -854,7 +839,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = (byte)(transferLen & 0xFF);
|
cdb[4] = (byte)(transferLen & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "RECOVER BUFFERED DATA took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "RECOVER BUFFERED DATA took {0} ms.", duration);
|
||||||
@@ -903,7 +888,6 @@ namespace DiscImageChef.Devices
|
|||||||
buffer = new byte[256];
|
buffer = new byte[256];
|
||||||
byte[] cdb = new byte[10];
|
byte[] cdb = new byte[10];
|
||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.ReportDensitySupport;
|
cdb[0] = (byte)ScsiCommands.ReportDensitySupport;
|
||||||
if(currentMedia) cdb[1] += 0x01;
|
if(currentMedia) cdb[1] += 0x01;
|
||||||
@@ -912,7 +896,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
if(sense) return true;
|
if(sense) return true;
|
||||||
@@ -955,13 +939,12 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Rewind;
|
cdb[0] = (byte)ScsiCommands.Rewind;
|
||||||
if(immediate) cdb[1] += 0x01;
|
if(immediate) cdb[1] += 0x01;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "REWIND took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "REWIND took {0} ms.", duration);
|
||||||
@@ -982,13 +965,12 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.TrackSelect;
|
cdb[0] = (byte)ScsiCommands.TrackSelect;
|
||||||
cdb[5] = track;
|
cdb[5] = track;
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "TRACK SELECT took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "TRACK SELECT took {0} ms.", duration);
|
||||||
@@ -1001,7 +983,6 @@ namespace DiscImageChef.Devices
|
|||||||
senseBuffer = new byte[32];
|
senseBuffer = new byte[32];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
bool sense;
|
|
||||||
byte[] countB = BitConverter.GetBytes(count);
|
byte[] countB = BitConverter.GetBytes(count);
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Space;
|
cdb[0] = (byte)ScsiCommands.Space;
|
||||||
@@ -1011,7 +992,7 @@ namespace DiscImageChef.Devices
|
|||||||
cdb[4] = countB[0];
|
cdb[4] = countB[0];
|
||||||
|
|
||||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
|
||||||
out sense);
|
out bool sense);
|
||||||
Error = LastError != 0;
|
Error = LastError != 0;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SCSI Device", "SPACE took {0} ms.", duration);
|
DicConsole.DebugWriteLine("SCSI Device", "SPACE took {0} ms.", duration);
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ namespace DiscImageChef.Devices
|
|||||||
if(readLong) cdb[5] += 0x40;
|
if(readLong) cdb[5] += 0x40;
|
||||||
|
|
||||||
if(!inhibitDma && !readLong)
|
if(!inhibitDma && !readLong)
|
||||||
if(transferLength == 0) buffer = new byte[256 * blockSize];
|
buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize];
|
||||||
else buffer = new byte[transferLength * blockSize];
|
|
||||||
else if(readLong)
|
else if(readLong)
|
||||||
{
|
{
|
||||||
buffer = new byte[blockSize];
|
buffer = new byte[blockSize];
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
// ReSharper disable MemberCanBeInternal
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
namespace DiscImageChef.Devices
|
namespace DiscImageChef.Devices
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.Decoders.ATA;
|
||||||
@@ -39,6 +40,7 @@ using static DiscImageChef.Devices.FreeBSD.Extern;
|
|||||||
|
|
||||||
namespace DiscImageChef.Devices.FreeBSD
|
namespace DiscImageChef.Devices.FreeBSD
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("ReSharper", "BitwiseOperatorOnEnumWithoutFlags")]
|
||||||
static class Command
|
static class Command
|
||||||
{
|
{
|
||||||
const int CAM_MAX_CDBLEN = 16;
|
const int CAM_MAX_CDBLEN = 16;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
//
|
//
|
||||||
// --[ Description ] ----------------------------------------------------------
|
// --[ Description ] ----------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Contains structures necessary for directly interfacing devices under
|
// Contains [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] structures necessary for directly interfacing devices under
|
||||||
// FreeBSD.
|
// FreeBSD.
|
||||||
//
|
//
|
||||||
// --[ License ] --------------------------------------------------------------
|
// --[ License ] --------------------------------------------------------------
|
||||||
@@ -32,15 +32,18 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using lun_id_t = System.UInt32;
|
using lun_id_t = System.UInt32;
|
||||||
using path_id_t = System.UInt32;
|
using path_id_t = System.UInt32;
|
||||||
using target_id_t = System.UInt32;
|
using target_id_t = System.UInt32;
|
||||||
|
#pragma warning disable 649
|
||||||
|
#pragma warning disable 169
|
||||||
|
|
||||||
namespace DiscImageChef.Devices.FreeBSD
|
namespace DiscImageChef.Devices.FreeBSD
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct AtaCmd
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct AtaCmd
|
||||||
{
|
{
|
||||||
public CamAtaIoFlags flags;
|
public CamAtaIoFlags flags;
|
||||||
public byte command;
|
public byte command;
|
||||||
@@ -59,7 +62,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct AtaRes
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct AtaRes
|
||||||
{
|
{
|
||||||
public CamAtaIoFlags flags;
|
public CamAtaIoFlags flags;
|
||||||
public byte status;
|
public byte status;
|
||||||
@@ -76,14 +79,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CamPinfo
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CamPinfo
|
||||||
{
|
{
|
||||||
public uint priority;
|
public uint priority;
|
||||||
public uint generation;
|
public uint generation;
|
||||||
public int index;
|
public int index;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ListEntry
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct ListEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// LIST_ENTRY(ccb_hdr)=le->*le_next
|
/// LIST_ENTRY(ccb_hdr)=le->*le_next
|
||||||
@@ -95,7 +98,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public IntPtr LePrev;
|
public IntPtr LePrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SlistEntry
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct SlistEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SLIST_ENTRY(ccb_hdr)=sle->*sle_next
|
/// SLIST_ENTRY(ccb_hdr)=sle->*sle_next
|
||||||
@@ -103,7 +106,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public IntPtr SleNext;
|
public IntPtr SleNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TailqEntry
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct TailqEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TAILQ_ENTRY(ccb_hdr)=tqe->*tqe_next
|
/// TAILQ_ENTRY(ccb_hdr)=tqe->*tqe_next
|
||||||
@@ -115,7 +118,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public IntPtr TqePrev;
|
public IntPtr TqePrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StailqEntry
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct StailqEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// STAILQ_ENTRY(ccb_hdr)=stqe->*stqe_next
|
/// STAILQ_ENTRY(ccb_hdr)=stqe->*stqe_next
|
||||||
@@ -124,7 +127,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
struct CamqEntry
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CamqEntry
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public ListEntry le;
|
[FieldOffset(0)] public ListEntry le;
|
||||||
[FieldOffset(0)] public SlistEntry sle;
|
[FieldOffset(0)] public SlistEntry sle;
|
||||||
@@ -133,7 +136,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct Timeval
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct Timeval
|
||||||
{
|
{
|
||||||
public long tv_sec;
|
public long tv_sec;
|
||||||
/// <summary>long</summary>
|
/// <summary>long</summary>
|
||||||
@@ -141,7 +144,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbQosArea
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbQosArea
|
||||||
{
|
{
|
||||||
public Timeval etime;
|
public Timeval etime;
|
||||||
public UIntPtr sim_data;
|
public UIntPtr sim_data;
|
||||||
@@ -149,7 +152,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbHdr
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbHdr
|
||||||
{
|
{
|
||||||
public CamPinfo pinfo;
|
public CamPinfo pinfo;
|
||||||
public CamqEntry xpt_links;
|
public CamqEntry xpt_links;
|
||||||
@@ -173,7 +176,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct ScsiSenseData
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct ScsiSenseData
|
||||||
{
|
{
|
||||||
const int SSD_FULL_SIZE = 252;
|
const int SSD_FULL_SIZE = 252;
|
||||||
public byte error_code;
|
public byte error_code;
|
||||||
@@ -184,7 +187,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbScsiio
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbScsiio
|
||||||
{
|
{
|
||||||
public CcbHdr ccb_h;
|
public CcbHdr ccb_h;
|
||||||
/// <summary>Ptr for next CCB for action</summary>
|
/// <summary>Ptr for next CCB for action</summary>
|
||||||
@@ -230,7 +233,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
/// SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO function codes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbScsiio64
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbScsiio64
|
||||||
{
|
{
|
||||||
public CcbHdr ccb_h;
|
public CcbHdr ccb_h;
|
||||||
/// <summary>Ptr for next CCB for action</summary>
|
/// <summary>Ptr for next CCB for action</summary>
|
||||||
@@ -277,7 +280,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
/// ATA I/O Request CCB used for the XPT_ATA_IO function code.
|
/// ATA I/O Request CCB used for the XPT_ATA_IO function code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbAtaio
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbAtaio
|
||||||
{
|
{
|
||||||
public CcbHdr ccb_h;
|
public CcbHdr ccb_h;
|
||||||
/// <summary>Ptr for next CCB for action</summary>
|
/// <summary>Ptr for next CCB for action</summary>
|
||||||
@@ -299,7 +302,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct NvmeCommand
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct NvmeCommand
|
||||||
{
|
{
|
||||||
ushort opc_fuse_rsvd1;
|
ushort opc_fuse_rsvd1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -370,7 +373,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct NvmeStatus
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct NvmeStatus
|
||||||
{
|
{
|
||||||
ushort status;
|
ushort status;
|
||||||
|
|
||||||
@@ -406,7 +409,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct NvmeCompletion
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct NvmeCompletion
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// command-specific
|
/// command-specific
|
||||||
@@ -440,7 +443,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
/// NVMe I/O Request CCB used for the XPT_NVME_IO and XPT_NVME_ADMIN function codes.
|
/// NVMe I/O Request CCB used for the XPT_NVME_IO and XPT_NVME_ADMIN function codes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbNvmeio
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbNvmeio
|
||||||
{
|
{
|
||||||
public CcbHdr ccb_h;
|
public CcbHdr ccb_h;
|
||||||
/// <summary>Ptr for next CCB for action</summary>
|
/// <summary>Ptr for next CCB for action</summary>
|
||||||
@@ -460,7 +463,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct PeriphMatchPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct PeriphMatchPattern
|
||||||
{
|
{
|
||||||
const int DEV_IDLEN = 16;
|
const int DEV_IDLEN = 16;
|
||||||
|
|
||||||
@@ -473,14 +476,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct DeviceIdMatchPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct DeviceIdMatchPattern
|
||||||
{
|
{
|
||||||
public byte id_len;
|
public byte id_len;
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] id;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public byte[] id;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct ScsiStaticInquiryPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct ScsiStaticInquiryPattern
|
||||||
{
|
{
|
||||||
const int SID_VENDOR_SIZE = 8;
|
const int SID_VENDOR_SIZE = 8;
|
||||||
const int SID_PRODUCT_SIZE = 16;
|
const int SID_PRODUCT_SIZE = 16;
|
||||||
@@ -493,14 +496,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
struct DeviceMatchPatternData
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct DeviceMatchPatternData
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public ScsiStaticInquiryPattern inq_pat;
|
[FieldOffset(0)] public ScsiStaticInquiryPattern inq_pat;
|
||||||
[FieldOffset(0)] public DeviceIdMatchPattern devid_pat;
|
[FieldOffset(0)] public DeviceIdMatchPattern devid_pat;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct DeviceMatchPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct DeviceMatchPattern
|
||||||
{
|
{
|
||||||
public path_id_t path_id;
|
public path_id_t path_id;
|
||||||
public target_id_t target_id;
|
public target_id_t target_id;
|
||||||
@@ -510,7 +513,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct BusMatchPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct BusMatchPattern
|
||||||
{
|
{
|
||||||
const int DEV_IDLEN = 16;
|
const int DEV_IDLEN = 16;
|
||||||
|
|
||||||
@@ -522,7 +525,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
struct MatchPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct MatchPattern
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public PeriphMatchPattern periph_pattern;
|
[FieldOffset(0)] public PeriphMatchPattern periph_pattern;
|
||||||
[FieldOffset(0)] public DeviceMatchPattern device_pattern;
|
[FieldOffset(0)] public DeviceMatchPattern device_pattern;
|
||||||
@@ -530,14 +533,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct DevMatchPattern
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct DevMatchPattern
|
||||||
{
|
{
|
||||||
public DevMatchType type;
|
public DevMatchType type;
|
||||||
public MatchPattern pattern;
|
public MatchPattern pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct PeriphMatchResult
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct PeriphMatchResult
|
||||||
{
|
{
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] periph_name;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] periph_name;
|
||||||
public uint unit_number;
|
public uint unit_number;
|
||||||
@@ -547,7 +550,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct MmcCid
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct MmcCid
|
||||||
{
|
{
|
||||||
public uint mid;
|
public uint mid;
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] pnm;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] pnm;
|
||||||
@@ -560,7 +563,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct MmcParams
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct MmcParams
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Card model
|
/// Card model
|
||||||
@@ -606,7 +609,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct DeviceMatchResult
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct DeviceMatchResult
|
||||||
{
|
{
|
||||||
public path_id_t path_id;
|
public path_id_t path_id;
|
||||||
public target_id_t target_id;
|
public target_id_t target_id;
|
||||||
@@ -619,7 +622,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct BusMatchResult
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct BusMatchResult
|
||||||
{
|
{
|
||||||
public path_id_t path_id;
|
public path_id_t path_id;
|
||||||
const int DEV_IDLEN = 16;
|
const int DEV_IDLEN = 16;
|
||||||
@@ -629,7 +632,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
struct MatchResult
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct MatchResult
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public PeriphMatchResult periph_result;
|
[FieldOffset(0)] public PeriphMatchResult periph_result;
|
||||||
[FieldOffset(0)] public DeviceMatchResult device_result;
|
[FieldOffset(0)] public DeviceMatchResult device_result;
|
||||||
@@ -637,14 +640,14 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct DevMatchResult
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct DevMatchResult
|
||||||
{
|
{
|
||||||
public DevMatchType type;
|
public DevMatchType type;
|
||||||
public MatchResult result;
|
public MatchResult result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbDmCookie
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbDmCookie
|
||||||
{
|
{
|
||||||
public IntPtr bus;
|
public IntPtr bus;
|
||||||
public IntPtr target;
|
public IntPtr target;
|
||||||
@@ -654,7 +657,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbDevPosition
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbDevPosition
|
||||||
{
|
{
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public CamGenerations[] generations;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public CamGenerations[] generations;
|
||||||
DevPosType position_type;
|
DevPosType position_type;
|
||||||
@@ -662,7 +665,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbDevMatch
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbDevMatch
|
||||||
{
|
{
|
||||||
public CcbHdr ccb_h;
|
public CcbHdr ccb_h;
|
||||||
CcbDevMatchStatus status;
|
CcbDevMatchStatus status;
|
||||||
@@ -685,6 +688,8 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
public CcbDevPosition pos;
|
public CcbDevPosition pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
|
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
|
||||||
struct CamDevice
|
struct CamDevice
|
||||||
{
|
{
|
||||||
const int MAXPATHLEN = 1024;
|
const int MAXPATHLEN = 1024;
|
||||||
@@ -769,7 +774,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct CcbGetdev
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] struct CcbGetdev
|
||||||
{
|
{
|
||||||
public CcbHdr ccb_h;
|
public CcbHdr ccb_h;
|
||||||
public CamProto protocol;
|
public CamProto protocol;
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
|
|
||||||
sense |= (ioHdr.info & SgInfo.OkMask) != SgInfo.Ok;
|
sense |= (ioHdr.info & SgInfo.OkMask) != SgInfo.Ok;
|
||||||
|
|
||||||
if(ioHdr.duration > 0) duration = ioHdr.duration;
|
duration = ioHdr.duration > 0 ? ioHdr.duration : (end - start).TotalMilliseconds;
|
||||||
else duration = (end - start).TotalMilliseconds;
|
|
||||||
|
|
||||||
Marshal.FreeHGlobal(ioHdr.dxferp);
|
Marshal.FreeHGlobal(ioHdr.dxferp);
|
||||||
Marshal.FreeHGlobal(ioHdr.cmdp);
|
Marshal.FreeHGlobal(ioHdr.cmdp);
|
||||||
@@ -162,8 +161,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
cdb[13] = registers.DeviceHead;
|
cdb[13] = registers.DeviceHead;
|
||||||
cdb[14] = registers.Command;
|
cdb[14] = registers.Command;
|
||||||
|
|
||||||
byte[] senseBuffer;
|
int error = SendScsiCommand(fd, cdb, ref buffer, out byte[] senseBuffer, timeout,
|
||||||
int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout,
|
|
||||||
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
||||||
|
|
||||||
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
|
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
|
||||||
@@ -224,8 +222,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
cdb[13] = registers.DeviceHead;
|
cdb[13] = registers.DeviceHead;
|
||||||
cdb[14] = registers.Command;
|
cdb[14] = registers.Command;
|
||||||
|
|
||||||
byte[] senseBuffer;
|
int error = SendScsiCommand(fd, cdb, ref buffer, out byte[] senseBuffer, timeout,
|
||||||
int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout,
|
|
||||||
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
||||||
|
|
||||||
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
|
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
|
||||||
@@ -292,8 +289,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
cdb[13] = registers.DeviceHead;
|
cdb[13] = registers.DeviceHead;
|
||||||
cdb[14] = registers.Command;
|
cdb[14] = registers.Command;
|
||||||
|
|
||||||
byte[] senseBuffer;
|
int error = SendScsiCommand(fd, cdb, ref buffer, out byte[] senseBuffer, timeout,
|
||||||
int error = SendScsiCommand(fd, cdb, ref buffer, out senseBuffer, timeout,
|
|
||||||
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
||||||
|
|
||||||
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
|
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error;
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
DeviceInfo[] devices = new DeviceInfo[sysdevs.Length];
|
DeviceInfo[] devices = new DeviceInfo[sysdevs.Length];
|
||||||
bool hasUdev;
|
bool hasUdev;
|
||||||
|
|
||||||
StreamReader sr;
|
|
||||||
IntPtr udev = IntPtr.Zero;
|
IntPtr udev = IntPtr.Zero;
|
||||||
IntPtr udevDev;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -59,13 +57,12 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
|
|
||||||
for(int i = 0; i < sysdevs.Length; i++)
|
for(int i = 0; i < sysdevs.Length; i++)
|
||||||
{
|
{
|
||||||
devices[i] = new DeviceInfo();
|
devices[i] = new DeviceInfo {Path = "/dev/" + Path.GetFileName(sysdevs[i])};
|
||||||
devices[i].Path = "/dev/" + Path.GetFileName(sysdevs[i]);
|
|
||||||
|
|
||||||
if(hasUdev)
|
if(hasUdev)
|
||||||
{
|
{
|
||||||
udevDev = Extern.udev_device_new_from_subsystem_sysname(udev, "block",
|
IntPtr udevDev = Extern.udev_device_new_from_subsystem_sysname(udev, "block",
|
||||||
Path.GetFileName(sysdevs[i]));
|
Path.GetFileName(sysdevs[i]));
|
||||||
devices[i].Vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR");
|
devices[i].Vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR");
|
||||||
devices[i].Model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
|
devices[i].Model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
|
||||||
if(!string.IsNullOrEmpty(devices[i].Model)) devices[i].Model = devices[i].Model.Replace('_', ' ');
|
if(!string.IsNullOrEmpty(devices[i].Model)) devices[i].Model = devices[i].Model.Replace('_', ' ');
|
||||||
@@ -75,10 +72,11 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
devices[i].Bus = Extern.udev_device_get_property_value(udevDev, "ID_BUS");
|
devices[i].Bus = Extern.udev_device_get_property_value(udevDev, "ID_BUS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StreamReader sr;
|
||||||
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].Vendor))
|
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].Vendor))
|
||||||
{
|
{
|
||||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
|
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
|
||||||
devices[i].Vendor = sr.ReadLine().Trim();
|
devices[i].Vendor = sr.ReadLine()?.Trim();
|
||||||
}
|
}
|
||||||
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
||||||
devices[i].Vendor = "Linux";
|
devices[i].Vendor = "Linux";
|
||||||
@@ -87,7 +85,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
(string.IsNullOrEmpty(devices[i].Model) || devices[i].Bus == "ata"))
|
(string.IsNullOrEmpty(devices[i].Model) || devices[i].Bus == "ata"))
|
||||||
{
|
{
|
||||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/model"), Encoding.ASCII);
|
sr = new StreamReader(Path.Combine(sysdevs[i], "device/model"), Encoding.ASCII);
|
||||||
devices[i].Model = sr.ReadLine().Trim();
|
devices[i].Model = sr.ReadLine()?.Trim();
|
||||||
}
|
}
|
||||||
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
||||||
devices[i].Model = "Linux";
|
devices[i].Model = "Linux";
|
||||||
@@ -95,7 +93,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].Serial))
|
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].Serial))
|
||||||
{
|
{
|
||||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
|
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
|
||||||
devices[i].Serial = sr.ReadLine().Trim();
|
devices[i].Serial = sr.ReadLine()?.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(devices[i].Vendor) || devices[i].Vendor == "ATA")
|
if(string.IsNullOrEmpty(devices[i].Vendor) || devices[i].Vendor == "ATA")
|
||||||
|
|||||||
@@ -32,11 +32,13 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DiscImageChef.Devices.Linux
|
namespace DiscImageChef.Devices.Linux
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct SgIoHdrT
|
struct SgIoHdrT
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -67,6 +69,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct MmcIocCmd
|
struct MmcIocCmd
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.Decoders.ATA;
|
||||||
@@ -39,6 +40,7 @@ using Microsoft.Win32.SafeHandles;
|
|||||||
|
|
||||||
namespace DiscImageChef.Devices.Windows
|
namespace DiscImageChef.Devices.Windows
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
|
||||||
static class Command
|
static class Command
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -63,19 +65,23 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
|
|
||||||
if(buffer == null) return -1;
|
if(buffer == null) return -1;
|
||||||
|
|
||||||
ScsiPassThroughDirectAndSenseBuffer sptdSb = new ScsiPassThroughDirectAndSenseBuffer();
|
ScsiPassThroughDirectAndSenseBuffer sptdSb = new ScsiPassThroughDirectAndSenseBuffer
|
||||||
sptdSb.sptd = new ScsiPassThroughDirect();
|
{
|
||||||
sptdSb.SenseBuf = new byte[32];
|
SenseBuf = new byte[32],
|
||||||
sptdSb.sptd.Cdb = new byte[16];
|
sptd = new ScsiPassThroughDirect
|
||||||
Array.Copy(cdb, sptdSb.sptd.Cdb, cdb.Length);
|
{
|
||||||
|
Cdb = new byte[16],
|
||||||
|
CdbLength = (byte)cdb.Length,
|
||||||
|
SenseInfoLength = 32,
|
||||||
|
DataIn = direction,
|
||||||
|
DataTransferLength = (uint)buffer.Length,
|
||||||
|
TimeOutValue = timeout,
|
||||||
|
DataBuffer = Marshal.AllocHGlobal(buffer.Length)
|
||||||
|
}
|
||||||
|
};
|
||||||
sptdSb.sptd.Length = (ushort)Marshal.SizeOf(sptdSb.sptd);
|
sptdSb.sptd.Length = (ushort)Marshal.SizeOf(sptdSb.sptd);
|
||||||
sptdSb.sptd.CdbLength = (byte)cdb.Length;
|
|
||||||
sptdSb.sptd.SenseInfoLength = (byte)sptdSb.SenseBuf.Length;
|
|
||||||
sptdSb.sptd.DataIn = direction;
|
|
||||||
sptdSb.sptd.DataTransferLength = (uint)buffer.Length;
|
|
||||||
sptdSb.sptd.TimeOutValue = timeout;
|
|
||||||
sptdSb.sptd.DataBuffer = Marshal.AllocHGlobal(buffer.Length);
|
|
||||||
sptdSb.sptd.SenseInfoOffset = (uint)Marshal.SizeOf(sptdSb.sptd);
|
sptdSb.sptd.SenseInfoOffset = (uint)Marshal.SizeOf(sptdSb.sptd);
|
||||||
|
Array.Copy(cdb, sptdSb.sptd.Cdb, cdb.Length);
|
||||||
|
|
||||||
uint k = 0;
|
uint k = 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@@ -454,8 +460,6 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
|
|
||||||
if(buffer == null) return -1;
|
if(buffer == null) return -1;
|
||||||
|
|
||||||
uint offsetForBuffer = (uint)(Marshal.SizeOf(typeof(AtaPassThroughDirect)) + Marshal.SizeOf(typeof(uint)));
|
|
||||||
|
|
||||||
IdePassThroughDirect iptd = new IdePassThroughDirect
|
IdePassThroughDirect iptd = new IdePassThroughDirect
|
||||||
{
|
{
|
||||||
CurrentTaskFile = new AtaTaskFile
|
CurrentTaskFile = new AtaTaskFile
|
||||||
@@ -504,10 +508,9 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static uint GetDeviceNumber(SafeFileHandle deviceHandle)
|
static uint GetDeviceNumber(SafeFileHandle deviceHandle)
|
||||||
{
|
{
|
||||||
StorageDeviceNumber sdn = new StorageDeviceNumber();
|
StorageDeviceNumber sdn = new StorageDeviceNumber {deviceNumber = -1};
|
||||||
sdn.deviceNumber = -1;
|
|
||||||
uint k = 0;
|
uint k = 0;
|
||||||
if(!Extern.DeviceIoControlGetDeviceNumber(deviceHandle, WindowsIoctl.IoctlStorageGetDeviceNumber,
|
if(!Extern.DeviceIoControlGetDeviceNumber(deviceHandle, WindowsIoctl.IoctlStorageGetDeviceNumber,
|
||||||
IntPtr.Zero, 0, ref sdn, (uint)Marshal.SizeOf(sdn), ref k,
|
IntPtr.Zero, 0, ref sdn, (uint)Marshal.SizeOf(sdn), ref k,
|
||||||
@@ -533,11 +536,9 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
DeviceInterfaceData spdid = new DeviceInterfaceData();
|
DeviceInterfaceData spdid = new DeviceInterfaceData();
|
||||||
spdid.cbSize = Marshal.SizeOf(spdid);
|
spdid.cbSize = Marshal.SizeOf(spdid);
|
||||||
|
|
||||||
byte[] buffer;
|
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
buffer = new byte[2048];
|
byte[] buffer = new byte[2048];
|
||||||
|
|
||||||
if(!Extern.SetupDiEnumDeviceInterfaces(hDevInfo, IntPtr.Zero, ref Consts.GuidDevinterfaceDisk, index,
|
if(!Extern.SetupDiEnumDeviceInterfaces(hDevInfo, IntPtr.Zero, ref Consts.GuidDevinterfaceDisk, index,
|
||||||
ref spdid)) break;
|
ref spdid)) break;
|
||||||
@@ -595,9 +596,8 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
{
|
{
|
||||||
SffdiskQueryDeviceProtocolData queryData1 = new SffdiskQueryDeviceProtocolData();
|
SffdiskQueryDeviceProtocolData queryData1 = new SffdiskQueryDeviceProtocolData();
|
||||||
queryData1.size = (ushort)Marshal.SizeOf(queryData1);
|
queryData1.size = (ushort)Marshal.SizeOf(queryData1);
|
||||||
uint bytesReturned;
|
|
||||||
Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskQueryDeviceProtocol, IntPtr.Zero, 0, ref queryData1,
|
Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskQueryDeviceProtocol, IntPtr.Zero, 0, ref queryData1,
|
||||||
queryData1.size, out bytesReturned, IntPtr.Zero);
|
queryData1.size, out _, IntPtr.Zero);
|
||||||
return queryData1.protocolGuid.Equals(Consts.GuidSffProtocolSd);
|
return queryData1.protocolGuid.Equals(Consts.GuidSffProtocolSd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,12 +660,11 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
Marshal.Copy(hBuf, commandB, 0, commandB.Length);
|
Marshal.Copy(hBuf, commandB, 0, commandB.Length);
|
||||||
Marshal.FreeHGlobal(hBuf);
|
Marshal.FreeHGlobal(hBuf);
|
||||||
|
|
||||||
uint bytesReturned;
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
DateTime start = DateTime.Now;
|
DateTime start = DateTime.Now;
|
||||||
sense = !Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB,
|
sense = !Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB,
|
||||||
(uint)commandB.Length, commandB, (uint)commandB.Length,
|
(uint)commandB.Length, commandB, (uint)commandB.Length,
|
||||||
out bytesReturned, IntPtr.Zero);
|
out _, IntPtr.Zero);
|
||||||
DateTime end = DateTime.Now;
|
DateTime end = DateTime.Now;
|
||||||
|
|
||||||
if(sense) error = Marshal.GetLastWin32Error();
|
if(sense) error = Marshal.GetLastWin32Error();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace DiscImageChef.Devices.Windows
|
namespace DiscImageChef.Devices.Windows
|
||||||
{
|
{
|
||||||
@@ -403,6 +404,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
Max = 3
|
Max = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
enum StorageBusType
|
enum StorageBusType
|
||||||
{
|
{
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
@@ -471,6 +473,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
MultiBlockNoCmd12
|
MultiBlockNoCmd12
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
enum SdResponseType : uint
|
enum SdResponseType : uint
|
||||||
{
|
{
|
||||||
Unspecified,
|
Unspecified,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -42,16 +43,17 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
{
|
{
|
||||||
static class ListDevices
|
static class ListDevices
|
||||||
{
|
{
|
||||||
internal static string HexStringToString(string hex)
|
static string HexStringToString(string hex)
|
||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
const string hextable = "0123456789abcdef";
|
const string HEXTABLE = "0123456789abcdef";
|
||||||
|
|
||||||
for(int i = 0; i < hex.Length / 2; i++) result.Append((char)(16 * hextable.IndexOf(hex[2 * i]) + hextable.IndexOf(hex[2 * i + 1])));
|
for(int i = 0; i < hex.Length / 2; i++) result.Append((char)(16 * HEXTABLE.IndexOf(hex[2 * i]) + HEXTABLE.IndexOf(hex[2 * i + 1])));
|
||||||
|
|
||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "RedundantCatchClause")]
|
||||||
internal static DeviceInfo[] GetList()
|
internal static DeviceInfo[] GetList()
|
||||||
{
|
{
|
||||||
List<string> deviceIDs = new List<string>();
|
List<string> deviceIDs = new List<string>();
|
||||||
@@ -74,7 +76,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
|
|
||||||
deviceIDs.AddRange(from ManagementObject drive in objCol select (string)drive["Drive"]);
|
deviceIDs.AddRange(from ManagementObject drive in objCol select (string)drive["Drive"]);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
throw;
|
throw;
|
||||||
@@ -94,10 +96,12 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
FileMode.OpenExisting, 0, IntPtr.Zero);
|
FileMode.OpenExisting, 0, IntPtr.Zero);
|
||||||
if(fd.IsInvalid) continue;
|
if(fd.IsInvalid) continue;
|
||||||
|
|
||||||
StoragePropertyQuery query = new StoragePropertyQuery();
|
StoragePropertyQuery query = new StoragePropertyQuery
|
||||||
query.PropertyId = StoragePropertyId.Device;
|
{
|
||||||
query.QueryType = StorageQueryType.Standard;
|
PropertyId = StoragePropertyId.Device,
|
||||||
query.AdditionalParameters = new byte[1];
|
QueryType = StorageQueryType.Standard,
|
||||||
|
AdditionalParameters = new byte[1]
|
||||||
|
};
|
||||||
|
|
||||||
//StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor();
|
//StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor();
|
||||||
//descriptor.RawDeviceProperties = new byte[16384];
|
//descriptor.RawDeviceProperties = new byte[16384];
|
||||||
@@ -118,19 +122,21 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
|
|
||||||
if(hasError && error != 0) continue;
|
if(hasError && error != 0) continue;
|
||||||
|
|
||||||
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor();
|
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor
|
||||||
descriptor.Version = BitConverter.ToUInt32(descriptorB, 0);
|
{
|
||||||
descriptor.Size = BitConverter.ToUInt32(descriptorB, 4);
|
Version = BitConverter.ToUInt32(descriptorB, 0),
|
||||||
descriptor.DeviceType = descriptorB[8];
|
Size = BitConverter.ToUInt32(descriptorB, 4),
|
||||||
descriptor.DeviceTypeModifier = descriptorB[9];
|
DeviceType = descriptorB[8],
|
||||||
descriptor.RemovableMedia = BitConverter.ToBoolean(descriptorB, 10);
|
DeviceTypeModifier = descriptorB[9],
|
||||||
descriptor.CommandQueueing = BitConverter.ToBoolean(descriptorB, 11);
|
RemovableMedia = BitConverter.ToBoolean(descriptorB, 10),
|
||||||
descriptor.VendorIdOffset = BitConverter.ToInt32(descriptorB, 12);
|
CommandQueueing = BitConverter.ToBoolean(descriptorB, 11),
|
||||||
descriptor.ProductIdOffset = BitConverter.ToInt32(descriptorB, 16);
|
VendorIdOffset = BitConverter.ToInt32(descriptorB, 12),
|
||||||
descriptor.ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20);
|
ProductIdOffset = BitConverter.ToInt32(descriptorB, 16),
|
||||||
descriptor.SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24);
|
ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20),
|
||||||
descriptor.BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28);
|
SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24),
|
||||||
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32);
|
BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28),
|
||||||
|
RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32)
|
||||||
|
};
|
||||||
|
|
||||||
DeviceInfo info = new DeviceInfo {Path = physId, Bus = descriptor.BusType.ToString()};
|
DeviceInfo info = new DeviceInfo {Path = physId, Bus = descriptor.BusType.ToString()};
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,13 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DiscImageChef.Devices.Windows
|
namespace DiscImageChef.Devices.Windows
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct ScsiPassThroughDirect
|
struct ScsiPassThroughDirect
|
||||||
{
|
{
|
||||||
public ushort Length;
|
public ushort Length;
|
||||||
@@ -62,6 +64,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct AtaPassThroughDirect
|
struct AtaPassThroughDirect
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -115,6 +118,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct AtaPassThroughDirectWithBuffer
|
struct AtaPassThroughDirectWithBuffer
|
||||||
{
|
{
|
||||||
public AtaPassThroughDirect aptd;
|
public AtaPassThroughDirect aptd;
|
||||||
@@ -123,6 +127,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct AtaTaskFile
|
struct AtaTaskFile
|
||||||
{
|
{
|
||||||
// Fields for commands sent
|
// Fields for commands sent
|
||||||
@@ -151,6 +156,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct StorageDescriptorHeader
|
struct StorageDescriptorHeader
|
||||||
{
|
{
|
||||||
public uint Version;
|
public uint Version;
|
||||||
@@ -193,6 +199,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct StorageDeviceNumber
|
struct StorageDeviceNumber
|
||||||
{
|
{
|
||||||
public int deviceType;
|
public int deviceType;
|
||||||
@@ -201,6 +208,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct DeviceInfoData
|
struct DeviceInfoData
|
||||||
{
|
{
|
||||||
public int cbSize;
|
public int cbSize;
|
||||||
@@ -210,6 +218,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct DeviceInterfaceData
|
struct DeviceInterfaceData
|
||||||
{
|
{
|
||||||
public int cbSize;
|
public int cbSize;
|
||||||
@@ -219,6 +228,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct UsbSetupPacket
|
struct UsbSetupPacket
|
||||||
{
|
{
|
||||||
public byte bmRequest;
|
public byte bmRequest;
|
||||||
@@ -229,6 +239,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct UsbDescriptorRequest
|
struct UsbDescriptorRequest
|
||||||
{
|
{
|
||||||
public int ConnectionIndex;
|
public int ConnectionIndex;
|
||||||
@@ -237,6 +248,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct SffdiskQueryDeviceProtocolData
|
struct SffdiskQueryDeviceProtocolData
|
||||||
{
|
{
|
||||||
public ushort size;
|
public ushort size;
|
||||||
@@ -245,6 +257,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
struct SffdiskDeviceCommandData
|
struct SffdiskDeviceCommandData
|
||||||
{
|
{
|
||||||
public ushort size;
|
public ushort size;
|
||||||
|
|||||||
@@ -28,18 +28,20 @@
|
|||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Copyright © 2011-2018 Natalia Portillo
|
// Copyright © 2011-2018 Natalia Portillo
|
||||||
|
// Copyright © 2007 Fort Hood TX, herethen, Public Domain
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
// Copyright "Fort Hood TX", internal domain, 2007
|
|
||||||
namespace DiscImageChef.Devices.Windows
|
namespace DiscImageChef.Devices.Windows
|
||||||
{
|
{
|
||||||
partial class Usb
|
// TODO: Even after cleaning, refactoring and xml-documenting, this code needs some love
|
||||||
|
static partial class Usb
|
||||||
{
|
{
|
||||||
#region "API Region"
|
#region "API Region"
|
||||||
// ********************** Constants ************************
|
// ********************** Constants ************************
|
||||||
@@ -276,6 +278,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
// UCHAR bNumConfigurations;
|
// UCHAR bNumConfigurations;
|
||||||
//} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR ;
|
//} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR ;
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||||
internal struct UsbDeviceDescriptor
|
internal struct UsbDeviceDescriptor
|
||||||
{
|
{
|
||||||
internal byte bLength;
|
internal byte bLength;
|
||||||
@@ -487,7 +490,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
//
|
//
|
||||||
// Return a list of USB Host Controllers
|
// Return a list of USB Host Controllers
|
||||||
//
|
//
|
||||||
static internal ReadOnlyCollection<UsbController> GetHostControllers()
|
static IEnumerable<UsbController> GetHostControllers()
|
||||||
{
|
{
|
||||||
List<UsbController> hostList = new List<UsbController>();
|
List<UsbController> hostList = new List<UsbController>();
|
||||||
Guid hostGuid = new Guid(GUID_DEVINTERFACE_HUBCONTROLLER);
|
Guid hostGuid = new Guid(GUID_DEVINTERFACE_HUBCONTROLLER);
|
||||||
@@ -503,8 +506,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UsbController host = new UsbController();
|
UsbController host = new UsbController {ControllerIndex = i};
|
||||||
host.ControllerIndex = i;
|
|
||||||
|
|
||||||
// create a Device Interface Data structure
|
// create a Device Interface Data structure
|
||||||
SpDeviceInterfaceData dia = new SpDeviceInterfaceData();
|
SpDeviceInterfaceData dia = new SpDeviceInterfaceData();
|
||||||
@@ -519,13 +521,14 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
da.cbSize = Marshal.SizeOf(da);
|
da.cbSize = Marshal.SizeOf(da);
|
||||||
|
|
||||||
// build a Device Interface Detail Data structure
|
// build a Device Interface Detail Data structure
|
||||||
SpDeviceInterfaceDetailData didd = new SpDeviceInterfaceDetailData();
|
SpDeviceInterfaceDetailData didd =
|
||||||
didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)
|
new SpDeviceInterfaceDetailData {cbSize = 4 + Marshal.SystemDefaultCharSize};
|
||||||
|
// trust me :)
|
||||||
|
|
||||||
// now we can get some more detailed information
|
// now we can get some more detailed information
|
||||||
int nRequiredSize = 0;
|
int nRequiredSize = 0;
|
||||||
int nBytes = BUFFER_SIZE;
|
const int N_BYTES = BUFFER_SIZE;
|
||||||
if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da))
|
if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, N_BYTES, ref nRequiredSize, ref da))
|
||||||
{
|
{
|
||||||
host.ControllerDevicePath = didd.DevicePath;
|
host.ControllerDevicePath = didd.DevicePath;
|
||||||
|
|
||||||
@@ -554,7 +557,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
//
|
//
|
||||||
// The USB Host Controller Class
|
// The USB Host Controller Class
|
||||||
//
|
//
|
||||||
internal class UsbController
|
class UsbController
|
||||||
{
|
{
|
||||||
internal int ControllerIndex;
|
internal int ControllerIndex;
|
||||||
internal string ControllerDriverKeyName, ControllerDevicePath, ControllerDeviceDesc;
|
internal string ControllerDriverKeyName, ControllerDevicePath, ControllerDeviceDesc;
|
||||||
@@ -569,50 +572,35 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the index of the instance
|
// Return the index of the instance
|
||||||
internal int Index
|
internal int Index => ControllerIndex;
|
||||||
{
|
|
||||||
get { return ControllerIndex; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the Device Path, such as "\\?\pci#ven_10de&dev_005a&subsys_815a1043&rev_a2#3&267a616a&0&58#{3abf6f2d-71c4-462a-8a92-1e6861e6af27}"
|
// Return the Device Path, such as "\\?\pci#ven_10de&dev_005a&subsys_815a1043&rev_a2#3&267a616a&0&58#{3abf6f2d-71c4-462a-8a92-1e6861e6af27}"
|
||||||
internal string DevicePath
|
internal string DevicePath => ControllerDevicePath;
|
||||||
{
|
|
||||||
get { return ControllerDevicePath; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// The DriverKeyName may be useful as a search key
|
// The DriverKeyName may be useful as a search key
|
||||||
internal string DriverKeyName
|
internal string DriverKeyName => ControllerDriverKeyName;
|
||||||
{
|
|
||||||
get { return ControllerDriverKeyName; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the Friendly Name, such as "VIA USB Enhanced Host Controller"
|
// Return the Friendly Name, such as "VIA USB Enhanced Host Controller"
|
||||||
internal string Name
|
internal string Name => ControllerDeviceDesc;
|
||||||
{
|
|
||||||
get { return ControllerDeviceDesc; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return Root Hub for this Controller
|
// Return Root Hub for this Controller
|
||||||
internal UsbHub GetRootHub()
|
internal UsbHub GetRootHub()
|
||||||
{
|
{
|
||||||
IntPtr h, h2;
|
IntPtr h, h2;
|
||||||
UsbHub root = new UsbHub();
|
UsbHub root = new UsbHub {HubIsRootHub = true, HubDeviceDesc = "Root Hub"};
|
||||||
root.HubIsRootHub = true;
|
|
||||||
root.HubDeviceDesc = "Root Hub";
|
|
||||||
|
|
||||||
// Open a handle to the Host Controller
|
// Open a handle to the Host Controller
|
||||||
h = CreateFile(ControllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
|
h = CreateFile(ControllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
|
||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
if(h.ToInt32() == INVALID_HANDLE_VALUE) return root;
|
if(h.ToInt32() == INVALID_HANDLE_VALUE) return root;
|
||||||
|
|
||||||
int nBytesReturned;
|
|
||||||
UsbRootHubName hubName = new UsbRootHubName();
|
UsbRootHubName hubName = new UsbRootHubName();
|
||||||
int nBytes = Marshal.SizeOf(hubName);
|
int nBytes = Marshal.SizeOf(hubName);
|
||||||
IntPtr ptrHubName = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrHubName = Marshal.AllocHGlobal(nBytes);
|
||||||
|
|
||||||
// get the Hub Name
|
// get the Hub Name
|
||||||
if(DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes,
|
if(DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes,
|
||||||
out nBytesReturned, IntPtr.Zero))
|
out _, IntPtr.Zero))
|
||||||
{
|
{
|
||||||
hubName = (UsbRootHubName)Marshal.PtrToStructure(ptrHubName, typeof(UsbRootHubName));
|
hubName = (UsbRootHubName)Marshal.PtrToStructure(ptrHubName, typeof(UsbRootHubName));
|
||||||
root.HubDevicePath = @"\\.\" + hubName.RootHubName;
|
root.HubDevicePath = @"\\.\" + hubName.RootHubName;
|
||||||
@@ -625,15 +613,14 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
if(h2.ToInt32() != INVALID_HANDLE_VALUE)
|
if(h2.ToInt32() != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
UsbNodeInformation nodeInfo = new UsbNodeInformation();
|
UsbNodeInformation nodeInfo = new UsbNodeInformation {NodeType = (int)UsbHubNode.UsbHub};
|
||||||
nodeInfo.NodeType = (int)UsbHubNode.UsbHub;
|
|
||||||
nBytes = Marshal.SizeOf(nodeInfo);
|
nBytes = Marshal.SizeOf(nodeInfo);
|
||||||
IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
|
||||||
Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
|
Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
|
||||||
|
|
||||||
// get the Hub Information
|
// get the Hub Information
|
||||||
if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
|
if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
|
||||||
out nBytesReturned, IntPtr.Zero))
|
out _, IntPtr.Zero))
|
||||||
{
|
{
|
||||||
nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
|
nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
|
||||||
typeof(UsbNodeInformation));
|
typeof(UsbNodeInformation));
|
||||||
@@ -676,64 +663,34 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return Port Count
|
// return Port Count
|
||||||
internal int PortCount
|
internal int PortCount => HubPortCount;
|
||||||
{
|
|
||||||
get { return HubPortCount; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the Device Path, such as "\\?\pci#ven_10de&dev_005a&subsys_815a1043&rev_a2#3&267a616a&0&58#{3abf6f2d-71c4-462a-8a92-1e6861e6af27}"
|
// return the Device Path, such as "\\?\pci#ven_10de&dev_005a&subsys_815a1043&rev_a2#3&267a616a&0&58#{3abf6f2d-71c4-462a-8a92-1e6861e6af27}"
|
||||||
internal string DevicePath
|
internal string DevicePath => HubDevicePath;
|
||||||
{
|
|
||||||
get { return HubDevicePath; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// The DriverKey may be useful as a search key
|
// The DriverKey may be useful as a search key
|
||||||
internal string DriverKey
|
internal string DriverKey => HubDriverKey;
|
||||||
{
|
|
||||||
get { return HubDriverKey; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the Friendly Name, such as "VIA USB Enhanced Host Controller"
|
// return the Friendly Name, such as "VIA USB Enhanced Host Controller"
|
||||||
internal string Name
|
internal string Name => HubDeviceDesc;
|
||||||
{
|
|
||||||
get { return HubDeviceDesc; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// the device path of this device
|
// the device path of this device
|
||||||
internal string InstanceId
|
internal string InstanceId => HubInstanceId;
|
||||||
{
|
|
||||||
get { return HubInstanceId; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// is is this a self-powered hub?
|
// is is this a self-powered hub?
|
||||||
internal bool IsBusPowered
|
internal bool IsBusPowered => HubIsBusPowered;
|
||||||
{
|
|
||||||
get { return HubIsBusPowered; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// is this a root hub?
|
// is this a root hub?
|
||||||
internal bool IsRootHub
|
internal bool IsRootHub => HubIsRootHub;
|
||||||
{
|
|
||||||
get { return HubIsRootHub; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string Manufacturer
|
internal string Manufacturer => HubManufacturer;
|
||||||
{
|
|
||||||
get { return HubManufacturer; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string Product
|
internal string Product => HubProduct;
|
||||||
{
|
|
||||||
get { return HubProduct; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string SerialNumber
|
internal string SerialNumber => HubSerialNumber;
|
||||||
{
|
|
||||||
get { return HubSerialNumber; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a list of the down stream ports
|
// return a list of the down stream ports
|
||||||
internal ReadOnlyCollection<UsbPort> GetPorts()
|
internal IEnumerable<UsbPort> GetPorts()
|
||||||
{
|
{
|
||||||
List<UsbPort> portList = new List<UsbPort>();
|
List<UsbPort> portList = new List<UsbPort>();
|
||||||
|
|
||||||
@@ -750,13 +707,12 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
// BTW: Ports are numbered starting at 1
|
// BTW: Ports are numbered starting at 1
|
||||||
for(int i = 1; i <= HubPortCount; i++)
|
for(int i = 1; i <= HubPortCount; i++)
|
||||||
{
|
{
|
||||||
int nBytesReturned;
|
UsbNodeConnectionInformationEx nodeConnection =
|
||||||
UsbNodeConnectionInformationEx nodeConnection = new UsbNodeConnectionInformationEx();
|
new UsbNodeConnectionInformationEx {ConnectionIndex = i};
|
||||||
nodeConnection.ConnectionIndex = i;
|
|
||||||
Marshal.StructureToPtr(nodeConnection, ptrNodeConnection, true);
|
Marshal.StructureToPtr(nodeConnection, ptrNodeConnection, true);
|
||||||
|
|
||||||
if(!DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes,
|
if(!DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes,
|
||||||
ptrNodeConnection, nBytes, out nBytesReturned, IntPtr.Zero)) continue;
|
ptrNodeConnection, nBytes, out _, IntPtr.Zero)) continue;
|
||||||
|
|
||||||
nodeConnection =
|
nodeConnection =
|
||||||
(UsbNodeConnectionInformationEx)Marshal.PtrToStructure(ptrNodeConnection,
|
(UsbNodeConnectionInformationEx)Marshal.PtrToStructure(ptrNodeConnection,
|
||||||
@@ -765,17 +721,17 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
));
|
));
|
||||||
|
|
||||||
// load up the USBPort class
|
// load up the USBPort class
|
||||||
UsbPort port = new UsbPort();
|
UsbPort port = new UsbPort
|
||||||
port.PortPortNumber = i;
|
{
|
||||||
port.PortHubDevicePath = HubDevicePath;
|
PortPortNumber = i,
|
||||||
UsbConnectionStatus status = (UsbConnectionStatus)nodeConnection.ConnectionStatus;
|
PortHubDevicePath = HubDevicePath,
|
||||||
port.PortStatus = status.ToString();
|
PortStatus = ((UsbConnectionStatus)nodeConnection.ConnectionStatus).ToString(),
|
||||||
UsbDeviceSpeed speed = (UsbDeviceSpeed)nodeConnection.Speed;
|
PortSpeed = ((UsbDeviceSpeed)nodeConnection.Speed).ToString(),
|
||||||
port.PortSpeed = speed.ToString();
|
PortIsDeviceConnected =
|
||||||
port.PortIsDeviceConnected =
|
nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected,
|
||||||
nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected;
|
PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub),
|
||||||
port.PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub);
|
PortDeviceDescriptor = nodeConnection.DeviceDescriptor
|
||||||
port.PortDeviceDescriptor = nodeConnection.DeviceDescriptor;
|
};
|
||||||
|
|
||||||
// add it to the list
|
// add it to the list
|
||||||
portList.Add(port);
|
portList.Add(port);
|
||||||
@@ -810,53 +766,36 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return Port Index of the Hub
|
// return Port Index of the Hub
|
||||||
internal int PortNumber
|
internal int PortNumber => PortPortNumber;
|
||||||
{
|
|
||||||
get { return PortPortNumber; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the Device Path of the Hub
|
// return the Device Path of the Hub
|
||||||
internal string HubDevicePath
|
internal string HubDevicePath => PortHubDevicePath;
|
||||||
{
|
|
||||||
get { return PortHubDevicePath; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// the status (see USB_CONNECTION_STATUS above)
|
// the status (see USB_CONNECTION_STATUS above)
|
||||||
internal string Status
|
internal string Status => PortStatus;
|
||||||
{
|
|
||||||
get { return PortStatus; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// the speed of the connection (see USB_DEVICE_SPEED above)
|
// the speed of the connection (see USB_DEVICE_SPEED above)
|
||||||
internal string Speed
|
internal string Speed => PortSpeed;
|
||||||
{
|
|
||||||
get { return PortSpeed; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// is this a downstream external hub?
|
// is this a downstream external hub?
|
||||||
internal bool IsHub
|
internal bool IsHub => PortIsHub;
|
||||||
{
|
|
||||||
get { return PortIsHub; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// is anybody home?
|
// is anybody home?
|
||||||
internal bool IsDeviceConnected
|
internal bool IsDeviceConnected => PortIsDeviceConnected;
|
||||||
{
|
|
||||||
get { return PortIsDeviceConnected; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a down stream external hub
|
// return a down stream external hub
|
||||||
internal UsbDevice GetDevice()
|
internal UsbDevice GetDevice()
|
||||||
{
|
{
|
||||||
if(!PortIsDeviceConnected) return null;
|
if(!PortIsDeviceConnected) return null;
|
||||||
|
|
||||||
UsbDevice device = new UsbDevice();
|
|
||||||
|
|
||||||
// Copy over some values from the Port class
|
// Copy over some values from the Port class
|
||||||
// Ya know, I've given some thought about making Device a derived class...
|
// Ya know, I've given some thought about making Device a derived class...
|
||||||
device.DevicePortNumber = PortPortNumber;
|
UsbDevice device = new UsbDevice
|
||||||
device.DeviceHubDevicePath = PortHubDevicePath;
|
{
|
||||||
device.DeviceDescriptor = PortDeviceDescriptor;
|
DevicePortNumber = PortPortNumber,
|
||||||
|
DeviceHubDevicePath = PortHubDevicePath,
|
||||||
|
DeviceDescriptor = PortDeviceDescriptor
|
||||||
|
};
|
||||||
|
|
||||||
// Open a handle to the Hub device
|
// Open a handle to the Hub device
|
||||||
IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
|
IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,
|
||||||
@@ -875,12 +814,17 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
if(PortDeviceDescriptor.iManufacturer > 0)
|
if(PortDeviceDescriptor.iManufacturer > 0)
|
||||||
{
|
{
|
||||||
// build a request for string descriptor
|
// build a request for string descriptor
|
||||||
UsbDescriptorRequest request = new UsbDescriptorRequest();
|
UsbDescriptorRequest request = new UsbDescriptorRequest
|
||||||
request.ConnectionIndex = PortPortNumber;
|
{
|
||||||
request.SetupPacket.wValue =
|
ConnectionIndex = PortPortNumber,
|
||||||
(short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
|
SetupPacket =
|
||||||
|
{
|
||||||
|
// Language Code
|
||||||
|
wIndex = 0x409,
|
||||||
|
wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer)
|
||||||
|
}
|
||||||
|
};
|
||||||
request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
|
request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
|
||||||
request.SetupPacket.wIndex = 0x409; // Language Code
|
|
||||||
// Geez, I wish C# had a Marshal.MemSet() method
|
// Geez, I wish C# had a Marshal.MemSet() method
|
||||||
IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
|
IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
|
||||||
Marshal.StructureToPtr(request, ptrRequest, true);
|
Marshal.StructureToPtr(request, ptrRequest, true);
|
||||||
@@ -904,12 +848,17 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
if(PortDeviceDescriptor.iProduct > 0)
|
if(PortDeviceDescriptor.iProduct > 0)
|
||||||
{
|
{
|
||||||
// build a request for string descriptor
|
// build a request for string descriptor
|
||||||
UsbDescriptorRequest request = new UsbDescriptorRequest();
|
UsbDescriptorRequest request = new UsbDescriptorRequest
|
||||||
request.ConnectionIndex = PortPortNumber;
|
{
|
||||||
request.SetupPacket.wValue =
|
ConnectionIndex = PortPortNumber,
|
||||||
(short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iProduct);
|
SetupPacket =
|
||||||
|
{
|
||||||
|
// Language Code
|
||||||
|
wIndex = 0x409,
|
||||||
|
wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iProduct)
|
||||||
|
}
|
||||||
|
};
|
||||||
request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
|
request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
|
||||||
request.SetupPacket.wIndex = 0x409; // Language Code
|
|
||||||
// Geez, I wish C# had a Marshal.MemSet() method
|
// Geez, I wish C# had a Marshal.MemSet() method
|
||||||
IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
|
IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
|
||||||
Marshal.StructureToPtr(request, ptrRequest, true);
|
Marshal.StructureToPtr(request, ptrRequest, true);
|
||||||
@@ -930,12 +879,17 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
if(PortDeviceDescriptor.iSerialNumber > 0)
|
if(PortDeviceDescriptor.iSerialNumber > 0)
|
||||||
{
|
{
|
||||||
// build a request for string descriptor
|
// build a request for string descriptor
|
||||||
UsbDescriptorRequest request = new UsbDescriptorRequest();
|
UsbDescriptorRequest request = new UsbDescriptorRequest
|
||||||
request.ConnectionIndex = PortPortNumber;
|
{
|
||||||
request.SetupPacket.wValue =
|
ConnectionIndex = PortPortNumber,
|
||||||
(short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iSerialNumber);
|
SetupPacket =
|
||||||
|
{
|
||||||
|
// Language Code
|
||||||
|
wIndex = 0x409,
|
||||||
|
wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iSerialNumber)
|
||||||
|
}
|
||||||
|
};
|
||||||
request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
|
request.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(request));
|
||||||
request.SetupPacket.wIndex = 0x409; // Language Code
|
|
||||||
// Geez, I wish C# had a Marshal.MemSet() method
|
// Geez, I wish C# had a Marshal.MemSet() method
|
||||||
IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
|
IntPtr ptrRequest = Marshal.StringToHGlobalAuto(nullString);
|
||||||
Marshal.StructureToPtr(request, ptrRequest, true);
|
Marshal.StructureToPtr(request, ptrRequest, true);
|
||||||
@@ -955,11 +909,12 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// build a request for configuration descriptor
|
// build a request for configuration descriptor
|
||||||
UsbDescriptorRequest dcrRequest = new UsbDescriptorRequest();
|
UsbDescriptorRequest dcrRequest = new UsbDescriptorRequest
|
||||||
dcrRequest.ConnectionIndex = PortPortNumber;
|
{
|
||||||
dcrRequest.SetupPacket.wValue = USB_CONFIGURATION_DESCRIPTOR_TYPE << 8;
|
ConnectionIndex = PortPortNumber,
|
||||||
|
SetupPacket = {wIndex = 0, wValue = USB_CONFIGURATION_DESCRIPTOR_TYPE << 8}
|
||||||
|
};
|
||||||
dcrRequest.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(dcrRequest));
|
dcrRequest.SetupPacket.wLength = (short)(nBytes - Marshal.SizeOf(dcrRequest));
|
||||||
dcrRequest.SetupPacket.wIndex = 0;
|
|
||||||
// Geez, I wish C# had a Marshal.MemSet() method
|
// Geez, I wish C# had a Marshal.MemSet() method
|
||||||
IntPtr dcrPtrRequest = Marshal.StringToHGlobalAuto(nullString);
|
IntPtr dcrPtrRequest = Marshal.StringToHGlobalAuto(nullString);
|
||||||
Marshal.StructureToPtr(dcrRequest, dcrPtrRequest, true);
|
Marshal.StructureToPtr(dcrRequest, dcrPtrRequest, true);
|
||||||
@@ -975,8 +930,8 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
Marshal.FreeHGlobal(dcrPtrRequest);
|
Marshal.FreeHGlobal(dcrPtrRequest);
|
||||||
|
|
||||||
// Get the Driver Key Name (usefull in locating a device)
|
// Get the Driver Key Name (usefull in locating a device)
|
||||||
UsbNodeConnectionDriverkeyName driverKey = new UsbNodeConnectionDriverkeyName();
|
UsbNodeConnectionDriverkeyName driverKey =
|
||||||
driverKey.ConnectionIndex = PortPortNumber;
|
new UsbNodeConnectionDriverkeyName {ConnectionIndex = PortPortNumber};
|
||||||
nBytes = Marshal.SizeOf(driverKey);
|
nBytes = Marshal.SizeOf(driverKey);
|
||||||
IntPtr ptrDriverKey = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrDriverKey = Marshal.AllocHGlobal(nBytes);
|
||||||
Marshal.StructureToPtr(driverKey, ptrDriverKey, true);
|
Marshal.StructureToPtr(driverKey, ptrDriverKey, true);
|
||||||
@@ -1015,16 +970,14 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
if(h.ToInt32() == INVALID_HANDLE_VALUE) return hub;
|
if(h.ToInt32() == INVALID_HANDLE_VALUE) return hub;
|
||||||
// Get the DevicePath for downstream hub
|
// Get the DevicePath for downstream hub
|
||||||
int nBytesReturned;
|
UsbNodeConnectionName nodeName = new UsbNodeConnectionName {ConnectionIndex = PortPortNumber};
|
||||||
UsbNodeConnectionName nodeName = new UsbNodeConnectionName();
|
|
||||||
nodeName.ConnectionIndex = PortPortNumber;
|
|
||||||
int nBytes = Marshal.SizeOf(nodeName);
|
int nBytes = Marshal.SizeOf(nodeName);
|
||||||
IntPtr ptrNodeName = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrNodeName = Marshal.AllocHGlobal(nBytes);
|
||||||
Marshal.StructureToPtr(nodeName, ptrNodeName, true);
|
Marshal.StructureToPtr(nodeName, ptrNodeName, true);
|
||||||
|
|
||||||
// Use an IOCTL call to request the Node Name
|
// Use an IOCTL call to request the Node Name
|
||||||
if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes,
|
if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes,
|
||||||
out nBytesReturned, IntPtr.Zero))
|
out _, IntPtr.Zero))
|
||||||
{
|
{
|
||||||
nodeName = (UsbNodeConnectionName)Marshal.PtrToStructure(ptrNodeName,
|
nodeName = (UsbNodeConnectionName)Marshal.PtrToStructure(ptrNodeName,
|
||||||
typeof(UsbNodeConnectionName));
|
typeof(UsbNodeConnectionName));
|
||||||
@@ -1036,15 +989,14 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
if(h2.ToInt32() != INVALID_HANDLE_VALUE)
|
if(h2.ToInt32() != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
UsbNodeInformation nodeInfo = new UsbNodeInformation();
|
UsbNodeInformation nodeInfo = new UsbNodeInformation {NodeType = (int)UsbHubNode.UsbHub};
|
||||||
nodeInfo.NodeType = (int)UsbHubNode.UsbHub;
|
|
||||||
nBytes = Marshal.SizeOf(nodeInfo);
|
nBytes = Marshal.SizeOf(nodeInfo);
|
||||||
IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrNodeInfo = Marshal.AllocHGlobal(nBytes);
|
||||||
Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
|
Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true);
|
||||||
|
|
||||||
// get the Hub Information
|
// get the Hub Information
|
||||||
if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
|
if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes,
|
||||||
out nBytesReturned, IntPtr.Zero))
|
out _, IntPtr.Zero))
|
||||||
{
|
{
|
||||||
nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
|
nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo,
|
||||||
typeof(UsbNodeInformation));
|
typeof(UsbNodeInformation));
|
||||||
@@ -1096,54 +1048,27 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return Port Index of the Hub
|
// return Port Index of the Hub
|
||||||
internal int PortNumber
|
internal int PortNumber => DevicePortNumber;
|
||||||
{
|
|
||||||
get { return DevicePortNumber; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the Device Path of the Hub (the parent device)
|
// return the Device Path of the Hub (the parent device)
|
||||||
internal string HubDevicePath
|
internal string HubDevicePath => DeviceHubDevicePath;
|
||||||
{
|
|
||||||
get { return DeviceHubDevicePath; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// useful as a search key
|
// useful as a search key
|
||||||
internal string DriverKey
|
internal string DriverKey => DeviceDriverKey;
|
||||||
{
|
|
||||||
get { return DeviceDriverKey; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// the device path of this device
|
// the device path of this device
|
||||||
internal string InstanceId
|
internal string InstanceId => DeviceInstanceId;
|
||||||
{
|
|
||||||
get { return DeviceInstanceId; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// the friendly name
|
// the friendly name
|
||||||
internal string Name
|
internal string Name => DeviceName;
|
||||||
{
|
|
||||||
get { return DeviceName; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string Manufacturer
|
internal string Manufacturer => DeviceManufacturer;
|
||||||
{
|
|
||||||
get { return DeviceManufacturer; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string Product
|
internal string Product => DeviceProduct;
|
||||||
{
|
|
||||||
get { return DeviceProduct; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal string SerialNumber
|
internal string SerialNumber => DeviceSerialNumber;
|
||||||
{
|
|
||||||
get { return DeviceSerialNumber; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal byte[] BinaryDescriptors
|
internal byte[] BinaryDescriptors => BinaryDeviceDescriptors;
|
||||||
{
|
|
||||||
get { return BinaryDeviceDescriptors; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1152,15 +1077,14 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
static string GetDescriptionByKeyName(string driverKeyName)
|
static string GetDescriptionByKeyName(string driverKeyName)
|
||||||
{
|
{
|
||||||
string ans = "";
|
string ans = "";
|
||||||
string devEnum = REGSTR_KEY_USB;
|
const string DEV_ENUM = REGSTR_KEY_USB;
|
||||||
|
|
||||||
// Use the "enumerator form" of the SetupDiGetClassDevs API
|
// Use the "enumerator form" of the SetupDiGetClassDevs API
|
||||||
// to generate a list of all USB devices
|
// to generate a list of all USB devices
|
||||||
IntPtr h = SetupDiGetClassDevs(0, devEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
|
IntPtr h = SetupDiGetClassDevs(0, DEV_ENUM, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
|
||||||
if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
|
if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
|
||||||
|
|
||||||
IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
|
IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
|
||||||
string keyName;
|
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -1176,7 +1100,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
{
|
{
|
||||||
int requiredSize = 0;
|
int requiredSize = 0;
|
||||||
int regType = REG_SZ;
|
int regType = REG_SZ;
|
||||||
keyName = "";
|
string keyName = "";
|
||||||
|
|
||||||
if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
|
if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
|
||||||
ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
|
ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
|
||||||
@@ -1206,15 +1130,14 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
static string GetInstanceIdByKeyName(string driverKeyName)
|
static string GetInstanceIdByKeyName(string driverKeyName)
|
||||||
{
|
{
|
||||||
string ans = "";
|
string ans = "";
|
||||||
string devEnum = REGSTR_KEY_USB;
|
const string DEV_ENUM = REGSTR_KEY_USB;
|
||||||
|
|
||||||
// Use the "enumerator form" of the SetupDiGetClassDevs API
|
// Use the "enumerator form" of the SetupDiGetClassDevs API
|
||||||
// to generate a list of all USB devices
|
// to generate a list of all USB devices
|
||||||
IntPtr h = SetupDiGetClassDevs(0, devEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
|
IntPtr h = SetupDiGetClassDevs(0, DEV_ENUM, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
|
||||||
if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
|
if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
|
||||||
|
|
||||||
IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
|
IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
|
||||||
string keyName;
|
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -1231,16 +1154,16 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
int requiredSize = 0;
|
int requiredSize = 0;
|
||||||
int regType = REG_SZ;
|
int regType = REG_SZ;
|
||||||
|
|
||||||
keyName = "";
|
string keyName = "";
|
||||||
if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
|
if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE,
|
||||||
ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
|
ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf);
|
||||||
|
|
||||||
// is it a match?
|
// is it a match?
|
||||||
if(keyName == driverKeyName)
|
if(keyName == driverKeyName)
|
||||||
{
|
{
|
||||||
int nBytes = BUFFER_SIZE;
|
const int N_BYTES = BUFFER_SIZE;
|
||||||
StringBuilder sb = new StringBuilder(nBytes);
|
StringBuilder sb = new StringBuilder(N_BYTES);
|
||||||
SetupDiGetDeviceInstanceId(h, ref da, sb, nBytes, out requiredSize);
|
SetupDiGetDeviceInstanceId(h, ref da, sb, N_BYTES, out requiredSize);
|
||||||
ans = sb.ToString();
|
ans = sb.ToString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,25 +28,26 @@
|
|||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Copyright © 2011-2018 Natalia Portillo
|
// Copyright © 2011-2018 Natalia Portillo
|
||||||
|
// Copyright © 2007 Fort Hood TX, herethen, Public Domain
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// Copyright "Fort Hood TX", internal domain, 2007
|
|
||||||
namespace DiscImageChef.Devices.Windows
|
namespace DiscImageChef.Devices.Windows
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// A place for "higher level" related functions
|
// A place for "higher level" related functions
|
||||||
// You might not want to keep these in the USB class... your choice
|
// You might not want to keep these in the USB class... your choice
|
||||||
//
|
//
|
||||||
partial class Usb
|
// TODO: Even after cleaning, refactoring and xml-documenting, this code needs some love
|
||||||
|
static partial class Usb
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Get a list of all connected devices
|
// Get a list of all connected devices
|
||||||
//
|
//
|
||||||
static internal List<UsbDevice> GetConnectedDevices()
|
internal static List<UsbDevice> GetConnectedDevices()
|
||||||
{
|
{
|
||||||
List<UsbDevice> devList = new List<UsbDevice>();
|
List<UsbDevice> devList = new List<UsbDevice>();
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// private routine for enumerating a hub
|
// private routine for enumerating a hub
|
||||||
static void ListHub(UsbHub hub, List<UsbDevice> devList)
|
static void ListHub(UsbHub hub, ICollection<UsbDevice> devList)
|
||||||
{
|
{
|
||||||
foreach(UsbPort port in hub.GetPorts())
|
foreach(UsbPort port in hub.GetPorts())
|
||||||
if(port.IsHub) ListHub(port.GetHub(), devList);
|
if(port.IsHub) ListHub(port.GetHub(), devList);
|
||||||
@@ -66,7 +67,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
//
|
//
|
||||||
// Find a device based upon it's DriverKeyName
|
// Find a device based upon it's DriverKeyName
|
||||||
//
|
//
|
||||||
static internal UsbDevice FindDeviceByDriverKeyName(string driverKeyName)
|
internal static UsbDevice FindDeviceByDriverKeyName(string driverKeyName)
|
||||||
{
|
{
|
||||||
UsbDevice foundDevice = null;
|
UsbDevice foundDevice = null;
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
//
|
//
|
||||||
// Find a device based upon it's Instance ID
|
// Find a device based upon it's Instance ID
|
||||||
//
|
//
|
||||||
static internal UsbDevice FindDeviceByInstanceId(string instanceId)
|
static UsbDevice FindDeviceByInstanceId(string instanceId)
|
||||||
{
|
{
|
||||||
UsbDevice foundDevice = null;
|
UsbDevice foundDevice = null;
|
||||||
|
|
||||||
@@ -167,38 +168,28 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
//
|
//
|
||||||
// Find a device based upon a Drive Letter
|
// Find a device based upon a Drive Letter
|
||||||
//
|
//
|
||||||
static internal UsbDevice FindDriveLetter(string driveLetter, string deviceGuid)
|
internal static UsbDevice FindDriveLetter(string driveLetter, string deviceGuid)
|
||||||
{
|
{
|
||||||
UsbDevice foundDevice = null;
|
|
||||||
string instanceId = "";
|
|
||||||
|
|
||||||
// We start by getting the unique DeviceNumber of the given
|
// We start by getting the unique DeviceNumber of the given
|
||||||
// DriveLetter. We'll use this later to find a matching
|
// DriveLetter. We'll use this later to find a matching
|
||||||
// DevicePath "symbolic name"
|
// DevicePath "symbolic name"
|
||||||
int devNum = GetDeviceNumber(@"\\.\" + driveLetter.TrimEnd('\\'));
|
int devNum = GetDeviceNumber(@"\\.\" + driveLetter.TrimEnd('\\'));
|
||||||
if(devNum < 0) return null;
|
return devNum < 0 ? null : FindDeviceNumber(devNum, deviceGuid);
|
||||||
|
|
||||||
return FindDeviceNumber(devNum, deviceGuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static internal UsbDevice FindDrivePath(string drivePath, string deviceGuid)
|
internal static UsbDevice FindDrivePath(string drivePath, string deviceGuid)
|
||||||
{
|
{
|
||||||
UsbDevice foundDevice = null;
|
|
||||||
string instanceId = "";
|
|
||||||
|
|
||||||
// We start by getting the unique DeviceNumber of the given
|
// We start by getting the unique DeviceNumber of the given
|
||||||
// DriveLetter. We'll use this later to find a matching
|
// DriveLetter. We'll use this later to find a matching
|
||||||
// DevicePath "symbolic name"
|
// DevicePath "symbolic name"
|
||||||
int devNum = GetDeviceNumber(drivePath);
|
int devNum = GetDeviceNumber(drivePath);
|
||||||
if(devNum < 0) return null;
|
return devNum < 0 ? null : FindDeviceNumber(devNum, deviceGuid);
|
||||||
|
|
||||||
return FindDeviceNumber(devNum, deviceGuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find a device based upon a Drive Letter
|
// Find a device based upon a Drive Letter
|
||||||
//
|
//
|
||||||
static internal UsbDevice FindDeviceNumber(int devNum, string deviceGuid)
|
static UsbDevice FindDeviceNumber(int devNum, string deviceGuid)
|
||||||
{
|
{
|
||||||
UsbDevice foundDevice = null;
|
UsbDevice foundDevice = null;
|
||||||
string instanceId = "";
|
string instanceId = "";
|
||||||
@@ -227,23 +218,22 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
da.cbSize = Marshal.SizeOf(da);
|
da.cbSize = Marshal.SizeOf(da);
|
||||||
|
|
||||||
// build a Device Interface Detail Data structure
|
// build a Device Interface Detail Data structure
|
||||||
SpDeviceInterfaceDetailData didd = new SpDeviceInterfaceDetailData();
|
SpDeviceInterfaceDetailData didd =
|
||||||
didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)
|
new SpDeviceInterfaceDetailData {cbSize = 4 + Marshal.SystemDefaultCharSize}; // trust me :)
|
||||||
|
|
||||||
// now we can get some more detailed information
|
// now we can get some more detailed information
|
||||||
int nRequiredSize = 0;
|
int nRequiredSize = 0;
|
||||||
int nBytes = BUFFER_SIZE;
|
const int N_BYTES = BUFFER_SIZE;
|
||||||
if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da))
|
if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, N_BYTES, ref nRequiredSize, ref da))
|
||||||
if(GetDeviceNumber(didd.DevicePath) == devNum)
|
if(GetDeviceNumber(didd.DevicePath) == devNum)
|
||||||
{
|
{
|
||||||
// current InstanceID is at the "USBSTOR" level, so we
|
// current InstanceID is at the "USBSTOR" level, so we
|
||||||
// need up "move up" one level to get to the "USB" level
|
// need up "move up" one level to get to the "USB" level
|
||||||
IntPtr ptrPrevious;
|
CM_Get_Parent(out IntPtr ptrPrevious, da.DevInst, 0);
|
||||||
CM_Get_Parent(out ptrPrevious, da.DevInst, 0);
|
|
||||||
|
|
||||||
// Now we get the InstanceID of the USB level device
|
// Now we get the InstanceID of the USB level device
|
||||||
IntPtr ptrInstanceBuf = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrInstanceBuf = Marshal.AllocHGlobal(N_BYTES);
|
||||||
CM_Get_Device_ID(ptrPrevious, ptrInstanceBuf, nBytes, 0);
|
CM_Get_Device_ID(ptrPrevious, ptrInstanceBuf, N_BYTES, 0);
|
||||||
instanceId = Marshal.PtrToStringAuto(ptrInstanceBuf);
|
instanceId = Marshal.PtrToStringAuto(ptrInstanceBuf);
|
||||||
|
|
||||||
Marshal.FreeHGlobal(ptrInstanceBuf);
|
Marshal.FreeHGlobal(ptrInstanceBuf);
|
||||||
@@ -271,12 +261,11 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
IntPtr h = CreateFile(devicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
|
IntPtr h = CreateFile(devicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
|
||||||
if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
|
if(h.ToInt32() == INVALID_HANDLE_VALUE) return ans;
|
||||||
|
|
||||||
int requiredSize;
|
|
||||||
StorageDeviceNumber sdn = new StorageDeviceNumber();
|
StorageDeviceNumber sdn = new StorageDeviceNumber();
|
||||||
int nBytes = Marshal.SizeOf(sdn);
|
int nBytes = Marshal.SizeOf(sdn);
|
||||||
IntPtr ptrSdn = Marshal.AllocHGlobal(nBytes);
|
IntPtr ptrSdn = Marshal.AllocHGlobal(nBytes);
|
||||||
|
|
||||||
if(DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, IntPtr.Zero, 0, ptrSdn, nBytes, out requiredSize,
|
if(DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, IntPtr.Zero, 0, ptrSdn, nBytes, out _,
|
||||||
IntPtr.Zero))
|
IntPtr.Zero))
|
||||||
{
|
{
|
||||||
sdn = (StorageDeviceNumber)Marshal.PtrToStructure(ptrSdn, typeof(StorageDeviceNumber));
|
sdn = (StorageDeviceNumber)Marshal.PtrToStructure(ptrSdn, typeof(StorageDeviceNumber));
|
||||||
|
|||||||
Reference in New Issue
Block a user