From 0e8ef7c4da1233fb4dceb4989b93303918d5e5f2 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 30 Jan 2022 12:53:57 +0100 Subject: [PATCH] fix(binding): enable hook in CreateHookFromPattern --- .../NosBindingManager.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Core/NosSmooth.LocalBinding/NosBindingManager.cs b/src/Core/NosSmooth.LocalBinding/NosBindingManager.cs index c4923c53ae83988674f0e8f3d88c9b310f3a4d6b..251915880b0c900973f42397cde64ff06fab18a9 100644 --- a/src/Core/NosSmooth.LocalBinding/NosBindingManager.cs +++ b/src/Core/NosSmooth.LocalBinding/NosBindingManager.cs @@ -338,7 +338,7 @@ public class NosBindingManager : IDisposable /// The callback function to call instead of the original one. /// The pattern. /// The offset from the pattern. - /// Whether to activate the hook. + /// Whether to activate the hook. /// The type of the function. /// The hook object or an error. internal Result> CreateHookFromPattern @@ -347,7 +347,7 @@ public class NosBindingManager : IDisposable TFunction callbackFunction, string pattern, int offset = 0, - bool hook = true + bool enableHook = true ) { var walkFunctionAddress = Scanner.CompiledFindPattern(pattern); @@ -358,14 +358,17 @@ public class NosBindingManager : IDisposable try { - return Result>.FromSuccess + var hook = Hooks.CreateHook ( - Hooks.CreateHook - ( - callbackFunction, - walkFunctionAddress.Offset + (int)_browserManager.Process.MainModule!.BaseAddress - ) + callbackFunction, + walkFunctionAddress.Offset + (int)_browserManager.Process.MainModule!.BaseAddress + offset ); + if (enableHook) + { + hook.Activate(); + } + + return Result>.FromSuccess(hook); } catch (Exception e) {