pub struct PeFile<'a> { /* private fields */ }Expand description
A parsed Portable Executable file borrowing its data.
The DOS and NT headers are parsed by PeFile::parse, everything else on access. Accessors
of optional structures return Ok(None) if the structure is absent and an error if it is
malformed.
Implementations§
Source§impl<'a> PeFile<'a>
impl<'a> PeFile<'a>
Sourcepub fn authenticode_info(&self) -> Result<Option<&AuthenticodeInfo<'a>>>
Available on crate feature authenticode only.
pub fn authenticode_info(&self) -> Result<Option<&AuthenticodeInfo<'a>>>
authenticode only.The Authenticode signature, Ok(None) for unsigned files and an error if the certificate
data cannot be decoded.
Sourcepub fn signing_certificate(&self) -> Result<Option<&Certificate>>
Available on crate feature authenticode only.
pub fn signing_certificate(&self) -> Result<Option<&Certificate>>
authenticode only.The certificate the file was signed with.
Sourcepub fn is_signed(&self) -> bool
Available on crate feature authenticode only.
pub fn is_signed(&self) -> bool
authenticode only.True if the file is signed. The signature is not validated.
Sourcepub fn has_valid_signature(&self) -> bool
Available on crate feature authenticode only.
pub fn has_valid_signature(&self) -> bool
authenticode only.True if the signature is valid. The trust of the certificate chain is not checked.
Sourcepub fn crl_url_list(&self) -> Result<Option<CrlUrlList>>
Available on crate feature authenticode only.
pub fn crl_url_list(&self) -> Result<Option<CrlUrlList>>
authenticode only.The CRL URLs of the signing certificate, Ok(None) if the file is not signed.
Sourcepub fn authenticode_hash(&self, algorithm: HashAlgorithm) -> Result<Vec<u8>>
Available on crate feature authenticode only.
pub fn authenticode_hash(&self, algorithm: HashAlgorithm) -> Result<Vec<u8>>
authenticode only.The Authenticode hash: the hash of the file without the checksum, the certificate table entry and the certificate data.
Source§impl<'a> PeFile<'a>
impl<'a> PeFile<'a>
pub fn data_directory(&self, t: DataDirectoryType) -> &'a ImageDataDirectory
pub fn export_directory(&self) -> Result<Option<&'a ImageExportDirectory>>
pub fn exported_functions(&self) -> Result<Option<Vec<ExportFunction<'a>>>>
pub fn import_descriptors( &self, ) -> Result<Option<Vec<&'a ImageImportDescriptor>>>
pub fn imported_functions(&self) -> Result<Option<Vec<ImportFunction<'a>>>>
pub fn delay_import_descriptors( &self, ) -> Result<Option<Vec<&'a ImageDelayImportDescriptor>>>
pub fn delay_imported_functions( &self, ) -> Result<Option<Vec<ImportFunction<'a>>>>
pub fn bound_import_descriptor( &self, ) -> Result<Option<&'a ImageBoundImportDescriptor>>
Sourcepub fn base_relocations(&self) -> Result<Option<BaseRelocations<'a>>>
pub fn base_relocations(&self) -> Result<Option<BaseRelocations<'a>>>
The blocks of the relocation directory.
Sourcepub fn exception_directory(&self) -> Result<Option<&'a [RuntimeFunction]>>
pub fn exception_directory(&self) -> Result<Option<&'a [RuntimeFunction]>>
The runtime functions of the exception directory, Ok(None) for 32 bit files.
pub fn debug_directory(&self) -> Result<Option<&'a [ImageDebugDirectory]>>
pub fn tls_directory(&self) -> Result<Option<TlsDirectory<'a>>>
Sourcepub fn tls_callbacks(&self) -> Result<Option<Vec<Va>>>
pub fn tls_callbacks(&self) -> Result<Option<Vec<Va>>>
The virtual addresses of the TLS callbacks.
pub fn load_config_directory(&self) -> Result<Option<LoadConfigDirectory>>
Sourcepub fn com_descriptor(&self) -> Result<Option<&'a ImageCor20Header>>
pub fn com_descriptor(&self) -> Result<Option<&'a ImageCor20Header>>
The COM descriptor (CLI header) of .NET assemblies.
Sourcepub fn win_certificate(&self) -> Result<Option<WinCertificate<'a>>>
pub fn win_certificate(&self) -> Result<Option<WinCertificate<'a>>>
The WIN_CERTIFICATE of the security directory, whose address is a file offset.
Sourcepub fn resource_directory(&self) -> Result<Option<ResourceDirectory<'a>>>
pub fn resource_directory(&self) -> Result<Option<ResourceDirectory<'a>>>
The root of the resource tree.
Source§impl<'a> PeFile<'a>
impl<'a> PeFile<'a>
Sourcepub fn is_dot_net(&self) -> bool
Available on crate feature dotnet only.
pub fn is_dot_net(&self) -> bool
dotnet only.True if the file has a CLI (COM descriptor) header.
Sourcepub fn metadata_header(&self) -> Result<Option<&MetadataHeader<'a>>>
Available on crate feature dotnet only.
pub fn metadata_header(&self) -> Result<Option<&MetadataHeader<'a>>>
dotnet only.The metadata root referenced by the CLI header.
Sourcepub fn metadata_strings(&self) -> Result<Option<StringsHeap<'a>>>
Available on crate feature dotnet only.
pub fn metadata_strings(&self) -> Result<Option<StringsHeap<'a>>>
dotnet only.The #Strings heap.
Sourcepub fn metadata_user_strings(&self) -> Result<Option<UserStringsHeap<'a>>>
Available on crate feature dotnet only.
pub fn metadata_user_strings(&self) -> Result<Option<UserStringsHeap<'a>>>
dotnet only.The #US (user strings) heap.
Sourcepub fn metadata_guids(&self) -> Result<Option<GuidHeap<'a>>>
Available on crate feature dotnet only.
pub fn metadata_guids(&self) -> Result<Option<GuidHeap<'a>>>
dotnet only.The #GUID heap.
Sourcepub fn metadata_blob(&self) -> Result<Option<BlobHeap<'a>>>
Available on crate feature dotnet only.
pub fn metadata_blob(&self) -> Result<Option<BlobHeap<'a>>>
dotnet only.The #Blob heap.
Sourcepub fn metadata_tables_header(
&self,
) -> Result<Option<&MetadataTablesHeader<'a>>>
Available on crate feature dotnet only.
pub fn metadata_tables_header( &self, ) -> Result<Option<&MetadataTablesHeader<'a>>>
dotnet only.The header of the #~ stream with all metadata tables.
Sourcepub fn type_ref_hash(&self) -> Result<Option<[u8; 32]>>
Available on crate feature dotnet only.
pub fn type_ref_hash(&self) -> Result<Option<[u8; 32]>>
dotnet only.The TypeRefHash, Ok(None) for files without metadata tables or #Strings heap.
Sourcepub fn clr_module_version_ids(&self) -> Result<Option<&[Uuid]>>
Available on crate feature dotnet only.
pub fn clr_module_version_ids(&self) -> Result<Option<&[Uuid]>>
dotnet only.The module version ID of each module, Ok(None) for files without metadata tables.
Sourcepub fn clr_com_type_lib_id(&self) -> Result<Option<Uuid>>
Available on crate feature dotnet only.
pub fn clr_com_type_lib_id(&self) -> Result<Option<Uuid>>
dotnet only.The COM TypeLib ID of the assembly, Ok(None) if it is not specified.
Source§impl<'a> PeFile<'a>
impl<'a> PeFile<'a>
Sourcepub fn resources(&self) -> Result<Option<Resources<'a>>>
Available on crate feature resources only.
pub fn resources(&self) -> Result<Option<Resources<'a>>>
resources only.The version information and icons, Ok(None) if the file has none of them.
Source§impl<'a> PeFile<'a>
impl<'a> PeFile<'a>
Sourcepub fn parse(data: &'a [u8]) -> Result<Self>
pub fn parse(data: &'a [u8]) -> Result<Self>
Parse a PE file. Fails with Error::NotAPeFile if the NT signature is not PE\0\0.
Sourcepub fn is_pe(data: &[u8]) -> bool
pub fn is_pe(data: &[u8]) -> bool
True if the data starts with the MZ magic. The rest of the data is not checked.
Sourcepub fn is_pe_reader(reader: &mut impl Read) -> Result<bool>
Available on crate feature std only.
pub fn is_pe_reader(reader: &mut impl Read) -> Result<bool>
std only.True if the reader starts with the MZ magic. The rest of the data is not checked.
pub fn dos_header(&self) -> &'a ImageDosHeader
pub fn nt_headers(&self) -> &NtHeaders<'a>
Sourcepub fn section_headers(&self) -> Result<&SectionTable<'a>>
pub fn section_headers(&self) -> Result<&SectionTable<'a>>
The section headers sorted by virtual address.