我如何修改 PE 导入 table,而不是链接到 foo.dll,而是链接到 bar.dll?

How can I modify a PE import table so that instead of linking to foo.dll it links to bar.dll?

我有一个文件 plugin.dll,其导入 table 链接到 foo.dll 中的几个符号。我想创建一个新文件 plugin-modified.dll,这样 plugin-modified.dllplugin.dll 相同,只是不是链接到 foo.dll 中的这些符号,而是导入 table 从 bar.dll 导入那些相同的符号。任何人都可以建议一个可以用这种方式重写 PE 文件的工具吗?理想情况下 command-line/scriptable 和开源,但我愿意考虑替代方案...

(真正的用例是我想用 foo-unique-id-934019384.dll 替换对 foo.dll 的引用,以便能够一起运送 plugin.dllfoo.dll在避免名称冲突的同时,以防万一其他人也分发了一些链接到其自己的不同版本 foo.dll.

的其他插件

在 Linux 上可以使用 patchelf 工具完成,在 OS X 上可以使用 install_name_tool 完成;我正在寻找 Windows 等价物。

我知道 SxS 程序集可能能够以不同的方式解决这个问题,但它们有自己的局限性,所以我想在决定之前探索这两种方法。)

嗯,我很生气错过了这个工具,所以我写了它:-)

https://github.com/njsmith/machomachomangler