Hi everyone

I want to build a modulair system (for my engine). It should have core DLL which implements managing of resources at a very abstract level. Modules can be hooked and these can implement classes with their own properties. Other modules (or the EXE) can create objects of a class and change their properties (all through this abstract Core DLL).

Besides that, it should be possible for the game (EXE or one of the modules) to call exported functions from different modules. This is a more easy and non-abstract way of accessing module/class data.

So let's say i want to get the vertexcount from a Mesh (All identifiers are pointers).

(CODE BELOW: **this post editor is weird, pascal tags dont work here** )

I want to build this abstract core because my engine will be more modulair, and it will be easier for me to intergrate the game into the editor (when i start building an editor).

And my question is..........

What is the best way to link these DLL's together?

I don't know much about DLL linking, but yesterday i realized, that it might be more complex than i thought, when i was originaly thinking about this system.

So.. Let's think of a scenario where i have my EXE, the Core and one module.
The EXE want's to acces the module both through the abstract core, and by using the Module's exported routines. This will be a combination of Static and dynamic linking.


-- The EXE project will contain a unit with all the exported routines for both the core and the module. (Static linking).
-- The EXE will call a N3D_Module_Hook routine (for each module), to load the Module into the core.
When this is called, the core will call LoadLibrary with the DLL path. (dynamic linking).
After this, communication (MODULE <-> CORE) is possible, by using datastructures with lots
of callbacks, that are provided by the MODULE when it's entry point code is executed.


But when the Module is loaded by the core (by LoadLibrary), It has allready been staticly linked when the EXE initialized. This raises a few (more specific) questions:

-- What happens when i call Loadlibrary from the Core, when the target module allready has been staticly linked by the EXE?? Will it be copied in memory or is the same instance used?

-- When i both staticly and dynamicly load a module, is it's entry point called twice??

If so, this might cause problems. In my current design, my entry point is the place where the
module registers itsself in the Core. So i have to make sure that the core module is allready
loaded (staticly linked) before all other modules. This raises another question:

-- In what order are modules staticly linked??

I hope you all understand my little story. If someone knows good articles of DLL linking, please post the URL. If anyone can think of a better way of building such a "Core with lots of modules - Spider", please let me know.

Thanx a lot for reading.

[pascal]
//--Through abstract level
N3D_Class_GetByName('Mesh', MyMeshClassIdentifer ); //gets the Mesh class identifer

N3D_Class_GetPropertyByName( MyMeshClassIdentfier , 'VertexCount', MyPropertyIdentifier );
//Gets the property identfier from the class

//Gets the VertexCount property from an Object which should be a Mesh
//And stores it at the address of VertexCount
N3D_Object_GetProperty( MyObjectIdentifier, MyPropertyIdentfier, @VertexCount);


//--Direct call to an exported function
N3D_Mesh_GetVertexCount( MyMeshIdentifier, Vertexcount );
//Accepts vertexcount as VAR parameter
[/pascal]