REFACTOR: Convert 'if' statement to 'switch' statement.

This commit is contained in:
2017-12-21 04:43:29 +00:00
parent df2fb651e4
commit 9cd1869d1d
55 changed files with 4429 additions and 4192 deletions

View File

@@ -118,31 +118,31 @@ namespace DiscImageChef.Core.Devices.Dumping
Decoders.PCMCIA.Tuple[] tuples = CIS.GetTuples(dev.Cis);
if(tuples != null)
foreach(Decoders.PCMCIA.Tuple tuple in tuples)
if(tuple.Code == TupleCodes.CISTPL_MANFID)
{
ManufacturerIdentificationTuple manfid =
CIS.DecodeManufacturerIdentificationTuple(tuple);
switch(tuple.Code) {
case TupleCodes.CISTPL_MANFID:
ManufacturerIdentificationTuple manfid =
CIS.DecodeManufacturerIdentificationTuple(tuple);
if(manfid != null)
{
sidecar.BlockMedia[0].PCMCIA.ManufacturerCode = manfid.ManufacturerID;
sidecar.BlockMedia[0].PCMCIA.CardCode = manfid.CardID;
sidecar.BlockMedia[0].PCMCIA.ManufacturerCodeSpecified = true;
sidecar.BlockMedia[0].PCMCIA.CardCodeSpecified = true;
}
}
else if(tuple.Code == TupleCodes.CISTPL_VERS_1)
{
Level1VersionTuple vers = CIS.DecodeLevel1VersionTuple(tuple);
if(manfid != null)
{
sidecar.BlockMedia[0].PCMCIA.ManufacturerCode = manfid.ManufacturerID;
sidecar.BlockMedia[0].PCMCIA.CardCode = manfid.CardID;
sidecar.BlockMedia[0].PCMCIA.ManufacturerCodeSpecified = true;
sidecar.BlockMedia[0].PCMCIA.CardCodeSpecified = true;
}
break;
case TupleCodes.CISTPL_VERS_1:
Level1VersionTuple vers = CIS.DecodeLevel1VersionTuple(tuple);
if(vers != null)
{
sidecar.BlockMedia[0].PCMCIA.Manufacturer = vers.Manufacturer;
sidecar.BlockMedia[0].PCMCIA.ProductName = vers.Product;
sidecar.BlockMedia[0].PCMCIA.Compliance =
string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation;
}
if(vers != null)
{
sidecar.BlockMedia[0].PCMCIA.Manufacturer = vers.Manufacturer;
sidecar.BlockMedia[0].PCMCIA.ProductName = vers.Product;
sidecar.BlockMedia[0].PCMCIA.Compliance =
string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation;
}
break;
}
}

View File

@@ -179,166 +179,179 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Device reports disc has {0} blocks", blocks);
#region Nintendo
if(dskType == MediaType.Unknown && blocks > 0)
{
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration);
if(!sense)
{
Decoders.DVD.PFI.PhysicalFormatInformation? nintendoPfi = Decoders.DVD.PFI.Decode(cmdBuf);
if(nintendoPfi != null)
if(nintendoPfi.Value.DiskCategory == Decoders.DVD.DiskCategory.Nintendo &&
nintendoPfi.Value.PartVersion == 15)
switch(dskType) {
case MediaType.Unknown when blocks > 0:
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration);
if(!sense)
{
Decoders.DVD.PFI.PhysicalFormatInformation? nintendoPfi = Decoders.DVD.PFI.Decode(cmdBuf);
if(nintendoPfi != null)
if(nintendoPfi.Value.DiskCategory == Decoders.DVD.DiskCategory.Nintendo &&
nintendoPfi.Value.PartVersion == 15)
{
dumpLog.WriteLine("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
throw new
NotImplementedException("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
}
}
break;
case MediaType.DVDDownload:
case MediaType.DVDPR:
case MediaType.DVDPRDL:
case MediaType.DVDPRW:
case MediaType.DVDPRWDL:
case MediaType.DVDR:
case MediaType.DVDRAM:
case MediaType.DVDRDL:
case MediaType.DVDROM:
case MediaType.DVDRW:
case MediaType.DVDRWDL:
case MediaType.HDDVDR:
case MediaType.HDDVDRAM:
case MediaType.HDDVDRDL:
case MediaType.HDDVDROM:
case MediaType.HDDVDRW:
case MediaType.HDDVDRWDL:
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration);
if(!sense)
{
alcohol.AddPfi(cmdBuf);
if(Decoders.DVD.PFI.Decode(cmdBuf).HasValue)
{
dumpLog.WriteLine("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
throw new
NotImplementedException("Dumping Nintendo GameCube or Wii discs is not yet implemented.");
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PFI = new DumpType
{
Image = outputPrefix + ".pfi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFI.Image, tmpBuf);
Decoders.DVD.PFI.PhysicalFormatInformation decPfi = Decoders.DVD.PFI.Decode(cmdBuf).Value;
DicConsole.WriteLine("PFI:\n{0}", Decoders.DVD.PFI.Prettify(decPfi));
// False book types
if(dskType == MediaType.DVDROM)
switch(decPfi.DiskCategory)
{
case Decoders.DVD.DiskCategory.DVDPR:
dskType = MediaType.DVDPR;
break;
case Decoders.DVD.DiskCategory.DVDPRDL:
dskType = MediaType.DVDPRDL;
break;
case Decoders.DVD.DiskCategory.DVDPRW:
dskType = MediaType.DVDPRW;
break;
case Decoders.DVD.DiskCategory.DVDPRWDL:
dskType = MediaType.DVDPRWDL;
break;
case Decoders.DVD.DiskCategory.DVDR:
if(decPfi.PartVersion == 6) dskType = MediaType.DVDRDL;
else dskType = MediaType.DVDR;
break;
case Decoders.DVD.DiskCategory.DVDRAM:
dskType = MediaType.DVDRAM;
break;
default:
dskType = MediaType.DVDROM;
break;
case Decoders.DVD.DiskCategory.DVDRW:
if(decPfi.PartVersion == 3) dskType = MediaType.DVDRWDL;
else dskType = MediaType.DVDRW;
break;
case Decoders.DVD.DiskCategory.HDDVDR:
dskType = MediaType.HDDVDR;
break;
case Decoders.DVD.DiskCategory.HDDVDRAM:
dskType = MediaType.HDDVDRAM;
break;
case Decoders.DVD.DiskCategory.HDDVDROM:
dskType = MediaType.HDDVDROM;
break;
case Decoders.DVD.DiskCategory.HDDVDRW:
dskType = MediaType.HDDVDRW;
break;
case Decoders.DVD.DiskCategory.Nintendo:
if(decPfi.DiscSize == Decoders.DVD.DVDSize.Eighty) dskType = MediaType.GOD;
else dskType = MediaType.WOD;
break;
case Decoders.DVD.DiskCategory.UMD:
dskType = MediaType.UMD;
break;
}
}
}
}
dumpLog.WriteLine("Reading Disc Manufacturing Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
if(Decoders.Xbox.DMI.IsXbox(cmdBuf) || Decoders.Xbox.DMI.IsXbox360(cmdBuf))
{
if(Decoders.Xbox.DMI.IsXbox(cmdBuf)) dskType = MediaType.XGD;
else if(Decoders.Xbox.DMI.IsXbox360(cmdBuf))
{
dskType = MediaType.XGD2;
// All XGD3 all have the same number of blocks
if(blocks == 25063 || // Locked (or non compatible drive)
blocks == 4229664 || // Xtreme unlock
blocks == 4246304) // Wxripper unlock
dskType = MediaType.XGD3;
}
sense = dev.ScsiInquiry(out byte[] inqBuf, out senseBuf);
if(sense || !Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue ||
Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue &&
!Decoders.SCSI.Inquiry.Decode(inqBuf).Value.KreonPresent)
{
dumpLog.WriteLine("Dumping Xbox Game Discs requires a drive with Kreon firmware.");
throw new
NotImplementedException("Dumping Xbox Game Discs requires a drive with Kreon firmware.");
}
if(dumpRaw && !force)
{
DicConsole
.ErrorWriteLine("Not continuing. If you want to continue reading cooked data when raw is not available use the force option.");
// TODO: Exit more gracefully
return;
}
isXbox = true;
}
alcohol.AddDmi(cmdBuf);
if(cmdBuf.Length == 2052)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DMI = new DumpType
{
Image = outputPrefix + ".dmi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DMI.Image, tmpBuf);
}
}
break;
}
#endregion Nintendo
#region All DVD and HD DVD types
if(dskType == MediaType.DVDDownload || dskType == MediaType.DVDPR || dskType == MediaType.DVDPRDL ||
dskType == MediaType.DVDPRW || dskType == MediaType.DVDPRWDL || dskType == MediaType.DVDR ||
dskType == MediaType.DVDRAM || dskType == MediaType.DVDRDL || dskType == MediaType.DVDROM ||
dskType == MediaType.DVDRW || dskType == MediaType.DVDRWDL || dskType == MediaType.HDDVDR ||
dskType == MediaType.HDDVDRAM || dskType == MediaType.HDDVDRDL || dskType == MediaType.HDDVDROM ||
dskType == MediaType.HDDVDRW || dskType == MediaType.HDDVDRWDL)
{
dumpLog.WriteLine("Reading Physical Format Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration);
if(!sense)
{
alcohol.AddPfi(cmdBuf);
if(Decoders.DVD.PFI.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PFI = new DumpType
{
Image = outputPrefix + ".pfi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFI.Image, tmpBuf);
Decoders.DVD.PFI.PhysicalFormatInformation decPfi = Decoders.DVD.PFI.Decode(cmdBuf).Value;
DicConsole.WriteLine("PFI:\n{0}", Decoders.DVD.PFI.Prettify(decPfi));
// False book types
if(dskType == MediaType.DVDROM)
switch(decPfi.DiskCategory)
{
case Decoders.DVD.DiskCategory.DVDPR:
dskType = MediaType.DVDPR;
break;
case Decoders.DVD.DiskCategory.DVDPRDL:
dskType = MediaType.DVDPRDL;
break;
case Decoders.DVD.DiskCategory.DVDPRW:
dskType = MediaType.DVDPRW;
break;
case Decoders.DVD.DiskCategory.DVDPRWDL:
dskType = MediaType.DVDPRWDL;
break;
case Decoders.DVD.DiskCategory.DVDR:
if(decPfi.PartVersion == 6) dskType = MediaType.DVDRDL;
else dskType = MediaType.DVDR;
break;
case Decoders.DVD.DiskCategory.DVDRAM:
dskType = MediaType.DVDRAM;
break;
default:
dskType = MediaType.DVDROM;
break;
case Decoders.DVD.DiskCategory.DVDRW:
if(decPfi.PartVersion == 3) dskType = MediaType.DVDRWDL;
else dskType = MediaType.DVDRW;
break;
case Decoders.DVD.DiskCategory.HDDVDR:
dskType = MediaType.HDDVDR;
break;
case Decoders.DVD.DiskCategory.HDDVDRAM:
dskType = MediaType.HDDVDRAM;
break;
case Decoders.DVD.DiskCategory.HDDVDROM:
dskType = MediaType.HDDVDROM;
break;
case Decoders.DVD.DiskCategory.HDDVDRW:
dskType = MediaType.HDDVDRW;
break;
case Decoders.DVD.DiskCategory.Nintendo:
if(decPfi.DiscSize == Decoders.DVD.DVDSize.Eighty) dskType = MediaType.GOD;
else dskType = MediaType.WOD;
break;
case Decoders.DVD.DiskCategory.UMD:
dskType = MediaType.UMD;
break;
}
}
}
dumpLog.WriteLine("Reading Disc Manufacturing Information");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
if(Decoders.Xbox.DMI.IsXbox(cmdBuf) || Decoders.Xbox.DMI.IsXbox360(cmdBuf))
{
if(Decoders.Xbox.DMI.IsXbox(cmdBuf)) dskType = MediaType.XGD;
else if(Decoders.Xbox.DMI.IsXbox360(cmdBuf))
{
dskType = MediaType.XGD2;
// All XGD3 all have the same number of blocks
if(blocks == 25063 || // Locked (or non compatible drive)
blocks == 4229664 || // Xtreme unlock
blocks == 4246304) // Wxripper unlock
dskType = MediaType.XGD3;
}
sense = dev.ScsiInquiry(out byte[] inqBuf, out senseBuf);
if(sense || !Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue ||
Decoders.SCSI.Inquiry.Decode(inqBuf).HasValue &&
!Decoders.SCSI.Inquiry.Decode(inqBuf).Value.KreonPresent)
{
dumpLog.WriteLine("Dumping Xbox Game Discs requires a drive with Kreon firmware.");
throw new
NotImplementedException("Dumping Xbox Game Discs requires a drive with Kreon firmware.");
}
if(dumpRaw && !force)
{
DicConsole
.ErrorWriteLine("Not continuing. If you want to continue reading cooked data when raw is not available use the force option.");
// TODO: Exit more gracefully
return;
}
isXbox = true;
}
alcohol.AddDmi(cmdBuf);
if(cmdBuf.Length == 2052)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DMI = new DumpType
{
Image = outputPrefix + ".dmi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DMI.Image, tmpBuf);
}
}
}
#endregion All DVD and HD DVD types
#region DVD-ROM
@@ -369,36 +382,260 @@ namespace DiscImageChef.Core.Devices.Dumping
}
#endregion DVD-ROM
#region DVD-ROM and HD DVD-ROM
if(dskType == MediaType.DVDDownload || dskType == MediaType.DVDROM || dskType == MediaType.HDDVDROM)
{
dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
alcohol.AddBca(tmpBuf);
sidecar.OpticalDisc[0].BCA = new DumpType
switch(dskType) {
#region DVD-ROM and HD DVD-ROM
case MediaType.DVDDownload:
case MediaType.DVDROM:
case MediaType.HDDVDROM:
dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out duration);
if(!sense)
{
Image = outputPrefix + ".bca.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf);
}
}
#endregion DVD-ROM and HD DVD-ROM
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
alcohol.AddBca(tmpBuf);
sidecar.OpticalDisc[0].BCA = new DumpType
{
Image = outputPrefix + ".bca.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf);
}
break;
#endregion DVD-ROM and HD DVD-ROM
#region DVD-RAM and HD DVD-RAM
case MediaType.DVDRAM:
case MediaType.HDDVDRAM:
dumpLog.WriteLine("Reading Disc Description Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out duration);
if(!sense)
if(Decoders.DVD.DDS.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DDS = new DumpType
{
Image = outputPrefix + ".dds.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf);
}
#region DVD-RAM and HD DVD-RAM
if(dskType == MediaType.DVDRAM || dskType == MediaType.HDDVDRAM)
{
dumpLog.WriteLine("Reading Disc Description Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out duration);
if(!sense)
if(Decoders.DVD.DDS.Decode(cmdBuf).HasValue)
dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, dev.Timeout,
out duration);
if(!sense)
if(Decoders.DVD.Spare.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].SAI = new DumpType
{
Image = outputPrefix + ".sai.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
}
break;
#endregion DVD-RAM and HD DVD-RAM
#region DVD-R and DVD-RW
case MediaType.DVDR:
case MediaType.DVDRW:
dumpLog.WriteLine("Reading Pre-Recorded Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PRI = new DumpType
{
Image = outputPrefix + ".pri.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
}
break;
#endregion DVD-R and DVD-RW
}
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 senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].MediaID = new DumpType
{
Image = outputPrefix + ".mid.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].MediaID.Image, tmpBuf);
}
dumpLog.WriteLine("Reading Recordable Physical Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrPhysicalInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PFIR = new DumpType
{
Image = outputPrefix + ".pfir.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFIR.Image, tmpBuf);
}
break;
#endregion DVD-R, DVD-RW and HD DVD-R
#region All DVD+
case MediaType.DVDPR:
case MediaType.DVDPRDL:
case MediaType.DVDPRW:
case MediaType.DVDPRWDL:
dumpLog.WriteLine("Reading ADdress In Pregroove.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Adip, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].ADIP = new DumpType
{
Image = outputPrefix + ".adip.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].ADIP.Image, tmpBuf);
}
dumpLog.WriteLine("Reading Disc Control Blocks.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DCB = new DumpType
{
Image = outputPrefix + ".dcb.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DCB.Image, tmpBuf);
}
break;
#endregion All DVD+
#region HD DVD-ROM
case MediaType.HDDVDROM:
dumpLog.WriteLine("Reading Lead-in Copyright Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.HddvdCopyrightInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].CMI = new DumpType
{
Image = outputPrefix + ".cmi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf);
}
break;
#endregion HD DVD-ROM
#region All Blu-ray
case MediaType.BDR:
case MediaType.BDRE:
case MediaType.BDROM:
case MediaType.BDRXL:
case MediaType.BDREXL:
dumpLog.WriteLine("Reading Disc Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out duration);
if(!sense)
if(Decoders.Bluray.DI.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DI = new DumpType
{
Image = outputPrefix + ".di.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DI.Image, tmpBuf);
}
dumpLog.WriteLine("Reading PAC.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.Pac, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PAC = new DumpType
{
Image = outputPrefix + ".pac.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PAC.Image, tmpBuf);
}
break;
#endregion All Blu-ray
}
switch(dskType) {
#region BD-ROM only
case MediaType.BDROM:
dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
alcohol.AddBca(tmpBuf);
sidecar.OpticalDisc[0].BCA = new DumpType
{
Image = outputPrefix + ".bca.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf);
}
break;
#endregion BD-ROM only
#region Writable Blu-ray only
case MediaType.BDR:
case MediaType.BDRE:
case MediaType.BDRXL:
case MediaType.BDREXL:
dumpLog.WriteLine("Reading Disc Definition Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
@@ -411,12 +648,11 @@ namespace DiscImageChef.Core.Devices.Dumping
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf);
}
dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, dev.Timeout,
out duration);
if(!sense)
if(Decoders.DVD.Spare.Decode(cmdBuf).HasValue)
dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
@@ -428,228 +664,9 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
}
break;
#endregion Writable Blu-ray only
}
#endregion DVD-RAM and HD DVD-RAM
#region DVD-R and DVD-RW
if(dskType == MediaType.DVDR || dskType == MediaType.DVDRW)
{
dumpLog.WriteLine("Reading Pre-Recorded Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PRI = new DumpType
{
Image = outputPrefix + ".pri.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
}
}
#endregion DVD-R and DVD-RW
#region DVD-R, DVD-RW and HD DVD-R
if(dskType == MediaType.DVDR || dskType == MediaType.DVDRW || dskType == MediaType.HDDVDR)
{
dumpLog.WriteLine("Reading Media Identifier.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].MediaID = new DumpType
{
Image = outputPrefix + ".mid.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].MediaID.Image, tmpBuf);
}
dumpLog.WriteLine("Reading Recordable Physical Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.DvdrPhysicalInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PFIR = new DumpType
{
Image = outputPrefix + ".pfir.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PFIR.Image, tmpBuf);
}
}
#endregion DVD-R, DVD-RW and HD DVD-R
#region All DVD+
if(dskType == MediaType.DVDPR || dskType == MediaType.DVDPRDL || dskType == MediaType.DVDPRW ||
dskType == MediaType.DVDPRWDL)
{
dumpLog.WriteLine("Reading ADdress In Pregroove.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Adip, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].ADIP = new DumpType
{
Image = outputPrefix + ".adip.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].ADIP.Image, tmpBuf);
}
dumpLog.WriteLine("Reading Disc Control Blocks.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DCB = new DumpType
{
Image = outputPrefix + ".dcb.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DCB.Image, tmpBuf);
}
}
#endregion All DVD+
#region HD DVD-ROM
if(dskType == MediaType.HDDVDROM)
{
dumpLog.WriteLine("Reading Lead-in Copyright Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.HddvdCopyrightInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].CMI = new DumpType
{
Image = outputPrefix + ".cmi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].CMI.Image, tmpBuf);
}
}
#endregion HD DVD-ROM
#region All Blu-ray
if(dskType == MediaType.BDR || dskType == MediaType.BDRE || dskType == MediaType.BDROM ||
dskType == MediaType.BDRXL || dskType == MediaType.BDREXL)
{
dumpLog.WriteLine("Reading Disc Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out duration);
if(!sense)
if(Decoders.Bluray.DI.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DI = new DumpType
{
Image = outputPrefix + ".di.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DI.Image, tmpBuf);
}
dumpLog.WriteLine("Reading PAC.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.Pac, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].PAC = new DumpType
{
Image = outputPrefix + ".pac.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PAC.Image, tmpBuf);
}
}
#endregion All Blu-ray
#region BD-ROM only
if(dskType == MediaType.BDROM)
{
dumpLog.WriteLine("Reading Burst Cutting Area.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
alcohol.AddBca(tmpBuf);
sidecar.OpticalDisc[0].BCA = new DumpType
{
Image = outputPrefix + ".bca.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].BCA.Image, tmpBuf);
}
}
#endregion BD-ROM only
#region Writable Blu-ray only
if(dskType == MediaType.BDR || dskType == MediaType.BDRE || dskType == MediaType.BDRXL ||
dskType == MediaType.BDREXL)
{
dumpLog.WriteLine("Reading Disc Definition Structure.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].DDS = new DumpType
{
Image = outputPrefix + ".dds.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].DDS.Image, tmpBuf);
}
dumpLog.WriteLine("Reading Spare Area Information.");
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0,
MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout,
out duration);
if(!sense)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
sidecar.OpticalDisc[0].SAI = new DumpType
{
Image = outputPrefix + ".sai.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].SAI.Image, tmpBuf);
}
}
#endregion Writable Blu-ray only
if(isXbox)
{

View File

@@ -658,12 +658,16 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(plugin.XmlFSType.Type == "Opera") dskType = MediaType.ThreeDO;
if(plugin.XmlFSType.Type == "PC Engine filesystem")
dskType = MediaType.SuperCDROM2;
if(plugin.XmlFSType.Type == "Nintendo Wii filesystem") dskType = MediaType.WOD;
if(plugin.XmlFSType.Type == "Nintendo Gamecube filesystem")
dskType = MediaType.GOD;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -696,10 +700,16 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(plugin.XmlFSType.Type == "Opera") dskType = MediaType.ThreeDO;
if(plugin.XmlFSType.Type == "PC Engine filesystem") dskType = MediaType.SuperCDROM2;
if(plugin.XmlFSType.Type == "Nintendo Wii filesystem") dskType = MediaType.WOD;
if(plugin.XmlFSType.Type == "Nintendo Gamecube filesystem") dskType = MediaType.GOD;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body

View File

@@ -173,23 +173,21 @@ namespace DiscImageChef.Core.Devices.Dumping
CICMMetadataType sidecar = new CICMMetadataType();
if(dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess)
{
if(dumpRaw) throw new ArgumentException("Tapes cannot be dumped raw.");
switch(dev.ScsiType) {
case Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess:
if(dumpRaw) throw new ArgumentException("Tapes cannot be dumped raw.");
Ssc.Dump(dev, outputPrefix, devicePath, ref sidecar, ref resume, ref dumpLog);
return;
Ssc.Dump(dev, outputPrefix, devicePath, ref sidecar, ref resume, ref dumpLog);
return;
case Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice:
Mmc.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError,
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);
break;
}
if(dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice)
{
Mmc.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError,
ref sidecar, ref dskType, separateSubchannel, ref resume, ref dumpLog, dumpLeadIn, encoding);
return;
}
Sbc.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar,
ref dskType, false, ref resume, ref dumpLog, encoding);
}
}
}

View File

@@ -89,72 +89,76 @@ namespace DiscImageChef.Core.Devices.Dumping
int physicalBlockSize = 0;
bool byteAddressed = true;
if(dev.Type == DeviceType.MMC)
{
ExtendedCSD ecsdDecoded = new ExtendedCSD();
CSD csdDecoded = new CSD();
dumpLog.WriteLine("Reading Extended CSD");
sense = dev.ReadExtendedCsd(out ecsd, out response, timeout, out duration);
if(!sense)
switch(dev.Type) {
case DeviceType.MMC:
{
ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
blocksToRead = ecsdDecoded.OptimalReadSize;
blocks = ecsdDecoded.SectorCount;
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
if(ecsdDecoded.NativeSectorSize == 0) physicalBlockSize = 512;
else if(ecsdDecoded.NativeSectorSize == 1) physicalBlockSize = 4096;
// Supposing it's high-capacity MMC if it has Extended CSD...
byteAddressed = false;
}
else ecsd = null;
ExtendedCSD ecsdDecoded = new ExtendedCSD();
CSD csdDecoded = new CSD();
dumpLog.WriteLine("Reading CSD");
sense = dev.ReadCsd(out csd, out response, timeout, out duration);
if(!sense)
{
if(blocks == 0)
dumpLog.WriteLine("Reading Extended CSD");
sense = dev.ReadExtendedCsd(out ecsd, out response, timeout, out duration);
if(!sense)
{
csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd);
blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
blocksToRead = ecsdDecoded.OptimalReadSize;
blocks = ecsdDecoded.SectorCount;
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
if(ecsdDecoded.NativeSectorSize == 0) physicalBlockSize = 512;
else if(ecsdDecoded.NativeSectorSize == 1) physicalBlockSize = 4096;
// Supposing it's high-capacity MMC if it has Extended CSD...
byteAddressed = false;
}
else ecsd = null;
dumpLog.WriteLine("Reading CSD");
sense = dev.ReadCsd(out csd, out response, timeout, out duration);
if(!sense)
{
if(blocks == 0)
{
csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd);
blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
}
}
else csd = null;
dumpLog.WriteLine("Reading OCR");
sense = dev.ReadOcr(out ocr, out response, timeout, out duration);
if(sense) ocr = null;
sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType();
break;
}
else csd = null;
dumpLog.WriteLine("Reading OCR");
sense = dev.ReadOcr(out ocr, out response, timeout, out duration);
if(sense) ocr = null;
sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType();
}
else if(dev.Type == DeviceType.SecureDigital)
{
Decoders.SecureDigital.CSD csdDecoded = new Decoders.SecureDigital.CSD();
dumpLog.WriteLine("Reading CSD");
sense = dev.ReadCsd(out csd, out response, timeout, out duration);
if(!sense)
case DeviceType.SecureDigital:
{
csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
blocks = (ulong)(csdDecoded.Structure == 0
? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
: (csdDecoded.Size + 1) * 1024);
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
// Structure >=1 for SDHC/SDXC, so that's block addressed
byteAddressed = csdDecoded.Structure == 0;
Decoders.SecureDigital.CSD csdDecoded = new Decoders.SecureDigital.CSD();
dumpLog.WriteLine("Reading CSD");
sense = dev.ReadCsd(out csd, out response, timeout, out duration);
if(!sense)
{
csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
blocks = (ulong)(csdDecoded.Structure == 0
? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
: (csdDecoded.Size + 1) * 1024);
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
// Structure >=1 for SDHC/SDXC, so that's block addressed
byteAddressed = csdDecoded.Structure == 0;
}
else csd = null;
dumpLog.WriteLine("Reading OCR");
sense = dev.ReadSdocr(out ocr, out response, timeout, out duration);
if(sense) ocr = null;
dumpLog.WriteLine("Reading SCR");
sense = dev.ReadScr(out scr, out response, timeout, out duration);
if(sense) scr = null;
sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType();
break;
}
else csd = null;
dumpLog.WriteLine("Reading OCR");
sense = dev.ReadSdocr(out ocr, out response, timeout, out duration);
if(sense) ocr = null;
dumpLog.WriteLine("Reading SCR");
sense = dev.ReadScr(out scr, out response, timeout, out duration);
if(sense) scr = null;
sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType();
}
dumpLog.WriteLine("Reading CID");
@@ -222,17 +226,17 @@ namespace DiscImageChef.Core.Devices.Dumping
}
;
if(dev.Type == DeviceType.MMC)
{
sidecar.BlockMedia[0].MultiMediaCard.CID = cidDump;
sidecar.BlockMedia[0].MultiMediaCard.CSD = csdDump;
sidecar.BlockMedia[0].MultiMediaCard.OCR = ocrDump;
}
else if(dev.Type == DeviceType.SecureDigital)
{
sidecar.BlockMedia[0].SecureDigital.CID = cidDump;
sidecar.BlockMedia[0].SecureDigital.CSD = csdDump;
sidecar.BlockMedia[0].SecureDigital.OCR = ocrDump;
switch(dev.Type) {
case DeviceType.MMC:
sidecar.BlockMedia[0].MultiMediaCard.CID = cidDump;
sidecar.BlockMedia[0].MultiMediaCard.CSD = csdDump;
sidecar.BlockMedia[0].MultiMediaCard.OCR = ocrDump;
break;
case DeviceType.SecureDigital:
sidecar.BlockMedia[0].SecureDigital.CID = cidDump;
sidecar.BlockMedia[0].SecureDigital.CSD = csdDump;
sidecar.BlockMedia[0].SecureDigital.OCR = ocrDump;
break;
}
DateTime start;
@@ -544,15 +548,15 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].Checksums = dataChk.End().ToArray();
string xmlDskTyp = null, xmlDskSubTyp = null;
if(dev.Type == DeviceType.MMC)
{
Metadata.MediaType.MediaTypeToString(MediaType.MMC, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(MediaType.MMC);
}
else if(dev.Type == DeviceType.SecureDigital)
{
Metadata.MediaType.MediaTypeToString(MediaType.SecureDigital, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(MediaType.SecureDigital);
switch(dev.Type) {
case DeviceType.MMC:
Metadata.MediaType.MediaTypeToString(MediaType.MMC, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(MediaType.MMC);
break;
case DeviceType.SecureDigital:
Metadata.MediaType.MediaTypeToString(MediaType.SecureDigital, out xmlDskTyp, out xmlDskSubTyp);
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(MediaType.SecureDigital);
break;
}
sidecar.BlockMedia[0].DiskType = xmlDskTyp;
sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp;
@@ -562,8 +566,12 @@ namespace DiscImageChef.Core.Devices.Dumping
format = "Raw disk image (sector by sector copy)",
Value = outputPrefix + ".bin"
};
if(dev.Type == DeviceType.MMC) sidecar.BlockMedia[0].Interface = "MultiMediaCard";
else if(dev.Type == DeviceType.SecureDigital) sidecar.BlockMedia[0].Interface = "SecureDigital";
switch(dev.Type) {
case DeviceType.MMC: sidecar.BlockMedia[0].Interface = "MultiMediaCard";
break;
case DeviceType.SecureDigital: sidecar.BlockMedia[0].Interface = "SecureDigital";
break;
}
sidecar.BlockMedia[0].LogicalBlocks = (long)blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize > 0 ? physicalBlockSize : (int)blockSize;
sidecar.BlockMedia[0].LogicalBlockSize = (int)blockSize;
@@ -597,8 +605,12 @@ namespace DiscImageChef.Core.Devices.Dumping
xmlFs.Close();
}
if(dev.Type == DeviceType.MMC) Statistics.AddMedia(MediaType.MMC, true);
else if(dev.Type == DeviceType.SecureDigital) Statistics.AddMedia(MediaType.SecureDigital, true);
switch(dev.Type) {
case DeviceType.MMC: Statistics.AddMedia(MediaType.MMC, true);
break;
case DeviceType.SecureDigital: Statistics.AddMedia(MediaType.SecureDigital, true);
break;
}
}
}
}

View File

@@ -857,12 +857,16 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(plugin.XmlFSType.Type == "Opera") dskType = MediaType.ThreeDO;
if(plugin.XmlFSType.Type == "PC Engine filesystem")
dskType = MediaType.SuperCDROM2;
if(plugin.XmlFSType.Type == "Nintendo Wii filesystem") dskType = MediaType.WOD;
if(plugin.XmlFSType.Type == "Nintendo Gamecube filesystem")
dskType = MediaType.GOD;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -895,10 +899,16 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(plugin.XmlFSType.Type == "Opera") dskType = MediaType.ThreeDO;
if(plugin.XmlFSType.Type == "PC Engine filesystem") dskType = MediaType.SuperCDROM2;
if(plugin.XmlFSType.Type == "Nintendo Wii filesystem") dskType = MediaType.WOD;
if(plugin.XmlFSType.Type == "Nintendo Gamecube filesystem") dskType = MediaType.GOD;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body