[EMAIL PROTECTED] wrote:
Suppose the main program (the .exe file) contains a
function procA() and the DLL contains a function procB().
I want procB() to be able to call procA().
While it is possible for the EXE to export a function via a .def file,
and for DLL to import it, it's a configuration nightmare. The usual way
to do what you want is for a DLL to export some kind of an
initialization function that accepts a function pointer (a callback) as
a parameter.
See for example HttpExtensionProc:
http://msdn.microsoft.com/library/en-us/iissdk/html/5f489650-d679-4523-8f44-4263c46e3c90.asp
It's a main entry point that should be implemented by an ISAPI extension
DLL (a plug-in module for Internet Information Server (IIS), MS' web
server). Note how it takes EXTENSION_CONTROL_BLOCK structure as a
parameter, that contains pointers to functions implemented by IIS
executable. This is how the extension talks back to its host.
This all works great on Unix. When I use dlopen() to
attach the shared library, the procA() reference in
the shared library is automatically resolved to the
address of procA() in the main program.
On Windows, the loader works in a very different way. Basically,
export/import connections are established at link time, not at load
time. The loader does not perform a symbol search over all the DLLs, the
import tables in the executable image (emitted by the linker) tell it
exactly where to look.
Igor Tandetnik