Added correct metadata for XGD structures.

This commit is contained in:
2017-06-20 06:42:09 +01:00
parent c25cc90c46
commit 1df2589b39
4 changed files with 92 additions and 23 deletions

View File

@@ -105,26 +105,32 @@ namespace DiscImageChef.Core
WriteTo(who, outputPrefix + outputSuffix, data, what);
}
public static void WriteTo(string who, string filename, byte[] data, string whatWriting = null)
public static void WriteTo(string who, string filename, byte[] data, string whatWriting = null, bool overwrite = false)
{
if(!string.IsNullOrEmpty(filename))
{
if(!File.Exists(filename))
if(File.Exists(filename))
{
try
if(overwrite)
File.Delete(filename);
else
{
DicConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
outputFs.Write(data, 0, data.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}", filename);
DicConsole.ErrorWriteLine("Not overwriting file {0}", filename);
return;
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}", filename);
try
{
DicConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
outputFs.Write(data, 0, data.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}", filename);
}
}
}
}

View File

@@ -91,12 +91,25 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
// TODO: Correct metadata
/*sidecar.OpticalDisc[0].XboxSecuritySectors = new DumpType();
sidecar.OpticalDisc[0].XboxSecuritySectors.Image = outputPrefix + ".bca.bin";
sidecar.OpticalDisc[0].XboxSecuritySectors.Size = cmdBuf.Length;
sidecar.OpticalDisc[0].XboxSecuritySectors.Checksums = Checksum.GetChecksums(cmbBuf).ToArray();
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].XboxSecuritySectors.Image, tmpBuf);*/
byte[] tmpBuf = new byte[ssBuf.Length - 4];
Array.Copy(ssBuf, 4, tmpBuf, 0, ssBuf.Length - 4);
sidecar.OpticalDisc[0].Xbox = new XboxType()
{
SecuritySectors = new XboxSecuritySectorsType[]
{
new XboxSecuritySectorsType()
{
RequestNumber = 0,
RequestVersion = 1,
SecuritySectors = new DumpType()
{
Image = outputPrefix + ".ss.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
}
}
}
};
DataFile.WriteTo("SCSI Dump", outputPrefix + ".ss.bin", ssBuf);
ulong l0Video, l1Video, middleZone, gameSize, totalSize, layerBreak;
@@ -122,9 +135,33 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.ErrorWriteLine("Cannot get PFI.");
return;
}
tmpBuf = new byte[readBuffer.Length - 4];
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.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, "Locked PFI", true);
DicConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize);
l0Video = Decoders.DVD.PFI.Decode(readBuffer).Value.Layer0EndPSN - Decoders.DVD.PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1;
l1Video = totalSize - l0Video + 1;
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out duration);
if(sense)
{
DicConsole.ErrorWriteLine("Cannot get DMI.");
return;
}
tmpBuf = new byte[readBuffer.Length - 4];
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.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, "Locked DMI", true);
// Get game partition size
DicConsole.DebugWriteLine("Dump-media command", "Getting game partition size");
@@ -168,6 +205,33 @@ namespace DiscImageChef.Core.Devices.Dumping
blocks = totalSize + 1;
middleZone = totalSize - (Decoders.DVD.PFI.Decode(readBuffer).Value.Layer0EndPSN - Decoders.DVD.PFI.Decode(readBuffer).Value.DataAreaStartPSN + 1) - gameSize + 1;
tmpBuf = new byte[readBuffer.Length - 4];
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4);
sidecar.OpticalDisc[0].Xbox.PFI = new DumpType
{
Image = outputPrefix + ".xboxpfi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].Xbox.PFI.Image, tmpBuf, "Unlocked PFI", true);
sense = dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out duration);
if(sense)
{
DicConsole.ErrorWriteLine("Cannot get DMI.");
return;
}
tmpBuf = new byte[readBuffer.Length - 4];
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4);
sidecar.OpticalDisc[0].Xbox.DMI = new DumpType
{
Image = outputPrefix + ".xboxdmi.bin",
Size = tmpBuf.Length,
Checksums = Checksum.GetChecksums(tmpBuf).ToArray()
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].Xbox.DMI.Image, tmpBuf, "Unlocked DMI", true);
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
layerBreak = l0Video + middleZone + gameSize / 2;

View File

@@ -215,7 +215,7 @@ namespace DiscImageChef.Devices
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
/// <param name="buffer">The SS sector.</param>
public bool KreonExtractSS(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
public bool KreonExtractSS(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration, byte requestNumber = 0x00)
{
buffer = new byte[2048];
byte[] cdb = new byte[12];
@@ -232,8 +232,7 @@ namespace DiscImageChef.Devices
cdb[7] = 0x00;
cdb[8] = 0x08;
cdb[9] = 0x00;
// TODO: Documentation puts this as xx but doesn't say what is the meaning.
cdb[10] = 0x00;
cdb[10] = requestNumber;
cdb[11] = 0xC0;
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);