Try turning on "loader snaps". Follow these steps: 1. Download and install the latest version of WinDBG[^]. 2. Select “Start”->”All Programs”->”Debugging Tools for Windows”->”Global Flags”. 3. The “Global Flags” dialog appears. Select the “Image File” tab. 4. In the “Image: (TAB to refresh)” edit control enter your exe name with extension; not the full path, just the filename. 5. Press the “Tab” key. 6. Tick the “Show loader snaps” tick box. 7. Press the “Apply” button. 8. Run the application in a debugger. Here’s some sample output:
Loaded 'ntdll.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found. Loaded symbols for 'C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll' [9b4,f48] LDR: Real INIT LIST for process C:\Projects\Scratch\StaticLinkProblem\Debug\StaticLinkProblem.exe pid 2484 0x9b4 [9b4,f48] C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll init routine 100011C0 [9b4,f48] LDR: ProblemDLL.dll loaded - Calling init routine at 100011C0 [9b4,f48] LDR: DLL_PROCESS_ATTACH for dll "C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll" (InitRoutine: 100011C0) failed LDR: LdrpInitializeProcess - Failed running initialization routines; status c0000142 LDR: _LdrpInitialize - call to LdrpInitializeProcess() failed with ntstatus c0000142 First-chance exception in StaticLinkProblem.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
9. When done un-check the “Show loader snaps” tick box and press "OK". The line of interest is the following:
[9b4,f48] LDR: DLL_PROCESS_ATTACH for dll "C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll" (InitRoutine: 100011C0) failed
Steve