lib.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //! Read-only analysis of PE32+ (x86-64) images and COFF import libraries.
  2. //!
  3. //! Xbox Series X|S titles are ordinary x86-64 PE32+ images (the console CPU
  4. //! is a Zen 2), so the same parser serves titles, console system DLLs and
  5. //! host binaries alike. This crate never modifies anything; patching lives in
  6. //! `victory-loader`, which uses the raw offsets exported from [`layout`].
  7. mod image;
  8. pub mod implib;
  9. pub mod layout;
  10. pub use image::{
  11. CodeViewInfo, ExportInfo, ImageInfo, ImportEntry, ImportModule, ImportSymbol, SectionInfo,
  12. TlsInfo,
  13. };
  14. /// Errors produced while parsing an image or import library.
  15. #[derive(Debug, thiserror::Error)]
  16. pub enum PeError {
  17. /// The file is a valid PE but not one we handle (e.g. 32-bit or ARM64).
  18. #[error("unsupported image: {0}")]
  19. Unsupported(String),
  20. /// The file is truncated or internally inconsistent.
  21. #[error("malformed image: {0}")]
  22. Malformed(String),
  23. }
  24. impl From<object::read::Error> for PeError {
  25. fn from(e: object::read::Error) -> Self {
  26. PeError::Malformed(e.to_string())
  27. }
  28. }
  29. /// `IMAGE_FILE_MACHINE_AMD64`.
  30. pub const MACHINE_AMD64: u16 = 0x8664;