Fix chained ctor confusing callingAssembly value

This commit is contained in:
Raymond 2021-11-01 12:40:57 -04:00
parent 067ffc9fd2
commit 9c27212d37

View file

@ -27,7 +27,7 @@ namespace Dalamud.Hooking
/// <param name="address">A memory address to install a hook.</param> /// <param name="address">A memory address to install a hook.</param>
/// <param name="detour">Callback function. Delegate must have a same original function prototype.</param> /// <param name="detour">Callback function. Delegate must have a same original function prototype.</param>
public Hook(IntPtr address, T detour) public Hook(IntPtr address, T detour)
: this(address, detour, false) : this(address, detour, false, Assembly.GetCallingAssembly())
{ {
} }
@ -40,6 +40,11 @@ namespace Dalamud.Hooking
/// <param name="detour">Callback function. Delegate must have a same original function prototype.</param> /// <param name="detour">Callback function. Delegate must have a same original function prototype.</param>
/// <param name="useMinHook">Use the MinHook hooking library instead of Reloaded.</param> /// <param name="useMinHook">Use the MinHook hooking library instead of Reloaded.</param>
public Hook(IntPtr address, T detour, bool useMinHook) 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); address = HookManager.FollowJmp(address);
this.isMinHook = EnvironmentConfiguration.DalamudForceMinHook || useMinHook; this.isMinHook = EnvironmentConfiguration.DalamudForceMinHook || useMinHook;
@ -69,7 +74,7 @@ namespace Dalamud.Hooking
this.hookImpl = ReloadedHooks.Instance.CreateHook<T>(detour, address.ToInt64()); this.hookImpl = ReloadedHooks.Instance.CreateHook<T>(detour, address.ToInt64());
} }
HookManager.TrackedHooks.Add(new HookInfo(this, detour, Assembly.GetCallingAssembly())); HookManager.TrackedHooks.Add(new HookInfo(this, detour, callingAssembly));
} }
/// <summary> /// <summary>