Expand description
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::PCSTRstring.
Structs§
- Date
- Date helper used for serializing and deserializing 2 LE-encoded u32
values into a single
u64value. - File
Info - Rust representation of
VS_FIXEDFILEINFOstructure. - Header
- Helper representing structure data header used in
VS_VERSIONINFOand all related data structures. - Resource
- Structure representing a single resource
- Resource
Data Inner - Placeholder for future data serialization (not implementated)
- Resources
- Data structure representing a resource file. This data structure
points to a
.resor.exefile 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 au64value represented as 2 LE-encodedu32(DWORD) values. - Version
Info VS_VERSIONINFOresource structure representation.
Enums§
- Data
- Wrapper of the underlying data that may be represented as a binary buffer or a text string.
- Data
Type - 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.
Idencapsulates this representation into a Rust enum and providesFromandIntotrait implementations to interop with the Windows API. - Resource
Data - Placeholder for future data serialization (not implementated)
- Version
Info Child - Helper enum for serializing and deserializing StringFileInfo and VarFileInfo child structures.