HookAPI with multiple DLLs having the same name

c++ / delphi package - dll injection and api hooking
Post Reply
immer000
Posts: 22
Joined: Tue Sep 04, 2012 12:05 am

HookAPI with multiple DLLs having the same name

Post by immer000 »

How would HookAPI behave in the case where multiple DLLs with the same name are loaded ?
The reason for asking is when an external software hooks stuff using a drop-in dll :
* App.exe links agains d3d9.dll.
* Third-party solution A provides a d3d9.dll file to copy into the application's folder. That DLL implements the same API as the real d3d9.dll provided with Windows and acts as a proxy.
* Our solution uses madCodeHook : HookAPI("d3d9.dll", "[...]")
Does our hook get called before it gets to A ? When A calls the real function in d3d9.dll ? Both ?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: HookAPI with multiple DLLs having the same name

Post by madshi »

I guess it will be random which of the 2 dlls will be hooked. Depends on which dll Windows reports when calling "GetModuleHandle('d3d9.dll')". I suppose you could use the full dll file path in your HookAPI() call to specify which dll you want to have hooked. But I haven't ever tested this, so I can't guarantee it will work as expected. Just give it a try and report back if it doesn't work.
Post Reply