Magic the magic happen

This commit is contained in:
Raymond Lynch 2021-07-11 16:32:29 -04:00
parent 84769ae5b7
commit 658eedca37
188 changed files with 10329 additions and 3549 deletions

View file

@ -3,7 +3,8 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using EasyHook;
using CoreHook;
using Dalamud.Hooking.Internal;
namespace Dalamud.Hooking
{
@ -30,8 +31,8 @@ namespace Dalamud.Hooking
{
this.hookInfo = LocalHook.Create(address, detour, null); // Installs a hook here
this.address = address;
this.original = Marshal.GetDelegateForFunctionPointer<T>(this.hookInfo.HookBypassAddress);
HookInfo.TrackedHooks.Add(new HookInfo() { Delegate = detour, Hook = this, Assembly = Assembly.GetCallingAssembly() });
this.original = Marshal.GetDelegateForFunctionPointer<T>(this.hookInfo.OriginalAddress);
HookManager.TrackedHooks.Add(new HookInfo() { Delegate = detour, Hook = this, Assembly = Assembly.GetCallingAssembly() });
}
/// <summary>
@ -130,9 +131,8 @@ namespace Dalamud.Hooking
return;
}
this.hookInfo.Dispose();
this.IsDisposed = true;
this.hookInfo.Dispose();
}
/// <summary>

View file

@ -3,18 +3,13 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
namespace Dalamud.Hooking
namespace Dalamud.Hooking.Internal
{
/// <summary>
/// Class containing information about registered hooks.
/// </summary>
internal class HookInfo
{
/// <summary>
/// Static list of tracked and registered hooks.
/// </summary>
internal static readonly List<HookInfo> TrackedHooks = new();
private ulong? inProcessMemory = 0;
/// <summary>

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
namespace Dalamud.Hooking.Internal
{
/// <summary>
/// This class manages the final disposition of hooks, cleaning up any that have not reverted their changes.
/// </summary>
internal class HookManager : IDisposable
{
// private readonly Dalamud dalamud;
/// <summary>
/// Initializes a new instance of the <see cref="HookManager"/> class.
/// </summary>
/// <param name="dalamud">Dalamud instance.</param>
public HookManager(Dalamud dalamud)
{
_ = dalamud;
// this.dalamud = dalamud;
}
/// <summary>
/// Gets a static list of tracked and registered hooks.
/// </summary>
internal static List<HookInfo> TrackedHooks { get; } = new();
/// <inheritdoc/>
public void Dispose()
{
}
}
}

View file

@ -1,6 +1,6 @@
using System;
namespace Dalamud.Hooking
namespace Dalamud.Hooking.Internal
{
/// <summary>
/// Interface describing a generic hook.