如何使用 WinSxS 清单重定向到旧版本的 DLL?
假设我有一个使用 MSHTML 的应用程序。安装 IE9 beta 会更新 MSHTML,这会破坏我的应用程序。我发现 IE8 dll 的副本仍然存在于 WinSxS 文件夹中,所以也许我可以以某种方式使用它们而无需重新编译我的程序? WinSxS 可以吗?
我已经搜索了很长时间,但无法弄清楚如何重定向加载程序以使用 IE8 MSHTML(位于 WinSXS 中)而不是 IE9(位于 %SYSTEMROOT%\system32 中)。任何想法/例子将不胜感激。
Let's say I have an application that uses MSHTML. Installing IE9 beta would update MSHTML which breaks my application. I found that copies of IE8 dll is still present in the WinSxS folder, so maybe I can somehow use them without recompiling my program? Can WinSxS do it?
I've searched for a long time but couldn't figure out how to redirect the loader to use the IE8 MSHTML (which is in WinSXS) instead of the IE9 (which is in %SYSTEMROOT%\system32). Any ideas/examples would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从那时起我就采用了不同的方法来解决这个问题。我将分享我最终所做的——我劫持
LoadLibrary
并加载我想要的任何 DLL:通过清单通过 DLL 重定向加载两次 DLL 文件。为了回答问题的具体标题(“使用 WinSxS 清单进行重定向”),根据我与 WinSxS 的长期斗争,我将回答“不,你不能”(如果您反对,请投反对票)不同意,我很乐意看看如何做到这一点。)
I've since gone with a different approach to this problem. I'll share what I eventually did -- I hijack
LoadLibrary
and load whatever DLL I want: DLL file loaded twice with DLL redirection through manifest.To answer the specific title of the question ("use WinSxS manifests to redirect"), I'll answer with "No, you can't" based on my long time battle with WinSxS (downvote if you disagree, I'll be happy to see how that can be done.)
您绝对不能使用 WinSxS 清单或策略重定向来强制加载不同版本的操作系统组件。虽然 os 组件也存储在 WinSxS 存储中,但它们不能作为 sxs 程序集进行绑定,因此不可能进行这种重定向。
卑躬屈膝地重定向 LoadLibrary 并强制加载旧版本的 mshtml(或任何其他操作系统 DLL)是一个非常糟糕的主意,我强烈建议不要这样做。原因包括以下事实:较旧的 DLL 可能不会出现在所有安装中,您不太可能正确挂钩所有加载路径(从而创建一个奇怪的混合体),当然,像 MSHTML 这样的东西是为在特定的环境中使用而设计的。方式和任何其他使用都可能会导致以后出现问题 - 特别是在 HTML 等安全敏感内容中。
马丁
You definitely can't use WinSxS manifests or policy redirection to force loading different versions of OS components. While os components are also stored in the WinSxS store, they are not bindable as sxs assemblies and so this kind of redirection is not possible.
Grovelling around to redirect LoadLibrary and force loading of an older version of mshtml (or any other OS DLL) is a very bad idea and I strongly recommend against it. Reasons include the fact that the older DLL may not be present on all installs, that you are unlikely to correctly hook all the loading paths (and hence create a strange hybrid), and of course that things like MSHTML are designed for use in a specific way and any other use could lead to problems later - especially in security sensitive stuff like HTML.
Martyn