diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index b0d22d948..c493e68f9 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -67,7 +67,7 @@ - + diff --git a/Dalamud/Hooking/Hook.cs b/Dalamud/Hooking/Hook.cs index 261edcd9b..fb7277d00 100644 --- a/Dalamud/Hooking/Hook.cs +++ b/Dalamud/Hooking/Hook.cs @@ -56,7 +56,15 @@ namespace Dalamud.Hooking this.address = address; if (this.isMinHook) { - this.minHookImpl = new MinSharp.Hook(address, detour); + var indexList = hasOtherHooks + ? HookManager.MultiHookTracker[address] + : HookManager.MultiHookTracker[address] = new(); + var index = (ulong)indexList.Count; + + this.minHookImpl = new MinSharp.Hook(address, detour, index); + + // Add afterwards, so the hookIdent starts at 0. + indexList.Add(this); } else { @@ -168,6 +176,7 @@ namespace Dalamud.Hooking if (this.isMinHook) { this.minHookImpl.Dispose(); + HookManager.MultiHookTracker[this.address] = null; } else { diff --git a/Dalamud/Hooking/Internal/HookManager.cs b/Dalamud/Hooking/Internal/HookManager.cs index 1f67ee1e8..8990930a0 100644 --- a/Dalamud/Hooking/Internal/HookManager.cs +++ b/Dalamud/Hooking/Internal/HookManager.cs @@ -79,6 +79,11 @@ namespace Dalamud.Hooking.Internal /// internal static Dictionary Originals { get; } = new(); + /// + /// Gets a static dictionary of the number of hooks on a given address. + /// + internal static Dictionary> MultiHookTracker { get; } = new(); + /// public void Dispose() {