aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/Loaders/Executables/KipExecutable.cs')
-rw-r--r--Ryujinx.HLE/Loaders/Executables/KipExecutable.cs30
1 files changed, 19 insertions, 11 deletions
diff --git a/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs b/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs
index 0f1309c0..a44b7c48 100644
--- a/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs
+++ b/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs
@@ -1,18 +1,24 @@
using LibHac.Fs;
using LibHac.Loader;
+using System;
namespace Ryujinx.HLE.Loaders.Executables
{
class KipExecutable : IExecutable
{
- public byte[] Text { get; }
- public byte[] Ro { get; }
- public byte[] Data { get; }
+ public byte[] Program { get; }
+ public Span<byte> Text => Program.AsSpan().Slice(TextOffset, TextSize);
+ public Span<byte> Ro => Program.AsSpan().Slice(RoOffset, RoSize);
+ public Span<byte> Data => Program.AsSpan().Slice(DataOffset, DataSize);
public int TextOffset { get; }
public int RoOffset { get; }
public int DataOffset { get; }
public int BssOffset { get; }
+
+ public int TextSize { get; }
+ public int RoSize { get; }
+ public int DataSize { get; }
public int BssSize { get; }
public int[] Capabilities { get; }
@@ -25,7 +31,6 @@ namespace Ryujinx.HLE.Loaders.Executables
public byte IdealCoreId { get; }
public int Version { get; }
public string Name { get; }
-
public KipExecutable(IStorage inStorage)
{
KipReader reader = new KipReader();
@@ -57,20 +62,23 @@ namespace Ryujinx.HLE.Loaders.Executables
Capabilities[index] = (int)reader.Capabilities[index];
}
- Text = DecompressSection(reader, KipReader.SegmentType.Text);
- Ro = DecompressSection(reader, KipReader.SegmentType.Ro);
- Data = DecompressSection(reader, KipReader.SegmentType.Data);
+ reader.GetSegmentSize(KipReader.SegmentType.Data, out int uncompressedSize).ThrowIfFailure();
+ Program = new byte[DataOffset + uncompressedSize];
+
+ TextSize = DecompressSection(reader, KipReader.SegmentType.Text, TextOffset, Program);
+ RoSize = DecompressSection(reader, KipReader.SegmentType.Ro, RoOffset, Program);
+ DataSize = DecompressSection(reader, KipReader.SegmentType.Data, DataOffset, Program);
}
- private static byte[] DecompressSection(KipReader reader, KipReader.SegmentType segmentType)
+ private static int DecompressSection(KipReader reader, KipReader.SegmentType segmentType, int offset, byte[] Program)
{
reader.GetSegmentSize(segmentType, out int uncompressedSize).ThrowIfFailure();
- byte[] result = new byte[uncompressedSize];
+ var span = Program.AsSpan().Slice(offset, uncompressedSize);
- reader.ReadSegment(segmentType, result).ThrowIfFailure();
+ reader.ReadSegment(segmentType, span).ThrowIfFailure();
- return result;
+ return uncompressedSize;
}
}
} \ No newline at end of file