diff options
| author | Caian Benedicto <caianbene@gmail.com> | 2021-08-04 17:05:17 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-04 22:05:17 +0200 |
| commit | ff8849671af5ac14fc9cc9d37da30f53d3f13d89 (patch) | |
| tree | 636e4e249084b20b871c158fdb8ff4f2b03f36e0 /Ryujinx.HLE/HOS/TamperMachine.cs | |
| parent | a27986c31167d8ce60efcee7e901da241f63ed08 (diff) | |
Update TamperMachine and disable write-to-code prevention (#2506)
* Enable write to memory and improve logging
* Update tamper machine opcodes and improve reporting
* Add Else support
* Add missing private statement
Diffstat (limited to 'Ryujinx.HLE/HOS/TamperMachine.cs')
| -rw-r--r-- | Ryujinx.HLE/HOS/TamperMachine.cs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Ryujinx.HLE/HOS/TamperMachine.cs b/Ryujinx.HLE/HOS/TamperMachine.cs index 9cdea94a..6044368e 100644 --- a/Ryujinx.HLE/HOS/TamperMachine.cs +++ b/Ryujinx.HLE/HOS/TamperMachine.cs @@ -31,7 +31,7 @@ namespace Ryujinx.HLE.HOS } } - internal void InstallAtmosphereCheat(IEnumerable<string> rawInstructions, ProcessTamperInfo info, ulong exeAddress) + internal void InstallAtmosphereCheat(string name, IEnumerable<string> rawInstructions, ProcessTamperInfo info, ulong exeAddress) { if (!CanInstallOnPid(info.Process.Pid)) { @@ -39,11 +39,13 @@ namespace Ryujinx.HLE.HOS } ITamperedProcess tamperedProcess = new TamperedKProcess(info.Process); - AtmosphereCompiler compiler = new AtmosphereCompiler(); - ITamperProgram program = compiler.Compile(rawInstructions, exeAddress, info.HeapAddress, tamperedProcess); + AtmosphereCompiler compiler = new AtmosphereCompiler(exeAddress, info.HeapAddress, info.AliasAddress, info.AslrAddress, tamperedProcess); + ITamperProgram program = compiler.Compile(name, rawInstructions); if (program != null) { + program.TampersCodeMemory = false; + _programs.Enqueue(program); } @@ -116,27 +118,27 @@ namespace Ryujinx.HLE.HOS // Re-enqueue the tampering program because the process is still valid. _programs.Enqueue(program); - Logger.Debug?.Print(LogClass.TamperMachine, "Running tampering program"); + Logger.Debug?.Print(LogClass.TamperMachine, $"Running tampering program {program.Name}"); try { ControllerKeys pressedKeys = (ControllerKeys)Thread.VolatileRead(ref _pressedKeys); + program.Process.TamperedCodeMemory = false; program.Execute(pressedKeys); - } - catch (CodeRegionTamperedException ex) - { - Logger.Debug?.Print(LogClass.TamperMachine, $"Prevented tampering program from modifing code memory"); - if (!String.IsNullOrEmpty(ex.Message)) + // Detect the first attempt to tamper memory and log it. + if (!program.TampersCodeMemory && program.Process.TamperedCodeMemory) { - Logger.Debug?.Print(LogClass.TamperMachine, ex.Message); + program.TampersCodeMemory = true; + + Logger.Warning?.Print(LogClass.TamperMachine, $"Tampering program {program.Name} modifies code memory so it may not work properly"); } } catch (Exception ex) { - Logger.Debug?.Print(LogClass.TamperMachine, $"The tampering program crashed, this can happen while the game is starting"); + Logger.Debug?.Print(LogClass.TamperMachine, $"The tampering program {program.Name} crashed, this can happen while the game is starting"); - if (!String.IsNullOrEmpty(ex.Message)) + if (!string.IsNullOrEmpty(ex.Message)) { Logger.Debug?.Print(LogClass.TamperMachine, ex.Message); } |
