From 6c06645b00984b3bdd6c95e75687110ce92fcb44 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Thu, 28 Oct 2021 01:14:27 +0200 Subject: [PATCH] reloaded by default, corehook => minhook --- Dalamud/Configuration/Internal/EnvironmentConfiguration.cs | 2 +- Dalamud/Hooking/Hook.cs | 6 +++--- Dalamud/Interface/Internal/Windows/DataWindow.cs | 6 ++++-- Dalamud/Support/Troubleshooting.cs | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs b/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs index b271ee4a4..31bee1204 100644 --- a/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs +++ b/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs @@ -25,7 +25,7 @@ namespace Dalamud.Configuration.Internal /// /// Gets a value indicating whether the DalamudForceCoreHook setting has been enabled. /// - public static bool DalamudForceCoreHook { get; } = GetEnvironmentVariable("DALAMUD_FORCE_COREHOOK"); + public static bool DalamudForceMinHook { get; } = GetEnvironmentVariable("DALAMUD_FORCE_COREHOOK"); private static bool GetEnvironmentVariable(string name) => bool.Parse(Environment.GetEnvironmentVariable(name) ?? "false"); diff --git a/Dalamud/Hooking/Hook.cs b/Dalamud/Hooking/Hook.cs index fb7277d00..9c4230d7a 100644 --- a/Dalamud/Hooking/Hook.cs +++ b/Dalamud/Hooking/Hook.cs @@ -29,7 +29,7 @@ namespace Dalamud.Hooking /// A memory address to install a hook. /// Callback function. Delegate must have a same original function prototype. public Hook(IntPtr address, T detour) - : this(address, detour, true) + : this(address, detour, false) { } @@ -44,7 +44,7 @@ namespace Dalamud.Hooking public Hook(IntPtr address, T detour, bool useMinHook) { address = HookManager.FollowJmp(address); - this.isMinHook = true; + this.isMinHook = EnvironmentConfiguration.DalamudForceMinHook || useMinHook; var hasOtherHooks = HookManager.Originals.ContainsKey(address); if (!hasOtherHooks) @@ -140,7 +140,7 @@ namespace Dalamud.Hooking /// Callback function. Delegate must have a same original function prototype. /// The hook with the supplied parameters. public static Hook FromSymbol(string moduleName, string exportName, T detour) - => FromSymbol(moduleName, exportName, detour, true); + => FromSymbol(moduleName, exportName, detour, false); /// /// Creates a hook. Hooking address is inferred by calling to GetProcAddress() function. diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs index 95a84e7a4..e7355e2ed 100644 --- a/Dalamud/Interface/Internal/Windows/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs @@ -41,7 +41,6 @@ using ImGuiNET; using ImGuiScene; using Newtonsoft.Json; using Serilog; -using SharpDX.Direct3D11; namespace Dalamud.Interface.Internal.Windows { @@ -73,6 +72,7 @@ namespace Dalamud.Interface.Internal.Windows private UIDebug addonInspector = null; private Hook? messageBoxMinHook; + private bool hookUseMinHook = false; // IPC private ICallGateProvider ipcPub; @@ -1589,8 +1589,10 @@ namespace Dalamud.Interface.Internal.Windows { try { + ImGui.Checkbox("Use MinHook", ref this.hookUseMinHook); + if (ImGui.Button("Create")) - this.messageBoxMinHook = Hook.FromSymbol("User32", "MessageBoxW", this.MessageBoxWDetour); + this.messageBoxMinHook = Hook.FromSymbol("User32", "MessageBoxW", this.MessageBoxWDetour, this.hookUseMinHook); if (ImGui.Button("Enable")) this.messageBoxMinHook?.Enable(); diff --git a/Dalamud/Support/Troubleshooting.cs b/Dalamud/Support/Troubleshooting.cs index e2e892b77..2ba9be696 100644 --- a/Dalamud/Support/Troubleshooting.cs +++ b/Dalamud/Support/Troubleshooting.cs @@ -74,7 +74,7 @@ namespace Dalamud.Support DoPluginTest = configuration.DoPluginTest, InterfaceLoaded = interfaceManager?.IsReady ?? false, ThirdRepo = configuration.ThirdRepoList, - ForcedCoreHook = EnvironmentConfiguration.DalamudForceCoreHook, + ForcedCoreHook = EnvironmentConfiguration.DalamudForceMinHook, }; var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));