Struct editpe::ResourceDirectory
source · pub struct ResourceDirectory { /* private fields */ }
Expand description
Portable executable resource directory.
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_icon(&self) -> Result<Option<&[u8]>, ResourceError>
pub fn get_icon(&self) -> Result<Option<&[u8]>, ResourceError>
Get the 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_icon<T: AsRef<[u8]>>(&mut self, icon: T) -> Result<(), ResourceError>
Available on crate feature image
only.
pub fn set_icon<T: AsRef<[u8]>>(&mut self, icon: T) -> Result<(), ResourceError>
image
only.Set the icon of the executable. The icon must be the byte slice of a valid image file.
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_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 remove_icon(&mut self) -> Result<(), ResourceError>
pub fn remove_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
source§fn eq(&self, other: &ResourceDirectory) -> bool
fn eq(&self, other: &ResourceDirectory) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for ResourceDirectory
impl StructuralEq for ResourceDirectory
impl StructuralPartialEq for ResourceDirectory
Auto Trait Implementations§
impl RefUnwindSafe for ResourceDirectory
impl Send for ResourceDirectory
impl Sync for ResourceDirectory
impl Unpin 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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.