pub struct ResourceDirectory { /* private fields */ }Expand description
Portable executable resource directory.
The resource directory contains the resource table and the resource data entries.
See Image::resource_directory for retrieving the resource directory from an image.
Implementations§
Source§impl ResourceDirectory
impl ResourceDirectory
Sourcepub fn parse(
image: &[u8],
base_address: u32,
virtual_address: u32,
) -> Result<Self, ImageReadError>
pub fn parse( image: &[u8], base_address: u32, virtual_address: u32, ) -> Result<Self, ImageReadError>
Parse the resource directory from the given image at the given base address. The virtual address is used to resolve the resource data offsets and has to correspond to the virtual address in the section table header of the source image.
§Returns
Returns an error if the resource directory at the given address is invalid.
Sourcepub fn get_main_icon(&self) -> Result<Option<&[u8]>, ResourceError>
pub fn get_main_icon(&self) -> Result<Option<&[u8]>, ResourceError>
Get the main icon of the executable.
The icon will be the first icon in the MAINICON group icon directory if it exists.
Otherwise, the first icon in the first group icon directory will be returned.
§Returns
Returns None if no icon exists.
Returns an error if the resource table structure is not well-formed.
Sourcepub fn set_main_icon<T: ToIcon>(&mut self, icon: T) -> Result<(), ResourceError>
pub fn set_main_icon<T: ToIcon>(&mut self, icon: T) -> Result<(), ResourceError>
Set the main icon of the executable.
The icon must be the byte slice of a valid icon, or a image::DynamicImage when the images feature is enabled.
When icon is a image::DynamicImage, the image is resized to the different icon resolutions.
This will overwrite the group icon directory with the MAINICON name if it exists and keep all other group icon directories intact.
This will not remove any existing icons.
To remove the existing main icon directory and the icons referenced by, call remove_main_icon before setting a new one.
§Returns
Returns an error if the new icon not a valid image or the resource table structure is not well-formed.
Sourcepub fn set_main_icon_file(&mut self, path: &str) -> Result<(), ResourceError>
Available on crate feature std only.
pub fn set_main_icon_file(&mut self, path: &str) -> Result<(), ResourceError>
std only.Set the main icon of the executable from a file.
The file must contain a valid image.
The image is resized to the different icon resolutions when the images feature is enabled.
See set_main_icon for more information.
§Returns
Returns an error if the file is not a valid image or the resource table structure is not well-formed.
Sourcepub fn set_main_icon_reader<R: Read>(
&mut self,
reader: &mut R,
) -> Result<(), ResourceError>
Available on crate feature std only.
pub fn set_main_icon_reader<R: Read>( &mut self, reader: &mut R, ) -> Result<(), ResourceError>
std only.Set the main icon of the executable from a reader.
The reader must contain a valid image.
The image is resized to the different icon resolutions when the images feature is enabled.
See set_main_icon for more information.
§Returns
Returns an error if the reader does not contain a valid image or the resource table structure is not well-formed.
Sourcepub fn remove_main_icon(&mut self) -> Result<(), ResourceError>
pub fn remove_main_icon(&mut self) -> Result<(), ResourceError>
Remove the main icon directory and all icons uniquely referenced by it.
§Returns
Returns an error if the icon resource directory is invalid.
Sourcepub fn get_version_info(&self) -> Result<Option<VersionInfo>, ResourceError>
pub fn get_version_info(&self) -> Result<Option<VersionInfo>, ResourceError>
Get the version information of the executable.
§Returns
Returns None if no version information exists.
Returns an error if the version resource directory is invalid.
Sourcepub fn set_version_info(
&mut self,
version_info: &VersionInfo,
) -> Result<(), ResourceError>
pub fn set_version_info( &mut self, version_info: &VersionInfo, ) -> Result<(), ResourceError>
Set the version information of the executable.
This will overwrite the existing version information.
§Returns
Returns an error if the resource table structure is not well-formed.
Sourcepub fn remove_version_info(&mut self) -> Result<(), ResourceError>
pub fn remove_version_info(&mut self) -> Result<(), ResourceError>
Remove the version information of the executable.
§Returns
Returns an error if the resource table structure is not well-formed.
Sourcepub fn get_manifest(&self) -> Result<Option<String>, ResourceError>
pub fn get_manifest(&self) -> Result<Option<String>, ResourceError>
Get the manifest of the executable.
§Returns
Returns None if no manifest exists.
Returns an error if the manifest resource directory is invalid.
Sourcepub fn set_manifest(&mut self, manifest: &str) -> Result<(), ResourceError>
pub fn set_manifest(&mut self, manifest: &str) -> Result<(), ResourceError>
Set the manifest of the executable.
This will overwrite the existing manifest.
§Returns
Returns an error if the resource table structure is not well-formed.
Sourcepub fn remove_manifest(&mut self) -> Result<(), ResourceError>
pub fn remove_manifest(&mut self) -> Result<(), ResourceError>
Remove the manifest of the executable.
§Returns
Returns an error if the resource table structure is not well-formed.
Sourcepub fn virtual_address(&self) -> u32
pub fn virtual_address(&self) -> u32
Returns the virtual address of the resource directory in the source image.
Sourcepub fn root(&self) -> &ResourceTable
pub fn root(&self) -> &ResourceTable
Returns the root resource table. The root resource table contains the top-level resource entries.
Sourcepub fn root_mut(&mut self) -> &mut ResourceTable
pub fn root_mut(&mut self) -> &mut ResourceTable
Returns the mutable root resource table. The root resource table contains the top-level resource entries.
Trait Implementations§
Source§impl Clone for ResourceDirectory
impl Clone for ResourceDirectory
Source§fn clone(&self) -> ResourceDirectory
fn clone(&self) -> ResourceDirectory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceDirectory
impl Debug for ResourceDirectory
Source§impl Default for ResourceDirectory
impl Default for ResourceDirectory
Source§fn default() -> ResourceDirectory
fn default() -> ResourceDirectory
Source§impl PartialEq for ResourceDirectory
impl PartialEq for ResourceDirectory
impl Eq for ResourceDirectory
impl StructuralPartialEq for ResourceDirectory
Auto Trait Implementations§
impl Freeze for ResourceDirectory
impl RefUnwindSafe for ResourceDirectory
impl Send for ResourceDirectory
impl Sync for ResourceDirectory
impl Unpin for ResourceDirectory
impl UnsafeUnpin for ResourceDirectory
impl UnwindSafe for ResourceDirectory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.