From 60a29e36c2a0d2f7a26195c96093501cb4ada110 Mon Sep 17 00:00:00 2001 From: nebel Date: Sun, 4 Jun 2023 02:49:59 +0900 Subject: [PATCH] Create RegisterUnhooker overload --- Dalamud/Hooking/Internal/HookManager.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Dalamud/Hooking/Internal/HookManager.cs b/Dalamud/Hooking/Internal/HookManager.cs index 43858d012..f185450eb 100644 --- a/Dalamud/Hooking/Internal/HookManager.cs +++ b/Dalamud/Hooking/Internal/HookManager.cs @@ -43,13 +43,26 @@ internal class HookManager : IDisposable, IServiceType /// /// Creates a new Unhooker instance for the provided address if no such unhooker was already registered, or returns - /// an existing instance if the address registered previously. + /// an existing instance if the address was registered previously. By default, the unhooker will restore between 0 + /// and 0x32 bytes depending on the detected size of the hook. To specify the minimum and maximum bytes restored + /// manually, use . /// /// The address of the instruction. - /// The minimum amount of bytes to restore when unhooking. Defaults to 0. - /// The maximum amount of bytes to restore when unhooking. Defaults to 0x32. /// A new Unhooker instance. - public static Unhooker RegisterUnhooker(IntPtr address, int minBytes = 0, int maxBytes = 0x32) + public static Unhooker RegisterUnhooker(IntPtr address) + { + return RegisterUnhooker(address, 0, 0x32); + } + + /// + /// Creates a new Unhooker instance for the provided address if no such unhooker was already registered, or returns + /// an existing instance if the address was registered previously. + /// + /// The address of the instruction. + /// The minimum amount of bytes to restore when unhooking. + /// The maximum amount of bytes to restore when unhooking. + /// A new Unhooker instance. + public static Unhooker RegisterUnhooker(IntPtr address, int minBytes, int maxBytes) { Log.Verbose($"Registering hook at 0x{address.ToInt64():X} (minBytes=0x{minBytes:X}, maxBytes=0x{maxBytes:X})"); return Unhookers.GetOrAdd(address, _ => new Unhooker(address, minBytes, maxBytes));