Greetings kind shrew!

So I'm needing to add a text resource to a PE executable file for Windows. However I'm unsure on how to do such. I did find a module called 'pefile' but this was of no help as it's functions did not include adding resources to files. I don't even know if this is possible in Python. Could anyone shed some light unto this?

Thanks Bye!

7 Years
Discussion Span
Last Post by mece

It maybe possible to add a sections to a binary using PEFile. by appending the new data to the end of the sections

import pefile
pe = pefile.PE("binary.exe")


The problem is pefile will not recognise the new section because when the sections attributes are retrieved from the EXE they are organised in a specific list format done in the Structure Class.

Examining the __get_format__ and __set_format__ attributes in the other sections might help point you in the right direction. An alternative option to using pefile is adding the section to the end of the binary and updating the necessary size and offset attributes in pefile to access the new code. Here is an excellent reference if needed:


Good Luck


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.