Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load multiple copies of dll in same process

I have a dll produced by a third party that has some sort of internal datastructure that limits it's size to X elements.

So basically, it has a Queue with X as the limit.

Now from what I've known DLL's are per process, but is it possible to load a DLL more than once? Maybe per thread? In C#? or in C++/CLI?

I'm trying to load a native c++ dll.

like image 932
halivingston Avatar asked Feb 04 '23 08:02

halivingston


2 Answers

Unfortunately, the NT core DLL loader routines don't expose a public interface to skip the pool of already-loaded DLLs. As such, you're left with just a few choices:

  • Copy, hardlink, symlink, and/or use reparse points to fool the loader into thinking you have multiple distinct DLLs.
  • Use multiple processes, and load one DLL per process.
  • Write a new DLL loader (very much not for the faint of heart!)
  • Convince the DLL's vendor to fix it (likely to be harder than writing a DLL loader :)
like image 113
bdonlan Avatar answered Feb 06 '23 15:02

bdonlan


The only way you can do it is by having multiple copies of the same dll, and then load them dynamically.

like image 21
Shay Erlichmen Avatar answered Feb 06 '23 14:02

Shay Erlichmen