pub struct ResourceDirectory { /* private fields */ }
Expand description

Portable executable resource directory.

Implementations§

source§

impl ResourceDirectory

source

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.

source

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.

source

pub fn set_icon<T: AsRef<[u8]>>(&mut self, icon: T) -> Result<(), ResourceError>

Available on crate feature 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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn virtual_address(&self) -> u32

Returns the virtual address of the resource directory in the source image.

source

pub fn root(&self) -> &ResourceTable

Returns the root resource table. The root resource table contains the top-level resource entries.

source

pub fn root_mut(&mut self) -> &mut ResourceTable

Returns the mutable root resource table. The root resource table contains the top-level resource entries.

source

pub fn size(&self) -> u32

Returns the size of the resulting resource directory in bytes.

source

pub fn build(&self, virtual_address: u32) -> Vec<u8>

Build the resource directory into raw bytes to be included in an image. The virtual address is used to compute the resource data offsets and has to correspond to the virtual address in the section table header of the target image.

Trait Implementations§

source§

impl Clone for ResourceDirectory

source§

fn clone(&self) -> ResourceDirectory

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ResourceDirectory

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ResourceDirectory

source§

fn default() -> ResourceDirectory

Returns the “default value” for a type. Read more
source§

impl PartialEq for ResourceDirectory

source§

fn eq(&self, other: &ResourceDirectory) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ResourceDirectory

source§

impl StructuralEq for ResourceDirectory

source§

impl StructuralPartialEq for ResourceDirectory

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.