Posted August 17, 200916 yr 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.
August 17, 200916 yr 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.
August 17, 200916 yr Author 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.
Create an account or sign in to comment