diff --git a/Dalamud/Hooking/Hook.cs b/Dalamud/Hooking/Hook.cs index f8fd02ec2..261edcd9b 100644 --- a/Dalamud/Hooking/Hook.cs +++ b/Dalamud/Hooking/Hook.cs @@ -167,7 +167,6 @@ namespace Dalamud.Hooking if (this.isMinHook) { - this.Disable(); this.minHookImpl.Dispose(); } else diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs index f6a45846d..f287c24e6 100644 --- a/Dalamud/Interface/Internal/Windows/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs @@ -27,6 +27,7 @@ using Dalamud.Game.Gui; using Dalamud.Game.Gui.FlyText; using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text; +using Dalamud.Hooking; using Dalamud.Interface.Colors; using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Windowing; @@ -39,6 +40,7 @@ using ImGuiNET; using ImGuiScene; using Newtonsoft.Json; using Serilog; +using SharpDX.Direct3D11; namespace Dalamud.Interface.Internal.Windows { @@ -69,6 +71,10 @@ namespace Dalamud.Interface.Internal.Windows private UIDebug addonInspector = null; + private delegate int MessageBoxWDelegate(IntPtr hWnd, string text, string caption, NativeFunctions.MessageBoxType type); + + private Hook? messageBoxMinHook; + // IPC private ICallGateProvider ipcPub; private ICallGateSubscriber ipcSub; @@ -143,6 +149,7 @@ namespace Dalamud.Interface.Internal.Windows Gamepad, Configuration, TaskSched, + Hook, } /// @@ -318,6 +325,34 @@ namespace Dalamud.Interface.Internal.Windows case DataKind.TaskSched: this.DrawTaskSched(); break; + + case DataKind.Hook: + { + if (ImGui.Button("Create")) + { + this.messageBoxMinHook = Hook.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