Code cleanup.

This commit is contained in:
2018-06-22 08:08:38 +01:00
parent 82f474c7e3
commit 88da8fc019
581 changed files with 22423 additions and 20839 deletions

View File

@@ -70,7 +70,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.AdaptecTranslate;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
if(drive1) cdb[1] += 0x20;
@@ -105,7 +105,7 @@ namespace DiscImageChef.Devices
/// <param name="drive1">If set to <c>true</c> set the threshold from drive 1.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, bool drive1, uint timeout,
public bool AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, bool drive1, uint timeout,
out double duration)
{
byte[] buffer = new byte[1];

View File

@@ -53,7 +53,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
cdb[4] = 3;
@@ -90,12 +90,12 @@ namespace DiscImageChef.Devices
out double duration)
{
byte[] buffer = new byte[0];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
if(immediate) cdb[1] += 0x01;

View File

@@ -70,7 +70,7 @@ namespace DiscImageChef.Devices
public bool CertanceParkUnpark(out byte[] senseBuffer, bool park, uint timeout, out double duration)
{
byte[] buffer = new byte[0];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
cdb[0] = (byte)ScsiCommands.CertanceParkUnpark;

View File

@@ -38,22 +38,23 @@ namespace DiscImageChef.Devices
{
public partial class Device
{
public bool FujitsuDisplay(out byte[] senseBuffer, bool flash, FujitsuDisplayModes mode, string firstHalf,
string secondHalf, uint timeout, out double duration)
public bool FujitsuDisplay(out byte[] senseBuffer, bool flash, FujitsuDisplayModes mode, string firstHalf,
string secondHalf, uint timeout, out double duration)
{
byte[] tmp;
byte[] firstHalfBytes = new byte[8];
byte[] firstHalfBytes = new byte[8];
byte[] secondHalfBytes = new byte[8];
byte[] buffer = new byte[17];
bool displayLen = false;
bool halfMsg = false;
byte[] cdb = new byte[10];
byte[] buffer = new byte[17];
bool displayLen = false;
bool halfMsg = false;
byte[] cdb = new byte[10];
if(!string.IsNullOrWhiteSpace(firstHalf))
{
tmp = Encoding.ASCII.GetBytes(firstHalf);
Array.Copy(tmp, 0, firstHalfBytes, 0, 8);
}
if(!string.IsNullOrWhiteSpace(secondHalf))
{
tmp = Encoding.ASCII.GetBytes(secondHalf);
@@ -62,17 +63,18 @@ namespace DiscImageChef.Devices
if(mode != FujitsuDisplayModes.Half)
if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
!ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes)) displayLen = true;
!ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes))
displayLen = true;
else if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(firstHalfBytes) &&
ArrayHelpers.ArrayIsNullOrWhiteSpace(secondHalfBytes)) halfMsg = true;
buffer[0] = (byte)((byte)mode << 5);
if(displayLen) buffer[0] += 0x10;
if(flash) buffer[0] += 0x08;
if(halfMsg) buffer[0] += 0x04;
if(flash) buffer[0] += 0x08;
if(halfMsg) buffer[0] += 0x04;
buffer[0] += 0x01; // Always ASCII
Array.Copy(firstHalfBytes, 0, buffer, 1, 8);
Array.Copy(firstHalfBytes, 0, buffer, 1, 8);
Array.Copy(secondHalfBytes, 0, buffer, 9, 8);
cdb[0] = (byte)ScsiCommands.FujitsuDisplay;

View File

@@ -46,22 +46,22 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="lba">Start block address.</param>
/// <param name="transferLength">How many blocks to read.</param>
public bool HlDtStReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
uint timeout, out double duration)
public bool HlDtStReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
buffer = new byte[2064 * transferLength];
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
cdb[1] = 0x48;
cdb[2] = 0x49;
cdb[3] = 0x54;
cdb[4] = 0x01;
cdb[6] = (byte)((lba & 0xFF000000) >> 24);
cdb[7] = (byte)((lba & 0xFF0000) >> 16);
cdb[8] = (byte)((lba & 0xFF00) >> 8);
cdb[9] = (byte)(lba & 0xFF);
cdb[0] = (byte)ScsiCommands.HlDtStVendor;
cdb[1] = 0x48;
cdb[2] = 0x49;
cdb[3] = 0x54;
cdb[4] = 0x01;
cdb[6] = (byte)((lba & 0xFF000000) >> 24);
cdb[7] = (byte)((lba & 0xFF0000) >> 16);
cdb[8] = (byte)((lba & 0xFF00) >> 8);
cdb[9] = (byte)(lba & 0xFF);
cdb[10] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[11] = (byte)(buffer.Length & 0xFF);

View File

@@ -48,8 +48,9 @@ namespace DiscImageChef.Devices
/// <param name="pba">If set to <c>true</c> address contain physical block address.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, ushort blockBytes,
bool pba, uint timeout, out double duration)
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort blockBytes,
bool pba, uint timeout, out double duration)
{
return HpReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
out duration);
@@ -72,8 +73,9 @@ namespace DiscImageChef.Devices
/// </param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout,
public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount,
uint timeout,
out double duration)
{
senseBuffer = new byte[32];
@@ -82,12 +84,12 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReadLong;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[5] = (byte)(address & 0xFF);
cdb[7] = (byte)((transferLen & 0xFF00) >> 8);
cdb[8] = (byte)(transferLen & 0xFF);
if(pba) cdb[9] += 0x80;
if(pba) cdb[9] += 0x80;
if(sectorCount) cdb[9] += 0x40;
buffer = sectorCount ? new byte[blockBytes * transferLen] : new byte[transferLen];

View File

@@ -47,7 +47,7 @@ namespace DiscImageChef.Devices
public bool KreonDeprecatedUnlock(out byte[] senseBuffer, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.KreonCommand;
@@ -111,7 +111,7 @@ namespace DiscImageChef.Devices
public bool KreonSetLockState(out byte[] senseBuffer, KreonLockStates state, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.KreonCommand;
@@ -141,7 +141,7 @@ namespace DiscImageChef.Devices
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[26];
features = 0;
@@ -214,22 +214,22 @@ namespace DiscImageChef.Devices
/// <param name="buffer">The SS sector.</param>
/// <param name="requestNumber">Request number.</param>
public bool KreonExtractSs(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration,
byte requestNumber = 0x00)
byte requestNumber = 0x00)
{
buffer = new byte[2048];
byte[] cdb = new byte[12];
senseBuffer = new byte[32];
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
cdb[1] = 0x00;
cdb[2] = 0xFF;
cdb[3] = 0x02;
cdb[4] = 0xFD;
cdb[5] = 0xFF;
cdb[6] = 0xFE;
cdb[7] = 0x00;
cdb[8] = 0x08;
cdb[9] = 0x00;
cdb[0] = (byte)ScsiCommands.KreonSsCommand;
cdb[1] = 0x00;
cdb[2] = 0xFF;
cdb[3] = 0x02;
cdb[4] = 0xFD;
cdb[5] = 0xFF;
cdb[6] = 0xFE;
cdb[7] = 0x00;
cdb[8] = 0x08;
cdb[9] = 0x00;
cdb[10] = requestNumber;
cdb[11] = 0xC0;

View File

@@ -61,7 +61,7 @@ namespace DiscImageChef.Devices
/// <param name="startingFeatureNumber">Feature number where the feature list should start from</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
uint timeout, out double duration)
{
return GetConfiguration(out buffer, out senseBuffer, startingFeatureNumber, MmcGetConfigurationRt.All,
@@ -78,19 +78,20 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="startingFeatureNumber">Starting Feature number.</param>
/// <param name="rt">Return type, <see cref="MmcGetConfigurationRt" />.</param>
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber,
MmcGetConfigurationRt rt, uint timeout, out double duration)
public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer,
ushort startingFeatureNumber,
MmcGetConfigurationRt rt, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
buffer = new byte[8];
byte[] cdb = new byte[10];
buffer = new byte[8];
cdb[0] = (byte)ScsiCommands.GetConfiguration;
cdb[1] = (byte)((byte)rt & 0x03);
cdb[1] = (byte)((byte)rt & 0x03);
cdb[2] = (byte)((startingFeatureNumber & 0xFF00) >> 8);
cdb[3] = (byte)(startingFeatureNumber & 0xFF);
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
cdb[3] = (byte)(startingFeatureNumber & 0xFF);
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
cdb[9] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -100,10 +101,10 @@ namespace DiscImageChef.Devices
if(sense) return true;
ushort confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4);
buffer = new byte[confLength];
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
buffer = new byte[confLength];
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
@@ -127,26 +128,26 @@ namespace DiscImageChef.Devices
/// <param name="format">Which disc structure are we requesting</param>
/// <param name="agid">AGID used in medium copy protection</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadDiscStructure(out byte[] buffer, out byte[] senseBuffer, MmcDiscStructureMediaType mediaType,
uint address, byte layerNumber, MmcDiscStructureFormat format,
public bool ReadDiscStructure(out byte[] buffer, out byte[] senseBuffer, MmcDiscStructureMediaType mediaType,
uint address, byte layerNumber, MmcDiscStructureFormat format,
byte agid,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
buffer = new byte[8];
byte[] cdb = new byte[12];
buffer = new byte[8];
cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
cdb[1] = (byte)((byte)mediaType & 0x0F);
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[5] = (byte)(address & 0xFF);
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[5] = (byte)(address & 0xFF);
cdb[6] = layerNumber;
cdb[7] = (byte)format;
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
cdb[10] = (byte)((agid & 0x03) << 6);
cdb[9] = (byte)(buffer.Length & 0xFF);
cdb[10] = (byte)((agid & 0x03) << 6);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -155,10 +156,9 @@ namespace DiscImageChef.Devices
if(sense) return true;
ushort strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
// WORKAROUND: Some drives return incorrect length information. As these structures are fixed length just apply known length.
if(mediaType == MmcDiscStructureMediaType.Bd)
{
switch(format)
{
case MmcDiscStructureFormat.DiscInformation:
@@ -180,12 +180,10 @@ namespace DiscImageChef.Devices
buffer = new byte[strctLength];
break;
}
}
else
buffer = new byte[strctLength];
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
else buffer = new byte[strctLength];
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out sense);
@@ -319,27 +317,27 @@ namespace DiscImageChef.Devices
/// <param name="trackSessionNumber">Track/Session number</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadTocPmaAtip(out byte[] buffer, out byte[] senseBuffer, bool msf, byte format,
byte trackSessionNumber, uint timeout, out double duration)
public bool ReadTocPmaAtip(out byte[] buffer, out byte[] senseBuffer, bool msf, byte format,
byte trackSessionNumber, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] cdb = new byte[10];
byte[] tmpBuffer = (format & 0x0F) == 5 ? new byte[32768] : new byte[1024];
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip;
if(msf) cdb[1] = 0x02;
cdb[2] = (byte)(format & 0x0F);
cdb[6] = trackSessionNumber;
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
cdb[2] = (byte)(format & 0x0F);
cdb[6] = trackSessionNumber;
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
Error = LastError != 0;
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
buffer = new byte[strctLength];
buffer = new byte[strctLength];
if(buffer.Length <= tmpBuffer.Length)
{
@@ -386,23 +384,23 @@ namespace DiscImageChef.Devices
MmcDiscInformationDataTypes dataType,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] tmpBuffer = new byte[804];
cdb[0] = (byte)ScsiCommands.ReadDiscInformation;
cdb[1] = (byte)dataType;
cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
cdb[8] = (byte)(tmpBuffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
Error = LastError != 0;
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
if(strctLength > tmpBuffer.Length) strctLength = (uint)tmpBuffer.Length;
buffer = new byte[strctLength];
buffer = new byte[strctLength];
Array.Copy(tmpBuffer, 0, buffer, 0, buffer.Length);
DicConsole.DebugWriteLine("SCSI Device", "READ DISC INFORMATION took {0} ms.", duration);
@@ -430,32 +428,34 @@ namespace DiscImageChef.Devices
/// <param name="edcEcc">If set to <c>true</c> we request the EDC/ECC fields for data sectors.</param>
/// <param name="c2Error">C2 error options.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool ReadCd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
uint transferLength,
MmcSectorTypes expectedSectorType, bool dap, bool relAddr, bool sync,
MmcHeaderCodes headerCodes, bool userData, bool edcEcc, MmcErrorField c2Error,
MmcSubchannel subchannel, uint timeout, out double duration)
public bool ReadCd(out byte[] buffer, out byte[] senseBuffer, uint lba,
uint blockSize, uint transferLength,
MmcSectorTypes expectedSectorType, bool dap, bool relAddr,
bool sync,
MmcHeaderCodes headerCodes, bool userData, bool edcEcc,
MmcErrorField c2Error,
MmcSubchannel subchannel, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.ReadCd;
cdb[1] = (byte)((byte)expectedSectorType << 2);
if(dap) cdb[1] += 0x02;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)(transferLength & 0xFF);
cdb[9] = (byte)((byte)c2Error << 1);
cdb[9] += (byte)((byte)headerCodes << 5);
cdb[0] = (byte)ScsiCommands.ReadCd;
cdb[1] = (byte)((byte)expectedSectorType << 2);
if(dap) cdb[1] += 0x02;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)(transferLength & 0xFF);
cdb[9] = (byte)((byte)c2Error << 1);
cdb[9] += (byte)((byte)headerCodes << 5);
if(sync) cdb[9] += 0x80;
if(userData) cdb[9] += 0x10;
if(edcEcc) cdb[9] += 0x08;
cdb[10] = (byte)subchannel;
cdb[10] = (byte)subchannel;
buffer = new byte[blockSize * transferLength];
@@ -487,32 +487,32 @@ namespace DiscImageChef.Devices
/// <param name="edcEcc">If set to <c>true</c> we request the EDC/ECC fields for data sectors.</param>
/// <param name="c2Error">C2 error options.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool ReadCdMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf,
uint endMsf, uint blockSize,
MmcSectorTypes expectedSectorType, bool dap, bool sync,
public bool ReadCdMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf,
uint endMsf, uint blockSize,
MmcSectorTypes expectedSectorType, bool dap, bool sync,
MmcHeaderCodes headerCodes,
bool userData, bool edcEcc, MmcErrorField c2Error,
bool userData, bool edcEcc, MmcErrorField c2Error,
MmcSubchannel subchannel, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
cdb[1] = (byte)((byte)expectedSectorType << 2);
if(dap) cdb[1] += 0x02;
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
cdb[5] = (byte)(startMsf & 0xFF);
cdb[6] = (byte)((endMsf & 0xFF0000) >> 16);
cdb[7] = (byte)((endMsf & 0xFF00) >> 8);
cdb[8] = (byte)(endMsf & 0xFF);
cdb[9] = (byte)((byte)c2Error << 1);
cdb[9] += (byte)((byte)headerCodes << 5);
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
cdb[1] = (byte)((byte)expectedSectorType << 2);
if(dap) cdb[1] += 0x02;
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
cdb[5] = (byte)(startMsf & 0xFF);
cdb[6] = (byte)((endMsf & 0xFF0000) >> 16);
cdb[7] = (byte)((endMsf & 0xFF00) >> 8);
cdb[8] = (byte)(endMsf & 0xFF);
cdb[9] = (byte)((byte)c2Error << 1);
cdb[9] += (byte)((byte)headerCodes << 5);
if(sync) cdb[9] += 0x80;
if(userData) cdb[9] += 0x10;
if(edcEcc) cdb[9] += 0x08;
cdb[10] = (byte)subchannel;
cdb[10] = (byte)subchannel;
uint transferLength = (uint)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5]));
@@ -540,11 +540,11 @@ namespace DiscImageChef.Devices
public bool PreventAllowMediumRemoval(out byte[] senseBuffer, bool persistent, bool prevent, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
if(prevent) cdb[4] += 0x01;
if(persistent) cdb[4] += 0x02;
@@ -577,15 +577,15 @@ namespace DiscImageChef.Devices
return StartStopUnit(out senseBuffer, false, 0, 0, false, false, false, timeout, out duration);
}
public bool StartStopUnit(out byte[] senseBuffer, bool immediate, byte formatLayer, byte powerConditions,
bool changeFormatLayer, bool loadEject, bool start, uint timeout,
public bool StartStopUnit(out byte[] senseBuffer, bool immediate, byte formatLayer, byte powerConditions,
bool changeFormatLayer, bool loadEject, bool start, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.StartStopUnit;
cdb[0] = (byte)ScsiCommands.StartStopUnit;
if(immediate) cdb[1] += 0x01;
if(changeFormatLayer)
{
@@ -613,15 +613,15 @@ namespace DiscImageChef.Devices
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
mcn = null;
byte[] cdb = new byte[10];
mcn = null;
cdb[0] = (byte)ScsiCommands.ReadSubChannel;
cdb[1] = 0;
cdb[2] = 0x40;
cdb[3] = 0x02;
cdb[7] = (23 & 0xFF00) >> 8;
cdb[8] = 23 & 0xFF;
cdb[8] = 23 & 0xFF;
buffer = new byte[23];
@@ -636,12 +636,13 @@ namespace DiscImageChef.Devices
return sense;
}
public bool ReadIsrc(byte trackNumber, out string isrc, out byte[] buffer, out byte[] senseBuffer, uint timeout,
out double duration)
public bool ReadIsrc(byte trackNumber, out string isrc, out byte[] buffer, out byte[] senseBuffer,
uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
isrc = null;
byte[] cdb = new byte[10];
isrc = null;
cdb[0] = (byte)ScsiCommands.ReadSubChannel;
cdb[1] = 0;
@@ -649,7 +650,7 @@ namespace DiscImageChef.Devices
cdb[3] = 0x03;
cdb[6] = trackNumber;
cdb[7] = (23 & 0xFF00) >> 8;
cdb[8] = 23 & 0xFF;
cdb[8] = 23 & 0xFF;
buffer = new byte[23];

View File

@@ -54,8 +54,8 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.NecReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)(transferLength & 0xFF);

View File

@@ -48,21 +48,21 @@ namespace DiscImageChef.Devices
/// <param name="transferLength">How many blocks to read.</param>
/// <param name="blockSize">Block size.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool PioneerReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
uint transferLength, PioneerSubchannel subchannel, uint timeout,
public bool PioneerReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
uint transferLength, PioneerSubchannel subchannel, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.ReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
cdb[0] = (byte)ScsiCommands.ReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
cdb[10] = (byte)subchannel;
buffer = new byte[blockSize * transferLength];
@@ -88,19 +88,21 @@ namespace DiscImageChef.Devices
/// <param name="endMsf">End MM:SS:FF of read encoded as 0x00MMSSFF.</param>
/// <param name="blockSize">Block size.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool PioneerReadCdDaMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf, uint endMsf,
uint blockSize, PioneerSubchannel subchannel, uint timeout, out double duration)
public bool PioneerReadCdDaMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf,
uint endMsf,
uint blockSize, PioneerSubchannel subchannel, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
cdb[5] = (byte)(startMsf & 0xFF);
cdb[7] = (byte)((endMsf & 0xFF0000) >> 16);
cdb[8] = (byte)((endMsf & 0xFF00) >> 8);
cdb[9] = (byte)(endMsf & 0xFF);
cdb[0] = (byte)ScsiCommands.ReadCdDaMsf;
cdb[3] = (byte)((startMsf & 0xFF0000) >> 16);
cdb[4] = (byte)((startMsf & 0xFF00) >> 8);
cdb[5] = (byte)(startMsf & 0xFF);
cdb[7] = (byte)((endMsf & 0xFF0000) >> 16);
cdb[8] = (byte)((endMsf & 0xFF00) >> 8);
cdb[9] = (byte)(endMsf & 0xFF);
cdb[10] = (byte)subchannel;
uint transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5]));
@@ -130,19 +132,20 @@ namespace DiscImageChef.Devices
/// <param name="wholeSector">If set to <c>true</c>, returns all 2352 bytes of sector data.</param>
/// <param name="lba">Start block address.</param>
/// <param name="transferLength">How many blocks to read.</param>
public bool PioneerReadCdXa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
bool errorFlags, bool wholeSector, uint timeout, out double duration)
public bool PioneerReadCdXa(out byte[] buffer, out byte[] senseBuffer, uint lba,
uint transferLength,
bool errorFlags, bool wholeSector, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.ReadCdXa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
if(errorFlags)

View File

@@ -48,8 +48,8 @@ namespace DiscImageChef.Devices
/// <param name="pba">If set to <c>true</c> address contain physical block address.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort blockBytes, bool pba, uint timeout, out double duration)
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort blockBytes, bool pba, uint timeout, out double duration)
{
return HpReadLong(out buffer, out senseBuffer, relAddr, address, 0, blockBytes, pba, false, timeout,
out duration);
@@ -72,12 +72,13 @@ namespace DiscImageChef.Devices
/// </param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout,
public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address,
ushort transferLen, ushort blockBytes, bool pba, bool sectorCount,
uint timeout,
out double duration)
{
return HpReadLong(out buffer, out senseBuffer, relAddr, address, transferLen, blockBytes, pba, sectorCount,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -90,16 +91,16 @@ namespace DiscImageChef.Devices
/// <param name="pba">If set to <c>true</c> address contain a physical block address.</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool PlasmonReadSectorLocation(out byte[] buffer, out byte[] senseBuffer, uint address, bool pba,
uint timeout, out double duration)
public bool PlasmonReadSectorLocation(out byte[] buffer, out byte[] senseBuffer, uint address, bool pba,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation;
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[5] = (byte)(address & 0xFF);
if(pba) cdb[9] += 0x80;

View File

@@ -49,22 +49,22 @@ namespace DiscImageChef.Devices
/// <param name="transferLength">How many blocks to read.</param>
/// <param name="blockSize">Block size.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool PlextorReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
uint transferLength, PlextorSubchannel subchannel, uint timeout,
public bool PlextorReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
uint transferLength, PlextorSubchannel subchannel, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.ReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
cdb[0] = (byte)ScsiCommands.ReadCdDa;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
cdb[10] = (byte)subchannel;
buffer = new byte[blockSize * transferLength];
@@ -88,8 +88,8 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="lba">Start block address.</param>
/// <param name="transferLength">How many blocks to read.</param>
public bool PlextorReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
uint timeout, out double duration)
public bool PlextorReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
@@ -98,10 +98,10 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReadBuffer;
cdb[1] = 0x02;
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[3] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[4] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[4] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[5] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -123,7 +123,7 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorReadEepromCdr(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[256];
buffer = new byte[256];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
@@ -149,7 +149,7 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorReadEeprom(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[512];
buffer = new byte[512];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
@@ -175,10 +175,10 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">How many bytes are in the EEPROM block</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool PlextorReadEepromBlock(out byte[] buffer, out byte[] senseBuffer, byte block, ushort blockSize,
uint timeout, out double duration)
public bool PlextorReadEepromBlock(out byte[] buffer, out byte[] senseBuffer, byte block, ushort blockSize,
uint timeout, out double duration)
{
buffer = new byte[blockSize];
buffer = new byte[blockSize];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
@@ -208,15 +208,15 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool PlextorGetSpeeds(out byte[] senseBuffer, out ushort selected, out ushort max, out ushort last,
uint timeout, out double duration)
uint timeout, out double duration)
{
byte[] buf = new byte[10];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
selected = 0;
max = 0;
last = 0;
max = 0;
last = 0;
cdb[0] = (byte)ScsiCommands.PlextorPoweRec;
cdb[9] = (byte)buf.Length;
@@ -230,9 +230,9 @@ namespace DiscImageChef.Devices
if(sense || Error) return sense;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
selected = BigEndianBitConverter.ToUInt16(buf, 4);
max = BigEndianBitConverter.ToUInt16(buf, 6);
last = BigEndianBitConverter.ToUInt16(buf, 8);
selected = BigEndianBitConverter.ToUInt16(buf, 4);
max = BigEndianBitConverter.ToUInt16(buf, 6);
last = BigEndianBitConverter.ToUInt16(buf, 8);
return false;
}
@@ -254,7 +254,7 @@ namespace DiscImageChef.Devices
byte[] cdb = new byte[12];
enabled = false;
speed = 0;
speed = 0;
cdb[0] = (byte)ScsiCommands.PlextorExtend2;
cdb[1] = (byte)PlextorSubCommands.GetMode;
@@ -269,8 +269,8 @@ namespace DiscImageChef.Devices
if(sense || Error) return sense;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
enabled = buf[2] != 0;
speed = BigEndianBitConverter.ToUInt16(buf, 4);
enabled = buf[2] != 0;
speed = BigEndianBitConverter.ToUInt16(buf, 4);
return false;
}
@@ -285,14 +285,14 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorGetSilentMode(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.Silent;
cdb[3] = 4;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.Silent;
cdb[3] = 4;
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -314,13 +314,13 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorGetGigaRec(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.GigaRec;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.GigaRec;
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -344,17 +344,17 @@ namespace DiscImageChef.Devices
public bool PlextorGetVariRec(out byte[] buffer, out byte[] senseBuffer, bool dvd, uint timeout,
out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.VariRec;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.VariRec;
cdb[10] = (byte)buffer.Length;
if(dvd) cdb[3] = 0x12;
else cdb[3] = 0x02;
else cdb[3] = 0x02;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -375,12 +375,12 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorGetSecuRec(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[2] = (byte)PlextorSubCommands.SecuRec;
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,
@@ -402,13 +402,13 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorGetSpeedRead(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.SpeedRead;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.SpeedRead;
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -430,7 +430,7 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param>
public bool PlextorGetHiding(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
@@ -460,7 +460,7 @@ namespace DiscImageChef.Devices
public bool PlextorGetBitsetting(out byte[] buffer, out byte[] senseBuffer, bool dualLayer, uint timeout,
out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
@@ -470,7 +470,7 @@ namespace DiscImageChef.Devices
cdb[9] = (byte)buffer.Length;
if(dualLayer) cdb[3] = (byte)PlextorSubCommands.BitSetRdl;
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
else cdb[3] = (byte)PlextorSubCommands.BitSetR;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -492,13 +492,13 @@ namespace DiscImageChef.Devices
public bool PlextorGetTestWriteDvdPlus(out byte[] buffer, out byte[] senseBuffer, uint timeout,
out double duration)
{
buffer = new byte[8];
buffer = new byte[8];
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus;
cdb[0] = (byte)ScsiCommands.PlextorExtend;
cdb[1] = (byte)PlextorSubCommands.GetMode;
cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus;
cdb[10] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,

View File

@@ -64,20 +64,20 @@ namespace DiscImageChef.Devices
/// <param name="lba">Starting block.</param>
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="transferLength">How many blocks to read.</param>
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, byte transferLength,
uint timeout, out double duration)
public bool Read6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, byte transferLength,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
cdb[0] = (byte)ScsiCommands.Read6;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
cdb[4] = transferLength;
if(transferLength == 0) buffer = new byte[256 * blockSize];
else buffer = new byte[transferLength * blockSize];
if(transferLength == 0) buffer = new byte[256 * blockSize];
else buffer = new byte[transferLength * blockSize];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -111,23 +111,25 @@ namespace DiscImageChef.Devices
/// <param name="groupNumber">Group number where attributes associated with this command should be collected.</param>
/// <param name="transferLength">How many blocks to read.</param>
/// <param name="relAddr">If set to <c>true</c> address is relative to current position.</param>
public bool Read10(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv,
bool relAddr, uint lba, uint blockSize, byte groupNumber, ushort transferLength,
uint timeout, out double duration)
public bool Read10(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua,
bool fuaNv,
bool relAddr, uint lba, uint blockSize, byte groupNumber,
ushort transferLength,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
cdb[0] = (byte)ScsiCommands.Read10;
cdb[1] = (byte)((rdprotect & 0x07) << 5);
if(dpo) cdb[1] += 0x10;
if(fua) cdb[1] += 0x08;
if(fuaNv) cdb[1] += 0x02;
if(dpo) cdb[1] += 0x10;
if(fua) cdb[1] += 0x08;
if(fuaNv) cdb[1] += 0x02;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)(groupNumber & 0x1F);
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)(transferLength & 0xFF);
@@ -167,28 +169,30 @@ namespace DiscImageChef.Devices
/// <param name="transferLength">How many blocks to read.</param>
/// <param name="streaming">If set to <c>true</c> the stream playback operation should be used (MMC only).</param>
/// <param name="relAddr">If set to <c>true</c> address is relative to current position.</param>
public bool Read12(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv,
bool relAddr, uint lba, uint blockSize, byte groupNumber, uint transferLength,
bool streaming, uint timeout, out double duration)
public bool Read12(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo,
bool fua, bool fuaNv,
bool relAddr, uint lba, uint blockSize, byte groupNumber,
uint transferLength,
bool streaming, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
cdb[0] = (byte)ScsiCommands.Read12;
cdb[1] = (byte)((rdprotect & 0x07) << 5);
if(dpo) cdb[1] += 0x10;
if(fua) cdb[1] += 0x08;
if(fuaNv) cdb[1] += 0x02;
if(dpo) cdb[1] += 0x10;
if(fua) cdb[1] += 0x08;
if(fuaNv) cdb[1] += 0x02;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
cdb[10] = (byte)(groupNumber & 0x1F);
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[6] = (byte)((transferLength & 0xFF000000) >> 24);
cdb[7] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[8] = (byte)((transferLength & 0xFF00) >> 8);
cdb[9] = (byte)(transferLength & 0xFF);
cdb[10] = (byte)(groupNumber & 0x1F);
if(streaming) cdb[10] += 0x80;
buffer = new byte[transferLength * blockSize];
@@ -225,32 +229,34 @@ namespace DiscImageChef.Devices
/// <param name="groupNumber">Group number where attributes associated with this command should be collected.</param>
/// <param name="transferLength">How many blocks to read.</param>
/// <param name="streaming">If set to <c>true</c> the stream playback operation should be used (MMC only).</param>
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv,
ulong lba, uint blockSize, byte groupNumber, uint transferLength, bool streaming,
uint timeout, out double duration)
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua,
bool fuaNv,
ulong lba, uint blockSize, byte groupNumber, uint transferLength,
bool streaming,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
byte[] cdb = new byte[16];
byte[] lbaBytes = BitConverter.GetBytes(lba);
cdb[0] = (byte)ScsiCommands.Read16;
cdb[1] = (byte)((rdprotect & 0x07) << 5);
if(dpo) cdb[1] += 0x10;
if(fua) cdb[1] += 0x08;
if(dpo) cdb[1] += 0x10;
if(fua) cdb[1] += 0x08;
if(fuaNv) cdb[1] += 0x02;
cdb[2] = lbaBytes[7];
cdb[3] = lbaBytes[6];
cdb[4] = lbaBytes[5];
cdb[5] = lbaBytes[4];
cdb[6] = lbaBytes[3];
cdb[7] = lbaBytes[2];
cdb[8] = lbaBytes[1];
cdb[9] = lbaBytes[0];
cdb[2] = lbaBytes[7];
cdb[3] = lbaBytes[6];
cdb[4] = lbaBytes[5];
cdb[5] = lbaBytes[4];
cdb[6] = lbaBytes[3];
cdb[7] = lbaBytes[2];
cdb[8] = lbaBytes[1];
cdb[9] = lbaBytes[0];
cdb[10] = (byte)((transferLength & 0xFF000000) >> 24);
cdb[11] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[12] = (byte)((transferLength & 0xFF00) >> 8);
cdb[11] = (byte)((transferLength & 0xFF0000) >> 16);
cdb[12] = (byte)((transferLength & 0xFF00) >> 8);
cdb[13] = (byte)(transferLength & 0xFF);
cdb[14] = (byte)(groupNumber & 0x1F);
cdb[14] = (byte)(groupNumber & 0x1F);
if(streaming) cdb[14] += 0x80;
buffer = new byte[transferLength * blockSize];
@@ -279,8 +285,9 @@ namespace DiscImageChef.Devices
/// How many bytes to read. If the number is not exactly the drive's size, the command will
/// fail and incidate a delta of the size in SENSE.
/// </param>
public bool ReadLong10(out byte[] buffer, out byte[] senseBuffer, bool correct, bool relAddr, uint lba,
ushort transferBytes, uint timeout, out double duration)
public bool ReadLong10(out byte[] buffer, out byte[] senseBuffer, bool correct, bool relAddr,
uint lba,
ushort transferBytes, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
@@ -289,8 +296,8 @@ namespace DiscImageChef.Devices
if(correct) cdb[1] += 0x02;
if(relAddr) cdb[1] += 0x01;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[7] = (byte)((transferBytes & 0xFF00) >> 8);
cdb[8] = (byte)(transferBytes & 0xFF);
@@ -320,23 +327,23 @@ namespace DiscImageChef.Devices
/// How many bytes to read. If the number is not exactly the drive's size, the command will
/// fail and incidate a delta of the size in SENSE.
/// </param>
public bool ReadLong16(out byte[] buffer, out byte[] senseBuffer, bool correct, ulong lba, uint transferBytes,
uint timeout, out double duration)
public bool ReadLong16(out byte[] buffer, out byte[] senseBuffer, bool correct, ulong lba, uint transferBytes,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
byte[] cdb = new byte[16];
byte[] lbaBytes = BitConverter.GetBytes(lba);
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
cdb[1] = (byte)ScsiServiceActions.ReadLong16;
cdb[2] = lbaBytes[7];
cdb[3] = lbaBytes[6];
cdb[4] = lbaBytes[5];
cdb[5] = lbaBytes[4];
cdb[6] = lbaBytes[3];
cdb[7] = lbaBytes[2];
cdb[8] = lbaBytes[1];
cdb[9] = lbaBytes[0];
cdb[0] = (byte)ScsiCommands.ServiceActionIn;
cdb[1] = (byte)ScsiServiceActions.ReadLong16;
cdb[2] = lbaBytes[7];
cdb[3] = lbaBytes[6];
cdb[4] = lbaBytes[5];
cdb[5] = lbaBytes[4];
cdb[6] = lbaBytes[3];
cdb[7] = lbaBytes[2];
cdb[8] = lbaBytes[1];
cdb[9] = lbaBytes[0];
cdb[12] = (byte)((transferBytes & 0xFF00) >> 8);
cdb[13] = (byte)(transferBytes & 0xFF);
if(correct) cdb[14] += 0x01;
@@ -362,12 +369,12 @@ namespace DiscImageChef.Devices
public bool Seek6(out byte[] senseBuffer, uint lba, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.Seek6;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
@@ -389,13 +396,13 @@ namespace DiscImageChef.Devices
public bool Seek10(out byte[] senseBuffer, uint lba, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] cdb = new byte[10];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.Seek10;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,

View File

@@ -50,26 +50,28 @@ namespace DiscImageChef.Devices
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, ushort element,
byte elementType, byte volume, byte partition, ushort firstAttribute, bool cache,
uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
ushort element,
byte elementType, byte volume, byte partition,
ushort firstAttribute, bool cache,
uint timeout, out double duration)
{
buffer = new byte[256];
byte[] cdb = new byte[16];
senseBuffer = new byte[32];
cdb[0] = (byte)ScsiCommands.ReadAttribute;
cdb[1] = (byte)((byte)action & 0x1F);
cdb[2] = (byte)((element & 0xFF00) >> 8);
cdb[3] = (byte)(element & 0xFF);
cdb[4] = (byte)(elementType & 0x0F);
cdb[5] = volume;
cdb[7] = partition;
cdb[8] = (byte)((firstAttribute & 0xFF00) >> 8);
cdb[9] = (byte)(firstAttribute & 0xFF);
cdb[0] = (byte)ScsiCommands.ReadAttribute;
cdb[1] = (byte)((byte)action & 0x1F);
cdb[2] = (byte)((element & 0xFF00) >> 8);
cdb[3] = (byte)(element & 0xFF);
cdb[4] = (byte)(elementType & 0x0F);
cdb[5] = volume;
cdb[7] = partition;
cdb[8] = (byte)((firstAttribute & 0xFF00) >> 8);
cdb[9] = (byte)(firstAttribute & 0xFF);
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[13] = (byte)(buffer.Length & 0xFF);
if(cache) cdb[14] += 0x01;
@@ -80,11 +82,11 @@ namespace DiscImageChef.Devices
if(sense) return true;
uint attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4);
buffer = new byte[attrLen];
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[13] = (byte)(buffer.Length & 0xFF);
buffer = new byte[attrLen];
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[13] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,

View File

@@ -85,7 +85,7 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{
buffer = new byte[36];
buffer = new byte[36];
senseBuffer = new byte[32];
byte[] cdb = {(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0};
@@ -97,8 +97,8 @@ namespace DiscImageChef.Devices
byte pagesLength = (byte)(buffer[4] + 5);
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0};
buffer = new byte[pagesLength];
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0};
buffer = new byte[pagesLength];
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -159,7 +159,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, out double duration)
{
buffer = new byte[36];
buffer = new byte[36];
senseBuffer = new byte[32];
byte[] cdb = {(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0};
@@ -174,8 +174,8 @@ namespace DiscImageChef.Devices
byte pagesLength = (byte)(buffer[3] + 4);
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0};
buffer = new byte[pagesLength];
cdb = new byte[] {(byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0};
buffer = new byte[pagesLength];
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -197,7 +197,7 @@ namespace DiscImageChef.Devices
public bool ScsiTestUnitReady(out byte[] senseBuffer, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
byte[] cdb = {(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0};
byte[] buffer = new byte[0];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
@@ -234,8 +234,9 @@ namespace DiscImageChef.Devices
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout,
out double duration)
{
return ModeSense6(out buffer, out senseBuffer, dbd, pageControl, pageCode, 0, timeout, out duration);
}
@@ -252,9 +253,10 @@ namespace DiscImageChef.Devices
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
/// <param name="subPageCode">Sub-page code.</param>
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout,
out double duration)
public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode,
uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
@@ -264,9 +266,9 @@ namespace DiscImageChef.Devices
if(dbd) cdb[1] = 0x08;
cdb[2] |= (byte)pageControl;
cdb[2] |= (byte)(pageCode & 0x3F);
cdb[3] = subPageCode;
cdb[4] = (byte)buffer.Length;
cdb[5] = 0;
cdb[3] = subPageCode;
cdb[4] = (byte)buffer.Length;
cdb[5] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -275,8 +277,8 @@ namespace DiscImageChef.Devices
if(sense) return true;
byte modeLength = (byte)(buffer[0] + 1);
buffer = new byte[modeLength];
cdb[4] = (byte)buffer.Length;
buffer = new byte[modeLength];
cdb[4] = (byte)buffer.Length;
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -299,8 +301,9 @@ namespace DiscImageChef.Devices
/// <param name="dbd">If set to <c>true</c> device MUST not return any block descriptor.</param>
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout,
out double duration)
{
return ModeSense10(out buffer, out senseBuffer, false, dbd, pageControl, pageCode, 0, timeout,
out duration);
@@ -318,8 +321,10 @@ namespace DiscImageChef.Devices
/// <param name="pageControl">Page control.</param>
/// <param name="pageCode">Page code.</param>
/// <param name="llbaa">If set means 64-bit LBAs are accepted by the caller.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration)
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa,
bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, uint timeout,
out double duration)
{
return ModeSense10(out buffer, out senseBuffer, llbaa, dbd, pageControl, pageCode, 0, timeout,
out duration);
@@ -338,9 +343,11 @@ namespace DiscImageChef.Devices
/// <param name="pageCode">Page code.</param>
/// <param name="subPageCode">Sub-page code.</param>
/// <param name="llbaa">If set means 64-bit LBAs are accepted by the caller.</param>
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout,
out double duration)
public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa,
bool dbd,
ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode,
uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
@@ -348,13 +355,13 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ModeSense10;
if(llbaa) cdb[1] |= 0x10;
if(dbd) cdb[1] |= 0x08;
if(dbd) cdb[1] |= 0x08;
cdb[2] |= (byte)pageControl;
cdb[2] |= (byte)(pageCode & 0x3F);
cdb[3] = subPageCode;
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
cdb[9] = 0;
cdb[3] = subPageCode;
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
cdb[9] = 0;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -363,9 +370,9 @@ namespace DiscImageChef.Devices
if(sense) return true;
ushort modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
buffer = new byte[modeLength];
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
buffer = new byte[modeLength];
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -431,7 +438,7 @@ namespace DiscImageChef.Devices
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
@@ -470,8 +477,8 @@ namespace DiscImageChef.Devices
/// <param name="pmi">If set, it is requesting partial media capacity</param>
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, bool pmi,
uint timeout, out double duration)
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, bool pmi,
uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
@@ -485,8 +492,8 @@ namespace DiscImageChef.Devices
if(relAddr) cdb[1] = 0x01;
cdb[2] = (byte)((address & 0xFF000000) >> 24);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[3] = (byte)((address & 0xFF0000) >> 16);
cdb[4] = (byte)((address & 0xFF00) >> 8);
cdb[5] = (byte)(address & 0xFF);
}
@@ -547,8 +554,8 @@ namespace DiscImageChef.Devices
}
cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[13] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -577,8 +584,8 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReadSerialNumber;
cdb[1] = 0x01;
cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -588,11 +595,11 @@ namespace DiscImageChef.Devices
if(sense) return true;
uint strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4);
buffer = new byte[strctLength];
cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
buffer = new byte[strctLength];
cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24);
cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16);
cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[9] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -615,11 +622,13 @@ namespace DiscImageChef.Devices
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte partition,
ushort firstAttribute, bool cache, uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
byte partition,
ushort firstAttribute, bool cache, uint timeout,
out double duration)
{
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, partition, firstAttribute, cache,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -632,8 +641,9 @@ namespace DiscImageChef.Devices
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
ushort firstAttribute, bool cache, uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
ushort firstAttribute, bool cache, uint timeout,
out double duration)
{
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, cache, timeout,
out duration);
@@ -649,11 +659,12 @@ namespace DiscImageChef.Devices
/// <param name="firstAttribute">First attribute identifier.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte partition,
ushort firstAttribute, uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
byte partition,
ushort firstAttribute, uint timeout, out double duration)
{
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, partition, firstAttribute, false,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -665,8 +676,8 @@ namespace DiscImageChef.Devices
/// <param name="firstAttribute">First attribute identifier.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
ushort firstAttribute, uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
ushort firstAttribute, uint timeout, out double duration)
{
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, false, timeout,
out duration);
@@ -683,11 +694,13 @@ namespace DiscImageChef.Devices
/// <param name="firstAttribute">First attribute identifier.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte volume,
byte partition, ushort firstAttribute, uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
byte volume,
byte partition, ushort firstAttribute, uint timeout,
out double duration)
{
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, false,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -702,11 +715,13 @@ namespace DiscImageChef.Devices
/// <param name="cache">If set to <c>true</c> device can return cached data.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte volume,
byte partition, ushort firstAttribute, bool cache, uint timeout, out double duration)
public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action,
byte volume,
byte partition, ushort firstAttribute, bool cache,
uint timeout, out double duration)
{
return ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, cache,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -719,7 +734,7 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="pageFormat">Set if page is formatted.</param>
public bool ModeSelect(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages, uint timeout,
public bool ModeSelect(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
@@ -727,11 +742,11 @@ namespace DiscImageChef.Devices
// Prevent overflows
if(buffer.Length > 255)
{
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
PlatformId != PlatformID.WindowsPhone && PlatformId != PlatformID.Xbox) LastError = 75;
else LastError = 111;
Error = true;
else LastError = 111;
Error = true;
duration = 0;
return true;
}
@@ -740,7 +755,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ModeSelect;
if(pageFormat) cdb[1] += 0x10;
if(savePages) cdb[1] += 0x01;
if(savePages) cdb[1] += 0x01;
cdb[4] = (byte)buffer.Length;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration,
@@ -762,7 +777,8 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout in seconds.</param>
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
/// <param name="pageFormat">Set if page is formatted.</param>
public bool ModeSelect10(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages, uint timeout,
public bool ModeSelect10(byte[] buffer, out byte[] senseBuffer, bool pageFormat, bool savePages,
uint timeout,
out double duration)
{
senseBuffer = new byte[32];
@@ -770,11 +786,11 @@ namespace DiscImageChef.Devices
// Prevent overflows
if(buffer.Length > 65535)
{
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
if(PlatformId != PlatformID.Win32NT && PlatformId != PlatformID.Win32S &&
PlatformId != PlatformID.Win32Windows && PlatformId != PlatformID.WinCE &&
PlatformId != PlatformID.WindowsPhone && PlatformId != PlatformID.Xbox) LastError = 75;
else LastError = 111;
Error = true;
else LastError = 111;
Error = true;
duration = 0;
return true;
}
@@ -783,7 +799,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ModeSelect10;
if(pageFormat) cdb[1] += 0x10;
if(savePages) cdb[1] += 0x01;
if(savePages) cdb[1] += 0x01;
cdb[7] = (byte)((buffer.Length & 0xFF00) << 8);
cdb[8] = (byte)(buffer.Length & 0xFF);

View File

@@ -76,19 +76,19 @@ namespace DiscImageChef.Devices
/// </param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape,
bool hold, uint timeout, out double duration)
public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape,
bool hold, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.LoadUnload;
if(immediate) cdb[1] = 0x01;
if(load) cdb[4] += 0x01;
if(retense) cdb[4] += 0x02;
if(immediate) cdb[1] = 0x01;
if(load) cdb[4] += 0x01;
if(retense) cdb[4] += 0x02;
if(endOfTape) cdb[4] += 0x04;
if(hold) cdb[4] += 0x08;
if(hold) cdb[4] += 0x08;
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration,
out bool sense);
@@ -163,20 +163,21 @@ namespace DiscImageChef.Devices
/// <param name="objectId">Object identifier.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Locate(out byte[] senseBuffer, bool immediate, bool blockType, bool changePartition, byte partition,
uint objectId, uint timeout, out double duration)
public bool Locate(out byte[] senseBuffer, bool immediate, bool blockType, bool changePartition,
byte partition,
uint objectId, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] cdb = new byte[10];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.Locate;
if(immediate) cdb[1] += 0x01;
if(immediate) cdb[1] += 0x01;
if(changePartition) cdb[1] += 0x02;
if(blockType) cdb[1] += 0x04;
if(blockType) cdb[1] += 0x04;
cdb[3] = (byte)((objectId & 0xFF000000) >> 24);
cdb[4] = (byte)((objectId & 0xFF0000) >> 16);
cdb[5] = (byte)((objectId & 0xFF00) >> 8);
cdb[4] = (byte)((objectId & 0xFF0000) >> 16);
cdb[5] = (byte)((objectId & 0xFF00) >> 8);
cdb[6] = (byte)(objectId & 0xFF);
cdb[8] = partition;
@@ -243,7 +244,7 @@ namespace DiscImageChef.Devices
out double duration)
{
return Locate16(out senseBuffer, immediate, true, SscLogicalIdTypes.ObjectId, false, partition, lba,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -258,27 +259,28 @@ namespace DiscImageChef.Devices
/// <param name="identifier">Destination identifier.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Locate16(out byte[] senseBuffer, bool immediate, bool changePartition, SscLogicalIdTypes destType,
bool bam, byte partition, ulong identifier, uint timeout, out double duration)
public bool Locate16(out byte[] senseBuffer, bool immediate, bool changePartition, SscLogicalIdTypes destType,
bool bam, byte partition, ulong identifier, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[16];
byte[] buffer = new byte[0];
byte[] cdb = new byte[16];
byte[] buffer = new byte[0];
byte[] idBytes = BitConverter.GetBytes(identifier);
cdb[0] = (byte)ScsiCommands.Locate16;
cdb[1] = (byte)((byte)destType << 3);
if(immediate) cdb[1] += 0x01;
if(immediate) cdb[1] += 0x01;
if(changePartition) cdb[1] += 0x02;
if(bam) cdb[2] = 0x01;
if(bam) cdb[2] = 0x01;
cdb[3] = partition;
cdb[4] = idBytes[7];
cdb[5] = idBytes[6];
cdb[6] = idBytes[5];
cdb[7] = idBytes[4];
cdb[8] = idBytes[3];
cdb[9] = idBytes[2];
cdb[4] = idBytes[7];
cdb[5] = idBytes[6];
cdb[6] = idBytes[5];
cdb[7] = idBytes[4];
cdb[8] = idBytes[3];
cdb[9] = idBytes[2];
cdb[10] = idBytes[1];
cdb[11] = idBytes[0];
@@ -315,8 +317,8 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
uint timeout, out double duration)
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
uint timeout, out double duration)
{
return Read6(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout, out duration);
}
@@ -338,8 +340,9 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen, uint transferLen,
uint blockSize, uint timeout, out double duration)
public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
uint transferLen,
uint blockSize, uint timeout, out double duration)
{
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
@@ -347,9 +350,9 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.Read6;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
if(sili) cdb[1] += 0x02;
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
cdb[4] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -372,8 +375,8 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
uint blockSize, uint timeout, out double duration)
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
uint blockSize, uint timeout, out double duration)
{
return Read16(out buffer, out senseBuffer, sili, false, 0, objectId, blocks, blockSize, timeout,
out duration);
@@ -391,8 +394,9 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition, ulong objectId,
uint blocks, uint blockSize, uint timeout, out double duration)
public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition,
ulong objectId,
uint blocks, uint blockSize, uint timeout, out double duration)
{
return Read16(out buffer, out senseBuffer, sili, false, partition, objectId, blocks, blockSize, timeout,
out duration);
@@ -408,8 +412,8 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
uint timeout, out double duration)
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
uint timeout, out double duration)
{
return Read16(out buffer, out senseBuffer, false, true, 0, objectId, blocks, blockSize, timeout,
out duration);
@@ -426,8 +430,9 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId, uint blocks,
uint blockSize, uint timeout, out double duration)
public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
uint blocks,
uint blockSize, uint timeout, out double duration)
{
return Read16(out buffer, out senseBuffer, false, true, partition, objectId, blocks, blockSize, timeout,
out duration);
@@ -452,8 +457,10 @@ namespace DiscImageChef.Devices
/// <param name="objectSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
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)
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)
{
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
@@ -462,18 +469,18 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.Read16;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
cdb[3] = partition;
cdb[4] = idBytes[7];
cdb[5] = idBytes[6];
cdb[6] = idBytes[5];
cdb[7] = idBytes[4];
cdb[8] = idBytes[3];
cdb[9] = idBytes[2];
if(sili) cdb[1] += 0x02;
cdb[3] = partition;
cdb[4] = idBytes[7];
cdb[5] = idBytes[6];
cdb[6] = idBytes[5];
cdb[7] = idBytes[4];
cdb[8] = idBytes[3];
cdb[9] = idBytes[2];
cdb[10] = idBytes[1];
cdb[11] = idBytes[0];
cdb[12] = (byte)((transferLen & 0xFF0000) >> 16);
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
cdb[14] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -543,12 +550,12 @@ namespace DiscImageChef.Devices
/// <param name="totalPosition">Requests current logical position.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, bool vendorType, bool longForm,
bool totalPosition, uint timeout, out double duration)
public bool ReadPosition(out byte[] buffer, out byte[] senseBuffer, bool vendorType, bool longForm,
bool totalPosition, uint timeout, out double duration)
{
byte responseForm = 0;
if(vendorType) responseForm += 0x01;
if(longForm) responseForm += 0x02;
byte responseForm = 0;
if(vendorType) responseForm += 0x01;
if(longForm) responseForm += 0x02;
if(totalPosition) responseForm += 0x04;
return ReadPosition(out buffer, out senseBuffer, (SscPositionForms)responseForm, timeout, out duration);
@@ -631,8 +638,9 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize,
uint timeout, out double duration)
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
uint blockSize,
uint timeout, out double duration)
{
return ReadReverse6(out buffer, out senseBuffer, false, sili, false, transferLen, blockSize, timeout,
out duration);
@@ -656,19 +664,20 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili, bool fixedLen,
uint transferLen, uint blockSize, uint timeout, out double duration)
public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili,
bool fixedLen,
uint transferLen, uint blockSize, uint timeout, out double duration)
{
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
senseBuffer = new byte[32];
cdb[0] = (byte)ScsiCommands.ReadReverse;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
if(byteOrder) cdb[1] += 0x04;
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
cdb[4] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -691,11 +700,12 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks,
uint blockSize, uint timeout, out double duration)
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId,
uint blocks,
uint blockSize, uint timeout, out double duration)
{
return ReadReverse16(out buffer, out senseBuffer, false, sili, false, 0, objectId, blocks, blockSize,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -710,11 +720,12 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition, ulong objectId,
uint blocks, uint blockSize, uint timeout, out double duration)
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition,
ulong objectId,
uint blocks, uint blockSize, uint timeout, out double duration)
{
return ReadReverse16(out buffer, out senseBuffer, false, sili, false, partition, objectId, blocks,
blockSize, timeout, out duration);
blockSize, timeout, out duration);
}
/// <summary>
@@ -727,11 +738,11 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks,
uint blockSize, uint timeout, out double duration)
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks,
uint blockSize, uint timeout, out double duration)
{
return ReadReverse16(out buffer, out senseBuffer, false, false, true, 0, objectId, blocks, blockSize,
timeout, out duration);
timeout, out duration);
}
/// <summary>
@@ -745,11 +756,11 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
uint blocks, uint blockSize, uint timeout, out double duration)
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId,
uint blocks, uint blockSize, uint timeout, out double duration)
{
return ReadReverse16(out buffer, out senseBuffer, false, false, true, partition, objectId, blocks,
blockSize, timeout, out duration);
blockSize, timeout, out duration);
}
/// <summary>
@@ -772,8 +783,10 @@ namespace DiscImageChef.Devices
/// <param name="objectSize">Object size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili, bool fixedLen,
byte partition, ulong objectId, uint transferLen, uint objectSize, uint timeout,
public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool byteOrder, bool sili,
bool fixedLen,
byte partition, ulong objectId, uint transferLen, uint objectSize,
uint timeout,
out double duration)
{
buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen];
@@ -782,20 +795,20 @@ namespace DiscImageChef.Devices
byte[] idBytes = BitConverter.GetBytes(objectId);
cdb[0] = (byte)ScsiCommands.Read16;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
if(byteOrder) cdb[1] += 0x04;
cdb[3] = partition;
cdb[4] = idBytes[7];
cdb[5] = idBytes[6];
cdb[6] = idBytes[5];
cdb[7] = idBytes[4];
cdb[8] = idBytes[3];
cdb[9] = idBytes[2];
cdb[3] = partition;
cdb[4] = idBytes[7];
cdb[5] = idBytes[6];
cdb[6] = idBytes[5];
cdb[7] = idBytes[4];
cdb[8] = idBytes[3];
cdb[9] = idBytes[2];
cdb[10] = idBytes[1];
cdb[11] = idBytes[0];
cdb[12] = (byte)((transferLen & 0xFF0000) >> 16);
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
cdb[13] = (byte)((transferLen & 0xFF00) >> 8);
cdb[14] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -816,8 +829,8 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize,
uint timeout, out double duration)
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize,
uint timeout, out double duration)
{
return RecoverBufferedData(out buffer, out senseBuffer, false, true, blocks, blockSize, timeout,
out duration);
@@ -833,8 +846,8 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
uint blockSize, uint timeout, out double duration)
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen,
uint blockSize, uint timeout, out double duration)
{
return RecoverBufferedData(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout,
out duration);
@@ -857,8 +870,10 @@ namespace DiscImageChef.Devices
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, bool fixedLen,
uint transferLen, uint blockSize, uint timeout, out double duration)
public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili,
bool fixedLen,
uint transferLen, uint blockSize, uint timeout,
out double duration)
{
buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen];
byte[] cdb = new byte[6];
@@ -866,9 +881,9 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.RecoverBufferedData;
if(fixedLen) cdb[1] += 0x01;
if(sili) cdb[1] += 0x02;
if(sili) cdb[1] += 0x02;
cdb[2] = (byte)((transferLen & 0xFF0000) >> 16);
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
cdb[3] = (byte)((transferLen & 0xFF00) >> 8);
cdb[4] = (byte)(transferLen & 0xFF);
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -915,8 +930,8 @@ namespace DiscImageChef.Devices
/// <param name="currentMedia">If set to <c>true</c> descriptors should apply to currently inserted media.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, bool mediumType, bool currentMedia,
uint timeout, out double duration)
public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, bool mediumType, bool currentMedia,
uint timeout, out double duration)
{
buffer = new byte[256];
byte[] cdb = new byte[10];
@@ -924,7 +939,7 @@ namespace DiscImageChef.Devices
cdb[0] = (byte)ScsiCommands.ReportDensitySupport;
if(currentMedia) cdb[1] += 0x01;
if(mediumType) cdb[1] += 0x02;
if(mediumType) cdb[1] += 0x02;
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
@@ -935,9 +950,9 @@ namespace DiscImageChef.Devices
if(sense) return true;
ushort availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
buffer = new byte[availableLength];
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
buffer = new byte[availableLength];
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
cdb[8] = (byte)(buffer.Length & 0xFF);
senseBuffer = new byte[32];
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
@@ -970,7 +985,7 @@ namespace DiscImageChef.Devices
public bool Rewind(out byte[] senseBuffer, bool immediate, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.Rewind;
@@ -996,7 +1011,7 @@ namespace DiscImageChef.Devices
public bool TrackSelect(out byte[] senseBuffer, byte track, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
cdb[0] = (byte)ScsiCommands.TrackSelect;
@@ -1014,7 +1029,7 @@ namespace DiscImageChef.Devices
public bool Space(out byte[] senseBuffer, SscSpaceCodes code, int count, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
byte[] countB = BitConverter.GetBytes(count);

View File

@@ -81,20 +81,21 @@ namespace DiscImageChef.Devices
/// <param name="readLong">If set to <c>true</c> drive will return ECC bytes and disable error detection.</param>
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="transferLength">How many blocks to read.</param>
public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
byte transferLength, bool inhibitDma, bool readLong, uint timeout, out double duration)
public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
byte transferLength, bool inhibitDma, bool readLong, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
bool sense;
bool sense;
cdb[0] = (byte)ScsiCommands.Read6;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
cdb[4] = transferLength;
if(inhibitDma) cdb[5] += 0x80;
if(readLong) cdb[5] += 0x40;
if(readLong) cdb[5] += 0x40;
if(!inhibitDma && !readLong)
buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize];
@@ -161,23 +162,23 @@ namespace DiscImageChef.Devices
/// <param name="readLong">If set to <c>true</c> drive will return ECC bytes and disable error detection.</param>
/// <param name="blockSize">Block size in bytes.</param>
/// <param name="transferLength">How many blocks to read.</param>
public bool SyQuestRead10(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
ushort transferLength, bool inhibitDma, bool readLong, uint timeout,
public bool SyQuestRead10(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize,
ushort transferLength, bool inhibitDma, bool readLong, uint timeout,
out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
bool sense;
bool sense;
cdb[0] = (byte)ScsiCommands.Read10;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
cdb[7] = (byte)((transferLength & 0xFF00) >> 8);
cdb[8] = (byte)(transferLength & 0xFF);
if(inhibitDma) cdb[9] += 0x80;
if(readLong) cdb[9] += 0x40;
if(readLong) cdb[9] += 0x40;
if(!inhibitDma && !readLong) buffer = new byte[transferLength * blockSize];
else if(readLong)