Skip to content

Can't hook functions #19

@NotBlue-Dev

Description

@NotBlue-Dev

Hi, i get this error when i try to hook any function of NMS :
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Here is the code used for hooking :

public void InitHook(IModLogger _logger, IReloadedHooks _hooks)
        {
            logger = _logger;

            string pattern = "48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 57 41 56 41 57 48 81 EC ? ? ? ? 0F 29 70 D8 48 8D";

            Function = _hooks.CreateFunction<HookDelegate>(new Signature(pattern).Scan());
            _hooks.CreateHook(Function, new Signature(pattern).Scan());
            logger.WriteLine($"Function: {Function}");
            Hook = Function.Hook(CodeToExecute).Activate();
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions