From b0fac2bc47c657de837fda86182fb836beb042af Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Tue, 26 Oct 2021 23:28:14 +0200 Subject: [PATCH] add hook tester to data window --- .../Interface/Internal/Windows/DataWindow.cs | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs index f287c24e6..dd67356c7 100644 --- a/Dalamud/Interface/Internal/Windows/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs @@ -328,28 +328,38 @@ namespace Dalamud.Interface.Internal.Windows case DataKind.Hook: { - if (ImGui.Button("Create")) + try { - 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("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 (ImGui.Button("Test")) NativeFunctions.MessageBoxW(IntPtr.Zero, "Hi", "Hello", NativeFunctions.MessageBoxType.Ok); + + if (this.messageBoxMinHook != null) + ImGui.Text("Enabled: " + this.messageBoxMinHook?.IsEnabled); } - - if (ImGui.Button("Enable")) this.messageBoxMinHook?.Enable(); - - if (ImGui.Button("Disable")) this.messageBoxMinHook?.Disable(); - - if (ImGui.Button("Dispose")) + catch (Exception ex) { - this.messageBoxMinHook?.Dispose(); - this.messageBoxMinHook = null; + Log.Error(ex, "MinHook error caught"); } - - if (this.messageBoxMinHook != null) - ImGui.Text("Enabled: " + this.messageBoxMinHook?.IsEnabled); } break;