4

I have a file plugin.dll whose import table links to several symbols in foo.dll. I want to make a new file plugin-modified.dll, such that plugin-modified.dll is identical to plugin.dll, except that instead of linking to these symbols in foo.dll, its import table imports those same symbols from bar.dll. Can anyone suggest a tool that will rewrite PE files in this way? Ideally command-line/scriptable and open-source, but I'm willing to consider alternatives...

(The real use case is that I want to replace the reference to foo.dll with foo-unique-id-934019384.dll, so as to be able to ship plugin.dll and foo.dll together while avoiding name collisions, just in case someone else also distributes some other plugin that links to its own, different version of foo.dll.

On Linux this can be done with the patchelf tool, and on OS X it can be done with install_name_tool; I'm looking for a Windows equivalent.

I'm aware that SxS assemblies may be able to solve this problem in a different way, but they have their own limitations so I want to explore both approaches before deciding.)

2
  • sounds scary dangerous. can you change it to dynamically load it using LoadLibarary? Feb 12, 2016 at 21:22
  • No, I'm looking for a general tool that I can use to bundle up arbitrary plugins without having to make bespoke build system and source code modifications. (Specifically this is in the context of providing a general tool for people distributing Python packages on Windows -- like I said, we have standard/reliable ways of doing this exact thing on Linux and OS X already. And it's not really that scary... there's just a string in the PE import table that we want to replace with a different string.) Feb 12, 2016 at 22:37

1 Answer 1

8

Well, I got so annoyed at missing this tool that I wrote it :-)

https://github.com/njsmith/machomachomangler

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.