mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 02:53:04 +00:00
Add Nacp parsing
This commit is contained in:
parent
37a9880ae7
commit
3090c9f236
2 changed files with 64 additions and 2 deletions
53
Ryujinx.HLE/Loaders/Archives/ControlArchive.cs
Normal file
53
Ryujinx.HLE/Loaders/Archives/ControlArchive.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue