Loading a DLL many times ...

  • Thread starter Thread starter Nicolas
  • Start date Start date
N

Nicolas

Hi all,

Here is a problem about loading a DLL many times using MSVC6:

I have to explicitely load two different flavors of the same libraries
implementing the same interface.
As long as they are not located in the same absolute path, this is ok.
The tricky part comes when these libraries are implicitely linked with other
libraries.

Let's put a few names as examples:
My two libraries explicitely loaded are respectively called A.dll and B.dll
respectively located in A_dir and B_dir directories.
A.dll and B.dll implement the same interface.
Let say these libraries are implicitely linked against X.dll.
So, when A.dll is loaded, X.dll will also be implicitely loaded. Now B.dll
is loaded, but as X.dll has already been loaded, it won't be again.
As far as I can understand the way Microsoft compiler is working, this looks
ok to me.

However, it is requested to me that X.dll must be loaded as many times as
A.dll and B.dll are loaded. By this I mean that the X.dll memory space
should be replicated as many times as A.dll and B.dll are loaded.
This might be achieved by copying X.dll in A_dir and B_dir directories to
give it a different path. The problem is now to force A.dll and B.dll to
implicitely load X.dll in their respective directory.
Then, my problem is how to force an implicit link to use a specific DLL ???
Using a few compiler/linker options, I made it work for Linux. Now it's time
to do it for Windows...

I really would like to thank in advance whoever will help me to solve this.

Thanks in advance,
Nicolas
 
Nicolas said:
Here is a problem about loading a DLL many times using MSVC6:

I have to explicitely load two different flavors of the same libraries
implementing the same interface.
As long as they are not located in the same absolute path, this is ok.
The tricky part comes when these libraries are implicitely linked with other
libraries.

Let's put a few names as examples:
My two libraries explicitely loaded are respectively called A.dll and B.dll
respectively located in A_dir and B_dir directories.
A.dll and B.dll implement the same interface.
Let say these libraries are implicitely linked against X.dll.
So, when A.dll is loaded, X.dll will also be implicitely loaded. Now B.dll
is loaded, but as X.dll has already been loaded, it won't be again.
As far as I can understand the way Microsoft compiler is working, this looks
ok to me.

However, it is requested to me that X.dll must be loaded as many times as
A.dll and B.dll are loaded. By this I mean that the X.dll memory space
should be replicated as many times as A.dll and B.dll are loaded.

What possible reason could there be for such a request? If you need to
distinguish between two different "opens", for example, then you could
allocate a context structure in whatever "open" call there is in X.dll, but
the two code segments would be identical. There is absolutely no point in
loading the same code segment twice.
I really would like to thank in advance whoever will help me to solve this.

I need to be convinced that this solves some real-world problem.
 
Back
Top