microsoft / microsoft/Detours

Detours DLL does not DLL_PROCESS_ATTACH if a statically linked DLL or delay loaded DLL is not found

Open
#336 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
6.4k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the missing-dependency cases described for delay-loaded and statically linked DLLs, using setdll and gflags -i Program.exe +sls. Trace whether MyDetoured.dll reaches DLL_PROCESS_ATTACH and determine whether the behavior is caused by Detours or the Windows loader; done requires a confirmed explanation and documented resolution.

Written by the indexing model from the issue text.

Assessment

Domain
operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.