From 9c27212d3745eeae719c6cacb82b18d51ad805db Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 1 Nov 2021 12:40:57 -0400 Subject: [PATCH] Fix chained ctor confusing callingAssembly value --- Dalamud/Hooking/Hook.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Dalamud/Hooking/Hook.cs b/Dalamud/Hooking/Hook.cs index f9892e92f..13b199dea 100644 --- a/Dalamud/Hooking/Hook.cs +++ b/Dalamud/Hooking/Hook.cs @@ -27,7 +27,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, false) + : this(address, detour, false, Assembly.GetCallingAssembly()) { } @@ -40,6 +40,11 @@ namespace Dalamud.Hooking /// Callback function. Delegate must have a same original function prototype. /// Use the MinHook hooking library instead of Reloaded. public Hook(IntPtr address, T detour, bool useMinHook) + : this(address, detour, useMinHook, Assembly.GetCallingAssembly()) + { + } + + private Hook(IntPtr address, T detour, bool useMinHook, Assembly callingAssembly) { address = HookManager.FollowJmp(address); this.isMinHook = EnvironmentConfiguration.DalamudForceMinHook || useMinHook; @@ -69,7 +74,7 @@ namespace Dalamud.Hooking this.hookImpl = ReloadedHooks.Instance.CreateHook(detour, address.ToInt64()); } - HookManager.TrackedHooks.Add(new HookInfo(this, detour, Assembly.GetCallingAssembly())); + HookManager.TrackedHooks.Add(new HookInfo(this, detour, callingAssembly)); } ///