pub struct PeFile<'a> { /* private fields */ }Expand description
View into an unmapped PE file.
Implementations§
Source§impl<'a> PeFile<'a>
impl<'a> PeFile<'a>
Sourcepub fn from_bytes<T: AsRef<[u8]> + ?Sized>(image: &'a T) -> Result<PeFile<'a>>
pub fn from_bytes<T: AsRef<[u8]> + ?Sized>(image: &'a T) -> Result<PeFile<'a>>
Constructs a file view from a byte slice.
§Errors
-
Bounds: The byte slice is too small to fit the PE headers. -
Misaligned: The minimum alignment of 4 is not satisfied. -
BadMagic: This is not a PE file. -
PeMagic: Trying to parse a PE32 file with the PE32+ parser and vice versa. -
Insanity: Reasonable limits one_lfanew,SizeOfHeadersorNumberOfSectionsare exceeded.
Trait Implementations§
Source§impl<'a> Pe<'a> for PeFile<'a>
impl<'a> Pe<'a> for PeFile<'a>
Source§fn dos_header(self) -> &'a IMAGE_DOS_HEADER
fn dos_header(self) -> &'a IMAGE_DOS_HEADER
Returns the DOS header.
Source§fn nt_headers(self) -> &'a IMAGE_NT_HEADERS
fn nt_headers(self) -> &'a IMAGE_NT_HEADERS
Returns the NT headers.
Source§fn file_header(self) -> &'a IMAGE_FILE_HEADER
fn file_header(self) -> &'a IMAGE_FILE_HEADER
Returns the file header.
Source§fn optional_header(self) -> &'a IMAGE_OPTIONAL_HEADER
fn optional_header(self) -> &'a IMAGE_OPTIONAL_HEADER
Returns the optional header.
Source§fn data_directory(self) -> &'a [IMAGE_DATA_DIRECTORY]
fn data_directory(self) -> &'a [IMAGE_DATA_DIRECTORY]
Returns the data directory.
Source§fn section_headers(self) -> &'a SectionHeaders
fn section_headers(self) -> &'a SectionHeaders
Returns the section headers.
Source§fn rva_to_file_offset(self, rva: Rva) -> Result<usize>
fn rva_to_file_offset(self, rva: Rva) -> Result<usize>
Converts a relative virtual address to file offset. Read more
Source§fn file_offset_to_rva(self, file_offset: usize) -> Result<Rva>
fn file_offset_to_rva(self, file_offset: usize) -> Result<Rva>
Converts a file offset to relative virtual address. Read more
Source§fn rva_to_va(self, rva: Rva) -> Result<Va>
fn rva_to_va(self, rva: Rva) -> Result<Va>
Converts from relative virtual address to virtual address. Read more
Source§fn va_to_rva(self, va: Va) -> Result<Rva>
fn va_to_rva(self, va: Va) -> Result<Rva>
Converts from virtual address to relative virtual address. Read more
Source§fn slice(&self, rva: Rva, min_size_of: usize, align: usize) -> Result<&'a [u8]>
fn slice(&self, rva: Rva, min_size_of: usize, align: usize) -> Result<&'a [u8]>
Slices the image at the specified rva. Read more
Source§fn slice_bytes(self, rva: Rva) -> Result<&'a [u8]>where
Self: Sized,
fn slice_bytes(self, rva: Rva) -> Result<&'a [u8]>where
Self: Sized,
Slices the image at the specified rva returning a byte slice with no alignment or minimum size. Read more
Source§fn get_section_bytes(
self,
section_header: &IMAGE_SECTION_HEADER,
) -> Result<&'a [u8]>
fn get_section_bytes( self, section_header: &IMAGE_SECTION_HEADER, ) -> Result<&'a [u8]>
Gets the bytes defined by a section header in this image. Read more
Source§fn read(&self, va: Va, min_size_of: usize, align: usize) -> Result<&'a [u8]>
fn read(&self, va: Va, min_size_of: usize, align: usize) -> Result<&'a [u8]>
Reads the image at the specified va. Read more
Source§fn read_bytes(self, va: Va) -> Result<&'a [u8]>where
Self: Sized,
fn read_bytes(self, va: Va) -> Result<&'a [u8]>where
Self: Sized,
Reads the image at the specified va returning a byte slice with no alignment or minimum size. Read more
Source§fn derva_into<T>(self, rva: Rva, dest: &mut T) -> Result<()>
fn derva_into<T>(self, rva: Rva, dest: &mut T) -> Result<()>
Reads and byte-wise copies the content to the given destination. Read more
Source§fn derva_slice<T>(self, rva: Rva, len: usize) -> Result<&'a [T]>where
T: Pod,
fn derva_slice<T>(self, rva: Rva, len: usize) -> Result<&'a [T]>where
T: Pod,
Reads an array of pod
T with given length.Source§fn derva_slice_f<T, F>(self, rva: Rva, f: F) -> Result<&'a [T]>
fn derva_slice_f<T, F>(self, rva: Rva, f: F) -> Result<&'a [T]>
Reads an array of pod
T. Read moreSource§fn derva_slice_s<T>(self, rva: Rva, sentinel: T) -> Result<&'a [T]>
fn derva_slice_s<T>(self, rva: Rva, sentinel: T) -> Result<&'a [T]>
Reads an array of pod
T. Read moreSource§fn deref<T>(self, ptr: Ptr<T>) -> Result<&'a T>where
T: Pod,
fn deref<T>(self, ptr: Ptr<T>) -> Result<&'a T>where
T: Pod,
Dereferences the pointer to a pod
T.Source§fn deref_copy<T>(self, ptr: Ptr<T>) -> Result<T>
fn deref_copy<T>(self, ptr: Ptr<T>) -> Result<T>
Dereferences the pointer to an unaligned pod
T.Source§fn deref_into<T>(self, ptr: Ptr<T>, dest: &mut T) -> Result<()>
fn deref_into<T>(self, ptr: Ptr<T>, dest: &mut T) -> Result<()>
Reads and byte-wise copies the content to the given destination. Read more
Source§fn deref_slice<T>(self, ptr: Ptr<[T]>, len: usize) -> Result<&'a [T]>where
T: Pod,
fn deref_slice<T>(self, ptr: Ptr<[T]>, len: usize) -> Result<&'a [T]>where
T: Pod,
Reads an array of pod
T with given length.Source§fn deref_slice_f<T, F>(self, ptr: Ptr<[T]>, f: F) -> Result<&'a [T]>
fn deref_slice_f<T, F>(self, ptr: Ptr<[T]>, f: F) -> Result<&'a [T]>
Reads an array of pod
T. Read moreSource§fn deref_slice_s<T>(self, ptr: Ptr<[T]>, sentinel: T) -> Result<&'a [T]>
fn deref_slice_s<T>(self, ptr: Ptr<[T]>, sentinel: T) -> Result<&'a [T]>
Reads an array of pod
T. Read moreSource§fn deref_c_str(self, ptr: Ptr<CStr>) -> Result<&'a CStr>
fn deref_c_str(self, ptr: Ptr<CStr>) -> Result<&'a CStr>
Dereferences the pointer to a nul-terminated C string.
Source§fn rich_structure(self) -> Result<RichStructure<'a>>
fn rich_structure(self) -> Result<RichStructure<'a>>
Returns the Rich structure.
Source§fn base_relocs(self) -> Result<BaseRelocs<'a>>
fn base_relocs(self) -> Result<BaseRelocs<'a>>
Gets the Base Relocations Directory. Read more
Source§fn load_config(self) -> Result<LoadConfig<'a, Self>>
fn load_config(self) -> Result<LoadConfig<'a, Self>>
Gets the Load Config Directory. Read more
impl<'a> Copy for PeFile<'a>
Auto Trait Implementations§
impl<'a> Freeze for PeFile<'a>
impl<'a> RefUnwindSafe for PeFile<'a>
impl<'a> Send for PeFile<'a>
impl<'a> Sync for PeFile<'a>
impl<'a> Unpin for PeFile<'a>
impl<'a> UnwindSafe for PeFile<'a>
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
Mutably borrows from an owned value. Read more