From 1aa8271d62ba1b17946e961db34883eded9c8b5c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 14 Dec 2025 11:23:54 +0000 Subject: [PATCH] Add support for dumping the 2nd layer PFI of DVDs. --- Aaru.CommonTypes/Enums/Images.cs | 5 +++- Aaru.Core/Devices/Dumping/MMC.cs | 27 +++++++++++++++++++ Aaru.Core/ImageInfo.cs | 14 ++++++++++ .../Windows/DecodeMediaTagsViewModel.cs | 1 + Aaru.Localization/Core.Designer.cs | 6 +++++ Aaru.Localization/Core.es.resx | 3 +++ Aaru.Localization/Core.resx | 3 +++ 7 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Aaru.CommonTypes/Enums/Images.cs b/Aaru.CommonTypes/Enums/Images.cs index d38d2cc2c..f8f241dfc 100644 --- a/Aaru.CommonTypes/Enums/Images.cs +++ b/Aaru.CommonTypes/Enums/Images.cs @@ -384,7 +384,10 @@ public enum MediaTagType MiniDiscDTOC = 72, /// Decrypted DVD disc key [Description("Disc key (Decrypted)")] - DVD_DiscKey_Decrypted = 73 + DVD_DiscKey_Decrypted = 73, + /// Physical Format Information for the 2nd layer of dual-layer DVDs + [Description("Physical Format Information (2nd Layer)")] + DVD_PFI_2ndLayer = 74 } /// Enumeration of media types defined in metadata diff --git a/Aaru.Core/Devices/Dumping/MMC.cs b/Aaru.Core/Devices/Dumping/MMC.cs index c956ff441..f90d6ec7e 100644 --- a/Aaru.Core/Devices/Dumping/MMC.cs +++ b/Aaru.Core/Devices/Dumping/MMC.cs @@ -420,6 +420,33 @@ partial class Dump DiskCategory.UMD => MediaType.UMD, _ => MediaType.DVDROM }; + + if(nullablePfi.Value.Layers > 1) + { + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 1, + MmcDiscStructureFormat.PhysicalInformation, + 0, + _dev.Timeout, + out _); + + if(!sense) + { + PFI.PhysicalFormatInformation? layer2Pfi = PFI.Decode(cmdBuf, dskType); + + if(layer2Pfi.HasValue) + { + tmpBuf = new byte[cmdBuf.Length - 4]; + Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); + mediaTags.Add(MediaTagType.DVD_PFI_2ndLayer, tmpBuf); + + UpdateStatus?.Invoke("Layer 2 PFI:\n" + PFI.Prettify(layer2Pfi.Value)); + } + } + } } } diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index 897f72deb..7ad8adc19 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -566,6 +566,20 @@ public static class ImageInfo } } + if(imageFormat.Info.ReadableMediaTags?.Contains(MediaTagType.DVD_PFI_2ndLayer) == true) + { + errno = imageFormat.ReadMediaTag(MediaTagType.DVD_PFI_2ndLayer, out byte[] pfi); + + if(errno == ErrorNumber.NoError) + { + AaruLogging.WriteLine(Localization.Core + .DVD_2nd_layer_Physical_Format_Information_contained_in_image_WithMarkup); + + AaruLogging.Write(PFI.Prettify(pfi, imageFormat.Info.MediaType)); + AaruLogging.WriteLine(); + } + } + if(imageFormat.Info.ReadableMediaTags?.Contains(MediaTagType.DVDRAM_DDS) == true) { errno = imageFormat.ReadMediaTag(MediaTagType.DVDRAM_DDS, out byte[] dds); diff --git a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs index 3678586ab..fb8c75db8 100644 --- a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs @@ -210,6 +210,7 @@ public sealed partial class DecodeMediaTagsViewModel : ViewModelBase break; case MediaTagType.DVD_PFI: + case MediaTagType.DVD_PFI_2ndLayer: DecodedText = PFI.Prettify(value.Data, _mediaType); if(string.IsNullOrEmpty(DecodedText)) DecodedVisible = false; diff --git a/Aaru.Localization/Core.Designer.cs b/Aaru.Localization/Core.Designer.cs index 6254daf77..0cdd4ad2a 100644 --- a/Aaru.Localization/Core.Designer.cs +++ b/Aaru.Localization/Core.Designer.cs @@ -6892,5 +6892,11 @@ namespace Aaru.Localization { return ResourceManager.GetString("Media_identified_as", resourceCulture); } } + + public static string DVD_2nd_layer_Physical_Format_Information_contained_in_image_WithMarkup { + get { + return ResourceManager.GetString("DVD_2nd_layer_Physical_Format_Information_contained_in_image_WithMarkup", resourceCulture); + } + } } } diff --git a/Aaru.Localization/Core.es.resx b/Aaru.Localization/Core.es.resx index 1d98339cc..05cfb1072 100644 --- a/Aaru.Localization/Core.es.resx +++ b/Aaru.Localization/Core.es.resx @@ -3496,4 +3496,7 @@ No tiene sentido hacerlo y supondría demasiado esfuerzo para la cinta. [slateblue1]Tipo XML:[/] [italic][rosybrown]{0}[/][/] + + [bold][blue]Información del formato físico del DVD (2ª capa) contenida en la imagen:[/][/] + \ No newline at end of file diff --git a/Aaru.Localization/Core.resx b/Aaru.Localization/Core.resx index fd8d88a10..c7bab3517 100644 --- a/Aaru.Localization/Core.resx +++ b/Aaru.Localization/Core.resx @@ -3517,4 +3517,7 @@ It has no sense to do it, and it will put too much strain on the tape. Media identified as + + [bold][blue]DVD 2nd layer Physical Format Information contained in image:[/][/] + \ No newline at end of file