编写一个加载 msvcr80.dll 并公开 free() 函数的 DLL
我有一个依赖于 MSVCR80 的第三方 DLL,并分配我需要清理的资源。该库不公开用于执行此操作的免费
函数。相反,我需要加载相同的运行时库并手动调用 free
函数。
作为一种解决方法,我尝试编写一个“包装器”DLL,它加载正确的运行时并公开 free
函数。此 DLL 是使用 Visual Studio 2010 创建的,并且依赖于单独的运行时库。执行 LoadLibrary("msvcr80.dll")
失败并出现错误 R6034,我猜这是因为明显的问题。
是否可以使用 LoadLibrary 加载 msvcr80.dll?我是否需要创建一个清单,将其嵌入到 DLL 中并将 msvcr80.dll 存储在与包装器 DLL 相同的目录中?
我意识到这是第三方库的一个缺陷,但我几乎坚持使用这个版本。让供应商解决这个问题很可能不是一个选择。
I have a third-party DLL that depends on MSVCR80 and allocates resources that I need to cleanup. The library does not expose a free
-function for doing this. Instead, I need to load the same runtime library and manually call the free
function.
As a workaround I'm trying to write a "wrapper" DLL that loads the correct runtime and exposes the free
function. This DLL is created using Visual Studio 2010 and is dependent on a separate runtime library. Doing LoadLibrary("msvcr80.dll")
fails with error R6034 which I guess is because of manifest issues.
Is it even possible to load msvcr80.dll using LoadLibrary
? Do I need to create a manifest, embed it into the DLL and store msvcr80.dll in the same directory as my wrapper DLL?
I realize that this is a flaw in the third-party library, but I'm pretty much stuck with this version. Getting the vendor to fix this is most likely not an option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许有更好的解决方案,但万一其他一切都失败了,您可以在某处找到 VC++ 2005 Express Edition 的副本(=免费,不需要盗版
;)
),它使用 8.0 版本的编译器,因此有缺陷的 dll 的运行时相同。然后,您可以用它构建您的包装器 dll,它只会调用其 CRT 提供的
free
(仔细检查您是否使用的是 dll 版本!)。Probably there are better solutions, but in case everything else failed you could find somewhere a copy of VC++ 2005 Express Edition (=free, no piracy is needed
;)
), which uses the version 8.0 of the compiler, and thus the same runtime of the defective dll.Then you would build your wrapper dll with it, which would just call the
free
provided by its CRT (double check that you're using the dll version!).