Jump to content
Tuts 4 You

Hook/Call the same function?


high6

Recommended Posts

Posted

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.

Posted

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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...