Categorygithub.com/mikewiacek/pefile-go
modulepackage
0.0.0-20240118192019-c0873c73ccc3
Repository: https://github.com/mikewiacek/pefile-go.git
Documentation: pkg.go.dev

# README

pefile-go

Golang implementation of pefile, stripped down to some bare minimums.

To use as a library:

  $ go get github.com/awsaba/pefile-go

To install the demo program stub:

  $ go install github.com/awsaba/pefile-go/pefile

Features

Some of the tasks that pefile makes possible are:

  • Inspecting headers
  • Analysis of sections' data
  • Parsing exports

Motivations

  • Have a golang library for PE file related utilities.
  • Projects based on "debug/pefile" would have an awkward split between was it added on by the wrapper lib and what is included in the core go lib.

Dependencies

pefile-go is self-contained. It has no dependecies and currently assumes a little-endian architecture.

Acknowledgements

Major changes from those versions

  • No hard-coded lists of ordinals. They were not accurate to those files in recent versions of Windows. If you need them, Microsoft tools can be used to retrieve the public symbols that contains that information, but that is beyond the scope of this project.
  • Simpler package layout.
  • As much adherence to golang conventions as possible. Hopefully what's left can be configured to be ignored by your editor of choice when running golint.

Additional resources (originally from pefile's readme)

PDFs of posters depicting the PE file format:

The following links provide detailed information about the PE format and its structures.

# Packages

No description provided by the author

# Functions

NewPEFile attempt to parse a PE file from a file on disk, using mmap.
NewPEFileFromBytes returns a PEFile from the file returned by r.
PowerOfTwo Returns whether this value is a power of 2.
SetFlags takes the binary flag value read from the guest, checks it against all the key-values in charMap, and sets the corresponding values in the passed in flagMap Should be called after reading raw header data out of the file to fill in convience structs.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Terse Executables have a 'VZ' signature.
2^20.
No description provided by the author
No description provided by the author

# Variables

DebugTypes is a lookup from the string name to flag value.
DirectoryEntryTypes provides names for the entries in the data directory header.
DllCharacteristics flags define some OS specific functionality.
ImageCharacteristics is a lookup from the string name to flag value Instantiated as Pe.COFFFileHeader.Flags.
Lang language definitions.
MachineTypes is a lookup from string name to the value of the flag.
RelocationTypes is map from the string name to the flag value.
ResourceType names and flag values.
SectionCharacteristics is a lookup from the string name to flag value.
Sublang sublanguage definitions.
SubsystemTypes is a lookup from the string name to flag value.

# Structs

BaseRelocation wrapper.
BaseRelocationD raw field data read from the file.
BaseRelocationEntry wrapper.
BaseRelocationEntryD raw field data read from the file.
BoundForwarderRef wrapper.
BoundForwarderRefD raw field data from file.
BoundImportDescriptor wrapper.
BoundImportDescriptorD raw field data read from file.
COFFFileHeader wrapper.
COFFFileHeaderD raw data field read from the file.
DataDirectory wrapper.
DataDirectoryD raw data field read from the file.
DebugDirectory wrapper.
DebugDirectoryD raw field data read from the file.
DelayImportDescriptor wrapper.
DelayImportDescriptorD raw data field read from the file.
DosHeader wrapper.
DosHeaderD raw data field read from the file.
ExportData wrapper.
ExportDirectory wrapper.
ExportDirectoryD raw data field read from the file.
ImportData wrapper.
ImportData64 64-bit version wrapper.
ImportDescriptor wrapper.
ImportDescriptorD raw data field read from the file.
LoadConfigDirectory wrapper.
LoadConfigDirectory64 wrapper.
LoadConfigDirectory64D raw field data read from file.
LoadConfigDirectoryD raw field contents read from the file.
NTHeader wrapper.
NTHeaderD raw data field read from the file.
OptionalHeader wrapper.
OptionalHeader64 wrapper.
OptionalHeader64D raw data field read from the file.
OptionalHeaderD raw data field read from the file.
PEFile is a representation of the PE/COFF file with some helpful abstractions.
ResourceDataEntry wrapper.
ResourceDataEntryD raw data field read from the file.
ResourceDirectory wrapper.
ResourceDirectoryD raw data field read from the file.
ResourceDirectoryEntry wrapper.
ResourceDirectoryEntryD raw data field read from the file.
SectionHeader wrapper.
SectionHeaderD raw data field read from the file.
String table entry wrapper.
StringD raw data field read from the file.
StringFileInfo wrapper.
StringFileInfoD raw data field read from the file.
StringTable wrapper.
StringTableD raw data field read from the file.
ThunkData wrapper.
ThunkData64 wrapper.
ThunkData64D raw field data read from the file.
ThunkDataD raw field data read from the file.
TLSDirectory wrapper.
TLSDirectory64 wrapper.
TLSDirectory64D raw field data read from the file.
TLSDirectoryD raw field data read from the file.
Var wrapper.
VarD raw data field read from the file.
VSFixedFileInfo wrapper.
VSFixedFileInfoD raw data field read from the file.
VSVersionInfo wrapper.
VSVersionInfoD raw data field read from the file.