diff options
Diffstat (limited to 'Ryujinx.HLE/Loaders')
| -rw-r--r-- | Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs | 9 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Elf/ElfSymbol32.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Elf/ElfSymbol64.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Executables/KipExecutable.cs | 44 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs | 8 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs | 53 | ||||
| -rw-r--r-- | Ryujinx.HLE/Loaders/Mods/MemPatch.cs | 8 |
8 files changed, 63 insertions, 69 deletions
diff --git a/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs b/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs index 9961afe1..1cfc0bdc 100644 --- a/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs +++ b/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs @@ -8,13 +8,8 @@ namespace Ryujinx.HLE.Loaders.Elf public ElfSymbolBinding Binding { get; private set; } public ElfSymbolVisibility Visibility { get; private set; } - public bool IsFuncOrObject => - Type == ElfSymbolType.SttFunc || - Type == ElfSymbolType.SttObject; - - public bool IsGlobalOrWeak => - Binding == ElfSymbolBinding.StbGlobal || - Binding == ElfSymbolBinding.StbWeak; + public bool IsFuncOrObject => Type == ElfSymbolType.SttFunc || Type == ElfSymbolType.SttObject; + public bool IsGlobalOrWeak => Binding == ElfSymbolBinding.StbGlobal || Binding == ElfSymbolBinding.StbWeak; public int ShIdx { get; private set; } public ulong Value { get; private set; } diff --git a/Ryujinx.HLE/Loaders/Elf/ElfSymbol32.cs b/Ryujinx.HLE/Loaders/Elf/ElfSymbol32.cs index 2b25d044..2f84796b 100644 --- a/Ryujinx.HLE/Loaders/Elf/ElfSymbol32.cs +++ b/Ryujinx.HLE/Loaders/Elf/ElfSymbol32.cs @@ -11,4 +11,4 @@ public ushort SectionIndex; #pragma warning restore CS0649 } -} +}
\ No newline at end of file diff --git a/Ryujinx.HLE/Loaders/Elf/ElfSymbol64.cs b/Ryujinx.HLE/Loaders/Elf/ElfSymbol64.cs index acbd2191..665e65b0 100644 --- a/Ryujinx.HLE/Loaders/Elf/ElfSymbol64.cs +++ b/Ryujinx.HLE/Loaders/Elf/ElfSymbol64.cs @@ -11,4 +11,4 @@ public ulong Size; #pragma warning restore CS0649 } -} +}
\ No newline at end of file diff --git a/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs b/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs index 12730cd3..fe88f691 100644 --- a/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs +++ b/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs @@ -12,25 +12,25 @@ namespace Ryujinx.HLE.Loaders.Executables public Span<byte> Data => Program.AsSpan().Slice((int)DataOffset, (int)DataSize); public uint TextOffset { get; } - public uint RoOffset { get; } + public uint RoOffset { get; } public uint DataOffset { get; } - public uint BssOffset { get; } + public uint BssOffset { get; } public uint TextSize { get; } - public uint RoSize { get; } + public uint RoSize { get; } public uint DataSize { get; } - public uint BssSize { get; } + public uint BssSize { get; } - public int[] Capabilities { get; } - public bool UsesSecureMemory { get; } + public int[] Capabilities { get; } + public bool UsesSecureMemory { get; } public bool Is64BitAddressSpace { get; } - public bool Is64Bit { get; } - public ulong ProgramId { get; } - public byte Priority { get; } - public int StackSize { get; } - public byte IdealCoreId { get; } - public int Version { get; } - public string Name { get; } + public bool Is64Bit { get; } + public ulong ProgramId { get; } + public byte Priority { get; } + public int StackSize { get; } + public byte IdealCoreId { get; } + public int Version { get; } + public string Name { get; } public KipExecutable(IStorage inStorage) { @@ -39,22 +39,22 @@ namespace Ryujinx.HLE.Loaders.Executables reader.Initialize(inStorage).ThrowIfFailure(); TextOffset = (uint)reader.Segments[0].MemoryOffset; - RoOffset = (uint)reader.Segments[1].MemoryOffset; + RoOffset = (uint)reader.Segments[1].MemoryOffset; DataOffset = (uint)reader.Segments[2].MemoryOffset; - BssOffset = (uint)reader.Segments[3].MemoryOffset; - BssSize = (uint)reader.Segments[3].Size; + BssOffset = (uint)reader.Segments[3].MemoryOffset; + BssSize = (uint)reader.Segments[3].Size; StackSize = reader.StackSize; - UsesSecureMemory = reader.UsesSecureMemory; + UsesSecureMemory = reader.UsesSecureMemory; Is64BitAddressSpace = reader.Is64BitAddressSpace; - Is64Bit = reader.Is64Bit; + Is64Bit = reader.Is64Bit; - ProgramId = reader.ProgramId; - Priority = reader.Priority; + ProgramId = reader.ProgramId; + Priority = reader.Priority; IdealCoreId = reader.IdealCoreId; - Version = reader.Version; - Name = reader.Name.ToString(); + Version = reader.Version; + Name = reader.Name.ToString(); Capabilities = new int[32]; diff --git a/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs b/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs index 20502c11..285ce7e6 100644 --- a/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs +++ b/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs @@ -17,14 +17,14 @@ namespace Ryujinx.HLE.Loaders.Executables public Span<byte> Data => Program.AsSpan().Slice((int)DataOffset, (int)DataSize); public uint TextOffset { get; } - public uint RoOffset { get; } + public uint RoOffset { get; } public uint DataOffset { get; } public uint BssOffset => DataOffset + (uint)Data.Length; public uint TextSize { get; } - public uint RoSize { get; } + public uint RoSize { get; } public uint DataSize { get; } - public uint BssSize { get; } + public uint BssSize { get; } public string Name; public Buffer32 BuildId; diff --git a/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs b/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs index 11c7f04c..de50c6eb 100644 --- a/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs +++ b/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs @@ -20,10 +20,10 @@ namespace Ryujinx.HLE.Loaders.Mods private static MemPatch ParseIps(BinaryReader reader) { - Span<byte> IpsHeaderMagic = Encoding.ASCII.GetBytes("PATCH").AsSpan(); - Span<byte> IpsTailMagic = Encoding.ASCII.GetBytes("EOF").AsSpan(); + Span<byte> IpsHeaderMagic = Encoding.ASCII.GetBytes("PATCH").AsSpan(); + Span<byte> IpsTailMagic = Encoding.ASCII.GetBytes("EOF").AsSpan(); Span<byte> Ips32HeaderMagic = Encoding.ASCII.GetBytes("IPS32").AsSpan(); - Span<byte> Ips32TailMagic = Encoding.ASCII.GetBytes("EEOF").AsSpan(); + Span<byte> Ips32TailMagic = Encoding.ASCII.GetBytes("EEOF").AsSpan(); MemPatch patches = new MemPatch(); var header = reader.ReadBytes(IpsHeaderMagic.Length).AsSpan(); @@ -68,7 +68,7 @@ namespace Ryujinx.HLE.Loaders.Mods } int patchOffset = is32 ? buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] - : buf[0] << 16 | buf[1] << 8 | buf[2]; + : buf[0] << 16 | buf[1] << 8 | buf[2]; if (ReadNext(2)) { diff --git a/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs b/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs index abe59dde..f0a32f86 100644 --- a/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs +++ b/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs @@ -7,11 +7,19 @@ namespace Ryujinx.HLE.Loaders.Mods { class IPSwitchPatcher { - readonly StreamReader _reader; - public string BuildId { get; } - const string BidHeader = "@nsobid-"; + private enum Token + { + Normal, + String, + EscapeChar, + Comment + } + + private readonly StreamReader _reader; + public string BuildId { get; } + public IPSwitchPatcher(StreamReader reader) { string header = reader.ReadLine(); @@ -26,14 +34,6 @@ namespace Ryujinx.HLE.Loaders.Mods BuildId = header.Substring(BidHeader.Length).TrimEnd().TrimEnd('0'); } - private enum Token - { - Normal, - String, - EscapeChar, - Comment - } - // Uncomments line and unescapes C style strings within private static string PreprocessLine(string line) { @@ -56,24 +56,24 @@ namespace Ryujinx.HLE.Loaders.Mods case Token.String: state = c switch { - '"' => Token.Normal, + '"' => Token.Normal, '\\' => Token.EscapeChar, - _ => Token.String + _ => Token.String }; break; case Token.EscapeChar: state = Token.String; c = c switch { - 'a' => '\a', - 'b' => '\b', - 'f' => '\f', - 'n' => '\n', - 'r' => '\r', - 't' => '\t', - 'v' => '\v', + 'a' => '\a', + 'b' => '\b', + 'f' => '\f', + 'n' => '\n', + 'r' => '\r', + 't' => '\t', + 'v' => '\v', '\\' => '\\', - _ => '?' + _ => '?' }; break; } @@ -119,7 +119,8 @@ namespace Ryujinx.HLE.Loaders.Mods for (int i = 0; i < hexstr.Length; i += 2) { int high = ParseHexByte((byte)hexstr[i]); - int low = ParseHexByte((byte)hexstr[i + 1]); + int low = ParseHexByte((byte)hexstr[i + 1]); + bytes[i >> 1] = (byte)((high << 4) | low); } @@ -131,11 +132,11 @@ namespace Ryujinx.HLE.Loaders.Mods { if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) { - return Int32.TryParse(str.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out value); + return int.TryParse(str.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out value); } else { - return Int32.TryParse(str, System.Globalization.NumberStyles.Integer, null, out value); + return int.TryParse(str, System.Globalization.NumberStyles.Integer, null, out value); } } @@ -148,7 +149,7 @@ namespace Ryujinx.HLE.Loaders.Mods MemPatch patches = new MemPatch(); - bool enabled = false; + bool enabled = false; bool printValues = false; int offset_shift = 0; @@ -236,7 +237,7 @@ namespace Ryujinx.HLE.Loaders.Mods continue; } - if (!Int32.TryParse(tokens[0], System.Globalization.NumberStyles.HexNumber, null, out int offset)) + if (!int.TryParse(tokens[0], System.Globalization.NumberStyles.HexNumber, null, out int offset)) { ParseWarn(); diff --git a/Ryujinx.HLE/Loaders/Mods/MemPatch.cs b/Ryujinx.HLE/Loaders/Mods/MemPatch.cs index 8b2dcb49..e224c3ef 100644 --- a/Ryujinx.HLE/Loaders/Mods/MemPatch.cs +++ b/Ryujinx.HLE/Loaders/Mods/MemPatch.cs @@ -1,10 +1,8 @@ -using Ryujinx.Cpu; +using Ryujinx.Common.Logging; using System; using System.Collections.Generic; using System.Linq; -using Ryujinx.Common.Logging; - namespace Ryujinx.HLE.Loaders.Mods { public class MemPatch @@ -71,7 +69,7 @@ namespace Ryujinx.HLE.Loaders.Mods foreach (var (offset, patch) in _patches.OrderBy(item => item.Key)) { int patchOffset = (int)offset; - int patchSize = patch.Length; + int patchSize = patch.Length; if (patchOffset < protectedOffset || patchOffset > memory.Length) { @@ -82,7 +80,7 @@ namespace Ryujinx.HLE.Loaders.Mods if (patchOffset + patchSize > memory.Length) { - patchSize = memory.Length - (int)patchOffset; // Add warning? + patchSize = memory.Length - patchOffset; // Add warning? } Logger.Info?.Print(LogClass.ModLoader, $"Patching address offset {patchOffset:x} <= {BitConverter.ToString(patch).Replace('-', ' ')} len={patchSize}"); |
