fix: don't double disable

This commit is contained in:
goat 2021-10-26 23:25:15 +02:00
parent b04adaecfc
commit ce3aaf7a9b
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
2 changed files with 35 additions and 1 deletions

View file

@ -167,7 +167,6 @@ namespace Dalamud.Hooking
if (this.isMinHook) if (this.isMinHook)
{ {
this.Disable();
this.minHookImpl.Dispose(); this.minHookImpl.Dispose();
} }
else else

View file

@ -27,6 +27,7 @@ using Dalamud.Game.Gui;
using Dalamud.Game.Gui.FlyText; using Dalamud.Game.Gui.FlyText;
using Dalamud.Game.Gui.Toast; using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Hooking;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
@ -39,6 +40,7 @@ using ImGuiNET;
using ImGuiScene; using ImGuiScene;
using Newtonsoft.Json; using Newtonsoft.Json;
using Serilog; using Serilog;
using SharpDX.Direct3D11;
namespace Dalamud.Interface.Internal.Windows namespace Dalamud.Interface.Internal.Windows
{ {
@ -69,6 +71,10 @@ namespace Dalamud.Interface.Internal.Windows
private UIDebug addonInspector = null; private UIDebug addonInspector = null;
private delegate int MessageBoxWDelegate(IntPtr hWnd, string text, string caption, NativeFunctions.MessageBoxType type);
private Hook<MessageBoxWDelegate>? messageBoxMinHook;
// IPC // IPC
private ICallGateProvider<string, string> ipcPub; private ICallGateProvider<string, string> ipcPub;
private ICallGateSubscriber<string, string> ipcSub; private ICallGateSubscriber<string, string> ipcSub;
@ -143,6 +149,7 @@ namespace Dalamud.Interface.Internal.Windows
Gamepad, Gamepad,
Configuration, Configuration,
TaskSched, TaskSched,
Hook,
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -318,6 +325,34 @@ namespace Dalamud.Interface.Internal.Windows
case DataKind.TaskSched: case DataKind.TaskSched:
this.DrawTaskSched(); this.DrawTaskSched();
break; break;
case DataKind.Hook:
{
if (ImGui.Button("Create"))
{
this.messageBoxMinHook = Hook<MessageBoxWDelegate>.FromSymbol("User32", "MessageBoxW",
(wnd, text, caption, type) =>
{
Log.Information("[DATAHOOK] {0} {1} {2} {3}", wnd, text, caption, type);
return this.messageBoxMinHook.Original(wnd, text, caption, type);
});
}
if (ImGui.Button("Enable")) this.messageBoxMinHook?.Enable();
if (ImGui.Button("Disable")) this.messageBoxMinHook?.Disable();
if (ImGui.Button("Dispose"))
{
this.messageBoxMinHook?.Dispose();
this.messageBoxMinHook = null;
}
if (this.messageBoxMinHook != null)
ImGui.Text("Enabled: " + this.messageBoxMinHook?.IsEnabled);
}
break;
} }
} }
else else