REFACTOR: All refactor in DiscImageChef.Devices.

This commit is contained in:
2017-12-22 03:13:43 +00:00
parent 49144eeb01
commit e87e058a11
40 changed files with 671 additions and 854 deletions

View File

@@ -41,14 +41,12 @@ namespace DiscImageChef.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBuffer};
registers.Command = (byte)AtaCommands.ReadBuffer;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration);
@@ -60,13 +58,11 @@ namespace DiscImageChef.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBufferDma};
registers.Command = (byte)AtaCommands.ReadBufferDma;
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;
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,
byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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;
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;
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,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
@@ -137,15 +132,13 @@ namespace DiscImageChef.Devices
{
lba = 0;
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadNativeMaxAddress};
registers.Command = (byte)AtaCommands.ReadNativeMaxAddress;
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 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,
byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
@@ -205,21 +197,21 @@ namespace DiscImageChef.Devices
uint blockSize, uint timeout, out double duration)
{
buffer = new byte[blockSize];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);

View File

@@ -41,16 +41,14 @@ namespace DiscImageChef.Devices
out double duration)
{
lba = 0;
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 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,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 65536];
else buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
{
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;
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;
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)
{
buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
AtaRegistersLba48 registers = new AtaRegistersLba48
{
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.LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
AtaRegistersLba48 registers = new AtaRegistersLba48
{
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.LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100);
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;
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,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 65536];
else buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "READ MULTIPLE EXT took {0} ms.", duration);
@@ -165,15 +165,13 @@ namespace DiscImageChef.Devices
{
lba = 0;
byte[] buffer = new byte[0];
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
AtaRegistersLba48 registers = new AtaRegistersLba48 {Command = (byte)AtaCommands.ReadNativeMaxAddressExt};
registers.Command = (byte)AtaCommands.ReadNativeMaxAddressExt;
registers.DeviceHead += 0x40;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 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,
uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 65536];
else buffer = new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48();
bool sense;
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
AtaRegistersLba48 registers = new AtaRegistersLba48
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "READ SECTORS EXT took {0} ms.", duration);

View File

@@ -69,8 +69,7 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout.</param>
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
{
double duration;
return AtaIdentify(out buffer, out statusRegisters, timeout, out duration);
return AtaIdentify(out buffer, out statusRegisters, timeout, out _);
}
/// <summary>
@@ -85,14 +84,12 @@ namespace DiscImageChef.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyDevice};
registers.Command = (byte)AtaCommands.IdentifyDevice;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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,
byte head, byte sector, byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs
{
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,
ref buffer, timeout, true, out duration, out sense);
ref buffer, timeout, true, out duration, out bool sense);
Error = LastError != 0;
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,
byte head, byte sector, byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs
{
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,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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,
byte head, byte sector, byte count, uint timeout, out double duration)
{
if(count == 0) buffer = new byte[512 * 256];
else buffer = new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
AtaRegistersChs registers = new AtaRegistersChs
{
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,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
buffer = new byte[blockSize];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
AtaRegistersChs registers = new AtaRegistersChs
{
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,
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
@@ -224,18 +219,19 @@ namespace DiscImageChef.Devices
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
AtaRegistersChs registers = new AtaRegistersChs
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);

View File

@@ -69,8 +69,7 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout.</param>
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout)
{
double duration;
return AtapiIdentify(out buffer, out statusRegisters, timeout, out duration);
return AtapiIdentify(out buffer, out statusRegisters, timeout, out _);
}
/// <summary>
@@ -85,14 +84,12 @@ namespace DiscImageChef.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyPacketDevice};
registers.Command = (byte)AtaCommands.IdentifyPacketDevice;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "IDENTIFY PACKET DEVICE took {0} ms.", duration);

View File

@@ -41,19 +41,20 @@ namespace DiscImageChef.Devices
uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
buffer = new byte[512];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
AtaRegistersChs registers = new AtaRegistersChs
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
@@ -88,14 +90,12 @@ namespace DiscImageChef.Devices
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.RequestSense};
registers.Command = (byte)AtaCommands.RequestSense;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
errorCode = statusRegisters.Error;

View File

@@ -53,15 +53,13 @@ namespace DiscImageChef.Devices
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersChs registers = new AtaRegistersChs();
bool sense;
AtaRegistersChs registers =
new AtaRegistersChs {Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature};
registers.Command = (byte)AtaCommands.CheckMediaCardType;
registers.Feature = feature;
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration);

View File

@@ -40,17 +40,18 @@ namespace DiscImageChef.Devices
public bool SmartDisable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SMART DISABLE OPERATIONS took {0} ms.", duration);
@@ -62,18 +63,19 @@ namespace DiscImageChef.Devices
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
@@ -85,17 +87,18 @@ namespace DiscImageChef.Devices
out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SMART ENABLE OPERATIONS took {0} ms.", duration);
@@ -128,18 +132,19 @@ namespace DiscImageChef.Devices
uint timeout, out double duration)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SMART EXECUTE OFF-LINE IMMEDIATE took {0} ms.", duration);
@@ -151,17 +156,18 @@ namespace DiscImageChef.Devices
out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SMART READ DATA took {0} ms.", duration);
@@ -173,18 +179,19 @@ namespace DiscImageChef.Devices
uint timeout, out double duration)
{
buffer = new byte[512];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
byte[] buffer = new byte[0];
AtaRegistersLba28 registers = new AtaRegistersLba28();
bool sense;
AtaRegistersLba28 registers = new AtaRegistersLba28
{
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,
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("ATA Device", "SMART RETURN STATUS took {0} ms.", duration);

View File

@@ -31,10 +31,12 @@
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
using DiscImageChef.Decoders.ATA;
namespace DiscImageChef.Devices
{
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public partial class Device
{
/// <summary>

View File

@@ -125,16 +125,12 @@ namespace DiscImageChef.Devices
Type = DeviceType.Unknown;
ScsiType = PeripheralDeviceTypes.UnknownDevice;
AtaErrorRegistersChs errorRegisters;
byte[] ataBuf;
byte[] senseBuf;
byte[] inqBuf = null;
if(Error) throw new SystemException($"Error {LastError} trying device.");
bool scsiSense = true;
string ntDevicePath;
// Windows is answering SCSI INQUIRY for all device types so it needs to be detected first
switch(PlatformId) {
@@ -163,19 +159,21 @@ namespace DiscImageChef.Devices
if(!hasError && error == 0)
{
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor();
descriptor.Version = BitConverter.ToUInt32(descriptorB, 0);
descriptor.Size = BitConverter.ToUInt32(descriptorB, 4);
descriptor.DeviceType = descriptorB[8];
descriptor.DeviceTypeModifier = descriptorB[9];
descriptor.RemovableMedia = descriptorB[10] > 0;
descriptor.CommandQueueing = descriptorB[11] > 0;
descriptor.VendorIdOffset = BitConverter.ToInt32(descriptorB, 12);
descriptor.ProductIdOffset = BitConverter.ToInt32(descriptorB, 16);
descriptor.ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20);
descriptor.SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24);
descriptor.BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28);
descriptor.RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32);
StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor
{
Version = BitConverter.ToUInt32(descriptorB, 0),
Size = BitConverter.ToUInt32(descriptorB, 4),
DeviceType = descriptorB[8],
DeviceTypeModifier = descriptorB[9],
RemovableMedia = descriptorB[10] > 0,
CommandQueueing = descriptorB[11] > 0,
VendorIdOffset = BitConverter.ToInt32(descriptorB, 12),
ProductIdOffset = BitConverter.ToInt32(descriptorB, 16),
ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20),
SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24),
BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28),
RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32)
};
descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength];
Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength);
@@ -216,36 +214,35 @@ namespace DiscImageChef.Devices
switch(Type) {
case DeviceType.SCSI:
case DeviceType.ATAPI: scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
case DeviceType.ATAPI: scsiSense = ScsiInquiry(out inqBuf, out _);
break;
case DeviceType.ATA:
bool atapiSense = AtapiIdentify(out ataBuf, out errorRegisters);
bool atapiSense = AtapiIdentify(out ataBuf, out _);
if(!atapiSense)
{
Type = DeviceType.ATAPI;
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";
break;
}
}
ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)FileHandle);
string ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)FileHandle);
DicConsole.DebugWriteLine("Windows devices", "NT device path: {0}", ntDevicePath);
Marshal.FreeHGlobal(descriptorPtr);
if(Windows.Command.IsSdhci((SafeFileHandle)FileHandle))
{
byte[] sdBuffer = new byte[16];
bool sense;
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd, false, false,
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer,
out uint[] response, out double duration, out sense, 0);
out _, out _, out bool sense);
if(!sense)
{
@@ -257,8 +254,8 @@ namespace DiscImageChef.Devices
LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid, false, false,
MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 |
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out response,
out duration, out sense, 0);
MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _,
out _, out sense);
if(!sense)
{
@@ -272,7 +269,7 @@ namespace DiscImageChef.Devices
(MmcCommands)SecureDigitalCommands.SendScr, false, true,
MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 |
MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer,
out response, out duration, out sense, 0);
out _, out _, out sense);
if(!sense)
{
@@ -289,7 +286,7 @@ namespace DiscImageChef.Devices
.SendOperatingCondition, false, true,
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
out response, out duration, out sense, 0);
out _, out _, out sense);
if(!sense)
{
@@ -305,7 +302,7 @@ namespace DiscImageChef.Devices
true,
MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 |
MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer,
out response, out duration, out sense, 0);
out _, out _, out sense);
if(!sense)
{
@@ -319,7 +316,7 @@ namespace DiscImageChef.Devices
if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
scsiSense = ScsiInquiry(out inqBuf, out _);
// MultiMediaCard and SecureDigital go here
else if(devicePath.StartsWith("/dev/mmcblk", StringComparison.Ordinal))
{
@@ -346,7 +343,7 @@ namespace DiscImageChef.Devices
}
}
break;
default: scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
default: scsiSense = ScsiInquiry(out inqBuf, out _);
break;
}
@@ -397,21 +394,17 @@ namespace DiscImageChef.Devices
!File.Exists(resolvedLink + "/idProduct") ||
!File.Exists(resolvedLink + "/idVendor")) continue;
FileStream usbFs;
StreamReader usbSr;
string usbTemp;
usbFs = new FileStream(resolvedLink + "/descriptors",
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
FileStream usbFs = new FileStream(resolvedLink + "/descriptors",
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
byte[] usbBuf = new byte[65536];
int usbCount = usbFs.Read(usbBuf, 0, 65536);
UsbDescriptors = new byte[usbCount];
Array.Copy(usbBuf, 0, UsbDescriptors, 0, usbCount);
usbFs.Close();
usbSr = new StreamReader(resolvedLink + "/idProduct");
usbTemp = usbSr.ReadToEnd();
StreamReader usbSr = new StreamReader(resolvedLink + "/idProduct");
string usbTemp = usbSr.ReadToEnd();
ushort.TryParse(usbTemp, NumberStyles.HexNumber,
CultureInfo.InvariantCulture, out usbProduct);
usbSr.Close();
@@ -500,11 +493,8 @@ namespace DiscImageChef.Devices
!File.Exists(resolvedLink + "/vendor") ||
!File.Exists(resolvedLink + "/guid")) continue;
StreamReader fwSr;
string fwTemp;
fwSr = new StreamReader(resolvedLink + "/model");
fwTemp = fwSr.ReadToEnd();
StreamReader fwSr = new StreamReader(resolvedLink + "/model");
string fwTemp = fwSr.ReadToEnd();
uint.TryParse(fwTemp, NumberStyles.HexNumber,
CultureInfo.InvariantCulture, out firewireModel);
fwSr.Close();
@@ -576,11 +566,9 @@ namespace DiscImageChef.Devices
if(!File.Exists(possibleDir + "/card_type") ||
!File.Exists(possibleDir + "/cis")) continue;
FileStream cisFs;
cisFs = new FileStream(possibleDir + "/cis",
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
FileStream cisFs = new FileStream(possibleDir + "/cis",
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
byte[] cisBuf = new byte[65536];
int cisCount = cisFs.Read(cisBuf, 0, 65536);
Cis = new byte[cisCount];
@@ -602,7 +590,7 @@ namespace DiscImageChef.Devices
Inquiry.SCSIInquiry? inquiry = Inquiry.Decode(inqBuf);
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(inquiry.HasValue)
@@ -618,7 +606,7 @@ namespace DiscImageChef.Devices
ScsiType = (PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType;
}
bool atapiSense = AtapiIdentify(out ataBuf, out errorRegisters);
bool atapiSense = AtapiIdentify(out ataBuf, out _);
if(!atapiSense)
{
@@ -636,7 +624,7 @@ namespace DiscImageChef.Devices
if(scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA")
{
bool ataSense = AtaIdentify(out ataBuf, out errorRegisters);
bool ataSense = AtaIdentify(out ataBuf, out _);
if(!ataSense)
{
Type = DeviceType.ATA;
@@ -680,7 +668,7 @@ namespace DiscImageChef.Devices
if(string.IsNullOrEmpty(Manufacturer)) Manufacturer = UsbManufacturerString;
if(string.IsNullOrEmpty(Model)) Model = UsbProductString;
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;
@@ -688,7 +676,7 @@ namespace DiscImageChef.Devices
if(string.IsNullOrEmpty(Manufacturer)) Manufacturer = FireWireVendorName;
if(string.IsNullOrEmpty(Model)) Model = FireWireModelName;
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)

View File

@@ -39,11 +39,10 @@ namespace DiscImageChef.Devices
public bool ReadCsd(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[16];
bool sense;
LastError = SendMmcCommand(MmcCommands.SendCsd, false, false,
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;
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)
{
buffer = new byte[16];
bool sense;
LastError = SendMmcCommand(MmcCommands.SendCid, false, false,
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;
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)
{
buffer = new byte[4];
bool sense;
LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true,
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;
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)
{
buffer = new byte[512];
bool sense;
LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false,
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;
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)
{
byte[] buffer = new byte[0];
bool sense;
LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false,
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;
DicConsole.DebugWriteLine("MMC Device", "SET_BLOCKLEN took {0} ms.", duration);
@@ -115,18 +110,15 @@ namespace DiscImageChef.Devices
bool byteAddressed, uint timeout, out double duration)
{
buffer = new byte[transferLength * blockSize];
bool sense;
uint address;
if(byteAddressed) address = lba * blockSize;
else address = lba;
MmcCommands command;
if(transferLength > 1) command = MmcCommands.ReadMultipleBlock;
else command = MmcCommands.ReadSingleBlock;
MmcCommands command = transferLength > 1 ? MmcCommands.ReadMultipleBlock : MmcCommands.ReadSingleBlock;
LastError = SendMmcCommand(command, false, false,
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);
Error = LastError != 0;
@@ -135,7 +127,7 @@ namespace DiscImageChef.Devices
byte[] foo = new byte[0];
SendMmcCommand(MmcCommands.StopTransmission, false, false,
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;
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)
{
buffer = new byte[4];
bool sense = false;
LastError = SendMmcCommand(MmcCommands.SendStatus, false, true,
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;
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_STATUS took {0} ms.", duration);

View File

@@ -39,11 +39,10 @@ namespace DiscImageChef.Devices
public bool ReadSdStatus(out byte[] buffer, out uint[] response, uint timeout, out double duration)
{
buffer = new byte[64];
bool sense = false;
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true,
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;
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)
{
buffer = new byte[4];
bool sense = false;
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true,
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;
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)
{
buffer = new byte[8];
bool sense = false;
LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true,
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;
DicConsole.DebugWriteLine("SecureDigital Device", "SEND_SCR took {0} ms.", duration);

View File

@@ -67,7 +67,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
@@ -76,7 +75,7 @@ namespace DiscImageChef.Devices
if(drive1) cdb[1] += 0x20;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC TRANSLATE took {0} ms.", duration);
@@ -113,14 +112,13 @@ namespace DiscImageChef.Devices
buffer[0] = threshold;
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.AdaptecSetErrorThreshold;
if(drive1) cdb[1] += 0x20;
cdb[4] = 1;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC SET ERROR THRESHOLD took {0} ms.", duration);
@@ -155,14 +153,13 @@ namespace DiscImageChef.Devices
buffer = new byte[9];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
if(drive1) cdb[1] += 0x20;
cdb[4] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
byte[] oneKBuffer = new byte[1024];
if(buffer.Length < 1024) Array.Copy(buffer, 0, oneKBuffer, 0, buffer.Length);
else Array.Copy(buffer, 0, oneKBuffer, 0, 1024);
Array.Copy(buffer, 0, oneKBuffer, 0, buffer.Length < 1024 ? buffer.Length : 1024);
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer;
LastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC WRITE DATA BUFFER took {0} ms.", duration);
@@ -210,12 +205,11 @@ namespace DiscImageChef.Devices
buffer = new byte[1024];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "ADAPTEC READ DATA BUFFER took {0} ms.", duration);

View File

@@ -50,7 +50,6 @@ namespace DiscImageChef.Devices
buffer = new byte[3];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
@@ -59,7 +58,7 @@ namespace DiscImageChef.Devices
cdb[4] = 3;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
@@ -102,7 +100,7 @@ namespace DiscImageChef.Devices
if(immediate) cdb[1] += 0x01;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "ARCHIVE CORP. SEEK BLOCK took {0} ms.", duration);

View File

@@ -30,10 +30,12 @@
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System.Diagnostics.CodeAnalysis;
using DiscImageChef.Console;
namespace DiscImageChef.Devices
{
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public partial class Device
{
/// <summary>
@@ -70,13 +72,12 @@ namespace DiscImageChef.Devices
byte[] buffer = new byte[0];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;
if(park) cdb[4] = 1;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "CERTANCE PARK UNPARK took {0} ms.", duration);

View File

@@ -48,7 +48,6 @@ namespace DiscImageChef.Devices
bool displayLen = false;
bool halfMsg = false;
byte[] cdb = new byte[10];
bool sense;
if(!string.IsNullOrWhiteSpace(firstHalf))
{
@@ -67,10 +66,7 @@ namespace DiscImageChef.Devices
displayLen = true;
else if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
{
displayLen = false;
halfMsg = true;
}
buffer[0] = (byte)((byte)mode << 5);
if(displayLen) buffer[0] += 0x10;
@@ -85,7 +81,7 @@ namespace DiscImageChef.Devices
cdb[6] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "FUJITSU DISPLAY took {0} ms.", duration);

View File

@@ -52,7 +52,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
buffer = new byte[2064 * transferLength];
bool sense;
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
cdb[1] = 0x48;
@@ -67,7 +66,7 @@ namespace DiscImageChef.Devices
cdb[11] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "HL-DT-ST READ DVD (RAW) took {0} ms.", duration);

View File

@@ -75,7 +75,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadLong;
if(relAddr) cdb[1] += 0x01;
@@ -88,11 +87,10 @@ namespace DiscImageChef.Devices
if(pba) cdb[9] += 0x80;
if(sectorCount) cdb[9] += 0x40;
if(sectorCount) buffer = new byte[blockBytes * transferLen];
else buffer = new byte[transferLen];
buffer = sectorCount ? new byte[blockBytes * transferLen] : new byte[transferLen];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "HP READ LONG took {0} ms.", duration);

View File

@@ -49,7 +49,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.KreonCommand;
cdb[1] = 0x08;
@@ -57,7 +56,7 @@ namespace DiscImageChef.Devices
cdb[3] = 0x01;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "KREON DEPRECATED UNLOCK took {0} ms.", duration);
@@ -114,7 +113,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.KreonCommand;
cdb[1] = 0x08;
@@ -123,7 +121,7 @@ namespace DiscImageChef.Devices
cdb[4] = (byte)state;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "KREON SET LOCK STATE took {0} ms.", duration);
@@ -145,7 +143,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[26];
bool sense;
features = 0;
cdb[0] = (byte)ScsiCommands.KreonCommand;
@@ -154,7 +151,7 @@ namespace DiscImageChef.Devices
cdb[3] = 0x10;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "KREON GET FEATURE LIST took {0} ms.", duration);
@@ -222,7 +219,6 @@ namespace DiscImageChef.Devices
buffer = new byte[2048];
byte[] cdb = new byte[12];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
cdb[1] = 0x00;
@@ -238,7 +234,7 @@ namespace DiscImageChef.Devices
cdb[11] = 0xC0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "KREON EXTRACT SS took {0} ms.", duration);

View File

@@ -83,7 +83,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
buffer = new byte[8];
bool sense;
cdb[0] = (byte)ScsiCommands.GetConfiguration;
cdb[1] = (byte)((byte)rt & 0x03);
@@ -94,7 +93,7 @@ namespace DiscImageChef.Devices
cdb[9] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -134,7 +133,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
buffer = new byte[8];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
cdb[1] = (byte)((byte)mediaType & 0x0F);
@@ -149,7 +147,7 @@ namespace DiscImageChef.Devices
cdb[10] = (byte)((agid & 0x03) << 6);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -297,11 +295,8 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] tmpBuffer;
bool sense;
if((format & 0x0F) == 5) tmpBuffer = new byte[32768];
else tmpBuffer = new byte[1024];
byte[] tmpBuffer = (format & 0x0F) == 5 ? new byte[32768] : new byte[1024];
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
if(msf) cdb[1] = 0x02;
@@ -311,7 +306,7 @@ namespace DiscImageChef.Devices
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
@@ -364,7 +359,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] tmpBuffer = new byte[804];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadDiscInformation;
cdb[1] = (byte)dataType;
@@ -372,7 +366,7 @@ namespace DiscImageChef.Devices
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
@@ -411,7 +405,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCd;
cdb[1] = (byte)((byte)expectedSectorType << 2);
@@ -434,7 +427,7 @@ namespace DiscImageChef.Devices
buffer = new byte[blockSize * transferLength];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ CD took {0} ms.", duration);
@@ -468,7 +461,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
cdb[1] = (byte)((byte)expectedSectorType << 2);
@@ -491,7 +483,7 @@ namespace DiscImageChef.Devices
buffer = new byte[blockSize * transferLength];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ CD MSF took {0} ms.", duration);
@@ -515,14 +507,13 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
if(prevent) cdb[4] += 0x01;
if(persistent) cdb[4] += 0x02;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
@@ -556,7 +547,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.StartStopUnit;
if(immediate) cdb[1] += 0x01;
@@ -573,7 +563,7 @@ namespace DiscImageChef.Devices
cdb[4] += (byte)((powerConditions & 0x0F) << 4);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "START STOP UNIT took {0} ms.", duration);

View File

@@ -51,7 +51,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.NecReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
@@ -64,7 +63,7 @@ namespace DiscImageChef.Devices
buffer = new byte[2352 * transferLength];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration);

View File

@@ -54,7 +54,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
@@ -69,7 +68,7 @@ namespace DiscImageChef.Devices
buffer = new byte[blockSize * transferLength];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA took {0} ms.", duration);
@@ -94,7 +93,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
@@ -109,7 +107,7 @@ namespace DiscImageChef.Devices
buffer = new byte[blockSize * transferLength];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-DA MSF took {0} ms.", duration);
@@ -134,7 +132,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCdXa;
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,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PIONEER READ CD-XA took {0} ms.", duration);

View File

@@ -92,7 +92,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation;
cdb[2] = (byte)((address & 0xFF000000) >> 24);
@@ -104,7 +103,7 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLASMON READ SECTOR LOCATION took {0} ms.", duration);

View File

@@ -55,7 +55,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
@@ -71,7 +70,7 @@ namespace DiscImageChef.Devices
buffer = new byte[blockSize * transferLength];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ CD-DA took {0} ms.", duration);
@@ -95,7 +94,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
buffer = new byte[2064 * transferLength];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadBuffer;
cdb[1] = 0x02;
@@ -107,7 +105,7 @@ namespace DiscImageChef.Devices
cdb[5] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "Plextor READ DVD (RAW) took {0} ms.", duration);
@@ -128,13 +126,12 @@ namespace DiscImageChef.Devices
buffer = new byte[256];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
cdb[8] = 1;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
@@ -155,13 +152,12 @@ namespace DiscImageChef.Devices
buffer = new byte[512];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
cdb[8] = 2;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
@@ -185,7 +181,6 @@ namespace DiscImageChef.Devices
buffer = new byte[blockSize];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorReadEeprom;
cdb[1] = 1;
@@ -194,7 +189,7 @@ namespace DiscImageChef.Devices
cdb[9] = (byte)(blockSize & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR READ EEPROM took {0} ms.", duration);
@@ -218,7 +213,6 @@ namespace DiscImageChef.Devices
byte[] buf = new byte[10];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
selected = 0;
max = 0;
@@ -228,7 +222,7 @@ namespace DiscImageChef.Devices
cdb[9] = (byte)buf.Length;
LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
@@ -258,7 +252,6 @@ namespace DiscImageChef.Devices
byte[] buf = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
enabled = false;
speed = 0;
@@ -268,7 +261,7 @@ namespace DiscImageChef.Devices
cdb[9] = (byte)buf.Length;
LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR POWEREC GET SPEEDS took {0} ms.", duration);
@@ -295,7 +288,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -304,7 +296,7 @@ namespace DiscImageChef.Devices
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SILENT MODE took {0} ms.", duration);
@@ -325,7 +317,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -333,7 +324,7 @@ namespace DiscImageChef.Devices
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET GIGAREC took {0} ms.", duration);
@@ -356,7 +347,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -367,7 +357,7 @@ namespace DiscImageChef.Devices
else cdb[3] = 0x02;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET VARIREC took {0} ms.", duration);
@@ -388,14 +378,13 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[2] = (byte)PlextorSubCommands.SecuRec;
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SECUREC took {0} ms.", duration);
@@ -416,7 +405,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -424,7 +412,7 @@ namespace DiscImageChef.Devices
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET SPEEDREAD took {0} ms.", duration);
@@ -445,7 +433,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -453,7 +440,7 @@ namespace DiscImageChef.Devices
cdb[9] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -487,7 +473,7 @@ namespace DiscImageChef.Devices
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET BOOK BITSETTING took {0} ms.", duration);
@@ -509,7 +495,6 @@ namespace DiscImageChef.Devices
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -517,7 +502,7 @@ namespace DiscImageChef.Devices
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PLEXTOR GET TEST WRITE DVD+ took {0} ms.", duration);

View File

@@ -69,7 +69,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
bool sense;
cdb[0] = (byte)ScsiCommands.Read6;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
@@ -81,7 +80,7 @@ namespace DiscImageChef.Devices
else buffer = new byte[transferLength * blockSize];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ (6) took {0} ms.", duration);
@@ -112,7 +111,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.Read10;
cdb[1] = (byte)((rdprotect & 0x07) << 5);
@@ -131,7 +129,7 @@ namespace DiscImageChef.Devices
buffer = new byte[transferLength * blockSize];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ (10) took {0} ms.", duration);
@@ -163,7 +161,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
bool sense;
cdb[0] = (byte)ScsiCommands.Read12;
cdb[1] = (byte)((rdprotect & 0x07) << 5);
@@ -185,7 +182,7 @@ namespace DiscImageChef.Devices
buffer = new byte[transferLength * blockSize];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ (12) took {0} ms.", duration);
@@ -216,7 +213,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
bool sense;
byte[] lbaBytes = BitConverter.GetBytes(lba);
cdb[0] = (byte)ScsiCommands.Read16;
@@ -242,7 +238,7 @@ namespace DiscImageChef.Devices
buffer = new byte[transferLength * blockSize];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
@@ -267,7 +263,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadLong;
if(correct) cdb[1] += 0x02;
@@ -282,7 +277,7 @@ namespace DiscImageChef.Devices
buffer = new byte[transferBytes];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (10) took {0} ms.", duration);
@@ -306,7 +301,6 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
bool sense;
byte[] lbaBytes = BitConverter.GetBytes(lba);
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
@@ -326,7 +320,7 @@ namespace DiscImageChef.Devices
buffer = new byte[transferBytes];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ LONG (16) took {0} ms.", duration);
@@ -346,7 +340,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Seek6;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
@@ -354,7 +347,7 @@ namespace DiscImageChef.Devices
cdb[3] = (byte)(lba & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "SEEK (6) took {0} ms.", duration);
@@ -374,7 +367,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Seek10;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
@@ -383,7 +375,7 @@ namespace DiscImageChef.Devices
cdb[5] = (byte)(lba & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "SEEK (10) took {0} ms.", duration);

View File

@@ -57,7 +57,6 @@ namespace DiscImageChef.Devices
buffer = new byte[256];
byte[] cdb = new byte[16];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadAttribute;
cdb[1] = (byte)((byte)action & 0x1F);
@@ -75,7 +74,7 @@ namespace DiscImageChef.Devices
if(cache) cdb[14] += 0x01;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;

View File

@@ -31,11 +31,13 @@
// ****************************************************************************/
using System;
using System.Diagnostics.CodeAnalysis;
using DiscImageChef.Console;
using PlatformID = DiscImageChef.Interop.PlatformID;
namespace DiscImageChef.Devices
{
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public partial class Device
{
/// <summary>
@@ -70,8 +72,7 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout in seconds.</param>
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, uint timeout)
{
double duration;
return ScsiInquiry(out buffer, out senseBuffer, timeout, out duration);
return ScsiInquiry(out buffer, out senseBuffer, timeout, out _);
}
/// <summary>
@@ -87,10 +88,9 @@ namespace DiscImageChef.Devices
buffer = new byte[36];
senseBuffer = new byte[32];
byte[] cdb = {(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0};
bool sense;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -145,8 +145,7 @@ namespace DiscImageChef.Devices
/// <param name="page">The Extended Vital Product Data</param>
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, byte page, uint timeout)
{
double duration;
return ScsiInquiry(out buffer, out senseBuffer, page, timeout, out duration);
return ScsiInquiry(out buffer, out senseBuffer, page, timeout, out _);
}
/// <summary>
@@ -163,10 +162,9 @@ namespace DiscImageChef.Devices
buffer = new byte[36];
senseBuffer = new byte[32];
byte[] cdb = {(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0};
bool sense;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -200,11 +198,10 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
bool sense;
byte[] buffer = new byte[0];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "TEST UNIT READY took {0} ms.", duration);
@@ -262,7 +259,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
buffer = new byte[255];
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSense;
if(dbd) cdb[1] = 0x08;
@@ -273,7 +269,7 @@ namespace DiscImageChef.Devices
cdb[5] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -349,7 +345,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
buffer = new byte[4096];
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSense10;
if(llbaa) cdb[1] |= 0x10;
@@ -362,7 +357,7 @@ namespace DiscImageChef.Devices
cdb[9] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -437,14 +432,13 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
bool sense;
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
cdb[4] = (byte)((byte)preventMode & 0x03);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
@@ -482,7 +476,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
buffer = new byte[8];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadCapacity;
@@ -498,7 +491,7 @@ namespace DiscImageChef.Devices
}
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY took {0} ms.", duration);
@@ -535,7 +528,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
buffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
cdb[1] = (byte)ScsiServiceActions.ReadCapacity16;
@@ -560,7 +552,7 @@ namespace DiscImageChef.Devices
cdb[13] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ CAPACITY(16) took {0} ms.", duration);
@@ -581,7 +573,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
buffer = new byte[4];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadSerialNumber;
cdb[1] = 0x01;
@@ -591,7 +582,7 @@ namespace DiscImageChef.Devices
cdb[9] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -748,7 +739,6 @@ namespace DiscImageChef.Devices
}
byte[] cdb = new byte[6];
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSelect;
if(pageFormat) cdb[1] += 0x10;
@@ -756,7 +746,7 @@ namespace DiscImageChef.Devices
cdb[4] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "MODE SELECT(6) took {0} ms.", duration);
@@ -793,7 +783,6 @@ namespace DiscImageChef.Devices
}
byte[] cdb = new byte[10];
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSelect10;
if(pageFormat) cdb[1] += 0x10;
@@ -802,7 +791,7 @@ namespace DiscImageChef.Devices
cdb[8] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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)
{
byte[] senseBuffer = new byte[32];
byte[] cdb = new byte[6];
buffer = new byte[252];
bool sense;
cdb[0] = (byte)ScsiCommands.RequestSense;
if(descriptor) cdb[1] = 0x01;
@@ -829,8 +816,8 @@ namespace DiscImageChef.Devices
cdb[4] = (byte)buffer.Length;
cdb[5] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
LastError = SendScsiCommand(cdb, ref buffer, out _, timeout, ScsiDirection.In, out duration,
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "REQUEST SENSE took {0} ms.", duration);

View File

@@ -79,7 +79,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.LoadUnload;
if(immediate) cdb[1] = 0x01;
@@ -89,7 +88,7 @@ namespace DiscImageChef.Devices
if(hold) cdb[4] += 0x08;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "LOAD UNLOAD (6) took {0} ms.", duration);
@@ -167,7 +166,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Locate;
if(immediate) cdb[1] += 0x01;
@@ -180,7 +178,7 @@ namespace DiscImageChef.Devices
cdb[8] = partition;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "LOCATE (10) took {0} ms.", duration);
@@ -263,7 +261,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
byte[] buffer = new byte[0];
bool sense;
byte[] idBytes = BitConverter.GetBytes(identifier);
cdb[0] = (byte)ScsiCommands.Locate16;
@@ -283,7 +280,7 @@ namespace DiscImageChef.Devices
cdb[11] = idBytes[0];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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,
uint blockSize, uint timeout, out double duration)
{
if(fixedLen) buffer = new byte[blockSize * transferLen];
else buffer = new byte[transferLen];
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.Read6;
if(fixedLen) cdb[1] += 0x01;
@@ -349,7 +344,7 @@ namespace DiscImageChef.Devices
cdb[4] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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,
ulong objectId, uint transferLen, uint objectSize, uint timeout, out double duration)
{
if(fixedLen) buffer = new byte[objectSize * transferLen];
else buffer = new byte[transferLen];
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
byte[] idBytes = BitConverter.GetBytes(objectId);
cdb[0] = (byte)ScsiCommands.Read16;
@@ -469,7 +462,7 @@ namespace DiscImageChef.Devices
cdb[14] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ (16) took {0} ms.", duration);
@@ -489,12 +482,11 @@ namespace DiscImageChef.Devices
buffer = new byte[6];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadBlockLimits;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "READ BLOCK LIMITS took {0} ms.", duration);
@@ -580,7 +572,6 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[10];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadPosition;
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,
out sense);
out bool sense);
Error = LastError != 0;
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,
uint transferLen, uint blockSize, uint timeout, out double duration)
{
if(fixedLen) buffer = new byte[blockSize * transferLen];
else buffer = new byte[transferLen];
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ReadReverse;
if(fixedLen) cdb[1] += 0x01;
@@ -662,7 +651,7 @@ namespace DiscImageChef.Devices
cdb[4] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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,
out double duration)
{
if(fixedLen) buffer = new byte[objectSize * transferLen];
else buffer = new byte[transferLen];
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
byte[] idBytes = BitConverter.GetBytes(objectId);
cdb[0] = (byte)ScsiCommands.Read16;
@@ -785,7 +772,7 @@ namespace DiscImageChef.Devices
cdb[14] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
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,
uint transferLen, uint blockSize, uint timeout, out double duration)
{
if(fixedLen) buffer = new byte[blockSize * transferLen];
else buffer = new byte[transferLen];
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.RecoverBufferedData;
if(fixedLen) cdb[1] += 0x01;
@@ -854,7 +839,7 @@ namespace DiscImageChef.Devices
cdb[4] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "RECOVER BUFFERED DATA took {0} ms.", duration);
@@ -903,7 +888,6 @@ namespace DiscImageChef.Devices
buffer = new byte[256];
byte[] cdb = new byte[10];
senseBuffer = new byte[32];
bool sense;
cdb[0] = (byte)ScsiCommands.ReportDensitySupport;
if(currentMedia) cdb[1] += 0x01;
@@ -912,7 +896,7 @@ namespace DiscImageChef.Devices
cdb[8] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
out bool sense);
Error = LastError != 0;
if(sense) return true;
@@ -955,13 +939,12 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Rewind;
if(immediate) cdb[1] += 0x01;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "REWIND took {0} ms.", duration);
@@ -982,13 +965,12 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.TrackSelect;
cdb[5] = track;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "TRACK SELECT took {0} ms.", duration);
@@ -1001,7 +983,6 @@ namespace DiscImageChef.Devices
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
byte[] countB = BitConverter.GetBytes(count);
cdb[0] = (byte)ScsiCommands.Space;
@@ -1011,7 +992,7 @@ namespace DiscImageChef.Devices
cdb[4] = countB[0];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out sense);
out bool sense);
Error = LastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "SPACE took {0} ms.", duration);

View File

@@ -97,8 +97,7 @@ namespace DiscImageChef.Devices
if(readLong) cdb[5] += 0x40;
if(!inhibitDma && !readLong)
if(transferLength == 0) buffer = new byte[256 * blockSize];
else buffer = new byte[transferLength * blockSize];
buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize];
else if(readLong)
{
buffer = new byte[blockSize];