【问题标题】:DLL redirection - working in XP, not in Windows 7DLL 重定向 - 在 XP 中工作,而不是在 Windows 7 中
【发布时间】:2013-01-03 09:33:25
【问题描述】:

在 Windows XP 上,我正在为指定的应用程序重定向 user32.dll,但在 Windows 7 上使用相同的设置,user32.dll 不会被重定向。

设置是这样的 - 一个目录包含:

app.exe
app.exe.manifest
user32.dll

app.exe.manifest 包含:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="0.0.0.0"
    name="Redirection"
    type="win32"
  />

  <file
    name="user32.dll"
  />
</assembly>

在 Windows XP 上,app.exe 从应用程序文件夹加载 user32.dll。在 Windows 7 上,app.exe 从 system32 文件夹加载 user32.dll。

如何让 app.exe 从 Windows 7 上的应用程序文件夹中加载 user32.dll? MSDN docs 没有提到平台之间在程序集工作方式方面的任何差异,但一定有一些差异会阻止重定向工作......

有什么想法吗?

【问题讨论】:

  • 在 Win7 上,系统 DLL 有一个额外的间接层,即 ext-ms-win-xxx.dll 存根。打破 Windows dll 之间依赖关系的长期项目的一部分。重定向系统 DLL 会流泪,是时候开始在 VM 中运行此应用了。

标签: windows dll manifest


【解决方案1】:

事实证明,从 Vista 开始的 Windows 平台会进行一些激活上下文缓存,即在应用程序第一次运行时查找清单。如果在第一次运行后添加或更改清单,Windows 不会费心寻找它以节省加载时间。

所以我的方案确实有效,但您需要通过修改应用程序二进制文件(例如时间戳)来强制 Windows 重新缓存激活上下文。

我试过了,我的 user32.dll 是从应用程序目录加载到 Windows 7 中的。

参考:
http://blogs.msdn.com/b/vistacompatteam/archive/2006/11/13/manifest-and-the-fusion-cache.aspx
VB6 Manifest not working on Windows 7

【讨论】:

  • 这仍然适用于 Windows 10。对我有很大帮助,谢谢!
猜你喜欢
  • 1970-01-01
  • 2012-07-04
  • 1970-01-01
  • 2012-07-01
  • 2013-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多