2. What is the relationship between dllcrt0.obj and DllMain.obj?
"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote:
Here is what I'm sure of: The CRT has a source file named
Dllmain.c. The comments say it is used when no other version is
provided.
Here is what I'm not sure of: I think that it is a simple matter
specifying Dllmain.obj on the linker command line but _after_ all
of the other object modules and libraries. If the reference is
resolved early, the CRT's Dllmain won't be linked. If not, it will
It's not even that hard. DllMain.obj is included in the run-time
library (msvcrt.lib or libcmt.lib).
When we link the DLL, we specify /entry:_DllMainCRTStartup@12. The
linker goes to find that in its library list, and finds it in
dllcrt0.obj in the run-time library. That routine references
DllMain, so the linker goes to find it. If DllMain is already in
the list of known symbols (that is, if it was part of the program),
it links to that. Otherwise, it goes back to the libraries, where
it will find it in dllmain.obj. --
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.