Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use two incompatible versions of the same DLL in the same process?

I'm using two commercial libraries that are produced by the same vendor, called VendorLibA and VendorLibB. The libraries are distributed as many DLLs that depend on the compiler version (e.g. VC7, VC8). Both libraries depend on a another library, produced by this vendor, called VendorLibUtils and contained in one DLL.

The problem: VendorLibA uses a different version of VendorLibUtils than VendorLibB. The two versions are not binary compatible, and even if they were it would be a bad idea to use the wrong version.

Is there any way I could use the two libraries under the same process?

Note: LoadLibrary can't solve this since my process is not that one that's importing VendorLibUtils.

EDIT: Forgot to mention the obvious, I don't have to source code for any of the commercial libraries and probably I will never have (sigh).

EDIT: The alternative btw, is to do this: How to combine GUI applications in Windows

like image 648
kshahar Avatar asked Nov 24 '08 20:11

kshahar


Video Answer


1 Answers

I think your most promising option is to complain, loudly, to the vendor who is distributing mutually incompatible products. That rather goes against the idea of a DLL.

You can't just put the DLLs in different directories. Once a DLL with a given name is loaded, all other attempts to load another DLL with the same module name will simply use the one that's already loaded, even if the paths are different.

From that, we can conclude that to load two copies of VendorLibUtils, one copy needs to have a different name. You can't just rename the DLL file; the code in your program won't know to look for the different file. Therefore, perhaps there's a way to edit the import table of VendorLibB to make it think the functions it needs are in VendorLibUtilsB.dll instead of just VendorLibUtils.dll. I'm afraid I don't know of any utility that will do that, but I have little doubt it's possible to do.

like image 74
Rob Kennedy Avatar answered Oct 26 '22 07:10

Rob Kennedy