Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 2.28 KB

File metadata and controls

61 lines (39 loc) · 2.28 KB

editpe

Crates.io Docs.rs Tests & Checks

Resource editor for portable executables.

Enables cross-platform parsing and modification of Windows executables and their resources.

Features

  • Parsing and modification of portable executables
  • Resource editing including icons, manifests, subsystem, version info and more!
  • Resource transfer between files

Compared to other resource editors like rcedit, editpe takes great care to keep the modified executable in a valid state. It does this by parsing and rebuilding the complete resource directory as well as all file and section headers, keeping existing sections intact, and leaving any additional data at the end of the file in place.

Usage

Library

Add editpe as a dependency. The std and images features are enabled by default and can be disabled for no-std support.

editpe = "0.2"
image = { version = "*", features = ["png"] } # to support additional icon file types

Examples

Adding an icon or manifest to an executable
let mut image = Image::parse_file("damocles.exe")?;
let mut resources = image.resource_directory().cloned().unwrap_or_default();

resources.set_main_icon_file("sword.png")?;

let manifest = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
resources.set_manifest(manifest)?;

image.set_resource_directory(resources)?;
image.write_file("damocles.exe");
Transferring resources between executables
let source = Image::parse_file("damocles.exe")?;
let resources = image.resource_directory().unwrap();

let mut target = Image::parse_file("fortuna.exe")?;
target.set_resource_directory(resources.clone())?;
target.write_file("fortuna.exe");

See the tests for other usage examples.

Note that packed executables (like packed with UPX) might not allow resource replacement. Edit the resources before packing if required.