-
Notifications
You must be signed in to change notification settings - Fork 49
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
Fast toggling of hooks #72
Comments
I created PR #73 as a starting point for this feature request. Let me know if you have any suggestions. |
Thanks for making this. Is there any reason you decided to assemble the jump from scratch instead of saving the original detour and just copying over the bytes? I feel like it would be faster but I don't know for sure. |
Assembling the jump is just filling out a struct on the stack and copying it over. The overhead is negligible compared to the syscalls needed to unprotect/reprotect the memory we write to ( |
Oh ok. What do you think about adding a flag to disable protection on hook creation and not bothering to re-protect it afterwards? |
I have to think about this some more. This would bypass/undermine a lot of the safety mechanisms put in place and at first glance would be quite disruptive code-wise. |
Ok never mind, I just realized there's probably no use to toggling hooks on and off that fast except for evading anti-cheat. For high performance purposes probably better just to leave the stuff hooked and toggle with a boolean. I think we can close this issue. I've tested the branch a bit and it seems to be working without issues. |
I'm looking for a new hooking library replacement and this one seems to suit my purposes except for 1 issue.
There doesn't seem to be a way to quickly toggle the hook on or off. So the only way seems to be completely destroying and recreating the hook which means new memory is allocated, and the prologue has to be disassembled and translated again which seems like a lot of overhead.
Would you be open to having a new member variable indicating whether the hook is on or not, and you could just replace the prologue with the hooked bytes or the original bytes?
The text was updated successfully, but these errors were encountered: