aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Loaders/Executables
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/Loaders/Executables')
-rw-r--r--Ryujinx.HLE/Loaders/Executables/IExecutable.cs4
-rw-r--r--Ryujinx.HLE/Loaders/Executables/KernelInitialProcess.cs154
-rw-r--r--Ryujinx.HLE/Loaders/Executables/NxRelocatableObject.cs80
-rw-r--r--Ryujinx.HLE/Loaders/Executables/NxStaticObject.cs132
4 files changed, 185 insertions, 185 deletions
diff --git a/Ryujinx.HLE/Loaders/Executables/IExecutable.cs b/Ryujinx.HLE/Loaders/Executables/IExecutable.cs
index d3eefde6..440e8f5f 100644
--- a/Ryujinx.HLE/Loaders/Executables/IExecutable.cs
+++ b/Ryujinx.HLE/Loaders/Executables/IExecutable.cs
@@ -3,11 +3,11 @@ namespace Ryujinx.HLE.Loaders.Executables
interface IExecutable
{
byte[] Text { get; }
- byte[] RO { get; }
+ byte[] Ro { get; }
byte[] Data { get; }
int TextOffset { get; }
- int ROOffset { get; }
+ int RoOffset { get; }
int DataOffset { get; }
int BssOffset { get; }
int BssSize { get; }
diff --git a/Ryujinx.HLE/Loaders/Executables/KernelInitialProcess.cs b/Ryujinx.HLE/Loaders/Executables/KernelInitialProcess.cs
index 1395d56f..d5ab2e8d 100644
--- a/Ryujinx.HLE/Loaders/Executables/KernelInitialProcess.cs
+++ b/Ryujinx.HLE/Loaders/Executables/KernelInitialProcess.cs
@@ -5,145 +5,145 @@ namespace Ryujinx.HLE.Loaders.Executables
{
class KernelInitialProcess : IExecutable
{
- public string Name { get; private set; }
+ public string Name { get; }
- public long TitleId { get; private set; }
+ public long TitleId { get; }
- public int ProcessCategory { get; private set; }
+ public int ProcessCategory { get; }
- public byte MainThreadPriority { get; private set; }
- public byte DefaultProcessorId { get; private set; }
+ public byte MainThreadPriority { get; }
+ public byte DefaultProcessorId { get; }
- public bool Is64Bits { get; private set; }
- public bool Addr39Bits { get; private set; }
- public bool IsService { get; private set; }
+ public bool Is64Bits { get; }
+ public bool Addr39Bits { get; }
+ public bool IsService { get; }
- public byte[] Text { get; private set; }
- public byte[] RO { get; private set; }
- public byte[] Data { get; private set; }
+ public byte[] Text { get; }
+ public byte[] Ro { get; }
+ public byte[] Data { get; }
- public int TextOffset { get; private set; }
- public int ROOffset { get; private set; }
- public int DataOffset { get; private set; }
- public int BssOffset { get; private set; }
- public int BssSize { get; private set; }
+ public int TextOffset { get; }
+ public int RoOffset { get; }
+ public int DataOffset { get; }
+ public int BssOffset { get; }
+ public int BssSize { get; }
- public int MainThreadStackSize { get; private set; }
+ public int MainThreadStackSize { get; }
- public int[] Capabilities { get; private set; }
+ public int[] Capabilities { get; }
private struct SegmentHeader
{
- public int Offset { get; private set; }
- public int DecompressedSize { get; private set; }
- public int CompressedSize { get; private set; }
- public int Attribute { get; private set; }
+ public int Offset { get; }
+ public int DecompressedSize { get; }
+ public int CompressedSize { get; }
+ public int Attribute { get; }
public SegmentHeader(
- int Offset,
- int DecompressedSize,
- int CompressedSize,
- int Attribute)
+ int offset,
+ int decompressedSize,
+ int compressedSize,
+ int attribute)
{
- this.Offset = Offset;
- this.DecompressedSize = DecompressedSize;
- this.CompressedSize = CompressedSize;
- this.Attribute = Attribute;
+ Offset = offset;
+ DecompressedSize = decompressedSize;
+ CompressedSize = compressedSize;
+ Attribute = attribute;
}
}
- public KernelInitialProcess(Stream Input)
+ public KernelInitialProcess(Stream input)
{
- BinaryReader Reader = new BinaryReader(Input);
+ BinaryReader reader = new BinaryReader(input);
- string Magic = ReadString(Reader, 4);
+ string magic = ReadString(reader, 4);
- if (Magic != "KIP1")
+ if (magic != "KIP1")
{
}
- Name = ReadString(Reader, 12);
+ Name = ReadString(reader, 12);
- TitleId = Reader.ReadInt64();
+ TitleId = reader.ReadInt64();
- ProcessCategory = Reader.ReadInt32();
+ ProcessCategory = reader.ReadInt32();
- MainThreadPriority = Reader.ReadByte();
- DefaultProcessorId = Reader.ReadByte();
+ MainThreadPriority = reader.ReadByte();
+ DefaultProcessorId = reader.ReadByte();
- byte Reserved = Reader.ReadByte();
- byte Flags = Reader.ReadByte();
+ byte reserved = reader.ReadByte();
+ byte flags = reader.ReadByte();
- Is64Bits = (Flags & 0x08) != 0;
- Addr39Bits = (Flags & 0x10) != 0;
- IsService = (Flags & 0x20) != 0;
+ Is64Bits = (flags & 0x08) != 0;
+ Addr39Bits = (flags & 0x10) != 0;
+ IsService = (flags & 0x20) != 0;
- SegmentHeader[] Segments = new SegmentHeader[6];
+ SegmentHeader[] segments = new SegmentHeader[6];
- for (int Index = 0; Index < Segments.Length; Index++)
+ for (int index = 0; index < segments.Length; index++)
{
- Segments[Index] = new SegmentHeader(
- Reader.ReadInt32(),
- Reader.ReadInt32(),
- Reader.ReadInt32(),
- Reader.ReadInt32());
+ segments[index] = new SegmentHeader(
+ reader.ReadInt32(),
+ reader.ReadInt32(),
+ reader.ReadInt32(),
+ reader.ReadInt32());
}
- TextOffset = Segments[0].Offset;
- ROOffset = Segments[1].Offset;
- DataOffset = Segments[2].Offset;
- BssOffset = Segments[3].Offset;
- BssSize = Segments[3].DecompressedSize;
+ TextOffset = segments[0].Offset;
+ RoOffset = segments[1].Offset;
+ DataOffset = segments[2].Offset;
+ BssOffset = segments[3].Offset;
+ BssSize = segments[3].DecompressedSize;
- MainThreadStackSize = Segments[1].Attribute;
+ MainThreadStackSize = segments[1].Attribute;
Capabilities = new int[8];
- for (int Index = 0; Index < Capabilities.Length; Index++)
+ for (int index = 0; index < Capabilities.Length; index++)
{
- Capabilities[Index] = Reader.ReadInt32();
+ Capabilities[index] = reader.ReadInt32();
}
- Input.Seek(0x100, SeekOrigin.Begin);
+ input.Seek(0x100, SeekOrigin.Begin);
- Text = ReadSegment(Segments[0], Input);
- RO = ReadSegment(Segments[1], Input);
- Data = ReadSegment(Segments[2], Input);
+ Text = ReadSegment(segments[0], input);
+ Ro = ReadSegment(segments[1], input);
+ Data = ReadSegment(segments[2], input);
}
- private byte[] ReadSegment(SegmentHeader Header, Stream Input)
+ private byte[] ReadSegment(SegmentHeader header, Stream input)
{
- long End = Input.Position + Header.CompressedSize;
+ long end = input.Position + header.CompressedSize;
- Input.Seek(End, SeekOrigin.Begin);
+ input.Seek(end, SeekOrigin.Begin);
- byte[] Data = BackwardsLz.Decompress(Input, Header.DecompressedSize);
+ byte[] data = BackwardsLz.Decompress(input, header.DecompressedSize);
- Input.Seek(End, SeekOrigin.Begin);
+ input.Seek(end, SeekOrigin.Begin);
- return Data;
+ return data;
}
- private static string ReadString(BinaryReader Reader, int MaxSize)
+ private static string ReadString(BinaryReader reader, int maxSize)
{
- string Value = string.Empty;
+ string value = string.Empty;
- for (int Index = 0; Index < MaxSize; Index++)
+ for (int index = 0; index < maxSize; index++)
{
- char Chr = (char)Reader.ReadByte();
+ char chr = (char)reader.ReadByte();
- if (Chr == '\0')
+ if (chr == '\0')
{
- Reader.BaseStream.Seek(MaxSize - Index - 1, SeekOrigin.Current);
+ reader.BaseStream.Seek(maxSize - index - 1, SeekOrigin.Current);
break;
}
- Value += Chr;
+ value += chr;
}
- return Value;
+ return value;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/Loaders/Executables/NxRelocatableObject.cs b/Ryujinx.HLE/Loaders/Executables/NxRelocatableObject.cs
index 20de5b5d..071a6fd9 100644
--- a/Ryujinx.HLE/Loaders/Executables/NxRelocatableObject.cs
+++ b/Ryujinx.HLE/Loaders/Executables/NxRelocatableObject.cs
@@ -4,61 +4,61 @@ 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 byte[] Text { get; }
+ public byte[] Ro { get; }
+ public byte[] Data { get; }
- 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 Mod0Offset { get; }
+ public int TextOffset { get; }
+ public int RoOffset { get; }
+ public int DataOffset { get; }
+ public int BssSize { get; }
public int BssOffset => DataOffset + Data.Length;
- public ulong SourceAddress { get; private set; }
- public ulong BssAddress { get; private set; }
+ public ulong SourceAddress { get; }
+ public ulong BssAddress { get; }
- public NxRelocatableObject(Stream Input, ulong SourceAddress = 0, ulong BssAddress = 0)
+ public NxRelocatableObject(Stream input, ulong sourceAddress = 0, ulong bssAddress = 0)
{
- this.SourceAddress = SourceAddress;
- this.BssAddress = BssAddress;
+ SourceAddress = sourceAddress;
+ BssAddress = bssAddress;
- BinaryReader Reader = new BinaryReader(Input);
+ BinaryReader reader = new BinaryReader(input);
- Input.Seek(4, SeekOrigin.Begin);
+ 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();
+ 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;
+ Mod0Offset = mod0Offset;
+ TextOffset = textOffset;
+ RoOffset = roOffset;
+ DataOffset = dataOffset;
+ BssSize = bssSize;
- byte[] Read(long Position, int Size)
+ byte[] Read(long position, int size)
{
- Input.Seek(Position, SeekOrigin.Begin);
+ input.Seek(position, SeekOrigin.Begin);
- return Reader.ReadBytes(Size);
+ return reader.ReadBytes(size);
}
- Text = Read(TextOffset, TextSize);
- RO = Read(ROOffset, ROSize);
- Data = Read(DataOffset, DataSize);
+ Text = Read(textOffset, textSize);
+ Ro = Read(roOffset, roSize);
+ Data = Read(dataOffset, dataSize);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/Loaders/Executables/NxStaticObject.cs b/Ryujinx.HLE/Loaders/Executables/NxStaticObject.cs
index 9fecb650..5509e865 100644
--- a/Ryujinx.HLE/Loaders/Executables/NxStaticObject.cs
+++ b/Ryujinx.HLE/Loaders/Executables/NxStaticObject.cs
@@ -6,14 +6,14 @@ namespace Ryujinx.HLE.Loaders.Executables
{
class NxStaticObject : IExecutable
{
- public byte[] Text { get; private set; }
- public byte[] RO { get; private set; }
- public byte[] Data { get; private set; }
+ public byte[] Text { get; }
+ public byte[] Ro { get; }
+ public byte[] Data { get; }
- 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 TextOffset { get; }
+ public int RoOffset { get; }
+ public int DataOffset { get; }
+ public int BssSize { get; }
public int BssOffset => DataOffset + Data.Length;
@@ -21,88 +21,88 @@ namespace Ryujinx.HLE.Loaders.Executables
private enum NsoFlags
{
IsTextCompressed = 1 << 0,
- IsROCompressed = 1 << 1,
+ IsRoCompressed = 1 << 1,
IsDataCompressed = 1 << 2,
HasTextHash = 1 << 3,
- HasROHash = 1 << 4,
+ HasRoHash = 1 << 4,
HasDataHash = 1 << 5
}
- public NxStaticObject(Stream Input)
+ public NxStaticObject(Stream input)
{
- BinaryReader Reader = new BinaryReader(Input);
-
- Input.Seek(0, SeekOrigin.Begin);
-
- int NsoMagic = Reader.ReadInt32();
- int Version = Reader.ReadInt32();
- int Reserved = Reader.ReadInt32();
- int FlagsMsk = Reader.ReadInt32();
- int TextOffset = Reader.ReadInt32();
- int TextMemOffset = Reader.ReadInt32();
- int TextDecSize = Reader.ReadInt32();
- int ModNameOffset = Reader.ReadInt32();
- int ROOffset = Reader.ReadInt32();
- int ROMemOffset = Reader.ReadInt32();
- int RODecSize = Reader.ReadInt32();
- int ModNameSize = Reader.ReadInt32();
- int DataOffset = Reader.ReadInt32();
- int DataMemOffset = Reader.ReadInt32();
- int DataDecSize = Reader.ReadInt32();
- int BssSize = Reader.ReadInt32();
-
- byte[] BuildId = Reader.ReadBytes(0x20);
-
- int TextSize = Reader.ReadInt32();
- int ROSize = Reader.ReadInt32();
- int DataSize = Reader.ReadInt32();
-
- Input.Seek(0x24, SeekOrigin.Current);
-
- int DynStrOffset = Reader.ReadInt32();
- int DynStrSize = Reader.ReadInt32();
- int DynSymOffset = Reader.ReadInt32();
- int DynSymSize = Reader.ReadInt32();
-
- byte[] TextHash = Reader.ReadBytes(0x20);
- byte[] ROHash = Reader.ReadBytes(0x20);
- byte[] DataHash = Reader.ReadBytes(0x20);
-
- NsoFlags Flags = (NsoFlags)FlagsMsk;
-
- this.TextOffset = TextMemOffset;
- this.ROOffset = ROMemOffset;
- this.DataOffset = DataMemOffset;
- this.BssSize = BssSize;
+ BinaryReader reader = new BinaryReader(input);
+
+ input.Seek(0, SeekOrigin.Begin);
+
+ int nsoMagic = reader.ReadInt32();
+ int version = reader.ReadInt32();
+ int reserved = reader.ReadInt32();
+ int flagsMsk = reader.ReadInt32();
+ int textOffset = reader.ReadInt32();
+ int textMemOffset = reader.ReadInt32();
+ int textDecSize = reader.ReadInt32();
+ int modNameOffset = reader.ReadInt32();
+ int roOffset = reader.ReadInt32();
+ int roMemOffset = reader.ReadInt32();
+ int roDecSize = reader.ReadInt32();
+ int modNameSize = reader.ReadInt32();
+ int dataOffset = reader.ReadInt32();
+ int dataMemOffset = reader.ReadInt32();
+ int dataDecSize = reader.ReadInt32();
+ int bssSize = reader.ReadInt32();
+
+ byte[] buildId = reader.ReadBytes(0x20);
+
+ int textSize = reader.ReadInt32();
+ int roSize = reader.ReadInt32();
+ int dataSize = reader.ReadInt32();
+
+ input.Seek(0x24, SeekOrigin.Current);
+
+ int dynStrOffset = reader.ReadInt32();
+ int dynStrSize = reader.ReadInt32();
+ int dynSymOffset = reader.ReadInt32();
+ int dynSymSize = reader.ReadInt32();
+
+ byte[] textHash = reader.ReadBytes(0x20);
+ byte[] roHash = reader.ReadBytes(0x20);
+ byte[] dataHash = reader.ReadBytes(0x20);
+
+ NsoFlags flags = (NsoFlags)flagsMsk;
+
+ TextOffset = textMemOffset;
+ RoOffset = roMemOffset;
+ DataOffset = dataMemOffset;
+ BssSize = bssSize;
//Text segment
- Input.Seek(TextOffset, SeekOrigin.Begin);
+ input.Seek(textOffset, SeekOrigin.Begin);
- Text = Reader.ReadBytes(TextSize);
+ Text = reader.ReadBytes(textSize);
- if (Flags.HasFlag(NsoFlags.IsTextCompressed))
+ if (flags.HasFlag(NsoFlags.IsTextCompressed))
{
- Text = Lz4.Decompress(Text, TextDecSize);
+ Text = Lz4.Decompress(Text, textDecSize);
}
//Read-only data segment
- Input.Seek(ROOffset, SeekOrigin.Begin);
+ input.Seek(roOffset, SeekOrigin.Begin);
- RO = Reader.ReadBytes(ROSize);
+ Ro = reader.ReadBytes(roSize);
- if (Flags.HasFlag(NsoFlags.IsROCompressed))
+ if (flags.HasFlag(NsoFlags.IsRoCompressed))
{
- RO = Lz4.Decompress(RO, RODecSize);
+ Ro = Lz4.Decompress(Ro, roDecSize);
}
//Data segment
- Input.Seek(DataOffset, SeekOrigin.Begin);
+ input.Seek(dataOffset, SeekOrigin.Begin);
- Data = Reader.ReadBytes(DataSize);
+ Data = reader.ReadBytes(dataSize);
- if (Flags.HasFlag(NsoFlags.IsDataCompressed))
+ if (flags.HasFlag(NsoFlags.IsDataCompressed))
{
- Data = Lz4.Decompress(Data, DataDecSize);
+ Data = Lz4.Decompress(Data, dataDecSize);
}
}
}