Consider a program MyProgram.exe with 2 dependencies: MyDetoured.dll and MyDelayLoaded.dll.
MyDetoured.dll is injected as first entry in the import libs of MyProgram.exe using setdll.
When MyProgram.exe runs, I can see MyDetoured.dll being loaded before MyDelayLoaded.dll and its DLL_PROCESS_ATTACH is called.
However when MyDelayLoaded.dll is not found, MyProgram.exe:
- loads MyDetoured.dll
- tries to load MyDelayLoaded.dll and fails with a dll not found pop up error
- DLL_PROCESS_ATTACH of MyDetoured.dll is not called <--- issue here
I see this by using "gflags -i Program.exe +sls" which traces dll calls.
I thought Detours are guaranteed to get called.
Is this a bug or is it a limitation that Detours doesn't work when a delay loaded DLL is not resolved at runtime ?
EDIT: this happens also with statically linked DLL