high6 Posted August 17, 2009 Posted August 17, 2009 So I have a C++ dll injected into a process and I want to hook/call the same function. Problem is that if I have the hook call the function then it can turn into some nasty recursion.What is the best way to Hook/Call the same function?Some thoughts-Could call the hook's trampoline instead which will cause it to skip over the hook. (Will only work if hooking the start of a function)-Could set a flag that will skip the hook. Not sure how I would do that without it being a giant mess though.
atom0s Posted August 17, 2009 Posted August 17, 2009 So I have a C++ dll injected into a process and I want to hook/call the same function. Problem is that if I have the hook call the function then it can turn into some nasty recursion.What is the best way to Hook/Call the same function?Some thoughts-Could call the hook's trampoline instead which will cause it to skip over the hook. (Will only work if hooking the start of a function)-Could set a flag that will skip the hook. Not sure how I would do that without it being a giant mess though.Your first thought would probably be the cleanest method to use if you are hooking the start of the function as you said.Adding a flag could get messy depending on how you plan to implement it.
high6 Posted August 17, 2009 Author Posted August 17, 2009 Okay well I did some thinking. Maybe I could make a SafeCalling class which would store the threadid and patch addrs in a static vector which would have static accessors for ASM use and when it is finished calling it would remove the threadid and patch addrs.Then I would build into the codecaves my hook class uses to read that vector making sure it isnt blocking.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now