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

Hooking causes crash #20

Closed AlmightyLks closed 1 year ago

AlmightyLks commented 1 year ago

Hooking into a function causes for my target game to crash. Registering the hook is fine, and the hooked method does run as you can see in the following screenshot, but right after it crashes the game. Do you happen to how to approach to fix this? I am new to native game modding, but highly interested 😄

image

image

Sewer56 commented 1 year ago

Access violation means there's either an invalid pointer somewhere or something wasn't initialised. Probably the latter here since in the crash it says it was trying to read from address 0x0.

Guessing since the method is named 'Startup', it creates things used later down the road.

Try calling the original method in your hook:

_hook.OriginalFunction();
AlmightyLks commented 1 year ago

Quick question then as well Seemingly a Hook replaces the ASM of the target function

Is there another type of injection that allows to create prefixes / postfixes like Harmony for example?

Edit: Actually, thinking about it. The "burden" of calling _hook.OriginalFunction() seems trivial Ignore me 😄

Sewer56 commented 1 year ago

It's technically possible, but adds performance overhead since you'd basically now have to look up a function list and execute each one.

With the way native hooking libraries work (including this one), you can think of anything before the call to the original function as a prefix and everything after that as a postfix.

AlmightyLks commented 1 year ago

Try calling the original method in your hook: _hook.OriginalFunction();

Yup, that did it! Thanks 😄