Crate editpe

Source
Expand description

Resource editor for portable executables.

Supports:

  • Parsing and introspection of portable executables
  • Resource editing and icon replacement
  • Resource transfer between files

See Image for the main entry point for parsing, querying and updating a portable executable image.

See ResourceDirectory for working with resource directories.

§Examples

§Replacing the icon of an executable

use editpe::Image;

let mut image = Image::parse_file("damocles.exe")?;

// get the resource directory
let mut resources = image.resource_directory().cloned().unwrap_or_default();
// set the icon file
resources.set_main_icon_file("sword.png")?;
// set the resource directory in the image
image.set_resource_directory(resources)?;

// write an executable image with all changes applied
image.write_file("damocles.exe");

§Transferring resources between executables

use editpe::Image;

let image = Image::parse_file("damocles.exe")?;
// get the resource directory from the source
let resources = image.resource_directory()?;

let mut image = Image::parse_file("fortuna.exe")?;
// copy the resource directory to the target
image.set_resource_directory(resources)?;

// write an executable image with all changes applied
image.write_file("fortuna.exe");

§Cargo features

§Default features

  • std: Enables standard library features, including reading and writing files.
  • images: Enables support for converting and resizing images in other formats when setting icons. Also enables std.

Modules§

constants
Windows API and binary constants.
types
Portable executable data types.

Structs§

Image
Portable executable image representation.
ReadError
Error that can occur when reading and parsing bytes.
ResourceData
Raw resource data.
ResourceDirectory
Portable executable resource directory.
ResourceTable
Portable executable resource table.
VersionInfo
Version info resource. This is a special resource that contains the version information of the executable.
VersionStringTable
Version string table. This is an entry in the version info resource.

Enums§

DataDirectoryType
Image data directory type enumeration.
DynamicImageimages
A Dynamic Image
ImageReadError
Errors that can occur when reading a PE image.
ImageWriteError
Errors that can occur when writing a PE image.
ResourceEntry
Resource entry in a resource table. This can be either a child table or raw data.
ResourceEntryName
Resource directory entry name. This can either be a raw id or a name.
ResourceError
Errors that can occur when modifying resource data.

Traits§

ToIcon
Trait for data types that can be converted to icon data.