mirror of
https://github.com/SabreTools/SabreTools.Models.git
synced 2026-09-24 15:47:27 +00:00
168 lines
4.5 KiB
C#
168 lines
4.5 KiB
C#
namespace SabreTools.Models.N3DS
|
|
{
|
|
/// <summary>
|
|
/// There are two known specialisations of the NCSD container format:
|
|
/// - The CTR Cart Image (CCI) format, the 3DS' raw NAND format
|
|
/// - CCI is the format of game ROM images.
|
|
///
|
|
/// CTR System Update (CSU) is a variant of CCI, where the only difference
|
|
/// is in the file extension.
|
|
/// </summary>
|
|
/// <see href="https://www.3dbrew.org/wiki/NCSD"/>
|
|
public sealed class NCSDHeader
|
|
{
|
|
#region Common to all NCSD files
|
|
|
|
/// <summary>
|
|
/// RSA-2048 SHA-256 signature of the NCSD header
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] RSA2048Signature { get; set; }
|
|
#else
|
|
public byte[]? RSA2048Signature { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Magic Number 'NCSD'
|
|
/// </summary>
|
|
#if NET48
|
|
public string MagicNumber { get; set; }
|
|
#else
|
|
public string? MagicNumber { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Size of the NCSD image, in media units (1 media unit = 0x200 bytes)
|
|
/// </summary>
|
|
public uint ImageSizeInMediaUnits { get; set; }
|
|
|
|
/// <summary>
|
|
/// Media ID
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] MediaId { get; set; }
|
|
#else
|
|
public byte[]? MediaId { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Partitions FS type (0=None, 1=Normal, 3=FIRM, 4=AGB_FIRM save)
|
|
/// </summary>
|
|
public FilesystemType PartitionsFSType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Partitions crypt type (each byte corresponds to a partition in the partition table)
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] PartitionsCryptType { get; set; }
|
|
#else
|
|
public byte[]? PartitionsCryptType { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Offset & Length partition table, in media units
|
|
/// </summary>
|
|
#if NET48
|
|
public PartitionTableEntry[] PartitionsTable { get; set; }
|
|
#else
|
|
public PartitionTableEntry?[]? PartitionsTable { get; set; }
|
|
#endif
|
|
|
|
#endregion
|
|
|
|
#region CTR Cart Image (CCI) Specific
|
|
|
|
/// <summary>
|
|
/// Exheader SHA-256 hash
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] ExheaderHash { get; set; }
|
|
#else
|
|
public byte[]? ExheaderHash { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Additional header size
|
|
/// </summary>
|
|
public uint AdditionalHeaderSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// Sector zero offset
|
|
/// </summary>
|
|
public uint SectorZeroOffset { get; set; }
|
|
|
|
/// <summary>
|
|
/// Partition Flags
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] PartitionFlags { get; set; }
|
|
#else
|
|
public byte[]? PartitionFlags { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Partition ID table
|
|
/// </summary>
|
|
#if NET48
|
|
public ulong[] PartitionIdTable { get; set; }
|
|
#else
|
|
public ulong[]? PartitionIdTable { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Reserved
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] Reserved1 { get; set; }
|
|
#else
|
|
public byte[]? Reserved1 { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Reserved?
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] Reserved2 { get; set; }
|
|
#else
|
|
public byte[]? Reserved2 { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Support for this was implemented with 9.6.0-X FIRM. Bit0=1 enables using bits 1-2, it's unknown
|
|
/// what these two bits are actually used for(the value of these two bits get compared with some other
|
|
/// value during NCSD verification/loading). This appears to enable a new, likely hardware-based,
|
|
/// antipiracy check on cartridges.
|
|
/// </summary>
|
|
public byte FirmUpdateByte1 { get; set; }
|
|
|
|
/// <summary>
|
|
/// Support for this was implemented with 9.6.0-X FIRM, see below regarding save crypto.
|
|
/// </summary>
|
|
public byte FirmUpdateByte2 { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Raw NAND Format Specific
|
|
|
|
/// <summary>
|
|
/// Unknown
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] Unknown { get; set; }
|
|
#else
|
|
public byte[]? Unknown { get; set; }
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Encrypted MBR partition-table, for the TWL partitions(key-data used for this keyslot is console-unique).
|
|
/// </summary>
|
|
#if NET48
|
|
public byte[] EncryptedMBR { get; set; }
|
|
#else
|
|
public byte[]? EncryptedMBR { get; set; }
|
|
#endif
|
|
|
|
#endregion
|
|
}
|
|
}
|