We have an application containing many (hundreds) DLLs. The EXE directly depends on part of them (via its Import Table), which in turn depend on another part (via their Import Tables) and so on. Out of all these DLLs there is one, that both the EXE and most of DLLs depend on. This DLL is one of the first to be (statically) loaded at the application startup.
According to all known to me sources describing process’ loading, the DLL_PROCESS_ATTACH entry of this DLL must be called on the process’ primary thread. This is also confirmed by @MSalters answer and @RbMm comment to my other question. But if this is true, then how to explain the following snapshot of the debugger’s “Threads” window, that I received from one of my colleagues (this snapshot was obtained by placing the MessageBox() statement after DLL_PROCESS_ATTACH and attaching the VS debugger):
In this snapshot you can see that the primary thread is stuck in the “ThreadStart” function, while the DLL is being loaded by the worker thread. It is also strange that we see one debugger thread, whereas usually VS debugger doesn’t show its threads.
If someone has an explanation, I’d be glad to hear it.