diff options
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Tamper/MemoryHelper.cs')
-rw-r--r-- | src/Ryujinx.HLE/HOS/Tamper/MemoryHelper.cs | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/Ryujinx.HLE/HOS/Tamper/MemoryHelper.cs b/src/Ryujinx.HLE/HOS/Tamper/MemoryHelper.cs index 1260ed9a..52e12bfe 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/MemoryHelper.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/MemoryHelper.cs @@ -7,23 +7,18 @@ namespace Ryujinx.HLE.HOS.Tamper { public static ulong GetAddressShift(MemoryRegion source, CompilationContext context) { - switch (source) + return source switch { - case MemoryRegion.NSO: - // Memory address is relative to the code start. - return context.ExeAddress; - case MemoryRegion.Heap: - // Memory address is relative to the heap. - return context.HeapAddress; - case MemoryRegion.Alias: - // Memory address is relative to the alias region. - return context.AliasAddress; - case MemoryRegion.Asrl: - // Memory address is relative to the asrl region, which matches the code region. - return context.AslrAddress; - default: - throw new TamperCompilationException($"Invalid memory source {source} in Atmosphere cheat"); - } + // Memory address is relative to the code start. + MemoryRegion.NSO => context.ExeAddress, + // Memory address is relative to the heap. + MemoryRegion.Heap => context.HeapAddress, + // Memory address is relative to the alias region. + MemoryRegion.Alias => context.AliasAddress, + // Memory address is relative to the asrl region, which matches the code region. + MemoryRegion.Asrl => context.AslrAddress, + _ => throw new TamperCompilationException($"Invalid memory source {source} in Atmosphere cheat"), + }; } private static void EmitAdd(Value<ulong> finalValue, IOperand firstOperand, IOperand secondOperand, CompilationContext context) @@ -33,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Tamper public static Pointer EmitPointer(ulong addressImmediate, CompilationContext context) { - Value<ulong> addressImmediateValue = new Value<ulong>(addressImmediate); + Value<ulong> addressImmediateValue = new(addressImmediate); return new Pointer(addressImmediateValue, context.Process); } @@ -45,8 +40,8 @@ namespace Ryujinx.HLE.HOS.Tamper public static Pointer EmitPointer(Register addressRegister, ulong offsetImmediate, CompilationContext context) { - Value<ulong> offsetImmediateValue = new Value<ulong>(offsetImmediate); - Value<ulong> finalAddressValue = new Value<ulong>(0); + Value<ulong> offsetImmediateValue = new(offsetImmediate); + Value<ulong> finalAddressValue = new(0); EmitAdd(finalAddressValue, addressRegister, offsetImmediateValue, context); return new Pointer(finalAddressValue, context.Process); @@ -54,7 +49,7 @@ namespace Ryujinx.HLE.HOS.Tamper public static Pointer EmitPointer(Register addressRegister, Register offsetRegister, CompilationContext context) { - Value<ulong> finalAddressValue = new Value<ulong>(0); + Value<ulong> finalAddressValue = new(0); EmitAdd(finalAddressValue, addressRegister, offsetRegister, context); return new Pointer(finalAddressValue, context.Process); @@ -62,10 +57,10 @@ namespace Ryujinx.HLE.HOS.Tamper public static Pointer EmitPointer(Register addressRegister, Register offsetRegister, ulong offsetImmediate, CompilationContext context) { - Value<ulong> offsetImmediateValue = new Value<ulong>(offsetImmediate); - Value<ulong> finalOffsetValue = new Value<ulong>(0); + Value<ulong> offsetImmediateValue = new(offsetImmediate); + Value<ulong> finalOffsetValue = new(0); EmitAdd(finalOffsetValue, offsetRegister, offsetImmediateValue, context); - Value<ulong> finalAddressValue = new Value<ulong>(0); + Value<ulong> finalAddressValue = new(0); EmitAdd(finalAddressValue, addressRegister, finalOffsetValue, context); return new Pointer(finalAddressValue, context.Process); |