From 56e633955308a67ea4593ed08003f3389495297b Mon Sep 17 00:00:00 2001 From: GreemDev Date: Sun, 31 Aug 2025 23:06:42 -0500 Subject: [PATCH] hle: cheats: Prevent NullRef and throw a TamperCompilationException instead for null base instruction byte arrays on the current block in EndConditionalBlock --- src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs | 4 ++-- .../HOS/Tamper/CodeEmitters/EndConditionalBlock.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs b/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs index ec41e9bd5..45cbf6c63 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs @@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Tamper Logger.Error?.Print(LogClass.TamperMachine, ex.ToString()); } - Logger.Error?.Print(LogClass.TamperMachine, "There was a problem while compiling the Atmosphere cheat"); + Logger.Error?.Print(LogClass.TamperMachine, $"There was a problem while compiling the Atmosphere cheat '{name}'"); return null; } @@ -126,7 +126,7 @@ namespace Ryujinx.HLE.HOS.Tamper DebugLog.Emit(instruction, context); break; default: - throw new TamperCompilationException($"Code type {codeType} not implemented in Atmosphere cheat"); + throw new TamperCompilationException($"Code type {codeType} not implemented in Atmosphere cheat compiler"); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs index 5eaed6530..cac469daa 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs @@ -40,7 +40,8 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters } // Use the conditional begin instruction stored in the stack. - byte[] upperInstruction = context.CurrentBlock.BaseInstruction; + byte[] upperInstruction = context.CurrentBlock.BaseInstruction + ?? throw new TamperCompilationException($"Base instruction in current block was null; termination type '{terminationType}'"); CodeType codeType = InstructionHelper.GetCodeType(upperInstruction); // Pop the current block of operations from the stack so control instructions