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

concern on multiple thread when hook one API in target process #6

Open
tigerking opened this issue Dec 27, 2014 · 3 comments
Open

concern on multiple thread when hook one API in target process #6

tigerking opened this issue Dec 27, 2014 · 3 comments

Comments

@tigerking
Copy link

Great project. After carefully read the source code and implementation, I have one concern, not sure it is correct. My concern is if the hooked API is called by multiple threads in one process, is it safe?
That is saying if the hooked thread is called and goes into hook_postcall() but not completed, another thread is trying call the same hooked API, how to deal with this case? Thanks
--TK

@jduck
Copy link
Collaborator

jduck commented Dec 29, 2014

Your assessment is correct. An entirely different hooking technique is needed to overcome this limitation.

@E3V3A
Copy link

E3V3A commented Jan 14, 2015

And which technique is that?

@jduck
Copy link
Collaborator

jduck commented Jan 15, 2015

Right now it uses a hook that is inserted and then temporarily removed to execute the original. What's needed is to relocate the overwritten instructions to some other executable memory and insert a persistent hook. Alternatively, the entire hooked function could be relocated. The main point is that the hook needs to be there the entire time that we wish it to be activated.

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

3 participants