REFACTOR: All refactor in DiscImageChef.Core.

This commit is contained in:
2017-12-21 23:00:30 +00:00
parent effdcb4e0e
commit 7f829422a8
37 changed files with 892 additions and 1143 deletions

View File

@@ -67,35 +67,35 @@ namespace DiscImageChef.Core
public static event UpdateProgressHandler UpdateProgressEvent; public static event UpdateProgressHandler UpdateProgressEvent;
public static event EndProgressHandler EndProgressEvent; public static event EndProgressHandler EndProgressEvent;
public static void InitProgress() static void InitProgress()
{ {
if(InitProgressEvent != null) InitProgressEvent(); InitProgressEvent?.Invoke();
} }
public static void UpdateProgress(string text, int current, int maximum) static void UpdateProgress(string text, int current, int maximum)
{ {
if(UpdateProgressEvent != null) UpdateProgressEvent?.Invoke(string.Format(text, current, maximum), current, maximum);
UpdateProgressEvent(string.Format(text, current, maximum), current, maximum);
} }
public static void EndProgress() static void EndProgress()
{ {
if(EndProgressEvent != null) EndProgressEvent(); EndProgressEvent?.Invoke();
} }
public static BenchmarkResults Do(int bufferSize, int blockSize) public static BenchmarkResults Do(int bufferSize, int blockSize)
{ {
BenchmarkResults results = new BenchmarkResults(); BenchmarkResults results = new BenchmarkResults
results.Entries = new Dictionary<string, BenchmarkEntry>(); {
results.MinMemory = long.MaxValue; Entries = new Dictionary<string, BenchmarkEntry>(),
results.MaxMemory = 0; MinMemory = long.MaxValue,
results.SeparateTime = 0; MaxMemory = 0,
SeparateTime = 0
};
MemoryStream ms = new MemoryStream(bufferSize); MemoryStream ms = new MemoryStream(bufferSize);
Random rnd = new Random(); Random rnd = new Random();
DateTime start; DateTime start;
DateTime end; DateTime end;
long mem; long mem;
object ctx;
start = DateTime.Now; start = DateTime.Now;
InitProgress(); InitProgress();
@@ -136,7 +136,7 @@ namespace DiscImageChef.Core
results.ReadSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds; results.ReadSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
#region Adler32 #region Adler32
ctx = new Adler32Context(); object ctx = new Adler32Context();
((Adler32Context)ctx).Init(); ((Adler32Context)ctx).Init();
ms.Seek(0, SeekOrigin.Begin); ms.Seek(0, SeekOrigin.Begin);
mem = GC.GetTotalMemory(false); mem = GC.GetTotalMemory(false);

View File

@@ -292,89 +292,67 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.All)) if(enabled.HasFlag(EnableChecksum.All))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.adler32, Value = adler32Ctx.End()};
chk.type = ChecksumTypeType.adler32;
chk.Value = adler32Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Crc16)) if(enabled.HasFlag(EnableChecksum.Crc16))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.crc16, Value = crc16Ctx.End()};
chk.type = ChecksumTypeType.crc16;
chk.Value = crc16Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Crc32)) if(enabled.HasFlag(EnableChecksum.Crc32))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.crc32, Value = crc32Ctx.End()};
chk.type = ChecksumTypeType.crc32;
chk.Value = crc32Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Crc64)) if(enabled.HasFlag(EnableChecksum.Crc64))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.crc64, Value = crc64Ctx.End()};
chk.type = ChecksumTypeType.crc64;
chk.Value = crc64Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Md5)) if(enabled.HasFlag(EnableChecksum.Md5))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.md5, Value = md5Ctx.End()};
chk.type = ChecksumTypeType.md5;
chk.Value = md5Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Ripemd160)) if(enabled.HasFlag(EnableChecksum.Ripemd160))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.ripemd160, Value = ripemd160Ctx.End()};
chk.type = ChecksumTypeType.ripemd160;
chk.Value = ripemd160Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha1)) if(enabled.HasFlag(EnableChecksum.Sha1))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha1, Value = sha1Ctx.End()};
chk.type = ChecksumTypeType.sha1;
chk.Value = sha1Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha256)) if(enabled.HasFlag(EnableChecksum.Sha256))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha256, Value = sha256Ctx.End()};
chk.type = ChecksumTypeType.sha256;
chk.Value = sha256Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha384)) if(enabled.HasFlag(EnableChecksum.Sha384))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha384, Value = sha384Ctx.End()};
chk.type = ChecksumTypeType.sha384;
chk.Value = sha384Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha512)) if(enabled.HasFlag(EnableChecksum.Sha512))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha512, Value = sha512Ctx.End()};
chk.type = ChecksumTypeType.sha512;
chk.Value = sha512Ctx.End();
chks.Add(chk); chks.Add(chk);
} }
if(!enabled.HasFlag(EnableChecksum.SpamSum)) return chks; if(!enabled.HasFlag(EnableChecksum.SpamSum)) return chks;
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.spamsum, Value = ssctx.End()};
chk.type = ChecksumTypeType.spamsum;
chk.Value = ssctx.End();
chks.Add(chk); chks.Add(chk);
return chks; return chks;
@@ -394,18 +372,6 @@ namespace DiscImageChef.Core
Sha512Context sha512CtxData = null; Sha512Context sha512CtxData = null;
SpamSumContext ssctxData = null; SpamSumContext ssctxData = null;
AdlerPacket adlerPktData;
Crc16Packet crc16PktData;
Crc32Packet crc32PktData;
Crc64Packet crc64PktData;
Md5Packet md5PktData;
Ripemd160Packet ripemd160PktData;
Sha1Packet sha1PktData;
Sha256Packet sha256PktData;
Sha384Packet sha384PktData;
Sha512Packet sha512PktData;
SpamsumPacket spamsumPktData;
Thread adlerThreadData = new Thread(UpdateAdler); Thread adlerThreadData = new Thread(UpdateAdler);
Thread crc16ThreadData = new Thread(UpdateCrc16); Thread crc16ThreadData = new Thread(UpdateCrc16);
Thread crc32ThreadData = new Thread(UpdateCrc32); Thread crc32ThreadData = new Thread(UpdateCrc32);
@@ -421,7 +387,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
adler32CtxData = new Adler32Context(); adler32CtxData = new Adler32Context();
adlerPktData = new AdlerPacket(); AdlerPacket adlerPktData = new AdlerPacket();
adler32CtxData.Init(); adler32CtxData.Init();
adlerPktData.Context = adler32CtxData; adlerPktData.Context = adler32CtxData;
adlerPktData.Data = data; adlerPktData.Data = data;
@@ -430,7 +396,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
crc16PktData = new Crc16Packet(); Crc16Packet crc16PktData = new Crc16Packet();
crc16CtxData = new Crc16Context(); crc16CtxData = new Crc16Context();
crc16CtxData.Init(); crc16CtxData.Init();
crc16PktData.Context = crc16CtxData; crc16PktData.Context = crc16CtxData;
@@ -440,7 +406,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
crc32PktData = new Crc32Packet(); Crc32Packet crc32PktData = new Crc32Packet();
crc32CtxData = new Crc32Context(); crc32CtxData = new Crc32Context();
crc32CtxData.Init(); crc32CtxData.Init();
crc32PktData.Context = crc32CtxData; crc32PktData.Context = crc32CtxData;
@@ -450,7 +416,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
crc64PktData = new Crc64Packet(); Crc64Packet crc64PktData = new Crc64Packet();
crc64CtxData = new Crc64Context(); crc64CtxData = new Crc64Context();
crc64CtxData.Init(); crc64CtxData.Init();
crc64PktData.Context = crc64CtxData; crc64PktData.Context = crc64CtxData;
@@ -460,7 +426,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
md5PktData = new Md5Packet(); Md5Packet md5PktData = new Md5Packet();
md5CtxData = new Md5Context(); md5CtxData = new Md5Context();
md5CtxData.Init(); md5CtxData.Init();
md5PktData.Context = md5CtxData; md5PktData.Context = md5CtxData;
@@ -470,7 +436,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
ripemd160PktData = new Ripemd160Packet(); Ripemd160Packet ripemd160PktData = new Ripemd160Packet();
ripemd160CtxData = new Ripemd160Context(); ripemd160CtxData = new Ripemd160Context();
ripemd160CtxData.Init(); ripemd160CtxData.Init();
ripemd160PktData.Context = ripemd160CtxData; ripemd160PktData.Context = ripemd160CtxData;
@@ -480,7 +446,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
sha1PktData = new Sha1Packet(); Sha1Packet sha1PktData = new Sha1Packet();
sha1CtxData = new Sha1Context(); sha1CtxData = new Sha1Context();
sha1CtxData.Init(); sha1CtxData.Init();
sha1PktData.Context = sha1CtxData; sha1PktData.Context = sha1CtxData;
@@ -490,7 +456,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
sha256PktData = new Sha256Packet(); Sha256Packet sha256PktData = new Sha256Packet();
sha256CtxData = new Sha256Context(); sha256CtxData = new Sha256Context();
sha256CtxData.Init(); sha256CtxData.Init();
sha256PktData.Context = sha256CtxData; sha256PktData.Context = sha256CtxData;
@@ -500,7 +466,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
sha384PktData = new Sha384Packet(); Sha384Packet sha384PktData = new Sha384Packet();
sha384CtxData = new Sha384Context(); sha384CtxData = new Sha384Context();
sha384CtxData.Init(); sha384CtxData.Init();
sha384PktData.Context = sha384CtxData; sha384PktData.Context = sha384CtxData;
@@ -510,7 +476,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
sha512PktData = new Sha512Packet(); Sha512Packet sha512PktData = new Sha512Packet();
sha512CtxData = new Sha512Context(); sha512CtxData = new Sha512Context();
sha512CtxData.Init(); sha512CtxData.Init();
sha512PktData.Context = sha512CtxData; sha512PktData.Context = sha512CtxData;
@@ -520,7 +486,7 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.SpamSum)) if(enabled.HasFlag(EnableChecksum.SpamSum))
{ {
spamsumPktData = new SpamsumPacket(); SpamsumPacket spamsumPktData = new SpamsumPacket();
ssctxData = new SpamSumContext(); ssctxData = new SpamSumContext();
ssctxData.Init(); ssctxData.Init();
spamsumPktData.Context = ssctxData; spamsumPktData.Context = ssctxData;
@@ -538,89 +504,67 @@ namespace DiscImageChef.Core
if(enabled.HasFlag(EnableChecksum.Adler32)) if(enabled.HasFlag(EnableChecksum.Adler32))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.adler32, Value = adler32CtxData.End()};
chk.type = ChecksumTypeType.adler32;
chk.Value = adler32CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Crc16)) if(enabled.HasFlag(EnableChecksum.Crc16))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.crc16, Value = crc16CtxData.End()};
chk.type = ChecksumTypeType.crc16;
chk.Value = crc16CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Crc32)) if(enabled.HasFlag(EnableChecksum.Crc32))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.crc32, Value = crc32CtxData.End()};
chk.type = ChecksumTypeType.crc32;
chk.Value = crc32CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Crc64)) if(enabled.HasFlag(EnableChecksum.Crc64))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.crc64, Value = crc64CtxData.End()};
chk.type = ChecksumTypeType.crc64;
chk.Value = crc64CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Md5)) if(enabled.HasFlag(EnableChecksum.Md5))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.md5, Value = md5CtxData.End()};
chk.type = ChecksumTypeType.md5;
chk.Value = md5CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Ripemd160)) if(enabled.HasFlag(EnableChecksum.Ripemd160))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.ripemd160, Value = ripemd160CtxData.End()};
chk.type = ChecksumTypeType.ripemd160;
chk.Value = ripemd160CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha1)) if(enabled.HasFlag(EnableChecksum.Sha1))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha1, Value = sha1CtxData.End()};
chk.type = ChecksumTypeType.sha1;
chk.Value = sha1CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha256)) if(enabled.HasFlag(EnableChecksum.Sha256))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha256, Value = sha256CtxData.End()};
chk.type = ChecksumTypeType.sha256;
chk.Value = sha256CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha384)) if(enabled.HasFlag(EnableChecksum.Sha384))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha384, Value = sha384CtxData.End()};
chk.type = ChecksumTypeType.sha384;
chk.Value = sha384CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(enabled.HasFlag(EnableChecksum.Sha512)) if(enabled.HasFlag(EnableChecksum.Sha512))
{ {
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.sha512, Value = sha512CtxData.End()};
chk.type = ChecksumTypeType.sha512;
chk.Value = sha512CtxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
} }
if(!enabled.HasFlag(EnableChecksum.SpamSum)) return dataChecksums; if(!enabled.HasFlag(EnableChecksum.SpamSum)) return dataChecksums;
chk = new ChecksumType(); chk = new ChecksumType {type = ChecksumTypeType.spamsum, Value = ssctxData.End()};
chk.type = ChecksumTypeType.spamsum;
chk.Value = ssctxData.End();
dataChecksums.Add(chk); dataChecksums.Add(chk);
return dataChecksums; return dataChecksums;

View File

@@ -46,7 +46,7 @@ namespace DiscImageChef.Core
public void Close() public void Close()
{ {
if(dataFs != null) dataFs.Close(); dataFs?.Close();
} }
public int Read(byte[] array, int offset, int count) public int Read(byte[] array, int offset, int count)
@@ -92,7 +92,7 @@ namespace DiscImageChef.Core
public long Position public long Position
{ {
get { return dataFs.Position; } get => dataFs.Position;
} }
public static void WriteTo(string who, string outputPrefix, string outputSuffix, string what, byte[] data) public static void WriteTo(string who, string outputPrefix, string outputSuffix, string what, byte[] data)

View File

@@ -59,8 +59,6 @@ namespace DiscImageChef.Core.Devices.Dumping
ref DumpLog dumpLog, Encoding encoding) ref DumpLog dumpLog, Encoding encoding)
{ {
bool aborted; bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
if(dumpRaw) if(dumpRaw)
{ {
@@ -75,12 +73,11 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
bool sense; bool sense;
ushort currentProfile = 0x0001; const ushort ATA_PROFILE = 0x0001;
uint timeout = 5; const uint TIMEOUT = 5;
double duration;
dumpLog.WriteLine("Requesting ATA IDENTIFY DEVICE."); dumpLog.WriteLine("Requesting ATA IDENTIFY DEVICE.");
sense = dev.AtaIdentify(out byte[] cmdBuf, out AtaErrorRegistersCHS errorChs); sense = dev.AtaIdentify(out byte[] cmdBuf, out _);
if(!sense && Identify.Decode(cmdBuf).HasValue) if(!sense && Identify.Decode(cmdBuf).HasValue)
{ {
Identify.IdentifyDevice? ataIdNullable = Identify.Decode(cmdBuf); Identify.IdentifyDevice? ataIdNullable = Identify.Decode(cmdBuf);
@@ -170,7 +167,6 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
Checksum dataChk;
aborted = false; aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
@@ -179,7 +175,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Initializate reader // Initializate reader
dumpLog.WriteLine("Initializing reader."); dumpLog.WriteLine("Initializing reader.");
Reader ataReader = new Reader(dev, timeout, cmdBuf); Reader ataReader = new Reader(dev, TIMEOUT, cmdBuf);
// Fill reader blocks // Fill reader blocks
ulong blocks = ataReader.GetDeviceBlocks(); ulong blocks = ataReader.GetDeviceBlocks();
// Check block sizes // Check block sizes
@@ -218,7 +214,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize); dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize);
dumpLog.WriteLine("Device reports {0} bytes per physical block.", physicalsectorsize); dumpLog.WriteLine("Device reports {0} bytes per physical block.", physicalsectorsize);
bool removable = false || !dev.IsCompactFlash && bool removable = !dev.IsCompactFlash &&
ataId.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit ataId.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit
.Removable); .Removable);
DumpHardwareType currentTry = null; DumpHardwareType currentTry = null;
@@ -228,12 +224,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(currentTry == null || extents == null) if(currentTry == null || extents == null)
throw new Exception("Could not process resume file, not continuing..."); throw new Exception("Could not process resume file, not continuing...");
MhddLog mhddLog;
IbgLog ibgLog;
double duration;
if(ataReader.IsLba) if(ataReader.IsLba)
{ {
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead); DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", currentProfile); ibgLog = new IbgLog(outputPrefix + ".ibg", ATA_PROFILE);
dumpFile = new DataFile(outputPrefix + ".bin"); dumpFile = new DataFile(outputPrefix + ".bin");
if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock); if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock);
@@ -271,8 +270,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b); for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
if(duration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, duration < 500 ? 65535 : duration);
else mhddLog.Write(i, duration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
dumpFile.Write(new byte[blockSize * blocksToRead]); dumpFile.Write(new byte[blockSize * blocksToRead]);
@@ -348,7 +346,7 @@ namespace DiscImageChef.Core.Devices.Dumping
else else
{ {
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", currentProfile); ibgLog = new IbgLog(outputPrefix + ".ibg", ATA_PROFILE);
dumpFile = new DataFile(outputPrefix + ".bin"); dumpFile = new DataFile(outputPrefix + ".bin");
ulong currentBlock = 0; ulong currentBlock = 0;
@@ -390,8 +388,7 @@ namespace DiscImageChef.Core.Devices.Dumping
else else
{ {
resume.BadBlocks.Add(currentBlock); resume.BadBlocks.Add(currentBlock);
if(duration < 500) mhddLog.Write(currentBlock, 65535); mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
else mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, 0); ibgLog.Write(currentBlock, 0);
dumpFile.Write(new byte[blockSize]); dumpFile.Write(new byte[blockSize]);
@@ -416,7 +413,7 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
} }
dataChk = new Checksum(); Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin); dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500; blocksToRead = 500;
@@ -454,7 +451,6 @@ namespace DiscImageChef.Core.Devices.Dumping
PluginBase plugins = new PluginBase(); PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding); plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList(); FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin"); Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
@@ -465,7 +461,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
imageFormat = ImageFormat.Detect(inputFilter); ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null; PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; } try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -503,7 +499,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, partitions[i])) continue; if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out string foo); plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
@@ -538,7 +534,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, wholePart)) continue; if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo); plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);

View File

@@ -59,14 +59,11 @@ namespace DiscImageChef.Core.Devices.Dumping
ref MediaType dskType, bool separateSubchannel, ref Resume resume, ref MediaType dskType, bool separateSubchannel, ref Resume resume,
ref DumpLog dumpLog, Alcohol120 alcohol, bool dumpLeadIn) ref DumpLog dumpLog, Alcohol120 alcohol, bool dumpLeadIn)
{ {
MhddLog mhddLog;
IbgLog ibgLog;
bool sense = false; bool sense = false;
ulong blocks; ulong blocks;
// TODO: Check subchannel support // TODO: Check subchannel support
uint blockSize; uint blockSize;
uint subSize; uint subSize;
byte[] tmpBuf;
FullTOC.CDFullTOC? toc = null; FullTOC.CDFullTOC? toc = null;
DateTime start; DateTime start;
DateTime end; DateTime end;
@@ -77,9 +74,7 @@ namespace DiscImageChef.Core.Devices.Dumping
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
Checksum dataChk; Checksum dataChk;
bool readcd; bool readcd;
byte[] readBuffer;
uint blocksToRead = 64; uint blocksToRead = 64;
ulong errored = 0;
DataFile dumpFile; DataFile dumpFile;
bool aborted = false; bool aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
@@ -87,13 +82,13 @@ namespace DiscImageChef.Core.Devices.Dumping
// We discarded all discs that falsify a TOC before requesting a real TOC // We discarded all discs that falsify a TOC before requesting a real TOC
// No TOC, no CD (or an empty one) // No TOC, no CD (or an empty one)
dumpLog.WriteLine("Reading full TOC"); dumpLog.WriteLine("Reading full TOC");
bool tocSense = dev.ReadRawToc(out byte[] cmdBuf, out byte[] senseBuf, 1, dev.Timeout, out double duration); bool tocSense = dev.ReadRawToc(out byte[] cmdBuf, out byte[] senseBuf, 1, dev.Timeout, out _);
if(!tocSense) if(!tocSense)
{ {
toc = FullTOC.Decode(cmdBuf); toc = FullTOC.Decode(cmdBuf);
if(toc.HasValue) if(toc.HasValue)
{ {
tmpBuf = new byte[cmdBuf.Length - 2]; byte[] tmpBuf = new byte[cmdBuf.Length - 2];
Array.Copy(cmdBuf, 2, tmpBuf, 0, cmdBuf.Length - 2); Array.Copy(cmdBuf, 2, tmpBuf, 0, cmdBuf.Length - 2);
sidecar.OpticalDisc[0].TOC = new DumpType sidecar.OpticalDisc[0].TOC = new DumpType
{ {
@@ -105,7 +100,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// ATIP exists on blank CDs // ATIP exists on blank CDs
dumpLog.WriteLine("Reading ATIP"); dumpLog.WriteLine("Reading ATIP");
sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
ATIP.CDATIP? atip = ATIP.Decode(cmdBuf); ATIP.CDATIP? atip = ATIP.Decode(cmdBuf);
@@ -129,7 +124,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading Disc Information"); dumpLog.WriteLine("Reading Disc Information");
sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf,
MmcDiscInformationDataTypes.DiscInformation, dev.Timeout, MmcDiscInformationDataTypes.DiscInformation, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
DiscInformation.StandardDiscInformation? discInfo = DiscInformation.StandardDiscInformation? discInfo =
@@ -151,7 +146,7 @@ namespace DiscImageChef.Core.Devices.Dumping
int firstTrackLastSession = 0; int firstTrackLastSession = 0;
dumpLog.WriteLine("Reading Session Information"); dumpLog.WriteLine("Reading Session Information");
sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
Session.CDSessionInfo? session = Session.Decode(cmdBuf); Session.CDSessionInfo? session = Session.Decode(cmdBuf);
@@ -194,7 +189,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading PMA"); dumpLog.WriteLine("Reading PMA");
sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out _);
if(!sense) if(!sense)
if(PMA.Decode(cmdBuf).HasValue) if(PMA.Decode(cmdBuf).HasValue)
{ {
@@ -210,7 +205,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading CD-Text from Lead-In"); dumpLog.WriteLine("Reading CD-Text from Lead-In");
sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out _);
if(!sense) if(!sense)
if(CDTextOnLeadIn.Decode(cmdBuf).HasValue) if(CDTextOnLeadIn.Decode(cmdBuf).HasValue)
{ {
@@ -319,8 +314,7 @@ namespace DiscImageChef.Core.Devices.Dumping
phour = trk.PHOUR; phour = trk.PHOUR;
} }
if(phour > 0) lastMsf = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe, phour); lastMsf = phour > 0 ? $"{phour:D2}:{pmin:D2}:{psec:D2}:{pframe:D2}" : $"{pmin:D2}:{psec:D2}:{pframe:D2}";
else lastMsf = $"{pmin:D2}:{psec:D2}:{pframe:D2}";
lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150; lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150;
} }
@@ -347,9 +341,7 @@ namespace DiscImageChef.Core.Devices.Dumping
pframe -= psec * 75; pframe -= psec * 75;
} }
if(phour > 0) tracks[t - 1].EndMSF = phour > 0 ? $"{phour:D2}:{pmin:D2}:{psec:D2}:{pframe:D2}" : $"{pmin:D2}:{psec:D2}:{pframe:D2}";
tracks[t - 1].EndMSF = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe, phour);
else tracks[t - 1].EndMSF = $"{pmin:D2}:{psec:D2}:{pframe:D2}";
} }
tracks[tracks.Length - 1].EndMSF = lastMsf; tracks[tracks.Length - 1].EndMSF = lastMsf;
@@ -364,9 +356,9 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dumpRaw) throw new NotImplementedException("Raw CD dumping not yet implemented"); if(dumpRaw) throw new NotImplementedException("Raw CD dumping not yet implemented");
// TODO: Check subchannel capabilities // TODO: Check subchannel capabilities
readcd = !dev.ReadCd(out readBuffer, out senseBuf, 0, blockSize, 1, MmcSectorTypes.AllTypes, false, readcd = !dev.ReadCd(out byte[] readBuffer, out senseBuf, 0, blockSize, 1, MmcSectorTypes.AllTypes, false,
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.Raw, dev.Timeout, out duration); MmcSubchannel.Raw, dev.Timeout, out _);
if(readcd) DicConsole.WriteLine("Using MMC READ CD command."); if(readcd) DicConsole.WriteLine("Using MMC READ CD command.");
@@ -463,7 +455,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
sense = dev.ReadCd(out readBuffer, out senseBuf, 0, blockSize, blocksToRead, sense = dev.ReadCd(out readBuffer, out senseBuf, 0, blockSize, blocksToRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out duration); true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out _);
if(dev.Error || sense) blocksToRead /= 2; if(dev.Error || sense) blocksToRead /= 2;
} }
@@ -490,8 +482,8 @@ namespace DiscImageChef.Core.Devices.Dumping
alcohol.SetExtension(".bin"); alcohol.SetExtension(".bin");
DataFile subFile = null; DataFile subFile = null;
if(separateSubchannel) subFile = new DataFile(outputPrefix + ".sub"); if(separateSubchannel) subFile = new DataFile(outputPrefix + ".sub");
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0008); IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0008);
dumpFile.Seek(resume.NextBlock, (ulong)sectorSize); dumpFile.Seek(resume.NextBlock, (ulong)sectorSize);
if(separateSubchannel) subFile.Seek(resume.NextBlock, subSize); if(separateSubchannel) subFile.Seek(resume.NextBlock, subSize);
@@ -499,7 +491,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock); if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock);
start = DateTime.UtcNow; start = DateTime.UtcNow;
for(int t = 0; t < tracks.Count(); t++) for(int t = 0; t < tracks.Length; t++)
{ {
dumpLog.WriteLine("Reading track {0}", t); dumpLog.WriteLine("Reading track {0}", t);
@@ -589,13 +581,11 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
else dumpFile.Write(new byte[blockSize * blocksToRead]); else dumpFile.Write(new byte[blockSize * blocksToRead]);
errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b); for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}", DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf)); Sense.PrettifySense(senseBuf));
if(cmdDuration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
dumpLog.WriteLine("Error reading {0} sectors from sector {1}.", blocksToRead, i); dumpLog.WriteLine("Error reading {0} sectors from sector {1}.", blocksToRead, i);
@@ -691,8 +681,6 @@ namespace DiscImageChef.Core.Devices.Dumping
break; break;
} }
double cmdDuration;
DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1, DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1,
forward ? "forward" : "reverse", forward ? "forward" : "reverse",
runningPersistent ? "recovering partial data, " : ""); runningPersistent ? "recovering partial data, " : "");
@@ -701,7 +689,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)badSector, blockSize, blocksToRead, sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)badSector, blockSize, blocksToRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out cmdDuration); true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out double cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
} }
@@ -731,25 +719,12 @@ namespace DiscImageChef.Core.Devices.Dumping
goto cdRepeatRetry; goto cdRepeatRetry;
} }
Modes.DecodedMode? currentMode = null;
Modes.ModePage? currentModePage = null; Modes.ModePage? currentModePage = null;
byte[] md6; byte[] md6;
byte[] md10; byte[] md10;
if(!runningPersistent && persistent) if(!runningPersistent && persistent)
{ {
sense = dev.ModeSense6(out readBuffer, out senseBuf, false, ScsiModeSensePageControl.Current, 0x01,
dev.Timeout, out duration);
if(sense)
{
sense = dev.ModeSense10(out readBuffer, out senseBuf, false, ScsiModeSensePageControl.Current,
0x01, dev.Timeout, out duration);
if(!sense) currentMode = Modes.DecodeMode10(readBuffer, dev.ScsiType);
}
else currentMode = Modes.DecodeMode6(readBuffer, dev.ScsiType);
if(currentMode.HasValue) currentModePage = currentMode.Value.Pages[0];
Modes.ModePage_01_MMC pgMmc = Modes.ModePage_01_MMC pgMmc =
new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20}; new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20};
Modes.DecodedMode md = new Modes.DecodedMode Modes.DecodedMode md = new Modes.DecodedMode
@@ -769,8 +744,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType); md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive."); dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out _);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out _);
runningPersistent = true; runningPersistent = true;
if(!sense && !dev.Error) if(!sense && !dev.Error)
@@ -790,8 +765,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType); md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive."); dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out _);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); if(sense) dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out _);
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
@@ -807,7 +782,7 @@ namespace DiscImageChef.Core.Devices.Dumping
blocksToRead = 500; blocksToRead = 500;
dumpLog.WriteLine("Checksum starts."); dumpLog.WriteLine("Checksum starts.");
for(int t = 0; t < tracks.Count(); t++) for(int t = 0; t < tracks.Length; t++)
{ {
Checksum trkChk = new Checksum(); Checksum trkChk = new Checksum();
Checksum subChk = new Checksum(); Checksum subChk = new Checksum();
@@ -857,8 +832,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
tracks[t].Checksums = trkChk.End().ToArray(); tracks[t].Checksums = trkChk.End().ToArray();
if(separateSubchannel) tracks[t].SubChannel.Checksums = subChk.End().ToArray(); tracks[t].SubChannel.Checksums = separateSubchannel ? subChk.End().ToArray() : tracks[t].Checksums;
else tracks[t].SubChannel.Checksums = tracks[t].Checksums;
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
@@ -877,7 +851,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Value = outputPrefix + ".bin" Value = outputPrefix + ".bin"
}; };
sidecar.OpticalDisc[0].Sessions = toc.Value.LastCompleteSession; sidecar.OpticalDisc[0].Sessions = toc.Value.LastCompleteSession;
sidecar.OpticalDisc[0].Tracks = new[] {tracks.Count()}; sidecar.OpticalDisc[0].Tracks = new[] {tracks.Length};
sidecar.OpticalDisc[0].Track = tracks; sidecar.OpticalDisc[0].Track = tracks;
sidecar.OpticalDisc[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType); sidecar.OpticalDisc[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp); Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp);

View File

@@ -55,11 +55,8 @@ namespace DiscImageChef.Core.Devices.Dumping
ref MediaType dskType, bool separateSubchannel, ref Resume resume, ref MediaType dskType, bool separateSubchannel, ref Resume resume,
ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding) ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding)
{ {
byte[] cmdBuf;
byte[] senseBuf;
bool sense; bool sense;
double duration; ulong blocks;
ulong blocks = 0;
byte[] tmpBuf; byte[] tmpBuf;
bool compactDisc = true; bool compactDisc = true;
bool isXbox = false; bool isXbox = false;
@@ -70,8 +67,8 @@ namespace DiscImageChef.Core.Devices.Dumping
// TODO: Log not only what is it reading, but if it was read correctly or not. // TODO: Log not only what is it reading, but if it was read correctly or not.
sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, sense = dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
Features.SeparatedFeatures ftr = Features.Separate(cmdBuf); Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);
@@ -188,8 +185,8 @@ namespace DiscImageChef.Core.Devices.Dumping
switch(dskType) { switch(dskType) {
case MediaType.Unknown when blocks > 0: case MediaType.Unknown when blocks > 0:
dumpLog.WriteLine("Reading Physical Format Information"); dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration); MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf); PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf);
@@ -222,8 +219,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.HDDVDRW: case MediaType.HDDVDRW:
case MediaType.HDDVDRWDL: case MediaType.HDDVDRWDL:
dumpLog.WriteLine("Reading Physical Format Information"); dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration); MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
alcohol.AddPfi(cmdBuf); alcohol.AddPfi(cmdBuf);
@@ -259,8 +256,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.DVDPRWDL; dskType = MediaType.DVDPRWDL;
break; break;
case DiskCategory.DVDR: case DiskCategory.DVDR:
if(decPfi.PartVersion == 6) dskType = MediaType.DVDRDL; dskType = decPfi.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR;
else dskType = MediaType.DVDR;
break; break;
case DiskCategory.DVDRAM: case DiskCategory.DVDRAM:
dskType = MediaType.DVDRAM; dskType = MediaType.DVDRAM;
@@ -269,8 +265,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.DVDROM; dskType = MediaType.DVDROM;
break; break;
case DiskCategory.DVDRW: case DiskCategory.DVDRW:
if(decPfi.PartVersion == 3) dskType = MediaType.DVDRWDL; dskType = decPfi.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW;
else dskType = MediaType.DVDRW;
break; break;
case DiskCategory.HDDVDR: case DiskCategory.HDDVDR:
dskType = MediaType.HDDVDR; dskType = MediaType.HDDVDR;
@@ -285,8 +280,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.HDDVDRW; dskType = MediaType.HDDVDRW;
break; break;
case DiskCategory.Nintendo: case DiskCategory.Nintendo:
if(decPfi.DiscSize == DVDSize.Eighty) dskType = MediaType.GOD; dskType = decPfi.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD;
else dskType = MediaType.WOD;
break; break;
case DiskCategory.UMD: case DiskCategory.UMD:
dskType = MediaType.UMD; dskType = MediaType.UMD;
@@ -296,9 +290,9 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading Disc Manufacturing Information"); dumpLog.WriteLine("Reading Disc Manufacturing Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
if(DMI.IsXbox(cmdBuf) || DMI.IsXbox360(cmdBuf)) if(DMI.IsXbox(cmdBuf) || DMI.IsXbox360(cmdBuf))
@@ -315,7 +309,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.XGD3; dskType = MediaType.XGD3;
} }
sense = dev.ScsiInquiry(out byte[] inqBuf, out senseBuf); sense = dev.ScsiInquiry(out byte[] inqBuf, out _);
if(sense || !Inquiry.Decode(inqBuf).HasValue || if(sense || !Inquiry.Decode(inqBuf).HasValue ||
Inquiry.Decode(inqBuf).HasValue && Inquiry.Decode(inqBuf).HasValue &&
@@ -364,9 +358,9 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dskType == MediaType.DVDDownload || dskType == MediaType.DVDROM) if(dskType == MediaType.DVDDownload || dskType == MediaType.DVDROM)
{ {
dumpLog.WriteLine("Reading Lead-in Copyright Information."); dumpLog.WriteLine("Reading Lead-in Copyright Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout, MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
if(CSS_CPRM.DecodeLeadInCopyright(cmdBuf).HasValue) if(CSS_CPRM.DecodeLeadInCopyright(cmdBuf).HasValue)
{ {
@@ -394,8 +388,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDROM: case MediaType.DVDROM:
case MediaType.HDDVDROM: case MediaType.HDDVDROM:
dumpLog.WriteLine("Reading Burst Cutting Area."); dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out duration); MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -415,8 +409,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDRAM: case MediaType.DVDRAM:
case MediaType.HDDVDRAM: case MediaType.HDDVDRAM:
dumpLog.WriteLine("Reading Disc Description Structure."); dumpLog.WriteLine("Reading Disc Description Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out duration); MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out _);
if(!sense) if(!sense)
if(DDS.Decode(cmdBuf).HasValue) if(DDS.Decode(cmdBuf).HasValue)
{ {
@@ -432,9 +426,9 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading Spare Area Information."); dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, dev.Timeout, MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
if(Spare.Decode(cmdBuf).HasValue) if(Spare.Decode(cmdBuf).HasValue)
{ {
@@ -454,8 +448,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDR: case MediaType.DVDR:
case MediaType.DVDRW: case MediaType.DVDRW:
dumpLog.WriteLine("Reading Pre-Recorded Information."); dumpLog.WriteLine("Reading Pre-Recorded Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out duration); MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -478,9 +472,9 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDRW: case MediaType.DVDRW:
case MediaType.HDDVDR: case MediaType.HDDVDR:
dumpLog.WriteLine("Reading Media Identifier."); dumpLog.WriteLine("Reading Media Identifier.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -495,9 +489,9 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading Recordable Physical Information."); dumpLog.WriteLine("Reading Recordable Physical Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrPhysicalInformation, 0, dev.Timeout, MmcDiscStructureFormat.DvdrPhysicalInformation, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -518,8 +512,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDPRW: case MediaType.DVDPRW:
case MediaType.DVDPRWDL: case MediaType.DVDPRWDL:
dumpLog.WriteLine("Reading ADdress In Pregroove."); dumpLog.WriteLine("Reading ADdress In Pregroove.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Adip, 0, dev.Timeout, out duration); MmcDiscStructureFormat.Adip, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -534,8 +528,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading Disc Control Blocks."); dumpLog.WriteLine("Reading Disc Control Blocks.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out duration); MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -553,9 +547,9 @@ namespace DiscImageChef.Core.Devices.Dumping
#region HD DVD-ROM #region HD DVD-ROM
case MediaType.HDDVDROM: case MediaType.HDDVDROM:
dumpLog.WriteLine("Reading Lead-in Copyright Information."); dumpLog.WriteLine("Reading Lead-in Copyright Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.HddvdCopyrightInformation, 0, dev.Timeout, MmcDiscStructureFormat.HddvdCopyrightInformation, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -577,8 +571,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.BDRXL: case MediaType.BDRXL:
case MediaType.BDREXL: case MediaType.BDREXL:
dumpLog.WriteLine("Reading Disc Information."); dumpLog.WriteLine("Reading Disc Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out duration); MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out _);
if(!sense) if(!sense)
if(DI.Decode(cmdBuf).HasValue) if(DI.Decode(cmdBuf).HasValue)
{ {
@@ -594,8 +588,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading PAC."); dumpLog.WriteLine("Reading PAC.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.Pac, 0, dev.Timeout, out duration); MmcDiscStructureFormat.Pac, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -616,8 +610,8 @@ namespace DiscImageChef.Core.Devices.Dumping
#region BD-ROM only #region BD-ROM only
case MediaType.BDROM: case MediaType.BDROM:
dumpLog.WriteLine("Reading Burst Cutting Area."); dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out duration); MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -639,8 +633,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.BDRXL: case MediaType.BDRXL:
case MediaType.BDREXL: case MediaType.BDREXL:
dumpLog.WriteLine("Reading Disc Definition Structure."); dumpLog.WriteLine("Reading Disc Definition Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out duration); MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
@@ -655,9 +649,9 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading Spare Area Information."); dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];

View File

@@ -60,12 +60,7 @@ namespace DiscImageChef.Core.Devices.Dumping
ref MediaType dskType, bool opticalDisc, ref Resume resume, ref MediaType dskType, bool opticalDisc, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding, Alcohol120 alcohol = null) ref DumpLog dumpLog, Encoding encoding, Alcohol120 alcohol = null)
{ {
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf;
byte[] senseBuf;
bool sense; bool sense;
double duration;
ulong blocks; ulong blocks;
uint blockSize; uint blockSize;
uint logicalBlockSize; uint logicalBlockSize;
@@ -73,7 +68,7 @@ namespace DiscImageChef.Core.Devices.Dumping
byte scsiMediumType = 0; byte scsiMediumType = 0;
byte scsiDensityCode = 0; byte scsiDensityCode = 0;
bool containsFloppyPage = false; bool containsFloppyPage = false;
ushort currentProfile = 0x0001; const ushort SBC_PROFILE = 0x0001;
DateTime start; DateTime start;
DateTime end; DateTime end;
double totalDuration = 0; double totalDuration = 0;
@@ -81,11 +76,8 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
Checksum dataChk;
byte[] readBuffer; byte[] readBuffer;
uint blocksToRead = 64; uint blocksToRead;
ulong errored = 0;
DataFile dumpFile;
bool aborted = false; bool aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
@@ -125,25 +117,6 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
if(dskType == MediaType.Unknown)
dskType = MediaTypeFromScsi.Get((byte)dev.ScsiType, dev.Manufacturer, dev.Model, scsiMediumType,
scsiDensityCode, blocks, blockSize);
// TODO: Solve floppy page resolve
if(dskType == MediaType.Unknown && dev.IsUsb && containsFloppyPage) dskType = MediaType.FlashDrive;
DicConsole.WriteLine("Media identified as {0}", dskType);
dumpLog.WriteLine("Device reports {0} blocks ({1} bytes).", blocks, blocks * blockSize);
dumpLog.WriteLine("Device can read {0} blocks at a time.", blocksToRead);
dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize);
dumpLog.WriteLine("Device reports {0} bytes per physical block.", scsiReader.LongBlockSize);
dumpLog.WriteLine("SCSI device type: {0}.", dev.ScsiType);
dumpLog.WriteLine("SCSI medium type: {0}.", scsiMediumType);
dumpLog.WriteLine("SCSI density type: {0}.", scsiDensityCode);
dumpLog.WriteLine("SCSI floppy mode page present: {0}.", containsFloppyPage);
dumpLog.WriteLine("Media identified as {0}.", dskType);
if(!opticalDisc) if(!opticalDisc)
{ {
sidecar.BlockMedia = new BlockMediaType[1]; sidecar.BlockMedia = new BlockMediaType[1];
@@ -169,10 +142,11 @@ namespace DiscImageChef.Core.Devices.Dumping
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].USB.Descriptors.Image, dev.UsbDescriptors); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].USB.Descriptors.Image, dev.UsbDescriptors);
} }
byte[] cmdBuf;
if(dev.Type == DeviceType.ATAPI) if(dev.Type == DeviceType.ATAPI)
{ {
dumpLog.WriteLine("Requesting ATAPI IDENTIFY PACKET DEVICE."); dumpLog.WriteLine("Requesting ATAPI IDENTIFY PACKET DEVICE.");
sense = dev.AtapiIdentify(out cmdBuf, out AtaErrorRegistersCHS errorRegs); sense = dev.AtapiIdentify(out cmdBuf, out _);
if(!sense) if(!sense)
{ {
sidecar.BlockMedia[0].ATA = new ATAType sidecar.BlockMedia[0].ATA = new ATAType
@@ -188,7 +162,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
} }
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf); sense = dev.ScsiInquiry(out cmdBuf, out _);
if(!sense) if(!sense)
{ {
dumpLog.WriteLine("Requesting SCSI INQUIRY."); dumpLog.WriteLine("Requesting SCSI INQUIRY.");
@@ -204,7 +178,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.Inquiry.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.Inquiry.Image, cmdBuf);
dumpLog.WriteLine("Reading SCSI Extended Vendor Page Descriptors."); dumpLog.WriteLine("Reading SCSI Extended Vendor Page Descriptors.");
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, 0x00); sense = dev.ScsiInquiry(out cmdBuf, out _, 0x00);
if(!sense) if(!sense)
{ {
byte[] pages = EVPD.DecodePage00(cmdBuf); byte[] pages = EVPD.DecodePage00(cmdBuf);
@@ -215,7 +189,7 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(byte page in pages) foreach(byte page in pages)
{ {
dumpLog.WriteLine("Requesting page {0:X2}h.", page); dumpLog.WriteLine("Requesting page {0:X2}h.", page);
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, page); sense = dev.ScsiInquiry(out cmdBuf, out _, page);
if(sense) continue; if(sense) continue;
EVPDType evpd = new EVPDType EVPDType evpd = new EVPDType
@@ -234,11 +208,11 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Requesting MODE SENSE (10)."); dumpLog.WriteLine("Requesting MODE SENSE (10).");
sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out duration); 0x3F, 0xFF, 5, out _);
if(!sense || dev.Error) if(!sense || dev.Error)
sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true, sense = dev.ModeSense10(out cmdBuf, out _, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration); ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _);
Modes.DecodedMode? decMode = null; Modes.DecodedMode? decMode = null;
@@ -256,12 +230,12 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Requesting MODE SENSE (6)."); dumpLog.WriteLine("Requesting MODE SENSE (6).");
sense = dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out duration); 0x00, 5, out _);
if(sense || dev.Error) if(sense || dev.Error)
sense = dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out duration); 0x3F, 0x00, 5, out _);
if(sense || dev.Error) sense = dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); if(sense || dev.Error) sense = dev.ModeSense(out cmdBuf, out _, 5, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
if(Modes.DecodeMode6(cmdBuf, dev.ScsiType).HasValue) if(Modes.DecodeMode6(cmdBuf, dev.ScsiType).HasValue)
@@ -289,15 +263,33 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
} }
if(dskType == MediaType.Unknown)
dskType = MediaTypeFromScsi.Get((byte)dev.ScsiType, dev.Manufacturer, dev.Model, scsiMediumType,
scsiDensityCode, blocks, blockSize);
dumpLog.WriteLine("Device reports {0} blocks ({1} bytes).", blocks, blocks * blockSize);
dumpLog.WriteLine("Device can read {0} blocks at a time.", blocksToRead);
dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize);
dumpLog.WriteLine("Device reports {0} bytes per physical block.", scsiReader.LongBlockSize);
dumpLog.WriteLine("SCSI device type: {0}.", dev.ScsiType);
dumpLog.WriteLine("SCSI medium type: {0}.", scsiMediumType);
dumpLog.WriteLine("SCSI density type: {0}.", scsiDensityCode);
if(dskType == MediaType.Unknown && dev.IsUsb && containsFloppyPage) dskType = MediaType.FlashDrive;
DicConsole.WriteLine("Media identified as {0}", dskType);
dumpLog.WriteLine("SCSI floppy mode page present: {0}.", containsFloppyPage);
dumpLog.WriteLine("Media identified as {0}.", dskType);
uint longBlockSize = scsiReader.LongBlockSize; uint longBlockSize = scsiReader.LongBlockSize;
if(dumpRaw) if(dumpRaw)
if(blockSize == longBlockSize) if(blockSize == longBlockSize)
{ {
if(!scsiReader.CanReadRaw) DicConsole.ErrorWriteLine("Device doesn't seem capable of reading raw data from media."); DicConsole.ErrorWriteLine(!scsiReader.CanReadRaw
else ? "Device doesn't seem capable of reading raw data from media."
DicConsole : "Device is capable of reading raw data but I've been unable to guess correct sector size.");
.ErrorWriteLine("Device is capable of reading raw data but I've been unable to guess correct sector size.");
if(!force) if(!force)
{ {
@@ -312,10 +304,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
else else
{ {
if(longBlockSize == 37856 // Only a block will be read, but it contains 16 sectors and command expect sector number not block number
) // Only a block will be read, but it contains 16 sectors and command expect sector number not block number blocksToRead = (uint)(longBlockSize == 37856 ? 16 : 1);
blocksToRead = 16;
else blocksToRead = 1;
DicConsole.WriteLine("Reading {0} raw bytes ({1} cooked bytes) per sector.", longBlockSize, DicConsole.WriteLine("Reading {0} raw bytes ({1} cooked bytes) per sector.", longBlockSize,
blockSize * blocksToRead); blockSize * blocksToRead);
physicalBlockSize = longBlockSize; physicalBlockSize = longBlockSize;
@@ -326,9 +316,9 @@ namespace DiscImageChef.Core.Devices.Dumping
string outputExtension = ".bin"; string outputExtension = ".bin";
if(opticalDisc && blockSize == 2048) outputExtension = ".iso"; if(opticalDisc && blockSize == 2048) outputExtension = ".iso";
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", currentProfile); IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", SBC_PROFILE);
dumpFile = new DataFile(outputPrefix + outputExtension); DataFile dumpFile = new DataFile(outputPrefix + outputExtension);
start = DateTime.UtcNow; start = DateTime.UtcNow;
@@ -387,11 +377,9 @@ namespace DiscImageChef.Core.Devices.Dumping
// Write empty data // Write empty data
dumpFile.Write(new byte[blockSize * blocksToRead]); dumpFile.Write(new byte[blockSize * blocksToRead]);
errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b); for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, i); dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, i);
@@ -454,25 +442,12 @@ namespace DiscImageChef.Core.Devices.Dumping
goto repeatRetry; goto repeatRetry;
} }
Modes.DecodedMode? currentMode = null;
Modes.ModePage? currentModePage = null; Modes.ModePage? currentModePage = null;
byte[] md6; byte[] md6;
byte[] md10; byte[] md10;
if(!runningPersistent && persistent) if(!runningPersistent && persistent)
{ {
sense = dev.ModeSense6(out readBuffer, out senseBuf, false, ScsiModeSensePageControl.Current, 0x01,
dev.Timeout, out duration);
if(sense)
{
sense = dev.ModeSense10(out readBuffer, out senseBuf, false, ScsiModeSensePageControl.Current,
0x01, dev.Timeout, out duration);
if(!sense) currentMode = Modes.DecodeMode10(readBuffer, dev.ScsiType);
}
else currentMode = Modes.DecodeMode6(readBuffer, dev.ScsiType);
if(currentMode.HasValue) currentModePage = currentMode.Value.Pages[0];
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{ {
Modes.ModePage_01_MMC pgMmc = Modes.ModePage_01_MMC pgMmc =
@@ -531,8 +506,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Sending MODE SELECT to drive."); dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); sense = dev.ModeSelect(md6, out _, true, false, dev.Timeout, out _);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); if(sense) sense = dev.ModeSelect10(md10, out _, true, false, dev.Timeout, out _);
runningPersistent = true; runningPersistent = true;
if(!sense && !dev.Error) if(!sense && !dev.Error)
@@ -552,8 +527,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType); md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive."); dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); sense = dev.ModeSelect(md6, out _, true, false, dev.Timeout, out _);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); if(sense) dev.ModeSelect10(md10, out _, true, false, dev.Timeout, out _);
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
@@ -563,7 +538,7 @@ namespace DiscImageChef.Core.Devices.Dumping
resume.BadBlocks.Sort(); resume.BadBlocks.Sort();
currentTry.Extents = ExtentsConverter.ToMetadata(extents); currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dataChk = new Checksum(); Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin); dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500; blocksToRead = 500;
@@ -601,7 +576,6 @@ namespace DiscImageChef.Core.Devices.Dumping
PluginBase plugins = new PluginBase(); PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding); plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList(); FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + outputExtension); Filter inputFilter = filtersList.GetFilter(outputPrefix + outputExtension);
@@ -611,7 +585,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
imageFormat = ImageFormat.Detect(inputFilter); ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null; PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; } try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -648,7 +622,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, partitions[i])) continue; if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out string foo); plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
@@ -689,7 +663,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, wholePart)) continue; if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo); plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);

View File

@@ -50,15 +50,13 @@ namespace DiscImageChef.Core.Devices.Dumping
bool dumpRaw, bool persistent, bool stopOnError, bool separateSubchannel, bool dumpRaw, bool persistent, bool stopOnError, bool separateSubchannel,
ref Resume resume, ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding) ref Resume resume, ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding)
{ {
byte[] senseBuf;
bool sense;
MediaType dskType = MediaType.Unknown; MediaType dskType = MediaType.Unknown;
int resets = 0; int resets = 0;
if(dev.IsRemovable) if(dev.IsRemovable)
{ {
deviceGotReset: deviceGotReset:
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out double duration); bool sense = dev.ScsiTestUnitReady(out byte[] senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuf); FixedSense? decSense = Sense.DecodeFixed(senseBuf);
@@ -81,7 +79,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
DicConsole.WriteLine("\rWaiting for drive to become ready"); DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break; if(!sense) break;
decSense = Sense.DecodeFixed(senseBuf); decSense = Sense.DecodeFixed(senseBuf);
@@ -104,7 +102,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
DicConsole.WriteLine("\rWaiting for drive to become ready"); DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break; if(!sense) break;
decSense = Sense.DecodeFixed(senseBuf); decSense = Sense.DecodeFixed(senseBuf);
@@ -141,7 +139,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
DicConsole.WriteLine("\rWaiting for drive to become ready"); DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break; if(!sense) break;
decSense = Sense.DecodeFixed(senseBuf); decSense = Sense.DecodeFixed(senseBuf);

View File

@@ -53,8 +53,6 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
FixedSense? fxSense; FixedSense? fxSense;
bool aborted; bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
bool sense; bool sense;
ulong blocks = 0; ulong blocks = 0;
uint blockSize; uint blockSize;
@@ -66,7 +64,6 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
Checksum dataChk;
dev.RequestSense(out byte[] senseBuf, dev.Timeout, out double duration); dev.RequestSense(out byte[] senseBuf, dev.Timeout, out double duration);
fxSense = Sense.DecodeFixed(senseBuf, out string strSense); fxSense = Sense.DecodeFixed(senseBuf, out string strSense);
@@ -87,7 +84,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Rewinding, please wait..."); dumpLog.WriteLine("Rewinding, please wait...");
DicConsole.Write("Rewinding, please wait..."); DicConsole.Write("Rewinding, please wait...");
// Rewind, let timeout apply // Rewind, let timeout apply
sense = dev.Rewind(out senseBuf, dev.Timeout, out duration); dev.Rewind(out senseBuf, dev.Timeout, out duration);
// Still rewinding? // Still rewinding?
// TODO: Pause? // TODO: Pause?
@@ -367,21 +364,17 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
} }
Checksum partitionChk;
Checksum fileChk;
List<TapePartitionType> partitions = new List<TapePartitionType>(); List<TapePartitionType> partitions = new List<TapePartitionType>();
List<TapeFileType> files = new List<TapeFileType>(); List<TapeFileType> files = new List<TapeFileType>();
TapeFileType currentTapeFile;
TapePartitionType currentTapePartition;
DicConsole.WriteLine(); DicConsole.WriteLine();
DataFile dumpFile = new DataFile(outputPrefix + ".bin"); DataFile dumpFile = new DataFile(outputPrefix + ".bin");
dataChk = new Checksum(); Checksum dataChk = new Checksum();
start = DateTime.UtcNow; start = DateTime.UtcNow;
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, 1); MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, 1);
ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0008); IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0008);
currentTapeFile = new TapeFileType TapeFileType currentTapeFile = new TapeFileType
{ {
Image = new ImageType Image = new ImageType
{ {
@@ -394,8 +387,8 @@ namespace DiscImageChef.Core.Devices.Dumping
StartBlock = (long)currentBlock, StartBlock = (long)currentBlock,
BlockSize = blockSize BlockSize = blockSize
}; };
fileChk = new Checksum(); Checksum fileChk = new Checksum();
currentTapePartition = new TapePartitionType TapePartitionType currentTapePartition = new TapePartitionType
{ {
Image = new ImageType Image = new ImageType
{ {
@@ -407,7 +400,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Sequence = currentPartition, Sequence = currentPartition,
StartBlock = (long)currentBlock StartBlock = (long)currentBlock
}; };
partitionChk = new Checksum(); Checksum partitionChk = new Checksum();
aborted = false; aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
@@ -467,7 +460,7 @@ namespace DiscImageChef.Core.Devices.Dumping
currentPartitionSize = 0; currentPartitionSize = 0;
partitionChk = new Checksum(); partitionChk = new Checksum();
DicConsole.WriteLine("Seeking to partition {0}", currentPartition); DicConsole.WriteLine("Seeking to partition {0}", currentPartition);
sense = dev.Locate(out senseBuf, false, currentPartition, 0, dev.Timeout, out duration); dev.Locate(out senseBuf, false, currentPartition, 0, dev.Timeout, out duration);
totalDuration += duration; totalDuration += duration;
} }

View File

@@ -57,8 +57,6 @@ namespace DiscImageChef.Core.Devices.Dumping
ref DumpLog dumpLog, Encoding encoding) ref DumpLog dumpLog, Encoding encoding)
{ {
bool aborted; bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
if(dumpRaw) if(dumpRaw)
{ {
@@ -73,8 +71,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
bool sense; bool sense;
ushort currentProfile = 0x0001; const ushort SD_PROFILE = 0x0001;
uint timeout = 5; const uint TIMEOUT = 5;
double duration; double duration;
CICMMetadataType sidecar = CICMMetadataType sidecar =
@@ -83,26 +81,21 @@ namespace DiscImageChef.Core.Devices.Dumping
uint blocksToRead = 128; uint blocksToRead = 128;
uint blockSize = 512; uint blockSize = 512;
ulong blocks = 0; ulong blocks = 0;
byte[] cid;
byte[] csd = null; byte[] csd = null;
byte[] ocr = null; byte[] ocr = null;
byte[] ecsd = null; byte[] ecsd = null;
byte[] scr = null; byte[] scr = null;
uint[] response;
int physicalBlockSize = 0; int physicalBlockSize = 0;
bool byteAddressed = true; bool byteAddressed = true;
switch(dev.Type) { switch(dev.Type) {
case DeviceType.MMC: case DeviceType.MMC:
{ {
ExtendedCSD ecsdDecoded = new ExtendedCSD();
CSD csdDecoded = new CSD();
dumpLog.WriteLine("Reading Extended CSD"); dumpLog.WriteLine("Reading Extended CSD");
sense = dev.ReadExtendedCsd(out ecsd, out response, timeout, out duration); sense = dev.ReadExtendedCsd(out ecsd, out _, TIMEOUT, out duration);
if(!sense) if(!sense)
{ {
ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd); ExtendedCSD ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
blocksToRead = ecsdDecoded.OptimalReadSize; blocksToRead = ecsdDecoded.OptimalReadSize;
blocks = ecsdDecoded.SectorCount; blocks = ecsdDecoded.SectorCount;
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512); blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
@@ -114,12 +107,12 @@ namespace DiscImageChef.Core.Devices.Dumping
else ecsd = null; else ecsd = null;
dumpLog.WriteLine("Reading CSD"); dumpLog.WriteLine("Reading CSD");
sense = dev.ReadCsd(out csd, out response, timeout, out duration); sense = dev.ReadCsd(out csd, out _, TIMEOUT, out duration);
if(!sense) if(!sense)
{ {
if(blocks == 0) if(blocks == 0)
{ {
csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd); CSD csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd);
blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)); blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength); blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
} }
@@ -127,7 +120,7 @@ namespace DiscImageChef.Core.Devices.Dumping
else csd = null; else csd = null;
dumpLog.WriteLine("Reading OCR"); dumpLog.WriteLine("Reading OCR");
sense = dev.ReadOcr(out ocr, out response, timeout, out duration); sense = dev.ReadOcr(out ocr, out _, TIMEOUT, out duration);
if(sense) ocr = null; if(sense) ocr = null;
sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType(); sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType();
@@ -135,13 +128,11 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
case DeviceType.SecureDigital: case DeviceType.SecureDigital:
{ {
Decoders.SecureDigital.CSD csdDecoded = new Decoders.SecureDigital.CSD();
dumpLog.WriteLine("Reading CSD"); dumpLog.WriteLine("Reading CSD");
sense = dev.ReadCsd(out csd, out response, timeout, out duration); sense = dev.ReadCsd(out csd, out _, TIMEOUT, out duration);
if(!sense) if(!sense)
{ {
csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd); Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
blocks = (ulong)(csdDecoded.Structure == 0 blocks = (ulong)(csdDecoded.Structure == 0
? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2) ? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
: (csdDecoded.Size + 1) * 1024); : (csdDecoded.Size + 1) * 1024);
@@ -152,11 +143,11 @@ namespace DiscImageChef.Core.Devices.Dumping
else csd = null; else csd = null;
dumpLog.WriteLine("Reading OCR"); dumpLog.WriteLine("Reading OCR");
sense = dev.ReadSdocr(out ocr, out response, timeout, out duration); sense = dev.ReadSdocr(out ocr, out _, TIMEOUT, out duration);
if(sense) ocr = null; if(sense) ocr = null;
dumpLog.WriteLine("Reading SCR"); dumpLog.WriteLine("Reading SCR");
sense = dev.ReadScr(out scr, out response, timeout, out duration); sense = dev.ReadScr(out scr, out _, TIMEOUT, out duration);
if(sense) scr = null; if(sense) scr = null;
sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType(); sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType();
@@ -165,7 +156,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Reading CID"); dumpLog.WriteLine("Reading CID");
sense = dev.ReadCid(out cid, out response, timeout, out duration); sense = dev.ReadCid(out byte[] cid, out _, TIMEOUT, out duration);
if(sense) cid = null; if(sense) cid = null;
DumpType cidDump = null; DumpType cidDump = null;
@@ -182,7 +173,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}; };
DataFile.WriteTo("MMC/SecureDigital Dump", cidDump.Image, cid); DataFile.WriteTo("MMC/SecureDigital Dump", cidDump.Image, cid);
} }
;
if(csd != null) if(csd != null)
{ {
csdDump = new DumpType csdDump = new DumpType
@@ -193,7 +184,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}; };
DataFile.WriteTo("MMC/SecureDigital Dump", csdDump.Image, csd); DataFile.WriteTo("MMC/SecureDigital Dump", csdDump.Image, csd);
} }
;
if(ecsd != null) if(ecsd != null)
{ {
sidecar.BlockMedia[0].MultiMediaCard.ExtendedCSD = new DumpType sidecar.BlockMedia[0].MultiMediaCard.ExtendedCSD = new DumpType
@@ -205,7 +196,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DataFile.WriteTo("MMC/SecureDigital Dump", sidecar.BlockMedia[0].MultiMediaCard.ExtendedCSD.Image, DataFile.WriteTo("MMC/SecureDigital Dump", sidecar.BlockMedia[0].MultiMediaCard.ExtendedCSD.Image,
ecsd); ecsd);
} }
;
if(ocr != null) if(ocr != null)
{ {
ocrDump = new DumpType ocrDump = new DumpType
@@ -216,7 +207,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}; };
DataFile.WriteTo("MMC/SecureDigital Dump", ocrDump.Image, ocr); DataFile.WriteTo("MMC/SecureDigital Dump", ocrDump.Image, ocr);
} }
;
if(scr != null) if(scr != null)
{ {
sidecar.BlockMedia[0].SecureDigital.SCR = new DumpType sidecar.BlockMedia[0].SecureDigital.SCR = new DumpType
@@ -227,7 +218,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}; };
DataFile.WriteTo("MMC/SecureDigital Dump", sidecar.BlockMedia[0].SecureDigital.SCR.Image, scr); DataFile.WriteTo("MMC/SecureDigital Dump", sidecar.BlockMedia[0].SecureDigital.SCR.Image, scr);
} }
;
switch(dev.Type) { switch(dev.Type) {
case DeviceType.MMC: case DeviceType.MMC:
@@ -249,13 +240,10 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
Checksum dataChk;
aborted = false; aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
DataFile dumpFile;
if(blocks == 0) if(blocks == 0)
{ {
dumpLog.WriteLine("Cannot get device size."); dumpLog.WriteLine("Cannot get device size.");
@@ -266,11 +254,11 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Device reports {0} blocks.", blocks); dumpLog.WriteLine("Device reports {0} blocks.", blocks);
byte[] cmdBuf; byte[] cmdBuf;
bool error = true; bool error;
while(true) while(true)
{ {
error = dev.Read(out cmdBuf, out response, 0, blockSize, blocksToRead, byteAddressed, timeout, error = dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT,
out duration); out duration);
if(error) blocksToRead /= 2; if(error) blocksToRead /= 2;
@@ -280,7 +268,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(error) if(error)
{ {
blocksToRead = 1;
dumpLog.WriteLine("ERROR: Cannot get blocks to read, device error {0}.", dev.LastError); dumpLog.WriteLine("ERROR: Cannot get blocks to read, device error {0}.", dev.LastError);
DicConsole.ErrorWriteLine("Device error {0} trying to guess ideal transfer length.", dev.LastError); DicConsole.ErrorWriteLine("Device error {0} trying to guess ideal transfer length.", dev.LastError);
return; return;
@@ -297,9 +284,9 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead); DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", currentProfile); IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", SD_PROFILE);
dumpFile = new DataFile(outputPrefix + ".bin"); DataFile dumpFile = new DataFile(outputPrefix + ".bin");
dumpFile.Seek(resume.NextBlock, blockSize); dumpFile.Seek(resume.NextBlock, blockSize);
if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock); if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock);
@@ -322,7 +309,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed);
error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed, timeout, error = dev.Read(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, TIMEOUT,
out duration); out duration);
if(!error) if(!error)
@@ -336,8 +323,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b); for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
if(duration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, duration < 500 ? 65535 : duration);
else mhddLog.Write(i, duration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
dumpFile.Write(new byte[blockSize * blocksToRead]); dumpFile.Write(new byte[blockSize * blocksToRead]);
@@ -380,7 +366,7 @@ namespace DiscImageChef.Core.Devices.Dumping
forward ? "forward" : "reverse", forward ? "forward" : "reverse",
runningPersistent ? "recovering partial data, " : ""); runningPersistent ? "recovering partial data, " : "");
error = dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, byteAddressed, timeout, error = dev.Read(out cmdBuf, out _, (uint)badSector, blockSize, 1, byteAddressed, TIMEOUT,
out duration); out duration);
totalDuration += duration; totalDuration += duration;
@@ -410,7 +396,7 @@ namespace DiscImageChef.Core.Devices.Dumping
currentTry.Extents = ExtentsConverter.ToMetadata(extents); currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dataChk = new Checksum(); Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin); dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500; blocksToRead = 500;
@@ -448,7 +434,6 @@ namespace DiscImageChef.Core.Devices.Dumping
PluginBase plugins = new PluginBase(); PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding); plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList(); FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin"); Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
@@ -459,7 +444,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
imageFormat = ImageFormat.Detect(inputFilter); ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null; PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; } try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -496,7 +481,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, partitions[i])) continue; if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out string foo); plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
@@ -527,7 +512,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, wholePart)) continue; if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo); plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
@@ -555,6 +540,7 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(CommonTypes.MediaType.SecureDigital); sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(CommonTypes.MediaType.SecureDigital);
break; break;
} }
sidecar.BlockMedia[0].DiskType = xmlDskTyp; sidecar.BlockMedia[0].DiskType = xmlDskTyp;
sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp; sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp;
// TODO: Implement device firmware revision // TODO: Implement device firmware revision
@@ -569,6 +555,7 @@ namespace DiscImageChef.Core.Devices.Dumping
case DeviceType.SecureDigital: sidecar.BlockMedia[0].Interface = "SecureDigital"; case DeviceType.SecureDigital: sidecar.BlockMedia[0].Interface = "SecureDigital";
break; break;
} }
sidecar.BlockMedia[0].LogicalBlocks = (long)blocks; sidecar.BlockMedia[0].LogicalBlocks = (long)blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize > 0 ? physicalBlockSize : (int)blockSize; sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize > 0 ? physicalBlockSize : (int)blockSize;
sidecar.BlockMedia[0].LogicalBlockSize = (int)blockSize; sidecar.BlockMedia[0].LogicalBlockSize = (int)blockSize;

View File

@@ -60,13 +60,10 @@ namespace DiscImageChef.Core.Devices.Dumping
ref MediaType dskType, ref Resume resume, ref DumpLog dumpLog, ref MediaType dskType, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding) Encoding encoding)
{ {
MhddLog mhddLog;
IbgLog ibgLog;
bool sense; bool sense;
ulong blocks; ulong blocks;
uint blockSize = 2048; const uint BLOCK_SIZE = 2048;
uint blocksToRead = 64; uint blocksToRead = 64;
ulong errored = 0;
DateTime start; DateTime start;
DateTime end; DateTime end;
double totalDuration = 0; double totalDuration = 0;
@@ -74,13 +71,11 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
Checksum dataChk;
DataFile dumpFile;
bool aborted = false; bool aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
dumpLog.WriteLine("Reading Xbox Security Sector."); dumpLog.WriteLine("Reading Xbox Security Sector.");
sense = dev.KreonExtractSs(out byte[] ssBuf, out byte[] senseBuf, dev.Timeout, out double duration); sense = dev.KreonExtractSs(out byte[] ssBuf, out byte[] senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get Xbox Security Sector, not continuing."); dumpLog.WriteLine("Cannot get Xbox Security Sector, not continuing.");
@@ -123,7 +118,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Get video partition size // Get video partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting video partition size"); DicConsole.DebugWriteLine("Dump-media command", "Getting video partition size");
dumpLog.WriteLine("Locking drive."); dumpLog.WriteLine("Locking drive.");
sense = dev.KreonLock(out senseBuf, dev.Timeout, out duration); sense = dev.KreonLock(out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot lock drive, not continuing."); dumpLog.WriteLine("Cannot lock drive, not continuing.");
@@ -132,7 +127,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Getting video partition size."); dumpLog.WriteLine("Getting video partition size.");
sense = dev.ReadCapacity(out byte[] readBuffer, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCapacity(out byte[] readBuffer, out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get disc capacity."); dumpLog.WriteLine("Cannot get disc capacity.");
@@ -143,7 +138,7 @@ namespace DiscImageChef.Core.Devices.Dumping
totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]);
dumpLog.WriteLine("Reading Physical Format Information."); dumpLog.WriteLine("Reading Physical Format Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration); MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get PFI."); dumpLog.WriteLine("Cannot get PFI.");
@@ -166,7 +161,7 @@ namespace DiscImageChef.Core.Devices.Dumping
l1Video = totalSize - l0Video + 1; l1Video = totalSize - l0Video + 1;
dumpLog.WriteLine("Reading Disc Manufacturing Information."); dumpLog.WriteLine("Reading Disc Manufacturing Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out duration); MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get DMI."); dumpLog.WriteLine("Cannot get DMI.");
@@ -187,7 +182,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Get game partition size // Get game partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting game partition size"); DicConsole.DebugWriteLine("Dump-media command", "Getting game partition size");
dumpLog.WriteLine("Unlocking drive (Xtreme)."); dumpLog.WriteLine("Unlocking drive (Xtreme).");
sense = dev.KreonUnlockXtreme(out senseBuf, dev.Timeout, out duration); sense = dev.KreonUnlockXtreme(out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot unlock drive, not continuing."); dumpLog.WriteLine("Cannot unlock drive, not continuing.");
@@ -196,7 +191,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Getting game partition size."); dumpLog.WriteLine("Getting game partition size.");
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get disc capacity."); dumpLog.WriteLine("Cannot get disc capacity.");
@@ -211,7 +206,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Get middle zone size // Get middle zone size
DicConsole.DebugWriteLine("Dump-media command", "Getting middle zone size"); DicConsole.DebugWriteLine("Dump-media command", "Getting middle zone size");
dumpLog.WriteLine("Unlocking drive (Wxripper)."); dumpLog.WriteLine("Unlocking drive (Wxripper).");
sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out duration); sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot unlock drive, not continuing."); dumpLog.WriteLine("Cannot unlock drive, not continuing.");
@@ -220,7 +215,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Getting disc size."); dumpLog.WriteLine("Getting disc size.");
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get disc capacity."); dumpLog.WriteLine("Cannot get disc capacity.");
@@ -231,7 +226,7 @@ namespace DiscImageChef.Core.Devices.Dumping
totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); totalSize = (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]);
dumpLog.WriteLine("Reading Physical Format Information."); dumpLog.WriteLine("Reading Physical Format Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration); MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get PFI."); dumpLog.WriteLine("Cannot get PFI.");
@@ -256,7 +251,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading Disc Manufacturing Information."); dumpLog.WriteLine("Reading Disc Manufacturing Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out duration); MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot get DMI."); dumpLog.WriteLine("Cannot get DMI.");
@@ -292,8 +287,8 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Total 0 size: {0} sectors", totalSize); dumpLog.WriteLine("Total 0 size: {0} sectors", totalSize);
dumpLog.WriteLine("Real layer break: {0}", layerBreak); dumpLog.WriteLine("Real layer break: {0}", layerBreak);
bool read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, 1, bool read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, BLOCK_SIZE, 0, 1,
false, dev.Timeout, out duration); false, dev.Timeout, out _);
if(!read12) if(!read12)
{ {
dumpLog.WriteLine("Cannot read medium, aborting scan..."); dumpLog.WriteLine("Cannot read medium, aborting scan...");
@@ -308,8 +303,8 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(read12) if(read12)
{ {
sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, blockSize, 0, sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, BLOCK_SIZE, 0,
blocksToRead, false, dev.Timeout, out duration); blocksToRead, false, dev.Timeout, out _);
if(sense || dev.Error) blocksToRead /= 2; if(sense || dev.Error) blocksToRead /= 2;
} }
@@ -326,9 +321,9 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead); dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead);
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead); DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, BLOCK_SIZE, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0010); IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0010);
dumpFile = new DataFile(outputPrefix + ".iso"); DataFile dumpFile = new DataFile(outputPrefix + ".iso");
start = DateTime.UtcNow; start = DateTime.UtcNow;
@@ -342,7 +337,7 @@ namespace DiscImageChef.Core.Devices.Dumping
throw new Exception("Could not process resume file, not continuing..."); throw new Exception("Could not process resume file, not continuing...");
ulong currentSector = resume.NextBlock; ulong currentSector = resume.NextBlock;
dumpFile.Seek(resume.NextBlock, blockSize); dumpFile.Seek(resume.NextBlock, BLOCK_SIZE);
if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock); if(resume.NextBlock > 0) dumpLog.WriteLine("Resuming from block {0}.", resume.NextBlock);
dumpLog.WriteLine("Reading game partition."); dumpLog.WriteLine("Reading game partition.");
@@ -402,7 +397,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, totalSize, currentSpeed); DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, totalSize, currentSpeed);
sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize, sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, BLOCK_SIZE,
0, blocksToRead, false, dev.Timeout, out cmdDuration); 0, blocksToRead, false, dev.Timeout, out cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
@@ -419,15 +414,13 @@ namespace DiscImageChef.Core.Devices.Dumping
if(stopOnError) return; // TODO: Return more cleanly if(stopOnError) return; // TODO: Return more cleanly
// Write empty data // Write empty data
dumpFile.Write(new byte[blockSize * blocksToRead]); dumpFile.Write(new byte[BLOCK_SIZE * blocksToRead]);
errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b); for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}", DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf)); Sense.PrettifySense(senseBuf));
if(cmdDuration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
@@ -437,7 +430,7 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(string senseLine in senseLines) dumpLog.WriteLine(senseLine); foreach(string senseLine in senseLines) dumpLog.WriteLine(senseLine);
} }
currentSpeed = (double)blockSize * blocksToRead / 1048576 / (cmdDuration / 1000); currentSpeed = (double)BLOCK_SIZE * blocksToRead / 1048576 / (cmdDuration / 1000);
blocksToRead = saveBlocksToRead; blocksToRead = saveBlocksToRead;
currentSector = i + 1; currentSector = i + 1;
resume.NextBlock = currentSector; resume.NextBlock = currentSector;
@@ -485,7 +478,7 @@ namespace DiscImageChef.Core.Devices.Dumping
mhddLog.Write(middle + currentSector, cmdDuration); mhddLog.Write(middle + currentSector, cmdDuration);
ibgLog.Write(middle + currentSector, currentSpeed * 1024); ibgLog.Write(middle + currentSector, currentSpeed * 1024);
dumpFile.Write(new byte[blockSize * blocksToRead]); dumpFile.Write(new byte[BLOCK_SIZE * blocksToRead]);
extents.Add(currentSector, blocksToRead, true); extents.Add(currentSector, blocksToRead, true);
currentSector += blocksToRead; currentSector += blocksToRead;
@@ -495,7 +488,7 @@ namespace DiscImageChef.Core.Devices.Dumping
blocksToRead = saveBlocksToRead; blocksToRead = saveBlocksToRead;
dumpLog.WriteLine("Locking drive."); dumpLog.WriteLine("Locking drive.");
sense = dev.KreonLock(out senseBuf, dev.Timeout, out duration); sense = dev.KreonLock(out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot lock drive, not continuing."); dumpLog.WriteLine("Cannot lock drive, not continuing.");
@@ -503,7 +496,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
DicConsole.ErrorWriteLine("Cannot get disc capacity."); DicConsole.ErrorWriteLine("Cannot get disc capacity.");
@@ -531,7 +524,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", currentSector, totalSize, DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", currentSector, totalSize,
currentSpeed); currentSpeed);
sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, blockSize, 0, sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, BLOCK_SIZE, 0,
blocksToRead, false, dev.Timeout, out cmdDuration); blocksToRead, false, dev.Timeout, out cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
@@ -548,15 +541,14 @@ namespace DiscImageChef.Core.Devices.Dumping
if(stopOnError) return; // TODO: Return more cleanly if(stopOnError) return; // TODO: Return more cleanly
// Write empty data // Write empty data
dumpFile.Write(new byte[blockSize * blocksToRead]); dumpFile.Write(new byte[BLOCK_SIZE * blocksToRead]);
// TODO: Handle errors in video partition // TODO: Handle errors in video partition
//errored += blocksToRead; //errored += blocksToRead;
//resume.BadBlocks.Add(l1); //resume.BadBlocks.Add(l1);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}", DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf)); Sense.PrettifySense(senseBuf));
if(cmdDuration < 500) mhddLog.Write(l1, 65535); mhddLog.Write(l1, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(l1, cmdDuration);
ibgLog.Write(l1, 0); ibgLog.Write(l1, 0);
dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, l1); dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, l1);
@@ -566,13 +558,13 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(string senseLine in senseLines) dumpLog.WriteLine(senseLine); foreach(string senseLine in senseLines) dumpLog.WriteLine(senseLine);
} }
currentSpeed = (double)blockSize * blocksToRead / 1048576 / (cmdDuration / 1000); currentSpeed = (double)BLOCK_SIZE * blocksToRead / 1048576 / (cmdDuration / 1000);
currentSector += blocksToRead; currentSector += blocksToRead;
resume.NextBlock = currentSector; resume.NextBlock = currentSector;
} }
dumpLog.WriteLine("Unlocking drive (Wxripper)."); dumpLog.WriteLine("Unlocking drive (Wxripper).");
sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out duration); sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
dumpLog.WriteLine("Cannot unlock drive, not continuing."); dumpLog.WriteLine("Cannot unlock drive, not continuing.");
@@ -580,7 +572,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
DicConsole.ErrorWriteLine("Cannot get disc capacity."); DicConsole.ErrorWriteLine("Cannot get disc capacity.");
@@ -590,11 +582,11 @@ namespace DiscImageChef.Core.Devices.Dumping
end = DateTime.UtcNow; end = DateTime.UtcNow;
DicConsole.WriteLine(); DicConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath);
dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds);
dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); (double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
#region Error handling #region Error handling
if(resume.BadBlocks.Count > 0 && !aborted) if(resume.BadBlocks.Count > 0 && !aborted)
@@ -627,17 +619,17 @@ namespace DiscImageChef.Core.Devices.Dumping
runningPersistent ? "recovering partial data, " : ""); runningPersistent ? "recovering partial data, " : "");
sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)badSector, sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)badSector,
blockSize, 0, 1, false, dev.Timeout, out cmdDuration); BLOCK_SIZE, 0, 1, false, dev.Timeout, out cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
resume.BadBlocks.Remove(badSector); resume.BadBlocks.Remove(badSector);
extents.Add(badSector); extents.Add(badSector);
dumpFile.WriteAt(readBuffer, badSector, blockSize); dumpFile.WriteAt(readBuffer, badSector, BLOCK_SIZE);
dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass); dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass);
} }
else if(runningPersistent) dumpFile.WriteAt(readBuffer, badSector, blockSize); else if(runningPersistent) dumpFile.WriteAt(readBuffer, badSector, BLOCK_SIZE);
} }
if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0) if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0)
@@ -649,25 +641,12 @@ namespace DiscImageChef.Core.Devices.Dumping
goto repeatRetry; goto repeatRetry;
} }
Modes.DecodedMode? currentMode = null;
Modes.ModePage? currentModePage = null; Modes.ModePage? currentModePage = null;
byte[] md6; byte[] md6;
byte[] md10; byte[] md10;
if(!runningPersistent && persistent) if(!runningPersistent && persistent)
{ {
sense = dev.ModeSense6(out readBuffer, out senseBuf, false, ScsiModeSensePageControl.Current, 0x01,
dev.Timeout, out duration);
if(sense)
{
sense = dev.ModeSense10(out readBuffer, out senseBuf, false, ScsiModeSensePageControl.Current,
0x01, dev.Timeout, out duration);
if(!sense) currentMode = Modes.DecodeMode10(readBuffer, dev.ScsiType);
}
else currentMode = Modes.DecodeMode6(readBuffer, dev.ScsiType);
if(currentMode.HasValue) currentModePage = currentMode.Value.Pages[0];
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{ {
Modes.ModePage_01_MMC pgMmc = Modes.ModePage_01_MMC pgMmc =
@@ -726,8 +705,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
dumpLog.WriteLine("Sending MODE SELECT to drive."); dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out _);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out _);
runningPersistent = true; runningPersistent = true;
if(!sense && !dev.Error) if(!sense && !dev.Error)
@@ -747,8 +726,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType); md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive."); dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out _);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); if(sense) dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out _);
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
@@ -758,7 +737,7 @@ namespace DiscImageChef.Core.Devices.Dumping
resume.BadBlocks.Sort(); resume.BadBlocks.Sort();
currentTry.Extents = ExtentsConverter.ToMetadata(extents); currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dataChk = new Checksum(); Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin); dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500; blocksToRead = 500;
@@ -778,15 +757,15 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.Write("\rChecksumming sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); DicConsole.Write("\rChecksumming sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed);
DateTime chkStart = DateTime.UtcNow; DateTime chkStart = DateTime.UtcNow;
byte[] dataToCheck = new byte[blockSize * blocksToRead]; byte[] dataToCheck = new byte[BLOCK_SIZE * blocksToRead];
dumpFile.Read(dataToCheck, 0, (int)(blockSize * blocksToRead)); dumpFile.Read(dataToCheck, 0, (int)(BLOCK_SIZE * blocksToRead));
dataChk.Update(dataToCheck); dataChk.Update(dataToCheck);
DateTime chkEnd = DateTime.UtcNow; DateTime chkEnd = DateTime.UtcNow;
double chkDuration = (chkEnd - chkStart).TotalMilliseconds; double chkDuration = (chkEnd - chkStart).TotalMilliseconds;
totalChkDuration += chkDuration; totalChkDuration += chkDuration;
currentSpeed = (double)blockSize * blocksToRead / 1048576 / (chkDuration / 1000); currentSpeed = (double)BLOCK_SIZE * blocksToRead / 1048576 / (chkDuration / 1000);
} }
DicConsole.WriteLine(); DicConsole.WriteLine();
@@ -794,11 +773,10 @@ namespace DiscImageChef.Core.Devices.Dumping
end = DateTime.UtcNow; end = DateTime.UtcNow;
dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds); dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds);
dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); (double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
PluginBase plugins = new PluginBase(); PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding); plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList(); FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".iso"); Filter inputFilter = filtersList.GetFilter(outputPrefix + ".iso");
@@ -808,7 +786,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
imageFormat = ImageFormat.Detect(inputFilter); ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null; PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; } try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -845,7 +823,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(!plugin.Identify(imageFormat, partitions[i])) continue; if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out string foo); plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
@@ -879,14 +857,14 @@ namespace DiscImageChef.Core.Devices.Dumping
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
Partition wholePart = Partition wholePart =
new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize}; new Partition {Name = "Whole device", Length = blocks, Size = blocks * BLOCK_SIZE};
foreach(Filesystem plugin in plugins.PluginsList.Values) foreach(Filesystem plugin in plugins.PluginsList.Values)
try try
{ {
if(!plugin.Identify(imageFormat, wholePart)) continue; if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo); plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type); dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
@@ -932,7 +910,7 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.OpticalDisc[0].Track = new TrackType[1]; sidecar.OpticalDisc[0].Track = new TrackType[1];
sidecar.OpticalDisc[0].Track[0] = new TrackType sidecar.OpticalDisc[0].Track[0] = new TrackType
{ {
BytesPerSector = (int)blockSize, BytesPerSector = (int)BLOCK_SIZE,
Checksums = sidecar.OpticalDisc[0].Checksums, Checksums = sidecar.OpticalDisc[0].Checksums,
EndSector = (long)(blocks - 1), EndSector = (long)(blocks - 1),
Image = Image =
@@ -944,7 +922,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Value = sidecar.OpticalDisc[0].Image.Value Value = sidecar.OpticalDisc[0].Image.Value
}, },
Sequence = new TrackSequenceType {Session = 1, TrackNumber = 1}, Sequence = new TrackSequenceType {Session = 1, TrackNumber = 1},
Size = (long)(totalSize * blockSize), Size = (long)(totalSize * BLOCK_SIZE),
StartSector = 0 StartSector = 0
}; };
if(xmlFileSysInfo != null) sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo; if(xmlFileSysInfo != null) sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo;

View File

@@ -42,7 +42,7 @@ namespace DiscImageChef.Core.Devices
uint timeout; uint timeout;
internal string ErrorMessage { get; private set; } internal string ErrorMessage { get; private set; }
internal ulong Blocks { get; set; } internal ulong Blocks { get; private set; }
internal uint BlocksToRead { get; private set; } internal uint BlocksToRead { get; private set; }
internal uint LogicalBlockSize { get; private set; } internal uint LogicalBlockSize { get; private set; }
internal uint PhysicalBlockSize { get; private set; } internal uint PhysicalBlockSize { get; private set; }
@@ -50,11 +50,11 @@ namespace DiscImageChef.Core.Devices
internal bool CanReadRaw { get; private set; } internal bool CanReadRaw { get; private set; }
internal bool CanSeek internal bool CanSeek
{ {
get { return ataSeek || seek6 || seek10; } get => ataSeek || seek6 || seek10;
} }
internal bool CanSeekLba internal bool CanSeekLba
{ {
get { return ataSeekLba || seek6 || seek10; } get => ataSeekLba || seek6 || seek10;
} }
internal Reader(Device dev, uint timeout, byte[] identification, bool raw = false) internal Reader(Device dev, uint timeout, byte[] identification, bool raw = false)

View File

@@ -103,39 +103,32 @@ namespace DiscImageChef.Core.Devices
bool AtaFindReadCommand() bool AtaFindReadCommand()
{ {
byte[] cmdBuf; bool sense = dev.Read(out byte[] cmdBuf, out AtaErrorRegistersCHS errorChs, false, 0, 0, 1, 1, timeout, out _);
bool sense;
AtaErrorRegistersCHS errorChs;
AtaErrorRegistersLBA28 errorLba;
AtaErrorRegistersLBA48 errorLba48;
double duration;
sense = dev.Read(out cmdBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration);
ataRead = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; ataRead = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0;
sense = dev.Read(out cmdBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); sense = dev.Read(out cmdBuf, out errorChs, true, 0, 0, 1, 1, timeout, out _);
ataReadRetry = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; ataReadRetry = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0;
sense = dev.ReadDma(out cmdBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); sense = dev.ReadDma(out cmdBuf, out errorChs, false, 0, 0, 1, 1, timeout, out _);
ataReadDma = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; ataReadDma = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0;
sense = dev.ReadDma(out cmdBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); sense = dev.ReadDma(out cmdBuf, out errorChs, true, 0, 0, 1, 1, timeout, out _);
ataReadDmaRetry = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0; ataReadDmaRetry = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0 && cmdBuf.Length > 0;
sense = dev.Read(out cmdBuf, out errorLba, false, 0, 1, timeout, out duration); sense = dev.Read(out cmdBuf, out AtaErrorRegistersLBA28 errorLba, false, 0, 1, timeout, out _);
ataReadLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; ataReadLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0;
sense = dev.Read(out cmdBuf, out errorLba, true, 0, 1, timeout, out duration); sense = dev.Read(out cmdBuf, out errorLba, true, 0, 1, timeout, out _);
ataReadRetryLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; ataReadRetryLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0;
sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, 1, timeout, out duration); sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, 1, timeout, out _);
ataReadDmaLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; ataReadDmaLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0;
sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, 1, timeout, out duration); sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, 1, timeout, out _);
ataReadDmaRetryLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0; ataReadDmaRetryLba = !sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0;
sense = dev.Read(out cmdBuf, out errorLba48, 0, 1, timeout, out duration); sense = dev.Read(out cmdBuf, out AtaErrorRegistersLBA48 errorLba48, 0, 1, timeout, out _);
ataReadLba48 = !sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0; ataReadLba48 = !sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0;
sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, 1, timeout, out duration); sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, 1, timeout, out _);
ataReadDmaLba48 = !sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0; ataReadDmaLba48 = !sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0;
sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out _);
ataSeek = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0; ataSeek = !sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0;
sense = dev.Seek(out errorLba, 0, timeout, out duration); sense = dev.Seek(out errorLba, 0, timeout, out _);
ataSeekLba = !sense && (errorLba.status & 0x27) == 0 && errorChs.error == 0; ataSeekLba = !sense && (errorLba.status & 0x27) == 0 && errorChs.error == 0;
if(IsLba) if(IsLba)
@@ -217,44 +210,46 @@ namespace DiscImageChef.Core.Devices
return false; return false;
} }
byte[] cmdBuf;
bool sense;
AtaErrorRegistersLBA28 errorLba;
AtaErrorRegistersLBA48 errorLba48;
double duration;
bool error = true; bool error = true;
while(IsLba) while(IsLba)
{ {
byte[] cmdBuf;
bool sense;
AtaErrorRegistersLBA48 errorLba48;
if(ataReadDmaLba48) if(ataReadDmaLba48)
{ {
sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, (byte)BlocksToRead, timeout, out duration); sense = dev.ReadDma(out cmdBuf, out errorLba48, 0, (byte)BlocksToRead, timeout, out _);
error = !(!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0); error = !(!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0);
} }
else if(ataReadLba48) else if(ataReadLba48)
{ {
sense = dev.Read(out cmdBuf, out errorLba48, 0, (byte)BlocksToRead, timeout, out duration); sense = dev.Read(out cmdBuf, out errorLba48, 0, (byte)BlocksToRead, timeout, out _);
error = !(!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0); error = !(!sense && (errorLba48.status & 0x27) == 0 && errorLba48.error == 0 && cmdBuf.Length > 0);
} }
else if(ataReadDmaRetryLba) else
{ {
sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, (byte)BlocksToRead, timeout, out duration); AtaErrorRegistersLBA28 errorLba;
error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); if(ataReadDmaRetryLba)
} {
else if(ataReadDmaLba) sense = dev.ReadDma(out cmdBuf, out errorLba, true, 0, (byte)BlocksToRead, timeout, out _);
{ error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0);
sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, (byte)BlocksToRead, timeout, out duration); }
error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); else if(ataReadDmaLba)
} {
else if(ataReadRetryLba) sense = dev.ReadDma(out cmdBuf, out errorLba, false, 0, (byte)BlocksToRead, timeout, out _);
{ error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0);
sense = dev.Read(out cmdBuf, out errorLba, true, 0, (byte)BlocksToRead, timeout, out duration); }
error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); else if(ataReadRetryLba)
} {
else if(ataReadLba) sense = dev.Read(out cmdBuf, out errorLba, true, 0, (byte)BlocksToRead, timeout, out _);
{ error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0);
sense = dev.Read(out cmdBuf, out errorLba, false, 0, (byte)BlocksToRead, timeout, out duration); }
error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0); else if(ataReadLba)
{
sense = dev.Read(out cmdBuf, out errorLba, false, 0, (byte)BlocksToRead, timeout, out _);
error = !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0 && cmdBuf.Length > 0);
}
} }
if(error) BlocksToRead /= 2; if(error) BlocksToRead /= 2;
@@ -372,17 +367,13 @@ namespace DiscImageChef.Core.Devices
bool AtaSeek(ulong block, out double duration) bool AtaSeek(ulong block, out double duration)
{ {
AtaErrorRegistersLBA28 errorLba; bool sense = dev.Seek(out AtaErrorRegistersLBA28 errorLba, (uint)block, timeout, out duration);
bool sense = dev.Seek(out errorLba, (uint)block, timeout, out duration);
return !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0); return !(!sense && (errorLba.status & 0x27) == 0 && errorLba.error == 0);
} }
bool AtaSeekChs(ushort cylinder, byte head, byte sector, out double duration) bool AtaSeekChs(ushort cylinder, byte head, byte sector, out double duration)
{ {
AtaErrorRegistersCHS errorChs; bool sense = dev.Seek(out AtaErrorRegistersCHS errorChs, cylinder, head, sector, timeout, out duration);
bool sense = dev.Seek(out errorChs, cylinder, head, sector, timeout, out duration);
return !(!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0); return !(!sense && (errorChs.status & 0x27) == 0 && errorChs.error == 0);
} }
} }

View File

@@ -60,24 +60,20 @@ namespace DiscImageChef.Core.Devices
bool ScsiFindReadCommand() bool ScsiFindReadCommand()
{ {
byte[] readBuffer; read6 = !dev.Read6(out _, out byte[] senseBuf, 0, LogicalBlockSize, timeout, out _);
byte[] senseBuf;
double duration;
read6 = !dev.Read6(out readBuffer, out senseBuf, 0, LogicalBlockSize, timeout, out duration); read10 = !dev.Read10(out _, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, 1,
timeout, out _);
read10 = !dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, 1, read12 = !dev.Read12(out _, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, 1, false,
timeout, out duration); timeout, out _);
read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, 1, false, read16 = !dev.Read16(out _, out senseBuf, 0, false, true, false, 0, LogicalBlockSize, 0, 1, false,
timeout, out duration); timeout, out _);
read16 = !dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, LogicalBlockSize, 0, 1, false, seek6 = !dev.Seek6(out senseBuf, 0, timeout, out _);
timeout, out duration);
seek6 = !dev.Seek6(out senseBuf, 0, timeout, out duration); seek10 = !dev.Seek10(out senseBuf, 0, timeout, out _);
seek10 = !dev.Seek10(out senseBuf, 0, timeout, out duration);
if(!read6 && !read10 && !read12 && !read16) if(!read6 && !read10 && !read12 && !read16)
{ {
@@ -102,7 +98,6 @@ namespace DiscImageChef.Core.Devices
if(CanReadRaw) if(CanReadRaw)
{ {
bool testSense; bool testSense;
FixedSense? decSense;
CanReadRaw = false; CanReadRaw = false;
if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice) if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice)
@@ -126,8 +121,9 @@ namespace DiscImageChef.Core.Devices
} }
}*/ }*/
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, 0xFFFF, timeout, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, 0xFFFF, timeout,
out duration); out _);
FixedSense? decSense;
if(testSense && !dev.Error) if(testSense && !dev.Error)
{ {
decSense = Sense.DecodeFixed(senseBuf); decSense = Sense.DecodeFixed(senseBuf);
@@ -139,8 +135,8 @@ namespace DiscImageChef.Core.Devices
if(decSense.Value.InformationValid && decSense.Value.ILI) if(decSense.Value.InformationValid && decSense.Value.ILI)
{ {
LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
readLong10 = !dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, readLong10 = !dev.ReadLong10(out _, out senseBuf, false, false, 0,
(ushort)LongBlockSize, timeout, out duration); (ushort)LongBlockSize, timeout, out _);
} }
} }
} }
@@ -157,8 +153,8 @@ namespace DiscImageChef.Core.Devices
600, 610, 630 600, 610, 630
}) })
{ {
testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, testSize, timeout, testSense = dev.ReadLong16(out _, out senseBuf, false, 0, testSize, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong16 = true; readLong16 = true;
@@ -167,8 +163,8 @@ namespace DiscImageChef.Core.Devices
break; break;
} }
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, testSize, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize,
timeout, out duration); timeout, out _);
if(testSense || dev.Error) continue; if(testSense || dev.Error) continue;
readLong10 = true; readLong10 = true;
@@ -185,8 +181,8 @@ namespace DiscImageChef.Core.Devices
1200 1200
}) })
{ {
testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, testSize, timeout, testSense = dev.ReadLong16(out _, out senseBuf, false, 0, testSize, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong16 = true; readLong16 = true;
@@ -195,8 +191,8 @@ namespace DiscImageChef.Core.Devices
break; break;
} }
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, testSize, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize,
timeout, out duration); timeout, out _);
if(testSense || dev.Error) continue; if(testSense || dev.Error) continue;
readLong10 = true; readLong10 = true;
@@ -206,8 +202,8 @@ namespace DiscImageChef.Core.Devices
} }
else if(LogicalBlockSize == 2048) else if(LogicalBlockSize == 2048)
{ {
testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 2380, timeout, testSense = dev.ReadLong16(out _, out senseBuf, false, 0, 2380, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong16 = true; readLong16 = true;
@@ -216,8 +212,8 @@ namespace DiscImageChef.Core.Devices
} }
else else
{ {
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, 2380, timeout, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, 2380, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong10 = true; readLong10 = true;
@@ -228,8 +224,8 @@ namespace DiscImageChef.Core.Devices
} }
else if(LogicalBlockSize == 4096) else if(LogicalBlockSize == 4096)
{ {
testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 4760, timeout, testSense = dev.ReadLong16(out _, out senseBuf, false, 0, 4760, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong16 = true; readLong16 = true;
@@ -238,8 +234,8 @@ namespace DiscImageChef.Core.Devices
} }
else else
{ {
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, 4760, timeout, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, 4760, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong10 = true; readLong10 = true;
@@ -250,8 +246,8 @@ namespace DiscImageChef.Core.Devices
} }
else if(LogicalBlockSize == 8192) else if(LogicalBlockSize == 8192)
{ {
testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 9424, timeout, testSense = dev.ReadLong16(out _, out senseBuf, false, 0, 9424, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong16 = true; readLong16 = true;
@@ -260,8 +256,8 @@ namespace DiscImageChef.Core.Devices
} }
else else
{ {
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, 9424, timeout, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, 9424, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLong10 = true; readLong10 = true;
@@ -273,8 +269,8 @@ namespace DiscImageChef.Core.Devices
if(!CanReadRaw && dev.Manufacturer == "SYQUEST") if(!CanReadRaw && dev.Manufacturer == "SYQUEST")
{ {
testSense = dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, 0xFFFF, timeout, testSense = dev.SyQuestReadLong10(out _, out senseBuf, 0, 0xFFFF, timeout,
out duration); out _);
if(testSense) if(testSense)
{ {
decSense = Sense.DecodeFixed(senseBuf); decSense = Sense.DecodeFixed(senseBuf);
@@ -287,14 +283,14 @@ namespace DiscImageChef.Core.Devices
{ {
LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
syqReadLong10 = syqReadLong10 =
!dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, LongBlockSize, !dev.SyQuestReadLong10(out _, out senseBuf, 0, LongBlockSize,
timeout, out duration); timeout, out _);
} }
} }
else else
{ {
testSense = dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, 0xFFFF, timeout, testSense = dev.SyQuestReadLong6(out _, out senseBuf, 0, 0xFFFF, timeout,
out duration); out _);
if(testSense) if(testSense)
{ {
decSense = Sense.DecodeFixed(senseBuf); decSense = Sense.DecodeFixed(senseBuf);
@@ -307,8 +303,8 @@ namespace DiscImageChef.Core.Devices
{ {
LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
syqReadLong6 = syqReadLong6 =
!dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, !dev.SyQuestReadLong6(out _, out senseBuf, 0,
LongBlockSize, timeout, out duration); LongBlockSize, timeout, out _);
} }
} }
} }
@@ -317,8 +313,8 @@ namespace DiscImageChef.Core.Devices
if(!CanReadRaw && LogicalBlockSize == 256) if(!CanReadRaw && LogicalBlockSize == 256)
{ {
testSense = dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, 262, timeout, testSense = dev.SyQuestReadLong6(out _, out senseBuf, 0, 262, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
syqReadLong6 = true; syqReadLong6 = true;
@@ -333,11 +329,11 @@ namespace DiscImageChef.Core.Devices
switch(dev.Manufacturer) { switch(dev.Manufacturer) {
case "HL-DT-ST": case "HL-DT-ST":
hldtstReadRaw = hldtstReadRaw =
!dev.HlDtStReadRawDvd(out readBuffer, out senseBuf, 0, 1, timeout, out duration); !dev.HlDtStReadRawDvd(out _, out senseBuf, 0, 1, timeout, out _);
break; break;
case "PLEXTOR": case "PLEXTOR":
plextorReadRaw = plextorReadRaw =
!dev.PlextorReadRawDvd(out readBuffer, out senseBuf, 0, 1, timeout, out duration); !dev.PlextorReadRawDvd(out _, out senseBuf, 0, 1, timeout, out _);
break; break;
} }
@@ -350,8 +346,8 @@ namespace DiscImageChef.Core.Devices
// READ LONG (10) for some DVD drives // READ LONG (10) for some DVD drives
if(!CanReadRaw && dev.Manufacturer == "MATSHITA") if(!CanReadRaw && dev.Manufacturer == "MATSHITA")
{ {
testSense = dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, 37856, timeout, testSense = dev.ReadLong10(out _, out senseBuf, false, false, 0, 37856, timeout,
out duration); out _);
if(!testSense && !dev.Error) if(!testSense && !dev.Error)
{ {
readLongDvd = true; readLongDvd = true;
@@ -382,12 +378,9 @@ namespace DiscImageChef.Core.Devices
bool ScsiGetBlockSize() bool ScsiGetBlockSize()
{ {
bool sense; bool sense;
byte[] cmdBuf;
byte[] senseBuf;
double duration;
Blocks = 0; Blocks = 0;
sense = dev.ReadCapacity(out cmdBuf, out senseBuf, timeout, out duration); sense = dev.ReadCapacity(out byte[] cmdBuf, out byte[] senseBuf, timeout, out _);
if(!sense) if(!sense)
{ {
Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]); Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]);
@@ -396,7 +389,7 @@ namespace DiscImageChef.Core.Devices
if(sense || Blocks == 0xFFFFFFFF) if(sense || Blocks == 0xFFFFFFFF)
{ {
sense = dev.ReadCapacity16(out cmdBuf, out senseBuf, timeout, out duration); sense = dev.ReadCapacity16(out cmdBuf, out senseBuf, timeout, out _);
if(sense && Blocks == 0) if(sense && Blocks == 0)
if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice) if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice)
@@ -424,35 +417,32 @@ namespace DiscImageChef.Core.Devices
bool ScsiGetBlocksToRead(uint startWithBlocks) bool ScsiGetBlocksToRead(uint startWithBlocks)
{ {
byte[] readBuffer;
byte[] senseBuf;
double duration;
BlocksToRead = startWithBlocks; BlocksToRead = startWithBlocks;
while(true) while(true)
{ {
if(read16) if(read16)
{ {
dev.Read16(out readBuffer, out senseBuf, 0, false, true, false, 0, LogicalBlockSize, 0, dev.Read16(out _, out _, 0, false, true, false, 0, LogicalBlockSize, 0,
BlocksToRead, false, timeout, out duration); BlocksToRead, false, timeout, out _);
if(dev.Error) BlocksToRead /= 2; if(dev.Error) BlocksToRead /= 2;
} }
else if(read12) else if(read12)
{ {
dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, LogicalBlockSize, 0, dev.Read12(out _, out _, 0, false, false, false, false, 0, LogicalBlockSize, 0,
BlocksToRead, false, timeout, out duration); BlocksToRead, false, timeout, out _);
if(dev.Error) BlocksToRead /= 2; if(dev.Error) BlocksToRead /= 2;
} }
else if(read10) else if(read10)
{ {
dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, 0, LogicalBlockSize, 0, dev.Read10(out _, out _, 0, false, true, false, false, 0, LogicalBlockSize, 0,
(ushort)BlocksToRead, timeout, out duration); (ushort)BlocksToRead, timeout, out _);
if(dev.Error) BlocksToRead /= 2; if(dev.Error) BlocksToRead /= 2;
} }
else if(read6) else if(read6)
{ {
dev.Read6(out readBuffer, out senseBuf, 0, LogicalBlockSize, (byte)BlocksToRead, timeout, dev.Read6(out _, out _, 0, LogicalBlockSize, (byte)BlocksToRead, timeout,
out duration); out _);
if(dev.Error) BlocksToRead /= 2; if(dev.Error) BlocksToRead /= 2;
} }
@@ -468,8 +458,8 @@ namespace DiscImageChef.Core.Devices
bool ScsiReadBlocks(out byte[] buffer, ulong block, uint count, out double duration) bool ScsiReadBlocks(out byte[] buffer, ulong block, uint count, out double duration)
{ {
bool sense = false; bool sense;
byte[] senseBuf = null; byte[] senseBuf;
buffer = null; buffer = null;
duration = 0; duration = 0;
@@ -519,12 +509,11 @@ namespace DiscImageChef.Core.Devices
bool ScsiSeek(ulong block, out double duration) bool ScsiSeek(ulong block, out double duration)
{ {
byte[] senseBuf;
bool sense = true; bool sense = true;
duration = 0; duration = 0;
if(seek6) sense = dev.Seek6(out senseBuf, (uint)block, timeout, out duration); if(seek6) sense = dev.Seek6(out _, (uint)block, timeout, out duration);
else if(seek10) sense = dev.Seek10(out senseBuf, (uint)block, timeout, out duration); else if(seek10) sense = dev.Seek10(out _, (uint)block, timeout, out duration);
return sense; return sense;
} }

View File

@@ -45,21 +45,17 @@ namespace DiscImageChef.Core.Devices.Report
{ {
if(report == null) return; if(report == null) return;
AtaErrorRegistersCHS errorRegs; const uint TIMEOUT = 5;
byte[] buffer;
double duration;
uint timeout = 5;
ConsoleKeyInfo pressedKey;
if(dev.IsUsb) Usb.Report(dev, ref report, debug, ref removable); if(dev.IsUsb) Usb.Report(dev, ref report, debug, ref removable);
if(dev.IsFireWire) FireWire.Report(dev, ref report, debug, ref removable); if(dev.IsFireWire) FireWire.Report(dev, ref report, ref removable);
if(dev.IsPcmcia) Pcmcia.Report(dev, ref report, debug, ref removable); if(dev.IsPcmcia) Pcmcia.Report(dev, ref report);
DicConsole.WriteLine("Querying ATA IDENTIFY..."); DicConsole.WriteLine("Querying ATA IDENTIFY...");
dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration); dev.AtaIdentify(out byte[] buffer, out _, TIMEOUT, out _);
if(!Identify.Decode(buffer).HasValue) return; if(!Identify.Decode(buffer).HasValue) return;
@@ -67,6 +63,7 @@ namespace DiscImageChef.Core.Devices.Report
if(ataIdNullable != null) { if(ataIdNullable != null) {
Identify.IdentifyDevice ataId = ataIdNullable.Value; Identify.IdentifyDevice ataId = ataIdNullable.Value;
ConsoleKeyInfo pressedKey;
if((ushort)ataId.GeneralConfiguration == 0x848A) if((ushort)ataId.GeneralConfiguration == 0x848A)
{ {
report.CompactFlash = true; report.CompactFlash = true;
@@ -92,7 +89,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Please remove any media from the device and press any key when it is out."); DicConsole.WriteLine("Please remove any media from the device and press any key when it is out.");
System.Console.ReadKey(true); System.Console.ReadKey(true);
DicConsole.WriteLine("Querying ATA IDENTIFY..."); DicConsole.WriteLine("Querying ATA IDENTIFY...");
dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration); dev.AtaIdentify(out buffer, out _, TIMEOUT, out _);
ataId = Identify.Decode(buffer).Value; ataId = Identify.Decode(buffer).Value;
} }
@@ -521,7 +518,7 @@ namespace DiscImageChef.Core.Devices.Report
mediaTest.MediaIsRecognized = true; mediaTest.MediaIsRecognized = true;
DicConsole.WriteLine("Querying ATA IDENTIFY..."); DicConsole.WriteLine("Querying ATA IDENTIFY...");
dev.AtaIdentify(out buffer, out errorRegs, timeout, out duration); dev.AtaIdentify(out buffer, out _, TIMEOUT, out _);
if(Identify.Decode(buffer).HasValue) if(Identify.Decode(buffer).HasValue)
{ {
@@ -540,10 +537,12 @@ namespace DiscImageChef.Core.Devices.Report
if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0) if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
{ {
mediaTest.CHS = new chsType(); mediaTest.CHS = new chsType
mediaTest.CHS.Cylinders = ataId.Cylinders; {
mediaTest.CHS.Heads = ataId.Heads; Cylinders = ataId.Cylinders,
mediaTest.CHS.Sectors = ataId.SectorsPerTrack; Heads = ataId.Heads,
Sectors = ataId.SectorsPerTrack
};
mediaTest.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack); mediaTest.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
mediaTest.BlocksSpecified = true; mediaTest.BlocksSpecified = true;
} }
@@ -551,10 +550,12 @@ namespace DiscImageChef.Core.Devices.Report
if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 &&
ataId.CurrentSectorsPerTrack > 0) ataId.CurrentSectorsPerTrack > 0)
{ {
mediaTest.CurrentCHS = new chsType(); mediaTest.CurrentCHS = new chsType
mediaTest.CurrentCHS.Cylinders = ataId.CurrentCylinders; {
mediaTest.CurrentCHS.Heads = ataId.CurrentHeads; Cylinders = ataId.CurrentCylinders,
mediaTest.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack; Heads = ataId.CurrentHeads,
Sectors = ataId.CurrentSectorsPerTrack
};
if(mediaTest.Blocks == 0) if(mediaTest.Blocks == 0)
mediaTest.Blocks = mediaTest.Blocks =
(ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads *
@@ -676,16 +677,11 @@ namespace DiscImageChef.Core.Devices.Report
mediaTest.SupportsReadLongRetrySpecified = true; mediaTest.SupportsReadLongRetrySpecified = true;
mediaTest.SupportsSeekSpecified = true; mediaTest.SupportsSeekSpecified = true;
AtaErrorRegistersCHS errorChs;
AtaErrorRegistersLBA28 errorLba;
AtaErrorRegistersLBA48 errorLba48;
byte[] readBuf;
ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0); ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
bool sense; bool sense;
DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); sense = dev.Read(out byte[] readBuf, out AtaErrorRegistersCHS errorChs, false, 0, 0, 1, 1, TIMEOUT, out _);
mediaTest.SupportsRead = mediaTest.SupportsRead =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -698,7 +694,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, TIMEOUT, out _);
mediaTest.SupportsReadRetry = mediaTest.SupportsReadRetry =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -711,8 +707,8 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ DMA in CHS mode..."); DicConsole.WriteLine("Trying READ DMA in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, TIMEOUT,
out duration); out _);
mediaTest.SupportsReadDma = mediaTest.SupportsReadDma =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -725,7 +721,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode..."); DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, TIMEOUT, out _);
mediaTest.SupportsReadDmaRetry = mediaTest.SupportsReadDmaRetry =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -738,7 +734,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying SEEK in CHS mode..."); DicConsole.WriteLine("Trying SEEK in CHS mode...");
sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); sense = dev.Seek(out errorChs, 0, 0, 1, TIMEOUT, out _);
mediaTest.SupportsSeek = mediaTest.SupportsSeek =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0; !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -746,7 +742,7 @@ namespace DiscImageChef.Core.Devices.Report
errorChs.status, errorChs.error); errorChs.status, errorChs.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration); sense = dev.Read(out readBuf, out AtaErrorRegistersLBA28 errorLba, false, 0, 1, TIMEOUT, out _);
mediaTest.SupportsReadLba = mediaTest.SupportsReadLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -759,7 +755,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration); sense = dev.Read(out readBuf, out errorLba, true, 0, 1, TIMEOUT, out _);
mediaTest.SupportsReadRetryLba = mediaTest.SupportsReadRetryLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -772,7 +768,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA mode..."); DicConsole.WriteLine("Trying READ DMA in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, TIMEOUT, out _);
mediaTest.SupportsReadDmaLba = mediaTest.SupportsReadDmaLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -785,7 +781,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode..."); DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, TIMEOUT, out _);
mediaTest.SupportsReadDmaRetryLba = mediaTest.SupportsReadDmaRetryLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -798,7 +794,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying SEEK in LBA mode..."); DicConsole.WriteLine("Trying SEEK in LBA mode...");
sense = dev.Seek(out errorLba, 0, timeout, out duration); sense = dev.Seek(out errorLba, 0, TIMEOUT, out _);
mediaTest.SupportsSeekLba = mediaTest.SupportsSeekLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0; !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -806,7 +802,7 @@ namespace DiscImageChef.Core.Devices.Report
errorChs.status, errorChs.error); errorChs.status, errorChs.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration); sense = dev.Read(out readBuf, out AtaErrorRegistersLBA48 errorLba48, 0, 1, TIMEOUT, out _);
mediaTest.SupportsReadLba48 = mediaTest.SupportsReadLba48 =
!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -819,7 +815,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA48 mode..."); DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, TIMEOUT, out _);
mediaTest.SupportsReadDmaLba48 = mediaTest.SupportsReadDmaLba48 =
!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 &&
readBuf.Length > 0; readBuf.Length > 0;
@@ -833,7 +829,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG in CHS mode..."); DicConsole.WriteLine("Trying READ LONG in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize, sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize,
timeout, out duration); TIMEOUT, out _);
mediaTest.SupportsReadLong = mediaTest.SupportsReadLong =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -847,7 +843,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode..."); DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize, sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize,
timeout, out duration); TIMEOUT, out _);
mediaTest.SupportsReadLongRetry = mediaTest.SupportsReadLongRetry =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -861,7 +857,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG in LBA mode..."); DicConsole.WriteLine("Trying READ LONG in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize, sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize,
timeout, out duration); TIMEOUT, out _);
mediaTest.SupportsReadLongLba = mediaTest.SupportsReadLongLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -875,7 +871,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode..."); DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize, sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize,
timeout, out duration); TIMEOUT, out _);
mediaTest.SupportsReadLongRetryLba = mediaTest.SupportsReadLongRetryLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -911,10 +907,12 @@ namespace DiscImageChef.Core.Devices.Report
if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0) if(ataId.Cylinders > 0 && ataId.Heads > 0 && ataId.SectorsPerTrack > 0)
{ {
report.ATA.ReadCapabilities.CHS = new chsType(); report.ATA.ReadCapabilities.CHS = new chsType
report.ATA.ReadCapabilities.CHS.Cylinders = ataId.Cylinders; {
report.ATA.ReadCapabilities.CHS.Heads = ataId.Heads; Cylinders = ataId.Cylinders,
report.ATA.ReadCapabilities.CHS.Sectors = ataId.SectorsPerTrack; Heads = ataId.Heads,
Sectors = ataId.SectorsPerTrack
};
report.ATA.ReadCapabilities.Blocks = report.ATA.ReadCapabilities.Blocks =
(ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack); (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
report.ATA.ReadCapabilities.BlocksSpecified = true; report.ATA.ReadCapabilities.BlocksSpecified = true;
@@ -922,10 +920,12 @@ namespace DiscImageChef.Core.Devices.Report
if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && ataId.CurrentSectorsPerTrack > 0) if(ataId.CurrentCylinders > 0 && ataId.CurrentHeads > 0 && ataId.CurrentSectorsPerTrack > 0)
{ {
report.ATA.ReadCapabilities.CurrentCHS = new chsType(); report.ATA.ReadCapabilities.CurrentCHS = new chsType
report.ATA.ReadCapabilities.CurrentCHS.Cylinders = ataId.CurrentCylinders; {
report.ATA.ReadCapabilities.CurrentCHS.Heads = ataId.CurrentHeads; Cylinders = ataId.CurrentCylinders,
report.ATA.ReadCapabilities.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack; Heads = ataId.CurrentHeads,
Sectors = ataId.CurrentSectorsPerTrack
};
report.ATA.ReadCapabilities.Blocks = report.ATA.ReadCapabilities.Blocks =
(ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack); (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack);
report.ATA.ReadCapabilities.BlocksSpecified = true; report.ATA.ReadCapabilities.BlocksSpecified = true;
@@ -1044,16 +1044,11 @@ namespace DiscImageChef.Core.Devices.Report
report.ATA.ReadCapabilities.SupportsReadLongRetrySpecified = true; report.ATA.ReadCapabilities.SupportsReadLongRetrySpecified = true;
report.ATA.ReadCapabilities.SupportsSeekSpecified = true; report.ATA.ReadCapabilities.SupportsSeekSpecified = true;
AtaErrorRegistersCHS errorChs;
AtaErrorRegistersLBA28 errorLba;
AtaErrorRegistersLBA48 errorLba48;
byte[] readBuf;
ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0); ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
bool sense; bool sense;
DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); sense = dev.Read(out byte[] readBuf, out AtaErrorRegistersCHS errorChs, false, 0, 0, 1, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsRead = report.ATA.ReadCapabilities.SupportsRead =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1064,7 +1059,7 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode...");
sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadRetry = report.ATA.ReadCapabilities.SupportsReadRetry =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1075,7 +1070,7 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying READ DMA in CHS mode..."); DicConsole.WriteLine("Trying READ DMA in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadDma = report.ATA.ReadCapabilities.SupportsReadDma =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1086,7 +1081,7 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode..."); DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode...");
sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadDmaRetry = report.ATA.ReadCapabilities.SupportsReadDmaRetry =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0; !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1097,14 +1092,14 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying SEEK in CHS mode..."); DicConsole.WriteLine("Trying SEEK in CHS mode...");
sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); sense = dev.Seek(out errorChs, 0, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsSeek = report.ATA.ReadCapabilities.SupportsSeek =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0; !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0;
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense, DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
errorChs.status, errorChs.error); errorChs.status, errorChs.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, false, 0, 1, timeout, out duration); sense = dev.Read(out readBuf, out AtaErrorRegistersLBA28 errorLba, false, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadLba = report.ATA.ReadCapabilities.SupportsReadLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1115,7 +1110,7 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode...");
sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration); sense = dev.Read(out readBuf, out errorLba, true, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadRetryLba = report.ATA.ReadCapabilities.SupportsReadRetryLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1126,7 +1121,7 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA mode..."); DicConsole.WriteLine("Trying READ DMA in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadDmaLba = report.ATA.ReadCapabilities.SupportsReadDmaLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1137,7 +1132,7 @@ namespace DiscImageChef.Core.Devices.Report
readBuf); readBuf);
DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode..."); DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode...");
sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadDmaRetryLba = report.ATA.ReadCapabilities.SupportsReadDmaRetryLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0; !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1148,14 +1143,14 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying SEEK in LBA mode..."); DicConsole.WriteLine("Trying SEEK in LBA mode...");
sense = dev.Seek(out errorLba, 0, timeout, out duration); sense = dev.Seek(out errorLba, 0, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsSeekLba = report.ATA.ReadCapabilities.SupportsSeekLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0; !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0;
DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense, DicConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
errorLba.status, errorLba.error); errorLba.status, errorLba.error);
DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode..."); DicConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
sense = dev.Read(out readBuf, out errorLba48, 0, 1, timeout, out duration); sense = dev.Read(out readBuf, out AtaErrorRegistersLBA48 errorLba48, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadLba48 = report.ATA.ReadCapabilities.SupportsReadLba48 =
!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0; !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1166,7 +1161,7 @@ namespace DiscImageChef.Core.Devices.Report
"read results", readBuf); "read results", readBuf);
DicConsole.WriteLine("Trying READ DMA in LBA48 mode..."); DicConsole.WriteLine("Trying READ DMA in LBA48 mode...");
sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration); sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadDmaLba48 = report.ATA.ReadCapabilities.SupportsReadDmaLba48 =
!sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0; !sense && (errorLba48.status & 0x01) != 0x01 && errorLba48.error == 0 && readBuf.Length > 0;
DicConsole.DebugWriteLine("ATA Report", DicConsole.DebugWriteLine("ATA Report",
@@ -1178,7 +1173,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG in CHS mode..."); DicConsole.WriteLine("Trying READ LONG in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1,
report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration); report.ATA.ReadCapabilities.LongBlockSize, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadLong = report.ATA.ReadCapabilities.SupportsReadLong =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -1191,7 +1186,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode..."); DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode...");
sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1,
report.ATA.ReadCapabilities.LongBlockSize, timeout, out duration); report.ATA.ReadCapabilities.LongBlockSize, TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadLongRetry = report.ATA.ReadCapabilities.SupportsReadLongRetry =
!sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 && !sense && (errorChs.status & 0x01) != 0x01 && errorChs.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -1204,7 +1199,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG in LBA mode..."); DicConsole.WriteLine("Trying READ LONG in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize, sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize,
timeout, out duration); TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadLongLba = report.ATA.ReadCapabilities.SupportsReadLongLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
@@ -1217,7 +1212,7 @@ namespace DiscImageChef.Core.Devices.Report
DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode..."); DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode...");
sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize, sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize,
timeout, out duration); TIMEOUT, out _);
report.ATA.ReadCapabilities.SupportsReadLongRetryLba = report.ATA.ReadCapabilities.SupportsReadLongRetryLba =
!sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 && !sense && (errorLba.status & 0x01) != 0x01 && errorLba.error == 0 && readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;

View File

@@ -43,14 +43,11 @@ namespace DiscImageChef.Core.Devices.Report
{ {
if(report == null) return; if(report == null) return;
byte[] buffer; const uint TIMEOUT = 5;
double duration;
uint timeout = 5;
DicConsole.WriteLine("Querying ATAPI IDENTIFY..."); DicConsole.WriteLine("Querying ATAPI IDENTIFY...");
AtaErrorRegistersCHS errorRegs; dev.AtapiIdentify(out byte[] buffer, out _, TIMEOUT, out _);
dev.AtapiIdentify(out buffer, out errorRegs, timeout, out duration);
if(!Identify.Decode(buffer).HasValue) return; if(!Identify.Decode(buffer).HasValue) return;

View File

@@ -39,7 +39,7 @@ namespace DiscImageChef.Core.Devices.Report
{ {
static class FireWire static class FireWire
{ {
internal static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable) internal static void Report(Device dev, ref DeviceReport report, ref bool removable)
{ {
if(report == null) return; if(report == null) return;
@@ -53,11 +53,13 @@ namespace DiscImageChef.Core.Devices.Report
if(pressedKey.Key != ConsoleKey.Y) return; if(pressedKey.Key != ConsoleKey.Y) return;
report.FireWire = new firewireType(); report.FireWire = new firewireType
report.FireWire.Manufacturer = dev.FireWireVendorName; {
report.FireWire.Product = dev.FireWireModelName; Manufacturer = dev.FireWireVendorName,
report.FireWire.ProductID = dev.FireWireModel; Product = dev.FireWireModelName,
report.FireWire.VendorID = dev.FireWireVendor; ProductID = dev.FireWireModel,
VendorID = dev.FireWireVendor
};
pressedKey = new ConsoleKeyInfo(); pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)

View File

@@ -38,10 +38,9 @@ namespace DiscImageChef.Core.Devices.Report
{ {
static class Pcmcia static class Pcmcia
{ {
internal static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable) internal static void Report(Device dev, ref DeviceReport report)
{ {
report.PCMCIA = new pcmciaType(); report.PCMCIA = new pcmciaType {CIS = dev.Cis};
report.PCMCIA.CIS = dev.Cis;
Tuple[] tuples = CIS.GetTuples(dev.Cis); Tuple[] tuples = CIS.GetTuples(dev.Cis);
if(tuples == null) return; if(tuples == null) return;

View File

@@ -48,18 +48,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
if(report == null) return; if(report == null) return;
byte[] senseBuffer;
byte[] buffer;
double duration;
bool sense; bool sense;
uint timeout = 5; const uint TIMEOUT = 5;
ConsoleKeyInfo pressedKey; ConsoleKeyInfo pressedKey;
if(dev.IsUsb) Usb.Report(dev, ref report, debug, ref removable); if(dev.IsUsb) Usb.Report(dev, ref report, debug, ref removable);
if(dev.IsFireWire) FireWire.Report(dev, ref report, debug, ref removable); if(dev.IsFireWire) FireWire.Report(dev, ref report, ref removable);
if(dev.IsPcmcia) Pcmcia.Report(dev, ref report, debug, ref removable); if(dev.IsPcmcia) Pcmcia.Report(dev, ref report);
if(!dev.IsUsb && !dev.IsFireWire && dev.IsRemovable) if(!dev.IsUsb && !dev.IsFireWire && dev.IsRemovable)
{ {
@@ -77,7 +74,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(dev.Type == DeviceType.ATAPI) Atapi.Report(dev, ref report, debug, ref removable); if(dev.Type == DeviceType.ATAPI) Atapi.Report(dev, ref report, debug, ref removable);
DicConsole.WriteLine("Querying SCSI INQUIRY..."); DicConsole.WriteLine("Querying SCSI INQUIRY...");
sense = dev.ScsiInquiry(out buffer, out senseBuffer); sense = dev.ScsiInquiry(out byte[] buffer, out byte[] senseBuffer);
report.SCSI = new scsiType(); report.SCSI = new scsiType();
@@ -192,9 +189,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
sense = dev.ScsiInquiry(out buffer, out senseBuffer, page); sense = dev.ScsiInquiry(out buffer, out senseBuffer, page);
if(sense) continue; if(sense) continue;
pageType evpd = new pageType(); pageType evpd = new pageType {page = page, value = buffer};
evpd.page = page;
evpd.value = buffer;
evpds.Add(evpd); evpds.Add(evpd);
} }
@@ -206,15 +201,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
switch(dev.ScsiType) { switch(dev.ScsiType) {
case PeripheralDeviceTypes.MultiMediaDevice: case PeripheralDeviceTypes.MultiMediaDevice:
dev.AllowMediumRemoval(out senseBuffer, timeout, out duration); dev.AllowMediumRemoval(out senseBuffer, TIMEOUT, out _);
dev.EjectTray(out senseBuffer, timeout, out duration); dev.EjectTray(out senseBuffer, TIMEOUT, out _);
break; break;
case PeripheralDeviceTypes.SequentialAccess: case PeripheralDeviceTypes.SequentialAccess:
dev.SpcAllowMediumRemoval(out senseBuffer, timeout, out duration); dev.SpcAllowMediumRemoval(out senseBuffer, TIMEOUT, out _);
DicConsole.WriteLine("Asking drive to unload tape (can take a few minutes)..."); DicConsole.WriteLine("Asking drive to unload tape (can take a few minutes)...");
dev.Unload(out senseBuffer, timeout, out duration); dev.Unload(out senseBuffer, TIMEOUT, out _);
break; break;
} }
DicConsole.WriteLine("Please remove any media from the device and press any key when it is out."); DicConsole.WriteLine("Please remove any media from the device and press any key when it is out.");
System.Console.ReadKey(true); System.Console.ReadKey(true);
} }
@@ -224,12 +220,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (10)..."); DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out byte[] mode10Buffer, out senseBuffer, false, true, sense = dev.ModeSense10(out byte[] mode10Buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Default, 0x3F, 0xFF, timeout, out duration); ScsiModeSensePageControl.Default, 0x3F, 0xFF, TIMEOUT, out _);
if(sense || dev.Error) if(sense || dev.Error)
{ {
DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (10)..."); DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out mode10Buffer, out senseBuffer, false, true, sense = dev.ModeSense10(out mode10Buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration); ScsiModeSensePageControl.Default, 0x3F, 0x00, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense10 = true; report.SCSI.SupportsModeSense10 = true;
@@ -246,16 +242,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (6)..."); DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (6)...");
sense = dev.ModeSense6(out byte[] mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, sense = dev.ModeSense6(out byte[] mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default,
0x3F, 0xFF, timeout, out duration); 0x3F, 0xFF, TIMEOUT, out _);
if(sense || dev.Error) if(sense || dev.Error)
{ {
DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (6)..."); DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (6)...");
sense = dev.ModeSense6(out mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F, sense = dev.ModeSense6(out mode6Buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F,
0x00, timeout, out duration); 0x00, TIMEOUT, out _);
if(sense || dev.Error) if(sense || dev.Error)
{ {
DicConsole.WriteLine("Querying SCSI MODE SENSE (6)..."); DicConsole.WriteLine("Querying SCSI MODE SENSE (6)...");
sense = dev.ModeSense(out mode6Buffer, out senseBuffer, timeout, out duration); sense = dev.ModeSense(out mode6Buffer, out senseBuffer, TIMEOUT, out _);
} }
} }
else report.SCSI.SupportsModeSubpages = true; else report.SCSI.SupportsModeSubpages = true;
@@ -272,10 +268,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(decMode.HasValue) if(decMode.HasValue)
{ {
report.SCSI.ModeSense = new modeType(); report.SCSI.ModeSense = new modeType
report.SCSI.ModeSense.BlankCheckEnabled = decMode.Value.Header.EBC; {
report.SCSI.ModeSense.DPOandFUA = decMode.Value.Header.DPOFUA; BlankCheckEnabled = decMode.Value.Header.EBC,
report.SCSI.ModeSense.WriteProtected = decMode.Value.Header.WriteProtected; DPOandFUA = decMode.Value.Header.DPOFUA,
WriteProtected = decMode.Value.Header.WriteProtected
};
if(decMode.Value.Header.BufferedMode > 0) if(decMode.Value.Header.BufferedMode > 0)
{ {
@@ -294,10 +292,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
List<modePageType> modePages = new List<modePageType>(); List<modePageType> modePages = new List<modePageType>();
foreach(Modes.ModePage page in decMode.Value.Pages) foreach(Modes.ModePage page in decMode.Value.Pages)
{ {
modePageType modePage = new modePageType(); modePageType modePage = new modePageType
modePage.page = page.Page; {
modePage.subpage = page.Subpage; page = page.Page,
modePage.value = page.PageResponse; subpage = page.Subpage,
value = page.PageResponse
};
modePages.Add(modePage); modePages.Add(modePage);
if(modePage.page == 0x2A && modePage.subpage == 0x00) cdromMode = Modes.DecodeModePage_2A(page.PageResponse); if(modePage.page == 0x2A && modePage.subpage == 0x00) cdromMode = Modes.DecodeModePage_2A(page.PageResponse);
@@ -347,7 +347,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.ModelSpecified = true; mediaTest.ModelSpecified = true;
mediaTest.MediaIsRecognized = true; mediaTest.MediaIsRecognized = true;
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(sense) if(sense)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuffer); FixedSense? decSense = Sense.DecodeFixed(senseBuffer);
@@ -359,7 +359,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -374,7 +374,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -392,7 +392,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsReadCapacity16Specified = true; mediaTest.SupportsReadCapacity16Specified = true;
DicConsole.WriteLine("Querying SCSI READ CAPACITY..."); DicConsole.WriteLine("Querying SCSI READ CAPACITY...");
sense = dev.ReadCapacity(out buffer, out senseBuffer, timeout, out duration); sense = dev.ReadCapacity(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadCapacity = true; mediaTest.SupportsReadCapacity = true;
@@ -406,7 +406,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)..."); DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)...");
sense = dev.ReadCapacity16(out buffer, out buffer, timeout, out duration); sense = dev.ReadCapacity16(out buffer, out buffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadCapacity16 = true; mediaTest.SupportsReadCapacity16 = true;
@@ -425,8 +425,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)..."); DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, ScsiModeSensePageControl.Current, 0x3F, 0x00, TIMEOUT,
out duration); out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense10 = true; report.SCSI.SupportsModeSense10 = true;
@@ -435,7 +435,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI MODE SENSE..."); DicConsole.WriteLine("Querying SCSI MODE SENSE...");
sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration); sense = dev.ModeSense(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense6 = true; report.SCSI.SupportsModeSense6 = true;
@@ -464,7 +464,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (6)..."); DicConsole.WriteLine("Trying SCSI READ (6)...");
mediaTest.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize, mediaTest.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read6", DataFile.WriteTo("SCSI Report", "read6",
@@ -474,7 +474,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (10)..."); DicConsole.WriteLine("Trying SCSI READ (10)...");
mediaTest.SupportsRead10 = mediaTest.SupportsRead10 =
!dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0, !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0,
mediaTest.BlockSize, 0, 1, timeout, out duration); mediaTest.BlockSize, 0, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read10", DataFile.WriteTo("SCSI Report", "read10",
@@ -484,7 +484,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (12)..."); DicConsole.WriteLine("Trying SCSI READ (12)...");
mediaTest.SupportsRead12 = mediaTest.SupportsRead12 =
!dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0, !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0,
mediaTest.BlockSize, 0, 1, false, timeout, out duration); mediaTest.BlockSize, 0, 1, false, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read12", DataFile.WriteTo("SCSI Report", "read12",
@@ -494,7 +494,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (16)..."); DicConsole.WriteLine("Trying SCSI READ (16)...");
mediaTest.SupportsRead16 = mediaTest.SupportsRead16 =
!dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0, !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
mediaTest.BlockSize, 0, 1, false, timeout, out duration); mediaTest.BlockSize, 0, 1, false, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read16", DataFile.WriteTo("SCSI Report", "read16",
@@ -503,8 +503,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.LongBlockSize = mediaTest.BlockSize; mediaTest.LongBlockSize = mediaTest.BlockSize;
DicConsole.WriteLine("Trying SCSI READ LONG (10)..."); DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, TIMEOUT,
out duration); out _);
if(sense && !dev.Error) if(sense && !dev.Error)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuffer); FixedSense? decSense = Sense.DecodeFixed(senseBuffer);
@@ -535,7 +535,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}) })
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
testSize, timeout, out duration); testSize, TIMEOUT, out _);
if(sense || dev.Error) continue; if(sense || dev.Error) continue;
mediaTest.SupportsReadLong = true; mediaTest.SupportsReadLong = true;
@@ -553,7 +553,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
}) })
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
testSize, timeout, out duration); testSize, TIMEOUT, out _);
if(sense || dev.Error) continue; if(sense || dev.Error) continue;
mediaTest.SupportsReadLong = true; mediaTest.SupportsReadLong = true;
@@ -564,7 +564,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
else if(mediaTest.BlockSize == 2048) else if(mediaTest.BlockSize == 2048)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380,
timeout, out duration); TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadLong = true; mediaTest.SupportsReadLong = true;
@@ -575,7 +575,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
else if(mediaTest.BlockSize == 4096) else if(mediaTest.BlockSize == 4096)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760,
timeout, out duration); TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadLong = true; mediaTest.SupportsReadLong = true;
@@ -586,7 +586,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
else if(mediaTest.BlockSize == 8192) else if(mediaTest.BlockSize == 8192)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424,
timeout, out duration); TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadLong = true; mediaTest.SupportsReadLong = true;
@@ -608,11 +608,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(pressedKey.Key == ConsoleKey.Y) if(pressedKey.Key == ConsoleKey.Y)
{ {
for(ushort i = (ushort)mediaTest.BlockSize; true; i++) for(ushort i = (ushort)mediaTest.BlockSize; ; i++)
{ {
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i); DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i,
timeout, out duration); TIMEOUT, out _);
if(!sense) if(!sense)
{ {
mediaTest.LongBlockSize = i; mediaTest.LongBlockSize = i;
@@ -631,7 +631,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.LongBlockSize != mediaTest.BlockSize) mediaTest.LongBlockSize != mediaTest.BlockSize)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
(ushort)mediaTest.LongBlockSize, timeout, out duration); (ushort)mediaTest.LongBlockSize, TIMEOUT, out _);
if(!sense) if(!sense)
DataFile.WriteTo("SCSI Report", "readlong10", DataFile.WriteTo("SCSI Report", "readlong10",
"_debug_" + mediaTest.MediumTypeName + ".bin", "read results", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results",
@@ -641,7 +641,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.CanReadMediaSerialSpecified = true; mediaTest.CanReadMediaSerialSpecified = true;
DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER..."); DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
mediaTest.CanReadMediaSerial = mediaTest.CanReadMediaSerial =
!dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration); !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, TIMEOUT, out _);
} }
mediaTests.Add(mediaTest); mediaTests.Add(mediaTest);
@@ -659,7 +659,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.ReadCapabilities.SupportsReadCapacity16Specified = true; report.SCSI.ReadCapabilities.SupportsReadCapacity16Specified = true;
DicConsole.WriteLine("Querying SCSI READ CAPACITY..."); DicConsole.WriteLine("Querying SCSI READ CAPACITY...");
sense = dev.ReadCapacity(out buffer, out senseBuffer, timeout, out duration); sense = dev.ReadCapacity(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.ReadCapabilities.SupportsReadCapacity = true; report.SCSI.ReadCapabilities.SupportsReadCapacity = true;
@@ -672,7 +672,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)..."); DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)...");
sense = dev.ReadCapacity16(out buffer, out buffer, timeout, out duration); sense = dev.ReadCapacity16(out buffer, out buffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.ReadCapabilities.SupportsReadCapacity16 = true; report.SCSI.ReadCapabilities.SupportsReadCapacity16 = true;
@@ -690,7 +690,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)..."); DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current,
0x3F, 0x00, timeout, out duration); 0x3F, 0x00, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense10 = true; report.SCSI.SupportsModeSense10 = true;
@@ -699,7 +699,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI MODE SENSE..."); DicConsole.WriteLine("Querying SCSI MODE SENSE...");
sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration); sense = dev.ModeSense(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense6 = true; report.SCSI.SupportsModeSense6 = true;
@@ -729,7 +729,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (6)..."); DicConsole.WriteLine("Trying SCSI READ (6)...");
report.SCSI.ReadCapabilities.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0, report.SCSI.ReadCapabilities.SupportsRead = !dev.Read6(out buffer, out senseBuffer, 0,
report.SCSI.ReadCapabilities.BlockSize, report.SCSI.ReadCapabilities.BlockSize,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read6", DataFile.WriteTo("SCSI Report", "read6",
@@ -739,7 +739,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (10)..."); DicConsole.WriteLine("Trying SCSI READ (10)...");
report.SCSI.ReadCapabilities.SupportsRead10 = report.SCSI.ReadCapabilities.SupportsRead10 =
!dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0, !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0,
report.SCSI.ReadCapabilities.BlockSize, 0, 1, timeout, out duration); report.SCSI.ReadCapabilities.BlockSize, 0, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!report.SCSI.ReadCapabilities.SupportsRead10); !report.SCSI.ReadCapabilities.SupportsRead10);
if(debug) if(debug)
@@ -750,7 +750,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (12)..."); DicConsole.WriteLine("Trying SCSI READ (12)...");
report.SCSI.ReadCapabilities.SupportsRead12 = report.SCSI.ReadCapabilities.SupportsRead12 =
!dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0, !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0,
report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, timeout, out duration); report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!report.SCSI.ReadCapabilities.SupportsRead12); !report.SCSI.ReadCapabilities.SupportsRead12);
if(debug) if(debug)
@@ -761,7 +761,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (16)..."); DicConsole.WriteLine("Trying SCSI READ (16)...");
report.SCSI.ReadCapabilities.SupportsRead16 = report.SCSI.ReadCapabilities.SupportsRead16 =
!dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0, !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, timeout, out duration); report.SCSI.ReadCapabilities.BlockSize, 0, 1, false, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!report.SCSI.ReadCapabilities.SupportsRead16); !report.SCSI.ReadCapabilities.SupportsRead16);
if(debug) if(debug)
@@ -771,7 +771,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.ReadCapabilities.LongBlockSize = report.SCSI.ReadCapabilities.BlockSize; report.SCSI.ReadCapabilities.LongBlockSize = report.SCSI.ReadCapabilities.BlockSize;
DicConsole.WriteLine("Trying SCSI READ LONG (10)..."); DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout, out duration); sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, TIMEOUT, out _);
if(sense && !dev.Error) if(sense && !dev.Error)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuffer); FixedSense? decSense = Sense.DecodeFixed(senseBuffer);
@@ -802,8 +802,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
600, 610, 630 600, 610, 630
}) })
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, TIMEOUT,
out duration); out _);
if(sense || dev.Error) continue; if(sense || dev.Error) continue;
report.SCSI.ReadCapabilities.SupportsReadLong = true; report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -820,8 +820,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1200 1200
}) })
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, TIMEOUT,
out duration); out _);
if(sense || dev.Error) continue; if(sense || dev.Error) continue;
report.SCSI.ReadCapabilities.SupportsReadLong = true; report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -831,8 +831,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
else if(report.SCSI.ReadCapabilities.BlockSize == 2048) else if(report.SCSI.ReadCapabilities.BlockSize == 2048)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, TIMEOUT,
out duration); out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.ReadCapabilities.SupportsReadLong = true; report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -842,8 +842,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
else if(report.SCSI.ReadCapabilities.BlockSize == 4096) else if(report.SCSI.ReadCapabilities.BlockSize == 4096)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, TIMEOUT,
out duration); out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.ReadCapabilities.SupportsReadLong = true; report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -853,8 +853,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
else if(report.SCSI.ReadCapabilities.BlockSize == 8192) else if(report.SCSI.ReadCapabilities.BlockSize == 8192)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, TIMEOUT,
out duration); out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.ReadCapabilities.SupportsReadLong = true; report.SCSI.ReadCapabilities.SupportsReadLong = true;
@@ -877,11 +877,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(pressedKey.Key == ConsoleKey.Y) if(pressedKey.Key == ConsoleKey.Y)
{ {
for(ushort i = (ushort)report.SCSI.ReadCapabilities.BlockSize; true; i++) for(ushort i = (ushort)report.SCSI.ReadCapabilities.BlockSize; ; i++)
{ {
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i); DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, TIMEOUT,
out duration); out _);
if(!sense) if(!sense)
{ {
if(debug) if(debug)
@@ -909,8 +909,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.ReadCapabilities.LongBlockSize != report.SCSI.ReadCapabilities.BlockSize) report.SCSI.ReadCapabilities.LongBlockSize != report.SCSI.ReadCapabilities.BlockSize)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
(ushort)report.SCSI.ReadCapabilities.LongBlockSize, timeout, (ushort)report.SCSI.ReadCapabilities.LongBlockSize, TIMEOUT,
out duration); out _);
if(!sense) if(!sense)
DataFile.WriteTo("SCSI Report", "readlong10", DataFile.WriteTo("SCSI Report", "readlong10",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin",

View File

@@ -50,13 +50,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
if(report == null) return; if(report == null) return;
byte[] senseBuffer;
byte[] buffer;
double duration;
bool sense; bool sense;
uint timeout = 5; const uint TIMEOUT = 5;
ConsoleKeyInfo pressedKey;
Modes.DecodedMode? decMode;
report.SCSI.MultiMediaDevice = new mmcType(); report.SCSI.MultiMediaDevice = new mmcType();
@@ -163,7 +158,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying MMC GET CONFIGURATION..."); DicConsole.WriteLine("Querying MMC GET CONFIGURATION...");
sense = dev.GetConfiguration(out buffer, out senseBuffer, timeout, out duration); sense = dev.GetConfiguration(out byte[] buffer, out byte[] senseBuffer, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
@@ -558,35 +553,32 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
Features.Decode_010C(desc.Data); Features.Decode_010C(desc.Data);
if(ftr010C.HasValue) if(ftr010C.HasValue)
{ {
string syear, smonth, sday, shour, sminute, ssecond; byte[] temp = new byte[4];
byte[] temp;
temp = new byte[4];
temp[0] = (byte)((ftr010C.Value.Century & 0xFF00) >> 8); temp[0] = (byte)((ftr010C.Value.Century & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Century & 0xFF); temp[1] = (byte)(ftr010C.Value.Century & 0xFF);
temp[2] = (byte)((ftr010C.Value.Year & 0xFF00) >> 8); temp[2] = (byte)((ftr010C.Value.Year & 0xFF00) >> 8);
temp[3] = (byte)(ftr010C.Value.Year & 0xFF); temp[3] = (byte)(ftr010C.Value.Year & 0xFF);
syear = Encoding.ASCII.GetString(temp); string syear = Encoding.ASCII.GetString(temp);
temp = new byte[2]; temp = new byte[2];
temp[0] = (byte)((ftr010C.Value.Month & 0xFF00) >> 8); temp[0] = (byte)((ftr010C.Value.Month & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Month & 0xFF); temp[1] = (byte)(ftr010C.Value.Month & 0xFF);
smonth = Encoding.ASCII.GetString(temp); string smonth = Encoding.ASCII.GetString(temp);
temp = new byte[2]; temp = new byte[2];
temp[0] = (byte)((ftr010C.Value.Day & 0xFF00) >> 8); temp[0] = (byte)((ftr010C.Value.Day & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Day & 0xFF); temp[1] = (byte)(ftr010C.Value.Day & 0xFF);
sday = Encoding.ASCII.GetString(temp); string sday = Encoding.ASCII.GetString(temp);
temp = new byte[2]; temp = new byte[2];
temp[0] = (byte)((ftr010C.Value.Hour & 0xFF00) >> 8); temp[0] = (byte)((ftr010C.Value.Hour & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Hour & 0xFF); temp[1] = (byte)(ftr010C.Value.Hour & 0xFF);
shour = Encoding.ASCII.GetString(temp); string shour = Encoding.ASCII.GetString(temp);
temp = new byte[2]; temp = new byte[2];
temp[0] = (byte)((ftr010C.Value.Minute & 0xFF00) >> 8); temp[0] = (byte)((ftr010C.Value.Minute & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Minute & 0xFF); temp[1] = (byte)(ftr010C.Value.Minute & 0xFF);
sminute = Encoding.ASCII.GetString(temp); string sminute = Encoding.ASCII.GetString(temp);
temp = new byte[2]; temp = new byte[2];
temp[0] = (byte)((ftr010C.Value.Second & 0xFF00) >> 8); temp[0] = (byte)((ftr010C.Value.Second & 0xFF00) >> 8);
temp[1] = (byte)(ftr010C.Value.Second & 0xFF); temp[1] = (byte)(ftr010C.Value.Second & 0xFF);
ssecond = Encoding.ASCII.GetString(temp); string ssecond = Encoding.ASCII.GetString(temp);
try try
{ {
@@ -598,7 +590,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
report.SCSI.MultiMediaDevice.Features.FirmwareDateSpecified = true; report.SCSI.MultiMediaDevice.Features.FirmwareDateSpecified = true;
} }
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch { } catch { // ignored
}
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
} }
} }
@@ -737,7 +730,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
List<testedMediaType> mediaTests = new List<testedMediaType>(); List<testedMediaType> mediaTests = new List<testedMediaType>();
foreach(string mediaType in mediaTypes) foreach(string mediaType in mediaTypes)
{ {
pressedKey = new ConsoleKeyInfo(); ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{ {
DicConsole.Write("Do you have a {0} disc that you can insert in the drive? (Y/N): ", mediaType); DicConsole.Write("Do you have a {0} disc that you can insert in the drive? (Y/N): ", mediaType);
@@ -747,16 +740,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(pressedKey.Key == ConsoleKey.Y) if(pressedKey.Key == ConsoleKey.Y)
{ {
dev.AllowMediumRemoval(out senseBuffer, timeout, out duration); dev.AllowMediumRemoval(out senseBuffer, TIMEOUT, out _);
dev.EjectTray(out senseBuffer, timeout, out duration); dev.EjectTray(out senseBuffer, TIMEOUT, out _);
DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready."); DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
System.Console.ReadKey(true); System.Console.ReadKey(true);
testedMediaType mediaTest = new testedMediaType(); testedMediaType mediaTest =
mediaTest.MediumTypeName = mediaType; new testedMediaType {MediumTypeName = mediaType, MediaIsRecognized = true};
mediaTest.MediaIsRecognized = true;
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(sense) if(sense)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuffer); FixedSense? decSense = Sense.DecodeFixed(senseBuffer);
@@ -768,7 +760,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -783,7 +775,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -799,7 +791,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -817,7 +809,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsReadCapacity16Specified = true; mediaTest.SupportsReadCapacity16Specified = true;
DicConsole.WriteLine("Querying SCSI READ CAPACITY..."); DicConsole.WriteLine("Querying SCSI READ CAPACITY...");
sense = dev.ReadCapacity(out buffer, out senseBuffer, timeout, out duration); sense = dev.ReadCapacity(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadCapacity = true; mediaTest.SupportsReadCapacity = true;
@@ -830,7 +822,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)..."); DicConsole.WriteLine("Querying SCSI READ CAPACITY (16)...");
sense = dev.ReadCapacity16(out buffer, out buffer, timeout, out duration); sense = dev.ReadCapacity16(out buffer, out buffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadCapacity16 = true; mediaTest.SupportsReadCapacity16 = true;
@@ -844,11 +836,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.BlockSizeSpecified = true; mediaTest.BlockSizeSpecified = true;
} }
decMode = null; Modes.DecodedMode? decMode = null;
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)..."); DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration); ScsiModeSensePageControl.Current, 0x3F, 0x00, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense10 = true; report.SCSI.SupportsModeSense10 = true;
@@ -856,7 +848,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(debug) mediaTest.ModeSense10Data = buffer; if(debug) mediaTest.ModeSense10Data = buffer;
} }
DicConsole.WriteLine("Querying SCSI MODE SENSE..."); DicConsole.WriteLine("Querying SCSI MODE SENSE...");
sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration); sense = dev.ModeSense(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense6 = true; report.SCSI.SupportsModeSense6 = true;
@@ -883,7 +875,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.CanReadFullTOCSpecified = true; mediaTest.CanReadFullTOCSpecified = true;
DicConsole.WriteLine("Querying CD TOC..."); DicConsole.WriteLine("Querying CD TOC...");
mediaTest.CanReadTOC = mediaTest.CanReadTOC =
!dev.ReadTocPmaAtip(out buffer, out senseBuffer, false, 0, 0, timeout, out duration); !dev.ReadTocPmaAtip(out buffer, out senseBuffer, false, 0, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadTOC); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadTOC);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readtoc", DataFile.WriteTo("SCSI Report", "readtoc",
@@ -892,7 +884,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying CD Full TOC..."); DicConsole.WriteLine("Querying CD Full TOC...");
mediaTest.CanReadFullTOC = mediaTest.CanReadFullTOC =
!dev.ReadRawToc(out buffer, out senseBuffer, 1, timeout, out duration); !dev.ReadRawToc(out buffer, out senseBuffer, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadFullTOC); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadFullTOC);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readfulltoc", DataFile.WriteTo("SCSI Report", "readfulltoc",
@@ -906,14 +898,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.CanReadATIPSpecified = true; mediaTest.CanReadATIPSpecified = true;
mediaTest.CanReadPMASpecified = true; mediaTest.CanReadPMASpecified = true;
DicConsole.WriteLine("Querying CD ATIP..."); DicConsole.WriteLine("Querying CD ATIP...");
mediaTest.CanReadATIP = !dev.ReadAtip(out buffer, out senseBuffer, timeout, out duration); mediaTest.CanReadATIP = !dev.ReadAtip(out buffer, out senseBuffer, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadATIP); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadATIP);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "atip", DataFile.WriteTo("SCSI Report", "atip",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
mediaType + ".bin", "read results", buffer); mediaType + ".bin", "read results", buffer);
DicConsole.WriteLine("Querying CD PMA..."); DicConsole.WriteLine("Querying CD PMA...");
mediaTest.CanReadPMA = !dev.ReadPma(out buffer, out senseBuffer, timeout, out duration); mediaTest.CanReadPMA = !dev.ReadPma(out buffer, out senseBuffer, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPMA); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPMA);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "pma", DataFile.WriteTo("SCSI Report", "pma",
@@ -929,8 +921,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD PFI..."); DicConsole.WriteLine("Querying DVD PFI...");
mediaTest.CanReadPFI = mediaTest.CanReadPFI =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, timeout, MmcDiscStructureFormat.PhysicalInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPFI); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPFI);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "pfi", DataFile.WriteTo("SCSI Report", "pfi",
@@ -939,8 +931,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD DMI..."); DicConsole.WriteLine("Querying DVD DMI...");
mediaTest.CanReadDMI = mediaTest.CanReadDMI =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, timeout, MmcDiscStructureFormat.DiscManufacturingInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDMI); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDMI);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "dmi", DataFile.WriteTo("SCSI Report", "dmi",
@@ -954,8 +946,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD CMI..."); DicConsole.WriteLine("Querying DVD CMI...");
mediaTest.CanReadCMI = mediaTest.CanReadCMI =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.CopyrightInformation, 0, timeout, MmcDiscStructureFormat.CopyrightInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCMI); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCMI);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "cmi", DataFile.WriteTo("SCSI Report", "cmi",
@@ -970,8 +962,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD BCA..."); DicConsole.WriteLine("Querying DVD BCA...");
mediaTest.CanReadBCA = mediaTest.CanReadBCA =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.BurstCuttingArea, 0, timeout, MmcDiscStructureFormat.BurstCuttingArea, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "bca", DataFile.WriteTo("SCSI Report", "bca",
@@ -981,7 +973,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD AACS..."); DicConsole.WriteLine("Querying DVD AACS...");
mediaTest.CanReadAACS = mediaTest.CanReadAACS =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdAacs, 0, timeout, out duration); MmcDiscStructureFormat.DvdAacs, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadAACS); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadAACS);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "aacs", DataFile.WriteTo("SCSI Report", "aacs",
@@ -993,8 +985,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying BD BCA..."); DicConsole.WriteLine("Querying BD BCA...");
mediaTest.CanReadBCA = mediaTest.CanReadBCA =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdBurstCuttingArea, 0, timeout, MmcDiscStructureFormat.BdBurstCuttingArea, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "bdbca", DataFile.WriteTo("SCSI Report", "bdbca",
@@ -1007,7 +999,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.CanReadSpareAreaInformationSpecified = true; mediaTest.CanReadSpareAreaInformationSpecified = true;
mediaTest.CanReadDDS = mediaTest.CanReadDDS =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramDds, 0, timeout, out duration); MmcDiscStructureFormat.DvdramDds, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "dds", DataFile.WriteTo("SCSI Report", "dds",
@@ -1015,8 +1007,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaType + ".bin", "read results", buffer); mediaType + ".bin", "read results", buffer);
mediaTest.CanReadSpareAreaInformation = mediaTest.CanReadSpareAreaInformation =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, timeout, MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadSpareAreaInformation); !mediaTest.CanReadSpareAreaInformation);
if(debug) if(debug)
@@ -1033,7 +1025,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying BD DDS..."); DicConsole.WriteLine("Querying BD DDS...");
mediaTest.CanReadDDS = mediaTest.CanReadDDS =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdDds, 0, timeout, out duration); MmcDiscStructureFormat.BdDds, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "bddds", DataFile.WriteTo("SCSI Report", "bddds",
@@ -1042,8 +1034,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying BD SAI..."); DicConsole.WriteLine("Querying BD SAI...");
mediaTest.CanReadSpareAreaInformation = mediaTest.CanReadSpareAreaInformation =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdSpareAreaInformation, 0, timeout, MmcDiscStructureFormat.BdSpareAreaInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadSpareAreaInformation); !mediaTest.CanReadSpareAreaInformation);
if(debug) if(debug)
@@ -1058,8 +1050,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD PRI..."); DicConsole.WriteLine("Querying DVD PRI...");
mediaTest.CanReadPRI = mediaTest.CanReadPRI =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PreRecordedInfo, 0, timeout, MmcDiscStructureFormat.PreRecordedInfo, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPRI); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPRI);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "pri", DataFile.WriteTo("SCSI Report", "pri",
@@ -1074,8 +1066,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD Media ID..."); DicConsole.WriteLine("Querying DVD Media ID...");
mediaTest.CanReadMediaID = mediaTest.CanReadMediaID =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, timeout, MmcDiscStructureFormat.DvdrMediaIdentifier, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadMediaID); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadMediaID);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "mediaid", DataFile.WriteTo("SCSI Report", "mediaid",
@@ -1084,8 +1076,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD Embossed PFI..."); DicConsole.WriteLine("Querying DVD Embossed PFI...");
mediaTest.CanReadRecordablePFI = mediaTest.CanReadRecordablePFI =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrPhysicalInformation, 0, timeout, MmcDiscStructureFormat.DvdrPhysicalInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRecordablePFI); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRecordablePFI);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "epfi", DataFile.WriteTo("SCSI Report", "epfi",
@@ -1100,7 +1092,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD ADIP..."); DicConsole.WriteLine("Querying DVD ADIP...");
mediaTest.CanReadADIP = mediaTest.CanReadADIP =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Adip, 0, timeout, out duration); MmcDiscStructureFormat.Adip, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadADIP); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadADIP);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "adip", DataFile.WriteTo("SCSI Report", "adip",
@@ -1109,7 +1101,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD DCB..."); DicConsole.WriteLine("Querying DVD DCB...");
mediaTest.CanReadDCB = mediaTest.CanReadDCB =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Dcb, 0, timeout, out duration); MmcDiscStructureFormat.Dcb, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDCB); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDCB);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "dcb", DataFile.WriteTo("SCSI Report", "dcb",
@@ -1123,8 +1115,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying HD DVD CMI..."); DicConsole.WriteLine("Querying HD DVD CMI...");
mediaTest.CanReadHDCMI = mediaTest.CanReadHDCMI =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.HddvdCopyrightInformation, 0, timeout, MmcDiscStructureFormat.HddvdCopyrightInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadHDCMI); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadHDCMI);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "hdcmi", DataFile.WriteTo("SCSI Report", "hdcmi",
@@ -1138,8 +1130,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying DVD Layer Capacity..."); DicConsole.WriteLine("Querying DVD Layer Capacity...");
mediaTest.CanReadLayerCapacity = mediaTest.CanReadLayerCapacity =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrLayerCapacity, 0, timeout, MmcDiscStructureFormat.DvdrLayerCapacity, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLayerCapacity); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLayerCapacity);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "layer", DataFile.WriteTo("SCSI Report", "layer",
@@ -1154,8 +1146,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying BD Disc Information..."); DicConsole.WriteLine("Querying BD Disc Information...");
mediaTest.CanReadDiscInformation = mediaTest.CanReadDiscInformation =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.DiscInformation, 0, timeout, MmcDiscStructureFormat.DiscInformation, 0, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDiscInformation); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDiscInformation);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "di", DataFile.WriteTo("SCSI Report", "di",
@@ -1164,7 +1156,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Querying BD PAC..."); DicConsole.WriteLine("Querying BD PAC...");
mediaTest.CanReadPAC = mediaTest.CanReadPAC =
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.Pac, 0, timeout, out duration); MmcDiscStructureFormat.Pac, 0, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPAC); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPAC);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "pac", DataFile.WriteTo("SCSI Report", "pac",
@@ -1179,7 +1171,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying SCSI READ (6)..."); DicConsole.WriteLine("Trying SCSI READ (6)...");
mediaTest.SupportsRead = mediaTest.SupportsRead =
!dev.Read6(out buffer, out senseBuffer, 0, 2048, timeout, out duration); !dev.Read6(out buffer, out senseBuffer, 0, 2048, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read6", DataFile.WriteTo("SCSI Report", "read6",
@@ -1187,7 +1179,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
".bin", "read results", buffer); ".bin", "read results", buffer);
DicConsole.WriteLine("Trying SCSI READ (10)..."); DicConsole.WriteLine("Trying SCSI READ (10)...");
mediaTest.SupportsRead10 = !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, mediaTest.SupportsRead10 = !dev.Read10(out buffer, out senseBuffer, 0, false, true, false,
false, 0, 2048, 0, 1, timeout, out duration); false, 0, 2048, 0, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read10", DataFile.WriteTo("SCSI Report", "read10",
@@ -1195,7 +1187,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
".bin", "read results", buffer); ".bin", "read results", buffer);
DicConsole.WriteLine("Trying SCSI READ (12)..."); DicConsole.WriteLine("Trying SCSI READ (12)...");
mediaTest.SupportsRead12 = !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, mediaTest.SupportsRead12 = !dev.Read12(out buffer, out senseBuffer, 0, false, true, false,
false, 0, 2048, 0, 1, false, timeout, out duration); false, 0, 2048, 0, 1, false, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read12", DataFile.WriteTo("SCSI Report", "read12",
@@ -1203,7 +1195,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
".bin", "read results", buffer); ".bin", "read results", buffer);
DicConsole.WriteLine("Trying SCSI READ (16)..."); DicConsole.WriteLine("Trying SCSI READ (16)...");
mediaTest.SupportsRead16 = !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0, mediaTest.SupportsRead16 = !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0,
2048, 0, 1, false, timeout, out duration); 2048, 0, 1, false, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "read16", DataFile.WriteTo("SCSI Report", "read16",
@@ -1248,8 +1240,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsReadCd = !dev.ReadCd(out buffer, out senseBuffer, 0, 2352, 1, mediaTest.SupportsReadCd = !dev.ReadCd(out buffer, out senseBuffer, 0, 2352, 1,
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, timeout, MmcErrorField.None, MmcSubchannel.None, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCd); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCd);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcd", DataFile.WriteTo("SCSI Report", "readcd",
@@ -1260,7 +1252,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
0x00000201, 2352, MmcSectorTypes.Cdda, 0x00000201, 2352, MmcSectorTypes.Cdda,
false, false, MmcHeaderCodes.None, true, false, false, MmcHeaderCodes.None, true,
false, MmcErrorField.None, false, MmcErrorField.None,
MmcSubchannel.None, timeout, out duration); MmcSubchannel.None, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdmsf", DataFile.WriteTo("SCSI Report", "readcdmsf",
@@ -1273,8 +1265,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsReadCd = !dev.ReadCd(out buffer, out senseBuffer, 0, 2048, 1, mediaTest.SupportsReadCd = !dev.ReadCd(out buffer, out senseBuffer, 0, 2048, 1,
MmcSectorTypes.AllTypes, false, false, false, MmcSectorTypes.AllTypes, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, timeout, MmcErrorField.None, MmcSubchannel.None, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCd); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCd);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcd", DataFile.WriteTo("SCSI Report", "readcd",
@@ -1285,7 +1277,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
0x00000201, 2048, MmcSectorTypes.AllTypes, 0x00000201, 2048, MmcSectorTypes.AllTypes,
false, false, MmcHeaderCodes.None, true, false, false, MmcHeaderCodes.None, true,
false, MmcErrorField.None, false, MmcErrorField.None,
MmcSubchannel.None, timeout, out duration); MmcSubchannel.None, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdmsf", DataFile.WriteTo("SCSI Report", "readcdmsf",
@@ -1296,7 +1288,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, true, MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, MmcErrorField.None, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdRaw); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdRaw);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdraw", DataFile.WriteTo("SCSI Report", "readcdraw",
@@ -1308,7 +1300,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, MmcSectorTypes.AllTypes, false, false,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, MmcErrorField.None, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.SupportsReadCdMsfRaw); !mediaTest.SupportsReadCdMsfRaw);
if(debug) if(debug)
@@ -1326,12 +1318,12 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
sense = dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, sense = dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1,
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcHeaderCodes.None, true, false, MmcErrorField.None,
MmcSubchannel.None, timeout, out duration); MmcSubchannel.None, TIMEOUT, out _);
else else
sense = dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, sense = dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1,
MmcSectorTypes.AllTypes, false, false, true, MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, timeout, out duration); MmcSubchannel.None, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", sense); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", sense);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "leadin", DataFile.WriteTo("SCSI Report", "leadin",
@@ -1350,14 +1342,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, MmcErrorField.None, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
else else
mediaTest.CanReadLeadOut = !dev.ReadCd(out buffer, out senseBuffer, mediaTest.CanReadLeadOut = !dev.ReadCd(out buffer, out senseBuffer,
(uint)(mediaTest.Blocks + 1), 2352, 1, (uint)(mediaTest.Blocks + 1), 2352, 1,
MmcSectorTypes.AllTypes, false, false, true, MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, MmcErrorField.None, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLeadOut); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLeadOut);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "leadout", DataFile.WriteTo("SCSI Report", "leadout",
@@ -1372,14 +1364,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2Pointers, MmcSubchannel.None, MmcErrorField.C2Pointers, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
if(!mediaTest.CanReadC2Pointers) if(!mediaTest.CanReadC2Pointers)
mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2648, 1, mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2648, 1,
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.None, timeout, MmcSubchannel.None, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdc2", DataFile.WriteTo("SCSI Report", "readcdc2",
@@ -1391,7 +1383,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.Q16, MmcErrorField.None, MmcSubchannel.Q16,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdpq", DataFile.WriteTo("SCSI Report", "readcdpq",
@@ -1401,7 +1393,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.Cdda, false, false, false, MmcSectorTypes.Cdda, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.Raw, MmcErrorField.None, MmcSubchannel.Raw,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdrw", DataFile.WriteTo("SCSI Report", "readcdrw",
@@ -1411,8 +1403,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1, MmcSectorTypes.Cdda, false, false, 1, MmcSectorTypes.Cdda, false, false,
false, MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true,
false, MmcErrorField.None, false, MmcErrorField.None,
MmcSubchannel.Rw, timeout, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadCorrectedSubchannel); !mediaTest.CanReadCorrectedSubchannel);
if(debug) if(debug)
@@ -1425,16 +1417,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1, MmcSectorTypes.Cdda, false, false, 1, MmcSectorTypes.Cdda, false, false,
false, MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true,
false, MmcErrorField.C2Pointers, false, MmcErrorField.C2Pointers,
MmcSubchannel.Q16, timeout, MmcSubchannel.Q16, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadPQSubchannelWithC2) if(!mediaTest.CanReadPQSubchannelWithC2)
mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0,
2664, 1, MmcSectorTypes.Cdda, 2664, 1, MmcSectorTypes.Cdda,
false, false, false, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Q16, timeout, MmcSubchannel.Q16, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadPQSubchannelWithC2); !mediaTest.CanReadPQSubchannelWithC2);
if(debug) if(debug)
@@ -1446,16 +1438,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1, MmcSectorTypes.Cdda, false, false, 1, MmcSectorTypes.Cdda, false, false,
false, MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true,
false, MmcErrorField.C2Pointers, false, MmcErrorField.C2Pointers,
MmcSubchannel.Raw, timeout, MmcSubchannel.Raw, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadRWSubchannelWithC2) if(!mediaTest.CanReadRWSubchannelWithC2)
mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0,
2714, 1, MmcSectorTypes.Cdda, 2714, 1, MmcSectorTypes.Cdda,
false, false, false, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Raw, timeout, MmcSubchannel.Raw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadRWSubchannelWithC2); !mediaTest.CanReadRWSubchannelWithC2);
if(debug) if(debug)
@@ -1469,14 +1461,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcHeaderCodes.None, true, MmcHeaderCodes.None, true,
false, false,
MmcErrorField.C2Pointers, MmcErrorField.C2Pointers,
MmcSubchannel.Rw, timeout, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadCorrectedSubchannelWithC2) if(!mediaTest.CanReadCorrectedSubchannelWithC2)
mediaTest.CanReadCorrectedSubchannelWithC2 = mediaTest.CanReadCorrectedSubchannelWithC2 =
!dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.Cdda, false, !dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.Cdda, false,
false, false, MmcHeaderCodes.None, true, false, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, timeout, MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadCorrectedSubchannelWithC2); !mediaTest.CanReadCorrectedSubchannelWithC2);
if(debug) if(debug)
@@ -1491,14 +1483,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, true, MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.C2Pointers, MmcSubchannel.None, MmcErrorField.C2Pointers, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
if(!mediaTest.CanReadC2Pointers) if(!mediaTest.CanReadC2Pointers)
mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2648, 1, mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2648, 1,
MmcSectorTypes.AllTypes, false, false, MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.C2PointersAndBlock, true, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.None, timeout, MmcSubchannel.None, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdc2", DataFile.WriteTo("SCSI Report", "readcdc2",
@@ -1510,7 +1502,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, true, MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.Q16, MmcErrorField.None, MmcSubchannel.Q16,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdpq", DataFile.WriteTo("SCSI Report", "readcdpq",
@@ -1520,7 +1512,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, true, MmcSectorTypes.AllTypes, false, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.Raw, MmcErrorField.None, MmcSubchannel.Raw,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdrw", DataFile.WriteTo("SCSI Report", "readcdrw",
@@ -1531,8 +1523,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
false, true, false, true,
MmcHeaderCodes.AllHeaders, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None, true, MmcErrorField.None,
MmcSubchannel.Rw, timeout, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadCorrectedSubchannel); !mediaTest.CanReadCorrectedSubchannel);
if(debug) if(debug)
@@ -1546,8 +1538,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
false, true, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.C2Pointers, MmcErrorField.C2Pointers,
MmcSubchannel.Q16, timeout, MmcSubchannel.Q16, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadPQSubchannelWithC2) if(!mediaTest.CanReadPQSubchannelWithC2)
mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0,
2664, 1, MmcSectorTypes.AllTypes, 2664, 1, MmcSectorTypes.AllTypes,
@@ -1555,8 +1547,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcHeaderCodes.AllHeaders, true, MmcHeaderCodes.AllHeaders, true,
true, true,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Q16, timeout, MmcSubchannel.Q16, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadPQSubchannelWithC2); !mediaTest.CanReadPQSubchannelWithC2);
if(debug) if(debug)
@@ -1569,8 +1561,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
false, true, false, true,
MmcHeaderCodes.AllHeaders, true, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.C2Pointers, MmcErrorField.C2Pointers,
MmcSubchannel.Raw, timeout, MmcSubchannel.Raw, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadRWSubchannelWithC2) if(!mediaTest.CanReadRWSubchannelWithC2)
mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0,
2714, 1, MmcSectorTypes.AllTypes, 2714, 1, MmcSectorTypes.AllTypes,
@@ -1578,8 +1570,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcHeaderCodes.AllHeaders, true, MmcHeaderCodes.AllHeaders, true,
true, true,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Raw, timeout, MmcSubchannel.Raw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadRWSubchannelWithC2); !mediaTest.CanReadRWSubchannelWithC2);
if(debug) if(debug)
@@ -1594,14 +1586,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcHeaderCodes.AllHeaders, MmcHeaderCodes.AllHeaders,
true, true, true, true,
MmcErrorField.C2Pointers, MmcErrorField.C2Pointers,
MmcSubchannel.Rw, timeout, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadCorrectedSubchannelWithC2) if(!mediaTest.CanReadCorrectedSubchannelWithC2)
mediaTest.CanReadCorrectedSubchannelWithC2 = mediaTest.CanReadCorrectedSubchannelWithC2 =
!dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.AllTypes, !dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, timeout, MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadCorrectedSubchannelWithC2); !mediaTest.CanReadCorrectedSubchannelWithC2);
if(debug) if(debug)
@@ -1616,14 +1608,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, false, MmcSectorTypes.AllTypes, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2Pointers, MmcSubchannel.None, MmcErrorField.C2Pointers, MmcSubchannel.None,
timeout, out duration); TIMEOUT, out _);
if(!mediaTest.CanReadC2Pointers) if(!mediaTest.CanReadC2Pointers)
mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2344, 1, mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2344, 1,
MmcSectorTypes.AllTypes, false, false, MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.None, true, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.None, timeout, MmcSubchannel.None, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdc2", DataFile.WriteTo("SCSI Report", "readcdc2",
@@ -1635,7 +1627,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.None, true, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.Q16, MmcErrorField.None, MmcSubchannel.Q16,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdpq", DataFile.WriteTo("SCSI Report", "readcdpq",
@@ -1645,7 +1637,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcSectorTypes.AllTypes, false, false, MmcSectorTypes.AllTypes, false, false,
false, MmcHeaderCodes.None, true, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.Raw, MmcErrorField.None, MmcSubchannel.Raw,
timeout, out duration); TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "readcdrw", DataFile.WriteTo("SCSI Report", "readcdrw",
@@ -1655,8 +1647,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1, MmcSectorTypes.AllTypes, false, 1, MmcSectorTypes.AllTypes, false,
false, false, MmcHeaderCodes.None, false, false, MmcHeaderCodes.None,
true, false, MmcErrorField.None, true, false, MmcErrorField.None,
MmcSubchannel.Rw, timeout, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadCorrectedSubchannel); !mediaTest.CanReadCorrectedSubchannel);
if(debug) if(debug)
@@ -1669,16 +1661,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1, MmcSectorTypes.AllTypes, false, 1, MmcSectorTypes.AllTypes, false,
false, false, MmcHeaderCodes.None, false, false, MmcHeaderCodes.None,
true, false, MmcErrorField.C2Pointers, true, false, MmcErrorField.C2Pointers,
MmcSubchannel.Q16, timeout, MmcSubchannel.Q16, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadPQSubchannelWithC2) if(!mediaTest.CanReadPQSubchannelWithC2)
mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0,
2360, 1, MmcSectorTypes.AllTypes, 2360, 1, MmcSectorTypes.AllTypes,
false, false, false, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Q16, timeout, MmcSubchannel.Q16, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadPQSubchannelWithC2); !mediaTest.CanReadPQSubchannelWithC2);
if(debug) if(debug)
@@ -1690,16 +1682,16 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
1, MmcSectorTypes.AllTypes, false, 1, MmcSectorTypes.AllTypes, false,
false, false, MmcHeaderCodes.None, false, false, MmcHeaderCodes.None,
true, false, MmcErrorField.C2Pointers, true, false, MmcErrorField.C2Pointers,
MmcSubchannel.Raw, timeout, MmcSubchannel.Raw, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadRWSubchannelWithC2) if(!mediaTest.CanReadRWSubchannelWithC2)
mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0,
2440, 1, MmcSectorTypes.AllTypes, 2440, 1, MmcSectorTypes.AllTypes,
false, false, false, false, false, false,
MmcHeaderCodes.None, true, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcErrorField.C2PointersAndBlock,
MmcSubchannel.Raw, timeout, MmcSubchannel.Raw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadRWSubchannelWithC2); !mediaTest.CanReadRWSubchannelWithC2);
if(debug) if(debug)
@@ -1714,14 +1706,14 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
MmcHeaderCodes.None, true, MmcHeaderCodes.None, true,
false, false,
MmcErrorField.C2Pointers, MmcErrorField.C2Pointers,
MmcSubchannel.Rw, timeout, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
if(!mediaTest.CanReadCorrectedSubchannelWithC2) if(!mediaTest.CanReadCorrectedSubchannelWithC2)
mediaTest.CanReadCorrectedSubchannelWithC2 = mediaTest.CanReadCorrectedSubchannelWithC2 =
!dev.ReadCd(out buffer, out senseBuffer, 0, 2440, 1, MmcSectorTypes.AllTypes, !dev.ReadCd(out buffer, out senseBuffer, 0, 2440, 1, MmcSectorTypes.AllTypes,
false, false, false, MmcHeaderCodes.None, true, false, false, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, timeout, MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, TIMEOUT,
out duration); out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.CanReadCorrectedSubchannelWithC2); !mediaTest.CanReadCorrectedSubchannelWithC2);
if(debug) if(debug)
@@ -1767,7 +1759,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying Plextor READ CD-DA..."); DicConsole.WriteLine("Trying Plextor READ CD-DA...");
mediaTest.SupportsPlextorReadCDDA = mediaTest.SupportsPlextorReadCDDA =
!dev.PlextorReadCdDa(out buffer, out senseBuffer, 0, 2352, 1, !dev.PlextorReadCdDa(out buffer, out senseBuffer, 0, 2352, 1,
PlextorSubchannel.None, timeout, out duration); PlextorSubchannel.None, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.SupportsPlextorReadCDDA); !mediaTest.SupportsPlextorReadCDDA);
if(debug) if(debug)
@@ -1783,7 +1775,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying Pioneer READ CD-DA..."); DicConsole.WriteLine("Trying Pioneer READ CD-DA...");
mediaTest.SupportsPioneerReadCDDA = mediaTest.SupportsPioneerReadCDDA =
!dev.PioneerReadCdDa(out buffer, out senseBuffer, 0, 2352, 1, !dev.PioneerReadCdDa(out buffer, out senseBuffer, 0, 2352, 1,
PioneerSubchannel.None, timeout, out duration); PioneerSubchannel.None, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.SupportsPioneerReadCDDA); !mediaTest.SupportsPioneerReadCDDA);
if(debug) if(debug)
@@ -1793,7 +1785,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
DicConsole.WriteLine("Trying Pioneer READ CD-DA MSF..."); DicConsole.WriteLine("Trying Pioneer READ CD-DA MSF...");
mediaTest.SupportsPioneerReadCDDAMSF = mediaTest.SupportsPioneerReadCDDAMSF =
!dev.PioneerReadCdDaMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2352, !dev.PioneerReadCdDaMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2352,
PioneerSubchannel.None, timeout, out duration); PioneerSubchannel.None, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.SupportsPioneerReadCDDAMSF); !mediaTest.SupportsPioneerReadCDDAMSF);
if(debug) if(debug)
@@ -1807,7 +1799,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsNECReadCDDASpecified = true; mediaTest.SupportsNECReadCDDASpecified = true;
DicConsole.WriteLine("Trying NEC READ CD-DA..."); DicConsole.WriteLine("Trying NEC READ CD-DA...");
mediaTest.SupportsNECReadCDDA = mediaTest.SupportsNECReadCDDA =
!dev.NecReadCdDa(out buffer, out senseBuffer, 0, 1, timeout, out duration); !dev.NecReadCdDa(out buffer, out senseBuffer, 0, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsNECReadCDDA); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsNECReadCDDA);
if(debug) if(debug)
DataFile.WriteTo("SCSI Report", "necreadcdda", DataFile.WriteTo("SCSI Report", "necreadcdda",
@@ -1818,8 +1810,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.LongBlockSize = mediaTest.BlockSize; mediaTest.LongBlockSize = mediaTest.BlockSize;
DicConsole.WriteLine("Trying SCSI READ LONG (10)..."); DicConsole.WriteLine("Trying SCSI READ LONG (10)...");
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 0xFFFF, TIMEOUT,
out duration); out _);
if(sense && !dev.Error) if(sense && !dev.Error)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuffer); FixedSense? decSense = Sense.DecodeFixed(senseBuffer);
@@ -1854,8 +1846,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize) if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize)
{ {
// DVDs // DVDs
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 37856, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 37856, TIMEOUT,
out duration); out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
mediaTest.SupportsReadLong = true; mediaTest.SupportsReadLong = true;
@@ -1869,7 +1861,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsPlextorReadRawDVDSpecified = true; mediaTest.SupportsPlextorReadRawDVDSpecified = true;
DicConsole.WriteLine("Trying Plextor trick to raw read DVDs..."); DicConsole.WriteLine("Trying Plextor trick to raw read DVDs...");
mediaTest.SupportsPlextorReadRawDVD = mediaTest.SupportsPlextorReadRawDVD =
!dev.PlextorReadRawDvd(out buffer, out senseBuffer, 0, 1, timeout, out duration); !dev.PlextorReadRawDvd(out buffer, out senseBuffer, 0, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.SupportsPlextorReadRawDVD); !mediaTest.SupportsPlextorReadRawDVD);
if(debug) if(debug)
@@ -1885,7 +1877,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.SupportsHLDTSTReadRawDVDSpecified = true; mediaTest.SupportsHLDTSTReadRawDVDSpecified = true;
DicConsole.WriteLine("Trying HL-DT-ST (aka LG) trick to raw read DVDs..."); DicConsole.WriteLine("Trying HL-DT-ST (aka LG) trick to raw read DVDs...");
mediaTest.SupportsHLDTSTReadRawDVD = mediaTest.SupportsHLDTSTReadRawDVD =
!dev.HlDtStReadRawDvd(out buffer, out senseBuffer, 0, 1, timeout, out duration); !dev.HlDtStReadRawDvd(out buffer, out senseBuffer, 0, 1, TIMEOUT, out _);
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
!mediaTest.SupportsHLDTSTReadRawDVD); !mediaTest.SupportsHLDTSTReadRawDVD);
if(debug) if(debug)
@@ -1907,11 +1899,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(pressedKey.Key == ConsoleKey.Y) if(pressedKey.Key == ConsoleKey.Y)
{ {
for(ushort i = (ushort)mediaTest.BlockSize; true; i++) for(ushort i = (ushort)mediaTest.BlockSize; ; i++)
{ {
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i); DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, TIMEOUT,
out duration); out _);
if(!sense) if(!sense)
{ {
if(debug) if(debug)
@@ -1938,7 +1930,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
mediaTest.LongBlockSize != mediaTest.BlockSize) mediaTest.LongBlockSize != mediaTest.BlockSize)
{ {
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
(ushort)mediaTest.LongBlockSize, timeout, out duration); (ushort)mediaTest.LongBlockSize, TIMEOUT, out _);
if(!sense) if(!sense)
DataFile.WriteTo("SCSI Report", "readlong10", DataFile.WriteTo("SCSI Report", "readlong10",
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +

View File

@@ -47,17 +47,13 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
if(report == null) return; if(report == null) return;
byte[] senseBuffer;
byte[] buffer;
double duration;
bool sense; bool sense;
uint timeout = 5; const uint TIMEOUT = 5;
ConsoleKeyInfo pressedKey; ConsoleKeyInfo pressedKey;
Modes.DecodedMode? decMode;
report.SCSI.SequentialDevice = new sscType(); report.SCSI.SequentialDevice = new sscType();
DicConsole.WriteLine("Querying SCSI READ BLOCK LIMITS..."); DicConsole.WriteLine("Querying SCSI READ BLOCK LIMITS...");
sense = dev.ReadBlockLimits(out buffer, out senseBuffer, timeout, out duration); sense = dev.ReadBlockLimits(out byte[] buffer, out byte[] senseBuffer, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
BlockLimits.BlockLimitsData? decBl = BlockLimits.Decode(buffer); BlockLimits.BlockLimitsData? decBl = BlockLimits.Decode(buffer);
@@ -82,7 +78,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT..."); DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT...");
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, false, timeout, out duration); sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, false, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DensitySupportHeader? dsh =
@@ -116,7 +112,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types..."); DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types...");
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, false, timeout, out duration); sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, false, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.MediaTypeSupportHeader? mtsh =
@@ -175,8 +171,8 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
seqTest.MediaIsRecognized = true; seqTest.MediaIsRecognized = true;
dev.Load(out senseBuffer, timeout, out duration); dev.Load(out senseBuffer, TIMEOUT, out _);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(sense) if(sense)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuffer); FixedSense? decSense = Sense.DecodeFixed(senseBuffer);
@@ -188,7 +184,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -203,7 +199,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
{ {
DicConsole.Write("\rWaiting for drive to become ready"); DicConsole.Write("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuffer, timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -217,11 +213,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(seqTest.MediaIsRecognized) if(seqTest.MediaIsRecognized)
{ {
decMode = null; Modes.DecodedMode? decMode = null;
DicConsole.WriteLine("Querying SCSI MODE SENSE (10)..."); DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, sense = dev.ModeSense10(out buffer, out senseBuffer, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, timeout, out duration); ScsiModeSensePageControl.Current, 0x3F, 0x00, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense10 = true; report.SCSI.SupportsModeSense10 = true;
@@ -230,7 +226,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI MODE SENSE..."); DicConsole.WriteLine("Querying SCSI MODE SENSE...");
sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration); sense = dev.ModeSense(out buffer, out senseBuffer, TIMEOUT, out _);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
report.SCSI.SupportsModeSense6 = true; report.SCSI.SupportsModeSense6 = true;
@@ -252,7 +248,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media..."); DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media...");
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, true, timeout, out duration); sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, true, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DensitySupportHeader? dsh =
@@ -279,7 +275,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
} }
DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media..."); DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...");
sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, true, timeout, out duration); sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, true, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.MediaTypeSupportHeader? mtsh =
@@ -309,7 +305,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
seqTest.CanReadMediaSerialSpecified = true; seqTest.CanReadMediaSerialSpecified = true;
DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER..."); DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
seqTest.CanReadMediaSerial = seqTest.CanReadMediaSerial =
!dev.ReadMediaSerialNumber(out buffer, out senseBuffer, timeout, out duration); !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, TIMEOUT, out _);
seqTests.Add(seqTest); seqTests.Add(seqTest);
} }

View File

@@ -38,7 +38,7 @@ namespace DiscImageChef.Core.Devices.Report
{ {
public static class SecureDigital public static class SecureDigital
{ {
public static void Report(Device dev, ref DeviceReport report, bool debug, ref bool removable) public static void Report(Device dev, ref DeviceReport report)
{ {
if(report == null) return; if(report == null) return;
@@ -50,7 +50,7 @@ namespace DiscImageChef.Core.Devices.Report
} }
DicConsole.WriteLine("Trying to get CID..."); DicConsole.WriteLine("Trying to get CID...");
bool sense = dev.ReadCid(out byte[] cid, out uint[] response, dev.Timeout, out double duration); bool sense = dev.ReadCid(out byte[] cid, out _, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
@@ -81,7 +81,7 @@ namespace DiscImageChef.Core.Devices.Report
else DicConsole.WriteLine("Could not read CID..."); else DicConsole.WriteLine("Could not read CID...");
DicConsole.WriteLine("Trying to get CSD..."); DicConsole.WriteLine("Trying to get CSD...");
sense = dev.ReadCsd(out byte[] csd, out response, dev.Timeout, out duration); sense = dev.ReadCsd(out byte[] csd, out _, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
@@ -100,7 +100,7 @@ namespace DiscImageChef.Core.Devices.Report
case DeviceType.MMC: case DeviceType.MMC:
{ {
DicConsole.WriteLine("Trying to get OCR..."); DicConsole.WriteLine("Trying to get OCR...");
sense = dev.ReadOcr(out byte[] ocr, out response, dev.Timeout, out duration); sense = dev.ReadOcr(out byte[] ocr, out _, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
@@ -110,7 +110,7 @@ namespace DiscImageChef.Core.Devices.Report
else DicConsole.WriteLine("Could not read OCR..."); else DicConsole.WriteLine("Could not read OCR...");
DicConsole.WriteLine("Trying to get Extended CSD..."); DicConsole.WriteLine("Trying to get Extended CSD...");
sense = dev.ReadExtendedCsd(out byte[] ecsd, out response, dev.Timeout, out duration); sense = dev.ReadExtendedCsd(out byte[] ecsd, out _, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
@@ -123,7 +123,7 @@ namespace DiscImageChef.Core.Devices.Report
case DeviceType.SecureDigital: case DeviceType.SecureDigital:
{ {
DicConsole.WriteLine("Trying to get OCR..."); DicConsole.WriteLine("Trying to get OCR...");
sense = dev.ReadSdocr(out byte[] ocr, out response, dev.Timeout, out duration); sense = dev.ReadSdocr(out byte[] ocr, out _, dev.Timeout, out _);
if(!sense) if(!sense)
{ {
@@ -133,7 +133,7 @@ namespace DiscImageChef.Core.Devices.Report
else DicConsole.WriteLine("Could not read OCR..."); else DicConsole.WriteLine("Could not read OCR...");
DicConsole.WriteLine("Trying to get SCR..."); DicConsole.WriteLine("Trying to get SCR...");
sense = dev.ReadScr(out byte[] scr, out response, dev.Timeout, out duration); sense = dev.ReadScr(out byte[] scr, out _, dev.Timeout, out _);
if(!sense) if(!sense)
{ {

View File

@@ -53,11 +53,13 @@ namespace DiscImageChef.Core.Devices.Report
if(pressedKey.Key != ConsoleKey.Y) return; if(pressedKey.Key != ConsoleKey.Y) return;
report.USB = new usbType(); report.USB = new usbType
report.USB.Manufacturer = dev.UsbManufacturerString; {
report.USB.Product = dev.UsbProductString; Manufacturer = dev.UsbManufacturerString,
report.USB.ProductID = dev.UsbProductId; Product = dev.UsbProductString,
report.USB.VendorID = dev.UsbVendorId; ProductID = dev.UsbProductId,
VendorID = dev.UsbVendorId
};
pressedKey = new ConsoleKeyInfo(); pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)

View File

@@ -45,21 +45,16 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
ScanResults results = new ScanResults(); ScanResults results = new ScanResults();
bool aborted; bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf;
bool sense; bool sense;
results.Blocks = 0; results.Blocks = 0;
ushort currentProfile = 0x0001; const ushort ATA_PROFILE = 0x0001;
AtaErrorRegistersCHS errorChs; const uint TIMEOUT = 5;
uint timeout = 5;
double duration;
sense = dev.AtaIdentify(out cmdBuf, out errorChs); sense = dev.AtaIdentify(out byte[] cmdBuf, out _);
if(!sense && Identify.Decode(cmdBuf).HasValue) if(!sense && Identify.Decode(cmdBuf).HasValue)
{ {
// Initializate reader // Initializate reader
Reader ataReader = new Reader(dev, timeout, cmdBuf); Reader ataReader = new Reader(dev, TIMEOUT, cmdBuf);
// Fill reader blocks // Fill reader blocks
results.Blocks = ataReader.GetDeviceBlocks(); results.Blocks = ataReader.GetDeviceBlocks();
if(ataReader.FindReadCommand()) if(ataReader.FindReadCommand())
@@ -76,7 +71,7 @@ namespace DiscImageChef.Core.Devices.Scanning
uint blockSize = ataReader.LogicalBlockSize; uint blockSize = ataReader.LogicalBlockSize;
// Check how many blocks to read, if error show and return // Check how many blocks to read, if error show and return
if(ataReader.GetBlocksToRead(64)) if(ataReader.GetBlocksToRead())
{ {
DicConsole.ErrorWriteLine(ataReader.ErrorMessage); DicConsole.ErrorWriteLine(ataReader.ErrorMessage);
return results; return results;
@@ -110,20 +105,18 @@ namespace DiscImageChef.Core.Devices.Scanning
Random rnd = new Random(); Random rnd = new Random();
uint seekPos;
ushort seekCy;
byte seekHd;
byte seekSc;
aborted = false; aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
MhddLog mhddLog;
IbgLog ibgLog;
double duration;
if(ataReader.IsLba) if(ataReader.IsLba)
{ {
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead); DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead); mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile); ibgLog = new IbgLog(ibgLogPath, ATA_PROFILE);
start = DateTime.UtcNow; start = DateTime.UtcNow;
for(ulong i = 0; i < results.Blocks; i += blocksToRead) for(ulong i = 0; i < results.Blocks; i += blocksToRead)
@@ -159,8 +152,7 @@ namespace DiscImageChef.Core.Devices.Scanning
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(duration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, duration < 500 ? 65535 : duration);
else mhddLog.Write(i, duration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
@@ -181,7 +173,7 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
if(aborted) break; if(aborted) break;
seekPos = (uint)rnd.Next((int)results.Blocks); uint seekPos = (uint)rnd.Next((int)results.Blocks);
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos); DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
@@ -199,7 +191,7 @@ namespace DiscImageChef.Core.Devices.Scanning
else else
{ {
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead); mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile); ibgLog = new IbgLog(ibgLogPath, ATA_PROFILE);
ulong currentBlock = 0; ulong currentBlock = 0;
results.Blocks = (ulong)(cylinders * heads * sectors); results.Blocks = (ulong)(cylinders * heads * sectors);
@@ -240,8 +232,7 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
results.Errored += blocksToRead; results.Errored += blocksToRead;
results.UnreadableSectors.Add(currentBlock); results.UnreadableSectors.Add(currentBlock);
if(duration < 500) mhddLog.Write(currentBlock, 65535); mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
else mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, 0); ibgLog.Write(currentBlock, 0);
} }
@@ -266,9 +257,9 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
if(aborted) break; if(aborted) break;
seekCy = (ushort)rnd.Next(cylinders); ushort seekCy = (ushort)rnd.Next(cylinders);
seekHd = (byte)rnd.Next(heads); byte seekHd = (byte)rnd.Next(heads);
seekSc = (byte)rnd.Next(sectors); byte seekSc = (byte)rnd.Next(sectors);
DicConsole.Write("\rSeeking to cylinder {0}, head {1}, sector {2}...\t\t", seekCy, seekHd, DicConsole.Write("\rSeeking to cylinder {0}, head {1}, sector {2}...\t\t", seekCy, seekHd,
seekSc); seekSc);

View File

@@ -50,17 +50,15 @@ namespace DiscImageChef.Core.Devices.Scanning
bool aborted; bool aborted;
MhddLog mhddLog; MhddLog mhddLog;
IbgLog ibgLog; IbgLog ibgLog;
byte[] cmdBuf;
byte[] senseBuf; byte[] senseBuf;
bool sense = false; bool sense = false;
double duration;
results.Blocks = 0; results.Blocks = 0;
uint blockSize = 0; uint blockSize = 0;
ushort currentProfile = 0x0001; ushort currentProfile = 0x0001;
if(dev.IsRemovable) if(dev.IsRemovable)
{ {
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(sense) if(sense)
{ {
FixedSense? decSense = Sense.DecodeFixed(senseBuf); FixedSense? decSense = Sense.DecodeFixed(senseBuf);
@@ -72,7 +70,7 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
DicConsole.WriteLine("\rWaiting for drive to become ready"); DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -91,7 +89,7 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
DicConsole.WriteLine("\rWaiting for drive to become ready"); DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -112,7 +110,7 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
DicConsole.WriteLine("\rWaiting for drive to become ready"); DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000); Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break; if(!sense) break;
leftRetries--; leftRetries--;
@@ -148,7 +146,7 @@ namespace DiscImageChef.Core.Devices.Scanning
case PeripheralDeviceTypes.OpticalDevice: case PeripheralDeviceTypes.OpticalDevice:
case PeripheralDeviceTypes.SimplifiedDevice: case PeripheralDeviceTypes.SimplifiedDevice:
case PeripheralDeviceTypes.WriteOnceDevice: case PeripheralDeviceTypes.WriteOnceDevice:
scsiReader = new Reader(dev, dev.Timeout, null, false); scsiReader = new Reader(dev, dev.Timeout, null);
results.Blocks = scsiReader.GetDeviceBlocks(); results.Blocks = scsiReader.GetDeviceBlocks();
if(scsiReader.FindReadCommand()) if(scsiReader.FindReadCommand())
{ {
@@ -182,8 +180,8 @@ namespace DiscImageChef.Core.Devices.Scanning
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{ {
sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, sense = dev.GetConfiguration(out byte[] cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout,
out duration); out _);
if(!sense) if(!sense)
{ {
Features.SeparatedFeatures ftr = Features.Separate(cmdBuf); Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);
@@ -210,13 +208,12 @@ namespace DiscImageChef.Core.Devices.Scanning
currentProfile = 0x0008; currentProfile = 0x0008;
// We discarded all discs that falsify a TOC before requesting a real TOC // We discarded all discs that falsify a TOC before requesting a real TOC
// No TOC, no CD (or an empty one) // No TOC, no CD (or an empty one)
bool tocSense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out duration); bool tocSense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out _);
if(!tocSense) toc = FullTOC.Decode(cmdBuf); if(!tocSense) toc = FullTOC.Decode(cmdBuf);
} }
} }
else compactDisc = false; else compactDisc = false;
byte[] readBuffer;
uint blocksToRead = 64; uint blocksToRead = 64;
results.A = 0; // <3ms results.A = 0; // <3ms
@@ -238,8 +235,6 @@ namespace DiscImageChef.Core.Devices.Scanning
aborted = false; aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
bool readcd = false;
if(compactDisc) if(compactDisc)
{ {
if(toc == null) if(toc == null)
@@ -248,9 +243,9 @@ namespace DiscImageChef.Core.Devices.Scanning
return results; return results;
} }
readcd = !dev.ReadCd(out readBuffer, out senseBuf, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, bool readcd = !dev.ReadCd(out _, out senseBuf, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, dev.Timeout, out duration); MmcSubchannel.None, dev.Timeout, out _);
if(readcd) DicConsole.WriteLine("Using MMC READ CD command."); if(readcd) DicConsole.WriteLine("Using MMC READ CD command.");
@@ -260,9 +255,9 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
if(readcd) if(readcd)
{ {
sense = dev.ReadCd(out readBuffer, out senseBuf, 0, 2352, blocksToRead, MmcSectorTypes.AllTypes, sense = dev.ReadCd(out _, out senseBuf, 0, 2352, blocksToRead, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out duration); MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(dev.Error) blocksToRead /= 2; if(dev.Error) blocksToRead /= 2;
} }
@@ -297,7 +292,7 @@ namespace DiscImageChef.Core.Devices.Scanning
if(readcd) if(readcd)
{ {
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)i, 2352, blocksToRead, sense = dev.ReadCd(out _, out senseBuf, (uint)i, 2352, blocksToRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out cmdDuration); true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out cmdDuration);
results.ProcessingTime += cmdDuration; results.ProcessingTime += cmdDuration;
@@ -333,8 +328,7 @@ namespace DiscImageChef.Core.Devices.Scanning
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
@@ -344,8 +338,7 @@ namespace DiscImageChef.Core.Devices.Scanning
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
@@ -375,8 +368,6 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
if(aborted) break; if(aborted) break;
double cmdDuration = 0;
if(results.Blocks - i < blocksToRead) blocksToRead = (uint)(results.Blocks - i); if(results.Blocks - i < blocksToRead) blocksToRead = (uint)(results.Blocks - i);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
@@ -386,7 +377,7 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed); DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed);
sense = scsiReader.ReadBlocks(out readBuffer, i, blocksToRead, out cmdDuration); sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration);
results.ProcessingTime += cmdDuration; results.ProcessingTime += cmdDuration;
if(!sense && !dev.Error) if(!sense && !dev.Error)
@@ -407,8 +398,7 @@ namespace DiscImageChef.Core.Devices.Scanning
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
else mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
@@ -428,22 +418,19 @@ namespace DiscImageChef.Core.Devices.Scanning
results.SeekTotal = 0; results.SeekTotal = 0;
const int SEEK_TIMES = 1000; const int SEEK_TIMES = 1000;
double seekCur = 0;
Random rnd = new Random(); Random rnd = new Random();
uint seekPos = (uint)rnd.Next((int)results.Blocks);
for(int i = 0; i < SEEK_TIMES; i++) for(int i = 0; i < SEEK_TIMES; i++)
{ {
if(aborted) break; if(aborted) break;
seekPos = (uint)rnd.Next((int)results.Blocks); uint seekPos = (uint)rnd.Next((int)results.Blocks);
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos); DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
double seekCur;
if(scsiReader.CanSeek) scsiReader.Seek(seekPos, out seekCur); if(scsiReader.CanSeek) scsiReader.Seek(seekPos, out seekCur);
else scsiReader.ReadBlock(out readBuffer, seekPos, out seekCur); else scsiReader.ReadBlock(out _, seekPos, out seekCur);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur; if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;

View File

@@ -45,15 +45,12 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
ScanResults results = new ScanResults(); ScanResults results = new ScanResults();
bool aborted; bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf; byte[] cmdBuf;
bool sense; bool sense;
results.Blocks = 0; results.Blocks = 0;
uint[] response; const uint TIMEOUT = 5;
uint timeout = 5; double duration;
double duration = 0; const ushort SD_PROFILE = 0x0001;
ushort currentProfile = 0x0001;
uint blocksToRead = 128; uint blocksToRead = 128;
uint blockSize = 512; uint blockSize = 512;
bool byteAddressed = true; bool byteAddressed = true;
@@ -61,13 +58,10 @@ namespace DiscImageChef.Core.Devices.Scanning
switch(dev.Type) { switch(dev.Type) {
case DeviceType.MMC: case DeviceType.MMC:
{ {
ExtendedCSD ecsd = new ExtendedCSD(); sense = dev.ReadExtendedCsd(out cmdBuf, out _, TIMEOUT, out _);
CSD csd = new CSD();
sense = dev.ReadExtendedCsd(out cmdBuf, out response, timeout, out duration);
if(!sense) if(!sense)
{ {
ecsd = Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf); ExtendedCSD ecsd = Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf);
blocksToRead = ecsd.OptimalReadSize; blocksToRead = ecsd.OptimalReadSize;
results.Blocks = ecsd.SectorCount; results.Blocks = ecsd.SectorCount;
blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512); blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512);
@@ -77,10 +71,10 @@ namespace DiscImageChef.Core.Devices.Scanning
if(sense || results.Blocks == 0) if(sense || results.Blocks == 0)
{ {
sense = dev.ReadCsd(out cmdBuf, out response, timeout, out duration); sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
if(!sense) if(!sense)
{ {
csd = Decoders.MMC.Decoders.DecodeCSD(cmdBuf); CSD csd = Decoders.MMC.Decoders.DecodeCSD(cmdBuf);
results.Blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)); results.Blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2));
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength); blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
} }
@@ -89,12 +83,10 @@ namespace DiscImageChef.Core.Devices.Scanning
} }
case DeviceType.SecureDigital: case DeviceType.SecureDigital:
{ {
Decoders.SecureDigital.CSD csd = new Decoders.SecureDigital.CSD(); sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
sense = dev.ReadCsd(out cmdBuf, out response, timeout, out duration);
if(!sense) if(!sense)
{ {
csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf); Decoders.SecureDigital.CSD csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
results.Blocks = (ulong)(csd.Structure == 0 results.Blocks = (ulong)(csd.Structure == 0
? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2) ? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)
: (csd.Size + 1) * 1024); : (csd.Size + 1) * 1024);
@@ -112,11 +104,9 @@ namespace DiscImageChef.Core.Devices.Scanning
return results; return results;
} }
sense = true;
while(true) while(true)
{ {
sense = dev.Read(out cmdBuf, out response, 0, blockSize, blocksToRead, byteAddressed, timeout, sense = dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT,
out duration); out duration);
if(sense) blocksToRead /= 2; if(sense) blocksToRead /= 2;
@@ -126,7 +116,6 @@ namespace DiscImageChef.Core.Devices.Scanning
if(sense) if(sense)
{ {
blocksToRead = 1;
DicConsole.ErrorWriteLine("Device error {0} trying to guess ideal transfer length.", dev.LastError); DicConsole.ErrorWriteLine("Device error {0} trying to guess ideal transfer length.", dev.LastError);
return results; return results;
} }
@@ -150,19 +139,15 @@ namespace DiscImageChef.Core.Devices.Scanning
results.SeekTotal = 0; results.SeekTotal = 0;
const int SEEK_TIMES = 1000; const int SEEK_TIMES = 1000;
double seekCur = 0;
Random rnd = new Random(); Random rnd = new Random();
uint seekPos = (uint)rnd.Next((int)results.Blocks);
aborted = false; aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true; System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead); DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead); MhddLog mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile); IbgLog ibgLog = new IbgLog(ibgLogPath, SD_PROFILE);
start = DateTime.UtcNow; start = DateTime.UtcNow;
for(ulong i = 0; i < results.Blocks; i += blocksToRead) for(ulong i = 0; i < results.Blocks; i += blocksToRead)
@@ -178,8 +163,8 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed); DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed);
bool error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed, bool error = dev.Read(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed,
timeout, out duration); TIMEOUT, out duration);
if(!error) if(!error)
{ {
@@ -198,8 +183,7 @@ namespace DiscImageChef.Core.Devices.Scanning
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(duration < 500) mhddLog.Write(i, 65535); mhddLog.Write(i, duration < 500 ? 65535 : duration);
else mhddLog.Write(i, duration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
@@ -219,12 +203,12 @@ namespace DiscImageChef.Core.Devices.Scanning
{ {
if(aborted) break; if(aborted) break;
seekPos = (uint)rnd.Next((int)results.Blocks); uint seekPos = (uint)rnd.Next((int)results.Blocks);
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos); DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
dev.Read(out cmdBuf, out response, seekPos, blockSize, blocksToRead, byteAddressed, timeout, dev.Read(out cmdBuf, out _, seekPos, blockSize, blocksToRead, byteAddressed, TIMEOUT,
out seekCur); out double seekCur);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur; if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;

View File

@@ -44,11 +44,10 @@ namespace DiscImageChef.Core
{ {
try try
{ {
ImagePlugin imageFormat;
PluginBase plugins = new PluginBase(); PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(); plugins.RegisterAllPlugins();
imageFormat = null; ImagePlugin imageFormat = null;
// Check all but RAW plugin // Check all but RAW plugin
foreach(ImagePlugin imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin => imageplugin.PluginUuid != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) try foreach(ImagePlugin imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin => imageplugin.PluginUuid != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) try
@@ -60,10 +59,12 @@ namespace DiscImageChef.Core
break; break;
} }
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch { } catch { // ignored
}
if(imageFormat != null) return imageFormat;
// Check only RAW plugin // Check only RAW plugin
if(imageFormat == null)
foreach(ImagePlugin imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin => imageplugin.PluginUuid == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) try foreach(ImagePlugin imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin => imageplugin.PluginUuid == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) try
{ {
DicConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imageplugin.Name); DicConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imageplugin.Name);
@@ -73,11 +74,10 @@ namespace DiscImageChef.Core
break; break;
} }
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch { } catch { // ignored
}
// Still not recognized // Still not recognized
if(imageFormat == null) return null;
return imageFormat; return imageFormat;
} }
catch { return null; } catch { return null; }

View File

@@ -48,14 +48,7 @@ namespace DiscImageChef.Core.Logging
mhddFs = new FileStream(outputFile, FileMode.Create); mhddFs = new FileStream(outputFile, FileMode.Create);
string device;
string mode; string mode;
string fw;
string sn;
string sectors;
string sectorsize;
string scanblocksize;
string ver;
switch(dev.Type) switch(dev.Type)
{ {
@@ -80,15 +73,15 @@ namespace DiscImageChef.Core.Logging
break; break;
} }
device = $"DEVICE: {dev.Manufacturer} {dev.Model}"; string device = $"DEVICE: {dev.Manufacturer} {dev.Model}";
fw = $"F/W: {dev.Revision}"; string fw = $"F/W: {dev.Revision}";
sn = $"S/N: {dev.Serial}"; string sn = $"S/N: {dev.Serial}";
sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks); string sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
sectorsize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes", string sectorsize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes",
blockSize); blockSize);
scanblocksize = string.Format(new CultureInfo("en-US"), string scanblocksize = string.Format(new CultureInfo("en-US"),
"SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead); "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead);
ver = "VER:2 "; const string MHDD_VER = "VER:2 ";
byte[] deviceBytes = Encoding.ASCII.GetBytes(device); byte[] deviceBytes = Encoding.ASCII.GetBytes(device);
byte[] modeBytes = Encoding.ASCII.GetBytes(mode); byte[] modeBytes = Encoding.ASCII.GetBytes(mode);
@@ -97,7 +90,7 @@ namespace DiscImageChef.Core.Logging
byte[] sectorsBytes = Encoding.ASCII.GetBytes(sectors); byte[] sectorsBytes = Encoding.ASCII.GetBytes(sectors);
byte[] sectorsizeBytes = Encoding.ASCII.GetBytes(sectorsize); byte[] sectorsizeBytes = Encoding.ASCII.GetBytes(sectorsize);
byte[] scanblocksizeBytes = Encoding.ASCII.GetBytes(scanblocksize); byte[] scanblocksizeBytes = Encoding.ASCII.GetBytes(scanblocksize);
byte[] verBytes = Encoding.ASCII.GetBytes(ver); byte[] verBytes = Encoding.ASCII.GetBytes(MHDD_VER);
uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length + uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
sectorsBytes.Length + sectorsizeBytes.Length + scanblocksizeBytes.Length + sectorsBytes.Length + sectorsizeBytes.Length + scanblocksizeBytes.Length +

View File

@@ -45,7 +45,7 @@ namespace DiscImageChef.Core
{ {
PluginBase plugins = new PluginBase(); PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(); plugins.RegisterAllPlugins();
List<Partition> partitions = new List<Partition>(); List<Partition> foundPartitions = new List<Partition>();
List<Partition> childPartitions = new List<Partition>(); List<Partition> childPartitions = new List<Partition>();
List<ulong> checkedLocations = new List<ulong>(); List<ulong> checkedLocations = new List<ulong>();
@@ -53,11 +53,11 @@ namespace DiscImageChef.Core
if(image.ImageInfo.ImageHasPartitions) if(image.ImageInfo.ImageHasPartitions)
foreach(Partition imagePartition in image.GetPartitions()) foreach(Partition imagePartition in image.GetPartitions())
{ {
foreach(PartitionPlugin _partplugin in plugins.PartPluginsList.Values) foreach(PartitionPlugin partitionPlugin in plugins.PartPluginsList.Values)
if(_partplugin.GetInformation(image, out List<Partition> _partitions, imagePartition.Start)) if(partitionPlugin.GetInformation(image, out List<Partition> partitions, imagePartition.Start))
{ {
partitions.AddRange(_partitions); foundPartitions.AddRange(partitions);
DicConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", _partplugin.Name, DicConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", partitionPlugin.Name,
imagePartition.Start); imagePartition.Start);
} }
@@ -66,57 +66,57 @@ namespace DiscImageChef.Core
// Getting all partitions at start of device // Getting all partitions at start of device
else else
{ {
foreach(PartitionPlugin _partplugin in plugins.PartPluginsList.Values) foreach(PartitionPlugin partitionPlugin in plugins.PartPluginsList.Values)
if(_partplugin.GetInformation(image, out List<Partition> _partitions, 0)) if(partitionPlugin.GetInformation(image, out List<Partition> partitions, 0))
{ {
partitions.AddRange(_partitions); foundPartitions.AddRange(partitions);
DicConsole.DebugWriteLine("Partitions", "Found {0} @ 0", _partplugin.Name); DicConsole.DebugWriteLine("Partitions", "Found {0} @ 0", partitionPlugin.Name);
} }
checkedLocations.Add(0); checkedLocations.Add(0);
} }
while(partitions.Count > 0) while(foundPartitions.Count > 0)
{ {
if(checkedLocations.Contains(partitions[0].Start)) if(checkedLocations.Contains(foundPartitions[0].Start))
{ {
childPartitions.Add(partitions[0]); childPartitions.Add(foundPartitions[0]);
partitions.RemoveAt(0); foundPartitions.RemoveAt(0);
continue; continue;
} }
List<Partition> childs = new List<Partition>(); List<Partition> childs = new List<Partition>();
foreach(PartitionPlugin _partplugin in plugins.PartPluginsList.Values) foreach(PartitionPlugin partitionPlugin in plugins.PartPluginsList.Values)
{ {
DicConsole.DebugWriteLine("Partitions", "Trying {0} @ {1}", _partplugin.Name, partitions[0].Start); DicConsole.DebugWriteLine("Partitions", "Trying {0} @ {1}", partitionPlugin.Name, foundPartitions[0].Start);
if(!_partplugin.GetInformation(image, out List<Partition> _partitions, partitions[0].Start)) if(!partitionPlugin.GetInformation(image, out List<Partition> partitions, foundPartitions[0].Start))
continue; continue;
DicConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", _partplugin.Name, DicConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", partitionPlugin.Name,
partitions[0].Start); foundPartitions[0].Start);
childs.AddRange(_partitions); childs.AddRange(partitions);
} }
checkedLocations.Add(partitions[0].Start); checkedLocations.Add(foundPartitions[0].Start);
DicConsole.DebugWriteLine("Partitions", "Got {0} childs", childs.Count); DicConsole.DebugWriteLine("Partitions", "Got {0} childs", childs.Count);
if(childs.Count > 0) if(childs.Count > 0)
{ {
partitions.RemoveAt(0); foundPartitions.RemoveAt(0);
foreach(Partition child in childs) foreach(Partition child in childs)
if(checkedLocations.Contains(child.Start)) childPartitions.Add(child); if(checkedLocations.Contains(child.Start)) childPartitions.Add(child);
else partitions.Add(child); else foundPartitions.Add(child);
} }
else else
{ {
childPartitions.Add(partitions[0]); childPartitions.Add(foundPartitions[0]);
partitions.RemoveAt(0); foundPartitions.RemoveAt(0);
} }
DicConsole.DebugWriteLine("Partitions", "Got {0} parents", partitions.Count); DicConsole.DebugWriteLine("Partitions", "Got {0} parents", foundPartitions.Count);
DicConsole.DebugWriteLine("Partitions", "Got {0} partitions", childPartitions.Count); DicConsole.DebugWriteLine("Partitions", "Got {0} partitions", childPartitions.Count);
} }

View File

@@ -56,9 +56,7 @@ namespace DiscImageChef.Core
public void RegisterAllPlugins(Encoding encoding = null) public void RegisterAllPlugins(Encoding encoding = null)
{ {
Assembly assembly; Assembly assembly = Assembly.GetAssembly(typeof(ImagePlugin));
assembly = Assembly.GetAssembly(typeof(ImagePlugin));
foreach(Type type in assembly.GetTypes()) foreach(Type type in assembly.GetTypes())
try try

View File

@@ -73,7 +73,7 @@ namespace DiscImageChef.Core
Stream data = response.GetResponseStream(); Stream data = response.GetResponseStream();
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException()); StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
string responseFromServer = reader.ReadToEnd(); reader.ReadToEnd();
data.Close(); data.Close();
response.Close(); response.Close();
xmlStream.Close(); xmlStream.Close();

View File

@@ -313,7 +313,7 @@ namespace DiscImageChef.Core
{ {
if(!plugin.Identify(image, partitions[i])) continue; if(!plugin.Identify(image, partitions[i])) continue;
plugin.GetInformation(image, partitions[i], out string foo); plugin.GetInformation(image, partitions[i], out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
} }
@@ -346,7 +346,7 @@ namespace DiscImageChef.Core
{ {
if(!plugin.Identify(image, wholePart)) continue; if(!plugin.Identify(image, wholePart)) continue;
plugin.GetInformation(image, wholePart, out string foo); plugin.GetInformation(image, wholePart, out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
} }
@@ -541,13 +541,17 @@ namespace DiscImageChef.Core
for(byte t = scpImage.Header.start; t <= scpImage.Header.end; t++) for(byte t = scpImage.Header.start; t <= scpImage.Header.end; t++)
{ {
BlockTrackType scpBlockTrackType = new BlockTrackType(); BlockTrackType scpBlockTrackType = new BlockTrackType
scpBlockTrackType.Cylinder = t / image.ImageInfo.Heads; {
scpBlockTrackType.Head = t % image.ImageInfo.Heads; Cylinder = t / image.ImageInfo.Heads,
scpBlockTrackType.Image = new ImageType(); Head = t % image.ImageInfo.Heads,
scpBlockTrackType.Image.format = scpImage.GetImageFormat(); Image = new ImageType
scpBlockTrackType.Image.Value = Path.GetFileName(scpFilePath); {
scpBlockTrackType.Image.offset = scpImage.Header.offsets[t]; format = scpImage.GetImageFormat(),
Value = Path.GetFileName(scpFilePath),
offset = scpImage.Header.offsets[t]
}
};
if(scpBlockTrackType.Cylinder < image.ImageInfo.Cylinders) if(scpBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
{ {
@@ -626,17 +630,21 @@ namespace DiscImageChef.Core
foreach(KeyValuePair<byte, Filter> kvp in kfImage.tracks) foreach(KeyValuePair<byte, Filter> kvp in kfImage.tracks)
{ {
BlockTrackType kfBlockTrackType = new BlockTrackType(); BlockTrackType kfBlockTrackType = new BlockTrackType
kfBlockTrackType.Cylinder = kvp.Key / image.ImageInfo.Heads; {
kfBlockTrackType.Head = kvp.Key % image.ImageInfo.Heads; Cylinder = kvp.Key / image.ImageInfo.Heads,
kfBlockTrackType.Image = new ImageType(); Head = kvp.Key % image.ImageInfo.Heads,
kfBlockTrackType.Image.format = kfImage.GetImageFormat(); Image = new ImageType
kfBlockTrackType.Image.Value = {
kfDir format = kfImage.GetImageFormat(),
? Path.Combine(Path.GetFileName(Path.GetDirectoryName(kvp.Value.GetBasePath())), Value = kfDir
kvp.Value.GetFilename()) ? Path
: kvp.Value.GetFilename(); .Combine(Path.GetFileName(Path.GetDirectoryName(kvp.Value.GetBasePath())),
kfBlockTrackType.Image.offset = 0; kvp.Value.GetFilename())
: kvp.Value.GetFilename(),
offset = 0
}
};
if(kfBlockTrackType.Cylinder < image.ImageInfo.Cylinders) if(kfBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
{ {
@@ -697,12 +705,16 @@ namespace DiscImageChef.Core
foreach(int t in dfiImage.TrackOffsets.Keys) foreach(int t in dfiImage.TrackOffsets.Keys)
{ {
BlockTrackType dfiBlockTrackType = new BlockTrackType(); BlockTrackType dfiBlockTrackType = new BlockTrackType
dfiBlockTrackType.Cylinder = t / image.ImageInfo.Heads; {
dfiBlockTrackType.Head = t % image.ImageInfo.Heads; Cylinder = t / image.ImageInfo.Heads,
dfiBlockTrackType.Image = new ImageType(); Head = t % image.ImageInfo.Heads,
dfiBlockTrackType.Image.format = dfiImage.GetImageFormat(); Image = new ImageType
dfiBlockTrackType.Image.Value = Path.GetFileName(dfiFilePath); {
format = dfiImage.GetImageFormat(),
Value = Path.GetFileName(dfiFilePath)
}
};
if(dfiBlockTrackType.Cylinder < image.ImageInfo.Cylinders) if(dfiBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
{ {

View File

@@ -89,7 +89,7 @@ namespace DiscImageChef.Core
Sequence = i Sequence = i
}; };
uint sectorsToRead = 512; const uint SECTORS_TO_READ = 512;
long sectors = fs.Length / blockSize; long sectors = fs.Length / blockSize;
long doneSectors = 0; long doneSectors = 0;
@@ -98,13 +98,13 @@ namespace DiscImageChef.Core
{ {
byte[] sector; byte[] sector;
if(sectors - doneSectors >= sectorsToRead) if(sectors - doneSectors >= SECTORS_TO_READ)
{ {
sector = new byte[sectorsToRead * blockSize]; sector = new byte[SECTORS_TO_READ * blockSize];
fs.Read(sector, 0, sector.Length); fs.Read(sector, 0, sector.Length);
UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}", UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}",
doneSectors, sectors); doneSectors, sectors);
doneSectors += sectorsToRead; doneSectors += SECTORS_TO_READ;
} }
else else
{ {

View File

@@ -44,39 +44,37 @@ namespace DiscImageChef.Core
public static void InitProgress() public static void InitProgress()
{ {
if(InitProgressEvent != null) InitProgressEvent(); InitProgressEvent?.Invoke();
} }
public static void UpdateProgress(string text, long current, long maximum) public static void UpdateProgress(string text, long current, long maximum)
{ {
if(UpdateProgressEvent != null) UpdateProgressEvent?.Invoke(string.Format(text, current, maximum), current, maximum);
UpdateProgressEvent(string.Format(text, current, maximum), current, maximum);
} }
public static void EndProgress() public static void EndProgress()
{ {
if(EndProgressEvent != null) EndProgressEvent(); EndProgressEvent?.Invoke();
} }
public static void InitProgress2() public static void InitProgress2()
{ {
if(InitProgressEvent2 != null) InitProgressEvent2(); InitProgressEvent2?.Invoke();
} }
public static void UpdateProgress2(string text, long current, long maximum) public static void UpdateProgress2(string text, long current, long maximum)
{ {
if(UpdateProgressEvent2 != null) UpdateProgressEvent2?.Invoke(string.Format(text, current, maximum), current, maximum);
UpdateProgressEvent2(string.Format(text, current, maximum), current, maximum);
} }
public static void EndProgress2() public static void EndProgress2()
{ {
if(EndProgressEvent2 != null) EndProgressEvent2(); EndProgressEvent2?.Invoke();
} }
public static void UpdateStatus(string text, params object[] args) public static void UpdateStatus(string text, params object[] args)
{ {
if(UpdateStatusEvent != null) UpdateStatusEvent(string.Format(text, args)); UpdateStatusEvent?.Invoke(string.Format(text, args));
} }
} }
} }

View File

@@ -235,7 +235,7 @@ namespace DiscImageChef.Core
try try
{ {
List<Session> sessions = image.GetSessions(); List<Session> sessions = image.GetSessions();
sidecar.OpticalDisc[0].Sessions = sessions != null ? sessions.Count : 1; sidecar.OpticalDisc[0].Sessions = sessions?.Count ?? 1;
} }
catch { sidecar.OpticalDisc[0].Sessions = 1; } catch { sidecar.OpticalDisc[0].Sessions = 1; }
@@ -473,7 +473,7 @@ namespace DiscImageChef.Core
{ {
if(!plugin.Identify(image, partitions[i])) continue; if(!plugin.Identify(image, partitions[i])) continue;
plugin.GetInformation(image, partitions[i], out string foo); plugin.GetInformation(image, partitions[i], out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);
@@ -520,7 +520,7 @@ namespace DiscImageChef.Core
{ {
if(!plugin.Identify(image, xmlPart)) continue; if(!plugin.Identify(image, xmlPart)) continue;
plugin.GetInformation(image, xmlPart, out string foo); plugin.GetInformation(image, xmlPart, out _);
lstFs.Add(plugin.XmlFSType); lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type); Statistics.AddFilesystem(plugin.XmlFSType.Type);

View File

@@ -173,7 +173,7 @@ namespace DiscImageChef.Core
submitStatsLock = true; submitStatsLock = true;
var statsFiles = Directory.EnumerateFiles(Settings.Settings.StatsPath, "PartialStats_*.xml", IEnumerable<string> statsFiles = Directory.EnumerateFiles(Settings.Settings.StatsPath, "PartialStats_*.xml",
SearchOption.TopDirectoryOnly); SearchOption.TopDirectoryOnly);
foreach(string statsFile in statsFiles) foreach(string statsFile in statsFiles)
@@ -366,7 +366,7 @@ namespace DiscImageChef.Core
CurrentStats.Filesystems.Add(nw); CurrentStats.Filesystems.Add(nw);
} }
public static void AddPartition(string partition) internal static void AddPartition(string partition)
{ {
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.PartitionStats) return; if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.PartitionStats) return;
@@ -502,24 +502,28 @@ namespace DiscImageChef.Core
if(old != null) AllStats.Devices.Remove(old); if(old != null) AllStats.Devices.Remove(old);
DeviceStats nw = new DeviceStats(); DeviceStats nw = new DeviceStats
nw.Model = dev.Model; {
nw.Manufacturer = dev.Manufacturer; Model = dev.Model,
nw.Revision = dev.Revision; Manufacturer = dev.Manufacturer,
nw.Bus = deviceBus; Revision = dev.Revision,
nw.ManufacturerSpecified = true; Bus = deviceBus,
ManufacturerSpecified = true
};
AllStats.Devices.Add(nw); AllStats.Devices.Add(nw);
old = CurrentStats.Devices.FirstOrDefault(ds => ds.Manufacturer == dev.Manufacturer && ds.Model == dev.Model && ds.Revision == dev.Revision && ds.Bus == deviceBus); old = CurrentStats.Devices.FirstOrDefault(ds => ds.Manufacturer == dev.Manufacturer && ds.Model == dev.Model && ds.Revision == dev.Revision && ds.Bus == deviceBus);
if(old != null) CurrentStats.Devices.Remove(old); if(old != null) CurrentStats.Devices.Remove(old);
nw = new DeviceStats(); nw = new DeviceStats
nw.Model = dev.Model; {
nw.Manufacturer = dev.Manufacturer; Model = dev.Model,
nw.Revision = dev.Revision; Manufacturer = dev.Manufacturer,
nw.Bus = deviceBus; Revision = dev.Revision,
nw.ManufacturerSpecified = true; Bus = deviceBus,
ManufacturerSpecified = true
};
CurrentStats.Devices.Add(nw); CurrentStats.Devices.Add(nw);
} }
@@ -572,16 +576,10 @@ namespace DiscImageChef.Core
{ {
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.BenchmarkStats) return; if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.BenchmarkStats) return;
CurrentStats.Benchmark = new BenchmarkStats(); CurrentStats.Benchmark = new BenchmarkStats {Checksum = new List<ChecksumStats>()};
CurrentStats.Benchmark.Checksum = new List<ChecksumStats>(); AllStats.Benchmark = new BenchmarkStats {Checksum = new List<ChecksumStats>()};
AllStats.Benchmark = new BenchmarkStats();
AllStats.Benchmark.Checksum = new List<ChecksumStats>();
foreach(KeyValuePair<string, double> kvp in checksums) foreach(ChecksumStats st in checksums.Select(kvp => new ChecksumStats {algorithm = kvp.Key, Value = kvp.Value})) {
{
ChecksumStats st = new ChecksumStats();
st.algorithm = kvp.Key;
st.Value = kvp.Value;
CurrentStats.Benchmark.Checksum.Add(st); CurrentStats.Benchmark.Checksum.Add(st);
AllStats.Benchmark.Checksum.Add(st); AllStats.Benchmark.Checksum.Add(st);
} }
@@ -605,17 +603,12 @@ namespace DiscImageChef.Core
if(CurrentStats.Verify == null) if(CurrentStats.Verify == null)
{ {
CurrentStats.Verify = new VerifyStats(); CurrentStats.Verify =
CurrentStats.Verify.MediaImages = new VerifiedItems(); new VerifyStats {MediaImages = new VerifiedItems(), Sectors = new ScannedSectors()};
CurrentStats.Verify.Sectors = new ScannedSectors();
} }
if(AllStats.Verify == null) if(AllStats.Verify == null)
{ { AllStats.Verify = new VerifyStats {MediaImages = new VerifiedItems(), Sectors = new ScannedSectors()}; }
AllStats.Verify = new VerifyStats();
AllStats.Verify.MediaImages = new VerifiedItems();
AllStats.Verify.Sectors = new ScannedSectors();
}
if(mediaVerified.HasValue) if(mediaVerified.HasValue)
if(mediaVerified.Value) if(mediaVerified.Value)
@@ -646,18 +639,10 @@ namespace DiscImageChef.Core
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaScanStats) return; if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaScanStats) return;
if(CurrentStats.MediaScan == null) if(CurrentStats.MediaScan == null)
{ { CurrentStats.MediaScan = new MediaScanStats {Sectors = new ScannedSectors(), Times = new TimeStats()}; }
CurrentStats.MediaScan = new MediaScanStats();
CurrentStats.MediaScan.Sectors = new ScannedSectors();
CurrentStats.MediaScan.Times = new TimeStats();
}
if(AllStats.MediaScan == null) if(AllStats.MediaScan == null)
{ { AllStats.MediaScan = new MediaScanStats {Sectors = new ScannedSectors(), Times = new TimeStats()}; }
AllStats.MediaScan = new MediaScanStats();
AllStats.MediaScan.Sectors = new ScannedSectors();
AllStats.MediaScan.Times = new TimeStats();
}
CurrentStats.MediaScan.Sectors.Correct += correct; CurrentStats.MediaScan.Sectors.Correct += correct;
CurrentStats.MediaScan.Sectors.Error += error; CurrentStats.MediaScan.Sectors.Error += error;

View File

@@ -80,7 +80,7 @@ namespace DiscImageChef.Commands
break; break;
case DeviceType.MMC: case DeviceType.MMC:
case DeviceType.SecureDigital: case DeviceType.SecureDigital:
SecureDigital.Report(dev, ref report, options.Debug, ref removable); SecureDigital.Report(dev, ref report);
break; break;
case DeviceType.NVMe: case DeviceType.NVMe:
Nvme.Report(dev, ref report, options.Debug, ref removable); Nvme.Report(dev, ref report, options.Debug, ref removable);