Writes of the title's that change nothing are not made: faulting stores and copies beside the guards, and flags it sets that are set (VICTORY_WRITE_SITES=<file>: places changed at load to look first; off without it)

A store that faults, or a part of a copy into a guarded block, whose bytes
are there already is left out (with VICTORY_STORE_BESIDE, VICTORY_COPY_BESIDE).
The places in the title's code where that is the rule and the instruction is
an `or` of a byte with a constant are written into the file, and made to look
before they write at the next start. The file holds offsets, no code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 13:10:05 -06:00
1 parent 44c69a8fee
commit 2ad419b24d
8 files changed
+437 -18

No files matched your search

+3 -3
View File
@@ -77,7 +77,7 @@ fn patches_clzero() -> bool {
}
/// `jmp rel32` at `at` to `to`, if it reaches.
fn jump(at: usize, to: usize) -> Option<[u8; 5]> {
pub(crate) fn jump(at: usize, to: usize) -> Option<[u8; 5]> {
let rel = i32::try_from(to as i64 - (at as i64 + 5)).ok()?;
let [a, b, c, d] = rel.to_le_bytes();
Some([0xe9, a, b, c, d])
@@ -111,10 +111,10 @@ fn clzero_stub(at: usize, stub: usize, cmp: [u8; 3]) -> Option<Vec<u8>> {
/// Room for [`clzero_stub`]s near the title's code: where it is and the bytes used.
static STUBS: std::sync::Mutex<Option<(usize, usize)>> = std::sync::Mutex::new(None);
const STUBS_LEN: usize = 64 << 10;
pub(crate) const STUBS_LEN: usize = 64 << 10;
/// Memory for code within reach of a `jmp rel32` at `at`.
fn near(at: usize) -> Option<usize> {
pub(crate) fn near(at: usize) -> Option<usize> {
use windows_sys::Win32::System::Memory::{MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE_READWRITE, VirtualAlloc};
let at = at & !0xffff;
(0x10_0000..0x7000_0000).step_by(0x10_0000).flat_map(|d| [at.checked_sub(d), at.checked_add(d)]).flatten().find_map(|place| {