我可以在同一个进程中使用同一个DLL的两个不兼容的版本吗? [英] Can I use two incompatible versions of the same DLL in the same process?

查看:125
本文介绍了我可以在同一个进程中使用同一个DLL的两个不兼容的版本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用由同一厂商生产的两个商业图书馆,名为VendorLibA和VendorLibB。这些库分布在很多依赖于编译器版本的DLL(例如VC7,VC8)中。这两个库依赖于由该供应商生产的另一个库,名为VendorLibUtils并包含在一个DLL中。



问题:VendorLibA使用的VendorLibUtils不同于VendorLibB。这两个版本不是二进制兼容的,即使是使用错误的版本也是一个坏主意。



有没有办法我可以使用这两个库在相同的过程中?



注意: LoadLibrary无法解决这个问题,因为我的进程不是那个导入VendorLibUtils的进程。

编辑:忘记提到明显的,我不必为任何商业图书馆的源代码,也许我永远不会(叹息



编辑:替代btw是这样做的:如何在Windows中组合GUI应用程序

解决方案

由于您不直接使用VendorLibUtils,我认为您不能使用 LoadLibrary 等。



如果VendorLibUtils DLL只有按顺序导出,那么您可能会重命名其中一个库并修补相应的VendorLib X ,以便为其导入使用不同的文件名。 p>

如果VendorLibUtils DLL具有一个或多个具有相同名称的导出符号,那么您可能需要修补导入和导出表,但是我们希望不! : - )


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

解决方案

As you are not using VendorLibUtils directly, I assume you can't use LoadLibrary etc.

If the VendorLibUtils DLLs only have exports by ordinal, you could probably rename one of the the libraries and patch the corresponding VendorLibX to use a different filename for its imports.

If the VendorLibUtils DLLs have one or more exported symbols with the same names, you might need to patch the imports and export tables too, but let's hope not! :-)

这篇关于我可以在同一个进程中使用同一个DLL的两个不兼容的版本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆