Refactor: simplification.

This commit is contained in:
2017-06-08 21:12:05 +01:00
parent b135a3f7d1
commit 943b8a8276
7 changed files with 660 additions and 483 deletions

View File

@@ -72,41 +72,48 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
} }
byte[] cmdBuf;
bool sense; bool sense;
ushort currentProfile = 0x0001; ushort currentProfile = 0x0001;
Decoders.ATA.AtaErrorRegistersCHS errorChs;
uint timeout = 5; uint timeout = 5;
double duration; double duration;
sense = dev.AtaIdentify(out cmdBuf, out errorChs); sense = dev.AtaIdentify(out byte[] cmdBuf, out Decoders.ATA.AtaErrorRegistersCHS errorChs);
if(!sense && Decoders.ATA.Identify.Decode(cmdBuf).HasValue) if(!sense && Decoders.ATA.Identify.Decode(cmdBuf).HasValue)
{ {
Decoders.ATA.Identify.IdentifyDevice ataId = Decoders.ATA.Identify.Decode(cmdBuf).Value; Decoders.ATA.Identify.IdentifyDevice ataId = Decoders.ATA.Identify.Decode(cmdBuf).Value;
CICMMetadataType sidecar = new CICMMetadataType(); CICMMetadataType sidecar = new CICMMetadataType()
sidecar.BlockMedia = new BlockMediaType[1]; {
sidecar.BlockMedia[0] = new BlockMediaType(); BlockMedia = new BlockMediaType[] { new BlockMediaType() }
};
if(dev.IsUSB) if(dev.IsUSB)
{ {
sidecar.BlockMedia[0].USB = new USBType(); sidecar.BlockMedia[0].USB = new USBType
sidecar.BlockMedia[0].USB.ProductID = dev.USBProductID; {
sidecar.BlockMedia[0].USB.VendorID = dev.USBVendorID; ProductID = dev.USBProductID,
sidecar.BlockMedia[0].USB.Descriptors = new DumpType(); VendorID = dev.USBVendorID,
sidecar.BlockMedia[0].USB.Descriptors.Image = outputPrefix + ".usbdescriptors.bin"; Descriptors = new DumpType
sidecar.BlockMedia[0].USB.Descriptors.Size = dev.USBDescriptors.Length; {
sidecar.BlockMedia[0].USB.Descriptors.Checksums = Checksum.GetChecksums(dev.USBDescriptors).ToArray(); Image = outputPrefix + ".usbdescriptors.bin",
Size = dev.USBDescriptors.Length,
Checksums = Checksum.GetChecksums(dev.USBDescriptors).ToArray()
}
};
DataFile.WriteTo("ATA Dump", sidecar.BlockMedia[0].USB.Descriptors.Image, dev.USBDescriptors); DataFile.WriteTo("ATA Dump", sidecar.BlockMedia[0].USB.Descriptors.Image, dev.USBDescriptors);
} }
if(dev.IsPCMCIA) if(dev.IsPCMCIA)
{ {
sidecar.BlockMedia[0].PCMCIA = new PCMCIAType(); sidecar.BlockMedia[0].PCMCIA = new PCMCIAType
sidecar.BlockMedia[0].PCMCIA.CIS = new DumpType(); {
sidecar.BlockMedia[0].PCMCIA.CIS.Image = outputPrefix + ".cis.bin"; CIS = new DumpType
sidecar.BlockMedia[0].PCMCIA.CIS.Size = dev.CIS.Length; {
sidecar.BlockMedia[0].PCMCIA.CIS.Checksums = Checksum.GetChecksums(dev.CIS).ToArray(); Image = outputPrefix + ".cis.bin",
Size = dev.CIS.Length,
Checksums = Checksum.GetChecksums(dev.CIS).ToArray()
}
};
DataFile.WriteTo("ATA Dump", sidecar.BlockMedia[0].PCMCIA.CIS.Image, dev.CIS); DataFile.WriteTo("ATA Dump", sidecar.BlockMedia[0].PCMCIA.CIS.Image, dev.CIS);
Decoders.PCMCIA.Tuple[] tuples = CIS.GetTuples(dev.CIS); Decoders.PCMCIA.Tuple[] tuples = CIS.GetTuples(dev.CIS);
if(tuples != null) if(tuples != null)
@@ -141,11 +148,15 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
} }
sidecar.BlockMedia[0].ATA = new ATAType(); sidecar.BlockMedia[0].ATA = new ATAType
sidecar.BlockMedia[0].ATA.Identify = new DumpType(); {
sidecar.BlockMedia[0].ATA.Identify.Image = outputPrefix + ".identify.bin"; Identify = new DumpType
sidecar.BlockMedia[0].ATA.Identify.Size = cmdBuf.Length; {
sidecar.BlockMedia[0].ATA.Identify.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Image = outputPrefix + ".identify.bin",
Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
}
};
DataFile.WriteTo("ATA Dump", sidecar.BlockMedia[0].ATA.Identify.Image, cmdBuf); DataFile.WriteTo("ATA Dump", sidecar.BlockMedia[0].ATA.Identify.Image, cmdBuf);
DateTime start; DateTime start;
@@ -432,9 +443,8 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values) foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
{ {
List<Partition> _partitions;
if(_partplugin.GetInformation(_imageFormat, out _partitions)) if(_partplugin.GetInformation(_imageFormat, out List<Partition> _partitions))
{ {
partitions.AddRange(_partitions); partitions.AddRange(_partitions);
Statistics.AddPartition(_partplugin.Name); Statistics.AddPartition(_partplugin.Name);
@@ -446,14 +456,15 @@ namespace DiscImageChef.Core.Devices.Dumping
xmlFileSysInfo = new PartitionType[partitions.Count]; xmlFileSysInfo = new PartitionType[partitions.Count];
for(int i = 0; i < partitions.Count; i++) for(int i = 0; i < partitions.Count; i++)
{ {
xmlFileSysInfo[i] = new PartitionType(); xmlFileSysInfo[i] = new PartitionType
xmlFileSysInfo[i].Description = partitions[i].PartitionDescription; {
xmlFileSysInfo[i].EndSector = (int)(partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1); Description = partitions[i].PartitionDescription,
xmlFileSysInfo[i].Name = partitions[i].PartitionName; EndSector = (int)(partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1),
xmlFileSysInfo[i].Sequence = (int)partitions[i].PartitionSequence; Name = partitions[i].PartitionName,
xmlFileSysInfo[i].StartSector = (int)partitions[i].PartitionStartSector; Sequence = (int)partitions[i].PartitionSequence,
xmlFileSysInfo[i].Type = partitions[i].PartitionType; StartSector = (int)partitions[i].PartitionStartSector,
Type = partitions[i].PartitionType
};
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem _plugin in plugins.PluginsList.Values) foreach(Filesystem _plugin in plugins.PluginsList.Values)
@@ -462,8 +473,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(_plugin.Identify(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1)) if(_plugin.Identify(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1))
{ {
string foo; _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out string foo);
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out foo);
lstFs.Add(_plugin.XmlFSType); lstFs.Add(_plugin.XmlFSType);
Statistics.AddFilesystem(_plugin.XmlFSType.Type); Statistics.AddFilesystem(_plugin.XmlFSType.Type);
} }
@@ -483,10 +493,11 @@ namespace DiscImageChef.Core.Devices.Dumping
else else
{ {
xmlFileSysInfo = new PartitionType[1]; xmlFileSysInfo = new PartitionType[1];
xmlFileSysInfo[0] = new PartitionType(); xmlFileSysInfo[0] = new PartitionType
xmlFileSysInfo[0].EndSector = (int)(blocks - 1); {
xmlFileSysInfo[0].StartSector = 0; EndSector = (int)(blocks - 1),
StartSector = 0
};
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem _plugin in plugins.PluginsList.Values) foreach(Filesystem _plugin in plugins.PluginsList.Values)
@@ -495,8 +506,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(_plugin.Identify(_imageFormat, (blocks - 1), 0)) if(_plugin.Identify(_imageFormat, (blocks - 1), 0))
{ {
string foo; _plugin.GetInformation(_imageFormat, (blocks - 1), 0, out string foo);
_plugin.GetInformation(_imageFormat, (blocks - 1), 0, out foo);
lstFs.Add(_plugin.XmlFSType); lstFs.Add(_plugin.XmlFSType);
Statistics.AddFilesystem(_plugin.XmlFSType.Type); Statistics.AddFilesystem(_plugin.XmlFSType.Type);
} }
@@ -525,9 +535,11 @@ namespace DiscImageChef.Core.Devices.Dumping
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
sidecar.BlockMedia[0].Image = new ImageType(); sidecar.BlockMedia[0].Image = new ImageType
sidecar.BlockMedia[0].Image.format = "Raw disk image (sector by sector copy)"; {
sidecar.BlockMedia[0].Image.Value = outputPrefix + ".bin"; format = "Raw disk image (sector by sector copy)",
Value = outputPrefix + ".bin"
};
sidecar.BlockMedia[0].Interface = "ATA"; sidecar.BlockMedia[0].Interface = "ATA";
sidecar.BlockMedia[0].LogicalBlocks = (long)blocks; sidecar.BlockMedia[0].LogicalBlocks = (long)blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = (int)physicalsectorsize; sidecar.BlockMedia[0].PhysicalBlockSize = (int)physicalsectorsize;

View File

@@ -54,16 +54,13 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
MHDDLog mhddLog; MHDDLog mhddLog;
IBGLog ibgLog; IBGLog ibgLog;
byte[] cmdBuf = null;
byte[] senseBuf = null;
bool sense = false; bool sense = false;
double duration;
ulong blocks = 0; ulong blocks = 0;
// TODO: Check subchannel support // TODO: Check subchannel support
uint blockSize = 0; uint blockSize = 0;
uint subSize = 0; uint subSize = 0;
byte[] tmpBuf; byte[] tmpBuf;
Decoders.CD.FullTOC.CDFullTOC? toc = null; FullTOC.CDFullTOC? toc = null;
DateTime start; DateTime start;
DateTime end; DateTime end;
double totalDuration = 0; double totalDuration = 0;
@@ -86,25 +83,27 @@ 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)
bool tocSense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out duration); bool tocSense = dev.ReadRawToc(out byte[] cmdBuf, out byte[] senseBuf, 1, dev.Timeout, out double duration);
if(!tocSense) if(!tocSense)
{ {
toc = Decoders.CD.FullTOC.Decode(cmdBuf); toc = FullTOC.Decode(cmdBuf);
if(toc.HasValue) if(toc.HasValue)
{ {
tmpBuf = new byte[cmdBuf.Length - 2]; 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
sidecar.OpticalDisc[0].TOC.Image = outputPrefix + ".toc.bin"; {
sidecar.OpticalDisc[0].TOC.Size = tmpBuf.Length; Image = outputPrefix + ".toc.bin",
sidecar.OpticalDisc[0].TOC.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].TOC.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].TOC.Image, tmpBuf);
// ATIP exists on blank CDs // ATIP exists on blank CDs
sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if(!sense) if(!sense)
{ {
Decoders.CD.ATIP.CDATIP? atip = Decoders.CD.ATIP.Decode(cmdBuf); ATIP.CDATIP? atip = ATIP.Decode(cmdBuf);
if(atip.HasValue) if(atip.HasValue)
{ {
if(blocks == 0) if(blocks == 0)
@@ -118,10 +117,12 @@ namespace DiscImageChef.Core.Devices.Dumping
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].ATIP = new DumpType(); sidecar.OpticalDisc[0].ATIP = new DumpType
sidecar.OpticalDisc[0].ATIP.Image = outputPrefix + ".atip.bin"; {
sidecar.OpticalDisc[0].ATIP.Size = tmpBuf.Length; Image = outputPrefix + ".atip.bin",
sidecar.OpticalDisc[0].ATIP.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].TOC.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].TOC.Image, tmpBuf);
} }
} }
@@ -154,7 +155,7 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if(!sense) if(!sense)
{ {
Decoders.CD.Session.CDSessionInfo? session = Decoders.CD.Session.Decode(cmdBuf); Session.CDSessionInfo? session = Session.Decode(cmdBuf);
if(session.HasValue) if(session.HasValue)
{ {
sessions = session.Value.LastCompleteSession; sessions = session.Value.LastCompleteSession;
@@ -171,17 +172,17 @@ namespace DiscImageChef.Core.Devices.Dumping
if(toc.HasValue) if(toc.HasValue)
{ {
foreach(Decoders.CD.FullTOC.TrackDataDescriptor track in toc.Value.TrackDescriptors) foreach(FullTOC.TrackDataDescriptor track in toc.Value.TrackDescriptors)
{ {
if(track.TNO == 1 && if(track.TNO == 1 &&
((Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == Decoders.CD.TOC_CONTROL.DataTrack || ((TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrack ||
(Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == Decoders.CD.TOC_CONTROL.DataTrackIncremental)) (TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrackIncremental))
{ {
allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; allFirstSessionTracksAreAudio &= firstTrackLastSession != 1;
} }
if((Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == Decoders.CD.TOC_CONTROL.DataTrack || if((TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrack ||
(Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == Decoders.CD.TOC_CONTROL.DataTrackIncremental) (TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrackIncremental)
{ {
hasDataTrack = true; hasDataTrack = true;
allFirstSessionTracksAreAudio &= track.TNO >= firstTrackLastSession; allFirstSessionTracksAreAudio &= track.TNO >= firstTrackLastSession;
@@ -206,14 +207,16 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if(!sense) if(!sense)
{ {
if(Decoders.CD.PMA.Decode(cmdBuf).HasValue) if(PMA.Decode(cmdBuf).HasValue)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PMA = new DumpType(); sidecar.OpticalDisc[0].PMA = new DumpType
sidecar.OpticalDisc[0].PMA.Image = outputPrefix + ".pma.bin"; {
sidecar.OpticalDisc[0].PMA.Size = tmpBuf.Length; Image = outputPrefix + ".pma.bin",
sidecar.OpticalDisc[0].PMA.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PMA.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PMA.Image, tmpBuf);
} }
} }
@@ -221,14 +224,16 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if(!sense) if(!sense)
{ {
if(Decoders.CD.CDTextOnLeadIn.Decode(cmdBuf).HasValue) if(CDTextOnLeadIn.Decode(cmdBuf).HasValue)
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].LeadInCdText = new DumpType(); sidecar.OpticalDisc[0].LeadInCdText = new DumpType
sidecar.OpticalDisc[0].LeadInCdText.Image = outputPrefix + ".cdtext.bin"; {
sidecar.OpticalDisc[0].LeadInCdText.Size = tmpBuf.Length; Image = outputPrefix + ".cdtext.bin",
sidecar.OpticalDisc[0].LeadInCdText.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].LeadInCdText.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].LeadInCdText.Image, tmpBuf);
} }
} }
@@ -250,20 +255,24 @@ namespace DiscImageChef.Core.Devices.Dumping
return; return;
} }
Decoders.CD.FullTOC.TrackDataDescriptor[] sortedTracks = toc.Value.TrackDescriptors.OrderBy(track => track.POINT).ToArray(); FullTOC.TrackDataDescriptor[] sortedTracks = toc.Value.TrackDescriptors.OrderBy(track => track.POINT).ToArray();
List<TrackType> trackList = new List<TrackType>(); List<TrackType> trackList = new List<TrackType>();
long lastSector = 0; long lastSector = 0;
string lastMSF = null; string lastMSF = null;
foreach(Decoders.CD.FullTOC.TrackDataDescriptor trk in sortedTracks) foreach(FullTOC.TrackDataDescriptor trk in sortedTracks)
{ {
if(trk.ADR == 1 || trk.ADR == 4) if(trk.ADR == 1 || trk.ADR == 4)
{ {
if(trk.POINT >= 0x01 && trk.POINT <= 0x63) if(trk.POINT >= 0x01 && trk.POINT <= 0x63)
{ {
TrackType track = new TrackType(); TrackType track = new TrackType
track.Sequence = new TrackSequenceType(); {
track.Sequence.Session = trk.SessionNumber; Sequence = new TrackSequenceType
track.Sequence.TrackNumber = trk.POINT; {
Session = trk.SessionNumber,
TrackNumber = trk.POINT
}
};
if((TOC_CONTROL)(trk.CONTROL & 0x0D) == TOC_CONTROL.DataTrack || if((TOC_CONTROL)(trk.CONTROL & 0x0D) == TOC_CONTROL.DataTrack ||
(TOC_CONTROL)(trk.CONTROL & 0x0D) == TOC_CONTROL.DataTrackIncremental) (TOC_CONTROL)(trk.CONTROL & 0x0D) == TOC_CONTROL.DataTrackIncremental)
track.TrackType1 = TrackTypeTrackType.mode1; track.TrackType1 = TrackTypeTrackType.mode1;
@@ -384,8 +393,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(aborted) if(aborted)
break; break;
double cmdDuration = 0;
#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(currentSpeed > maxSpeed && currentSpeed != 0) if(currentSpeed > maxSpeed && currentSpeed != 0)
maxSpeed = currentSpeed; maxSpeed = currentSpeed;
@@ -396,7 +403,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.Write("\rTrying to read lead-in sector {0} ({1:F3} MiB/sec.)", leadInBlock, currentSpeed); DicConsole.Write("\rTrying to read lead-in sector {0} ({1:F3} MiB/sec.)", leadInBlock, currentSpeed);
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)leadInBlock, blockSize, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)leadInBlock, blockSize, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out cmdDuration); true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, out double cmdDuration);
if(!sense && !dev.Error) if(!sense && !dev.Error)
{ {
@@ -425,11 +432,15 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpFile.Close(); dumpFile.Close();
if(leadInSectorsGood > 0) if(leadInSectorsGood > 0)
{ {
sidecar.OpticalDisc[0].LeadIn = new BorderType[1]; sidecar.OpticalDisc[0].LeadIn = new BorderType[]
sidecar.OpticalDisc[0].LeadIn[0] = new BorderType(); {
sidecar.OpticalDisc[0].LeadIn[0].Image = outputPrefix + ".leadin.bin"; sidecar.OpticalDisc[0].LeadIn[0] = new BorderType
sidecar.OpticalDisc[0].LeadIn[0].Checksums = dataChk.End().ToArray(); {
sidecar.OpticalDisc[0].LeadIn[0].Size = leadInSectorsTotal * blockSize; Image = outputPrefix + ".leadin.bin",
Checksums = dataChk.End().ToArray(),
Size = leadInSectorsTotal * blockSize
}
};
} }
else else
File.Delete(outputPrefix + ".leadin.bin"); File.Delete(outputPrefix + ".leadin.bin");
@@ -469,19 +480,24 @@ namespace DiscImageChef.Core.Devices.Dumping
start = DateTime.UtcNow; start = DateTime.UtcNow;
for(int t = 0; t < tracks.Count(); t++) for(int t = 0; t < tracks.Count(); t++)
{ {
tracks[t].BytesPerSector = (int)sectorSize; tracks[t].BytesPerSector = sectorSize;
tracks[t].Image = new ImageType(); tracks[t].Image = new ImageType
tracks[t].Image.format = "BINARY"; {
tracks[t].Image.offset = dumpFile.Position; format = "BINARY",
tracks[t].Image.offsetSpecified = true; offset = dumpFile.Position,
tracks[t].Image.Value = outputPrefix + ".bin"; offsetSpecified = true,
tracks[t].Size = (long)((tracks[t].EndSector - tracks[t].StartSector + 1) * sectorSize); Value = outputPrefix + ".bin"
tracks[t].SubChannel = new SubChannelType(); };
tracks[t].SubChannel.Image = new ImageType(); tracks[t].Size = (tracks[t].EndSector - tracks[t].StartSector + 1) * sectorSize;
tracks[t].SubChannel.Image.format = "rw_raw"; tracks[t].SubChannel = new SubChannelType
tracks[t].SubChannel.Image.offsetSpecified = true; {
tracks[t].SubChannel.Size = (long)((tracks[t].EndSector - tracks[t].StartSector + 1) * subSize); Image = new ImageType
{
format = "rw_raw",
offsetSpecified = true
},
Size = (tracks[t].EndSector - tracks[t].StartSector + 1) * subSize
};
if(separateSubchannel) if(separateSubchannel)
{ {
tracks[t].SubChannel.Image.offset = subFile.Position; tracks[t].SubChannel.Image.offset = subFile.Position;
@@ -681,18 +697,25 @@ namespace DiscImageChef.Core.Devices.Dumping
if(currentMode.HasValue) if(currentMode.HasValue)
currentModePage = currentMode.Value.Pages[0]; currentModePage = currentMode.Value.Pages[0];
Decoders.SCSI.Modes.ModePage_01_MMC pgMMC = new Decoders.SCSI.Modes.ModePage_01_MMC(); Decoders.SCSI.Modes.ModePage_01_MMC pgMMC = new Decoders.SCSI.Modes.ModePage_01_MMC
pgMMC.PS = false; {
pgMMC.ReadRetryCount = 255; PS = false,
pgMMC.Parameter = 0x20; ReadRetryCount = 255,
Parameter = 0x20
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); };
md.Header = new Decoders.SCSI.Modes.ModeHeader(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; {
md.Pages[0] = new Decoders.SCSI.Modes.ModePage(); Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0].Page = 0x01; Pages = new Decoders.SCSI.Modes.ModePage[]
md.Pages[0].Subpage = 0x00; {
md.Pages[0].PageResponse = Decoders.SCSI.Modes.EncodeModePage_01_MMC(pgMMC); new Decoders.SCSI.Modes.ModePage
{
Page = 0x01,
Subpage = 0x00,
PageResponse = Decoders.SCSI.Modes.EncodeModePage_01_MMC(pgMMC)
}
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
@@ -711,10 +734,14 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
else if(runningPersistent && persistent && currentModePage.HasValue) else if(runningPersistent && persistent && currentModePage.HasValue)
{ {
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Header = new Decoders.SCSI.Modes.ModeHeader(); {
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0] = currentModePage.Value; Pages = new Decoders.SCSI.Modes.ModePage[]
{
currentModePage.Value
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
@@ -794,24 +821,29 @@ namespace DiscImageChef.Core.Devices.Dumping
// TODO: Correct this // TODO: Correct this
sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray(); sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray();
sidecar.OpticalDisc[0].DumpHardwareArray = new DumpHardwareType[1]; sidecar.OpticalDisc[0].DumpHardwareArray = new DumpHardwareType[1];
sidecar.OpticalDisc[0].DumpHardwareArray[0] = new DumpHardwareType(); sidecar.OpticalDisc[0].DumpHardwareArray[0] = new DumpHardwareType
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents = new ExtentType[1]; {
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0] = new ExtentType(); Extents = new ExtentType[1]
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0].Start = 0; };
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0].End = (int)(blocks - 1); sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0] = new ExtentType
{
Start = 0,
End = (int)(blocks - 1)
};
sidecar.OpticalDisc[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer; sidecar.OpticalDisc[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Model = dev.Model; sidecar.OpticalDisc[0].DumpHardwareArray[0].Model = dev.Model;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Revision = dev.Revision; sidecar.OpticalDisc[0].DumpHardwareArray[0].Revision = dev.Revision;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Software = Version.GetSoftwareType(dev.PlatformID); sidecar.OpticalDisc[0].DumpHardwareArray[0].Software = Version.GetSoftwareType(dev.PlatformID);
sidecar.OpticalDisc[0].Image = new ImageType(); sidecar.OpticalDisc[0].Image = new ImageType
sidecar.OpticalDisc[0].Image.format = "Raw disk image (sector by sector copy)"; {
sidecar.OpticalDisc[0].Image.Value = outputPrefix + ".bin"; format = "Raw disk image (sector by sector copy)",
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.Count() };
sidecar.OpticalDisc[0].Track = tracks; sidecar.OpticalDisc[0].Track = tracks;
sidecar.OpticalDisc[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType); sidecar.OpticalDisc[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType);
string xmlDskTyp, xmlDskSubTyp; Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(dskType, out xmlDskTyp, out xmlDskSubTyp);
sidecar.OpticalDisc[0].DiscType = xmlDskTyp; sidecar.OpticalDisc[0].DiscType = xmlDskTyp;
sidecar.OpticalDisc[0].DiscSubType = xmlDskSubTyp; sidecar.OpticalDisc[0].DiscSubType = xmlDskSubTyp;
} }

View File

@@ -208,10 +208,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PFI = new DumpType(); sidecar.OpticalDisc[0].PFI = new DumpType
sidecar.OpticalDisc[0].PFI.Image = outputPrefix + ".pfi.bin"; {
sidecar.OpticalDisc[0].PFI.Size = tmpBuf.Length; Image = outputPrefix + ".pfi.bin",
sidecar.OpticalDisc[0].PFI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFI.Image, tmpBuf);
Decoders.DVD.PFI.PhysicalFormatInformation decPfi = Decoders.DVD.PFI.Decode(cmdBuf).Value; Decoders.DVD.PFI.PhysicalFormatInformation decPfi = Decoders.DVD.PFI.Decode(cmdBuf).Value;
@@ -295,8 +297,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.XGD3; dskType = MediaType.XGD3;
} }
byte[] inqBuf; sense = dev.ScsiInquiry(out byte[] inqBuf, out senseBuf);
sense = dev.ScsiInquiry(out inqBuf, out senseBuf);
if(sense || !Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue || if(sense || !Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue ||
(Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue && !Decoders.SCSI.Inquiry.Decode(inqBuf).Value.KreonPresent)) (Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue && !Decoders.SCSI.Inquiry.Decode(inqBuf).Value.KreonPresent))
@@ -316,10 +317,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DMI = new DumpType(); sidecar.OpticalDisc[0].DMI = new DumpType
sidecar.OpticalDisc[0].DMI.Image = outputPrefix + ".dmi.bin"; {
sidecar.OpticalDisc[0].DMI.Size = tmpBuf.Length; Image = outputPrefix + ".dmi.bin",
sidecar.OpticalDisc[0].DMI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DMI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DMI.Image, tmpBuf);
} }
} }
@@ -336,10 +339,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].CMI = new DumpType(); sidecar.OpticalDisc[0].CMI = new DumpType
sidecar.OpticalDisc[0].CMI.Image = outputPrefix + ".cmi.bin"; {
sidecar.OpticalDisc[0].CMI.Size = tmpBuf.Length; Image = outputPrefix + ".cmi.bin",
sidecar.OpticalDisc[0].CMI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf);
Decoders.DVD.CSS_CPRM.LeadInCopyright cpy = Decoders.DVD.CSS_CPRM.DecodeLeadInCopyright(cmdBuf).Value; Decoders.DVD.CSS_CPRM.LeadInCopyright cpy = Decoders.DVD.CSS_CPRM.DecodeLeadInCopyright(cmdBuf).Value;
@@ -359,10 +364,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].BCA = new DumpType(); sidecar.OpticalDisc[0].BCA = new DumpType
sidecar.OpticalDisc[0].BCA.Image = outputPrefix + ".bca.bin"; {
sidecar.OpticalDisc[0].BCA.Size = tmpBuf.Length; Image = outputPrefix + ".bca.bin",
sidecar.OpticalDisc[0].BCA.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf);
} }
} }
@@ -378,10 +385,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DDS = new DumpType(); sidecar.OpticalDisc[0].DDS = new DumpType
sidecar.OpticalDisc[0].DDS.Image = outputPrefix + ".dds.bin"; {
sidecar.OpticalDisc[0].DDS.Size = tmpBuf.Length; Image = outputPrefix + ".dds.bin",
sidecar.OpticalDisc[0].DDS.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf);
} }
} }
@@ -393,10 +402,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].SAI = new DumpType(); sidecar.OpticalDisc[0].SAI = new DumpType
sidecar.OpticalDisc[0].SAI.Image = outputPrefix + ".sai.bin"; {
sidecar.OpticalDisc[0].SAI.Size = tmpBuf.Length; Image = outputPrefix + ".sai.bin",
sidecar.OpticalDisc[0].SAI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
} }
} }
@@ -411,10 +422,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PRI = new DumpType(); sidecar.OpticalDisc[0].PRI = new DumpType
sidecar.OpticalDisc[0].PRI.Image = outputPrefix + ".pri.bin"; {
sidecar.OpticalDisc[0].PRI.Size = tmpBuf.Length; Image = outputPrefix + ".pri.bin",
sidecar.OpticalDisc[0].PRI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
} }
} }
@@ -428,10 +441,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].MediaID = new DumpType(); sidecar.OpticalDisc[0].MediaID = new DumpType
sidecar.OpticalDisc[0].MediaID.Image = outputPrefix + ".mid.bin"; {
sidecar.OpticalDisc[0].MediaID.Size = tmpBuf.Length; Image = outputPrefix + ".mid.bin",
sidecar.OpticalDisc[0].MediaID.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].MediaID.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].MediaID.Image, tmpBuf);
} }
@@ -440,10 +455,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PFIR = new DumpType(); sidecar.OpticalDisc[0].PFIR = new DumpType
sidecar.OpticalDisc[0].PFIR.Image = outputPrefix + ".pfir.bin"; {
sidecar.OpticalDisc[0].PFIR.Size = tmpBuf.Length; Image = outputPrefix + ".pfir.bin",
sidecar.OpticalDisc[0].PFIR.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFIR.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFIR.Image, tmpBuf);
} }
} }
@@ -458,10 +475,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].ADIP = new DumpType(); sidecar.OpticalDisc[0].ADIP = new DumpType
sidecar.OpticalDisc[0].ADIP.Image = outputPrefix + ".adip.bin"; {
sidecar.OpticalDisc[0].ADIP.Size = tmpBuf.Length; Image = outputPrefix + ".adip.bin",
sidecar.OpticalDisc[0].ADIP.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].ADIP.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].ADIP.Image, tmpBuf);
} }
@@ -470,10 +489,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DCB = new DumpType(); sidecar.OpticalDisc[0].DCB = new DumpType
sidecar.OpticalDisc[0].DCB.Image = outputPrefix + ".dcb.bin"; {
sidecar.OpticalDisc[0].DCB.Size = tmpBuf.Length; Image = outputPrefix + ".dcb.bin",
sidecar.OpticalDisc[0].DCB.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DCB.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DCB.Image, tmpBuf);
} }
} }
@@ -487,10 +508,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].CMI = new DumpType(); sidecar.OpticalDisc[0].CMI = new DumpType
sidecar.OpticalDisc[0].CMI.Image = outputPrefix + ".cmi.bin"; {
sidecar.OpticalDisc[0].CMI.Size = tmpBuf.Length; Image = outputPrefix + ".cmi.bin",
sidecar.OpticalDisc[0].CMI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf);
} }
} }
@@ -507,10 +530,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DI = new DumpType(); sidecar.OpticalDisc[0].DI = new DumpType()
sidecar.OpticalDisc[0].DI.Image = outputPrefix + ".di.bin"; {
sidecar.OpticalDisc[0].DI.Size = tmpBuf.Length; Image = outputPrefix + ".di.bin",
sidecar.OpticalDisc[0].DI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DI.Image, tmpBuf);
} }
} }
@@ -520,10 +545,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PAC = new DumpType(); sidecar.OpticalDisc[0].PAC = new DumpType
sidecar.OpticalDisc[0].PAC.Image = outputPrefix + ".pac.bin"; {
sidecar.OpticalDisc[0].PAC.Size = tmpBuf.Length; Image = outputPrefix + ".pac.bin",
sidecar.OpticalDisc[0].PAC.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PAC.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PAC.Image, tmpBuf);
} }
} }
@@ -538,10 +565,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].BCA = new DumpType(); sidecar.OpticalDisc[0].BCA = new DumpType
sidecar.OpticalDisc[0].BCA.Image = outputPrefix + ".bca.bin"; {
sidecar.OpticalDisc[0].BCA.Size = tmpBuf.Length; Image = outputPrefix + ".bca.bin",
sidecar.OpticalDisc[0].BCA.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf);
} }
} }
@@ -556,10 +585,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DDS = new DumpType(); sidecar.OpticalDisc[0].DDS = new DumpType
sidecar.OpticalDisc[0].DDS.Image = outputPrefix + ".dds.bin"; {
sidecar.OpticalDisc[0].DDS.Size = tmpBuf.Length; Image = outputPrefix + ".dds.bin",
sidecar.OpticalDisc[0].DDS.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf);
} }
@@ -568,10 +599,12 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].SAI = new DumpType(); sidecar.OpticalDisc[0].SAI = new DumpType
sidecar.OpticalDisc[0].SAI.Image = outputPrefix + ".sai.bin"; {
sidecar.OpticalDisc[0].SAI.Size = tmpBuf.Length; Image = outputPrefix + ".sai.bin",
sidecar.OpticalDisc[0].SAI.Checksums = Checksum.GetChecksums(tmpBuf).ToArray(); Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf); DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
} }
} }

View File

@@ -130,27 +130,34 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(dev.IsUSB) if(dev.IsUSB)
{ {
sidecar.BlockMedia[0].USB = new USBType(); sidecar.BlockMedia[0].USB = new USBType
sidecar.BlockMedia[0].USB.ProductID = dev.USBProductID; {
sidecar.BlockMedia[0].USB.VendorID = dev.USBVendorID; ProductID = dev.USBProductID,
sidecar.BlockMedia[0].USB.Descriptors = new DumpType(); VendorID = dev.USBVendorID,
sidecar.BlockMedia[0].USB.Descriptors.Image = outputPrefix + ".usbdescriptors.bin"; Descriptors = new DumpType()
sidecar.BlockMedia[0].USB.Descriptors.Size = dev.USBDescriptors.Length; {
sidecar.BlockMedia[0].USB.Descriptors.Checksums = Checksum.GetChecksums(dev.USBDescriptors).ToArray(); Image = outputPrefix + ".usbdescriptors.bin",
Size = dev.USBDescriptors.Length,
Checksums = Checksum.GetChecksums(dev.USBDescriptors).ToArray()
}
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].USB.Descriptors.Image, dev.USBDescriptors); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].USB.Descriptors.Image, dev.USBDescriptors);
} }
if(dev.Type == DeviceType.ATAPI) if(dev.Type == DeviceType.ATAPI)
{ {
Decoders.ATA.AtaErrorRegistersCHS errorRegs; sense = dev.AtapiIdentify(out cmdBuf, out Decoders.ATA.AtaErrorRegistersCHS errorRegs);
sense = dev.AtapiIdentify(out cmdBuf, out errorRegs);
if(!sense) if(!sense)
{ {
sidecar.BlockMedia[0].ATA = new ATAType(); sidecar.BlockMedia[0].ATA = new ATAType
sidecar.BlockMedia[0].ATA.Identify = new DumpType(); {
sidecar.BlockMedia[0].ATA.Identify.Image = outputPrefix + ".identify.bin"; Identify = new DumpType
sidecar.BlockMedia[0].ATA.Identify.Size = cmdBuf.Length; {
sidecar.BlockMedia[0].ATA.Identify.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Image = outputPrefix + ".identify.bin",
Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
}
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].ATA.Identify.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].ATA.Identify.Image, cmdBuf);
} }
} }
@@ -158,11 +165,15 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf); sense = dev.ScsiInquiry(out cmdBuf, out senseBuf);
if(!sense) if(!sense)
{ {
sidecar.BlockMedia[0].SCSI = new SCSIType(); sidecar.BlockMedia[0].SCSI = new SCSIType
sidecar.BlockMedia[0].SCSI.Inquiry = new DumpType(); {
sidecar.BlockMedia[0].SCSI.Inquiry.Image = outputPrefix + ".inquiry.bin"; Inquiry = new DumpType
sidecar.BlockMedia[0].SCSI.Inquiry.Size = cmdBuf.Length; {
sidecar.BlockMedia[0].SCSI.Inquiry.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Image = outputPrefix + ".inquiry.bin",
Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
}
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.Inquiry.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.Inquiry.Image, cmdBuf);
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, 0x00); sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, 0x00);
@@ -178,10 +189,12 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, page); sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, page);
if(!sense) if(!sense)
{ {
EVPDType evpd = new EVPDType(); EVPDType evpd = new EVPDType
evpd.Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page); {
evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page),
evpd.Size = cmdBuf.Length; Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
Size = cmdBuf.Length
};
evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray();
DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf);
evpds.Add(evpd); evpds.Add(evpd);
@@ -206,10 +219,12 @@ namespace DiscImageChef.Core.Devices.Dumping
if(Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType).HasValue) if(Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType).HasValue)
{ {
decMode = Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType); decMode = Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType);
sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType(); sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType
sidecar.BlockMedia[0].SCSI.ModeSense10.Image = outputPrefix + ".modesense10.bin"; {
sidecar.BlockMedia[0].SCSI.ModeSense10.Size = cmdBuf.Length; Image = outputPrefix + ".modesense10.bin",
sidecar.BlockMedia[0].SCSI.ModeSense10.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense10.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense10.Image, cmdBuf);
} }
} }
@@ -225,10 +240,12 @@ namespace DiscImageChef.Core.Devices.Dumping
if(Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType).HasValue) if(Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType).HasValue)
{ {
decMode = Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType); decMode = Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType);
sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType(); sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType
sidecar.BlockMedia[0].SCSI.ModeSense.Image = outputPrefix + ".modesense.bin"; {
sidecar.BlockMedia[0].SCSI.ModeSense.Size = cmdBuf.Length; Image = outputPrefix + ".modesense.bin",
sidecar.BlockMedia[0].SCSI.ModeSense.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense.Image, cmdBuf);
} }
} }
@@ -303,8 +320,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(aborted) if(aborted)
break; break;
double cmdDuration = 0;
if((blocks - i) < blocksToRead) if((blocks - i) < blocksToRead)
blocksToRead = (uint)(blocks - i); blocksToRead = (uint)(blocks - i);
@@ -317,7 +332,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);
sense = scsiReader.ReadBlocks(out readBuffer, i, blocksToRead, out cmdDuration); sense = scsiReader.ReadBlocks(out readBuffer, i, blocksToRead, out double cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
if(!sense && !dev.Error) if(!sense && !dev.Error)
@@ -384,11 +399,9 @@ namespace DiscImageChef.Core.Devices.Dumping
if(aborted) if(aborted)
break; break;
double cmdDuration = 0;
DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1, forward ? "forward" : "reverse", runningPersistent ? "recovering partial data, " : ""); DicConsole.Write("\rRetrying sector {0}, pass {1}, {3}{2}", badSector, pass + 1, forward ? "forward" : "reverse", runningPersistent ? "recovering partial data, " : "");
sense = scsiReader.ReadBlock(out readBuffer, badSector, out cmdDuration); sense = scsiReader.ReadBlock(out readBuffer, badSector, out double cmdDuration);
totalDuration += cmdDuration; totalDuration += cmdDuration;
if(!sense && !dev.Error) if(!sense && !dev.Error)
@@ -431,42 +444,56 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice)
{ {
Decoders.SCSI.Modes.ModePage_01_MMC pgMMC = new Decoders.SCSI.Modes.ModePage_01_MMC(); Decoders.SCSI.Modes.ModePage_01_MMC pgMMC = new Decoders.SCSI.Modes.ModePage_01_MMC
pgMMC.PS = false; {
pgMMC.ReadRetryCount = 255; PS = false,
pgMMC.Parameter = 0x20; ReadRetryCount = 255,
Parameter = 0x20
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); };
md.Header = new Decoders.SCSI.Modes.ModeHeader(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; {
md.Pages[0] = new Decoders.SCSI.Modes.ModePage(); Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0].Page = 0x01; Pages = new Decoders.SCSI.Modes.ModePage[]
md.Pages[0].Subpage = 0x00; {
md.Pages[0].PageResponse = Decoders.SCSI.Modes.EncodeModePage_01_MMC(pgMMC); new Decoders.SCSI.Modes.ModePage
{
Page = 0x01,
Subpage = 0x00,
PageResponse = Decoders.SCSI.Modes.EncodeModePage_01_MMC(pgMMC)
}
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
} }
else else
{ {
Decoders.SCSI.Modes.ModePage_01 pg = new Decoders.SCSI.Modes.ModePage_01(); Decoders.SCSI.Modes.ModePage_01 pg = new Decoders.SCSI.Modes.ModePage_01()
pg.PS = false; {
pg.AWRE = false; PS = false,
pg.ARRE = false; AWRE = false,
pg.TB = true; ARRE = false,
pg.RC = false; TB = true,
pg.EER = true; RC = false,
pg.PER = false; EER = true,
pg.DTE = false; PER = false,
pg.DCR = false; DTE = false,
pg.ReadRetryCount = 255; DCR = false,
ReadRetryCount = 255
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); };
md.Header = new Decoders.SCSI.Modes.ModeHeader(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode()
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; {
md.Pages[0] = new Decoders.SCSI.Modes.ModePage(); Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0].Page = 0x01; Pages = new Decoders.SCSI.Modes.ModePage[]
md.Pages[0].Subpage = 0x00; {
md.Pages[0].PageResponse = Decoders.SCSI.Modes.EncodeModePage_01(pg); new Decoders.SCSI.Modes.ModePage
{
Page = 0x01,
Subpage = 0x00,
PageResponse = Decoders.SCSI.Modes.EncodeModePage_01(pg)
}
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
} }
@@ -486,10 +513,14 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
else if(runningPersistent && persistent && currentModePage.HasValue) else if(runningPersistent && persistent && currentModePage.HasValue)
{ {
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Header = new Decoders.SCSI.Modes.ModeHeader(); {
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0] = currentModePage.Value; Pages = new Decoders.SCSI.Modes.ModePage[]
{
currentModePage.Value
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
@@ -566,9 +597,8 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values) foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
{ {
List<Partition> _partitions;
if(_partplugin.GetInformation(_imageFormat, out _partitions)) if(_partplugin.GetInformation(_imageFormat, out List<Partition> _partitions))
{ {
partitions.AddRange(_partitions); partitions.AddRange(_partitions);
Statistics.AddPartition(_partplugin.Name); Statistics.AddPartition(_partplugin.Name);
@@ -580,14 +610,15 @@ namespace DiscImageChef.Core.Devices.Dumping
xmlFileSysInfo = new PartitionType[partitions.Count]; xmlFileSysInfo = new PartitionType[partitions.Count];
for(int i = 0; i < partitions.Count; i++) for(int i = 0; i < partitions.Count; i++)
{ {
xmlFileSysInfo[i] = new PartitionType(); xmlFileSysInfo[i] = new PartitionType
xmlFileSysInfo[i].Description = partitions[i].PartitionDescription; {
xmlFileSysInfo[i].EndSector = (int)(partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1); Description = partitions[i].PartitionDescription,
xmlFileSysInfo[i].Name = partitions[i].PartitionName; EndSector = (int)(partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1),
xmlFileSysInfo[i].Sequence = (int)partitions[i].PartitionSequence; Name = partitions[i].PartitionName,
xmlFileSysInfo[i].StartSector = (int)partitions[i].PartitionStartSector; Sequence = (int)partitions[i].PartitionSequence,
xmlFileSysInfo[i].Type = partitions[i].PartitionType; StartSector = (int)partitions[i].PartitionStartSector,
Type = partitions[i].PartitionType
};
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem _plugin in plugins.PluginsList.Values) foreach(Filesystem _plugin in plugins.PluginsList.Values)
@@ -596,8 +627,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(_plugin.Identify(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1)) if(_plugin.Identify(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1))
{ {
string foo; _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out string foo);
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out foo);
lstFs.Add(_plugin.XmlFSType); lstFs.Add(_plugin.XmlFSType);
Statistics.AddFilesystem(_plugin.XmlFSType.Type); Statistics.AddFilesystem(_plugin.XmlFSType.Type);
@@ -626,10 +656,11 @@ namespace DiscImageChef.Core.Devices.Dumping
else else
{ {
xmlFileSysInfo = new PartitionType[1]; xmlFileSysInfo = new PartitionType[1];
xmlFileSysInfo[0] = new PartitionType(); xmlFileSysInfo[0] = new PartitionType
xmlFileSysInfo[0].EndSector = (int)(blocks - 1); {
xmlFileSysInfo[0].StartSector = 0; EndSector = (int)(blocks - 1),
StartSector = 0
};
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem _plugin in plugins.PluginsList.Values) foreach(Filesystem _plugin in plugins.PluginsList.Values)
@@ -638,8 +669,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(_plugin.Identify(_imageFormat, (blocks - 1), 0)) if(_plugin.Identify(_imageFormat, (blocks - 1), 0))
{ {
string foo; _plugin.GetInformation(_imageFormat, (blocks - 1), 0, out string foo);
_plugin.GetInformation(_imageFormat, (blocks - 1), 0, out foo);
lstFs.Add(_plugin.XmlFSType); lstFs.Add(_plugin.XmlFSType);
Statistics.AddFilesystem(_plugin.XmlFSType.Type); Statistics.AddFilesystem(_plugin.XmlFSType.Type);
@@ -670,37 +700,49 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray(); sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray();
sidecar.OpticalDisc[0].DumpHardwareArray = new DumpHardwareType[1]; sidecar.OpticalDisc[0].DumpHardwareArray = new DumpHardwareType[1];
sidecar.OpticalDisc[0].DumpHardwareArray[0] = new DumpHardwareType(); sidecar.OpticalDisc[0].DumpHardwareArray[0] = new DumpHardwareType
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents = new ExtentType[1]; {
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0] = new ExtentType(); Extents = new ExtentType[1]
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0].Start = 0; };
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0].End = (int)(blocks - 1); sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0] = new ExtentType
{
Start = 0,
End = (int)(blocks - 1)
};
sidecar.OpticalDisc[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer; sidecar.OpticalDisc[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Model = dev.Model; sidecar.OpticalDisc[0].DumpHardwareArray[0].Model = dev.Model;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Revision = dev.Revision; sidecar.OpticalDisc[0].DumpHardwareArray[0].Revision = dev.Revision;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Software = Version.GetSoftwareType(dev.PlatformID); sidecar.OpticalDisc[0].DumpHardwareArray[0].Software = Version.GetSoftwareType(dev.PlatformID);
sidecar.OpticalDisc[0].Image = new ImageType(); sidecar.OpticalDisc[0].Image = new ImageType
sidecar.OpticalDisc[0].Image.format = "Raw disk image (sector by sector copy)"; {
sidecar.OpticalDisc[0].Image.Value = outputPrefix + outputExtension; format = "Raw disk image (sector by sector copy)",
Value = outputPrefix + outputExtension
};
// TODO: Implement layers // TODO: Implement layers
//sidecar.OpticalDisc[0].Layers = new LayersType(); //sidecar.OpticalDisc[0].Layers = new LayersType();
sidecar.OpticalDisc[0].Sessions = 1; sidecar.OpticalDisc[0].Sessions = 1;
sidecar.OpticalDisc[0].Tracks = new[] { 1 }; sidecar.OpticalDisc[0].Tracks = new[] { 1 };
sidecar.OpticalDisc[0].Track = new Schemas.TrackType[1]; sidecar.OpticalDisc[0].Track = new Schemas.TrackType[1];
sidecar.OpticalDisc[0].Track[0] = new Schemas.TrackType(); sidecar.OpticalDisc[0].Track[0] = new Schemas.TrackType
sidecar.OpticalDisc[0].Track[0].BytesPerSector = (int)blockSize; {
sidecar.OpticalDisc[0].Track[0].Checksums = sidecar.OpticalDisc[0].Checksums; BytesPerSector = (int)blockSize,
sidecar.OpticalDisc[0].Track[0].EndSector = (long)(blocks - 1); Checksums = sidecar.OpticalDisc[0].Checksums,
sidecar.OpticalDisc[0].Track[0].Image = new ImageType(); EndSector = (long)(blocks - 1),
sidecar.OpticalDisc[0].Track[0].Image.format = "BINARY"; Image = new ImageType
sidecar.OpticalDisc[0].Track[0].Image.offset = 0; {
sidecar.OpticalDisc[0].Track[0].Image.offsetSpecified = true; format = "BINARY",
sidecar.OpticalDisc[0].Track[0].Image.Value = sidecar.OpticalDisc[0].Image.Value; offset = 0,
sidecar.OpticalDisc[0].Track[0].Sequence = new TrackSequenceType(); offsetSpecified = true,
sidecar.OpticalDisc[0].Track[0].Sequence.Session = 1; Value = sidecar.OpticalDisc[0].Image.Value
sidecar.OpticalDisc[0].Track[0].Sequence.TrackNumber = 1; },
sidecar.OpticalDisc[0].Track[0].Size = (long)(blocks * blockSize); Sequence = new TrackSequenceType
sidecar.OpticalDisc[0].Track[0].StartSector = 0; {
Session = 1,
TrackNumber = 1
},
Size = (long)(blocks * blockSize),
StartSector = 0
};
if(xmlFileSysInfo != null) if(xmlFileSysInfo != null)
sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo; sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo;
switch(dskType) switch(dskType)
@@ -740,8 +782,7 @@ namespace DiscImageChef.Core.Devices.Dumping
break; break;
} }
sidecar.OpticalDisc[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType); sidecar.OpticalDisc[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType);
string xmlDskTyp, xmlDskSubTyp; Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(dskType, out xmlDskTyp, out xmlDskSubTyp);
sidecar.OpticalDisc[0].DiscType = xmlDskTyp; sidecar.OpticalDisc[0].DiscType = xmlDskTyp;
sidecar.OpticalDisc[0].DiscSubType = xmlDskSubTyp; sidecar.OpticalDisc[0].DiscSubType = xmlDskSubTyp;
} }
@@ -749,14 +790,15 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray(); sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray();
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType); sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType);
string xmlDskTyp, xmlDskSubTyp; Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(dskType, out xmlDskTyp, out xmlDskSubTyp);
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
sidecar.BlockMedia[0].Image = new ImageType(); sidecar.BlockMedia[0].Image = new ImageType
sidecar.BlockMedia[0].Image.format = "Raw disk image (sector by sector copy)"; {
sidecar.BlockMedia[0].Image.Value = outputPrefix + ".bin"; format = "Raw disk image (sector by sector copy)",
Value = outputPrefix + ".bin"
};
if(!dev.IsRemovable || dev.IsUSB) if(!dev.IsRemovable || dev.IsUSB)
{ {
if(dev.Type == DeviceType.ATAPI) if(dev.Type == DeviceType.ATAPI)
@@ -781,11 +823,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dev.IsRemovable) if(dev.IsRemovable)
{ {
sidecar.BlockMedia[0].DumpHardwareArray = new DumpHardwareType[1]; sidecar.BlockMedia[0].DumpHardwareArray = new DumpHardwareType[1];
sidecar.BlockMedia[0].DumpHardwareArray[0] = new DumpHardwareType(); sidecar.BlockMedia[0].DumpHardwareArray[0] = new DumpHardwareType
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents = new ExtentType[1]; {
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0] = new ExtentType(); Extents = new ExtentType[1]
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0].Start = 0; };
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0].End = (int)(blocks - 1); sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0] = new ExtentType
{
Start = 0,
End = (int)(blocks - 1)
};
sidecar.BlockMedia[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer; sidecar.BlockMedia[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer;
sidecar.BlockMedia[0].DumpHardwareArray[0].Model = dev.Model; sidecar.BlockMedia[0].DumpHardwareArray[0].Model = dev.Model;
sidecar.BlockMedia[0].DumpHardwareArray[0].Revision = dev.Revision; sidecar.BlockMedia[0].DumpHardwareArray[0].Revision = dev.Revision;

View File

@@ -51,12 +51,11 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
byte[] senseBuf = null; byte[] senseBuf = null;
bool sense = false; bool sense = false;
double duration;
MediaType dskType = MediaType.Unknown; MediaType dskType = MediaType.Unknown;
if(dev.IsRemovable) if(dev.IsRemovable)
{ {
sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out duration); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out double duration);
if(sense) if(sense)
{ {
Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf); Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf);

View File

@@ -51,14 +51,10 @@ namespace DiscImageChef.Core.Devices.Dumping
internal static void Dump(Device dev, string outputPrefix, string devicePath, ref CICMMetadataType sidecar, ref Metadata.Resume resume) internal static void Dump(Device dev, string outputPrefix, string devicePath, ref CICMMetadataType sidecar, ref Metadata.Resume resume)
{ {
Decoders.SCSI.FixedSense? fxSense; Decoders.SCSI.FixedSense? fxSense;
string strSense;
bool aborted; bool aborted;
MHDDLog mhddLog; MHDDLog mhddLog;
IBGLog ibgLog; IBGLog ibgLog;
byte[] cmdBuf = null;
byte[] senseBuf = null;
bool sense = false; bool sense = false;
double duration;
ulong blocks = 0; ulong blocks = 0;
uint blockSize = 0; uint blockSize = 0;
MediaType dskType = MediaType.Unknown; MediaType dskType = MediaType.Unknown;
@@ -72,8 +68,8 @@ namespace DiscImageChef.Core.Devices.Dumping
List<ulong> unreadableSectors = new List<ulong>(); List<ulong> unreadableSectors = new List<ulong>();
Checksum dataChk; Checksum dataChk;
dev.RequestSense(out senseBuf, dev.Timeout, out duration); dev.RequestSense(out byte[] senseBuf, dev.Timeout, out double duration);
fxSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf, out strSense); fxSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf, out string strSense);
if(fxSense.HasValue && fxSense.Value.SenseKey != Decoders.SCSI.SenseKeys.NoSense) if(fxSense.HasValue && fxSense.Value.SenseKey != Decoders.SCSI.SenseKeys.NoSense)
{ {
@@ -115,7 +111,7 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
// Check position // Check position
sense = dev.ReadPosition(out cmdBuf, out senseBuf, SscPositionForms.Short, dev.Timeout, out duration); sense = dev.ReadPosition(out byte[] cmdBuf, out senseBuf, SscPositionForms.Short, dev.Timeout, out duration);
if(sense) if(sense)
{ {
@@ -187,8 +183,10 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
sidecar.BlockMedia = new BlockMediaType[1]; sidecar.BlockMedia = new BlockMediaType[1];
sidecar.BlockMedia[0] = new BlockMediaType(); sidecar.BlockMedia[0] = new BlockMediaType
sidecar.BlockMedia[0].SCSI = new SCSIType(); {
SCSI = new SCSIType()
};
byte scsiMediumTypeTape = 0; byte scsiMediumTypeTape = 0;
byte scsiDensityCodeTape = 0; byte scsiDensityCodeTape = 0;
@@ -205,10 +203,12 @@ namespace DiscImageChef.Core.Devices.Dumping
if(Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType).HasValue) if(Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType).HasValue)
{ {
decMode = Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType); decMode = Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.SCSIType);
sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType(); sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType
sidecar.BlockMedia[0].SCSI.ModeSense10.Image = outputPrefix + ".modesense10.bin"; {
sidecar.BlockMedia[0].SCSI.ModeSense10.Size = cmdBuf.Length; Image = outputPrefix + ".modesense10.bin",
sidecar.BlockMedia[0].SCSI.ModeSense10.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense10.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense10.Image, cmdBuf);
} }
} }
@@ -224,10 +224,12 @@ namespace DiscImageChef.Core.Devices.Dumping
if(Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType).HasValue) if(Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType).HasValue)
{ {
decMode = Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType); decMode = Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.SCSIType);
sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType(); sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType
sidecar.BlockMedia[0].SCSI.ModeSense.Image = outputPrefix + ".modesense.bin"; {
sidecar.BlockMedia[0].SCSI.ModeSense.Size = cmdBuf.Length; Image = outputPrefix + ".modesense.bin",
sidecar.BlockMedia[0].SCSI.ModeSense.Checksums = Checksum.GetChecksums(cmdBuf).ToArray(); Size = cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense.Image, cmdBuf); DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense.Image, cmdBuf);
} }
} }
@@ -335,24 +337,32 @@ namespace DiscImageChef.Core.Devices.Dumping
mhddLog = new MHDDLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, 1); mhddLog = new MHDDLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, 1);
ibgLog = new IBGLog(outputPrefix + ".ibg", 0x0008); ibgLog = new IBGLog(outputPrefix + ".ibg", 0x0008);
currentTapeFile = new TapeFileType(); currentTapeFile = new TapeFileType
currentTapeFile.Image = new ImageType(); {
currentTapeFile.Image.format = "BINARY"; Image = new ImageType
currentTapeFile.Image.offset = (long)currentSize; {
currentTapeFile.Image.offsetSpecified = true; format = "BINARY",
currentTapeFile.Image.Value = outputPrefix + ".bin"; offset = (long)currentSize,
currentTapeFile.Sequence = (long)currentFile; offsetSpecified = true,
currentTapeFile.StartBlock = (long)currentBlock; Value = outputPrefix + ".bin"
currentTapeFile.BlockSize = blockSize; },
Sequence = (long)currentFile,
StartBlock = (long)currentBlock,
BlockSize = blockSize
};
fileChk = new Checksum(); fileChk = new Checksum();
currentTapePartition = new TapePartitionType(); currentTapePartition = new TapePartitionType
currentTapePartition.Image = new ImageType(); {
currentTapePartition.Image.format = "BINARY"; Image = new ImageType
currentTapePartition.Image.offset = (long)currentSize; {
currentTapePartition.Image.offsetSpecified = true; format = "BINARY",
currentTapePartition.Image.Value = outputPrefix + ".bin"; offset = (long)currentSize,
currentTapePartition.Sequence = (long)currentPartition; offsetSpecified = true,
currentTapePartition.StartBlock = (long)currentBlock; Value = outputPrefix + ".bin"
},
Sequence = (long)currentPartition,
StartBlock = (long)currentBlock
};
partitionChk = new Checksum(); partitionChk = new Checksum();
aborted = false; aborted = false;
@@ -381,26 +391,34 @@ namespace DiscImageChef.Core.Devices.Dumping
if(currentPartition < totalPartitions) if(currentPartition < totalPartitions)
{ {
currentFile++; currentFile++;
currentTapeFile = new TapeFileType(); currentTapeFile = new TapeFileType
currentTapeFile.Image = new ImageType(); {
currentTapeFile.Image.format = "BINARY"; Image = new ImageType
currentTapeFile.Image.offset = (long)currentSize; {
currentTapeFile.Image.offsetSpecified = true; format = "BINARY",
currentTapeFile.Image.Value = outputPrefix + ".bin"; offset = (long)currentSize,
currentTapeFile.Sequence = (long)currentFile; offsetSpecified = true,
currentTapeFile.StartBlock = (long)currentBlock; Value = outputPrefix + ".bin"
currentTapeFile.BlockSize = blockSize; },
Sequence = (long)currentFile,
StartBlock = (long)currentBlock,
BlockSize = blockSize
};
currentFileSize = 0; currentFileSize = 0;
fileChk = new Checksum(); fileChk = new Checksum();
files = new List<TapeFileType>(); files = new List<TapeFileType>();
currentTapePartition = new TapePartitionType(); currentTapePartition = new TapePartitionType
currentTapePartition.Image = new ImageType(); {
currentTapePartition.Image.format = "BINARY"; Image = new ImageType
currentTapePartition.Image.offset = (long)currentSize; {
currentTapePartition.Image.offsetSpecified = true; format = "BINARY",
currentTapePartition.Image.Value = outputPrefix + ".bin"; offset = (long)currentSize,
currentTapePartition.Sequence = currentPartition; offsetSpecified = true,
currentTapePartition.StartBlock = (long)currentBlock; Value = outputPrefix + ".bin"
},
Sequence = currentPartition,
StartBlock = (long)currentBlock
};
currentPartitionSize = 0; currentPartitionSize = 0;
partitionChk = new Checksum(); partitionChk = new Checksum();
DicConsole.WriteLine("Seeking to partition {0}", currentPartition); DicConsole.WriteLine("Seeking to partition {0}", currentPartition);
@@ -491,15 +509,19 @@ namespace DiscImageChef.Core.Devices.Dumping
files.Add(currentTapeFile); files.Add(currentTapeFile);
currentFile++; currentFile++;
currentTapeFile = new TapeFileType(); currentTapeFile = new TapeFileType
currentTapeFile.Image = new ImageType(); {
currentTapeFile.Image.format = "BINARY"; Image = new ImageType
currentTapeFile.Image.offset = (long)currentSize; {
currentTapeFile.Image.offsetSpecified = true; format = "BINARY",
currentTapeFile.Image.Value = outputPrefix + ".bin"; offset = (long)currentSize,
currentTapeFile.Sequence = (long)currentFile; offsetSpecified = true,
currentTapeFile.StartBlock = (long)currentBlock; Value = outputPrefix + ".bin"
currentTapeFile.BlockSize = blockSize; },
Sequence = (long)currentFile,
StartBlock = (long)currentBlock,
BlockSize = blockSize
};
currentFileSize = 0; currentFileSize = 0;
fileChk = new Checksum(); fileChk = new Checksum();
@@ -550,22 +572,27 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray(); sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray();
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType); sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType);
string xmlDskTyp, xmlDskSubTyp; Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(dskType, out xmlDskTyp, out xmlDskSubTyp);
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
sidecar.BlockMedia[0].Image = new ImageType(); sidecar.BlockMedia[0].Image = new ImageType
sidecar.BlockMedia[0].Image.format = "Raw disk image (sector by sector copy)"; {
sidecar.BlockMedia[0].Image.Value = outputPrefix + ".bin"; format = "Raw disk image (sector by sector copy)",
Value = outputPrefix + ".bin"
};
sidecar.BlockMedia[0].LogicalBlocks = (long)blocks; sidecar.BlockMedia[0].LogicalBlocks = (long)blocks;
sidecar.BlockMedia[0].Size = (long)(currentSize); sidecar.BlockMedia[0].Size = (long)(currentSize);
sidecar.BlockMedia[0].DumpHardwareArray = new DumpHardwareType[1]; sidecar.BlockMedia[0].DumpHardwareArray = new DumpHardwareType[1];
sidecar.BlockMedia[0].DumpHardwareArray[0] = new DumpHardwareType(); sidecar.BlockMedia[0].DumpHardwareArray[0] = new DumpHardwareType
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents = new ExtentType[1]; {
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0] = new ExtentType(); Extents = new ExtentType[1]
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0].Start = 0; };
sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0].End = (int)(blocks - 1); sidecar.BlockMedia[0].DumpHardwareArray[0].Extents[0] = new ExtentType
{
Start = 0,
End = (int)(blocks - 1)
};
sidecar.BlockMedia[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer; sidecar.BlockMedia[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer;
sidecar.BlockMedia[0].DumpHardwareArray[0].Model = dev.Model; sidecar.BlockMedia[0].DumpHardwareArray[0].Model = dev.Model;
sidecar.BlockMedia[0].DumpHardwareArray[0].Revision = dev.Revision; sidecar.BlockMedia[0].DumpHardwareArray[0].Revision = dev.Revision;

View File

@@ -56,15 +56,11 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
MHDDLog mhddLog; MHDDLog mhddLog;
IBGLog ibgLog; IBGLog ibgLog;
byte[] senseBuf = null;
bool sense = false; bool sense = false;
double duration;
ulong blocks = 0; ulong blocks = 0;
uint blockSize = 2048; uint blockSize = 2048;
byte[] readBuffer;
uint blocksToRead = 64; uint blocksToRead = 64;
ulong errored = 0; ulong errored = 0;
byte[] ssBuf;
DateTime start; DateTime start;
DateTime end; DateTime end;
double totalDuration = 0; double totalDuration = 0;
@@ -81,7 +77,7 @@ namespace DiscImageChef.Core.Devices.Dumping
e.Cancel = aborted = true; e.Cancel = aborted = true;
}; };
sense = dev.KreonExtractSS(out ssBuf, out senseBuf, dev.Timeout, out duration); sense = dev.KreonExtractSS(out byte[] ssBuf, out byte[] senseBuf, dev.Timeout, out double duration);
if(sense) if(sense)
{ {
DicConsole.ErrorWriteLine("Cannot get Xbox Security Sector, not continuing."); DicConsole.ErrorWriteLine("Cannot get Xbox Security Sector, not continuing.");
@@ -113,7 +109,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.ErrorWriteLine("Cannot lock drive, not continuing."); DicConsole.ErrorWriteLine("Cannot lock drive, not continuing.");
return; return;
} }
sense = dev.ReadCapacity(out readBuffer, out senseBuf, dev.Timeout, out duration); sense = dev.ReadCapacity(out byte[] readBuffer, out senseBuf, dev.Timeout, out duration);
if(sense) if(sense)
{ {
DicConsole.ErrorWriteLine("Cannot get disc capacity."); DicConsole.ErrorWriteLine("Cannot get disc capacity.");
@@ -505,42 +501,56 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice)
{ {
Decoders.SCSI.Modes.ModePage_01_MMC pgMMC = new Decoders.SCSI.Modes.ModePage_01_MMC(); Decoders.SCSI.Modes.ModePage_01_MMC pgMMC = new Decoders.SCSI.Modes.ModePage_01_MMC
pgMMC.PS = false; {
pgMMC.ReadRetryCount = 255; PS = false,
pgMMC.Parameter = 0x20; ReadRetryCount = 255,
Parameter = 0x20
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); };
md.Header = new Decoders.SCSI.Modes.ModeHeader(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; {
md.Pages[0] = new Decoders.SCSI.Modes.ModePage(); Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0].Page = 0x01; Pages = new Decoders.SCSI.Modes.ModePage[]
md.Pages[0].Subpage = 0x00; {
md.Pages[0].PageResponse = Decoders.SCSI.Modes.EncodeModePage_01_MMC(pgMMC); new Decoders.SCSI.Modes.ModePage
{
Page = 0x01,
Subpage = 0x00,
PageResponse = Decoders.SCSI.Modes.EncodeModePage_01_MMC(pgMMC)
}
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
} }
else else
{ {
Decoders.SCSI.Modes.ModePage_01 pg = new Decoders.SCSI.Modes.ModePage_01(); Decoders.SCSI.Modes.ModePage_01 pg = new Decoders.SCSI.Modes.ModePage_01
pg.PS = false; {
pg.AWRE = false; PS = false,
pg.ARRE = false; AWRE = false,
pg.TB = true; ARRE = false,
pg.RC = false; TB = true,
pg.EER = true; RC = false,
pg.PER = false; EER = true,
pg.DTE = false; PER = false,
pg.DCR = false; DTE = false,
pg.ReadRetryCount = 255; DCR = false,
ReadRetryCount = 255
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); };
md.Header = new Decoders.SCSI.Modes.ModeHeader(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; {
md.Pages[0] = new Decoders.SCSI.Modes.ModePage(); Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0].Page = 0x01; Pages = new Decoders.SCSI.Modes.ModePage[]
md.Pages[0].Subpage = 0x00; {
md.Pages[0].PageResponse = Decoders.SCSI.Modes.EncodeModePage_01(pg); new Decoders.SCSI.Modes.ModePage
{
Page = 0x01,
Subpage = 0x00,
PageResponse = Decoders.SCSI.Modes.EncodeModePage_01(pg)
}
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
} }
@@ -560,10 +570,14 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
else if(runningPersistent && persistent && currentModePage.HasValue) else if(runningPersistent && persistent && currentModePage.HasValue)
{ {
Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode(); Decoders.SCSI.Modes.DecodedMode md = new Decoders.SCSI.Modes.DecodedMode
md.Header = new Decoders.SCSI.Modes.ModeHeader(); {
md.Pages = new Decoders.SCSI.Modes.ModePage[1]; Header = new Decoders.SCSI.Modes.ModeHeader(),
md.Pages[0] = currentModePage.Value; Pages = new Decoders.SCSI.Modes.ModePage[]
{
currentModePage.Value
}
};
md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType); md6 = Decoders.SCSI.Modes.EncodeMode6(md, dev.SCSIType);
md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType); md10 = Decoders.SCSI.Modes.EncodeMode10(md, dev.SCSIType);
@@ -642,9 +656,8 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values) foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
{ {
List<Partition> _partitions;
if(_partplugin.GetInformation(_imageFormat, out _partitions)) if(_partplugin.GetInformation(_imageFormat, out List<Partition> _partitions))
{ {
partitions.AddRange(_partitions); partitions.AddRange(_partitions);
Statistics.AddPartition(_partplugin.Name); Statistics.AddPartition(_partplugin.Name);
@@ -656,14 +669,15 @@ namespace DiscImageChef.Core.Devices.Dumping
xmlFileSysInfo = new PartitionType[partitions.Count]; xmlFileSysInfo = new PartitionType[partitions.Count];
for(int i = 0; i < partitions.Count; i++) for(int i = 0; i < partitions.Count; i++)
{ {
xmlFileSysInfo[i] = new PartitionType(); xmlFileSysInfo[i] = new PartitionType
xmlFileSysInfo[i].Description = partitions[i].PartitionDescription; {
xmlFileSysInfo[i].EndSector = (int)(partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1); Description = partitions[i].PartitionDescription,
xmlFileSysInfo[i].Name = partitions[i].PartitionName; EndSector = (int)(partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1),
xmlFileSysInfo[i].Sequence = (int)partitions[i].PartitionSequence; Name = partitions[i].PartitionName,
xmlFileSysInfo[i].StartSector = (int)partitions[i].PartitionStartSector; Sequence = (int)partitions[i].PartitionSequence,
xmlFileSysInfo[i].Type = partitions[i].PartitionType; StartSector = (int)partitions[i].PartitionStartSector,
Type = partitions[i].PartitionType
};
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem _plugin in plugins.PluginsList.Values) foreach(Filesystem _plugin in plugins.PluginsList.Values)
@@ -672,8 +686,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(_plugin.Identify(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1)) if(_plugin.Identify(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1))
{ {
string foo; _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out string foo);
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out foo);
lstFs.Add(_plugin.XmlFSType); lstFs.Add(_plugin.XmlFSType);
Statistics.AddFilesystem(_plugin.XmlFSType.Type); Statistics.AddFilesystem(_plugin.XmlFSType.Type);
@@ -702,10 +715,11 @@ namespace DiscImageChef.Core.Devices.Dumping
else else
{ {
xmlFileSysInfo = new PartitionType[1]; xmlFileSysInfo = new PartitionType[1];
xmlFileSysInfo[0] = new PartitionType(); xmlFileSysInfo[0] = new PartitionType
xmlFileSysInfo[0].EndSector = (int)(blocks - 1); {
xmlFileSysInfo[0].StartSector = 0; EndSector = (int)(blocks - 1),
StartSector = 0
};
List<FileSystemType> lstFs = new List<FileSystemType>(); List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem _plugin in plugins.PluginsList.Values) foreach(Filesystem _plugin in plugins.PluginsList.Values)
@@ -714,8 +728,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
if(_plugin.Identify(_imageFormat, (blocks - 1), 0)) if(_plugin.Identify(_imageFormat, (blocks - 1), 0))
{ {
string foo; _plugin.GetInformation(_imageFormat, (blocks - 1), 0, out string foo);
_plugin.GetInformation(_imageFormat, (blocks - 1), 0, out foo);
lstFs.Add(_plugin.XmlFSType); lstFs.Add(_plugin.XmlFSType);
Statistics.AddFilesystem(_plugin.XmlFSType.Type); Statistics.AddFilesystem(_plugin.XmlFSType.Type);
@@ -744,47 +757,62 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray(); sidecar.OpticalDisc[0].Checksums = dataChk.End().ToArray();
sidecar.OpticalDisc[0].DumpHardwareArray = new DumpHardwareType[1]; sidecar.OpticalDisc[0].DumpHardwareArray = new DumpHardwareType[1];
sidecar.OpticalDisc[0].DumpHardwareArray[0] = new DumpHardwareType(); sidecar.OpticalDisc[0].DumpHardwareArray[0] = new DumpHardwareType
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents = new ExtentType[1]; {
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0] = new ExtentType(); Extents = new ExtentType[1]
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0].Start = 0; };
sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0].End = (int)(blocks - 1); sidecar.OpticalDisc[0].DumpHardwareArray[0].Extents[0] = new ExtentType
{
Start = 0,
End = (int)(blocks - 1)
};
sidecar.OpticalDisc[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer; sidecar.OpticalDisc[0].DumpHardwareArray[0].Manufacturer = dev.Manufacturer;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Model = dev.Model; sidecar.OpticalDisc[0].DumpHardwareArray[0].Model = dev.Model;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Revision = dev.Revision; sidecar.OpticalDisc[0].DumpHardwareArray[0].Revision = dev.Revision;
sidecar.OpticalDisc[0].DumpHardwareArray[0].Software = Version.GetSoftwareType(dev.PlatformID); sidecar.OpticalDisc[0].DumpHardwareArray[0].Software = Version.GetSoftwareType(dev.PlatformID);
sidecar.OpticalDisc[0].Image = new ImageType(); sidecar.OpticalDisc[0].Image = new ImageType
sidecar.OpticalDisc[0].Image.format = "Raw disk image (sector by sector copy)"; {
sidecar.OpticalDisc[0].Image.Value = outputPrefix + ".iso"; format = "Raw disk image (sector by sector copy)",
sidecar.OpticalDisc[0].Layers = new LayersType(); Value = outputPrefix + ".iso"
sidecar.OpticalDisc[0].Layers.type = LayersTypeType.OTP; };
sidecar.OpticalDisc[0].Layers.typeSpecified = true; sidecar.OpticalDisc[0].Layers = new LayersType
sidecar.OpticalDisc[0].Layers.Sectors = new SectorsType[1]; {
sidecar.OpticalDisc[0].Layers.Sectors[0] = new SectorsType(); type = LayersTypeType.OTP,
sidecar.OpticalDisc[0].Layers.Sectors[0].Value = (long)layerBreak; typeSpecified = true,
Sectors = new SectorsType[1]
};
sidecar.OpticalDisc[0].Layers.Sectors[0] = new SectorsType
{
Value = (long)layerBreak
};
sidecar.OpticalDisc[0].Sessions = 1; sidecar.OpticalDisc[0].Sessions = 1;
sidecar.OpticalDisc[0].Tracks = new[] { 1 }; sidecar.OpticalDisc[0].Tracks = new[] { 1 };
sidecar.OpticalDisc[0].Track = new Schemas.TrackType[1]; sidecar.OpticalDisc[0].Track = new Schemas.TrackType[1];
sidecar.OpticalDisc[0].Track[0] = new Schemas.TrackType(); sidecar.OpticalDisc[0].Track[0] = new Schemas.TrackType
sidecar.OpticalDisc[0].Track[0].BytesPerSector = (int)blockSize; {
sidecar.OpticalDisc[0].Track[0].Checksums = sidecar.OpticalDisc[0].Checksums; BytesPerSector = (int)blockSize,
sidecar.OpticalDisc[0].Track[0].EndSector = (long)(blocks - 1); Checksums = sidecar.OpticalDisc[0].Checksums,
sidecar.OpticalDisc[0].Track[0].Image = new ImageType(); EndSector = (long)(blocks - 1),
sidecar.OpticalDisc[0].Track[0].Image.format = "BINARY"; Image = new ImageType()
sidecar.OpticalDisc[0].Track[0].Image.offset = 0; {
sidecar.OpticalDisc[0].Track[0].Image.offsetSpecified = true; format = "BINARY",
sidecar.OpticalDisc[0].Track[0].Image.Value = sidecar.OpticalDisc[0].Image.Value; offset = 0,
sidecar.OpticalDisc[0].Track[0].Sequence = new TrackSequenceType(); offsetSpecified = true,
sidecar.OpticalDisc[0].Track[0].Sequence.Session = 1; Value = sidecar.OpticalDisc[0].Image.Value
sidecar.OpticalDisc[0].Track[0].Sequence.TrackNumber = 1; },
sidecar.OpticalDisc[0].Track[0].Size = (long)(totalSize * blockSize); Sequence = new TrackSequenceType()
sidecar.OpticalDisc[0].Track[0].StartSector = 0; {
Session = 1,
TrackNumber = 1
},
Size = (long)(totalSize * blockSize),
StartSector = 0
};
if(xmlFileSysInfo != null) if(xmlFileSysInfo != null)
sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo; sidecar.OpticalDisc[0].Track[0].FileSystemInformation = xmlFileSysInfo;
sidecar.OpticalDisc[0].Track[0].TrackType1 = TrackTypeTrackType.dvd; sidecar.OpticalDisc[0].Track[0].TrackType1 = TrackTypeTrackType.dvd;
sidecar.OpticalDisc[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType); sidecar.OpticalDisc[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(dskType);
string xmlDskTyp, xmlDskSubTyp; Metadata.MediaType.MediaTypeToString(dskType, out string xmlDskTyp, out string xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(dskType, out xmlDskTyp, out xmlDskSubTyp);
sidecar.OpticalDisc[0].DiscType = xmlDskTyp; sidecar.OpticalDisc[0].DiscType = xmlDskTyp;
sidecar.OpticalDisc[0].DiscSubType = xmlDskSubTyp; sidecar.OpticalDisc[0].DiscSubType = xmlDskSubTyp;
} }