* DiscImageChef.Decoders/SCSI/Modes.cs:

Check for vendor pages not following page format (even if
	  they must).

	* DiscImageChef.Devices/Device/Constructor.cs:
	  Some devices (at least smsc usb-floppy) crash and reset when
	  receiving ata over the ATA PASS-THROUGH scsi command. This
	  will check for SCSI compliance first giving devices time to
	  reset.

	* DiscImageChef.Devices/Device/ScsiCommands.cs:
	  Some devices (smsc usb floppies) return the real command
	  result size disregarding allocation length and generating a
	  buffer overflow.

	* DiscImageChef.Devices/Enums.cs:
	  Added some vendor commands for Plextor and HL-DT-ST devices.

	* DiscImageChef/Commands/DeviceInfo.cs:
	  Mode sense should be written even if it can't be decoded.
This commit is contained in:
2015-11-05 06:50:02 +00:00
parent 626c9062eb
commit 361b8977b0
8 changed files with 110 additions and 49 deletions

View File

@@ -1,3 +1,19 @@
2015-11-05 Natalia Portillo <claunia@claunia.com>
* Device/Constructor.cs:
Some devices (at least smsc usb-floppy) crash and reset when
receiving ata over the ATA PASS-THROUGH scsi command. This
will check for SCSI compliance first giving devices time to
reset.
* Device/ScsiCommands.cs:
Some devices (smsc usb floppies) return the real command
result size disregarding allocation length and generating a
buffer overflow.
* Enums.cs:
Added some vendor commands for Plextor and HL-DT-ST devices.
2015-11-02 Natalia Portillo <claunia@claunia.com>
* Enums.cs:

View File

@@ -95,33 +95,29 @@ namespace DiscImageChef.Devices
AtaErrorRegistersCHS errorRegisters;
byte[] ataBuf;
bool sense = AtaIdentify(out ataBuf, out errorRegisters);
byte[] senseBuf;
byte[] inqBuf;
if (!sense)
bool scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
if (!scsiSense)
{
type = DeviceType.ATA;
Decoders.ATA.Identify.IdentifyDevice? ATAID = Decoders.ATA.Identify.Decode(ataBuf);
Decoders.SCSI.Inquiry.SCSIInquiry? Inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf);
if (ATAID.HasValue)
type = DeviceType.SCSI;
bool sense = ScsiInquiry(out inqBuf, out senseBuf, 0x80);
if (!sense)
serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
if (Inquiry.HasValue)
{
string[] separated = ATAID.Value.Model.Split(' ');
revision = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductRevisionLevel);
model = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductIdentification);
manufacturer = StringHandlers.SpacePaddedToString(Inquiry.Value.VendorIdentification);
if (separated.Length == 1)
model = separated[0];
else
{
manufacturer = separated[0];
model = separated[separated.Length - 1];
}
revision = ATAID.Value.FirmwareRevision;
serial = ATAID.Value.SerialNumber;
scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess;
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)Inquiry.Value.PeripheralDeviceType;
}
}
else
{
sense = AtapiIdentify(out ataBuf, out errorRegisters);
if (!sense)
@@ -132,31 +128,32 @@ namespace DiscImageChef.Devices
if (ATAID.HasValue)
serial = ATAID.Value.SerialNumber;
}
}
byte[] senseBuf;
byte[] inqBuf;
sense = ScsiInquiry(out inqBuf, out senseBuf);
if (scsiSense || manufacturer == "ATA")
{
bool sense = AtaIdentify(out ataBuf, out errorRegisters);
if (!sense)
{
Decoders.SCSI.Inquiry.SCSIInquiry? Inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf);
type = DeviceType.ATA;
Decoders.ATA.Identify.IdentifyDevice? ATAID = Decoders.ATA.Identify.Decode(ataBuf);
if (type != DeviceType.ATAPI)
if (ATAID.HasValue)
{
type = DeviceType.SCSI;
sense = ScsiInquiry(out inqBuf, out senseBuf, 0x80);
if (!sense)
serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
}
string[] separated = ATAID.Value.Model.Split(' ');
if (Inquiry.HasValue)
{
revision = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductRevisionLevel);
model = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductIdentification);
manufacturer = StringHandlers.SpacePaddedToString(Inquiry.Value.VendorIdentification);
if (separated.Length == 1)
model = separated[0];
else
{
manufacturer = separated[0];
model = separated[separated.Length - 1];
}
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)Inquiry.Value.PeripheralDeviceType;
revision = ATAID.Value.FirmwareRevision;
serial = ATAID.Value.SerialNumber;
scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess;
}
}
}

View File

@@ -88,9 +88,9 @@ 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[5];
buffer = new byte[36];
senseBuffer = new byte[32];
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 5, 0 };
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0 };
bool sense;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
@@ -163,9 +163,9 @@ 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[5];
buffer = new byte[36];
senseBuffer = new byte[32];
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 5, 0 };
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0 };
bool sense;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
@@ -174,6 +174,10 @@ namespace DiscImageChef.Devices
if (sense)
return true;
// This is because INQ was returned instead of EVPD
if (buffer[1] != page)
return true;
byte pagesLength = (byte)(buffer[3] + 4);
cdb = new byte[] { (byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0 };
@@ -336,7 +340,7 @@ namespace DiscImageChef.Devices
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
buffer = new byte[4];
buffer = new byte[4096];
bool sense;
cdb[0] = (byte)ScsiCommands.ModeSense10;

View File

@@ -2559,7 +2559,29 @@ namespace DiscImageChef.Devices
/// Variable sized Command Description Block
/// SPC-4 rev. 16
/// </summary>
VariableSizedCDB = 0x7F
VariableSizedCDB = 0x7F,
#region Plextor vendor commands
/// <summary>
/// Sends extended commands (like SpeedRead) to Plextor drives
/// </summary>
Plextor_Extend = 0xE9,
/// <summary>
/// Resets Plextor drives
/// </summary>
Plextor_Reset = 0xEE,
/// <summary>
/// Reads drive statistics from Plextor drives EEPROM
/// </summary>
Plextor_ReadEeprom = 0xF1,
#endregion Plextor vendor commands
#region HL-DT-ST vendor commands
/// <summary>
/// Sends debugging commands to HL-DT-ST DVD drives
/// </summary>
HlDtSt_Vendor = 0xE7
#endregion HL-DT-ST vendor commands
}
#endregion SCSI Commands