ryujinx-mirror/Ryujinx.HLE/Loaders/Executables/NxRelocatableObject.cs
Thomas Guillemard b126ea48c6 Support HomeBrew Loader (#577)
* Make it possibles to load hb-loader and hb-menu

One issue remains with hb-menu homebrew icons because of SIMD issues
(libjpeg-turbo related) and netloader doesn't work.

* Implement GetApplicationControlData

* Fix shared fonts for NSO/NRO

* Add homebrew NRO romfs support

This readd the NRO support by parsing the ASET header

* Address comments about HomebrewRomFs

* override Dispose in homebrew romfs stream

* Use a struct for file timestamp

* Simplify positional increments in GetApplicationControlData

* Address comments

* improve readability of the memory permission check in SetProcessMemoryPermission

* Fix previous broken check

* Add address space checks in SetProcessMemoryPermission
2019-02-14 11:44:39 +11:00

67 lines
No EOL
2.2 KiB
C#

using System.IO;
namespace Ryujinx.HLE.Loaders.Executables
{
class NxRelocatableObject : 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 NxRelocatableObject(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;
}
}
}