no_dll_planting.rs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. //! Host pass-through must only load DLLs from System32, never from the
  2. //! current folder (e.g. a title's folder shipping its own `msvcp140_*.dll`).
  3. #![cfg(windows)]
  4. use victory_hle::{HleResolver, HostPolicy};
  5. use victory_pe::ImportSymbol;
  6. #[test]
  7. fn ignores_dlls_in_current_folder() {
  8. let name = "msvcp140_victorytest.dll";
  9. assert!(
  10. HostPolicy::default().allows(name),
  11. "test needs an allow-listed name"
  12. );
  13. assert!(HostPolicy::default().allows("vcruntime140_1.dll"));
  14. let dir = tempfile::tempdir().unwrap();
  15. // Any loadable DLL will do.
  16. std::fs::copy(r"C:\Windows\System32\version.dll", dir.path().join(name)).unwrap();
  17. std::env::set_current_dir(dir.path()).unwrap();
  18. let symbol = ImportSymbol::Name {
  19. hint: 0,
  20. name: "GetFileVersionInfoSizeW".into(),
  21. };
  22. let found = HleResolver::default().classify(name, &symbol);
  23. std::env::set_current_dir(env!("CARGO_MANIFEST_DIR")).unwrap();
  24. assert_eq!(found, None, "DLL was loaded from the current folder");
  25. }