0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-23 19:45:48 +00:00
ryujinx-fork/Ryujinx.HLE/Loaders/Executables/NroExecutable.cs
mageven 189c0c9c72
Implement modding support (#1249)
* Implement Modding Support

* Executables: Rewrite to use contiguous mem and Spans

* Reorder ExeFs, Npdm, ControlData and SaveData calls

After discussion with gdkchan, it was decided it's best to call
LoadExeFs after all other loads are done as it starts the guest process.

* Build RomFs manually instead of Layering FS

Layered FS approach has considerable latency when building the final
romfs. So, we manually replace files in a single romfs instance.

* Add RomFs modding via storage file

* Fix and cleanup MemPatch

* Add dynamically loaded NRO patching

* Support exefs file replacement

* Rewrite ModLoader to use mods-search architecture

* Disable PPTC when exefs patches are detected

Disable PPTC on exefs replacements too

* Rewrite ModLoader, again

* Increased maintainability and matches Atmosphere closely
* Creates base mods structure if it doesn't exist
* Add Exefs partition replacement
* IPSwitch: Fix nsobid parsing

* Move mod logs to new LogClass

* Allow custom suffixes to title dirs again

* Address nits

* Add a per-App "Open Mods Directory" context menu item

Creates the path if not present.

* Normalize tooltips verbiage

* Use LocalStorage and remove unused namespaces
2020-07-09 14:31:15 +10:00

38 lines
No EOL
1.5 KiB
C#

using LibHac;
using LibHac.Fs;
using System;
namespace Ryujinx.HLE.Loaders.Executables
{
class NroExecutable : Nro, IExecutable
{
public byte[] Program { get; }
public Span<byte> Text => Program.AsSpan().Slice(TextOffset, (int)Header.NroSegments[0].Size);
public Span<byte> Ro => Program.AsSpan().Slice(RoOffset, (int)Header.NroSegments[1].Size);
public Span<byte> Data => Program.AsSpan().Slice(DataOffset, (int)Header.NroSegments[2].Size);
public int TextOffset => (int)Header.NroSegments[0].FileOffset;
public int RoOffset => (int)Header.NroSegments[1].FileOffset;
public int DataOffset => (int)Header.NroSegments[2].FileOffset;
public int BssOffset => DataOffset + Data.Length;
public int BssSize => (int)Header.BssSize;
public int Mod0Offset => Start.Mod0Offset;
public int FileSize => (int)Header.Size;
public ulong SourceAddress { get; private set; }
public ulong BssAddress { get; private set; }
public NroExecutable(IStorage inStorage, ulong sourceAddress = 0, ulong bssAddress = 0) : base(inStorage)
{
Program = new byte[FileSize];
SourceAddress = sourceAddress;
BssAddress = bssAddress;
OpenNroSegment(NroSegmentType.Text, false).Read(0, Text);
OpenNroSegment(NroSegmentType.Ro , false).Read(0, Ro);
OpenNroSegment(NroSegmentType.Data, false).Read(0, Data);
}
}
}