diff --git a/BurnOutSharp.Builders/Nitro.cs b/BurnOutSharp.Builders/Nitro.cs
index f397b066..030f7934 100644
--- a/BurnOutSharp.Builders/Nitro.cs
+++ b/BurnOutSharp.Builders/Nitro.cs
@@ -58,12 +58,26 @@ namespace BurnOutSharp.Builders
#region Header
// Try to parse the header
- var header = ParseHeader(data);
+ var header = ParseCommonHeader(data);
if (header == null)
return null;
// Set the cart image header
- cart.Header = header;
+ cart.CommonHeader = header;
+
+ #endregion
+
+ #region Extended DSi Header
+
+ // If we have a DSi-compatible cartridge
+ if (header.UnitCode == Unitcode.NDSPlusDSi || header.UnitCode == Unitcode.DSi)
+ {
+ var extendedDSiHeader = ParseExtendedDSiHeader(data);
+ if (extendedDSiHeader == null)
+ return null;
+
+ cart.ExtendedDSiHeader = extendedDSiHeader;
+ }
#endregion
@@ -89,125 +103,134 @@ namespace BurnOutSharp.Builders
}
///
- /// Parse a Stream into a header
+ /// Parse a Stream into a common header
///
/// Stream to parse
- /// Filled header on success, null on error
- private static Header ParseHeader(Stream data)
+ /// Filled common header on success, null on error
+ private static CommonHeader ParseCommonHeader(Stream data)
{
// TODO: Use marshalling here instead of building
- Header header = new Header();
+ CommonHeader commonHeader = new CommonHeader();
byte[] gameTitle = data.ReadBytes(0x0C);
- header.GameTitle = Encoding.ASCII.GetString(gameTitle);
- header.GameCode = data.ReadUInt32();
+ commonHeader.GameTitle = Encoding.ASCII.GetString(gameTitle);
+ commonHeader.GameCode = data.ReadUInt32();
byte[] makerCode = data.ReadBytes(2);
- header.MakerCode = Encoding.ASCII.GetString(bytes: makerCode);
- header.UnitCode = (Unitcode)data.ReadByteValue();
- header.EncryptionSeedSelect = data.ReadByteValue();
- header.DeviceCapacity = data.ReadByteValue();
- header.Reserved1 = data.ReadBytes(7);
- header.GameRevision = data.ReadUInt16();
- header.RomVersion = data.ReadByteValue();
- header.InternalFlags = data.ReadByteValue();
- header.ARM9RomOffset = data.ReadUInt32();
- header.ARM9EntryAddress = data.ReadUInt32();
- header.ARM9LoadAddress = data.ReadUInt32();
- header.ARM9Size = data.ReadUInt32();
- header.ARM7RomOffset = data.ReadUInt32();
- header.ARM7EntryAddress = data.ReadUInt32();
- header.ARM7LoadAddress = data.ReadUInt32();
- header.ARM7Size = data.ReadUInt32();
- header.FileNameTableOffset = data.ReadUInt32();
- header.FileNameTableLength = data.ReadUInt32();
- header.FileAllocationTableOffset = data.ReadUInt32();
- header.FileAllocationTableLength = data.ReadUInt32();
- header.ARM9OverlayOffset = data.ReadUInt32();
- header.ARM9OverlayLength = data.ReadUInt32();
- header.ARM7OverlayOffset = data.ReadUInt32();
- header.ARM7OverlayLength = data.ReadUInt32();
- header.NormalCardControlRegisterSettings = data.ReadUInt32();
- header.SecureCardControlRegisterSettings = data.ReadUInt32();
- header.IconBannerOffset = data.ReadUInt32();
- header.SecureAreaCRC = data.ReadUInt16();
- header.SecureTransferTimeout = data.ReadUInt16();
- header.ARM9Autoload = data.ReadUInt32();
- header.ARM7Autoload = data.ReadUInt32();
- header.SecureDisable = data.ReadBytes(8);
- header.NTRRegionRomSize = data.ReadUInt32();
- header.HeaderSize = data.ReadUInt32();
- header.Reserved2 = data.ReadBytes(56);
- header.NintendoLogo = data.ReadBytes(156);
- header.NintendoLogoCRC = data.ReadUInt16();
- header.HeaderCRC = data.ReadUInt16();
- header.DebuggerReserved = data.ReadBytes(0x20);
+ commonHeader.MakerCode = Encoding.ASCII.GetString(bytes: makerCode);
+ commonHeader.UnitCode = (Unitcode)data.ReadByteValue();
+ commonHeader.EncryptionSeedSelect = data.ReadByteValue();
+ commonHeader.DeviceCapacity = data.ReadByteValue();
+ commonHeader.Reserved1 = data.ReadBytes(7);
+ commonHeader.GameRevision = data.ReadUInt16();
+ commonHeader.RomVersion = data.ReadByteValue();
+ commonHeader.InternalFlags = data.ReadByteValue();
+ commonHeader.ARM9RomOffset = data.ReadUInt32();
+ commonHeader.ARM9EntryAddress = data.ReadUInt32();
+ commonHeader.ARM9LoadAddress = data.ReadUInt32();
+ commonHeader.ARM9Size = data.ReadUInt32();
+ commonHeader.ARM7RomOffset = data.ReadUInt32();
+ commonHeader.ARM7EntryAddress = data.ReadUInt32();
+ commonHeader.ARM7LoadAddress = data.ReadUInt32();
+ commonHeader.ARM7Size = data.ReadUInt32();
+ commonHeader.FileNameTableOffset = data.ReadUInt32();
+ commonHeader.FileNameTableLength = data.ReadUInt32();
+ commonHeader.FileAllocationTableOffset = data.ReadUInt32();
+ commonHeader.FileAllocationTableLength = data.ReadUInt32();
+ commonHeader.ARM9OverlayOffset = data.ReadUInt32();
+ commonHeader.ARM9OverlayLength = data.ReadUInt32();
+ commonHeader.ARM7OverlayOffset = data.ReadUInt32();
+ commonHeader.ARM7OverlayLength = data.ReadUInt32();
+ commonHeader.NormalCardControlRegisterSettings = data.ReadUInt32();
+ commonHeader.SecureCardControlRegisterSettings = data.ReadUInt32();
+ commonHeader.IconBannerOffset = data.ReadUInt32();
+ commonHeader.SecureAreaCRC = data.ReadUInt16();
+ commonHeader.SecureTransferTimeout = data.ReadUInt16();
+ commonHeader.ARM9Autoload = data.ReadUInt32();
+ commonHeader.ARM7Autoload = data.ReadUInt32();
+ commonHeader.SecureDisable = data.ReadBytes(8);
+ commonHeader.NTRRegionRomSize = data.ReadUInt32();
+ commonHeader.HeaderSize = data.ReadUInt32();
+ commonHeader.Reserved2 = data.ReadBytes(56);
+ commonHeader.NintendoLogo = data.ReadBytes(156);
+ commonHeader.NintendoLogoCRC = data.ReadUInt16();
+ commonHeader.HeaderCRC = data.ReadUInt16();
+ commonHeader.DebuggerReserved = data.ReadBytes(0x20);
- // If we have a DSi compatible title
- if (header.UnitCode == Unitcode.NDSPlusDSi || header.UnitCode == Unitcode.DSi)
+ return commonHeader;
+ }
+
+ ///
+ /// Parse a Stream into an extended DSi header
+ ///
+ /// Stream to parse
+ /// Filled extended DSi header on success, null on error
+ private static ExtendedDSiHeader ParseExtendedDSiHeader(Stream data)
+ {
+ // TODO: Use marshalling here instead of building
+ ExtendedDSiHeader extendedDSiHeader = new ExtendedDSiHeader();
+
+ extendedDSiHeader.GlobalMBK15Settings = new uint[5];
+ for (int i = 0; i < 5; i++)
{
- header.GlobalMBK15Settings = new uint[5];
- for (int i = 0; i < 5; i++)
- {
- header.GlobalMBK15Settings[i] = data.ReadUInt32();
- }
- header.LocalMBK68SettingsARM9 = new uint[3];
- for (int i = 0; i < 3; i++)
- {
- header.LocalMBK68SettingsARM9[i] = data.ReadUInt32();
- }
- header.LocalMBK68SettingsARM7 = new uint[3];
- for (int i = 0; i < 3; i++)
- {
- header.LocalMBK68SettingsARM7[i] = data.ReadUInt32();
- }
- header.GlobalMBK9Setting = data.ReadUInt32();
- header.RegionFlags = data.ReadUInt32();
- header.AccessControl = data.ReadUInt32();
- header.ARM7SCFGEXTMask = data.ReadUInt32();
- header.ReservedFlags = data.ReadUInt32();
- header.ARM9iRomOffset = data.ReadUInt32();
- header.Reserved3 = data.ReadUInt32();
- header.ARM9iLoadAddress = data.ReadUInt32();
- header.ARM9iSize = data.ReadUInt32();
- header.ARM7iRomOffset = data.ReadUInt32();
- header.Reserved4 = data.ReadUInt32();
- header.ARM7iLoadAddress = data.ReadUInt32();
- header.ARM7iSize = data.ReadUInt32();
- header.DigestNTRRegionOffset = data.ReadUInt32();
- header.DigestNTRRegionLength = data.ReadUInt32();
- header.DigestTWLRegionOffset = data.ReadUInt32();
- header.DigestTWLRegionLength = data.ReadUInt32();
- header.DigestSectorHashtableRegionOffset = data.ReadUInt32();
- header.DigestSectorHashtableRegionLength = data.ReadUInt32();
- header.DigestBlockHashtableRegionOffset = data.ReadUInt32();
- header.DigestBlockHashtableRegionLength = data.ReadUInt32();
- header.DigestSectorSize = data.ReadUInt32();
- header.DigestBlockSectorCount = data.ReadUInt32();
- header.IconBannerSize = data.ReadUInt32();
- header.Unknown1 = data.ReadUInt32();
- header.ModcryptArea1Offset = data.ReadUInt32();
- header.ModcryptArea1Size = data.ReadUInt32();
- header.ModcryptArea2Offset = data.ReadUInt32();
- header.ModcryptArea2Size = data.ReadUInt32();
- header.TitleID = data.ReadBytes(8);
- header.DSiWarePublicSavSize = data.ReadUInt32();
- header.DSiWarePrivateSavSize = data.ReadUInt32();
- header.ReservedZero = data.ReadBytes(176);
- header.Unknown2 = data.ReadBytes(0x10);
- header.ARM9WithSecureAreaSHA1HMACHash = data.ReadBytes(20);
- header.ARM7SHA1HMACHash = data.ReadBytes(20);
- header.DigestMasterSHA1HMACHash = data.ReadBytes(20);
- header.BannerSHA1HMACHash = data.ReadBytes(20);
- header.ARM9iDecryptedSHA1HMACHash = data.ReadBytes(20);
- header.ARM7iDecryptedSHA1HMACHash = data.ReadBytes(20);
- header.Reserved5 = data.ReadBytes(40);
- header.ARM9NoSecureAreaSHA1HMACHash = data.ReadBytes(20);
- header.Reserved6 = data.ReadBytes(2636);
- header.ReservedAndUnchecked = data.ReadBytes(0x180);
- header.RSASignature = data.ReadBytes(0x80);
+ extendedDSiHeader.GlobalMBK15Settings[i] = data.ReadUInt32();
}
+ extendedDSiHeader.LocalMBK68SettingsARM9 = new uint[3];
+ for (int i = 0; i < 3; i++)
+ {
+ extendedDSiHeader.LocalMBK68SettingsARM9[i] = data.ReadUInt32();
+ }
+ extendedDSiHeader.LocalMBK68SettingsARM7 = new uint[3];
+ for (int i = 0; i < 3; i++)
+ {
+ extendedDSiHeader.LocalMBK68SettingsARM7[i] = data.ReadUInt32();
+ }
+ extendedDSiHeader.GlobalMBK9Setting = data.ReadUInt32();
+ extendedDSiHeader.RegionFlags = data.ReadUInt32();
+ extendedDSiHeader.AccessControl = data.ReadUInt32();
+ extendedDSiHeader.ARM7SCFGEXTMask = data.ReadUInt32();
+ extendedDSiHeader.ReservedFlags = data.ReadUInt32();
+ extendedDSiHeader.ARM9iRomOffset = data.ReadUInt32();
+ extendedDSiHeader.Reserved3 = data.ReadUInt32();
+ extendedDSiHeader.ARM9iLoadAddress = data.ReadUInt32();
+ extendedDSiHeader.ARM9iSize = data.ReadUInt32();
+ extendedDSiHeader.ARM7iRomOffset = data.ReadUInt32();
+ extendedDSiHeader.Reserved4 = data.ReadUInt32();
+ extendedDSiHeader.ARM7iLoadAddress = data.ReadUInt32();
+ extendedDSiHeader.ARM7iSize = data.ReadUInt32();
+ extendedDSiHeader.DigestNTRRegionOffset = data.ReadUInt32();
+ extendedDSiHeader.DigestNTRRegionLength = data.ReadUInt32();
+ extendedDSiHeader.DigestTWLRegionOffset = data.ReadUInt32();
+ extendedDSiHeader.DigestTWLRegionLength = data.ReadUInt32();
+ extendedDSiHeader.DigestSectorHashtableRegionOffset = data.ReadUInt32();
+ extendedDSiHeader.DigestSectorHashtableRegionLength = data.ReadUInt32();
+ extendedDSiHeader.DigestBlockHashtableRegionOffset = data.ReadUInt32();
+ extendedDSiHeader.DigestBlockHashtableRegionLength = data.ReadUInt32();
+ extendedDSiHeader.DigestSectorSize = data.ReadUInt32();
+ extendedDSiHeader.DigestBlockSectorCount = data.ReadUInt32();
+ extendedDSiHeader.IconBannerSize = data.ReadUInt32();
+ extendedDSiHeader.Unknown1 = data.ReadUInt32();
+ extendedDSiHeader.ModcryptArea1Offset = data.ReadUInt32();
+ extendedDSiHeader.ModcryptArea1Size = data.ReadUInt32();
+ extendedDSiHeader.ModcryptArea2Offset = data.ReadUInt32();
+ extendedDSiHeader.ModcryptArea2Size = data.ReadUInt32();
+ extendedDSiHeader.TitleID = data.ReadBytes(8);
+ extendedDSiHeader.DSiWarePublicSavSize = data.ReadUInt32();
+ extendedDSiHeader.DSiWarePrivateSavSize = data.ReadUInt32();
+ extendedDSiHeader.ReservedZero = data.ReadBytes(176);
+ extendedDSiHeader.Unknown2 = data.ReadBytes(0x10);
+ extendedDSiHeader.ARM9WithSecureAreaSHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.ARM7SHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.DigestMasterSHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.BannerSHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.ARM9iDecryptedSHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.ARM7iDecryptedSHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.Reserved5 = data.ReadBytes(40);
+ extendedDSiHeader.ARM9NoSecureAreaSHA1HMACHash = data.ReadBytes(20);
+ extendedDSiHeader.Reserved6 = data.ReadBytes(2636);
+ extendedDSiHeader.ReservedAndUnchecked = data.ReadBytes(0x180);
+ extendedDSiHeader.RSASignature = data.ReadBytes(0x80);
- return header;
+ return extendedDSiHeader;
}
#endregion
diff --git a/BurnOutSharp.Models/Nitro/Cart.cs b/BurnOutSharp.Models/Nitro/Cart.cs
index 18ae46ae..68c77f43 100644
--- a/BurnOutSharp.Models/Nitro/Cart.cs
+++ b/BurnOutSharp.Models/Nitro/Cart.cs
@@ -1,14 +1,19 @@
namespace BurnOutSharp.Models.Nitro
{
///
- /// Represents a DS cart image
+ /// Represents a DS/DSi cart image
///
public class Cart
{
///
- /// DS cart header
+ /// DS/DSi cart header
///
- public Header Header { get; set; }
+ public CommonHeader CommonHeader { get; set; }
+
+ ///
+ /// DSi extended cart header
+ ///
+ public ExtendedDSiHeader ExtendedDSiHeader { get; set; }
///
/// Secure area, may be encrypted or decrypted
diff --git a/BurnOutSharp.Models/Nitro/CommonHeader.cs b/BurnOutSharp.Models/Nitro/CommonHeader.cs
new file mode 100644
index 00000000..84a6d625
--- /dev/null
+++ b/BurnOutSharp.Models/Nitro/CommonHeader.cs
@@ -0,0 +1,214 @@
+namespace BurnOutSharp.Models.Nitro
+{
+ ///
+ /// Nintendo DS / DSi cartridge header
+ ///
+ ///
+ public sealed class CommonHeader
+ {
+ ///
+ /// Game Title
+ ///
+ public string GameTitle;
+
+ ///
+ /// Gamecode
+ ///
+ public uint GameCode;
+
+ ///
+ /// Makercode
+ ///
+ public string MakerCode;
+
+ ///
+ /// Unitcode
+ ///
+ public Unitcode UnitCode;
+
+ ///
+ /// Encryption seed select (device code. 0 = normal)
+ ///
+ public byte EncryptionSeedSelect;
+
+ ///
+ /// Devicecapacity
+ ///
+ public byte DeviceCapacity;
+
+ ///
+ /// Reserved
+ ///
+ public byte[] Reserved1;
+
+ ///
+ /// Game Revision (used by DSi titles)
+ ///
+ public ushort GameRevision;
+
+ ///
+ /// ROM Version
+ ///
+ public byte RomVersion;
+
+ ///
+ /// Internal flags, (Bit2: Autostart)
+ ///
+ public byte InternalFlags;
+
+ ///
+ /// ARM9 rom offset
+ ///
+ public uint ARM9RomOffset;
+
+ ///
+ /// ARM9 entry address
+ ///
+ public uint ARM9EntryAddress;
+
+ ///
+ /// ARM9 load address
+ ///
+ public uint ARM9LoadAddress;
+
+ ///
+ /// ARM9 size
+ ///
+ public uint ARM9Size;
+
+ ///
+ /// ARM7 rom offset
+ ///
+ public uint ARM7RomOffset;
+
+ ///
+ /// ARM7 entry address
+ ///
+ public uint ARM7EntryAddress;
+
+ ///
+ /// ARM7 load address
+ ///
+ public uint ARM7LoadAddress;
+
+ ///
+ /// ARM7 size
+ ///
+ public uint ARM7Size;
+
+ ///
+ /// File Name Table (FNT) offset
+ ///
+ public uint FileNameTableOffset;
+
+ ///
+ /// File Name Table (FNT) length
+ ///
+ public uint FileNameTableLength;
+
+ ///
+ /// File Allocation Table (FNT) offset
+ ///
+ public uint FileAllocationTableOffset;
+
+ ///
+ /// File Allocation Table (FNT) length
+ ///
+ public uint FileAllocationTableLength;
+
+ ///
+ /// File Name Table (FNT) offset
+ ///
+ public uint ARM9OverlayOffset;
+
+ ///
+ /// File Name Table (FNT) length
+ ///
+ public uint ARM9OverlayLength;
+
+ ///
+ /// File Name Table (FNT) offset
+ ///
+ public uint ARM7OverlayOffset;
+
+ ///
+ /// File Name Table (FNT) length
+ ///
+ public uint ARM7OverlayLength;
+
+ ///
+ /// Normal card control register settings (0x00416657 for OneTimePROM)
+ ///
+ public uint NormalCardControlRegisterSettings;
+
+ ///
+ /// Secure card control register settings (0x081808F8 for OneTimePROM)
+ ///
+ public uint SecureCardControlRegisterSettings;
+
+ ///
+ /// Icon Banner offset (NDSi same as NDS, but with new extra entries)
+ ///
+ public uint IconBannerOffset;
+
+ ///
+ /// Secure area (2K) CRC
+ ///
+ public ushort SecureAreaCRC;
+
+ ///
+ /// Secure transfer timeout (0x0D7E for OneTimePROM)
+ ///
+ public ushort SecureTransferTimeout;
+
+ ///
+ /// ARM9 autoload
+ ///
+ public uint ARM9Autoload;
+
+ ///
+ /// ARM7 autoload
+ ///
+ public uint ARM7Autoload;
+
+ ///
+ /// Secure disable
+ ///
+ public byte[] SecureDisable;
+
+ ///
+ /// NTR region ROM size (excluding DSi area)
+ ///
+ public uint NTRRegionRomSize;
+
+ ///
+ /// Header size
+ ///
+ public uint HeaderSize;
+
+ ///
+ ///Reserved (0x88, 0x8C, 0x90 = Unknown, used by DSi)
+ ///
+ public byte[] Reserved2;
+
+ ///
+ /// Nintendo Logo
+ ///
+ public byte[] NintendoLogo;
+
+ ///
+ /// Nintendo Logo CRC
+ ///
+ public ushort NintendoLogoCRC;
+
+ ///
+ /// Header CRC
+ ///
+ public ushort HeaderCRC;
+
+ ///
+ /// Debugger reserved
+ ///
+ public byte[] DebuggerReserved;
+ }
+}
\ No newline at end of file
diff --git a/BurnOutSharp.Models/Nitro/Header.cs b/BurnOutSharp.Models/Nitro/ExtendedDSiHeader.cs
similarity index 56%
rename from BurnOutSharp.Models/Nitro/Header.cs
rename to BurnOutSharp.Models/Nitro/ExtendedDSiHeader.cs
index 4ddbfe4c..94054348 100644
--- a/BurnOutSharp.Models/Nitro/Header.cs
+++ b/BurnOutSharp.Models/Nitro/ExtendedDSiHeader.cs
@@ -1,223 +1,11 @@
namespace BurnOutSharp.Models.Nitro
{
///
- /// Nintendo DS / DSi Cartridge Header
+ /// Nintendo DSi extended cart header
///
///
- public sealed class Header
+ public sealed class ExtendedDSiHeader
{
- #region Common
-
- ///
- /// Game Title
- ///
- public string GameTitle;
-
- ///
- /// Gamecode
- ///
- public uint GameCode;
-
- ///
- /// Makercode
- ///
- public string MakerCode;
-
- ///
- /// Unitcode
- ///
- public Unitcode UnitCode;
-
- ///
- /// Encryption seed select (device code. 0 = normal)
- ///
- public byte EncryptionSeedSelect;
-
- ///
- /// Devicecapacity
- ///
- public byte DeviceCapacity;
-
- ///
- /// Reserved
- ///
- public byte[] Reserved1;
-
- ///
- /// Game Revision (used by DSi titles)
- ///
- public ushort GameRevision;
-
- ///
- /// ROM Version
- ///
- public byte RomVersion;
-
- ///
- /// Internal flags, (Bit2: Autostart)
- ///
- public byte InternalFlags;
-
- ///
- /// ARM9 rom offset
- ///
- public uint ARM9RomOffset;
-
- ///
- /// ARM9 entry address
- ///
- public uint ARM9EntryAddress;
-
- ///
- /// ARM9 load address
- ///
- public uint ARM9LoadAddress;
-
- ///
- /// ARM9 size
- ///
- public uint ARM9Size;
-
- ///
- /// ARM7 rom offset
- ///
- public uint ARM7RomOffset;
-
- ///
- /// ARM7 entry address
- ///
- public uint ARM7EntryAddress;
-
- ///
- /// ARM7 load address
- ///
- public uint ARM7LoadAddress;
-
- ///
- /// ARM7 size
- ///
- public uint ARM7Size;
-
- ///
- /// File Name Table (FNT) offset
- ///
- public uint FileNameTableOffset;
-
- ///
- /// File Name Table (FNT) length
- ///
- public uint FileNameTableLength;
-
- ///
- /// File Allocation Table (FNT) offset
- ///
- public uint FileAllocationTableOffset;
-
- ///
- /// File Allocation Table (FNT) length
- ///
- public uint FileAllocationTableLength;
-
- ///
- /// File Name Table (FNT) offset
- ///
- public uint ARM9OverlayOffset;
-
- ///
- /// File Name Table (FNT) length
- ///
- public uint ARM9OverlayLength;
-
- ///
- /// File Name Table (FNT) offset
- ///
- public uint ARM7OverlayOffset;
-
- ///
- /// File Name Table (FNT) length
- ///
- public uint ARM7OverlayLength;
-
- ///
- /// Normal card control register settings (0x00416657 for OneTimePROM)
- ///
- public uint NormalCardControlRegisterSettings;
-
- ///
- /// Secure card control register settings (0x081808F8 for OneTimePROM)
- ///
- public uint SecureCardControlRegisterSettings;
-
- ///
- /// Icon Banner offset (NDSi same as NDS, but with new extra entries)
- ///
- public uint IconBannerOffset;
-
- ///
- /// Secure area (2K) CRC
- ///
- public ushort SecureAreaCRC;
-
- ///
- /// Secure transfer timeout (0x0D7E for OneTimePROM)
- ///
- public ushort SecureTransferTimeout;
-
- ///
- /// ARM9 autoload
- ///
- public uint ARM9Autoload;
-
- ///
- /// ARM7 autoload
- ///
- public uint ARM7Autoload;
-
- ///
- /// Secure disable
- ///
- public byte[] SecureDisable;
-
- ///
- /// NTR region ROM size (excluding DSi area)
- ///
- public uint NTRRegionRomSize;
-
- ///
- /// Header size
- ///
- public uint HeaderSize;
-
- ///
- ///Reserved (0x88, 0x8C, 0x90 = Unknown, used by DSi)
- ///
- public byte[] Reserved2;
-
- ///
- /// Nintendo Logo
- ///
- public byte[] NintendoLogo;
-
- ///
- /// Nintendo Logo CRC
- ///
- public ushort NintendoLogoCRC;
-
- ///
- /// Header CRC
- ///
- public ushort HeaderCRC;
-
- ///
- /// Debugger reserved
- ///
- public byte[] DebuggerReserved;
-
- #endregion
-
- // TODO: Should this be separated into a distinct file?
- #region Extended DSi
-
///
/// Global MBK1..MBK5 Settings
///
@@ -467,7 +255,5 @@ namespace BurnOutSharp.Models.Nitro
/// RSA signature (the first 0xE00 bytes of the header are signed with an 1024-bit RSA signature).
///
public byte[] RSASignature;
-
- #endregion
}
}
\ No newline at end of file
diff --git a/BurnOutSharp.Wrappers/Nitro.cs b/BurnOutSharp.Wrappers/Nitro.cs
index b8f012fc..d2981090 100644
--- a/BurnOutSharp.Wrappers/Nitro.cs
+++ b/BurnOutSharp.Wrappers/Nitro.cs
@@ -7,282 +7,278 @@ namespace BurnOutSharp.Wrappers
{
#region Pass-Through Properties
- #region Header
+ #region Common Header
- #region Common
+ ///
+ public string GameTitle => _cart.CommonHeader.GameTitle;
- ///
- public string GameTitle => _cart.Header.GameTitle;
+ ///
+ public uint GameCode => _cart.CommonHeader.GameCode;
- ///
- public uint GameCode => _cart.Header.GameCode;
+ ///
+ public string MakerCode => _cart.CommonHeader.MakerCode;
- ///
- public string MakerCode => _cart.Header.MakerCode;
+ ///
+ public Models.Nitro.Unitcode UnitCode => _cart.CommonHeader.UnitCode;
- ///
- public Models.Nitro.Unitcode UnitCode => _cart.Header.UnitCode;
+ ///
+ public byte EncryptionSeedSelect => _cart.CommonHeader.EncryptionSeedSelect;
- ///
- public byte EncryptionSeedSelect => _cart.Header.EncryptionSeedSelect;
+ ///
+ public byte DeviceCapacity => _cart.CommonHeader.DeviceCapacity;
- ///
- public byte DeviceCapacity => _cart.Header.DeviceCapacity;
+ ///
+ public byte[] Reserved1 => _cart.CommonHeader.Reserved1;
- ///
- public byte[] Reserved1 => _cart.Header.Reserved1;
+ ///
+ public ushort GameRevision => _cart.CommonHeader.GameRevision;
- ///
- public ushort GameRevision => _cart.Header.GameRevision;
+ ///
+ public byte RomVersion => _cart.CommonHeader.RomVersion;
- ///
- public byte RomVersion => _cart.Header.RomVersion;
+ ///
+ public byte InternalFlags => _cart.CommonHeader.InternalFlags;
- ///
- public byte InternalFlags => _cart.Header.InternalFlags;
+ ///
+ public uint ARM9RomOffset => _cart.CommonHeader.ARM9RomOffset;
- ///
- public uint ARM9RomOffset => _cart.Header.ARM9RomOffset;
+ ///
+ public uint ARM9EntryAddress => _cart.CommonHeader.ARM9EntryAddress;
- ///
- public uint ARM9EntryAddress => _cart.Header.ARM9EntryAddress;
+ ///
+ public uint ARM9LoadAddress => _cart.CommonHeader.ARM9LoadAddress;
- ///
- public uint ARM9LoadAddress => _cart.Header.ARM9LoadAddress;
+ ///
+ public uint ARM9Size => _cart.CommonHeader.ARM9Size;
- ///
- public uint ARM9Size => _cart.Header.ARM9Size;
+ ///
+ public uint ARM7RomOffset => _cart.CommonHeader.ARM7RomOffset;
- ///
- public uint ARM7RomOffset => _cart.Header.ARM7RomOffset;
+ ///
+ public uint ARM7EntryAddress => _cart.CommonHeader.ARM7EntryAddress;
- ///
- public uint ARM7EntryAddress => _cart.Header.ARM7EntryAddress;
+ ///
+ public uint ARM7LoadAddress => _cart.CommonHeader.ARM7LoadAddress;
- ///
- public uint ARM7LoadAddress => _cart.Header.ARM7LoadAddress;
+ ///
+ public uint ARM7Size => _cart.CommonHeader.ARM7Size;
- ///
- public uint ARM7Size => _cart.Header.ARM7Size;
+ ///
+ public uint FileNameTableOffset => _cart.CommonHeader.FileNameTableOffset;
- ///
- public uint FileNameTableOffset => _cart.Header.FileNameTableOffset;
+ ///
+ public uint FileNameTableLength => _cart.CommonHeader.FileNameTableLength;
- ///
- public uint FileNameTableLength => _cart.Header.FileNameTableLength;
+ ///
+ public uint FileAllocationTableOffset => _cart.CommonHeader.FileAllocationTableOffset;
- ///
- public uint FileAllocationTableOffset => _cart.Header.FileAllocationTableOffset;
+ ///
+ public uint FileAllocationTableLength => _cart.CommonHeader.FileAllocationTableLength;
- ///
- public uint FileAllocationTableLength => _cart.Header.FileAllocationTableLength;
+ ///
+ public uint ARM9OverlayOffset => _cart.CommonHeader.ARM9OverlayOffset;
- ///
- public uint ARM9OverlayOffset => _cart.Header.ARM9OverlayOffset;
+ ///
+ public uint ARM9OverlayLength => _cart.CommonHeader.ARM9OverlayLength;
- ///
- public uint ARM9OverlayLength => _cart.Header.ARM9OverlayLength;
+ ///
+ public uint ARM7OverlayOffset => _cart.CommonHeader.ARM7OverlayOffset;
- ///
- public uint ARM7OverlayOffset => _cart.Header.ARM7OverlayOffset;
+ ///
+ public uint ARM7OverlayLength => _cart.CommonHeader.ARM7OverlayLength;
- ///
- public uint ARM7OverlayLength => _cart.Header.ARM7OverlayLength;
+ ///
+ public uint NormalCardControlRegisterSettings => _cart.CommonHeader.NormalCardControlRegisterSettings;
- ///
- public uint NormalCardControlRegisterSettings => _cart.Header.NormalCardControlRegisterSettings;
+ ///
+ public uint SecureCardControlRegisterSettings => _cart.CommonHeader.SecureCardControlRegisterSettings;
- ///
- public uint SecureCardControlRegisterSettings => _cart.Header.SecureCardControlRegisterSettings;
+ ///
+ public uint IconBannerOffset => _cart.CommonHeader.IconBannerOffset;
- ///
- public uint IconBannerOffset => _cart.Header.IconBannerOffset;
+ ///
+ public ushort SecureAreaCRC => _cart.CommonHeader.SecureAreaCRC;
- ///
- public ushort SecureAreaCRC => _cart.Header.SecureAreaCRC;
+ ///
+ public ushort SecureTransferTimeout => _cart.CommonHeader.SecureTransferTimeout;
- ///
- public ushort SecureTransferTimeout => _cart.Header.SecureTransferTimeout;
+ ///
+ public uint ARM9Autoload => _cart.CommonHeader.ARM9Autoload;
- ///
- public uint ARM9Autoload => _cart.Header.ARM9Autoload;
+ ///
+ public uint ARM7Autoload => _cart.CommonHeader.ARM7Autoload;
- ///
- public uint ARM7Autoload => _cart.Header.ARM7Autoload;
+ ///
+ public byte[] SecureDisable => _cart.CommonHeader.SecureDisable;
- ///
- public byte[] SecureDisable => _cart.Header.SecureDisable;
+ ///
+ public uint NTRRegionRomSize => _cart.CommonHeader.NTRRegionRomSize;
- ///
- public uint NTRRegionRomSize => _cart.Header.NTRRegionRomSize;
+ ///
+ public uint HeaderSize => _cart.CommonHeader.HeaderSize;
- ///
- public uint HeaderSize => _cart.Header.HeaderSize;
+ ///
+ public byte[] Reserved2 => _cart.CommonHeader.Reserved2;
- ///
- public byte[] Reserved2 => _cart.Header.Reserved2;
+ ///
+ public byte[] NintendoLogo => _cart.CommonHeader.NintendoLogo;
- ///
- public byte[] NintendoLogo => _cart.Header.NintendoLogo;
+ ///
+ public ushort NintendoLogoCRC => _cart.CommonHeader.NintendoLogoCRC;
- ///
- public ushort NintendoLogoCRC => _cart.Header.NintendoLogoCRC;
+ ///
+ public ushort HeaderCRC => _cart.CommonHeader.HeaderCRC;
- ///
- public ushort HeaderCRC => _cart.Header.HeaderCRC;
-
- ///
- public byte[] DebuggerReserved => _cart.Header.DebuggerReserved;
+ ///
+ public byte[] DebuggerReserved => _cart.CommonHeader.DebuggerReserved;
#endregion
- #region Extended DSi
+ #region Extended DSi Header
- ///
- public uint[] GlobalMBK15Settings => _cart.Header.GlobalMBK15Settings;
+ ///
+ public uint[] GlobalMBK15Settings => _cart.ExtendedDSiHeader?.GlobalMBK15Settings;
- ///
- public uint[] LocalMBK68SettingsARM9 => _cart.Header.LocalMBK68SettingsARM9;
+ ///
+ public uint[] LocalMBK68SettingsARM9 => _cart.ExtendedDSiHeader?.LocalMBK68SettingsARM9;
- ///
- public uint[] LocalMBK68SettingsARM7 => _cart.Header.LocalMBK68SettingsARM7;
+ ///
+ public uint[] LocalMBK68SettingsARM7 => _cart.ExtendedDSiHeader?.LocalMBK68SettingsARM7;
- ///
- public uint GlobalMBK9Setting => _cart.Header.GlobalMBK9Setting;
+ ///
+ public uint? GlobalMBK9Setting => _cart.ExtendedDSiHeader?.GlobalMBK9Setting;
- ///
- public uint RegionFlags => _cart.Header.RegionFlags;
+ ///
+ public uint? RegionFlags => _cart.ExtendedDSiHeader?.RegionFlags;
- ///
- public uint AccessControl => _cart.Header.AccessControl;
+ ///
+ public uint? AccessControl => _cart.ExtendedDSiHeader?.AccessControl;
- ///
- public uint ARM7SCFGEXTMask => _cart.Header.ARM7SCFGEXTMask;
+ ///
+ public uint? ARM7SCFGEXTMask => _cart.ExtendedDSiHeader?.ARM7SCFGEXTMask;
- ///
- public uint ReservedFlags => _cart.Header.ReservedFlags;
+ ///
+ public uint? ReservedFlags => _cart.ExtendedDSiHeader?.ReservedFlags;
- ///
- public uint ARM9iRomOffset => _cart.Header.ARM9iRomOffset;
+ ///
+ public uint? ARM9iRomOffset => _cart.ExtendedDSiHeader?.ARM9iRomOffset;
- ///
- public uint Reserved3 => _cart.Header.Reserved3;
+ ///
+ public uint? Reserved3 => _cart.ExtendedDSiHeader?.Reserved3;
- ///
- public uint ARM9iLoadAddress => _cart.Header.ARM9iLoadAddress;
+ ///
+ public uint? ARM9iLoadAddress => _cart.ExtendedDSiHeader?.ARM9iLoadAddress;
- ///
- public uint ARM9iSize => _cart.Header.ARM9iSize;
+ ///
+ public uint? ARM9iSize => _cart.ExtendedDSiHeader?.ARM9iSize;
- ///
- public uint ARM7iRomOffset => _cart.Header.ARM7iRomOffset;
+ ///
+ public uint? ARM7iRomOffset => _cart.ExtendedDSiHeader?.ARM7iRomOffset;
- ///
- public uint Reserved4 => _cart.Header.Reserved4;
+ ///
+ public uint? Reserved4 => _cart.ExtendedDSiHeader?.Reserved4;
- ///
- public uint ARM7iLoadAddress => _cart.Header.ARM7iLoadAddress;
+ ///
+ public uint? ARM7iLoadAddress => _cart.ExtendedDSiHeader?.ARM7iLoadAddress;
- ///
- public uint ARM7iSize => _cart.Header.ARM7iSize;
+ ///
+ public uint? ARM7iSize => _cart.ExtendedDSiHeader?.ARM7iSize;
- ///
- public uint DigestNTRRegionOffset => _cart.Header.DigestNTRRegionOffset;
+ ///
+ public uint? DigestNTRRegionOffset => _cart.ExtendedDSiHeader?.DigestNTRRegionOffset;
- ///
- public uint DigestNTRRegionLength => _cart.Header.DigestNTRRegionLength;
+ ///
+ public uint? DigestNTRRegionLength => _cart.ExtendedDSiHeader?.DigestNTRRegionLength;
- ///
- public uint DigestTWLRegionOffset => _cart.Header.DigestTWLRegionOffset;
+ ///
+ public uint? DigestTWLRegionOffset => _cart.ExtendedDSiHeader?.DigestTWLRegionOffset;
- ///
- public uint DigestTWLRegionLength => _cart.Header.DigestTWLRegionLength;
+ ///
+ public uint? DigestTWLRegionLength => _cart.ExtendedDSiHeader?.DigestTWLRegionLength;
- ///
- public uint DigestSectorHashtableRegionOffset => _cart.Header.DigestSectorHashtableRegionOffset;
+ ///
+ public uint? DigestSectorHashtableRegionOffset => _cart.ExtendedDSiHeader?.DigestSectorHashtableRegionOffset;
- ///
- public uint DigestSectorHashtableRegionLength => _cart.Header.DigestSectorHashtableRegionLength;
+ ///
+ public uint? DigestSectorHashtableRegionLength => _cart.ExtendedDSiHeader?.DigestSectorHashtableRegionLength;
- ///
- public uint DigestBlockHashtableRegionOffset => _cart.Header.DigestBlockHashtableRegionOffset;
+ ///
+ public uint? DigestBlockHashtableRegionOffset => _cart.ExtendedDSiHeader?.DigestBlockHashtableRegionOffset;
- ///
- public uint DigestBlockHashtableRegionLength => _cart.Header.DigestBlockHashtableRegionLength;
+ ///
+ public uint? DigestBlockHashtableRegionLength => _cart.ExtendedDSiHeader?.DigestBlockHashtableRegionLength;
- ///
- public uint DigestSectorSize => _cart.Header.DigestSectorSize;
+ ///
+ public uint? DigestSectorSize => _cart.ExtendedDSiHeader?.DigestSectorSize;
- ///
- public uint DigestBlockSectorCount => _cart.Header.DigestBlockSectorCount;
+ ///
+ public uint? DigestBlockSectorCount => _cart.ExtendedDSiHeader?.DigestBlockSectorCount;
- ///
- public uint IconBannerSize => _cart.Header.IconBannerSize;
+ ///
+ public uint? IconBannerSize => _cart.ExtendedDSiHeader?.IconBannerSize;
- ///
- public uint Unknown1 => _cart.Header.Unknown1;
+ ///
+ public uint? Unknown1 => _cart.ExtendedDSiHeader?.Unknown1;
- ///
- public uint ModcryptArea1Offset => _cart.Header.ModcryptArea1Offset;
+ ///
+ public uint? ModcryptArea1Offset => _cart.ExtendedDSiHeader?.ModcryptArea1Offset;
- ///
- public uint ModcryptArea1Size => _cart.Header.ModcryptArea1Size;
+ ///
+ public uint? ModcryptArea1Size => _cart.ExtendedDSiHeader?.ModcryptArea1Size;
- ///
- public uint ModcryptArea2Offset => _cart.Header.ModcryptArea2Offset;
+ ///
+ public uint? ModcryptArea2Offset => _cart.ExtendedDSiHeader?.ModcryptArea2Offset;
- ///
- public uint ModcryptArea2Size => _cart.Header.ModcryptArea2Size;
+ ///
+ public uint? ModcryptArea2Size => _cart.ExtendedDSiHeader?.ModcryptArea2Size;
- ///
- public byte[] TitleID => _cart.Header.TitleID;
+ ///
+ public byte[] TitleID => _cart.ExtendedDSiHeader?.TitleID;
- ///
- public uint DSiWarePublicSavSize => _cart.Header.DSiWarePublicSavSize;
+ ///
+ public uint? DSiWarePublicSavSize => _cart.ExtendedDSiHeader?.DSiWarePublicSavSize;
- ///
- public uint DSiWarePrivateSavSize => _cart.Header.DSiWarePrivateSavSize;
+ ///
+ public uint? DSiWarePrivateSavSize => _cart.ExtendedDSiHeader?.DSiWarePrivateSavSize;
- ///
- public byte[] ReservedZero => _cart.Header.ReservedZero;
+ ///
+ public byte[] ReservedZero => _cart.ExtendedDSiHeader?.ReservedZero;
- ///
- public byte[] Unknown2 => _cart.Header.Unknown2;
+ ///
+ public byte[] Unknown2 => _cart.ExtendedDSiHeader?.Unknown2;
- ///
- public byte[] ARM9WithSecureAreaSHA1HMACHash => _cart.Header.ARM9WithSecureAreaSHA1HMACHash;
+ ///
+ public byte[] ARM9WithSecureAreaSHA1HMACHash => _cart.ExtendedDSiHeader?.ARM9WithSecureAreaSHA1HMACHash;
- ///
- public byte[] ARM7SHA1HMACHash => _cart.Header.ARM7SHA1HMACHash;
+ ///
+ public byte[] ARM7SHA1HMACHash => _cart.ExtendedDSiHeader?.ARM7SHA1HMACHash;
- ///
- public byte[] DigestMasterSHA1HMACHash => _cart.Header.DigestMasterSHA1HMACHash;
+ ///
+ public byte[] DigestMasterSHA1HMACHash => _cart.ExtendedDSiHeader?.DigestMasterSHA1HMACHash;
- ///
- public byte[] BannerSHA1HMACHash => _cart.Header.BannerSHA1HMACHash;
+ ///
+ public byte[] BannerSHA1HMACHash => _cart.ExtendedDSiHeader?.BannerSHA1HMACHash;
- ///
- public byte[] ARM9iDecryptedSHA1HMACHash => _cart.Header.ARM9iDecryptedSHA1HMACHash;
+ ///
+ public byte[] ARM9iDecryptedSHA1HMACHash => _cart.ExtendedDSiHeader?.ARM9iDecryptedSHA1HMACHash;
- ///
- public byte[] ARM7iDecryptedSHA1HMACHash => _cart.Header.ARM7iDecryptedSHA1HMACHash;
+ ///
+ public byte[] ARM7iDecryptedSHA1HMACHash => _cart.ExtendedDSiHeader?.ARM7iDecryptedSHA1HMACHash;
- ///
- public byte[] Reserved5 => _cart.Header.Reserved5;
+ ///
+ public byte[] Reserved5 => _cart.ExtendedDSiHeader?.Reserved5;
- ///
- public byte[] ARM9NoSecureAreaSHA1HMACHash => _cart.Header.ARM9NoSecureAreaSHA1HMACHash;
+ ///
+ public byte[] ARM9NoSecureAreaSHA1HMACHash => _cart.ExtendedDSiHeader?.ARM9NoSecureAreaSHA1HMACHash;
- ///
- public byte[] Reserved6 => _cart.Header.Reserved6;
+ ///
+ public byte[] Reserved6 => _cart.ExtendedDSiHeader?.Reserved6;
- ///
- public byte[] ReservedAndUnchecked => _cart.Header.ReservedAndUnchecked;
+ ///
+ public byte[] ReservedAndUnchecked => _cart.ExtendedDSiHeader?.ReservedAndUnchecked;
- ///
- public byte[] RSASignature => _cart.Header.RSASignature;
-
- #endregion
+ ///
+ public byte[] RSASignature => _cart.ExtendedDSiHeader?.RSASignature;
#endregion
@@ -368,7 +364,7 @@ namespace BurnOutSharp.Wrappers
Console.WriteLine();
PrintCommonHeader();
- PrintDSiHeader();
+ PrintExtendedDSiHeader();
PrintSecureArea();
}
@@ -423,15 +419,15 @@ namespace BurnOutSharp.Wrappers
}
///
- /// Print DSi header information
+ /// Print extended DSi header information
///
- private void PrintDSiHeader()
+ private void PrintExtendedDSiHeader()
{
- Console.WriteLine(" DSi Header Information:");
+ Console.WriteLine(" Extended DSi Header Information:");
Console.WriteLine(" -------------------------");
- if (UnitCode == Models.Nitro.Unitcode.NDSPlusDSi || UnitCode == Models.Nitro.Unitcode.DSi)
+ if (_cart.ExtendedDSiHeader == null)
{
- Console.WriteLine(" No DSi header");
+ Console.WriteLine(" No extended DSi header");
}
else
{