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

@@ -59,8 +59,6 @@ namespace DiscImageChef.Core.Devices.Dumping
ref DumpLog dumpLog, Encoding encoding)
{
bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
if(dumpRaw)
{
@@ -75,12 +73,11 @@ namespace DiscImageChef.Core.Devices.Dumping
}
bool sense;
ushort currentProfile = 0x0001;
uint timeout = 5;
double duration;
const ushort ATA_PROFILE = 0x0001;
const uint TIMEOUT = 5;
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)
{
Identify.IdentifyDevice? ataIdNullable = Identify.Decode(cmdBuf);
@@ -170,7 +167,6 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
Checksum dataChk;
aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
@@ -179,7 +175,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Initializate reader
dumpLog.WriteLine("Initializing reader.");
Reader ataReader = new Reader(dev, timeout, cmdBuf);
Reader ataReader = new Reader(dev, TIMEOUT, cmdBuf);
// Fill reader blocks
ulong blocks = ataReader.GetDeviceBlocks();
// 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 physical block.", physicalsectorsize);
bool removable = false || !dev.IsCompactFlash &&
bool removable = !dev.IsCompactFlash &&
ataId.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit
.Removable);
DumpHardwareType currentTry = null;
@@ -228,12 +224,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(currentTry == null || extents == null)
throw new Exception("Could not process resume file, not continuing...");
MhddLog mhddLog;
IbgLog ibgLog;
double duration;
if(ataReader.IsLba)
{
DicConsole.WriteLine("Reading {0} sectors at a time.", 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");
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);
if(duration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, duration);
mhddLog.Write(i, duration < 500 ? 65535 : duration);
ibgLog.Write(i, 0);
dumpFile.Write(new byte[blockSize * blocksToRead]);
@@ -348,7 +346,7 @@ namespace DiscImageChef.Core.Devices.Dumping
else
{
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");
ulong currentBlock = 0;
@@ -390,8 +388,7 @@ namespace DiscImageChef.Core.Devices.Dumping
else
{
resume.BadBlocks.Add(currentBlock);
if(duration < 500) mhddLog.Write(currentBlock, 65535);
else mhddLog.Write(currentBlock, duration);
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
ibgLog.Write(currentBlock, 0);
dumpFile.Write(new byte[blockSize]);
@@ -416,7 +413,7 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
}
dataChk = new Checksum();
Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500;
@@ -454,7 +451,6 @@ namespace DiscImageChef.Core.Devices.Dumping
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
@@ -465,7 +461,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
imageFormat = ImageFormat.Detect(inputFilter);
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -503,7 +499,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
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);
Statistics.AddFilesystem(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;
plugin.GetInformation(imageFormat, wholePart, out string foo);
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(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 DumpLog dumpLog, Alcohol120 alcohol, bool dumpLeadIn)
{
MhddLog mhddLog;
IbgLog ibgLog;
bool sense = false;
ulong blocks;
// TODO: Check subchannel support
uint blockSize;
uint subSize;
byte[] tmpBuf;
FullTOC.CDFullTOC? toc = null;
DateTime start;
DateTime end;
@@ -77,9 +74,7 @@ namespace DiscImageChef.Core.Devices.Dumping
double minSpeed = double.MaxValue;
Checksum dataChk;
bool readcd;
byte[] readBuffer;
uint blocksToRead = 64;
ulong errored = 0;
DataFile dumpFile;
bool aborted = false;
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
// No TOC, no CD (or an empty one)
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)
{
toc = FullTOC.Decode(cmdBuf);
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);
sidecar.OpticalDisc[0].TOC = new DumpType
{
@@ -105,7 +100,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// ATIP exists on blank CDs
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)
{
ATIP.CDATIP? atip = ATIP.Decode(cmdBuf);
@@ -129,7 +124,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading Disc Information");
sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf,
MmcDiscInformationDataTypes.DiscInformation, dev.Timeout,
out duration);
out _);
if(!sense)
{
DiscInformation.StandardDiscInformation? discInfo =
@@ -151,7 +146,7 @@ namespace DiscImageChef.Core.Devices.Dumping
int firstTrackLastSession = 0;
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)
{
Session.CDSessionInfo? session = Session.Decode(cmdBuf);
@@ -194,7 +189,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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(PMA.Decode(cmdBuf).HasValue)
{
@@ -210,7 +205,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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(CDTextOnLeadIn.Decode(cmdBuf).HasValue)
{
@@ -319,8 +314,7 @@ namespace DiscImageChef.Core.Devices.Dumping
phour = trk.PHOUR;
}
if(phour > 0) lastMsf = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe, phour);
else lastMsf = $"{pmin:D2}:{psec:D2}:{pframe:D2}";
lastMsf = phour > 0 ? $"{phour:D2}:{pmin:D2}:{psec:D2}:{pframe:D2}" : $"{pmin:D2}:{psec:D2}:{pframe:D2}";
lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150;
}
@@ -347,9 +341,7 @@ namespace DiscImageChef.Core.Devices.Dumping
pframe -= psec * 75;
}
if(phour > 0)
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[t - 1].EndMSF = phour > 0 ? $"{phour:D2}:{pmin:D2}:{psec:D2}:{pframe:D2}" : $"{pmin:D2}:{psec:D2}:{pframe:D2}";
}
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");
// 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,
MmcSubchannel.Raw, dev.Timeout, out duration);
MmcSubchannel.Raw, dev.Timeout, out _);
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,
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;
}
@@ -490,8 +482,8 @@ namespace DiscImageChef.Core.Devices.Dumping
alcohol.SetExtension(".bin");
DataFile subFile = null;
if(separateSubchannel) subFile = new DataFile(outputPrefix + ".sub");
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0008);
MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0008);
dumpFile.Seek(resume.NextBlock, (ulong)sectorSize);
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);
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);
@@ -589,13 +581,11 @@ namespace DiscImageChef.Core.Devices.Dumping
}
else dumpFile.Write(new byte[blockSize * blocksToRead]);
errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf));
if(cmdDuration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, cmdDuration);
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
dumpLog.WriteLine("Error reading {0} sectors from sector {1}.", blocksToRead, i);
@@ -691,8 +681,6 @@ namespace DiscImageChef.Core.Devices.Dumping
break;
}
double cmdDuration;
DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1,
forward ? "forward" : "reverse",
runningPersistent ? "recovering partial data, " : "");
@@ -701,7 +689,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)badSector, blockSize, blocksToRead,
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;
}
@@ -731,25 +719,12 @@ namespace DiscImageChef.Core.Devices.Dumping
goto cdRepeatRetry;
}
Modes.DecodedMode? currentMode = null;
Modes.ModePage? currentModePage = null;
byte[] md6;
byte[] md10;
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 =
new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20};
Modes.DecodedMode md = new Modes.DecodedMode
@@ -769,8 +744,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) sense = dev.ModeSelect10(md10, 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 _);
runningPersistent = true;
if(!sense && !dev.Error)
@@ -790,8 +765,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out _);
if(sense) dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out _);
}
DicConsole.WriteLine();
@@ -807,7 +782,7 @@ namespace DiscImageChef.Core.Devices.Dumping
blocksToRead = 500;
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 subChk = new Checksum();
@@ -857,8 +832,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
tracks[t].Checksums = trkChk.End().ToArray();
if(separateSubchannel) tracks[t].SubChannel.Checksums = subChk.End().ToArray();
else tracks[t].SubChannel.Checksums = tracks[t].Checksums;
tracks[t].SubChannel.Checksums = separateSubchannel ? subChk.End().ToArray() : tracks[t].Checksums;
}
DicConsole.WriteLine();
@@ -877,7 +851,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Value = outputPrefix + ".bin"
};
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].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
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 DumpLog dumpLog, bool dumpLeadIn, Encoding encoding)
{
byte[] cmdBuf;
byte[] senseBuf;
bool sense;
double duration;
ulong blocks = 0;
ulong blocks;
byte[] tmpBuf;
bool compactDisc = true;
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.
sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout,
out duration);
sense = dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, dev.Timeout,
out _);
if(!sense)
{
Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);
@@ -188,8 +185,8 @@ namespace DiscImageChef.Core.Devices.Dumping
switch(dskType) {
case MediaType.Unknown when blocks > 0:
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
if(!sense)
{
PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf);
@@ -222,8 +219,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.HDDVDRW:
case MediaType.HDDVDRWDL:
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
if(!sense)
{
alcohol.AddPfi(cmdBuf);
@@ -259,8 +256,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.DVDPRWDL;
break;
case DiskCategory.DVDR:
if(decPfi.PartVersion == 6) dskType = MediaType.DVDRDL;
else dskType = MediaType.DVDR;
dskType = decPfi.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR;
break;
case DiskCategory.DVDRAM:
dskType = MediaType.DVDRAM;
@@ -269,8 +265,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.DVDROM;
break;
case DiskCategory.DVDRW:
if(decPfi.PartVersion == 3) dskType = MediaType.DVDRWDL;
else dskType = MediaType.DVDRW;
dskType = decPfi.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW;
break;
case DiskCategory.HDDVDR:
dskType = MediaType.HDDVDR;
@@ -285,8 +280,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.HDDVDRW;
break;
case DiskCategory.Nintendo:
if(decPfi.DiscSize == DVDSize.Eighty) dskType = MediaType.GOD;
else dskType = MediaType.WOD;
dskType = decPfi.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD;
break;
case DiskCategory.UMD:
dskType = MediaType.UMD;
@@ -296,9 +290,9 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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,
out duration);
out _);
if(!sense)
{
if(DMI.IsXbox(cmdBuf) || DMI.IsXbox360(cmdBuf))
@@ -315,7 +309,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.XGD3;
}
sense = dev.ScsiInquiry(out byte[] inqBuf, out senseBuf);
sense = dev.ScsiInquiry(out byte[] inqBuf, out _);
if(sense || !Inquiry.Decode(inqBuf).HasValue ||
Inquiry.Decode(inqBuf).HasValue &&
@@ -364,9 +358,9 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dskType == MediaType.DVDDownload || dskType == MediaType.DVDROM)
{
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,
out duration);
out _);
if(!sense)
if(CSS_CPRM.DecodeLeadInCopyright(cmdBuf).HasValue)
{
@@ -394,8 +388,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDROM:
case MediaType.HDDVDROM:
dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -415,8 +409,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDRAM:
case MediaType.HDDVDRAM:
dumpLog.WriteLine("Reading Disc Description Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out _);
if(!sense)
if(DDS.Decode(cmdBuf).HasValue)
{
@@ -432,9 +426,9 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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,
out duration);
out _);
if(!sense)
if(Spare.Decode(cmdBuf).HasValue)
{
@@ -454,8 +448,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDR:
case MediaType.DVDRW:
dumpLog.WriteLine("Reading Pre-Recorded Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -478,9 +472,9 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDRW:
case MediaType.HDDVDR:
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,
out duration);
out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -495,9 +489,9 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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,
out duration);
out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -518,8 +512,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.DVDPRW:
case MediaType.DVDPRWDL:
dumpLog.WriteLine("Reading ADdress In Pregroove.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Adip, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Adip, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -534,8 +528,8 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Reading Disc Control Blocks.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -553,9 +547,9 @@ namespace DiscImageChef.Core.Devices.Dumping
#region HD DVD-ROM
case MediaType.HDDVDROM:
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,
out duration);
out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -577,8 +571,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.BDRXL:
case MediaType.BDREXL:
dumpLog.WriteLine("Reading Disc Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out _);
if(!sense)
if(DI.Decode(cmdBuf).HasValue)
{
@@ -594,8 +588,8 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Reading PAC.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.Pac, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.Pac, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -616,8 +610,8 @@ namespace DiscImageChef.Core.Devices.Dumping
#region BD-ROM only
case MediaType.BDROM:
dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -639,8 +633,8 @@ namespace DiscImageChef.Core.Devices.Dumping
case MediaType.BDRXL:
case MediaType.BDREXL:
dumpLog.WriteLine("Reading Disc Definition Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out duration);
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -655,9 +649,9 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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,
out duration);
out _);
if(!sense)
{
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 DumpLog dumpLog, Encoding encoding, Alcohol120 alcohol = null)
{
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf;
byte[] senseBuf;
bool sense;
double duration;
ulong blocks;
uint blockSize;
uint logicalBlockSize;
@@ -73,7 +68,7 @@ namespace DiscImageChef.Core.Devices.Dumping
byte scsiMediumType = 0;
byte scsiDensityCode = 0;
bool containsFloppyPage = false;
ushort currentProfile = 0x0001;
const ushort SBC_PROFILE = 0x0001;
DateTime start;
DateTime end;
double totalDuration = 0;
@@ -81,11 +76,8 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
Checksum dataChk;
byte[] readBuffer;
uint blocksToRead = 64;
ulong errored = 0;
DataFile dumpFile;
uint blocksToRead;
bool aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
@@ -125,25 +117,6 @@ namespace DiscImageChef.Core.Devices.Dumping
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)
{
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);
}
byte[] cmdBuf;
if(dev.Type == DeviceType.ATAPI)
{
dumpLog.WriteLine("Requesting ATAPI IDENTIFY PACKET DEVICE.");
sense = dev.AtapiIdentify(out cmdBuf, out AtaErrorRegistersCHS errorRegs);
sense = dev.AtapiIdentify(out cmdBuf, out _);
if(!sense)
{
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)
{
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);
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)
{
byte[] pages = EVPD.DecodePage00(cmdBuf);
@@ -215,7 +189,7 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(byte page in pages)
{
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;
EVPDType evpd = new EVPDType
@@ -234,11 +208,11 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Requesting MODE SENSE (10).");
sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out duration);
sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out _);
if(!sense || dev.Error)
sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration);
sense = dev.ModeSense10(out cmdBuf, out _, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _);
Modes.DecodedMode? decMode = null;
@@ -256,12 +230,12 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Requesting MODE SENSE (6).");
sense = dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out duration);
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
if(sense || dev.Error)
sense = dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out duration);
if(sense || dev.Error) sense = dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out _);
if(sense || dev.Error) sense = dev.ModeSense(out cmdBuf, out _, 5, out _);
if(!sense && !dev.Error)
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;
if(dumpRaw)
if(blockSize == longBlockSize)
{
if(!scsiReader.CanReadRaw) DicConsole.ErrorWriteLine("Device doesn't seem capable of reading raw data from media.");
else
DicConsole
.ErrorWriteLine("Device is capable of reading raw data but I've been unable to guess correct sector size.");
DicConsole.ErrorWriteLine(!scsiReader.CanReadRaw
? "Device doesn't seem capable of reading raw data from media."
: "Device is capable of reading raw data but I've been unable to guess correct sector size.");
if(!force)
{
@@ -312,10 +304,8 @@ namespace DiscImageChef.Core.Devices.Dumping
}
else
{
if(longBlockSize == 37856
) // Only a block will be read, but it contains 16 sectors and command expect sector number not block number
blocksToRead = 16;
else blocksToRead = 1;
// 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);
DicConsole.WriteLine("Reading {0} raw bytes ({1} cooked bytes) per sector.", longBlockSize,
blockSize * blocksToRead);
physicalBlockSize = longBlockSize;
@@ -326,9 +316,9 @@ namespace DiscImageChef.Core.Devices.Dumping
string outputExtension = ".bin";
if(opticalDisc && blockSize == 2048) outputExtension = ".iso";
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", currentProfile);
dumpFile = new DataFile(outputPrefix + outputExtension);
MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", SBC_PROFILE);
DataFile dumpFile = new DataFile(outputPrefix + outputExtension);
start = DateTime.UtcNow;
@@ -387,11 +377,9 @@ namespace DiscImageChef.Core.Devices.Dumping
// Write empty data
dumpFile.Write(new byte[blockSize * blocksToRead]);
errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, cmdDuration);
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, i);
@@ -454,25 +442,12 @@ namespace DiscImageChef.Core.Devices.Dumping
goto repeatRetry;
}
Modes.DecodedMode? currentMode = null;
Modes.ModePage? currentModePage = null;
byte[] md6;
byte[] md10;
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)
{
Modes.ModePage_01_MMC pgMmc =
@@ -531,8 +506,8 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) sense = dev.ModeSelect10(md10, 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 _, true, false, dev.Timeout, out _);
runningPersistent = true;
if(!sense && !dev.Error)
@@ -552,8 +527,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
sense = dev.ModeSelect(md6, out _, true, false, dev.Timeout, out _);
if(sense) dev.ModeSelect10(md10, out _, true, false, dev.Timeout, out _);
}
DicConsole.WriteLine();
@@ -563,7 +538,7 @@ namespace DiscImageChef.Core.Devices.Dumping
resume.BadBlocks.Sort();
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dataChk = new Checksum();
Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500;
@@ -601,7 +576,6 @@ namespace DiscImageChef.Core.Devices.Dumping
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + outputExtension);
@@ -611,7 +585,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
imageFormat = ImageFormat.Detect(inputFilter);
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -648,7 +622,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
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);
Statistics.AddFilesystem(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;
plugin.GetInformation(imageFormat, wholePart, out string foo);
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(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,
ref Resume resume, ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding)
{
byte[] senseBuf;
bool sense;
MediaType dskType = MediaType.Unknown;
int resets = 0;
if(dev.IsRemovable)
{
deviceGotReset:
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out double duration);
bool sense = dev.ScsiTestUnitReady(out byte[] senseBuf, dev.Timeout, out _);
if(sense)
{
FixedSense? decSense = Sense.DecodeFixed(senseBuf);
@@ -81,7 +79,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break;
decSense = Sense.DecodeFixed(senseBuf);
@@ -104,7 +102,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break;
decSense = Sense.DecodeFixed(senseBuf);
@@ -141,7 +139,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
DicConsole.WriteLine("\rWaiting for drive to become ready");
Thread.Sleep(2000);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration);
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);
if(!sense) break;
decSense = Sense.DecodeFixed(senseBuf);

View File

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

View File

@@ -57,8 +57,6 @@ namespace DiscImageChef.Core.Devices.Dumping
ref DumpLog dumpLog, Encoding encoding)
{
bool aborted;
MhddLog mhddLog;
IbgLog ibgLog;
if(dumpRaw)
{
@@ -73,8 +71,8 @@ namespace DiscImageChef.Core.Devices.Dumping
}
bool sense;
ushort currentProfile = 0x0001;
uint timeout = 5;
const ushort SD_PROFILE = 0x0001;
const uint TIMEOUT = 5;
double duration;
CICMMetadataType sidecar =
@@ -83,26 +81,21 @@ namespace DiscImageChef.Core.Devices.Dumping
uint blocksToRead = 128;
uint blockSize = 512;
ulong blocks = 0;
byte[] cid;
byte[] csd = null;
byte[] ocr = null;
byte[] ecsd = null;
byte[] scr = null;
uint[] response;
int physicalBlockSize = 0;
bool byteAddressed = true;
switch(dev.Type) {
case DeviceType.MMC:
{
ExtendedCSD ecsdDecoded = new ExtendedCSD();
CSD csdDecoded = new 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)
{
ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
ExtendedCSD ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
blocksToRead = ecsdDecoded.OptimalReadSize;
blocks = ecsdDecoded.SectorCount;
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
@@ -114,12 +107,12 @@ namespace DiscImageChef.Core.Devices.Dumping
else ecsd = null;
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(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));
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
}
@@ -127,7 +120,7 @@ namespace DiscImageChef.Core.Devices.Dumping
else csd = null;
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;
sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType();
@@ -135,13 +128,11 @@ namespace DiscImageChef.Core.Devices.Dumping
}
case DeviceType.SecureDigital:
{
Decoders.SecureDigital.CSD csdDecoded = new Decoders.SecureDigital.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)
{
csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
blocks = (ulong)(csdDecoded.Structure == 0
? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
: (csdDecoded.Size + 1) * 1024);
@@ -152,11 +143,11 @@ namespace DiscImageChef.Core.Devices.Dumping
else csd = null;
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;
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;
sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType();
@@ -165,7 +156,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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;
DumpType cidDump = null;
@@ -182,7 +173,7 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("MMC/SecureDigital Dump", cidDump.Image, cid);
}
;
if(csd != null)
{
csdDump = new DumpType
@@ -193,7 +184,7 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("MMC/SecureDigital Dump", csdDump.Image, csd);
}
;
if(ecsd != null)
{
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,
ecsd);
}
;
if(ocr != null)
{
ocrDump = new DumpType
@@ -216,7 +207,7 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("MMC/SecureDigital Dump", ocrDump.Image, ocr);
}
;
if(scr != null)
{
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);
}
;
switch(dev.Type) {
case DeviceType.MMC:
@@ -249,13 +240,10 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
Checksum dataChk;
aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
DataFile dumpFile;
if(blocks == 0)
{
dumpLog.WriteLine("Cannot get device size.");
@@ -266,11 +254,11 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Device reports {0} blocks.", blocks);
byte[] cmdBuf;
bool error = true;
bool error;
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);
if(error) blocksToRead /= 2;
@@ -280,7 +268,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(error)
{
blocksToRead = 1;
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);
return;
@@ -297,9 +284,9 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(outputPrefix + ".ibg", currentProfile);
dumpFile = new DataFile(outputPrefix + ".bin");
MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", SD_PROFILE);
DataFile dumpFile = new DataFile(outputPrefix + ".bin");
dumpFile.Seek(resume.NextBlock, blockSize);
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);
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);
if(!error)
@@ -336,8 +323,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
if(duration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, duration);
mhddLog.Write(i, duration < 500 ? 65535 : duration);
ibgLog.Write(i, 0);
dumpFile.Write(new byte[blockSize * blocksToRead]);
@@ -380,7 +366,7 @@ namespace DiscImageChef.Core.Devices.Dumping
forward ? "forward" : "reverse",
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);
totalDuration += duration;
@@ -410,7 +396,7 @@ namespace DiscImageChef.Core.Devices.Dumping
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dataChk = new Checksum();
Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin);
blocksToRead = 500;
@@ -448,7 +434,6 @@ namespace DiscImageChef.Core.Devices.Dumping
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
@@ -459,7 +444,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
imageFormat = ImageFormat.Detect(inputFilter);
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -496,7 +481,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
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);
Statistics.AddFilesystem(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;
plugin.GetInformation(imageFormat, wholePart, out string foo);
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(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);
break;
}
sidecar.BlockMedia[0].DiskType = xmlDskTyp;
sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp;
// TODO: Implement device firmware revision
@@ -569,6 +555,7 @@ namespace DiscImageChef.Core.Devices.Dumping
case DeviceType.SecureDigital: sidecar.BlockMedia[0].Interface = "SecureDigital";
break;
}
sidecar.BlockMedia[0].LogicalBlocks = (long)blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize > 0 ? physicalBlockSize : (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,
Encoding encoding)
{
MhddLog mhddLog;
IbgLog ibgLog;
bool sense;
ulong blocks;
uint blockSize = 2048;
const uint BLOCK_SIZE = 2048;
uint blocksToRead = 64;
ulong errored = 0;
DateTime start;
DateTime end;
double totalDuration = 0;
@@ -74,13 +71,11 @@ namespace DiscImageChef.Core.Devices.Dumping
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
Checksum dataChk;
DataFile dumpFile;
bool aborted = false;
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
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)
{
dumpLog.WriteLine("Cannot get Xbox Security Sector, not continuing.");
@@ -123,7 +118,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Get video partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting video partition size");
dumpLog.WriteLine("Locking drive.");
sense = dev.KreonLock(out senseBuf, dev.Timeout, out duration);
sense = dev.KreonLock(out senseBuf, dev.Timeout, out _);
if(sense)
{
dumpLog.WriteLine("Cannot lock drive, not continuing.");
@@ -132,7 +127,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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)
{
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]);
dumpLog.WriteLine("Reading Physical Format Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration);
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
if(sense)
{
dumpLog.WriteLine("Cannot get PFI.");
@@ -166,7 +161,7 @@ namespace DiscImageChef.Core.Devices.Dumping
l1Video = totalSize - l0Video + 1;
dumpLog.WriteLine("Reading Disc Manufacturing Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out duration);
MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _);
if(sense)
{
dumpLog.WriteLine("Cannot get DMI.");
@@ -187,7 +182,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Get game partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting game partition size");
dumpLog.WriteLine("Unlocking drive (Xtreme).");
sense = dev.KreonUnlockXtreme(out senseBuf, dev.Timeout, out duration);
sense = dev.KreonUnlockXtreme(out senseBuf, dev.Timeout, out _);
if(sense)
{
dumpLog.WriteLine("Cannot unlock drive, not continuing.");
@@ -196,7 +191,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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)
{
dumpLog.WriteLine("Cannot get disc capacity.");
@@ -211,7 +206,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// Get middle zone size
DicConsole.DebugWriteLine("Dump-media command", "Getting middle zone size");
dumpLog.WriteLine("Unlocking drive (Wxripper).");
sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out duration);
sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out _);
if(sense)
{
dumpLog.WriteLine("Cannot unlock drive, not continuing.");
@@ -220,7 +215,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
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)
{
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]);
dumpLog.WriteLine("Reading Physical Format Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out duration);
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
if(sense)
{
dumpLog.WriteLine("Cannot get PFI.");
@@ -256,7 +251,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading Disc Manufacturing Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out duration);
MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _);
if(sense)
{
dumpLog.WriteLine("Cannot get DMI.");
@@ -292,8 +287,8 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Total 0 size: {0} sectors", totalSize);
dumpLog.WriteLine("Real layer break: {0}", layerBreak);
bool read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, 1,
false, dev.Timeout, out duration);
bool read12 = !dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, BLOCK_SIZE, 0, 1,
false, dev.Timeout, out _);
if(!read12)
{
dumpLog.WriteLine("Cannot read medium, aborting scan...");
@@ -308,8 +303,8 @@ namespace DiscImageChef.Core.Devices.Dumping
{
if(read12)
{
sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, blockSize, 0,
blocksToRead, false, dev.Timeout, out duration);
sense = dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, BLOCK_SIZE, 0,
blocksToRead, false, dev.Timeout, out _);
if(sense || dev.Error) blocksToRead /= 2;
}
@@ -326,9 +321,9 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.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);
ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0010);
dumpFile = new DataFile(outputPrefix + ".iso");
MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, BLOCK_SIZE, blocksToRead);
IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", 0x0010);
DataFile dumpFile = new DataFile(outputPrefix + ".iso");
start = DateTime.UtcNow;
@@ -342,7 +337,7 @@ namespace DiscImageChef.Core.Devices.Dumping
throw new Exception("Could not process resume file, not continuing...");
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);
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);
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);
totalDuration += cmdDuration;
@@ -419,15 +414,13 @@ namespace DiscImageChef.Core.Devices.Dumping
if(stopOnError) return; // TODO: Return more cleanly
// 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);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf));
if(cmdDuration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, cmdDuration);
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
@@ -437,7 +430,7 @@ namespace DiscImageChef.Core.Devices.Dumping
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;
currentSector = i + 1;
resume.NextBlock = currentSector;
@@ -485,7 +478,7 @@ namespace DiscImageChef.Core.Devices.Dumping
mhddLog.Write(middle + currentSector, cmdDuration);
ibgLog.Write(middle + currentSector, currentSpeed * 1024);
dumpFile.Write(new byte[blockSize * blocksToRead]);
dumpFile.Write(new byte[BLOCK_SIZE * blocksToRead]);
extents.Add(currentSector, blocksToRead, true);
currentSector += blocksToRead;
@@ -495,7 +488,7 @@ namespace DiscImageChef.Core.Devices.Dumping
blocksToRead = saveBlocksToRead;
dumpLog.WriteLine("Locking drive.");
sense = dev.KreonLock(out senseBuf, dev.Timeout, out duration);
sense = dev.KreonLock(out senseBuf, dev.Timeout, out _);
if(sense)
{
dumpLog.WriteLine("Cannot lock drive, not continuing.");
@@ -503,7 +496,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration);
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out _);
if(sense)
{
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,
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);
totalDuration += cmdDuration;
@@ -548,15 +541,14 @@ namespace DiscImageChef.Core.Devices.Dumping
if(stopOnError) return; // TODO: Return more cleanly
// Write empty data
dumpFile.Write(new byte[blockSize * blocksToRead]);
dumpFile.Write(new byte[BLOCK_SIZE * blocksToRead]);
// TODO: Handle errors in video partition
//errored += blocksToRead;
//resume.BadBlocks.Add(l1);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf));
if(cmdDuration < 500) mhddLog.Write(l1, 65535);
else mhddLog.Write(l1, cmdDuration);
mhddLog.Write(l1, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(l1, 0);
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);
}
currentSpeed = (double)blockSize * blocksToRead / 1048576 / (cmdDuration / 1000);
currentSpeed = (double)BLOCK_SIZE * blocksToRead / 1048576 / (cmdDuration / 1000);
currentSector += blocksToRead;
resume.NextBlock = currentSector;
}
dumpLog.WriteLine("Unlocking drive (Wxripper).");
sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out duration);
sense = dev.KreonUnlockWxripper(out senseBuf, dev.Timeout, out _);
if(sense)
{
dumpLog.WriteLine("Cannot unlock drive, not continuing.");
@@ -580,7 +572,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration);
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out _);
if(sense)
{
DicConsole.ErrorWriteLine("Cannot get disc capacity.");
@@ -590,11 +582,11 @@ namespace DiscImageChef.Core.Devices.Dumping
end = DateTime.UtcNow;
DicConsole.WriteLine();
mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath);
ibgLog.Close(dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024,
BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath);
dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds);
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
if(resume.BadBlocks.Count > 0 && !aborted)
@@ -627,17 +619,17 @@ namespace DiscImageChef.Core.Devices.Dumping
runningPersistent ? "recovering partial data, " : "");
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;
if(!sense && !dev.Error)
{
resume.BadBlocks.Remove(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);
}
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)
@@ -649,25 +641,12 @@ namespace DiscImageChef.Core.Devices.Dumping
goto repeatRetry;
}
Modes.DecodedMode? currentMode = null;
Modes.ModePage? currentModePage = null;
byte[] md6;
byte[] md10;
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)
{
Modes.ModePage_01_MMC pgMmc =
@@ -726,8 +705,8 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) sense = dev.ModeSelect10(md10, 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 _);
runningPersistent = true;
if(!sense && !dev.Error)
@@ -747,8 +726,8 @@ namespace DiscImageChef.Core.Devices.Dumping
md10 = Modes.EncodeMode10(md, dev.ScsiType);
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out _);
if(sense) dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out _);
}
DicConsole.WriteLine();
@@ -758,7 +737,7 @@ namespace DiscImageChef.Core.Devices.Dumping
resume.BadBlocks.Sort();
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dataChk = new Checksum();
Checksum dataChk = new Checksum();
dumpFile.Seek(0, SeekOrigin.Begin);
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);
DateTime chkStart = DateTime.UtcNow;
byte[] dataToCheck = new byte[blockSize * blocksToRead];
dumpFile.Read(dataToCheck, 0, (int)(blockSize * blocksToRead));
byte[] dataToCheck = new byte[BLOCK_SIZE * blocksToRead];
dumpFile.Read(dataToCheck, 0, (int)(BLOCK_SIZE * blocksToRead));
dataChk.Update(dataToCheck);
DateTime chkEnd = DateTime.UtcNow;
double chkDuration = (chkEnd - chkStart).TotalMilliseconds;
totalChkDuration += chkDuration;
currentSpeed = (double)blockSize * blocksToRead / 1048576 / (chkDuration / 1000);
currentSpeed = (double)BLOCK_SIZE * blocksToRead / 1048576 / (chkDuration / 1000);
}
DicConsole.WriteLine();
@@ -794,11 +773,10 @@ namespace DiscImageChef.Core.Devices.Dumping
end = DateTime.UtcNow;
dumpLog.WriteLine("Checksum finished in {0} seconds.", (end - start).TotalSeconds);
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();
plugins.RegisterAllPlugins(encoding);
ImagePlugin imageFormat;
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".iso");
@@ -808,7 +786,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
imageFormat = ImageFormat.Detect(inputFilter);
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -845,7 +823,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
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);
Statistics.AddFilesystem(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>();
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)
try
{
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo);
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(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[0] = new TrackType
{
BytesPerSector = (int)blockSize,
BytesPerSector = (int)BLOCK_SIZE,
Checksums = sidecar.OpticalDisc[0].Checksums,
EndSector = (long)(blocks - 1),
Image =
@@ -944,7 +922,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Value = sidecar.OpticalDisc[0].Image.Value
},
Sequence = new TrackSequenceType {Session = 1, TrackNumber = 1},
Size = (long)(totalSize * blockSize),
Size = (long)(totalSize * BLOCK_SIZE),
StartSector = 0
};
if(xmlFileSysInfo != null) sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo;