mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
Move AntiDebug to xivfixes (#2264)
* Move AntiDebug to xivfixes * Update BootEnabledGameFixes * Check BootEnabledGameFixes * Apply suggestions from code review Co-authored-by: KazWolfe <KazWolfe@users.noreply.github.com> --------- Co-authored-by: KazWolfe <KazWolfe@users.noreply.github.com>
This commit is contained in:
parent
4dce0c00e8
commit
33605e3ace
6 changed files with 45 additions and 121 deletions
|
|
@ -284,11 +284,6 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
|
|||
/// </summary>
|
||||
public bool IsFocusManagementEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the anti-anti-debug check is enabled on startup.
|
||||
/// </summary>
|
||||
public bool IsAntiAntiDebugEnabled { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to resume game main thread after plugins load.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Dalamud.Utility;
|
||||
|
||||
#if !DEBUG
|
||||
using Dalamud.Configuration.Internal;
|
||||
#endif
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Game.Internal;
|
||||
|
||||
/// <summary>
|
||||
/// This class disables anti-debug functionality in the game client.
|
||||
/// </summary>
|
||||
[ServiceManager.EarlyLoadedService]
|
||||
internal sealed class AntiDebug : IInternalDisposableService
|
||||
{
|
||||
private readonly byte[] nop = [0x31, 0xC0, 0x90, 0x90, 0x90, 0x90];
|
||||
private byte[]? original;
|
||||
private IntPtr debugCheckAddress;
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private AntiDebug(TargetSigScanner sigScanner)
|
||||
{
|
||||
try
|
||||
{
|
||||
// This sig has to be the call site in Framework_Tick
|
||||
this.debugCheckAddress = sigScanner.ScanText("FF 15 ?? ?? ?? ?? 85 C0 74 13 41");
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
this.debugCheckAddress = IntPtr.Zero;
|
||||
}
|
||||
|
||||
Log.Verbose($"Debug check address {Util.DescribeAddress(this.debugCheckAddress)}");
|
||||
|
||||
if (!this.IsEnabled)
|
||||
{
|
||||
#if DEBUG
|
||||
this.Enable();
|
||||
#else
|
||||
if (Service<DalamudConfiguration>.Get().IsAntiAntiDebugEnabled)
|
||||
this.Enable();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Finalizes an instance of the <see cref="AntiDebug"/> class.</summary>
|
||||
~AntiDebug() => ((IInternalDisposableService)this).DisposeService();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the anti-debugging is enabled.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; private set; } = false;
|
||||
|
||||
/// <inheritdoc />
|
||||
void IInternalDisposableService.DisposeService() => this.Disable();
|
||||
|
||||
/// <summary>
|
||||
/// Enables the anti-debugging by overwriting code in memory.
|
||||
/// </summary>
|
||||
public void Enable()
|
||||
{
|
||||
if (this.IsEnabled)
|
||||
return;
|
||||
|
||||
this.original = new byte[this.nop.Length];
|
||||
if (this.debugCheckAddress != IntPtr.Zero && !this.IsEnabled)
|
||||
{
|
||||
Log.Information($"Overwriting debug check at {Util.DescribeAddress(this.debugCheckAddress)}");
|
||||
SafeMemory.ReadBytes(this.debugCheckAddress, this.nop.Length, out this.original);
|
||||
SafeMemory.WriteBytes(this.debugCheckAddress, this.nop);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Information("Debug check already overwritten?");
|
||||
}
|
||||
|
||||
this.IsEnabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable the anti-debugging by reverting the overwritten code in memory.
|
||||
/// </summary>
|
||||
public void Disable()
|
||||
{
|
||||
if (!this.IsEnabled)
|
||||
return;
|
||||
|
||||
if (this.debugCheckAddress != IntPtr.Zero && this.original != null)
|
||||
{
|
||||
Log.Information($"Reverting debug check at {Util.DescribeAddress(this.debugCheckAddress)}");
|
||||
SafeMemory.WriteBytes(this.debugCheckAddress, this.original);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Information("Debug check was not overwritten?");
|
||||
}
|
||||
|
||||
this.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ using Dalamud.Game.ClientState;
|
|||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Internal;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Interface.Animation.EasingFunctions;
|
||||
using Dalamud.Interface.Colors;
|
||||
|
|
@ -719,19 +718,6 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
this.dalamud.StartInfo.LogName);
|
||||
}
|
||||
|
||||
var antiDebug = Service<AntiDebug>.Get();
|
||||
if (ImGui.MenuItem("Disable Debugging Protections", null, antiDebug.IsEnabled))
|
||||
{
|
||||
var newEnabled = !antiDebug.IsEnabled;
|
||||
if (newEnabled)
|
||||
antiDebug.Enable();
|
||||
else
|
||||
antiDebug.Disable();
|
||||
|
||||
this.configuration.IsAntiAntiDebugEnabled = newEnabled;
|
||||
this.configuration.QueueSave();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.MenuItem("Open Data window"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue