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!

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")

pe.sections.append(DATA)

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:

http://www.woodmann.com/fravia/covert1.htm

Good Luck

Mece

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.