REFACTOR: Final cleanup of DiscImageChef.Core.

This commit is contained in:
2017-12-23 17:41:23 +00:00
parent e05de44620
commit 380dbad1a0
48 changed files with 986 additions and 1017 deletions

View File

@@ -53,12 +53,12 @@ using Tuple = DiscImageChef.Decoders.PCMCIA.Tuple;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implements dumping ATA devices
/// Implements dumping ATA devices
/// </summary>
public class Ata
{
/// <summary>
/// Dumps an ATA device
/// Dumps an ATA device
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -73,8 +73,8 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="encoding">Encoding to use when analyzing dump</param>
/// <exception cref="InvalidOperationException">If the resume file is invalid</exception>
public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force,
bool dumpRaw, bool persistent, bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding)
bool dumpRaw, bool persistent, bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding)
{
bool aborted;
@@ -99,11 +99,11 @@ namespace DiscImageChef.Core.Devices.Dumping
if(!sense && Identify.Decode(cmdBuf).HasValue)
{
Identify.IdentifyDevice? ataIdNullable = Identify.Decode(cmdBuf);
if(ataIdNullable != null) {
if(ataIdNullable != null)
{
Identify.IdentifyDevice ataId = ataIdNullable.Value;
CICMMetadataType sidecar =
new CICMMetadataType {BlockMedia = new[] {new BlockMediaType()}};
CICMMetadataType sidecar = new CICMMetadataType {BlockMedia = new[] {new BlockMediaType()}};
if(dev.IsUsb)
{
@@ -139,7 +139,8 @@ namespace DiscImageChef.Core.Devices.Dumping
Tuple[] tuples = CIS.GetTuples(dev.Cis);
if(tuples != null)
foreach(Tuple tuple in tuples)
switch(tuple.Code) {
switch(tuple.Code)
{
case TupleCodes.CISTPL_MANFID:
ManufacturerIdentificationTuple manfid =
CIS.DecodeManufacturerIdentificationTuple(tuple);
@@ -161,7 +162,8 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].PCMCIA.ProductName = vers.Product;
sidecar.BlockMedia[0].PCMCIA.Compliance =
$"{vers.MajorVersion}.{vers.MinorVersion}";
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation;
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation =
vers.AdditionalInformation;
}
break;
}
@@ -233,8 +235,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Device reports {0} bytes per physical block.", physicalsectorsize);
bool removable = !dev.IsCompactFlash &&
ataId.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit
.Removable);
ataId.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit.Removable);
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(ataReader.IsLba, removable, blocks, dev.Manufacturer, dev.Model, dev.Serial,
@@ -304,8 +305,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine();
mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000),
devicePath);
blockSize * (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));
@@ -388,8 +388,8 @@ namespace DiscImageChef.Core.Devices.Dumping
if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", cy, hd,
sc, currentSpeed);
DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", cy,
hd, sc, currentSpeed);
bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration);
@@ -401,7 +401,8 @@ namespace DiscImageChef.Core.Devices.Dumping
ibgLog.Write(currentBlock, currentSpeed * 1024);
dumpFile.Write(cmdBuf);
extents.Add(currentBlock);
dumpLog.WriteLine("Error reading cylinder {0} head {1} sector {2}.", cy, hd, sc);
dumpLog.WriteLine("Error reading cylinder {0} head {1} sector {2}.", cy, hd,
sc);
}
else
{
@@ -424,8 +425,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine();
mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000),
devicePath);
blockSize * (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));
@@ -572,10 +572,12 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray();
string xmlDskTyp, xmlDskSubTyp;
if(dev.IsCompactFlash)
MediaType.MediaTypeToString(CommonTypes.MediaType.CompactFlash, out xmlDskTyp, out xmlDskSubTyp);
MediaType.MediaTypeToString(CommonTypes.MediaType.CompactFlash, out xmlDskTyp,
out xmlDskSubTyp);
else if(dev.IsPcmcia)
MediaType.MediaTypeToString(CommonTypes.MediaType.PCCardTypeI, out xmlDskTyp, out xmlDskSubTyp);
else MediaType.MediaTypeToString(CommonTypes.MediaType.GENERIC_HDD, out xmlDskTyp, out xmlDskSubTyp);
else
MediaType.MediaTypeToString(CommonTypes.MediaType.GENERIC_HDD, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].DiskType = xmlDskTyp;
sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp;
// TODO: Implement device firmware revision
@@ -605,8 +607,9 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine();
DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming).",
(end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000);
DicConsole
.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming).",
(end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000);
DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000));
DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed);
@@ -621,8 +624,7 @@ namespace DiscImageChef.Core.Devices.Dumping
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer =
new XmlSerializer(typeof(CICMMetadataType));
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}

View File

@@ -44,120 +44,16 @@ namespace DiscImageChef.Core.Devices.Dumping
// TODO: For >4.0, this class must disappear
class Alcohol120
{
#region Internal Structures
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholHeader
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string signature;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] version;
public AlcoholMediumType type;
public ushort sessions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public ushort[] unknown1;
public ushort bcaLength;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] unknown2;
public uint bcaOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public uint[] unknown3;
public uint structuresOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] unknown4;
public uint sessionOffset;
public uint dpmOffset;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholSession
{
public int sessionStart;
public int sessionEnd;
public ushort sessionSequence;
public byte allBlocks;
public byte nonTrackBlocks;
public ushort firstTrack;
public ushort lastTrack;
public uint unknown;
public uint trackOffset;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholTrack
{
public AlcoholTrackMode mode;
public AlcoholSubchannelMode subMode;
public byte adrCtl;
public byte tno;
public byte point;
public byte min;
public byte sec;
public byte frame;
public byte zero;
public byte pmin;
public byte psec;
public byte pframe;
public uint extraOffset;
public ushort sectorSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)] public byte[] unknown;
public uint startLba;
public ulong startOffset;
public uint files;
public uint footerOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] unknown2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholTrackExtra
{
public uint pregap;
public uint sectors;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholFooter
{
public uint filenameOffset;
public uint widechar;
public uint unknown1;
public uint unknown2;
}
#endregion Internal Structures
#region Internal enumerations
enum AlcoholMediumType : ushort
{
Cd = 0x00,
Cdr = 0x01,
Cdrw = 0x02,
Dvd = 0x10,
Dvdr = 0x12
}
enum AlcoholTrackMode : byte
{
NoData = 0x00,
Dvd = 0x02,
Audio = 0xA9,
Mode1 = 0xAA,
Mode2 = 0xAB,
Mode2F1 = 0xAC,
Mode2F2 = 0xAD
}
enum AlcoholSubchannelMode : byte
{
None = 0x00,
Interleaved = 0x08
}
#endregion Internal enumerations
string outputPrefix;
string extension;
byte[] bca;
byte[] pfi;
byte[] dmi;
string extension;
AlcoholFooter footer;
AlcoholHeader header;
List<AlcoholTrack> tracks;
string outputPrefix;
byte[] pfi;
List<AlcoholSession> sessions;
Dictionary<byte, uint> trackLengths;
AlcoholFooter footer;
List<AlcoholTrack> tracks;
internal Alcohol120(string outputPrefix)
{
@@ -382,7 +278,7 @@ namespace DiscImageChef.Core.Devices.Dumping
firstTrack = (ushort)cdSession.StartTrack,
lastTrack = (ushort)cdSession.EndTrack,
sessionSequence = cdSession.SessionSequence
})) { sessions.Add(session); }
})) sessions.Add(session);
}
internal void SetTrackTypes(byte point, TrackType mode, TrackSubchannelType subMode)
@@ -470,7 +366,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
internal void AddTrack(byte adrCtl, byte tno, byte point, byte min, byte sec, byte frame, byte zero, byte pmin,
byte psec, byte pframe, byte session)
byte psec, byte pframe, byte session)
{
AlcoholTrack trk = new AlcoholTrack
{
@@ -531,5 +427,108 @@ namespace DiscImageChef.Core.Devices.Dumping
{
this.extension = extension;
}
#region Internal Structures
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholHeader
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string signature;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] version;
public AlcoholMediumType type;
public ushort sessions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public ushort[] unknown1;
public ushort bcaLength;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] unknown2;
public uint bcaOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public uint[] unknown3;
public uint structuresOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] unknown4;
public uint sessionOffset;
public uint dpmOffset;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholSession
{
public int sessionStart;
public int sessionEnd;
public ushort sessionSequence;
public byte allBlocks;
public byte nonTrackBlocks;
public ushort firstTrack;
public ushort lastTrack;
public uint unknown;
public uint trackOffset;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholTrack
{
public AlcoholTrackMode mode;
public AlcoholSubchannelMode subMode;
public byte adrCtl;
public byte tno;
public byte point;
public byte min;
public byte sec;
public byte frame;
public byte zero;
public byte pmin;
public byte psec;
public byte pframe;
public uint extraOffset;
public ushort sectorSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)] public byte[] unknown;
public uint startLba;
public ulong startOffset;
public uint files;
public uint footerOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] unknown2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholTrackExtra
{
public uint pregap;
public uint sectors;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AlcoholFooter
{
public uint filenameOffset;
public uint widechar;
public uint unknown1;
public uint unknown2;
}
#endregion Internal Structures
#region Internal enumerations
enum AlcoholMediumType : ushort
{
Cd = 0x00,
Cdr = 0x01,
Cdrw = 0x02,
Dvd = 0x10,
Dvdr = 0x12
}
enum AlcoholTrackMode : byte
{
NoData = 0x00,
Dvd = 0x02,
Audio = 0xA9,
Mode1 = 0xAA,
Mode2 = 0xAB,
Mode2F1 = 0xAC,
Mode2F2 = 0xAD
}
enum AlcoholSubchannelMode : byte
{
None = 0x00,
Interleaved = 0x08
}
#endregion Internal enumerations
}
}

View File

@@ -53,12 +53,12 @@ using TrackType = Schemas.TrackType;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implement dumping Compact Discs
/// Implement dumping Compact Discs
/// </summary>
class CompactDisc
{
/// <summary>
/// Dumps a compact disc
/// Dumps a compact disc
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -147,12 +147,10 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading Disc Information");
sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf,
MmcDiscInformationDataTypes.DiscInformation, dev.Timeout,
out _);
MmcDiscInformationDataTypes.DiscInformation, dev.Timeout, out _);
if(!sense)
{
DiscInformation.StandardDiscInformation? discInfo =
DiscInformation.Decode000b(cmdBuf);
DiscInformation.StandardDiscInformation? discInfo = DiscInformation.Decode000b(cmdBuf);
if(discInfo.HasValue)
if(dskType == MediaType.CD)
switch(discInfo.Value.DiscType)
@@ -191,8 +189,8 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(FullTOC.TrackDataDescriptor track in toc.Value.TrackDescriptors)
{
if(track.TNO == 1 && ((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack ||
(TocControl)(track.CONTROL & 0x0D) ==
TocControl.DataTrackIncremental)) allFirstSessionTracksAreAudio &= firstTrackLastSession != 1;
(TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)
) allFirstSessionTracksAreAudio &= firstTrackLastSession != 1;
if((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack ||
(TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)
@@ -265,7 +263,10 @@ namespace DiscImageChef.Core.Devices.Dumping
sessionsForAlcohol[i].SessionSequence = (ushort)(i + 1);
sessionsForAlcohol[i].StartTrack = ushort.MaxValue;
}
foreach(FullTOC.TrackDataDescriptor trk in toc.Value.TrackDescriptors.Where(trk => trk.POINT > 0 && trk.POINT < 0xA0 && trk.SessionNumber <= sessionsForAlcohol.Length)) {
foreach(FullTOC.TrackDataDescriptor trk in
toc.Value.TrackDescriptors.Where(trk => trk.POINT > 0 && trk.POINT < 0xA0 &&
trk.SessionNumber <= sessionsForAlcohol.Length))
{
if(trk.POINT < sessionsForAlcohol[trk.SessionNumber - 1].StartTrack)
sessionsForAlcohol[trk.SessionNumber - 1].StartTrack = trk.POINT;
if(trk.POINT > sessionsForAlcohol[trk.SessionNumber - 1].EndTrack)
@@ -283,7 +284,8 @@ namespace DiscImageChef.Core.Devices.Dumping
List<TrackType> trackList = new List<TrackType>();
long lastSector = 0;
string lastMsf = null;
foreach(FullTOC.TrackDataDescriptor trk in sortedTracks.Where(trk => trk.ADR == 1 || trk.ADR == 4)) if(trk.POINT >= 0x01 && trk.POINT <= 0x63)
foreach(FullTOC.TrackDataDescriptor trk in sortedTracks.Where(trk => trk.ADR == 1 || trk.ADR == 4))
if(trk.POINT >= 0x01 && trk.POINT <= 0x63)
{
TrackType track = new TrackType
{
@@ -294,11 +296,10 @@ namespace DiscImageChef.Core.Devices.Dumping
track.TrackType1 = TrackTypeTrackType.mode1;
else track.TrackType1 = TrackTypeTrackType.audio;
if(trk.PHOUR > 0)
track.StartMSF = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", trk.PMIN, trk.PSEC,
trk.PFRAME, trk.PHOUR);
track.StartMSF = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", trk.PMIN, trk.PSEC, trk.PFRAME,
trk.PHOUR);
else track.StartMSF = $"{trk.PMIN:D2}:{trk.PSEC:D2}:{trk.PFRAME:D2}";
track.StartSector = trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME -
150;
track.StartSector = trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME - 150;
trackList.Add(track);
}
else if(trk.POINT == 0xA2)
@@ -338,7 +339,9 @@ namespace DiscImageChef.Core.Devices.Dumping
phour = trk.PHOUR;
}
lastMsf = phour > 0 ? $"{phour:D2}:{pmin:D2}:{psec:D2}:{pframe:D2}" : $"{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;
}
@@ -365,7 +368,9 @@ namespace DiscImageChef.Core.Devices.Dumping
pframe -= psec * 75;
}
tracks[t - 1].EndMSF = phour > 0 ? $"{phour:D2}:{pmin:D2}:{psec:D2}:{pframe:D2}" : $"{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;
@@ -608,8 +613,7 @@ namespace DiscImageChef.Core.Devices.Dumping
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf));
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}", Sense.PrettifySense(senseBuf));
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
@@ -715,7 +719,8 @@ 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 double cmdDuration);
true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout,
out double cmdDuration);
totalDuration += cmdDuration;
}
@@ -891,8 +896,7 @@ namespace DiscImageChef.Core.Devices.Dumping
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer =
new XmlSerializer(typeof(CICMMetadataType));
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
alcohol.Close();

View File

@@ -49,12 +49,12 @@ using Spare = DiscImageChef.Decoders.DVD.Spare;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implement dumping optical discs from MultiMedia devices
/// Implement dumping optical discs from MultiMedia devices
/// </summary>
static class Mmc
{
/// <summary>
/// Dumps an optical disc
/// Dumps an optical disc
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -204,7 +204,8 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Device reports disc has {0} blocks", blocks);
#region Nintendo
switch(dskType) {
switch(dskType)
{
case MediaType.Unknown when blocks > 0:
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
@@ -333,8 +334,7 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ScsiInquiry(out byte[] inqBuf, out _);
if(sense || !Inquiry.Decode(inqBuf).HasValue ||
Inquiry.Decode(inqBuf).HasValue &&
if(sense || !Inquiry.Decode(inqBuf).HasValue || Inquiry.Decode(inqBuf).HasValue &&
!Inquiry.Decode(inqBuf).Value.KreonPresent)
{
dumpLog.WriteLine("Dumping Xbox Game Discs requires a drive with Kreon firmware.");
@@ -381,8 +381,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
dumpLog.WriteLine("Reading Lead-in Copyright Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout,
out _);
MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout, out _);
if(!sense)
if(CSS_CPRM.DecodeLeadInCopyright(cmdBuf).HasValue)
{
@@ -396,15 +395,15 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf);
CSS_CPRM.LeadInCopyright cpy =
CSS_CPRM.DecodeLeadInCopyright(cmdBuf).Value;
CSS_CPRM.LeadInCopyright cpy = CSS_CPRM.DecodeLeadInCopyright(cmdBuf).Value;
if(cpy.CopyrightType != CopyrightType.NoProtection)
sidecar.OpticalDisc[0].CopyProtection = cpy.CopyrightType.ToString();
}
}
#endregion DVD-ROM
switch(dskType) {
switch(dskType)
{
#region DVD-ROM and HD DVD-ROM
case MediaType.DVDDownload:
case MediaType.DVDROM:
@@ -427,6 +426,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
break;
#endregion DVD-ROM and HD DVD-ROM
#region DVD-RAM and HD DVD-RAM
case MediaType.DVDRAM:
case MediaType.HDDVDRAM:
@@ -466,6 +466,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
break;
#endregion DVD-RAM and HD DVD-RAM
#region DVD-R and DVD-RW
case MediaType.DVDR:
case MediaType.DVDRW:
@@ -488,15 +489,15 @@ namespace DiscImageChef.Core.Devices.Dumping
#endregion DVD-R and DVD-RW
}
switch(dskType) {
switch(dskType)
{
#region DVD-R, DVD-RW and HD DVD-R
case MediaType.DVDR:
case MediaType.DVDRW:
case MediaType.HDDVDR:
dumpLog.WriteLine("Reading Media Identifier.");
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout,
out _);
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -528,6 +529,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
break;
#endregion DVD-R, DVD-RW and HD DVD-R
#region All DVD+
case MediaType.DVDPR:
case MediaType.DVDPRDL:
@@ -566,6 +568,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
break;
#endregion All DVD+
#region HD DVD-ROM
case MediaType.HDDVDROM:
dumpLog.WriteLine("Reading Lead-in Copyright Information.");
@@ -586,6 +589,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
break;
#endregion HD DVD-ROM
#region All Blu-ray
case MediaType.BDR:
case MediaType.BDRE:
@@ -628,7 +632,8 @@ namespace DiscImageChef.Core.Devices.Dumping
#endregion All Blu-ray
}
switch(dskType) {
switch(dskType)
{
#region BD-ROM only
case MediaType.BDROM:
dumpLog.WriteLine("Reading Burst Cutting Area.");
@@ -649,6 +654,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
break;
#endregion BD-ROM only
#region Writable Blu-ray only
case MediaType.BDR:
case MediaType.BDRE:
@@ -672,8 +678,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout,
out _);
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, out _);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];

View File

@@ -41,8 +41,8 @@ namespace DiscImageChef.Core.Devices.Dumping
public static class NvMe
{
public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force,
bool dumpRaw, bool persistent, bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding)
bool dumpRaw, bool persistent, bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding)
{
throw new NotImplementedException("NVMe devices not yet supported.");
}

View File

@@ -40,12 +40,12 @@ using PlatformID = DiscImageChef.Interop.PlatformID;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implements resume support
/// Implements resume support
/// </summary>
static class ResumeSupport
{
/// <summary>
/// Process resume
/// Process resume
/// </summary>
/// <param name="isLba">If drive is LBA</param>
/// <param name="removable">If media is removable from device</param>
@@ -57,11 +57,14 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="resume">Previous resume, or null</param>
/// <param name="currentTry">Current dumping hardware</param>
/// <param name="extents">Dumped extents</param>
/// <exception cref="NotImplementedException">If device uses CHS addressing</exception>
/// <exception cref="InvalidOperationException">If the provided resume does not correspond with the current in progress dump</exception>
/// <exception cref="System.NotImplementedException">If device uses CHS addressing</exception>
/// <exception cref="System.InvalidOperationException">
/// If the provided resume does not correspond with the current in
/// progress dump
/// </exception>
internal static void Process(bool isLba, bool removable, ulong blocks, string manufacturer, string model,
string serial, PlatformID platform, ref Resume resume,
ref DumpHardwareType currentTry, ref ExtentsULong extents)
string serial, PlatformID platform, ref Resume resume,
ref DumpHardwareType currentTry, ref ExtentsULong extents)
{
if(resume != null)
{
@@ -92,7 +95,8 @@ namespace DiscImageChef.Core.Devices.Dumping
InvalidOperationException($"Resume file specifies a device with serial {oldtry.Serial} but you're requesting to dump one with serial {serial}, not continuing...");
}
if(oldtry.Software == null) throw new InvalidOperationException("Found corrupt resume file, cannot continue...");
if(oldtry.Software == null)
throw new InvalidOperationException("Found corrupt resume file, cannot continue...");
if(oldtry.Software.Name != "DiscImageChef" ||
oldtry.Software.OperatingSystem != platform.ToString() ||

View File

@@ -39,7 +39,6 @@ using System.Xml.Serialization;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.Core.Logging;
using DiscImageChef.Decoders.ATA;
using DiscImageChef.Decoders.SCSI;
using DiscImageChef.Devices;
using DiscImageChef.DiscImages;
@@ -54,12 +53,12 @@ using TrackType = DiscImageChef.DiscImages.TrackType;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implements dumping SCSI Block Commands and Reduced Block Commands devices
/// Implements dumping SCSI Block Commands and Reduced Block Commands devices
/// </summary>
static class Sbc
{
/// <summary>
/// Dumps a SCSI Block Commands device or a Reduced Block Commands devices
/// Dumps a SCSI Block Commands device or a Reduced Block Commands devices
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -79,8 +78,8 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <exception cref="InvalidOperationException">If the resume file is invalid</exception>
internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force,
bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar,
ref MediaType dskType, bool opticalDisc, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding, Alcohol120 alcohol = null)
ref MediaType dskType, bool opticalDisc, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding, Alcohol120 alcohol = null)
{
bool sense;
ulong blocks;
@@ -230,11 +229,11 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Requesting MODE SENSE (10).");
sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out _);
sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
0xFF, 5, out _);
if(!sense || dev.Error)
sense = dev.ModeSense10(out cmdBuf, out _, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _);
sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out _);
Modes.DecodedMode? decMode = null;
@@ -252,11 +251,11 @@ namespace DiscImageChef.Core.Devices.Dumping
}
dumpLog.WriteLine("Requesting MODE SENSE (6).");
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
5, out _);
if(sense || dev.Error)
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out _);
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)
@@ -279,7 +278,9 @@ namespace DiscImageChef.Core.Devices.Dumping
decMode.Value.Header.BlockDescriptors.Length >= 1)
scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
containsFloppyPage = decMode.Value.Pages.Aggregate(containsFloppyPage, (current, modePage) => current | (modePage.Page == 0x05));
containsFloppyPage =
decMode.Value.Pages.Aggregate(containsFloppyPage,
(current, modePage) => current | (modePage.Page == 0x05));
}
}
}
@@ -289,7 +290,6 @@ namespace DiscImageChef.Core.Devices.Dumping
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);
@@ -407,7 +407,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, i);
}
double newSpeed= (double)blockSize * blocksToRead / 1048576 / (cmdDuration / 1000);
double newSpeed = (double)blockSize * blocksToRead / 1048576 / (cmdDuration / 1000);
if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed;
resume.NextBlock = i + blocksToRead;
}
@@ -474,12 +474,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{
Modes.ModePage_01_MMC pgMmc =
new Modes.ModePage_01_MMC
{
PS = false,
ReadRetryCount = 255,
Parameter = 0x20
};
new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20};
Modes.DecodedMode md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
@@ -651,14 +646,19 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
switch(plugin.XmlFSType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
case "PC Engine filesystem":
dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
case "Nintendo Wii filesystem":
dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
case "Nintendo Gamecube filesystem":
dskType = MediaType.GOD;
break;
}
}
@@ -692,14 +692,19 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
switch(plugin.XmlFSType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
case "PC Engine filesystem":
dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
case "Nintendo Wii filesystem":
dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
case "Nintendo Gamecube filesystem":
dskType = MediaType.GOD;
break;
}
}
@@ -837,8 +842,7 @@ namespace DiscImageChef.Core.Devices.Dumping
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer =
new XmlSerializer(typeof(CICMMetadataType));
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
if(alcohol != null && !dumpRaw) alcohol.Close();

View File

@@ -44,13 +44,13 @@ using MediaType = DiscImageChef.CommonTypes.MediaType;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implements dumping SCSI and ATAPI devices
/// Implements dumping SCSI and ATAPI devices
/// </summary>
public class Scsi
{
// TODO: Get cartridge serial number from Certance vendor EVPD
/// <summary>
/// Dumps a SCSI Block Commands device or a Reduced Block Commands devices
/// Dumps a SCSI Block Commands device or a Reduced Block Commands devices
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -193,7 +193,8 @@ namespace DiscImageChef.Core.Devices.Dumping
CICMMetadataType sidecar = new CICMMetadataType();
switch(dev.ScsiType) {
switch(dev.ScsiType)
{
case PeripheralDeviceTypes.SequentialAccess:
if(dumpRaw) throw new ArgumentException("Tapes cannot be dumped raw.");
@@ -201,11 +202,12 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
case PeripheralDeviceTypes.MultiMediaDevice:
Mmc.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError,
ref sidecar, ref dskType, separateSubchannel, ref resume, ref dumpLog, dumpLeadIn, encoding);
ref sidecar, ref dskType, separateSubchannel, ref resume, ref dumpLog, dumpLeadIn,
encoding);
return;
default:
Sbc.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar,
ref dskType, false, ref resume, ref dumpLog, encoding);
Sbc.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError,
ref sidecar, ref dskType, false, ref resume, ref dumpLog, encoding);
break;
}
}

View File

@@ -49,7 +49,7 @@ namespace DiscImageChef.Core.Devices.Dumping
static class Ssc
{
/// <summary>
/// Dumps the tape from a SCSI Streaming device
/// Dumps the tape from a SCSI Streaming device
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -110,8 +110,8 @@ namespace DiscImageChef.Core.Devices.Dumping
fxSense = Sense.DecodeFixed(senseBuf, out strSense);
// And yet, did not rewind!
if(fxSense.HasValue && (fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 ||
fxSense.Value.ASC != 0x00))
if(fxSense.HasValue &&
(fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 || fxSense.Value.ASC != 0x00))
{
DicConsole.WriteLine();
DicConsole.ErrorWriteLine("Drive could not rewind, please correct. Sense follows...");
@@ -136,8 +136,8 @@ namespace DiscImageChef.Core.Devices.Dumping
fxSense = Sense.DecodeFixed(senseBuf, out strSense);
if(fxSense.HasValue && (fxSense.Value.ASC == 0x20 && fxSense.Value.ASCQ != 0x00 ||
fxSense.Value.ASC != 0x20 && fxSense.Value.SenseKey !=
SenseKeys.IllegalRequest))
fxSense.Value.ASC != 0x20 && fxSense.Value.SenseKey != SenseKeys.IllegalRequest)
)
{
DicConsole.ErrorWriteLine("Could not get position. Sense follows...");
DicConsole.ErrorWriteLine("{0}", strSense);
@@ -671,8 +671,7 @@ namespace DiscImageChef.Core.Devices.Dumping
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer =
new XmlSerializer(typeof(CICMMetadataType));
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}

View File

@@ -51,12 +51,12 @@ using MediaType = DiscImageChef.Metadata.MediaType;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implements dumping a MultiMediaCard or SecureDigital flash card
/// Implements dumping a MultiMediaCard or SecureDigital flash card
/// </summary>
public class SecureDigital
{
/// <summary>
/// Dumps a MultiMediaCard or SecureDigital flash card
/// Dumps a MultiMediaCard or SecureDigital flash card
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -71,8 +71,8 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="encoding">Encoding to use when analyzing dump</param>
/// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception>
public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force,
bool dumpRaw, bool persistent, bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding)
bool dumpRaw, bool persistent, bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding)
{
bool aborted;
@@ -93,8 +93,7 @@ namespace DiscImageChef.Core.Devices.Dumping
const uint TIMEOUT = 5;
double duration;
CICMMetadataType sidecar =
new CICMMetadataType {BlockMedia = new[] {new BlockMediaType()}};
CICMMetadataType sidecar = new CICMMetadataType {BlockMedia = new[] {new BlockMediaType()}};
uint blocksToRead = 128;
uint blockSize = 512;
@@ -106,7 +105,8 @@ namespace DiscImageChef.Core.Devices.Dumping
int physicalBlockSize = 0;
bool byteAddressed = true;
switch(dev.Type) {
switch(dev.Type)
{
case DeviceType.MMC:
{
dumpLog.WriteLine("Reading Extended CSD");
@@ -237,8 +237,8 @@ namespace DiscImageChef.Core.Devices.Dumping
DataFile.WriteTo("MMC/SecureDigital Dump", sidecar.BlockMedia[0].SecureDigital.SCR.Image, scr);
}
switch(dev.Type) {
switch(dev.Type)
{
case DeviceType.MMC:
sidecar.BlockMedia[0].MultiMediaCard.CID = cidDump;
sidecar.BlockMedia[0].MultiMediaCard.CSD = csdDump;
@@ -276,8 +276,7 @@ namespace DiscImageChef.Core.Devices.Dumping
while(true)
{
error = dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT,
out duration);
error = dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT, out duration);
if(error) blocksToRead /= 2;
@@ -549,14 +548,16 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray();
string xmlDskTyp = null, xmlDskSubTyp = null;
switch(dev.Type) {
switch(dev.Type)
{
case DeviceType.MMC:
MediaType.MediaTypeToString(CommonTypes.MediaType.MMC, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(CommonTypes.MediaType.MMC);
break;
case DeviceType.SecureDigital:
MediaType.MediaTypeToString(CommonTypes.MediaType.SecureDigital, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(CommonTypes.MediaType.SecureDigital);
sidecar.BlockMedia[0].Dimensions =
Dimensions.DimensionsFromMediaType(CommonTypes.MediaType.SecureDigital);
break;
}
@@ -568,10 +569,13 @@ namespace DiscImageChef.Core.Devices.Dumping
format = "Raw disk image (sector by sector copy)",
Value = outputPrefix + ".bin"
};
switch(dev.Type) {
case DeviceType.MMC: sidecar.BlockMedia[0].Interface = "MultiMediaCard";
switch(dev.Type)
{
case DeviceType.MMC:
sidecar.BlockMedia[0].Interface = "MultiMediaCard";
break;
case DeviceType.SecureDigital: sidecar.BlockMedia[0].Interface = "SecureDigital";
case DeviceType.SecureDigital:
sidecar.BlockMedia[0].Interface = "SecureDigital";
break;
}
@@ -602,16 +606,18 @@ namespace DiscImageChef.Core.Devices.Dumping
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer =
new XmlSerializer(typeof(CICMMetadataType));
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
switch(dev.Type) {
case DeviceType.MMC: Statistics.AddMedia(CommonTypes.MediaType.MMC, true);
switch(dev.Type)
{
case DeviceType.MMC:
Statistics.AddMedia(CommonTypes.MediaType.MMC, true);
break;
case DeviceType.SecureDigital: Statistics.AddMedia(CommonTypes.MediaType.SecureDigital, true);
case DeviceType.SecureDigital:
Statistics.AddMedia(CommonTypes.MediaType.SecureDigital, true);
break;
}
}

View File

@@ -54,12 +54,12 @@ using TrackType = Schemas.TrackType;
namespace DiscImageChef.Core.Devices.Dumping
{
/// <summary>
/// Implements dumping an Xbox Game Disc using a Kreon drive
/// Implements dumping an Xbox Game Disc using a Kreon drive
/// </summary>
static class Xgd
{
/// <summary>
/// Dumps an Xbox Game Disc using a Kreon drive
/// Dumps an Xbox Game Disc using a Kreon drive
/// </summary>
/// <param name="dev">Device</param>
/// <param name="devicePath">Path to the device</param>
@@ -74,11 +74,13 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="encoding">Encoding to use when analyzing dump</param>
/// <param name="sidecar">Partially filled initialized sidecar</param>
/// <param name="dskType">Disc type as detected in MMC layer</param>
/// <exception cref="InvalidOperationException">If the provided resume does not correspond with the current in progress dump</exception>
/// <exception cref="InvalidOperationException">
/// If the provided resume does not correspond with the current in progress
/// dump
/// </exception>
internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force,
bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar,
ref MediaType dskType, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding)
ref MediaType dskType, ref Resume resume, ref DumpLog dumpLog, Encoding encoding)
{
bool sense;
ulong blocks;
@@ -176,8 +178,7 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFI.Image, tmpBuf, "Locked PFI", true);
DicConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize);
l0Video = PFI.Decode(readBuffer).Value.Layer0EndPSN -
PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1;
l0Video = PFI.Decode(readBuffer).Value.Layer0EndPSN - PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1;
l1Video = totalSize - l0Video + 1;
dumpLog.WriteLine("Reading Disc Manufacturing Information.");
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
@@ -256,8 +257,9 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize);
blocks = totalSize + 1;
middleZone = totalSize - (PFI.Decode(readBuffer).Value.Layer0EndPSN -
PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1) - gameSize + 1;
middleZone =
totalSize - (PFI.Decode(readBuffer).Value.Layer0EndPSN - PFI.Decode(readBuffer).Value.DataAreaStartPSN +
1) - gameSize + 1;
tmpBuf = new byte[readBuffer.Length - 4];
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4);
@@ -438,15 +440,15 @@ namespace DiscImageChef.Core.Devices.Dumping
for(ulong b = i; b < i + blocksToRead; b++) resume.BadBlocks.Add(b);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf));
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}", Sense.PrettifySense(senseBuf));
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, i);
string[] senseLines = Sense.PrettifySense(senseBuf).Split(new[] {Environment.NewLine},
StringSplitOptions.RemoveEmptyEntries);
StringSplitOptions
.RemoveEmptyEntries);
foreach(string senseLine in senseLines) dumpLog.WriteLine(senseLine);
}
@@ -567,15 +569,13 @@ namespace DiscImageChef.Core.Devices.Dumping
// TODO: Handle errors in video partition
//errored += blocksToRead;
//resume.BadBlocks.Add(l1);
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}",
Sense.PrettifySense(senseBuf));
DicConsole.DebugWriteLine("Dump-Media", "READ error:\n{0}", Sense.PrettifySense(senseBuf));
mhddLog.Write(l1, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(l1, 0);
dumpLog.WriteLine("Error reading {0} blocks from block {1}.", blocksToRead, l1);
string[] senseLines = Sense.PrettifySense(senseBuf).Split(new[] {Environment.NewLine},
StringSplitOptions
.RemoveEmptyEntries);
StringSplitOptions.RemoveEmptyEntries);
foreach(string senseLine in senseLines) dumpLog.WriteLine(senseLine);
}
@@ -672,12 +672,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{
Modes.ModePage_01_MMC pgMmc =
new Modes.ModePage_01_MMC
{
PS = false,
ReadRetryCount = 255,
Parameter = 0x20
};
new Modes.ModePage_01_MMC {PS = false, ReadRetryCount = 255, Parameter = 0x20};
Modes.DecodedMode md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
@@ -851,14 +846,19 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
switch(plugin.XmlFSType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
case "PC Engine filesystem":
dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
case "Nintendo Wii filesystem":
dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
case "Nintendo Gamecube filesystem":
dskType = MediaType.GOD;
break;
}
}
@@ -892,14 +892,19 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
switch(plugin.XmlFSType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
case "PC Engine filesystem":
dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
case "Nintendo Wii filesystem":
dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
case "Nintendo Gamecube filesystem":
dskType = MediaType.GOD;
break;
}
}
@@ -961,8 +966,7 @@ namespace DiscImageChef.Core.Devices.Dumping
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer =
new XmlSerializer(typeof(CICMMetadataType));
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}