When using LoadLibrary on the same file twice, simply a DLL reference counter is increased. Is it possible to load a DLL twice and let it become 2 independent copies, just like loading two DLL files?
Posted on 2003-10-23 08:29:13 by optimus
have you checked to see if it returns the same handle if so theres your answer... im not sure my self..
Posted on 2003-10-23 08:59:04 by devilsclaw
I think its possible to do that by loading same dll on different base addresses in each .exe memory space, but why do you need all this for?
Posted on 2003-10-26 15:35:27 by Mikky
but how?
I need 2 duplicated copy of a DLL threads in my 8051 Emulator so that 2 CPUs can be emulated easily.
Posted on 2003-10-26 22:34:18 by optimus
If you launch the emulator program twice, you will get two virtual CPUs, each with its own "copy" of the DLL. However, they will not be synchronized with each other.

To get two copies in the same process (executable), I would try putting a copy of the DLL in another directory and loading the DLLs from the different directories. If it works, then I would create directories on-the-fly for each processor I wanted to create.
Posted on 2003-10-27 16:27:23 by tenkey
that means keeping 2 copies of the same DLL file?
Posted on 2003-10-27 19:49:59 by optimus

but how?
I need 2 duplicated copy of a DLL threads in my 8051 Emulator so that 2 CPUs can be emulated easily.

Why not just create 2 threads and call the appropriate functions in the DLL?
Posted on 2003-10-27 21:27:30 by Mecurius
yeah, that's something. let me try.
Posted on 2003-10-27 23:37:46 by optimus
hi optimus
i feel that it is possible to load a dll twice by using an artful protection scheme by accessing the file by its alternate short name, leaving the system loader in delusion and loading them in 2 addresses.

thank you
Posted on 2004-10-06 15:14:20 by nickdigital
if the dll is thread-aware (it allocates a new portion of the memory for every new thread at DLL_THREAD_ATTACH, and deallocates it at DLL_THREAD_DETACH) you can just use LoadLibrary() twice on 2 different threads (or even 1 - i can't remember now). if not - the only option is to cheat somehow - use two copies, or play with processes and filemapping for synchronization, etc.
Posted on 2004-10-06 22:18:43 by ti_mo_n