From 2197167088305bd58824c51724ef9b5d90544f5b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 14 Nov 2024 20:48:42 -0500 Subject: [PATCH] Add remaining easy sizes per partition --- SabreTools.Serialization/Wrappers/N3DS.cs | 48 +++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/N3DS.cs b/SabreTools.Serialization/Wrappers/N3DS.cs index 692a8804..7b06f998 100644 --- a/SabreTools.Serialization/Wrappers/N3DS.cs +++ b/SabreTools.Serialization/Wrappers/N3DS.cs @@ -437,10 +437,10 @@ namespace SabreTools.Serialization.Wrappers } /// - /// Get the offset of a partition logo + /// Get the offset of a partition logo region /// - /// Offset to the logo of the partition, 0 on error - public uint GetLogoOffset(int index) + /// Offset to the logo region of the partition, 0 on error + public uint GetLogoRegionOffset(int index) { // No partitions means no size is available if (PartitionsTable == null || Partitions == null) @@ -604,6 +604,48 @@ namespace SabreTools.Serialization.Wrappers return header.ExtendedHeaderSizeInBytes; } + /// + /// Get the size of a partition logo region + /// + /// Size of the partition logo region in bytes, 0 on error + public uint GetLogoRegionSize(int index) + { + // Empty partitions array means no size is available + if (Partitions == null) + return 0; + if (index < 0 || index >= Partitions.Length) + return 0; + + // Invalid partition header means no size is available + var header = Partitions[index]; + if (header == null) + return 0; + + // Return the adjusted size + return header.LogoRegionSizeInMediaUnits * MediaUnitSize; + } + + /// + /// Get the size of a partition plain region + /// + /// Size of the partition plain region in bytes, 0 on error + public uint GetPlainRegionSize(int index) + { + // Empty partitions array means no size is available + if (Partitions == null) + return 0; + if (index < 0 || index >= Partitions.Length) + return 0; + + // Invalid partition header means no size is available + var header = Partitions[index]; + if (header == null) + return 0; + + // Return the adjusted size + return header.PlainRegionSizeInMediaUnits * MediaUnitSize; + } + /// /// Get the size of a partition RomFS ///