diff --git a/Aaru.Core/Devices/Dumping/MMC.cs b/Aaru.Core/Devices/Dumping/MMC.cs index 38a4b70eb..2d48b5ac5 100644 --- a/Aaru.Core/Devices/Dumping/MMC.cs +++ b/Aaru.Core/Devices/Dumping/MMC.cs @@ -316,7 +316,7 @@ namespace Aaru.Core.Devices.Dumping if(!sense) { - PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf); + PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf, dskType); if(nintendoPfi?.DiskCategory == DiskCategory.Nintendo && nintendoPfi.Value.PartVersion == 15) @@ -354,13 +354,13 @@ namespace Aaru.Core.Devices.Dumping MmcDiscStructureFormat.PhysicalInformation, 0, _dev.Timeout, out _); if(!sense) - if(PFI.Decode(cmdBuf).HasValue) + if(PFI.Decode(cmdBuf, dskType).HasValue) { tmpBuf = new byte[cmdBuf.Length - 4]; Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf); - PFI.PhysicalFormatInformation decPfi = PFI.Decode(cmdBuf).Value; + PFI.PhysicalFormatInformation decPfi = PFI.Decode(cmdBuf, dskType).Value; UpdateStatus?.Invoke($"PFI:\n{PFI.Prettify(decPfi)}"); // False book types diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index ae0a01a38..f4ef1742a 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -195,10 +195,10 @@ namespace Aaru.Core.Devices.Dumping mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf); AaruConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize); - ulong l0Video = - (PFI.Decode(readBuffer)?.Layer0EndPSN ?? 0 - PFI.Decode(readBuffer)?.DataAreaStartPSN ?? 0) + 1; + ulong l0Video = (PFI.Decode(readBuffer, MediaType.DVDROM)?.Layer0EndPSN ?? + 0 - PFI.Decode(readBuffer, MediaType.DVDROM)?.DataAreaStartPSN ?? 0) + 1; - ulong l1Video = (totalSize - l0Video) + 1; + ulong l1Video = totalSize - l0Video + 1; UpdateStatus?.Invoke("Reading Disc Manufacturing Information."); _dumpLog.WriteLine("Reading Disc Manufacturing Information."); @@ -232,9 +232,10 @@ namespace Aaru.Core.Devices.Dumping mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf); AaruConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize); - l0Video = (PFI.Decode(coldPfi)?.Layer0EndPSN ?? 0 - PFI.Decode(coldPfi)?.DataAreaStartPSN ?? 0) + 1; + l0Video = (PFI.Decode(coldPfi, MediaType.DVDROM)?.Layer0EndPSN ?? + 0 - PFI.Decode(coldPfi, MediaType.DVDROM)?.DataAreaStartPSN ?? 0) + 1; - l1Video = (totalSize - l0Video) + 1; + l1Video = totalSize - l0Video + 1; if(totalSize > 300000) { @@ -323,15 +324,14 @@ namespace Aaru.Core.Devices.Dumping AaruConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize); ulong blocks = totalSize + 1; - PFI.PhysicalFormatInformation wxRipperPfi = PFI.Decode(readBuffer).Value; + PFI.PhysicalFormatInformation wxRipperPfi = PFI.Decode(readBuffer, MediaType.DVDROM).Value; UpdateStatus?.Invoke($"WxRipper PFI's Data Area Start PSN: {wxRipperPfi.DataAreaStartPSN} sectors"); UpdateStatus?.Invoke($"WxRipper PFI's Layer 0 End PSN: {wxRipperPfi.Layer0EndPSN} sectors"); _dumpLog.WriteLine($"WxRipper PFI's Data Area Start PSN: {wxRipperPfi.DataAreaStartPSN} sectors"); _dumpLog.WriteLine($"WxRipper PFI's Layer 0 End PSN: {wxRipperPfi.Layer0EndPSN} sectors"); - ulong middleZone = - (totalSize - ((wxRipperPfi.Layer0EndPSN - wxRipperPfi.DataAreaStartPSN) + 1) - gameSize) + 1; + ulong middleZone = totalSize - (wxRipperPfi.Layer0EndPSN - wxRipperPfi.DataAreaStartPSN + 1) - gameSize + 1; tmpBuf = new byte[readBuffer.Length - 4]; Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4); @@ -648,7 +648,7 @@ namespace Aaru.Core.Devices.Dumping if(elapsed < 1) continue; - currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed); + currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } @@ -756,7 +756,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Reading Video Layer 1."); InitProgress?.Invoke(); - for(ulong l1 = (currentSector - blocks - middleZone) + l0Video; l1 < l0Video + l1Video; l1 += blocksToRead) + for(ulong l1 = currentSector - blocks - middleZone + l0Video; l1 < l0Video + l1Video; l1 += blocksToRead) { if(_aborted) { @@ -767,8 +767,8 @@ namespace Aaru.Core.Devices.Dumping break; } - if((l0Video + l1Video) - l1 < blocksToRead) - blocksToRead = (uint)((l0Video + l1Video) - l1); + if(l0Video + l1Video - l1 < blocksToRead) + blocksToRead = (uint)(l0Video + l1Video - l1); if(currentSpeed > maxSpeed && currentSpeed > 0) @@ -837,7 +837,7 @@ namespace Aaru.Core.Devices.Dumping if(elapsed < 1) continue; - currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed); + currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } @@ -871,23 +871,23 @@ namespace Aaru.Core.Devices.Dumping 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); UpdateStatus?.Invoke($"Dump finished in {(end - start).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average dump speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); + Invoke($"Average dump speed {blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000):F3} KiB/sec."); UpdateStatus?. - Invoke($"Average write speed {((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); + Invoke($"Average write speed {blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration:F3} KiB/sec."); _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)); + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", - ((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration); + blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); #region Trimming if(_resume.BadBlocks.Count > 0 && @@ -1225,7 +1225,7 @@ namespace Aaru.Core.Devices.Dumping Invoke($"Took a total of {(end - start).TotalSeconds:F3} seconds ({totalDuration / 1000:F3} processing commands, {totalChkDuration / 1000:F3} checksumming, {imageWriteDuration:F3} writing, {(closeEnd - closeStart).TotalSeconds:F3} closing)."); UpdateStatus?. - Invoke($"Average speed: {((double)blockSize * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); + Invoke($"Average speed: {blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index ba272ea2e..f5a049ca2 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -350,7 +350,7 @@ namespace Aaru.Core byte[] pfi = imageFormat.ReadDiskTag(MediaTagType.DVD_PFI); AaruConsole.WriteLine("DVD Physical Format Information contained in image:"); - AaruConsole.Write("{0}", PFI.Prettify(pfi)); + AaruConsole.Write("{0}", PFI.Prettify(pfi, imageFormat.Info.MediaType)); AaruConsole.WriteLine(); } @@ -368,7 +368,7 @@ namespace Aaru.Core byte[] pfi = imageFormat.ReadDiskTag(MediaTagType.DVDR_PFI); AaruConsole.WriteLine("DVD-R Physical Format Information contained in image:"); - AaruConsole.Write("{0}", PFI.Prettify(pfi)); + AaruConsole.Write("{0}", PFI.Prettify(pfi, imageFormat.Info.MediaType)); AaruConsole.WriteLine(); } @@ -541,7 +541,7 @@ namespace Aaru.Core byte[] xpfi = imageFormat.ReadDiskTag(MediaTagType.Xbox_PFI); AaruConsole.WriteLine("Xbox Physical Format Information contained in image:"); - AaruConsole.Write("{0}", PFI.Prettify(xpfi)); + AaruConsole.Write("{0}", PFI.Prettify(xpfi, imageFormat.Info.MediaType)); AaruConsole.WriteLine(); } diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index fabe98fb4..29619aafd 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -1145,7 +1145,7 @@ namespace Aaru.Core.Media.Detection if(!sense) { - PFI.PhysicalFormatInformation? pfi = PFI.Decode(cmdBuf); + PFI.PhysicalFormatInformation? pfi = PFI.Decode(cmdBuf, mediaType); if(pfi != null) { diff --git a/Aaru.Core/Media/Info/ScsiInfo.cs b/Aaru.Core/Media/Info/ScsiInfo.cs index 0c4c24e95..4750ad090 100644 --- a/Aaru.Core/Media/Info/ScsiInfo.cs +++ b/Aaru.Core/Media/Info/ScsiInfo.cs @@ -521,7 +521,7 @@ namespace Aaru.Core.Media.Info else { DvdPfi = cmdBuf; - DecodedPfi = PFI.Decode(cmdBuf); + DecodedPfi = PFI.Decode(cmdBuf, MediaType); if(DecodedPfi.HasValue) if(MediaType == MediaType.DVDROM) @@ -1219,11 +1219,11 @@ namespace Aaru.Core.Media.Info else { DvdPfi = cmdBuf; - PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf); + PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf, MediaType); if(nintendoPfi != null) { - AaruConsole.WriteLine("PFI:\n{0}", PFI.Prettify(cmdBuf)); + AaruConsole.WriteLine("PFI:\n{0}", PFI.Prettify(cmdBuf, MediaType)); if(nintendoPfi.Value.DiskCategory == DiskCategory.Nintendo && nintendoPfi.Value.PartVersion == 15) @@ -1328,8 +1328,8 @@ namespace Aaru.Core.Media.Info AaruConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors", totalSize); - ulong l0Video = PFI.Decode(cmdBuf).Value.Layer0EndPSN - - PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1; + ulong l0Video = PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN - + PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN + 1; ulong l1Video = totalSize - l0Video + 1; @@ -1395,8 +1395,8 @@ namespace Aaru.Core.Media.Info totalSize); ulong middleZone = - totalSize - (PFI.Decode(cmdBuf).Value.Layer0EndPSN - - PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1; + totalSize - (PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN - + PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN + 1) - gameSize + 1; totalSize = l0Video + l1Video + (middleZone * 2) + gameSize; ulong layerBreak = l0Video + middleZone + (gameSize / 2); diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index 9fd838ff1..1d58e1135 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -148,7 +148,7 @@ namespace Aaru.Core break; case MediaTagType.DVD_PFI: - PFI.PhysicalFormatInformation? pfi = PFI.Decode(tag); + PFI.PhysicalFormatInformation? pfi = PFI.Decode(tag, dskType); if(pfi.HasValue) if(dskType != MediaType.XGD && diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index c38186d42..b39b340be 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -382,7 +382,7 @@ namespace Aaru.Gui.ViewModels.Panels if(imageFormat.Info.ReadableMediaTags?.Contains(MediaTagType.DVD_PFI) == true) { dvdPfi = imageFormat.ReadDiskTag(MediaTagType.DVD_PFI); - decodedPfi = PFI.Decode(dvdPfi); + decodedPfi = PFI.Decode(dvdPfi, imageFormat.Info.MediaType); } if(imageFormat.Info.ReadableMediaTags?.Contains(MediaTagType.DVD_DMI) == true) diff --git a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs index 0382c6d6f..d32a7f423 100644 --- a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs @@ -32,6 +32,7 @@ using System.Collections.ObjectModel; using System.Text; +using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs.Devices.SCSI; @@ -57,17 +58,19 @@ namespace Aaru.Gui.ViewModels.Windows { public sealed class DecodeMediaTagsViewModel : ViewModelBase { - const int HEX_COLUMNS = 32; - string _decodedText; - bool _decodedVisible; - string _hexViewText; - - MediaTagModel _selectedTag; + const int HEX_COLUMNS = 32; + string _decodedText; + bool _decodedVisible; + string _hexViewText; + readonly MediaType _mediaType; + MediaTagModel _selectedTag; public DecodeMediaTagsViewModel([NotNull] IMediaImage inputFormat) { TagsList = new ObservableCollection(); + _mediaType = inputFormat.Info.MediaType; + foreach(MediaTagType tag in inputFormat.Info.ReadableMediaTags) try { @@ -140,7 +143,7 @@ namespace Aaru.Gui.ViewModels.Windows break; case MediaTagType.DVD_PFI: - DecodedText = PFI.Prettify(value.Data); + DecodedText = PFI.Prettify(value.Data, _mediaType); break; case MediaTagType.DVD_CMI: @@ -156,11 +159,11 @@ namespace Aaru.Gui.ViewModels.Windows break; case MediaTagType.DVDR_PFI: - DecodedText = PFI.Prettify(value.Data); + DecodedText = PFI.Prettify(value.Data, _mediaType); break; case MediaTagType.HDDVD_MediumStatus: - DecodedText = PFI.Prettify(value.Data); + DecodedText = PFI.Prettify(value.Data, _mediaType); break; case MediaTagType.BD_DI: diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index e999dcb5b..51df0f506 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -378,7 +378,7 @@ namespace Aaru.DiscImages _dmi[0] = 0x08; _dmi[1] = 0x02; - PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(_pfi); + PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(_pfi, _imageInfo.MediaType); // All discs I tested the disk category and part version (as well as the start PSN for DVD-RAM) where modified by Alcohol // So much for archival value diff --git a/Aaru.Images/BlindWrite5/Read.cs b/Aaru.Images/BlindWrite5/Read.cs index 593fbbf78..d0b6325b0 100644 --- a/Aaru.Images/BlindWrite5/Read.cs +++ b/Aaru.Images/BlindWrite5/Read.cs @@ -204,7 +204,7 @@ namespace Aaru.DiscImages _dmi[0] = 0x08; _dmi[1] = 0x02; - PFI.PhysicalFormatInformation? decodedPfi = PFI.Decode(_pfi); + PFI.PhysicalFormatInformation? decodedPfi = PFI.Decode(_pfi, MediaType.DVDROM); if(decodedPfi.HasValue) AaruConsole.DebugWriteLine("BlindWrite5 plugin", "PFI: {0}", PFI.Prettify(decodedPfi)); @@ -904,7 +904,7 @@ namespace Aaru.DiscImages if(_dmi != null && _pfi != null) { - PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(_pfi); + PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(_pfi, _imageInfo.MediaType); // All discs I tested the disk category and part version (as well as the start PSN for DVD-RAM) where modified by Alcohol // So much for archival value diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index fd91ee238..c5539d96d 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -415,7 +415,7 @@ namespace Aaru.DiscImages // It is a DVD if(_mediaTags.TryGetValue(MediaTagType.DVD_PFI, out byte[] pfi)) { - PFI.PhysicalFormatInformation decPfi = PFI.Decode(pfi).Value; + PFI.PhysicalFormatInformation decPfi = PFI.Decode(pfi, _imageInfo.MediaType).Value; switch(decPfi.DiskCategory) {