diff --git a/Ryujinx.HLE/Loaders/Archives/ControlArchive.cs b/Ryujinx.HLE/Loaders/Archives/ControlArchive.cs new file mode 100644 index 0000000000..481b359da2 --- /dev/null +++ b/Ryujinx.HLE/Loaders/Archives/ControlArchive.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace Ryujinx.HLE.Loaders.Archives +{ + public class ControlArchive + { + public LanguageEntry[] LanguageEntries { get; set; } + public long ApplicationTitleID { get; set; } + public long BaseTitleID { get; set; } + public long ProductCode { get; set; } + public string ApplicationVersion { get; set; } + + public ControlArchive(Stream Input) + { + BinaryReader Reader = new BinaryReader(Input); + + byte[] LanguageEntryData = Reader.ReadBytes(0x3000); + + Input.Seek(0x3060, SeekOrigin.Begin); + ApplicationVersion = Encoding.ASCII.GetString(Reader.ReadBytes(0x10)); + BaseTitleID = Reader.ReadInt64(); + ApplicationTitleID = Reader.ReadInt64(); + + Input.Seek(0x30a8, SeekOrigin.Begin); + ProductCode = Reader.ReadInt64(); + + LanguageEntries = new LanguageEntry[16]; + + using (MemoryStream LanguageStream = new MemoryStream(LanguageEntryData)) + { + BinaryReader LanguageReader = new BinaryReader(LanguageStream); + for (int index = 0; index < 16; index++) + { + LanguageEntries[index] = new LanguageEntry() + { + AplicationName = Encoding.ASCII.GetString(LanguageReader.ReadBytes(0x200)).Trim('\0'), + DeveloperName = Encoding.ASCII.GetString(LanguageReader.ReadBytes(0x100)).Trim('\0') + }; + } + } + } + } + + + public struct LanguageEntry + { + public string AplicationName; + public string DeveloperName; + } +} diff --git a/Ryujinx.HLE/Loaders/Executables/Nro.cs b/Ryujinx.HLE/Loaders/Executables/Nro.cs index 671936c8ef..b7712173c0 100644 --- a/Ryujinx.HLE/Loaders/Executables/Nro.cs +++ b/Ryujinx.HLE/Loaders/Executables/Nro.cs @@ -2,6 +2,7 @@ using System; using System.Drawing; using System.IO; using System.Text; +using Ryujinx.HLE.Loaders.Archives; namespace Ryujinx.HLE.Loaders.Executables { @@ -14,7 +15,6 @@ namespace Ryujinx.HLE.Loaders.Executables public byte[] Data { get; private set; } public byte[] AssetRomfData { get; set; } public byte[] IconData { get; set; } - public byte[] NCAPData { get; set; } public int Mod0Offset { get; private set; } public int TextOffset { get; private set; } @@ -23,6 +23,10 @@ namespace Ryujinx.HLE.Loaders.Executables public int BssSize { get; private set; } public int AssetOffset { get; set; } + public ControlArchive ControlArchive { get; set; } + + private byte[] NACPData { get; set; } + public Nro(Stream Input, string Name) { this.Name = Name; @@ -88,12 +92,17 @@ namespace Ryujinx.HLE.Loaders.Executables IconData = Reader.ReadBytes((int)IconSize); Input.Seek(AssetOffset + NACPOffset, SeekOrigin.Begin); - NCAPData = Reader.ReadBytes((int)NACPSize); + NACPData = Reader.ReadBytes((int)NACPSize); Input.Seek(AssetOffset + RomfOffset, SeekOrigin.Begin); AssetRomfData = Reader.ReadBytes((int)RomfSize); } } + + using(MemoryStream NACPStream = new MemoryStream(NACPData)) + { + ControlArchive = new ControlArchive(NACPStream); + } } } } \ No newline at end of file