-
Notifications
You must be signed in to change notification settings - Fork 83
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
Unsafe hooks, lpOriginal is not set right after resuming threads #8
Comments
Hi Syahmi, Are you trying to hook a function used by Deviare when it is hooking? Or the call is done by another thread after resuming them but before the Hook method return? Regards, |
Hi Mauro, I think the call is done by another thread after resuming them but before the Hook method return if I understand you correctly. I will show pesudo code example to illustrate the problem better.
Above illustrate the problem better, what should be done for safe hooking is the lplpCallOriginal is set right before hooking on this line: https://github.com/nektra/Deviare-InProc/blob/master/Src/Lib/NktHookLib.cpp#L662 instead of passing the value and assign it later after hooking is done and threads resumed here: https://github.com/nektra/Deviare-InProc/blob/master/Src/Lib/NktHookLib.cpp#L152 Regards, |
Hi Syahmi, Thanks for the hint. I will apply the change on next working day. Regards. |
Hi Syahmi, After checking the code, you can call the Regards, |
Hi Mauro, I think I will propose a fix for this problem. Stay tune. Sorry, I had an unexpected errand. So I'll try to fix when there is time. There are several ways of fixing this:
|
Hi Syahmi, I uploaded a fix (among other for low IL processes). Please try it. Regards. |
Hi Mauro, Sorry I couldn't get back to you earlier. The commit should fix the problem. Thanks. |
Here's the problem, when we call Hook(), the function calls RemoteHook() which then build the trampoline, suspend the threads and do the actual hooking. Once hooked, all the threads is resumed and one of the threads which calls the hooked functions will crash if the detoured function try to call lpOriginal function too, before the Hook() actually return and give proper lpOriginal address.
Let me illustrate a bit:
The text was updated successfully, but these errors were encountered: