Run Minecraft: runtime HLE, D3D12.X device on the host GPU, shader IR
Loader: map title-shipped DLLs, patch static TLS loads to slot 0, crash reporter, title paths for GetModuleFileName*. HLE: task queue and async, XUser (one offline user), system ids, title id, features, invites, game events, persistent local storage, GameInput with no devices, xmem, console audio hardware queues, life cycle (close suspends, then terminates), and a file layer with virtual drives rewritten in path-taking imports. GPU: D3D12.X device, DXGI chain, heaps, resources, fences, queues and command lists translated onto a host D3D12 device; clears, barriers, copies, resolves and PresentX into the title's window. Shaders: SGD5 reader and `victory translate`; SSA IR with node splitting for irreducible flow; structurisation removing EXEC. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
12caefe804
commit
754619f30e
61 files changed
+12775
-88
No files matched your search
+57
-20
@@ -8,7 +8,7 @@ use crate::Unimplemented;
|
||||
pub fn run(exe: &Path, unimplemented: Unimplemented, strict: bool, execute: bool) -> Result<()> {
|
||||
use std::sync::Arc;
|
||||
use victory_hle::{HleResolver, HostPolicy};
|
||||
use victory_loader::UnimplementedPolicy;
|
||||
use victory_loader::{BindReport, UnimplementedPolicy, WithTitleDlls};
|
||||
|
||||
let cfg = victory_core::Config::load()?;
|
||||
let original = std::fs::read(exe).with_context(|| format!("reading {}", exe.display()))?;
|
||||
@@ -19,41 +19,78 @@ pub fn run(exe: &Path, unimplemented: Unimplemented, strict: bool, execute: bool
|
||||
None => println!("build unknown ({hash})"),
|
||||
}
|
||||
|
||||
let image = victory_loader::load(&prepared, &cfg.cache_subdir("images")?)?;
|
||||
let images = cfg.cache_subdir("images")?;
|
||||
let image = victory_loader::load(&prepared, &images)?;
|
||||
victory_hle::runtime::set_main_image(image.base());
|
||||
let resolver = HleResolver::new(if strict {
|
||||
HostPolicy::none()
|
||||
} else {
|
||||
HostPolicy::default()
|
||||
});
|
||||
let policy = match unimplemented {
|
||||
Unimplemented::Trap => UnimplementedPolicy::Trap,
|
||||
Unimplemented::Zero => UnimplementedPolicy::ReturnZero,
|
||||
};
|
||||
let report = image.bind_imports(&resolver, policy)?;
|
||||
victory_hle::runtime::set_image_path(image.base(), exe);
|
||||
println!(
|
||||
"mapped at {:#x} (preferred {:#x})",
|
||||
image.base(),
|
||||
image.info().image_base
|
||||
);
|
||||
let resolver = HleResolver::new(if strict {
|
||||
HostPolicy::none()
|
||||
} else {
|
||||
HostPolicy::default()
|
||||
});
|
||||
// DLLs the host or our runtime provide are never taken from the title.
|
||||
let wanted = |dll: &str| {
|
||||
!resolver.host.allows(dll) && !victory_hle::registry().iter().any(|m| m.serves(dll))
|
||||
};
|
||||
let title_dir = exe.parent().unwrap_or(Path::new("."));
|
||||
// A missing manifest leaves id 0 and no storage quota.
|
||||
let manifest =
|
||||
std::fs::read_to_string(title_dir.join("MicrosoftGame.config")).unwrap_or_default();
|
||||
let title = victory_hle::runtime::Title::from_manifest(&manifest);
|
||||
let storage = cfg.data_subdir(&format!("{:08X}/storage", title.id))?;
|
||||
println!(
|
||||
"bound {} hle, {} host, {} missing",
|
||||
report.hle,
|
||||
report.host,
|
||||
report.missing.len()
|
||||
"title {:08X}, storage {} ({} MB)",
|
||||
title.id,
|
||||
storage.display(),
|
||||
title.storage_bytes >> 20
|
||||
);
|
||||
for m in &report.missing {
|
||||
println!(" missing {}!{}", m.dll, m.symbol);
|
||||
victory_hle::runtime::set_title(victory_hle::runtime::Title { storage, ..title });
|
||||
let dlls = victory_loader::load_title_dlls(image.info(), title_dir, &images, &wanted)?;
|
||||
for (name, dll) in &dlls {
|
||||
println!("title dll {name} at {:#x}", dll.base());
|
||||
victory_hle::runtime::set_image_path(dll.base(), &title_dir.join(name));
|
||||
}
|
||||
|
||||
let policy = match unimplemented {
|
||||
Unimplemented::Trap => UnimplementedPolicy::Trap,
|
||||
Unimplemented::Zero => UnimplementedPolicy::ReturnZero,
|
||||
};
|
||||
let with_dlls = WithTitleDlls {
|
||||
inner: &resolver,
|
||||
dlls: &dlls,
|
||||
};
|
||||
let show = |name: &str, report: BindReport| {
|
||||
println!(
|
||||
"bound {name}: {} hle, {} host, {} title, {} missing",
|
||||
report.hle,
|
||||
report.host,
|
||||
report.title,
|
||||
report.missing.len()
|
||||
);
|
||||
for m in &report.missing {
|
||||
println!(" missing {}!{}", m.dll, m.symbol);
|
||||
}
|
||||
};
|
||||
for (name, dll) in &dlls {
|
||||
show(name, dll.bind_imports(&with_dlls, policy)?);
|
||||
}
|
||||
let exe_name = exe.file_name().unwrap_or_default().to_string_lossy();
|
||||
show(&exe_name, image.bind_imports(&with_dlls, policy)?);
|
||||
if !execute {
|
||||
println!("not executing (pass --execute to start the title)");
|
||||
return Ok(());
|
||||
}
|
||||
victory_loader::report_crashes();
|
||||
// SAFETY: imports are bound; from here on we run title code.
|
||||
let main = unsafe { Arc::new(image).spawn_main()? };
|
||||
let main = unsafe { Arc::new(image).spawn_main(dlls)? };
|
||||
let code = main
|
||||
.join()
|
||||
.map_err(|_| anyhow::anyhow!("title main thread panicked"))?;
|
||||
.map_err(|_| anyhow::anyhow!("title main thread panicked"))??;
|
||||
println!("title exited with {code}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user