N3DS model cleanup

This commit is contained in:
Matt Nadareski
2025-10-30 22:36:21 -04:00
parent c4f73abcb6
commit 4aa0eb54b7
24 changed files with 206 additions and 400 deletions

View File

@@ -39,7 +39,7 @@ namespace SabreTools.Data.Models.N3DS
/// TODO: Make enum for flag values
/// <remarks>28 entries</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)]
public uint[]? Descriptors;
public uint[] Descriptors;
/// <summary>
/// Reserved

View File

@@ -44,26 +44,26 @@ namespace SabreTools.Data.Models.N3DS
/// </summary>
/// <remarks>16 entries</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public ushort[]? ResourceLimitDescriptors;
public ushort[] ResourceLimitDescriptors = new ushort[16];
/// <summary>
/// Storage info
/// </summary>
public StorageInfo? StorageInfo;
public StorageInfo StorageInfo;
/// <summary>
/// Service access control
/// </summary>
/// <remarks>32 entries</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public ulong[]? ServiceAccessControl;
public ulong[] ServiceAccessControl = new ulong[32];
/// <summary>
/// Extended service access control, support for this was implemented with 9.3.0-X.
/// </summary>
/// <remarks>2 entries</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public ulong[]? ExtendedServiceAccessControl;
public ulong[] ExtendedServiceAccessControl = new ulong[2];
/// <summary>
/// Reserved

View File

@@ -11,7 +11,7 @@ namespace SabreTools.Data.Models.N3DS
/// </summary>
/// <remarks>15 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public ARM9AccessControlDescriptors[]? Descriptors;
public ARM9AccessControlDescriptors[] Descriptors;
/// <summary>
/// ARM9 Descriptor Version. Originally this value had to be ≥ 2.

View File

@@ -9,17 +9,17 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// ARM11 local system capabilities
/// </summary>
public ARM11LocalSystemCapabilities? ARM11LocalSystemCapabilities;
public ARM11LocalSystemCapabilities ARM11LocalSystemCapabilities;
/// <summary>
/// ARM11 kernel capabilities
/// </summary>
public ARM11KernelCapabilities? ARM11KernelCapabilities;
public ARM11KernelCapabilities ARM11KernelCapabilities;
/// <summary>
/// ARM9 access control
/// </summary>
/// TODO: Fix serialization issue with this type
public ARM9AccessControl? ARM9AccessControl;
public ARM9AccessControl ARM9AccessControl;
}
}

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// CIA header
/// </summary>
public CIAHeader? Header { get; set; }
public CIAHeader Header { get; set; }
/// <summary>
/// Certificate chain
@@ -25,22 +25,22 @@ namespace SabreTools.Data.Models.N3DS
/// <remarks>
/// https://www.3dbrew.org/wiki/CIA#Certificate_Chain
/// </remarks>
public Certificate[]? CertificateChain { get; set; }
public Certificate[] CertificateChain { get; set; }
/// <summary>
/// Ticket
/// </summary>
public Ticket? Ticket { get; set; }
public Ticket Ticket { get; set; }
/// <summary>
/// TMD file data
/// </summary>
public TitleMetadata? TMDFileData { get; set; }
public TitleMetadata TMDFileData { get; set; }
/// <summary>
/// Content file data
/// </summary>
public NCCHHeader[]? Partitions { get; set; }
public NCCHHeader[] Partitions { get; set; }
/// <summary>
/// Content file data
@@ -51,6 +51,6 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Meta file data (Not a necessary component)
/// </summary>
public MetaData? MetaData { get; set; }
public MetaData MetaData { get; set; }
}
}

View File

@@ -74,6 +74,6 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// This data is returned by 16-byte cartridge command 0x82.
/// </summary>
public InitialData? InitialData;
public InitialData InitialData;
}
}

View File

@@ -8,36 +8,36 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// 3DS cart header
/// </summary>
public NCSDHeader? Header { get; set; }
public NCSDHeader Header { get; set; }
/// <summary>
/// 3DS card info header
/// </summary>
public CardInfoHeader? CardInfoHeader { get; set; }
public CardInfoHeader CardInfoHeader { get; set; }
/// <summary>
/// 3DS development card info header
/// </summary>
public DevelopmentCardInfoHeader? DevelopmentCardInfoHeader { get; set; }
public DevelopmentCardInfoHeader DevelopmentCardInfoHeader { get; set; }
/// <summary>
/// NCCH partitions
/// </summary>
public NCCHHeader[]? Partitions { get; set; }
public NCCHHeader[] Partitions { get; set; }
/// <summary>
/// NCCH extended headers
/// </summary>
public NCCHExtendedHeader[]? ExtendedHeaders { get; set; }
public NCCHExtendedHeader[] ExtendedHeaders { get; set; }
/// <summary>
/// ExeFS headers associated with each partition
/// </summary>
public ExeFSHeader[]? ExeFSHeaders { get; set; }
public ExeFSHeader[] ExeFSHeaders { get; set; }
/// <summary>
/// RomFS headers associated with each partition
/// </summary>
public RomFSHeader[]? RomFSHeaders { get; set; }
public RomFSHeader[] RomFSHeaders { get; set; }
}
}
}

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Issuer
/// </summary>
public string? Issuer { get; set; }
public string Issuer { get; set; }
/// <summary>
/// Key Type
@@ -47,7 +47,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Name
/// </summary>
public string? Name { get; set; }
public string Name { get; set; }
/// <summary>
/// Expiration time as UNIX Timestamp, used at least for CTCert

View File

@@ -30,6 +30,6 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// TestData
/// </summary>
public TestData? TestData;
public TestData TestData;
}
}

View File

@@ -21,7 +21,7 @@ namespace SabreTools.Data.Models.N3DS
public enum ARM11LSCFlag0 : byte
{
IdealProcessor = 0x01 | 0x02,
AffinityMask = 0x04 | 0x08,
/// <summary>

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Data.Models.N3DS
/// </summary>
/// <remarks>8 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string? FileName;
public string FileName;
/// <summary>
/// File offset

View File

@@ -16,7 +16,7 @@
/// <summary>
/// File headers (10 headers maximum, 16 bytes each)
/// </summary>
public ExeFSFileHeader[]? FileHeaders { get; set; }
public ExeFSFileHeader[] FileHeaders { get; set; }
/// <summary>
/// Reserved
@@ -28,6 +28,6 @@
/// File hashes (10 hashes maximum, 32 bytes each, one for each header)
/// </summary>
/// <remarks>SHA-256 hashes</remarks>
public byte[][]? FileHashes { get; set; }
public byte[][] FileHashes { get; set; }
}
}

View File

@@ -44,6 +44,6 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Copy of first NCCH header (excluding RSA signature)
/// </summary>
public NCCHHeader? BackupHeader;
public NCCHHeader BackupHeader;
}
}

View File

@@ -14,12 +14,12 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// SCI
/// </summary>
public SystemControlInfo? SCI;
public SystemControlInfo SCI;
/// <summary>
/// ACI
/// </summary>
public AccessControlInfo? ACI;
public AccessControlInfo ACI;
/// <summary>
/// AccessDesc signature (RSA-2048-SHA256)
@@ -38,6 +38,6 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// ACI (for limitation of first ACI)
/// </summary>
public AccessControlInfo? ACIForLimitations;
public AccessControlInfo ACIForLimitations;
}
}

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Data.Models.N3DS
/// </summary>
/// <remarks>4 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string? MagicID;
public string MagicID;
/// <summary>
/// Content size, in media units (1 media unit = 0x200 bytes)
@@ -74,7 +74,7 @@ namespace SabreTools.Data.Models.N3DS
/// </summary>
/// <remarks>0x10 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x10)]
public string? ProductCode;
public string ProductCode;
/// <summary>
/// Extended header SHA-256 hash (SHA256 of 2x Alignment Size, beginning at 0x0 of ExHeader)
@@ -96,7 +96,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Flags
/// </summary>
public NCCHHeaderFlags? Flags;
public NCCHHeaderFlags Flags;
/// <summary>
/// Plain region offset, in media units

View File

@@ -22,7 +22,7 @@
/// <summary>
/// Magic Number 'NCSD'
/// </summary>
public string? MagicNumber { get; set; }
public string MagicNumber { get; set; }
/// <summary>
/// Size of the NCSD image, in media units (1 media unit = 0x200 bytes)
@@ -49,7 +49,7 @@
/// <summary>
/// Offset & Length partition table, in media units
/// </summary>
public PartitionTableEntry[]? PartitionsTable { get; set; }
public PartitionTableEntry[] PartitionsTable { get; set; }
#endregion

View File

@@ -16,7 +16,7 @@ namespace SabreTools.Data.Models.N3DS
/// Magic "IVFC"
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string? MagicString;
public string MagicString;
/// <summary>
/// Magic number 0x10000

View File

@@ -11,7 +11,7 @@ namespace SabreTools.Data.Models.N3DS
/// </summary>
/// <remarks>8 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string? ApplicationTitle;
public string ApplicationTitle;
/// <summary>
/// Reserved
@@ -33,7 +33,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Text code set info
/// </summary>
public CodeSetInfo? TextCodeSetInfo;
public CodeSetInfo TextCodeSetInfo;
/// <summary>
/// Stack size
@@ -43,7 +43,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Read-only code set info
/// </summary>
public CodeSetInfo? ReadOnlyCodeSetInfo;
public CodeSetInfo ReadOnlyCodeSetInfo;
/// <summary>
/// Reserved
@@ -53,7 +53,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Data code set info
/// </summary>
public CodeSetInfo? DataCodeSetInfo;
public CodeSetInfo DataCodeSetInfo;
/// <summary>
/// BSS size
@@ -70,6 +70,6 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// SystemInfo
/// </summary>
public SystemInfo? SystemInfo;
public SystemInfo SystemInfo;
}
}

View File

@@ -160,7 +160,7 @@ namespace SabreTools.Data.Models.N3DS
/// <remarks>
/// In demos, the first u32 in the "Limits" section is 0x4, then the second u32 is the max-playcount.
/// </remarks>
public uint[]? Limits { get; set; }
public uint[] Limits { get; set; }
/// <summary>
/// The Content Index of a ticket has its own size defined within itself,
@@ -180,6 +180,6 @@ namespace SabreTools.Data.Models.N3DS
/// <remarks>
/// https://www.3dbrew.org/wiki/Ticket#Certificate_Chain
/// </remarks>
public Certificate[]? CertificateChain { get; set; }
public Certificate[] CertificateChain { get; set; }
}
}

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// Signature Issuer
/// </summary>
public string? Issuer { get; set; }
public string Issuer { get; set; }
/// <summary>
/// Version
@@ -140,13 +140,13 @@ namespace SabreTools.Data.Models.N3DS
/// <summary>
/// There are 64 of these records, usually only the first is used.
/// </summary>
public ContentInfoRecord[]? ContentInfoRecords { get; set; }
public ContentInfoRecord[] ContentInfoRecords { get; set; }
/// <summary>
/// There is one of these for each content contained in this title.
/// (Determined by "Content Count" in the TMD Header).
/// </summary>
public ContentChunkRecord[]? ContentChunkRecords { get; set; }
public ContentChunkRecord[] ContentChunkRecords { get; set; }
/// <summary>
/// Certificate chain
@@ -154,6 +154,6 @@ namespace SabreTools.Data.Models.N3DS
/// <remarks>
/// https://www.3dbrew.org/wiki/Title_metadata#Certificate_Chain
/// </remarks>
public Certificate[]? CertificateChain { get; set; }
public Certificate[] CertificateChain { get; set; }
}
}

View File

@@ -67,7 +67,7 @@ namespace SabreTools.Serialization.Readers
for (int i = 0; i < 8; i++)
{
// Find the offset to the partition
long partitionOffset = initialOffset + cart.Header.PartitionsTable?[i]?.Offset ?? 0;
long partitionOffset = initialOffset + cart.Header.PartitionsTable[i].Offset;
partitionOffset *= mediaUnitSize;
if (partitionOffset <= initialOffset)
continue;

View File

@@ -26,17 +26,10 @@ namespace SabreTools.Serialization.Wrappers
Print(builder, Model.MetaData);
}
private static void Print(StringBuilder builder, CIAHeader? header)
private static void Print(StringBuilder builder, CIAHeader header)
{
builder.AppendLine(" CIA Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No CIA header");
builder.AppendLine();
return;
}
builder.AppendLine(header.HeaderSize, " Header size");
builder.AppendLine(header.Type, " Type");
builder.AppendLine(header.Version, " Version");
@@ -49,11 +42,11 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Certificate[]? certificateChain)
private static void Print(StringBuilder builder, Certificate[] certificateChain)
{
builder.AppendLine(" Certificate Chain Information:");
builder.AppendLine(" -------------------------");
if (certificateChain == null || certificateChain.Length == 0)
if (certificateChain.Length == 0)
{
builder.AppendLine(" No certificates, expected 3");
builder.AppendLine();
@@ -100,17 +93,10 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Ticket? ticket)
private static void Print(StringBuilder builder, Ticket ticket)
{
builder.AppendLine(" Ticket Information:");
builder.AppendLine(" -------------------------");
if (ticket == null)
{
builder.AppendLine(" No ticket");
builder.AppendLine();
return;
}
builder.AppendLine($" Signature type: {ticket.SignatureType} (0x{ticket.SignatureType:X})");
builder.AppendLine(ticket.SignatureSize, " Signature size");
builder.AppendLine(ticket.PaddingSize, " Padding size");
@@ -137,7 +123,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(ticket.Audit, " Audit");
builder.AppendLine(ticket.Reserved6, " Reserved 6");
builder.AppendLine(" Limits:");
if (ticket.Limits == null || ticket.Limits.Length == 0)
if (ticket.Limits.Length == 0)
{
builder.AppendLine(" No limits");
}
@@ -154,7 +140,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(" Ticket Certificate Chain Information:");
builder.AppendLine(" -------------------------");
if (ticket.CertificateChain == null || ticket.CertificateChain.Length == 0)
if (ticket.CertificateChain.Length == 0)
{
builder.AppendLine(" No certificates, expected 2");
}
@@ -200,17 +186,10 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, TitleMetadata? tmd)
private static void Print(StringBuilder builder, TitleMetadata tmd)
{
builder.AppendLine(" Title Metadata Information:");
builder.AppendLine(" -------------------------");
if (tmd == null)
{
builder.AppendLine(" No title metadata");
builder.AppendLine();
return;
}
builder.AppendLine($" Signature type: {tmd.SignatureType} (0x{tmd.SignatureType:X})");
builder.AppendLine(tmd.SignatureSize, " Signature size");
builder.AppendLine(tmd.PaddingSize, " Padding size");
@@ -240,7 +219,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(" Ticket Content Info Records Information:");
builder.AppendLine(" -------------------------");
if (tmd.ContentInfoRecords == null || tmd.ContentInfoRecords.Length == 0)
if (tmd.ContentInfoRecords.Length == 0)
{
builder.AppendLine(" No content info records, expected 64");
}
@@ -261,7 +240,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(" Ticket Content Chunk Records Information:");
builder.AppendLine(" -------------------------");
if (tmd.ContentChunkRecords == null || tmd.ContentChunkRecords.Length == 0)
if (tmd.ContentChunkRecords.Length == 0)
{
builder.AppendLine($" No content chunk records, expected {tmd.ContentCount}");
}
@@ -284,7 +263,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(" Ticket Certificate Chain Information:");
builder.AppendLine(" -------------------------");
if (tmd.CertificateChain == null || tmd.CertificateChain.Length == 0)
if (tmd.CertificateChain.Length == 0)
{
builder.AppendLine(" No certificates, expected 2");
}
@@ -330,11 +309,11 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, NCCHHeader[]? partitions)
private static void Print(StringBuilder builder, NCCHHeader[] partitions)
{
builder.AppendLine(" NCCH Partition Header Information:");
builder.AppendLine(" -------------------------");
if (partitions == null || partitions.Length == 0)
if (partitions.Length == 0)
{
builder.AppendLine(" No NCCH partition headers");
builder.AppendLine();
@@ -371,22 +350,17 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(partitionHeader.ExtendedHeaderHash, " Extended header SHA-256 hash");
builder.AppendLine(partitionHeader.ExtendedHeaderSizeInBytes, " Extended header size in bytes");
builder.AppendLine(partitionHeader.Reserved2, " Reserved 2");
builder.AppendLine(" Flags:");
if (partitionHeader.Flags == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(partitionHeader.Flags.Reserved0, " Reserved 0");
builder.AppendLine(partitionHeader.Flags.Reserved1, " Reserved 1");
builder.AppendLine(partitionHeader.Flags.Reserved2, " Reserved 2");
builder.AppendLine($" Crypto method: {partitionHeader.Flags.CryptoMethod} (0x{partitionHeader.Flags.CryptoMethod:X})");
builder.AppendLine($" Content platform: {partitionHeader.Flags.ContentPlatform} (0x{partitionHeader.Flags.ContentPlatform:X})");
builder.AppendLine($" Content type: {partitionHeader.Flags.MediaPlatformIndex} (0x{partitionHeader.Flags.MediaPlatformIndex:X})");
builder.AppendLine(partitionHeader.Flags.ContentUnitSize, " Content unit size");
builder.AppendLine($" Bitmasks: {partitionHeader.Flags.BitMasks} (0x{partitionHeader.Flags.BitMasks:X})");
}
builder.AppendLine(partitionHeader.Flags.Reserved0, " Reserved 0");
builder.AppendLine(partitionHeader.Flags.Reserved1, " Reserved 1");
builder.AppendLine(partitionHeader.Flags.Reserved2, " Reserved 2");
builder.AppendLine($" Crypto method: {partitionHeader.Flags.CryptoMethod} (0x{partitionHeader.Flags.CryptoMethod:X})");
builder.AppendLine($" Content platform: {partitionHeader.Flags.ContentPlatform} (0x{partitionHeader.Flags.ContentPlatform:X})");
builder.AppendLine($" Content type: {partitionHeader.Flags.MediaPlatformIndex} (0x{partitionHeader.Flags.MediaPlatformIndex:X})");
builder.AppendLine(partitionHeader.Flags.ContentUnitSize, " Content unit size");
builder.AppendLine($" Bitmasks: {partitionHeader.Flags.BitMasks} (0x{partitionHeader.Flags.BitMasks:X})");
builder.AppendLine(partitionHeader.PlainRegionOffsetInMediaUnits, " Plain region offset, in media units");
builder.AppendLine(partitionHeader.PlainRegionSizeInMediaUnits, " Plain region size, in media units");
builder.AppendLine(partitionHeader.LogoRegionOffsetInMediaUnits, " Logo region offset, in media units");
@@ -406,17 +380,10 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, MetaData? metaData)
private static void Print(StringBuilder builder, MetaData metaData)
{
builder.AppendLine(" Meta Data Information:");
builder.AppendLine(" -------------------------");
if (metaData == null)
{
builder.AppendLine(" No meta file data");
builder.AppendLine();
return;
}
builder.AppendLine(metaData.TitleIDDependencyList, " Title ID dependency list");
builder.AppendLine(metaData.Reserved1, " Reserved 1");
builder.AppendLine(metaData.CoreVersion, " Core version");

View File

@@ -28,17 +28,10 @@ namespace SabreTools.Serialization.Wrappers
Print(builder, Model.RomFSHeaders);
}
private static void Print(StringBuilder builder, NCSDHeader? header)
private static void Print(StringBuilder builder, NCSDHeader header)
{
builder.AppendLine(" NCSD Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No NCSD header");
builder.AppendLine();
return;
}
builder.AppendLine(header.RSA2048Signature, " RSA-2048 SHA-256 signature");
builder.AppendLine(header.MagicNumber, " Magic number");
builder.AppendLine(header.ImageSizeInMediaUnits, " Image size in media units");
@@ -49,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(" Partition table:");
builder.AppendLine(" -------------------------");
if (header.PartitionsTable == null || header.PartitionsTable.Length == 0)
if (header.PartitionsTable.Length == 0)
{
builder.AppendLine(" No partition table entries");
}
@@ -108,17 +101,10 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, CardInfoHeader? header)
private static void Print(StringBuilder builder, CardInfoHeader header)
{
builder.AppendLine(" Card Info Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No card info header");
builder.AppendLine();
return;
}
builder.AppendLine(header.WritableAddressMediaUnits, " Writable address in media units");
builder.AppendLine(header.CardInfoBitmask, " Card info bitmask");
builder.AppendLine(header.Reserved1, " Reserved 1");
@@ -135,17 +121,10 @@ namespace SabreTools.Serialization.Wrappers
Print(builder, header.InitialData);
}
private static void Print(StringBuilder builder, DevelopmentCardInfoHeader? header)
private static void Print(StringBuilder builder, DevelopmentCardInfoHeader header)
{
builder.AppendLine(" Development Card Info Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No development card info header");
builder.AppendLine();
return;
}
builder.AppendLine(header.CardDeviceReserved1, " Card device reserved 1");
builder.AppendLine(header.TitleKey, " Title key");
builder.AppendLine(header.CardDeviceReserved2, " Card device reserved 2");
@@ -153,38 +132,24 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(" Test Data:");
builder.AppendLine(" -------------------------");
if (header.TestData == null)
{
builder.AppendLine(" No test data");
}
else
{
builder.AppendLine(header.TestData.Signature, " Signature");
builder.AppendLine(header.TestData.AscendingByteSequence, " Ascending byte sequence");
builder.AppendLine(header.TestData.DescendingByteSequence, " Descending byte sequence");
builder.AppendLine(header.TestData.Filled00, " Filled with 00");
builder.AppendLine(header.TestData.FilledFF, " Filled with FF");
builder.AppendLine(header.TestData.Filled0F, " Filled with 0F");
builder.AppendLine(header.TestData.FilledF0, " Filled with F0");
builder.AppendLine(header.TestData.Filled55, " Filled with 55");
builder.AppendLine(header.TestData.FilledAA, " Filled with AA");
builder.AppendLine(header.TestData.FinalByte, " Final byte");
}
builder.AppendLine(header.TestData.Signature, " Signature");
builder.AppendLine(header.TestData.AscendingByteSequence, " Ascending byte sequence");
builder.AppendLine(header.TestData.DescendingByteSequence, " Descending byte sequence");
builder.AppendLine(header.TestData.Filled00, " Filled with 00");
builder.AppendLine(header.TestData.FilledFF, " Filled with FF");
builder.AppendLine(header.TestData.Filled0F, " Filled with 0F");
builder.AppendLine(header.TestData.FilledF0, " Filled with F0");
builder.AppendLine(header.TestData.Filled55, " Filled with 55");
builder.AppendLine(header.TestData.FilledAA, " Filled with AA");
builder.AppendLine(header.TestData.FinalByte, " Final byte");
builder.AppendLine();
}
private static void Print(StringBuilder builder, InitialData? id)
private static void Print(StringBuilder builder, InitialData id)
{
builder.AppendLine(" Initial Data Information:");
builder.AppendLine(" -------------------------");
if (id == null)
{
builder.AppendLine(" No initial data");
builder.AppendLine();
return;
}
builder.AppendLine(id.CardSeedKeyY, " Card seed KeyY");
builder.AppendLine(id.EncryptedCardSeed, " Encrypted card seed");
builder.AppendLine(id.CardSeedAESMAC, " Card seed AES-MAC");
@@ -195,17 +160,10 @@ namespace SabreTools.Serialization.Wrappers
PrintBackup(builder, id.BackupHeader);
}
private static void PrintBackup(StringBuilder builder, NCCHHeader? header)
private static void PrintBackup(StringBuilder builder, NCCHHeader header)
{
builder.AppendLine(" Backup NCCH Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No backup NCCH header");
builder.AppendLine();
return;
}
if (header.MagicID == string.Empty)
{
builder.AppendLine(" Empty backup header, no data can be parsed");
@@ -233,22 +191,17 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(header.ExtendedHeaderHash, " Extended header SHA-256 hash");
builder.AppendLine(header.ExtendedHeaderSizeInBytes, " Extended header size in bytes");
builder.AppendLine(header.Reserved2, " Reserved 2");
builder.AppendLine(" Flags:");
if (header.Flags == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(header.Flags.Reserved0, " Reserved 0");
builder.AppendLine(header.Flags.Reserved1, " Reserved 1");
builder.AppendLine(header.Flags.Reserved2, " Reserved 2");
builder.AppendLine($" Crypto method: {header.Flags.CryptoMethod} (0x{header.Flags.CryptoMethod:X})");
builder.AppendLine($" Content platform: {header.Flags.ContentPlatform} (0x{header.Flags.ContentPlatform:X})");
builder.AppendLine($" Content type: {header.Flags.MediaPlatformIndex} (0x{header.Flags.MediaPlatformIndex:X})");
builder.AppendLine(header.Flags.ContentUnitSize, " Content unit size");
builder.AppendLine($" Bitmasks: {header.Flags.BitMasks} (0x{header.Flags.BitMasks:X})");
}
builder.AppendLine(header.Flags.Reserved0, " Reserved 0");
builder.AppendLine(header.Flags.Reserved1, " Reserved 1");
builder.AppendLine(header.Flags.Reserved2, " Reserved 2");
builder.AppendLine($" Crypto method: {header.Flags.CryptoMethod} (0x{header.Flags.CryptoMethod:X})");
builder.AppendLine($" Content platform: {header.Flags.ContentPlatform} (0x{header.Flags.ContentPlatform:X})");
builder.AppendLine($" Content type: {header.Flags.MediaPlatformIndex} (0x{header.Flags.MediaPlatformIndex:X})");
builder.AppendLine(header.Flags.ContentUnitSize, " Content unit size");
builder.AppendLine($" Bitmasks: {header.Flags.BitMasks} (0x{header.Flags.BitMasks:X})");
builder.AppendLine(header.PlainRegionOffsetInMediaUnits, " Plain region offset, in media units");
builder.AppendLine(header.PlainRegionSizeInMediaUnits, " Plain region size, in media units");
builder.AppendLine(header.LogoRegionOffsetInMediaUnits, " Logo region offset, in media units");
@@ -266,11 +219,11 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, NCCHHeader[]? entries)
private static void Print(StringBuilder builder, NCCHHeader[] entries)
{
builder.AppendLine(" NCCH Partition Header Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
if (entries.Length == 0)
{
builder.AppendLine(" No NCCH partition headers");
builder.AppendLine();
@@ -344,11 +297,11 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, NCCHExtendedHeader[]? entries)
private static void Print(StringBuilder builder, NCCHExtendedHeader[] entries)
{
builder.AppendLine(" NCCH Extended Header Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
if (entries.Length == 0)
{
builder.AppendLine(" No NCCH extended headers");
builder.AppendLine();
@@ -360,226 +313,115 @@ namespace SabreTools.Serialization.Wrappers
var entry = entries[i];
builder.AppendLine($" NCCH Extended Header {i}");
builder.AppendLine(" System control info:");
if (entry.SCI == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.SCI.ApplicationTitle, " Application title");
builder.AppendLine(entry.SCI.Reserved1, " Reserved 1");
builder.AppendLine(entry.SCI.Flag, " Flag");
builder.AppendLine(entry.SCI.RemasterVersion, " Remaster version");
builder.AppendLine(entry.SCI.ApplicationTitle, " Application title");
builder.AppendLine(entry.SCI.Reserved1, " Reserved 1");
builder.AppendLine(entry.SCI.Flag, " Flag");
builder.AppendLine(entry.SCI.RemasterVersion, " Remaster version");
builder.AppendLine(" Text code set info:");
if (entry.SCI.TextCodeSetInfo == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.SCI.TextCodeSetInfo.Address, " Address");
builder.AppendLine(entry.SCI.TextCodeSetInfo.PhysicalRegionSizeInPages, " Physical region size (in page-multiples)");
builder.AppendLine(entry.SCI.TextCodeSetInfo.SizeInBytes, " Size (in bytes)");
}
builder.AppendLine(" Text code set info:");
builder.AppendLine(entry.SCI.TextCodeSetInfo.Address, " Address");
builder.AppendLine(entry.SCI.TextCodeSetInfo.PhysicalRegionSizeInPages, " Physical region size (in page-multiples)");
builder.AppendLine(entry.SCI.TextCodeSetInfo.SizeInBytes, " Size (in bytes)");
builder.AppendLine(entry.SCI.StackSize, " Stack size");
builder.AppendLine(entry.SCI.StackSize, " Stack size");
builder.AppendLine(" Read-only code set info:");
if (entry.SCI.ReadOnlyCodeSetInfo == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.SCI.ReadOnlyCodeSetInfo.Address, " Address");
builder.AppendLine(entry.SCI.ReadOnlyCodeSetInfo.PhysicalRegionSizeInPages, " Physical region size (in page-multiples)");
builder.AppendLine(entry.SCI.ReadOnlyCodeSetInfo.SizeInBytes, " Size (in bytes)");
}
builder.AppendLine(" Read-only code set info:");
builder.AppendLine(entry.SCI.ReadOnlyCodeSetInfo.Address, " Address");
builder.AppendLine(entry.SCI.ReadOnlyCodeSetInfo.PhysicalRegionSizeInPages, " Physical region size (in page-multiples)");
builder.AppendLine(entry.SCI.ReadOnlyCodeSetInfo.SizeInBytes, " Size (in bytes)");
builder.AppendLine(entry.SCI.Reserved2, " Reserved 2");
builder.AppendLine(entry.SCI.Reserved2, " Reserved 2");
builder.AppendLine(" Data code set info:");
if (entry.SCI.DataCodeSetInfo == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.SCI.DataCodeSetInfo.Address, " Address");
builder.AppendLine(entry.SCI.DataCodeSetInfo.PhysicalRegionSizeInPages, " Physical region size (in page-multiples)");
builder.AppendLine(entry.SCI.DataCodeSetInfo.SizeInBytes, " Size (in bytes)");
}
builder.AppendLine(" Data code set info:");
builder.AppendLine(entry.SCI.DataCodeSetInfo.Address, " Address");
builder.AppendLine(entry.SCI.DataCodeSetInfo.PhysicalRegionSizeInPages, " Physical region size (in page-multiples)");
builder.AppendLine(entry.SCI.DataCodeSetInfo.SizeInBytes, " Size (in bytes)");
builder.AppendLine(entry.SCI.BSSSize, " BSS size");
builder.AppendLine(entry.SCI.DependencyModuleList, " Dependency module list");
builder.AppendLine(entry.SCI.BSSSize, " BSS size");
builder.AppendLine(entry.SCI.DependencyModuleList, " Dependency module list");
builder.AppendLine(" System info:");
if (entry.SCI.SystemInfo == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.SCI.SystemInfo.SaveDataSize, " SaveData size");
builder.AppendLine(entry.SCI.SystemInfo.JumpID, " Jump ID");
builder.AppendLine(entry.SCI.SystemInfo.Reserved, " Reserved");
}
}
builder.AppendLine(" System info:");
builder.AppendLine(entry.SCI.SystemInfo.SaveDataSize, " SaveData size");
builder.AppendLine(entry.SCI.SystemInfo.JumpID, " Jump ID");
builder.AppendLine(entry.SCI.SystemInfo.Reserved, " Reserved");
builder.AppendLine(" Access control info:");
if (entry.ACI == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(" ARM11 local system capabilities:");
if (entry.ACI.ARM11LocalSystemCapabilities == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ProgramID, " Program ID");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.CoreVersion, " Core version");
builder.AppendLine($" Flag 1: {entry.ACI.ARM11LocalSystemCapabilities.Flag1} (0x{entry.ACI.ARM11LocalSystemCapabilities.Flag1:X})");
builder.AppendLine($" Flag 2: {entry.ACI.ARM11LocalSystemCapabilities.Flag2} (0x{entry.ACI.ARM11LocalSystemCapabilities.Flag2:X})");
builder.AppendLine($" Flag 0: {entry.ACI.ARM11LocalSystemCapabilities.Flag0} (0x{entry.ACI.ARM11LocalSystemCapabilities.Flag0:X})");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.Priority, " Priority");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ResourceLimitDescriptors, " Resource limit descriptors");
builder.AppendLine(" Storage info:");
if (entry.ACI.ARM11LocalSystemCapabilities.StorageInfo == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.ExtdataID, " Extdata ID");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.SystemSavedataIDs, " System savedata IDs");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.StorageAccessibleUniqueIDs, " Storage accessible unique IDs");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.FileSystemAccessInfo, " File system access info");
builder.AppendLine($" Other attributes: {entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes} (0x{entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes:X})");
}
builder.AppendLine(" ARM11 local system capabilities:");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ProgramID, " Program ID");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.CoreVersion, " Core version");
builder.AppendLine($" Flag 1: {entry.ACI.ARM11LocalSystemCapabilities.Flag1} (0x{entry.ACI.ARM11LocalSystemCapabilities.Flag1:X})");
builder.AppendLine($" Flag 2: {entry.ACI.ARM11LocalSystemCapabilities.Flag2} (0x{entry.ACI.ARM11LocalSystemCapabilities.Flag2:X})");
builder.AppendLine($" Flag 0: {entry.ACI.ARM11LocalSystemCapabilities.Flag0} (0x{entry.ACI.ARM11LocalSystemCapabilities.Flag0:X})");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.Priority, " Priority");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ResourceLimitDescriptors, " Resource limit descriptors");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ServiceAccessControl, " Service access control");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ExtendedServiceAccessControl, " Extended service access control");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.Reserved, " Reserved");
builder.AppendLine($" Resource limit cateogry: {entry.ACI.ARM11LocalSystemCapabilities.ResourceLimitCategory} (0x{entry.ACI.ARM11LocalSystemCapabilities.ResourceLimitCategory:X})");
}
builder.AppendLine(" Storage info:");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.ExtdataID, " Extdata ID");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.SystemSavedataIDs, " System savedata IDs");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.StorageAccessibleUniqueIDs, " Storage accessible unique IDs");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.FileSystemAccessInfo, " File system access info");
builder.AppendLine($" Other attributes: {entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes} (0x{entry.ACI.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes:X})");
builder.AppendLine(" ARM11 kernel capabilities:");
if (entry.ACI.ARM11KernelCapabilities == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.ACI.ARM11KernelCapabilities.Descriptors, " Descriptors");
builder.AppendLine(entry.ACI.ARM11KernelCapabilities.Reserved, " Reserved");
}
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ServiceAccessControl, " Service access control");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.ExtendedServiceAccessControl, " Extended service access control");
builder.AppendLine(entry.ACI.ARM11LocalSystemCapabilities.Reserved, " Reserved");
builder.AppendLine($" Resource limit cateogry: {entry.ACI.ARM11LocalSystemCapabilities.ResourceLimitCategory} (0x{entry.ACI.ARM11LocalSystemCapabilities.ResourceLimitCategory:X})");
builder.AppendLine(" ARM9 access control:");
if (entry.ACI.ARM9AccessControl == null)
{
builder.AppendLine(" [NULL]");
}
else
{
string descriptorsStr = "[NULL]";
if (entry.ACI.ARM9AccessControl.Descriptors != null)
{
var descriptors = Array.ConvertAll(entry.ACI.ARM9AccessControl.Descriptors, d => d.ToString());
descriptorsStr = string.Join(", ", descriptors);
}
builder.AppendLine(descriptorsStr, " Descriptors");
builder.AppendLine(entry.ACI.ARM9AccessControl.DescriptorVersion, " Descriptor version");
}
}
builder.AppendLine(" ARM11 kernel capabilities:");
builder.AppendLine(entry.ACI.ARM11KernelCapabilities.Descriptors, " Descriptors");
builder.AppendLine(entry.ACI.ARM11KernelCapabilities.Reserved, " Reserved");
builder.AppendLine(" ARM9 access control:");
var descriptors = Array.ConvertAll(entry.ACI.ARM9AccessControl.Descriptors, d => d.ToString());
string descriptorsStr = string.Join(", ", descriptors);
builder.AppendLine(descriptorsStr, " Descriptors");
builder.AppendLine(entry.ACI.ARM9AccessControl.DescriptorVersion, " Descriptor version");
builder.AppendLine(entry.AccessDescSignature, " AccessDec signature (RSA-2048-SHA256)");
builder.AppendLine(entry.NCCHHDRPublicKey, " NCCH HDR RSA-2048 public key");
builder.AppendLine(" Access control info (for limitations of first ACI):");
if (entry.ACIForLimitations == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(" ARM11 local system capabilities:");
if (entry.ACIForLimitations.ARM11LocalSystemCapabilities == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ProgramID, " Program ID");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.CoreVersion, " Core version");
builder.AppendLine($" Flag 1: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag1} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag1:X})");
builder.AppendLine($" Flag 2: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag2} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag2:X})");
builder.AppendLine($" Flag 0: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag0} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag0:X})");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.Priority, " Priority");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ResourceLimitDescriptors, " Resource limit descriptors");
builder.AppendLine(" ARM11 local system capabilities:");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ProgramID, " Program ID");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.CoreVersion, " Core version");
builder.AppendLine($" Flag 1: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag1} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag1:X})");
builder.AppendLine($" Flag 2: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag2} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag2:X})");
builder.AppendLine($" Flag 0: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag0} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.Flag0:X})");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.Priority, " Priority");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ResourceLimitDescriptors, " Resource limit descriptors");
builder.AppendLine(" Storage info:");
if (entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.ExtdataID, " Extdata ID");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.SystemSavedataIDs, " System savedata IDs");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.StorageAccessibleUniqueIDs, " Storage accessible unique IDs");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.FileSystemAccessInfo, " File system access info");
builder.AppendLine($" Other attributes: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes:X})");
}
builder.AppendLine(" Storage info:");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.ExtdataID, " Extdata ID");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.SystemSavedataIDs, " System savedata IDs");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.StorageAccessibleUniqueIDs, " Storage accessible unique IDs");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.FileSystemAccessInfo, " File system access info");
builder.AppendLine($" Other attributes: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.StorageInfo.OtherAttributes:X})");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ServiceAccessControl, " Service access control");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ExtendedServiceAccessControl, " Extended service access control");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.Reserved, " Reserved");
builder.AppendLine($" Resource limit cateogry: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.ResourceLimitCategory} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.ResourceLimitCategory:X})");
}
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ServiceAccessControl, " Service access control");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.ExtendedServiceAccessControl, " Extended service access control");
builder.AppendLine(entry.ACIForLimitations.ARM11LocalSystemCapabilities.Reserved, " Reserved");
builder.AppendLine($" Resource limit cateogry: {entry.ACIForLimitations.ARM11LocalSystemCapabilities.ResourceLimitCategory} (0x{entry.ACIForLimitations.ARM11LocalSystemCapabilities.ResourceLimitCategory:X})");
builder.AppendLine(" ARM11 kernel capabilities:");
if (entry.ACIForLimitations.ARM11KernelCapabilities == null)
{
builder.AppendLine(" [NULL]");
}
else
{
builder.AppendLine(entry.ACIForLimitations.ARM11KernelCapabilities.Descriptors, " Descriptors");
builder.AppendLine(entry.ACIForLimitations.ARM11KernelCapabilities.Reserved, " Reserved");
}
builder.AppendLine(" ARM11 kernel capabilities:");
builder.AppendLine(entry.ACIForLimitations.ARM11KernelCapabilities.Descriptors, " Descriptors");
builder.AppendLine(entry.ACIForLimitations.ARM11KernelCapabilities.Reserved, " Reserved");
builder.AppendLine(" ARM9 access control:");
if (entry.ACIForLimitations.ARM9AccessControl == null)
{
builder.AppendLine(" [NULL]");
}
else
{
string descriptorsStr = "[NULL]";
if (entry.ACIForLimitations.ARM9AccessControl.Descriptors != null)
{
var descriptors = Array.ConvertAll(entry.ACIForLimitations.ARM9AccessControl.Descriptors, d => d.ToString());
descriptorsStr = string.Join(", ", descriptors);
}
builder.AppendLine(descriptorsStr, " Descriptors");
builder.AppendLine(entry.ACIForLimitations.ARM9AccessControl.DescriptorVersion, " Descriptor version");
}
}
builder.AppendLine(" ARM9 access control:");
descriptors = Array.ConvertAll(entry.ACIForLimitations.ARM9AccessControl.Descriptors, d => d.ToString());
descriptorsStr = string.Join(", ", descriptors);
builder.AppendLine(descriptorsStr, " Descriptors");
builder.AppendLine(entry.ACIForLimitations.ARM9AccessControl.DescriptorVersion, " Descriptor version");
}
builder.AppendLine();
}
private static void Print(StringBuilder builder, ExeFSHeader[]? entries)
private static void Print(StringBuilder builder, ExeFSHeader[] entries)
{
builder.AppendLine(" ExeFS Header Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
if (entries.Length == 0)
{
builder.AppendLine(" No ExeFS headers");
builder.AppendLine();
@@ -595,7 +437,7 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine(entry.Reserved, " Reserved");
builder.AppendLine(" File hashes:");
if (entry.FileHashes == null || entry.FileHashes.Length == 0)
if (entry.FileHashes.Length == 0)
{
builder.AppendLine(" No file hashes");
}
@@ -614,10 +456,10 @@ namespace SabreTools.Serialization.Wrappers
builder.AppendLine();
}
private static void Print(StringBuilder builder, ExeFSFileHeader[]? entries)
private static void Print(StringBuilder builder, ExeFSFileHeader[] entries)
{
builder.AppendLine(" File headers:");
if (entries == null || entries.Length == 0)
if (entries.Length == 0)
{
builder.AppendLine(" No file headers");
return;
@@ -634,11 +476,11 @@ namespace SabreTools.Serialization.Wrappers
}
}
private static void Print(StringBuilder builder, RomFSHeader[]? entries)
private static void Print(StringBuilder builder, RomFSHeader[] entries)
{
builder.AppendLine(" RomFS Header Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
if (entries.Length == 0)
{
builder.AppendLine(" No RomFS headers");
builder.AppendLine();

View File

@@ -19,12 +19,12 @@ namespace SabreTools.Serialization.Wrappers
/// <summary>
/// Backup header
/// </summary>
public NCCHHeader? BackupHeader => Model.CardInfoHeader?.InitialData?.BackupHeader;
public NCCHHeader BackupHeader => Model.CardInfoHeader.InitialData.BackupHeader;
/// <summary>
/// ExeFS headers
/// </summary>
public ExeFSHeader[] ExeFSHeaders => Model.ExeFSHeaders ?? [];
public ExeFSHeader[] ExeFSHeaders => Model.ExeFSHeaders;
/// <summary>
/// Media unit size in bytes
@@ -33,9 +33,6 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (Model.Header?.PartitionFlags == null)
return default;
return (uint)(0x200 * Math.Pow(2, Model.Header.PartitionFlags[(int)NCSDFlags.MediaUnitSize]));
}
}
@@ -43,12 +40,12 @@ namespace SabreTools.Serialization.Wrappers
/// <summary>
/// Partitions data table
/// </summary>
public NCCHHeader[] Partitions => Model.Partitions ?? [];
public NCCHHeader[] Partitions => Model.Partitions;
/// <summary>
/// Partitions header table
/// </summary>
public PartitionTableEntry[] PartitionsTable => Model.Header?.PartitionsTable ?? [];
public PartitionTableEntry[] PartitionsTable => Model.Header.PartitionsTable;
#region Named Partition Entries
@@ -59,7 +56,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionsTable == null || PartitionsTable.Length == 0)
if (PartitionsTable.Length == 0)
return null;
return PartitionsTable[0];
@@ -73,7 +70,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionsTable == null || PartitionsTable.Length == 0)
if (PartitionsTable.Length == 0)
return null;
return PartitionsTable[1];
@@ -87,7 +84,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionsTable == null || PartitionsTable.Length == 0)
if (PartitionsTable.Length == 0)
return null;
return PartitionsTable[2];
@@ -101,7 +98,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionsTable == null || PartitionsTable.Length == 0)
if (PartitionsTable.Length == 0)
return null;
return PartitionsTable[6];
@@ -115,7 +112,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionsTable == null || PartitionsTable.Length == 0)
if (PartitionsTable.Length == 0)
return null;
return PartitionsTable[7];
@@ -127,7 +124,7 @@ namespace SabreTools.Serialization.Wrappers
/// <summary>
/// Partitions flags
/// </summary>
public byte[] PartitionFlags => Model.Header?.PartitionFlags ?? [];
public byte[] PartitionFlags => Model.Header.PartitionFlags;
#region Partition Flags
@@ -139,7 +136,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionFlags == null || PartitionFlags.Length == 0)
if (PartitionFlags.Length == 0)
return default;
return PartitionFlags[(int)NCSDFlags.BackupWriteWaitTime];
@@ -153,7 +150,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionFlags == null || PartitionFlags.Length == 0)
if (PartitionFlags.Length == 0)
return default;
return (MediaCardDeviceType)PartitionFlags[(int)NCSDFlags.MediaCardDevice2X];
@@ -167,7 +164,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionFlags == null || PartitionFlags.Length == 0)
if (PartitionFlags.Length == 0)
return default;
return (MediaCardDeviceType)PartitionFlags[(int)NCSDFlags.MediaCardDevice3X];
@@ -181,7 +178,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionFlags == null || PartitionFlags.Length == 0)
if (PartitionFlags.Length == 0)
return default;
return (MediaPlatformIndex)PartitionFlags[(int)NCSDFlags.MediaPlatformIndex];
@@ -195,7 +192,7 @@ namespace SabreTools.Serialization.Wrappers
{
get
{
if (PartitionFlags == null || PartitionFlags.Length == 0)
if (PartitionFlags.Length == 0)
return default;
return (MediaTypeIndex)PartitionFlags[(int)NCSDFlags.MediaTypeIndex];