Diagnostics: VICTORY_POKE writes title bytes twice a second
A title that ends itself when its main loop has not ticked for a while runs on through slower frames. Co-Authored-By: Claude Fable 5.2 <[email protected]> (cherry picked from commit 532cb7cdfee02e6139a683f79ee4c9b4a92828a4)
This commit is contained in:
1 parent
f4d1863f25
commit
3f0055e213
2 files changed
+30
No files matched your search
@@ -305,6 +305,7 @@ The on/off switches below (`...=1`) are off when unset or set to `0`.
|
|||||||
| `VICTORY_LOG=<target>=debug,...` | debug and trace output |
|
| `VICTORY_LOG=<target>=debug,...` | debug and trace output |
|
||||||
| `VICTORY_STACKS=20,60` | every thread's stack at those seconds |
|
| `VICTORY_STACKS=20,60` | every thread's stack at those seconds |
|
||||||
| `VICTORY_WATCH=<rva>,...` | logs a title u32 when it changes |
|
| `VICTORY_WATCH=<rva>,...` | logs a title u32 when it changes |
|
||||||
|
| `VICTORY_POKE=<rva>:<byte>,...` | writes a title byte twice a second (a hang watchdog's tick, say) |
|
||||||
| `VICTORY_KEYS=30:Enter,35:X` | presses keys at those seconds, focus or not |
|
| `VICTORY_KEYS=30:Enter,35:X` | presses keys at those seconds, focus or not |
|
||||||
| `VICTORY_CRASH_SAVE=<rva>:<len>,...` | saves title memory to the cache folder on a crash |
|
| `VICTORY_CRASH_SAVE=<rva>:<len>,...` | saves title memory to the cache folder on a crash |
|
||||||
| `VICTORY_CAPTURE=<dir>` | saves presented frames (powers of two, or `VICTORY_CAPTURE_FRAMES=<list>`) |
|
| `VICTORY_CAPTURE=<dir>` | saves presented frames (powers of two, or `VICTORY_CAPTURE_FRAMES=<list>`) |
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ fn diagnostics(image: &victory_loader::LoadedImage, cfg: &victory_core::Config)
|
|||||||
victory_loader::dump_stacks_on_schedule();
|
victory_loader::dump_stacks_on_schedule();
|
||||||
victory_hle::modules::audio::capture::start();
|
victory_hle::modules::audio::capture::start();
|
||||||
watch(image.base(), image.info().size_of_image as usize);
|
watch(image.base(), image.info().size_of_image as usize);
|
||||||
|
poke(image.base(), image.info().size_of_image as usize);
|
||||||
// Debugging aid: `VICTORY_CRASH_SAVE=<rva>:<len>,...` (hex) writes those
|
// Debugging aid: `VICTORY_CRASH_SAVE=<rva>:<len>,...` (hex) writes those
|
||||||
// title ranges to `crash-<rva>.bin` in the cache dir on a crash.
|
// title ranges to `crash-<rva>.bin` in the cache dir on a crash.
|
||||||
let size = image.info().size_of_image as usize;
|
let size = image.info().size_of_image as usize;
|
||||||
@@ -245,6 +246,34 @@ fn watch(base: usize, size: usize) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Debugging aid: `VICTORY_POKE=<rva>:<byte>,...` (hex) writes the byte at
|
||||||
|
/// each title+rva twice a second. A title that ends itself when its main
|
||||||
|
/// loop has not ticked for a while (Grand Theft Auto VI: 30 s) runs on
|
||||||
|
/// through slower frames with its tick flag poked. The address must be
|
||||||
|
/// writable title data.
|
||||||
|
#[cfg(all(windows, feature = "diagnostics"))]
|
||||||
|
fn poke(base: usize, size: usize) {
|
||||||
|
let Ok(list) = std::env::var("VICTORY_POKE") else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let hex = |s: &str| usize::from_str_radix(s.trim().trim_start_matches("0x"), 16).ok();
|
||||||
|
let pokes: Vec<(usize, u8)> = list
|
||||||
|
.split(',')
|
||||||
|
.filter_map(|p| p.split_once(':'))
|
||||||
|
.filter_map(|(rva, byte)| Some((hex(rva)?, u8::try_from(hex(byte)?).ok()?)))
|
||||||
|
.filter(|&(rva, _)| rva < size)
|
||||||
|
.collect();
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
loop {
|
||||||
|
for &(rva, byte) in &pokes {
|
||||||
|
// SAFETY: a byte inside the mapped image, checked above.
|
||||||
|
unsafe { ((base + rva) as *mut u8).write_volatile(byte) };
|
||||||
|
}
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// DLLs the host or our runtime provide are never taken from the title.
|
/// DLLs the host or our runtime provide are never taken from the title.
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn title_dll(host: &victory_hle::HostPolicy, dll: &str) -> bool {
|
fn title_dll(host: &victory_hle::HostPolicy, dll: &str) -> bool {
|
||||||
|
|||||||
Reference in new issue
Block a user