Skip to main content

Write COFF object files

Project description

A library for building COFF object files.


Start with the ObjectModule class:

module = ObjectModule()

Now, let’s create a ‘.text’ section:

section = Section(b'.text', SectionFlags.MEM_EXECUTE)

Add a bit of code: = b'\x29\xC0\xC3'  # return 0
section.size_of_raw_data = len(

Good enough, let’s add it to our module:


To make use of that bit of code, we are going to need an exported symbol:

main = SymbolRecord(b'main', section_number=1, storage_class=StorageClass.EXTERNAL)

Set the value to the offset in the section:

main.value = 0

And add it to our module:


That’s enough, let’s write our module to a file:

with open('test.obj', 'wb') as obj_file:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cough, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size cough-0.2.1-py3-none-any.whl (8.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cough-0.2.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page