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

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

问题描述

我使用两个由相同供应商生产的商业库,称为VendorLibA和VendorLibB。库分发与依赖于编译器版本的许多DLL(例如VC7,VC8)。这两个库都依赖于这个供应商生产的另一个库,名为VendorLibUtils,并且包含在一个DLL中。



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



有任何方式,我可以使用这两个库在相同的过程下?



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

编辑:忘了提到显而易见的,我不必为任何商业库的源代码,也许我永远不会有(



EDIT:替代btw是这样做的: http://stackoverflow.com/questions/312569/how-to-combine-gui-applications-in-windows

解决方案

由于您不直接使用VendorLibUtils,我假设您不能使用 LoadLibrary 等。



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



如果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: http://stackoverflow.com/questions/312569/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 VendorLib*X* 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天全站免登陆