Added option to dump binary responses got from devices while

getting device info.
This commit is contained in:
2015-11-02 21:08:38 +00:00
parent ca8a152d8f
commit 626c9062eb
3 changed files with 178 additions and 0 deletions

View File

@@ -1,3 +1,10 @@
2015-11-02 Natalia Portillo <claunia@claunia.com>
* Options.cs:
* Commands/DeviceInfo.cs:
Added option to dump binary responses got from devices while
getting device info.
2015-11-02 Natalia Portillo <claunia@claunia.com> 2015-11-02 Natalia Portillo <claunia@claunia.com>
* Commands/DeviceInfo.cs: * Commands/DeviceInfo.cs:

View File

@@ -50,6 +50,8 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Device-Info command", "--debug={0}", options.Debug); DicConsole.DebugWriteLine("Device-Info command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Device-Info command", "--verbose={0}", options.Verbose); DicConsole.DebugWriteLine("Device-Info command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath); DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath);
DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix);
FileStream outputFs;
if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0]))
@@ -88,6 +90,26 @@ namespace DiscImageChef.Commands
break; break;
} }
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + "_ata_identify.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing ATA IDENTIFY to {0}{1}", options.OutputPrefix, "_ata_identify.bin");
outputFs = new FileStream(options.OutputPrefix + "_ata_identify.bin", FileMode.CreateNew);
outputFs.Write(ataBuf, 0, ataBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_ata_identify.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_ata_identify.bin");
}
DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf)); DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf));
break; break;
} }
@@ -112,6 +134,26 @@ namespace DiscImageChef.Commands
break; break;
} }
if (!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + "_atapi_identify.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing ATAPI IDENTIFY to {0}{1}", options.OutputPrefix, "_atapi_identify.bin");
outputFs = new FileStream(options.OutputPrefix + "_atapi_identify.bin", FileMode.CreateNew);
outputFs.Write(ataBuf, 0, ataBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_atapi_identify.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_atapi_identify.bin");
}
DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf)); DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf));
// ATAPI devices are also SCSI devices // ATAPI devices are also SCSI devices
@@ -139,6 +181,26 @@ namespace DiscImageChef.Commands
if (dev.Type != DeviceType.ATAPI) if (dev.Type != DeviceType.ATAPI)
DicConsole.WriteLine("SCSI device"); DicConsole.WriteLine("SCSI device");
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + "_scsi_inquiry.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY to {0}{1}", options.OutputPrefix, "_scsi_inquiry.bin");
outputFs = new FileStream(options.OutputPrefix + "_scsi_inquiry.bin", FileMode.CreateNew);
outputFs.Write(inqBuf, 0, inqBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_scsi_inquiry.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_scsi_inquiry.bin");
}
Decoders.SCSI.Inquiry.SCSIInquiry? inq = Decoders.SCSI.Inquiry.Decode(inqBuf); Decoders.SCSI.Inquiry.SCSIInquiry? inq = Decoders.SCSI.Inquiry.Decode(inqBuf);
DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inq)); DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inq));
@@ -164,6 +226,26 @@ namespace DiscImageChef.Commands
if (sb == null) if (sb == null)
sb = new StringBuilder(); sb = new StringBuilder();
sb.AppendFormat("Page 0x{0:X2}: ", Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf)).AppendLine(); sb.AppendFormat("Page 0x{0:X2}: ", Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf)).AppendLine();
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page)))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY EVPD {2:X2}h to {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), page);
outputFs = new FileStream(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page), FileMode.CreateNew);
outputFs.Write(inqBuf, 0, inqBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page));
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page));
}
} }
} }
else if (page == 0x80) else if (page == 0x80)
@@ -173,12 +255,58 @@ namespace DiscImageChef.Commands
{ {
scsi83 = true; scsi83 = true;
scsiSerial = Decoders.SCSI.EVPD.DecodePage80(inqBuf); scsiSerial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page)))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY EVPD {2:X2}h to {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), page);
outputFs = new FileStream(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page), FileMode.CreateNew);
outputFs.Write(inqBuf, 0, inqBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page));
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page));
}
} }
} }
else else
{ {
if (page != 0x00) if (page != 0x00)
{
DicConsole.DebugWriteLine("Device-Info command", "Found undecoded SCSI VPD page 0x{0:X2}", page); DicConsole.DebugWriteLine("Device-Info command", "Found undecoded SCSI VPD page 0x{0:X2}", page);
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
if (!sense)
{
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page)))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY EVPD {2:X2}h to {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), page);
outputFs = new FileStream(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page), FileMode.CreateNew);
outputFs.Write(inqBuf, 0, inqBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page));
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page));
}
}
}
} }
} }
} }
@@ -223,6 +351,26 @@ namespace DiscImageChef.Commands
if (decMode.HasValue) if (decMode.HasValue)
{ {
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + "_scsi_modesense.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI MODE SENSE to {0}{1}", options.OutputPrefix, "_scsi_modesense.bin");
outputFs = new FileStream(options.OutputPrefix +"_scsi_modesense.bin", FileMode.CreateNew);
outputFs.Write(modeBuf, 0, modeBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_scsi_modesense.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_scsi_modesense.bin");
}
DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModeHeader(decMode.Value.Header, devType)); DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModeHeader(decMode.Value.Header, devType));
if (decMode.Value.Pages != null) if (decMode.Value.Pages != null)
@@ -454,6 +602,26 @@ namespace DiscImageChef.Commands
if (!sense) if (!sense)
{ {
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + "_mmc_getconfiguration.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI MODE SENSE to {0}{1}", options.OutputPrefix, "_mmc_getconfiguration.bin");
outputFs = new FileStream(options.OutputPrefix +"_mmc_getconfiguration.bin", FileMode.CreateNew);
outputFs.Write(confBuf, 0, confBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_mmc_getconfiguration.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_mmc_getconfiguration.bin");
}
Decoders.SCSI.MMC.Features.SeparatedFeatures ftr = Decoders.SCSI.MMC.Features.Separate(confBuf); Decoders.SCSI.MMC.Features.SeparatedFeatures ftr = Decoders.SCSI.MMC.Features.Separate(confBuf);
DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength); DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength);

View File

@@ -218,6 +218,9 @@ namespace DiscImageChef
{ {
[Option('i', "device", Required = true, HelpText = "Device path.")] [Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; } public string DevicePath { get; set; }
[Option('w', "output-prefix", Required = false, DefaultValue = "", HelpText = "Write binary responses from device with that prefix.")]
public string OutputPrefix { get; set; }
} }
public class FormatsSubOptions : CommonSubOptions public class FormatsSubOptions : CommonSubOptions