From 090da41ff19781688ffa6850d128eca081e6fc5f Mon Sep 17 00:00:00 2001 From: Philpax Date: Sun, 11 Jul 2021 00:21:19 +0200 Subject: [PATCH] AntiDebug: persist state in config --- Dalamud/Configuration/DalamudConfiguration.cs | 5 +++++ Dalamud/Dalamud.cs | 5 ++++- Dalamud/Game/Internal/AntiDebug.cs | 2 +- Dalamud/Interface/DalamudInterface.cs | 9 ++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dalamud/Configuration/DalamudConfiguration.cs b/Dalamud/Configuration/DalamudConfiguration.cs index cb2ffa1ce..aec7cfe16 100644 --- a/Dalamud/Configuration/DalamudConfiguration.cs +++ b/Dalamud/Configuration/DalamudConfiguration.cs @@ -138,6 +138,11 @@ namespace Dalamud.Configuration /// public bool IsGamepadNavigationEnabled { get; set; } = true; + /// + /// Gets or sets a value indicating whether or not the anti-anti-debug check is enabled on startup. + /// + public bool IsAntiAntiDebugEnabled { get; set; } = false; + /// /// Load a configuration from the provided path. /// diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 7c98e6a8e..3b0638053 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -229,8 +229,11 @@ namespace Dalamud this.Configuration = DalamudConfiguration.Load(this.StartInfo.ConfigurationPath); this.AntiDebug = new AntiDebug(this.SigScanner); + if (this.Configuration.IsAntiAntiDebugEnabled) + this.AntiDebug.Enable(); #if DEBUG - this.AntiDebug.Enable(); + if (!this.AntiDebug.IsEnabled) + this.AntiDebug.Enable(); #endif Log.Information("[T2] AntiDebug OK!"); diff --git a/Dalamud/Game/Internal/AntiDebug.cs b/Dalamud/Game/Internal/AntiDebug.cs index 04b107458..b7ca43b86 100644 --- a/Dalamud/Game/Internal/AntiDebug.cs +++ b/Dalamud/Game/Internal/AntiDebug.cs @@ -35,7 +35,7 @@ namespace Dalamud.Game.Internal /// /// Gets a value indicating whether the anti-debugging is enabled. /// - public bool IsEnabled { get; private set; } + public bool IsEnabled { get; private set; } = false; /// /// Enables the anti-debugging by overwriting code in memory. diff --git a/Dalamud/Interface/DalamudInterface.cs b/Dalamud/Interface/DalamudInterface.cs index 30f1534f5..8ac21a29a 100644 --- a/Dalamud/Interface/DalamudInterface.cs +++ b/Dalamud/Interface/DalamudInterface.cs @@ -198,7 +198,14 @@ namespace Dalamud.Interface if (ImGui.MenuItem("Enable AntiDebug", null, this.dalamud.AntiDebug.IsEnabled)) { - this.dalamud.AntiDebug.Enable(); + var newEnabled = !this.dalamud.AntiDebug.IsEnabled; + if (newEnabled) + this.dalamud.AntiDebug.Enable(); + else + this.dalamud.AntiDebug.Disable(); + + this.dalamud.Configuration.IsAntiAntiDebugEnabled = newEnabled; + this.dalamud.Configuration.Save(); } ImGui.Separator();