From 6e71c17de167b74d840c2bb23d800dcf20acb61e Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 3 Feb 2021 02:09:17 +0000 Subject: [PATCH] Fix XGD detection. --- Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs | 2 +- Aaru.Core/Devices/Dumping/Sbc/Dump.cs | 2 +- Aaru.Core/Media/Detection/MMC.cs | 41 ++++++++++++++++++- Aaru.Core/Media/Info/ScsiInfo.cs | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index 544fce5cf..12ebccb3c 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -557,7 +557,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Detecting disc type..."); MMC.DetectDiscType(ref dskType, sessions, toc, _dev, out hiddenTrack, out hiddenData, - firstTrackLastSession); + firstTrackLastSession, blocks); if(hiddenTrack || firstLba > 0) { diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index 180cc1a4f..48c81eb2e 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -188,7 +188,7 @@ namespace Aaru.Core.Devices.Dumping _dev.IsUsb, opticalDisc); if(_dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) - MMC.DetectDiscType(ref dskType, 1, null, _dev, out _, out _, 0); + MMC.DetectDiscType(ref dskType, 1, null, _dev, out _, out _, 0, blocks+1); switch(dskType) { diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index 3a8e52b27..ef1ff9934 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -42,6 +42,7 @@ using Aaru.Decoders.Bluray; using Aaru.Decoders.CD; using Aaru.Decoders.SCSI.MMC; using Aaru.Decoders.Sega; +using Aaru.Decoders.Xbox; using Aaru.Devices; using Aaru.Helpers; @@ -281,7 +282,7 @@ namespace Aaru.Core.Media.Detection internal static void DetectDiscType(ref MediaType mediaType, int sessions, FullTOC.CDFullTOC? decodedToc, Device dev, out bool hiddenTrack, out bool hiddenData, - int firstTrackLastSession) + int firstTrackLastSession, ulong blocks) { uint startOfFirstDataTrack = uint.MaxValue; DI.DiscInformation? blurayDi = null; @@ -1111,6 +1112,44 @@ namespace Aaru.Core.Media.Detection } } + if(mediaType == MediaType.DVDROM) + { + sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, + MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, + out _); + + if(!sense) + { + if(DMI.IsXbox(cmdBuf)) + { + AaruConsole.DebugWriteLine("Media detection", + "Found Xbox DMI, setting disc type to Xbox Game Disc (XGD)."); + + mediaType = MediaType.XGD; + + return; + } + if(DMI.IsXbox360(cmdBuf)) + { + + // 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 + { + AaruConsole.DebugWriteLine("Media detection", + "Found Xbox 360 DMI with {0} blocks, setting disc type to Xbox 360 Game Disc 3 (XGD3)."); + + mediaType = MediaType.XGD3; + return; + } + AaruConsole.DebugWriteLine("Media detection", + "Found Xbox 360 DMI with {0} blocks, setting disc type to Xbox 360 Game Disc 2 (XGD2)."); + mediaType = MediaType.XGD2; + return; + } + } + } break; // Recordables will be checked for PhotoCD only diff --git a/Aaru.Core/Media/Info/ScsiInfo.cs b/Aaru.Core/Media/Info/ScsiInfo.cs index 536ccccee..a3a5a5447 100644 --- a/Aaru.Core/Media/Info/ScsiInfo.cs +++ b/Aaru.Core/Media/Info/ScsiInfo.cs @@ -1461,7 +1461,7 @@ namespace Aaru.Core.Media.Info } MediaType tmpType = MediaType; - MMC.DetectDiscType(ref tmpType, sessions, FullToc, dev, out _, out _, firstTrackLastSession); + MMC.DetectDiscType(ref tmpType, sessions, FullToc, dev, out _, out _, firstTrackLastSession, Blocks); MediaType = tmpType; }