Crate winres_edit

Crate winres_edit 

Source
Expand description

github crates.io docs.rs license

This crate allows you to load and modify Windows resources inside of .exe and .res files. This crate currently does not support actual resource data destructuring with exception of Version Strings (VS_VERSIONINFO), which is useful to modify application manifests. Loaded resources are available as raw Vec<u8> data, useful to modify bitmaps and icons.

Please note that all operations performed on the opened resource file are accumulated and are then “flushed” to the file when the file is closed using the close() function. This is due to the behavior of the underlying Win32 API (UpdateResource) functionality used by this crate.

§Example

§Load and update a resource
let mut resources = Resources::new(&Path::new("myfile.exe"));
resources.load().expect("Unable to load resources");
resources.open().expect("Unable to open resource file for updates");

resources.find(resource_type::ICON,Id::Integer(1))
    .expect("unable to find main icon")
    .replace(icon_data)?
    .update()?;

let version: [u16;4] = [0,1,0,0];
resources.get_version_info()?.expect("Unable to get version info")
    .set_file_version(&version)
    .set_product_version(&version)
    .insert_strings(
        &[
            ("ProductName","My Product")
            ("FileDescription","My File")
        ]
    )
    .remove_string("SomeExistingString")
    .update()?;

resources.close();
§Create a new resource
let res = Resource::new(
    &resources,
    resource_type::ICON.into(),
    Id::Integer(14).into(),
    1033,
    target_icon.data(),
);
res.update()?;

Modules§

resource_type
List of resource constants representing Windows resource types expressed as Id

Macros§

pcstr
Convert a string to a zero-terminated windows::core::PCSTR string.

Structs§

Date
Date helper used for serializing and deserializing 2 LE-encoded u32 values into a single u64 value.
FileInfo
Rust representation of VS_FIXEDFILEINFO structure.
Header
Helper representing structure data header used in VS_VERSIONINFO and all related data structures.
Resource
Structure representing a single resource
ResourceDataInner
Placeholder for future data serialization (not implementated)
Resources
Data structure representing a resource file. This data structure points to a .res or .exe file and allows loading and modifying resource in this file.
Version
Windows Version value represented as [u16;4] array. This version struct is helpful for serialization and deserialization of the versions packed into a u64 value represented as 2 LE-encoded u32 (DWORD) values.
VersionInfo
VS_VERSIONINFO resource structure representation.

Enums§

Data
Wrapper of the underlying data that may be represented as a binary buffer or a text string.
DataType
Data type flag indicating if data is encoded as a binary or a text string.
Error
Errors produced by this crate.
Id
Id enum that contains a windows resource id representation. Windows resource ids can be a pointer to a string or if the pointer value is below 0xffff the id represents an integer resource id. Id encapsulates this representation into a Rust enum and provides From and Into trait implementations to interop with the Windows API.
ResourceData
Placeholder for future data serialization (not implementated)
VersionInfoChild
Helper enum for serializing and deserializing StringFileInfo and VarFileInfo child structures.