~ruther/NosSmooth.Local

0e8ef7c4da1233fb4dceb4989b93303918d5e5f2 — Rutherther 3 years ago afd97ef
fix(binding): enable hook in CreateHookFromPattern
1 files changed, 11 insertions(+), 8 deletions(-)

M src/Core/NosSmooth.LocalBinding/NosBindingManager.cs
M src/Core/NosSmooth.LocalBinding/NosBindingManager.cs => src/Core/NosSmooth.LocalBinding/NosBindingManager.cs +11 -8
@@ 338,7 338,7 @@ public class NosBindingManager : IDisposable
    /// <param name="callbackFunction">The callback function to call instead of the original one.</param>
    /// <param name="pattern">The pattern.</param>
    /// <param name="offset">The offset from the pattern.</param>
    /// <param name="hook">Whether to activate the hook.</param>
    /// <param name="enableHook">Whether to activate the hook.</param>
    /// <typeparam name="TFunction">The type of the function.</typeparam>
    /// <returns>The hook object or an error.</returns>
    internal Result<IHook<TFunction>> CreateHookFromPattern<TFunction>


@@ 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<IHook<TFunction>>.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<IHook<TFunction>>.FromSuccess(hook);
        }
        catch (Exception e)
        {

Do not follow this link