RE: [GD-Windows] GetProcAddress()
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2001-10-17 17:53:59
|
> logging, etc). It's actually possible to have a DLL load symbols from an > executable, but the executable name has to be known at link time. The > problem I ran into is that I wanted to be able to use this one rasterizer > DLL with multiple executables (the game itself, world builder tools, asset The MacOS and BeOS linkage models allowed a magic name to be used for linking, meaning "whatever application is loading me". That was very convenient. > viewers, etc). I did some research and ended up using the techniques > involved in hooking DLL functions to actually allow the DLL to rebind the > imported functions into the executable that loaded it. Very nifty. If The approach I've ended up using on platforms that don't have the magic host linkage capability, is simply to configure the interface gotten out of the DLL with a callback interface. class SomeDllInterface; class HostCallbacks { public: virtual void LogAMessage( SomeDllInterface * source, char const * fmt, ... ) = 0; ... }; class SomeDLLInterface { public: virtual void setHostCallbacks( HostCallbacks * cb ) = 0; ... }; This has the benefit of not requiring you to find the main module handle and start picking out symbols by name from there (although that works, too). Cheers, / h + |