/// The common parts of `PeFile` and `CoffFile`. #[derive(Debug)] pub(crate) struct CoffCommon<'data, R: ReadRef<'data>, Coff: CoffHeader = pe::ImageFileHeader> { pub(crate) sections: SectionTable<'data>, pub(crate) symbols: SymbolTable<'data, R, Coff>, pub(crate) image_base: u64,
}
/// A COFF bigobj object file with 32-bit section numbers. /// /// This is a file that starts with [`pe::AnonObjectHeaderBigobj`], and corresponds /// to [`crate::FileKind::CoffBig`]. /// /// Most functionality is provided by the [`Object`] trait implementation. pubtype CoffBigFile<'data, R = &'data [u8]> = CoffFile<'data, R, pe::AnonObjectHeaderBigobj>;
/// A COFF object file. /// /// This is a file that starts with [`pe::ImageFileHeader`], and corresponds /// to [`crate::FileKind::Coff`]. /// /// Most functionality is provided by the [`Object`] trait implementation. #[derive(Debug)] pubstruct CoffFile<'data, R: ReadRef<'data> = &'data [u8], Coff: CoffHeader = pe::ImageFileHeader>
{ pub(super) header: &'data Coff, pub(super) common: CoffCommon<'data, R, Coff>, pub(super) data: R,
}
impl<'data, R: ReadRef<'data>, Coff: CoffHeader> CoffFile<'data, R, Coff> { /// Parse the raw COFF file data. pubfn parse(data: R) -> Result<Self> { letmut offset = 0; let header = Coff::parse(data, &mut offset)?; let sections = header.sections(data, offset)?; let symbols = header.symbols(data)?;
/// Read the `class_id` field from a [`pe::AnonObjectHeader`]. /// /// This can be used to determine the format of the header. pubfn anon_object_class_id<'data, R: ReadRef<'data>>(data: R) -> Result<pe::ClsId> { let header = data
.read_at::<pe::AnonObjectHeader>(0)
.read_error("Invalid anon object header size or alignment")?;
Ok(header.class_id)
}
/// A trait for generic access to [`pe::ImageFileHeader`] and [`pe::AnonObjectHeaderBigobj`]. #[allow(missing_docs)] pubtrait CoffHeader: Debug + Pod { type ImageSymbol: ImageSymbol; type ImageSymbolBytes: Debug + Pod;
/// Return true if this type is [`pe::AnonObjectHeaderBigobj`]. /// /// This is a property of the type, not a value in the header data. fn is_type_bigobj() -> bool;
/// Read the file header. /// /// `data` must be the entire file data. /// `offset` must be the file header offset. It is updated to point after the optional header, /// which is where the section headers are located. fn parse<'data, R: ReadRef<'data>>(data: R, offset: &mut u64) -> read::Result<&'data Self>;
/// Read the section table. /// /// `data` must be the entire file data. /// `offset` must be after the optional file header. #[inline] fn sections<'data, R: ReadRef<'data>>(
&self,
data: R,
offset: u64,
) -> read::Result<SectionTable<'data>> {
SectionTable::parse(self, data, offset)
}
/// Read the symbol table and string table. /// /// `data` must be the entire file data. #[inline] fn symbols<'data, R: ReadRef<'data>>(
&self,
data: R,
) -> read::Result<SymbolTable<'data, R, Self>> {
SymbolTable::parse(self, data)
}
}
impl CoffHeader for pe::ImageFileHeader { type ImageSymbol = pe::ImageSymbol; type ImageSymbolBytes = pe::ImageSymbolBytes;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.