diff options
| author | Elise <elisezerotwo@gmail.com> | 2020-04-08 00:41:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-07 19:41:02 -0300 |
| commit | dc144d2e190e03729b16e402da9c36eec5aaf53f (patch) | |
| tree | 00728f4639cc9642c25031aff6ae9a6d465f4fe7 /Ryujinx.HLE/Loaders/Executables/NroExecutable.cs | |
| parent | 468d8f841ffcbebf4130371eb64ab04165bce3e9 (diff) | |
Use libhac for loading NSO and KIP (#1047)
* Use libhac for loading NSOs and KIPs
* Fix formatting
* Refactor KIP and NSO executables for libhac
* Fix up formatting
* Remove Ryujinx.HLE.Loaders.Compression
* Remove reference to Ryujinx.HLE.Loaders.Compression in NxStaticObject.cs
* Remove reference to Ryujinx.HLE.Loaders.Compression in KernelInitialProcess.cs
* Rename classes in Ryujinx.HLE.Loaders.Executables
* Fix space alignment
* Fix up formatting
Diffstat (limited to 'Ryujinx.HLE/Loaders/Executables/NroExecutable.cs')
| -rw-r--r-- | Ryujinx.HLE/Loaders/Executables/NroExecutable.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Ryujinx.HLE/Loaders/Executables/NroExecutable.cs b/Ryujinx.HLE/Loaders/Executables/NroExecutable.cs new file mode 100644 index 00000000..4a7f2116 --- /dev/null +++ b/Ryujinx.HLE/Loaders/Executables/NroExecutable.cs @@ -0,0 +1,67 @@ +using System.IO; + +namespace Ryujinx.HLE.Loaders.Executables +{ + class NroExecutable : IExecutable + { + public byte[] Text { get; private set; } + public byte[] Ro { get; private set; } + public byte[] Data { get; private set; } + + public int Mod0Offset { get; private set; } + public int TextOffset { get; private set; } + public int RoOffset { get; private set; } + public int DataOffset { get; private set; } + public int BssSize { get; private set; } + public int FileSize { get; private set; } + + public int BssOffset => DataOffset + Data.Length; + + public ulong SourceAddress { get; private set; } + public ulong BssAddress { get; private set; } + + public NroExecutable(Stream input, ulong sourceAddress = 0, ulong bssAddress = 0) + { + SourceAddress = sourceAddress; + BssAddress = bssAddress; + + BinaryReader reader = new BinaryReader(input); + + input.Seek(4, SeekOrigin.Begin); + + int mod0Offset = reader.ReadInt32(); + int padding8 = reader.ReadInt32(); + int paddingC = reader.ReadInt32(); + int nroMagic = reader.ReadInt32(); + int unknown14 = reader.ReadInt32(); + int fileSize = reader.ReadInt32(); + int unknown1C = reader.ReadInt32(); + int textOffset = reader.ReadInt32(); + int textSize = reader.ReadInt32(); + int roOffset = reader.ReadInt32(); + int roSize = reader.ReadInt32(); + int dataOffset = reader.ReadInt32(); + int dataSize = reader.ReadInt32(); + int bssSize = reader.ReadInt32(); + + Mod0Offset = mod0Offset; + TextOffset = textOffset; + RoOffset = roOffset; + DataOffset = dataOffset; + BssSize = bssSize; + + byte[] Read(long position, int size) + { + input.Seek(position, SeekOrigin.Begin); + + return reader.ReadBytes(size); + } + + Text = Read(textOffset, textSize); + Ro = Read(roOffset, roSize); + Data = Read(dataOffset, dataSize); + + FileSize = fileSize; + } + } +}
\ No newline at end of file |
