Howard said:
I don't know about you, but when I use a DLL, I often explicitly load it in
run-time code, then get the address of the function I need to call, then
call the function. Saying that it links "before any of the executable's
opcodes evaluates" doesn't sound correct to me.
But loading a DLL "manually" is a different way then linking the DLL, which
means entering all used symbols to the Import Address Table of the
executable, which is used by the loader later on.
In a typical windows application no code from within the executable is
executed before all (linked) DLLs are loaded, because the loader will load
all DLLs before it starts to execute the entry point (typically CRT main,
which does the initialisation and calls your int main() afterwards). But as
windows DLLs have a main (entry point) as well (which is e.g executed when
the dll is loaded), someone could execute code located in the executable
from such a dllmain(). To achieve this you need to know what to execute, so
the executable need to export symbols, which can be found from other modules
(DLLs), which means you can call a GetProcAddress(...) and get the address
of the exported symbol.
In such cases code from within the executable is executed before all linked
DLLs are loaded.
If you think this sounds very constructed, well there are executables out
there, which do exactly this, but
I have no idea why ;-)
Wouldn't it have to wait
until I make the call to load it? (Otherwise, whatever would the call to
load it be doing?)
If you are using LoadLibrary() everything is under your control and you are
responsible for providing valid function addresses before you call them.
Regards
Michael