Merge pull request #285 from Dufftwt/fix/name-title-dll-that-fails-to-prepare
Loader: a title DLL that fails to prepare is named in the error
This commit is contained in:
commit
a6aa850464
2 files changed
+18
-2
No files matched your search
@@ -152,8 +152,8 @@ fn map_dll(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let original = std::fs::read(&path).with_context(|| format!("reading {}", path.display()))?;
|
let original = std::fs::read(&path).with_context(|| format!("reading {}", path.display()))?;
|
||||||
let image = load(&prepare(&original)?, dirs.1)
|
let prepared = prepare(&original).with_context(|| format!("preparing {}", path.display()))?;
|
||||||
.with_context(|| format!("loading {}", path.display()))?;
|
let image = load(&prepared, dirs.1).with_context(|| format!("loading {}", path.display()))?;
|
||||||
map_imports(&image.info, dirs, wanted, seen, loaded)?;
|
map_imports(&image.info, dirs, wanted, seen, loaded)?;
|
||||||
loaded.push((name, image));
|
loaded.push((name, image));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
//! A title DLL that cannot be loaded is named in the error.
|
||||||
|
#![cfg(windows)]
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_title_dll_that_does_not_prepare_is_named() {
|
||||||
|
let title = tempfile::tempdir().unwrap();
|
||||||
|
let cache = tempfile::tempdir().unwrap();
|
||||||
|
std::fs::write(title.path().join("broken.dll"), b"MZ not a PE").unwrap();
|
||||||
|
let wanted = |_: &str| true;
|
||||||
|
let loaded = victory_loader::load_title_dll("broken.dll", title.path(), cache.path(), &wanted);
|
||||||
|
let Err(error) = loaded else {
|
||||||
|
panic!("a DLL that is not a PE loaded");
|
||||||
|
};
|
||||||
|
let text = format!("{error:#}");
|
||||||
|
assert!(text.contains("broken.dll"), "{text}");
|
||||||
|
}
|
||||||
Reference in new issue
Block a user