Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't hook functions #19

Open
NotBlue-Dev opened this issue Dec 11, 2022 · 1 comment
Open

Can't hook functions #19

NotBlue-Dev opened this issue Dec 11, 2022 · 1 comment

Comments

@NotBlue-Dev
Copy link

NotBlue-Dev commented Dec 11, 2022

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();
        }
@Sewer56
Copy link
Member

Sewer56 commented Dec 11, 2022

Have you checked whether the signature scan returns a valid address?
Maybe a game update has changed the relevant code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants