mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-22 00:19:18 +01:00
feat: add Cara AllowDebug in debug mode
This commit is contained in:
parent
969e935f27
commit
6dab2b7ab1
2 changed files with 50 additions and 20 deletions
|
|
@ -11,7 +11,6 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CheapLoc;
|
using CheapLoc;
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.DiscordBot;
|
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.Chat;
|
using Dalamud.Game.Chat;
|
||||||
using Dalamud.Game.Chat.SeStringHandling;
|
using Dalamud.Game.Chat.SeStringHandling;
|
||||||
|
|
@ -44,7 +43,7 @@ namespace Dalamud {
|
||||||
|
|
||||||
public NetworkHandlers NetworkHandlers { get; private set; }
|
public NetworkHandlers NetworkHandlers { get; private set; }
|
||||||
|
|
||||||
public DiscordBotManager BotManager { get; private set; }
|
public AntiDebug AntiDebug { get; set; }
|
||||||
|
|
||||||
internal PluginManager PluginManager { get; private set; }
|
internal PluginManager PluginManager { get; private set; }
|
||||||
internal PluginRepository PluginRepository { get; private set; }
|
internal PluginRepository PluginRepository { get; private set; }
|
||||||
|
|
@ -142,14 +141,16 @@ namespace Dalamud {
|
||||||
|
|
||||||
NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection);
|
NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
AntiDebug = new AntiDebug(this.SigScanner);
|
||||||
|
AntiDebug.Enable();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialize managers. Basically handlers for the logic
|
// Initialize managers. Basically handlers for the logic
|
||||||
CommandManager = new CommandManager(this, info.Language);
|
CommandManager = new CommandManager(this, info.Language);
|
||||||
SetupCommands();
|
SetupCommands();
|
||||||
|
|
||||||
ChatHandlers = new ChatHandlers(this);
|
ChatHandlers = new ChatHandlers(this);
|
||||||
// Discord Bot Manager
|
|
||||||
BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig);
|
|
||||||
BotManager.Start();
|
|
||||||
|
|
||||||
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) {
|
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) {
|
||||||
try
|
try
|
||||||
|
|
@ -207,8 +208,6 @@ namespace Dalamud {
|
||||||
this.Framework.Dispose();
|
this.Framework.Dispose();
|
||||||
this.ClientState.Dispose();
|
this.ClientState.Dispose();
|
||||||
|
|
||||||
this.BotManager.Dispose();
|
|
||||||
|
|
||||||
this.unloadSignal.Dispose();
|
this.unloadSignal.Dispose();
|
||||||
|
|
||||||
this.WinSock2.Dispose();
|
this.WinSock2.Dispose();
|
||||||
|
|
@ -216,6 +215,8 @@ namespace Dalamud {
|
||||||
this.SigScanner.Dispose();
|
this.SigScanner.Dispose();
|
||||||
|
|
||||||
this.Data.Dispose();
|
this.Data.Dispose();
|
||||||
|
|
||||||
|
this.AntiDebug?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Interface
|
#region Interface
|
||||||
|
|
@ -295,6 +296,10 @@ namespace Dalamud {
|
||||||
|
|
||||||
ImGui.EndMenu();
|
ImGui.EndMenu();
|
||||||
}
|
}
|
||||||
|
if (AntiDebug == null && ImGui.MenuItem("Enable AntiDebug")) {
|
||||||
|
AntiDebug = new AntiDebug(this.SigScanner);
|
||||||
|
AntiDebug.Enable();
|
||||||
|
}
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
if (ImGui.MenuItem("Open Data window"))
|
if (ImGui.MenuItem("Open Data window"))
|
||||||
{
|
{
|
||||||
|
|
@ -526,10 +531,6 @@ namespace Dalamud {
|
||||||
HelpMessage = Loc.Localize("DalamudLastLinkHelp", "Open the last posted link in your default browser.")
|
HelpMessage = Loc.Localize("DalamudLastLinkHelp", "Open the last posted link in your default browser.")
|
||||||
});
|
});
|
||||||
|
|
||||||
CommandManager.AddHandler("/xlbotjoin", new CommandInfo(OnBotJoinCommand) {
|
|
||||||
HelpMessage = Loc.Localize("DalamudBotJoinHelp", "Add the XIVLauncher discord bot you set up to your server.")
|
|
||||||
});
|
|
||||||
|
|
||||||
CommandManager.AddHandler("/xlbgmset", new CommandInfo(OnBgmSetCommand) {
|
CommandManager.AddHandler("/xlbgmset", new CommandInfo(OnBgmSetCommand) {
|
||||||
HelpMessage = Loc.Localize("DalamudBgmSetHelp", "Set the Game background music. Usage: /xlbgmset <BGM ID>")
|
HelpMessage = Loc.Localize("DalamudBgmSetHelp", "Set the Game background music. Usage: /xlbgmset <BGM ID>")
|
||||||
});
|
});
|
||||||
|
|
@ -673,15 +674,6 @@ namespace Dalamud {
|
||||||
Process.Start(ChatHandlers.LastLink);
|
Process.Start(ChatHandlers.LastLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBotJoinCommand(string command, string arguments) {
|
|
||||||
if (this.BotManager != null && this.BotManager.IsConnected)
|
|
||||||
Process.Start(
|
|
||||||
$"https://discordapp.com/oauth2/authorize?client_id={this.BotManager.UserId}&scope=bot&permissions=117760");
|
|
||||||
else
|
|
||||||
Framework.Gui.Chat.Print(
|
|
||||||
Loc.Localize("DalamudBotNotSetup", "The XIVLauncher discord bot was not set up correctly or could not connect to discord. Please check the settings and the FAQ."));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnBgmSetCommand(string command, string arguments)
|
private void OnBgmSetCommand(string command, string arguments)
|
||||||
{
|
{
|
||||||
Framework.Gui.SetBgm(ushort.Parse(arguments));
|
Framework.Gui.SetBgm(ushort.Parse(arguments));
|
||||||
|
|
|
||||||
38
Dalamud/Game/Internal/AntiDebug.cs
Normal file
38
Dalamud/Game/Internal/AntiDebug.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Dalamud.Hooking;
|
||||||
|
using EasyHook;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace Dalamud.Game.Internal
|
||||||
|
{
|
||||||
|
public class AntiDebug : IDisposable
|
||||||
|
{
|
||||||
|
private IntPtr DebugCheckAddress { get; set; }
|
||||||
|
|
||||||
|
public AntiDebug(SigScanner scanner) {
|
||||||
|
DebugCheckAddress = scanner.ScanText("FF 15 ?? ?? ?? ?? 85 C0 74 11");
|
||||||
|
|
||||||
|
Log.Verbose("IsDebuggerPresent address {IsDebuggerPresent}", DebugCheckAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntPtr scanAddress;
|
||||||
|
private readonly byte[] nop = new byte[] { 0x31, 0xC0, 0x90, 0x90, 0x90, 0x90 };
|
||||||
|
private byte[] original;
|
||||||
|
|
||||||
|
public void Enable() {
|
||||||
|
this.original = new byte[this.nop.Length];
|
||||||
|
if (DebugCheckAddress != IntPtr.Zero) {
|
||||||
|
Log.Information($"Overwriting Debug Check @ 0x{scanAddress.ToInt64():X}");
|
||||||
|
Marshal.Copy(DebugCheckAddress, this.original, 0, this.nop.Length);
|
||||||
|
Marshal.Copy(this.nop, 0, DebugCheckAddress, this.nop.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose() {
|
||||||
|
if (this.scanAddress != IntPtr.Zero && this.original != null)
|
||||||
|
Marshal.Copy(this.original, 0, DebugCheckAddress, this.nop.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue