2018-02-04 23:08:20 +00:00
|
|
|
using System.IO;
|
|
|
|
|
2018-06-11 00:46:42 +00:00
|
|
|
namespace Ryujinx.HLE.Loaders.Executables
|
2018-02-04 23:08:20 +00:00
|
|
|
{
|
2018-11-28 22:18:09 +00:00
|
|
|
class NxRelocatableObject : IExecutable
|
2018-02-04 23:08:20 +00:00
|
|
|
{
|
2018-03-10 23:39:16 +00:00
|
|
|
public byte[] Text { get; private set; }
|
|
|
|
public byte[] RO { get; private set; }
|
|
|
|
public byte[] Data { get; private set; }
|
2018-02-04 23:08:20 +00:00
|
|
|
|
|
|
|
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; }
|
|
|
|
|
2018-11-28 22:18:09 +00:00
|
|
|
public int BssOffset => DataOffset + Data.Length;
|
|
|
|
|
|
|
|
public ulong SourceAddress { get; private set; }
|
|
|
|
public ulong BssAddress { get; private set; }
|
2018-10-09 23:01:49 +00:00
|
|
|
|
2018-11-28 22:18:09 +00:00
|
|
|
public NxRelocatableObject(Stream Input, ulong SourceAddress = 0, ulong BssAddress = 0)
|
2018-02-04 23:08:20 +00:00
|
|
|
{
|
2018-10-09 23:01:49 +00:00
|
|
|
this.SourceAddress = SourceAddress;
|
|
|
|
this.BssAddress = BssAddress;
|
2018-04-22 04:21:49 +00:00
|
|
|
|
2018-02-04 23:08:20 +00:00
|
|
|
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();
|
|
|
|
|
|
|
|
this.Mod0Offset = Mod0Offset;
|
|
|
|
this.TextOffset = TextOffset;
|
|
|
|
this.ROOffset = ROOffset;
|
|
|
|
this.DataOffset = DataOffset;
|
|
|
|
this.BssSize = BssSize;
|
|
|
|
|
|
|
|
byte[] Read(long Position, int Size)
|
|
|
|
{
|
|
|
|
Input.Seek(Position, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
return Reader.ReadBytes(Size);
|
|
|
|
}
|
|
|
|
|
2018-03-10 23:39:16 +00:00
|
|
|
Text = Read(TextOffset, TextSize);
|
|
|
|
RO = Read(ROOffset, ROSize);
|
|
|
|
Data = Read(DataOffset, DataSize);
|
2018-02-04 23:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|