[MUD-Dev] Dynamic Loading of Modules

Jon A. Lambert jlsysinc at ix.netcom.com
Sun Mar 22 14:34:54 New Zealand Daylight Time 1998


On 21 Mar 98 at 10:21, Chris Gray wrote:
> [Niklas Elmqvist:]
> 
> :Yes, I do know that Windows has dynamically linked libraries, just like
> :Sun and Linux and whatnot (I think they had that *before* it went
> :32-bit, however). However, I suppose you did not read the earlier
> :part (this may be blamed on my too-active-snippage), where I explained
> :about my "discovery" where a server binary with a base class called aClass
> :could dynamically load a module which implemented a subclass of aClass
> :called bClass and *still* use the bClass (as a reference to an aClass
> :object, of course, using polymorphism) even though the server had no idea
> :of its existence at compile-time. (Phew.) According to my RL friend (I
> :have no personal experience in this), this scheme is impossible to
> :implement using Windows DLLs -- I believe he tried after hearing me
> :explain about it.
> 
> Well, I hate to think I'm becoming knowledgeable about Windows, but I
> guess its actually true. A co-worker and I have been playing with a small
> DLL on NT, and the debugger and paging interfaces. We haven't been using
> C++, however, just C, so there may be some extra stuff we haven't noticed.
> 
> In order to get your dynamic stuff working right, you have to (of course)
> ensure that the main code and the dynamic code are compiled by the same
> compiler, so that the mangled names come out right. You also normally
> use the '__cdecl(dllexport)' magic word with DLL entry points. So, you
> would need the partner '__cdecl(dllimport)' on the declaration of the
> function pointers you use. 

I have only played with this stuff in C++, specifically BorlandC++.  
I know that Visual C++ 4.1 and earlier did not support the _import 
keyword.  Most of the items Nicklas mentions are more compiler 
dependent than OS dependent.  Prologue and epilogue code (vtables) 
are generated by the compiler to handle run-time polymorphism, thus, 
while it can be done in C, you will be writing this code yourself.  
All modules must be prepared with the same compiler.

--
--/*\ Jon A. Lambert - TychoMUD     Internet:jlsysinc at ix.netcom.com /*\--
--/*\ Mud Server Developer's Page <http://www.netcom.com/~jlsysinc> /*\--
--/*\   "Everything that deceives may be said to enchant" - Plato   /*\--



More information about the MUD-Dev mailing list