Reloaded-Project / Reloaded.Hooks

Advanced native function hooks for x86, x64. Welcome to the next level!
GNU Lesser General Public License v3.0
213 stars 33 forks source link

Can't hook functions #19

Open NotBlue-Dev opened 1 year ago

NotBlue-Dev commented 1 year ago

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 commented 1 year ago

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