direct.dist.pefile
from direct.dist.pefile import DataResource, IconGroupResource, PEFile, RVASize, ResourceTable, Section, VersionInfoResource, expdirtab, impdirtab
Tools for manipulating Portable Executable files.
This can be used, for example, to extract a list of dependencies from an .exe or .dll file, or to add version information and an icon resource to it.
Inheritance diagram
- class DataResource[source]
Bases:
object
A resource entry in the resource table.
- accelerator = 9
- animated_cursor = 21
- animated_icon = 22
- bitmap = 2
- cursor = 1
- cursor_group = 12
- dialog = 5
- dlg_include = 17
- property encoding
- font = 8
- font_directory = 7
- html = 23
- icon = 3
- icon_group = 14
- manifest = 24
- message_table = 11
- plug_play = 19
- rcdata = 10
- string = 6
- version = 16
- vxd = 20
- class IconGroupResource[source]
Bases:
object
- class Icon(width, height, planes, bpp, size, id)
Bases:
tuple
- property bpp
Alias for field number 3
- property height
Alias for field number 1
- property id
Alias for field number 5
- property planes
Alias for field number 2
- property size
Alias for field number 4
- property width
Alias for field number 0
- code_page = 0
- type = 14
- class PEFile[source]
Bases:
object
- add_icon(self, icon, ordinal=2)[source]
Adds an icon resource from the given Icon object. Requires calling add_resource_section() afterwards.
- add_resource_section(self)[source]
Adds a resource section to the file containing the resources that were previously added via add_icon et al. Assumes the file does not contain a resource section yet.
- add_section(self, name, flags, data)[source]
Adds a new section with the given name, flags and data. The virtual address space is automatically resized to fit the new data.
Returns the newly created Section object.
- add_version_info(self, file_ver, product_ver, data, lang=1033, codepage=1200)[source]
Adds a version info resource to the file.
- get_address_offset(self, addr)[source]
Turns an address into a offset relative to the file beginning.
- imports = ()
- class RVASize(addr, size)
Bases:
tuple
- property addr
Alias for field number 0
- property size
Alias for field number 1
- class expdirtab(flags, timdat, majver, minver, name, ordinal_base, nentries, nnames, entries, names, ordinals)
Bases:
tuple
- property entries
Alias for field number 8
- property flags
Alias for field number 0
- property majver
Alias for field number 2
- property minver
Alias for field number 3
- property name
Alias for field number 4
- property names
Alias for field number 9
- property nentries
Alias for field number 6
- property nnames
Alias for field number 7
- property ordinal_base
Alias for field number 5
- property ordinals
Alias for field number 10
- property timdat
Alias for field number 1