Search code examples
c++apihookdetours

is it possible to inject multiple Dlls with MS detours?


In c++ ,I want to hook more than one dll to a process. Right now I use CreateProcesswithdll() which can hook only one api at a time. What can I do to inject multiple dlls?

I came across this problem because MS detours requires us to name our custom dll the same as original dll in order to properly detour the api calls. So even though i could have different api calls handled in the same detour dll I created I need to have different names to hook calls from different apis, which means I need different detour Dlls. This also means I need to inject different DLLs. Am I right?

If I am unclear about something I will try to present it more clearly :D

Thanks!

P.S: Just to make my problem more lucid. I need to inject more than 1 dll onto the same process. CreateProcesswithdll() creates a new process with its thread in sleep state. It is woken up after the detours has finished injecting the dll and setting up the hooks. If I want to inject more than one dll I obviously cant repeatedly call CreateProcesswithdll()

so what do i do?? or Is my understanding about some aspect of this wrong?


Solution

  • Seems like detourattach and detourdetach will do the trick for me. Thanks everyone!

    I found this blog useful!