resolve.rs 927 B

123456789101112131415161718192021222324252627282930313233
  1. //! How imports get their addresses.
  2. use victory_pe::ImportSymbol;
  3. /// Who provides a bound import.
  4. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
  5. pub enum Provenance {
  6. /// Our implementation of the console API.
  7. Hle,
  8. /// The host's own implementation (e.g. Windows API sets that behave the
  9. /// same on console and PC).
  10. Host,
  11. /// A DLL the title ships, mapped like the executable.
  12. Title,
  13. }
  14. #[derive(Debug, Clone, Copy, PartialEq, Eq)]
  15. pub enum Resolution {
  16. Found {
  17. address: usize,
  18. provenance: Provenance,
  19. },
  20. /// Nobody implements it; the loader installs a reporting stub.
  21. Missing,
  22. }
  23. /// Supplies an address for each `dll!symbol` the title imports.
  24. ///
  25. /// `dll` is passed exactly as written in the image; implementations should
  26. /// compare case-insensitively.
  27. pub trait ImportResolver {
  28. fn resolve(&self, dll: &str, symbol: &ImportSymbol) -> Resolution;
  29. }