Fix leaking a hook?

This commit is contained in:
Ottermandias 2023-10-05 16:05:43 +02:00
parent 9218ede11d
commit 06299d1966
4 changed files with 7 additions and 4 deletions

View file

@ -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.
/// </summary>
public unsafe class ChangeCustomizeService : EventWrapper<Action<Model, Ref<Customize>>, ChangeCustomizeService.Priority>
public unsafe class ChangeCustomizeService : EventWrapper<Action<Model, Ref<Customize>>, ChangeCustomizeService.Priority>, IDisposable
{
private readonly PenumbraReloaded _penumbraReloaded;
private readonly IGameInteropProvider _interop;

View file

@ -18,9 +18,11 @@ public unsafe class InventoryService : IDisposable
public InventoryService(MovedEquipment @event, IGameInteropProvider interop)
{
_event = @event;
_moveItemHook = interop.HookFromAddress<MoveItemDelegate>((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour);
_equipGearsetHook =
interop.HookFromAddress<EquipGearsetDelegate>((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour);
_moveItemHook.Enable();
_equipGearsetHook.Enable();
}

View file

@ -20,6 +20,7 @@ public unsafe class ScalingService : IDisposable
_setupOrnamentHook = interop.HookFromAddress<SetupOrnament>((nint)Ornament.MemberFunctionPointers.SetupOrnament, SetupOrnamentDetour);
_calculateHeightHook =
interop.HookFromAddress<CalculateHeight>((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour);
_setupMountHook.Enable();
_setupOrnamentHook.Enable();
_placeMinionHook.Enable();

View file

@ -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);
}
/// <summary>
@ -70,7 +70,7 @@ public class VisorService : IDisposable
/// So we wrap a manual change of that flag with the function call.
/// </summary>
[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);