How to add a new import to a PE file?
See original GitHub issueHello,
Thanks for the library. I took a look at both the docs, the issues and the source code, but couldn’t find something similar to what I need to do: programatically add a new import to a PE file.
To read what are the current imports I use PeFile.ImportedFunctions
, but I noticed it is read only. Any tips on how to achieve that?
My goal is to write an auto patcher that will be able to fetch a DLL from the internet and then patch it to load a custom DLL of mine. I’m able to do that manually using some software I found online called LordPE, but I need to do that programatically. Sadly there’s no source code available for it.
I’m also having a tough time grasping how to implement that from scratch myself. The general idea seems to be:
- Parse the PE
- Find the offset where the Import section starts
- Add a new import
- Update the offset
- Probably something more that I might be missing
Then I found out about PeNet and think it might be able to really help me out.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Documentation to add imports: http://secana.github.io/PeNet/articles/imports.html
Happy to hear that it works. I’ll keep the alpha out for a few more day in the case that you stumble upon a bug. If not I’ll merge it into master and release 2.3.0.