From 06299d1966bee4d164edf3cf9134a6891842f78d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 5 Oct 2023 16:05:43 +0200 Subject: [PATCH] Fix leaking a hook? --- Glamourer/Interop/ChangeCustomizeService.cs | 2 +- Glamourer/Interop/InventoryService.cs | 2 ++ Glamourer/Interop/ScalingService.cs | 1 + Glamourer/Interop/VisorService.cs | 6 +++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index fe7c907..f2f2696 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -17,7 +17,7 @@ namespace Glamourer.Interop; /// Changes in Race, body type or Gender are probably ignored. /// This operates on draw objects, not game objects. /// -public unsafe class ChangeCustomizeService : EventWrapper>, ChangeCustomizeService.Priority> +public unsafe class ChangeCustomizeService : EventWrapper>, ChangeCustomizeService.Priority>, IDisposable { private readonly PenumbraReloaded _penumbraReloaded; private readonly IGameInteropProvider _interop; diff --git a/Glamourer/Interop/InventoryService.cs b/Glamourer/Interop/InventoryService.cs index 38c809f..f2832bd 100644 --- a/Glamourer/Interop/InventoryService.cs +++ b/Glamourer/Interop/InventoryService.cs @@ -18,9 +18,11 @@ public unsafe class InventoryService : IDisposable public InventoryService(MovedEquipment @event, IGameInteropProvider interop) { _event = @event; + _moveItemHook = interop.HookFromAddress((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour); _equipGearsetHook = interop.HookFromAddress((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour); + _moveItemHook.Enable(); _equipGearsetHook.Enable(); } diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index b2fee58..f714a9e 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -20,6 +20,7 @@ public unsafe class ScalingService : IDisposable _setupOrnamentHook = interop.HookFromAddress((nint)Ornament.MemberFunctionPointers.SetupOrnament, SetupOrnamentDetour); _calculateHeightHook = interop.HookFromAddress((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour); + _setupMountHook.Enable(); _setupOrnamentHook.Enable(); _placeMinionHook.Enable(); diff --git a/Glamourer/Interop/VisorService.cs b/Glamourer/Interop/VisorService.cs index 7a3aff8..2b49eba 100644 --- a/Glamourer/Interop/VisorService.cs +++ b/Glamourer/Interop/VisorService.cs @@ -43,7 +43,7 @@ public class VisorService : IDisposable if (oldState == on) return false; - SetupVisorHook(human, human.GetArmor(EquipSlot.Head).Set.Id, on); + SetupVisorDetour(human, human.GetArmor(EquipSlot.Head).Set.Id, on); return true; } @@ -61,7 +61,7 @@ public class VisorService : IDisposable Glamourer.Log.Excessive( $"[SetVisorState] Invoked from game on 0x{human:X} switching to {on} (original {originalOn})."); - SetupVisorHook(human, modelId, on); + SetupVisorDetour((Model)human, modelId, on); } /// @@ -70,7 +70,7 @@ public class VisorService : IDisposable /// So we wrap a manual change of that flag with the function call. /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - private unsafe void SetupVisorHook(Model human, ushort modelId, bool on) + private unsafe void SetupVisorDetour(Model human, ushort modelId, bool on) { human.AsCharacterBase->VisorToggled = on; _setupVisorHook.Original(human.Address, modelId, on);