[BUNDLE] Loader, PE reader and config: 20 PRs, #188 #213 #214 #219 #221 #311 #324 #363 #406 #454 #529 #560 #708 #937 #941 #963 #1111 #1159 #1304 #1306 #1456

Closed
github-bot wants to merge 51 commits from gh-pr/1456/head into gh-pr/1456/base
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 18:08 UTC · original
MamaLeVrai:bundle/loader-pe-core → main · +2731 −292 · 16 files · 51 commits · closed without merging

One PR in place of 20. Twenty PRs on the loader, the PE reader and the config: TLS scan speed, relocation and section bounds, import binding, unwind and crash reports, thread shutdown, CPU instruction emulation (CLZERO, RDPRU, CLWB), the watchdog opt-out, and the policy and data-directory checks. Every head is merged unchanged onto main (ffe310e), and the result is built and tested together.

For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a [BUNDLE] PR. The re-verification commands are below, so one run covers all of it.

What is inside

PR Author Head Title
#188 TG0000 2a6e6a4bc Loader: find TLS-array load candidates sixteen offsets at a time (8-9x faster scan)
#213 Dufftwt 7f00a62a4 Crash reports: name the host's CPU and Windows build
#214 Makto94 514927d Loader: clzero loops in one exception; rdpru (#34 rebased, with a fix)
#219 DiegoFR20 e57e76a7b fix(pe): validate section raw data bounds
#221 AndyLatimer acdcc4168 Loader: suspend a thread before reading its TEB; skip bad dump times
#311 CesarLopesO 1251a24b7 test(pe): cover header layout offsets
#324 pedrofort c37793a fix(pe): detect incomplete TLS callback arrays
#363 enzoduarte1 fd44561ea Config: ignore an empty VICTORY_CONFIG
#406 ? b33c704e3
#454 ruvenesh 85c04d129 Loader: opt-in VICTORY_NO_WATCHDOG hook for the title's watchdog (build 1.0.2.1)
#529 pushkarreddyy 609c74fbd PE: preallocate symbol_key in CodeViewInfo
#560 Quat3rnion 1aac20aa8 Loader: stage prepared images in per-writer files
#708 Loggerten a9698e748 fix(config): keep the data directory out of the cache root
#937 nino-exe 52f0a099e policy: resolve a .. in the not-yet-existing part of a path
#941 BastienRodz 60d2cf9cb Loader: a clwb in the last bytes of a page is emulated instead of faulting
#963 enzoduarte1 adeb9ff49 PE: read long-format import descriptors
#1111 divyeshganta 5f8800dd9 fix(loader): preserve protection regions when binding unaligned imports
#1159 geiyiliyabumo 121412bec loader(crash): verify unwind against known caller frames when RtlCaptureStackBackTrace returns empty
#1304 geiyiliyabumo 98716d1a5 Loader: fix thread shutdown targeting, registry lifetime, and CRT detach ordering
#1306 geiyiliyabumo 29d78bae7 Loader: fix thunk block overflow, capacity enforcement, flush errors, and leaks

Changes made while bundling

No merge conflicts. One change of mine, in its own commit: the long-format import descriptor code that #963 adds nests if size == 0 inside an if let, which clippy::collapsible_if rejects under -D warnings (#963's own CI run fails on it). It is now one if let ... && size == 0 (cargo clippy --fix, same behaviour).

Left out, and why

  • #396, #555, #670, #973, #1163, #1171, #1192, #1201: each conflicts with one of the PRs above in the file it edits (victory-pe layout, image and implib; victory-loader prepare, tls/stacks and windows; victory-core policy); they need a rebase after these land.

Verification

Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain):

Check Result
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo test --workspace --locked 391 passed, 0 failed, 7 ignored (main: 342 passed, 6 ignored)

The title was not run, so this says nothing about in-game effect. No game data is used or committed.

Re-verify in one go

git fetch https://github.com/MamaLeVrai/VIctory.git bundle/loader-pe-core
git checkout FETCH_HEAD
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked

To confirm that no component PR moved since this was built, compare each Head above with gh pr view <n> --repo Marvisak/VIctory --json headRefOid. If one differs, the branch needs a rebuild: merge the new head in the same order.

If this lands

The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠MamaLeVrai** on GitHub · 2026-11-24 18:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1456) `MamaLeVrai:bundle/loader-pe-core` → `main` · +2731 −292 · 16 files · 51 commits · closed without merging **One PR in place of 20.** Twenty PRs on the loader, the PE reader and the config: TLS scan speed, relocation and section bounds, import binding, unwind and crash reports, thread shutdown, CPU instruction emulation (CLZERO, RDPRU, CLWB), the watchdog opt-out, and the policy and data-directory checks. Every head is merged unchanged onto `main` (`ffe310e`), and the result is built and tested together. > For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a `[BUNDLE]` PR. The re-verification commands are below, so one run covers all of it. ## What is inside | PR | Author | Head | Title | |---|---|---|---| | #188 | TG0000 | `2a6e6a4bc` | Loader: find TLS-array load candidates sixteen offsets at a time (8-9x faster scan) | | #213 | Dufftwt | `7f00a62a4` | Crash reports: name the host's CPU and Windows build | | #214 | Makto94 | `514927d` | Loader: clzero loops in one exception; rdpru (#34 rebased, with a fix) | | #219 | DiegoFR20 | `e57e76a7b` | fix(pe): validate section raw data bounds | | #221 | AndyLatimer | `acdcc4168` | Loader: suspend a thread before reading its TEB; skip bad dump times | | #311 | CesarLopesO | `1251a24b7` | test(pe): cover header layout offsets | | #324 | pedrofort | `c37793a` | fix(pe): detect incomplete TLS callback arrays | | #363 | enzoduarte1 | `fd44561ea` | Config: ignore an empty VICTORY_CONFIG | | #406 | ? | `b33c704e3` | | | #454 | ruvenesh | `85c04d129` | Loader: opt-in VICTORY_NO_WATCHDOG hook for the title's watchdog (build 1.0.2.1) | | #529 | pushkarreddyy | `609c74fbd` | PE: preallocate symbol_key in CodeViewInfo | | #560 | Quat3rnion | `1aac20aa8` | Loader: stage prepared images in per-writer files | | #708 | Loggerten | `a9698e748` | fix(config): keep the data directory out of the cache root | | #937 | nino-exe | `52f0a099e` | policy: resolve a .. in the not-yet-existing part of a path | | #941 | BastienRodz | `60d2cf9cb` | Loader: a clwb in the last bytes of a page is emulated instead of faulting | | #963 | enzoduarte1 | `adeb9ff49` | PE: read long-format import descriptors | | #1111 | divyeshganta | `5f8800dd9` | fix(loader): preserve protection regions when binding unaligned imports | | #1159 | geiyiliyabumo | `121412bec` | loader(crash): verify unwind against known caller frames when RtlCaptureStackBackTrace returns empty | | #1304 | geiyiliyabumo | `98716d1a5` | Loader: fix thread shutdown targeting, registry lifetime, and CRT detach ordering | | #1306 | geiyiliyabumo | `29d78bae7` | Loader: fix thunk block overflow, capacity enforcement, flush errors, and leaks | ## Changes made while bundling No merge conflicts. One change of mine, in its own commit: the long-format import descriptor code that #963 adds nests `if size == 0` inside an `if let`, which `clippy::collapsible_if` rejects under `-D warnings` (#963's own CI run fails on it). It is now one `if let ... && size == 0` (`cargo clippy --fix`, same behaviour). ## Left out, and why - **#396**, **#555**, **#670**, **#973**, **#1163**, **#1171**, **#1192**, **#1201**: each conflicts with one of the PRs above in the file it edits (`victory-pe` layout, image and implib; `victory-loader` prepare, tls/stacks and windows; `victory-core` policy); they need a rebase after these land. ## Verification Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain): | Check | Result | |---|---| | `cargo clippy --workspace --all-targets --locked -- -D warnings` | clean | | `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` | clean | | `cargo test --workspace --locked` | 391 passed, 0 failed, 7 ignored (`main`: 342 passed, 6 ignored) | The title was not run, so this says nothing about in-game effect. No game data is used or committed. ## Re-verify in one go ```powershell git fetch https://github.com/MamaLeVrai/VIctory.git bundle/loader-pe-core git checkout FETCH_HEAD cargo clippy --workspace --all-targets --locked -- -D warnings cargo clippy --workspace --all-targets --all-features --locked -- -D warnings cargo test --workspace --locked ``` To confirm that no component PR moved since this was built, compare each `Head` above with `gh pr view <n> --repo Marvisak/VIctory --json headRefOid`. If one differs, the branch needs a rebuild: merge the new head in the same order. ## If this lands The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The static TLS redirect tested the whole 9-byte `mov r64, gs:[0x58]`
pattern at every byte of every executable section. It now skips with
SSE2 compares to the offsets that hold `gs`, `8B` two bytes on and `25`
four bytes on, and tests the full pattern only there. Offsets without
those three bytes cannot match, so the patched bytes and the count are
the same as before.

A test checks the new scan against the old byte-at-a-time one on random
code with loads, near misses and overlaps, at every word alignment. An
ignored release benchmark (tls_scan_speed) times both on 1, 16 and
128 MiB of synthetic code: 8-9x faster.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Whether a crash is a missing instruction depends on the CPU (Intel CPUs
lack some of the console's AMD-only instructions), and which D3D12
runtime there is depends on the Windows build, yet a report carries
neither, so every report has needed a follow-up question.

Unhandled exceptions, panics and host GPU failures now end with a
"host:" line naming the CPU's brand string and the real Windows
version (RtlGetVersion), read once when the crash log is set up.
Based on #34 by ka1qux (commit faa0a9a), rebased over #45, which added the
same flag and register helpers for clwb loops; the duplicates are merged
into gpr/cmp_flags/CMP_FLAGS.

clzero: the two loops compilers build around it are done whole in one
exception, leaving registers and flags as the last pass would. Anything else
around it is one line and the next instruction.

rdpru: returns the time-stamp counter for MPERF and APERF, 0 for other
counters, and leaves the flags as they are: a Ryzen 7 5800X3D running it
natively in user mode changes none, for known counters or not.

Added over #34:
- loop 1 rejects cmp rax, rax (it fell into the loop and left wrong flags);
- tests that go through the emulation on any CPU (both loop shapes, the
  rax-rax and wrong-neighbour fallbacks, rdpru with both flag states), since
  on an AMD host the native tests never enter the handler.
Based on #34 by ka1qux (commit faa0a9a), rebased over #45, which added the
same flag and register helpers for clwb loops; the duplicates are merged
into gpr/cmp_flags/CMP_FLAGS.

clzero: the two loops compilers build around it are done whole in one
exception, leaving registers and flags as the last pass would. Anything else
around it is one line and the next instruction.

rdpru: returns the time-stamp counter for MPERF and APERF, 0 for other
counters, and leaves the flags as they are: a Ryzen 7 5800X3D running it
natively in user mode changes none, for known counters or not.

Added over #34:
- loop 1 rejects cmp rax, rax (it fell into the loop and left wrong flags);
- tests that go through the emulation on any CPU (both loop shapes, the
  rax-rax and wrong-neighbour fallbacks, rdpru with both flag states), since
  on an AMD host the native tests never enter the handler.
Stack dumps (VICTORY_STACKS, diagnostics builds) read another thread's
TEB right after NtQueryInformationThread and suspended it only later: a
thread exiting in between frees its TEB, and the read faults. The
thread is now suspended first and resumed on every way out.

The dump times went through Duration::from_secs_f64, which panics on
`inf` or `1e20`, killing the dump thread (the crash hook logs it as a
crash). They are parsed by `schedule` now, which leaves out NaN and
times no Duration holds. 1 new test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The title ends the process on purpose when its main thread has not advanced
for about 30 one-second ticks (a write to address 0 at +0x23cf683, with a
second one at +0x2215c35 right after the handler call). On a host much slower
than the console a long load can exceed that window.

With VICTORY_NO_WATCHDOG=1 the loader jumps over the abort site and makes the
handler's fault a NOP. Each patch is applied only if the original BLAKE3
starts with the 1.0.2.1 identity and the exact original bytes are at the
offset; otherwise it logs a warning and does nothing. Off by default.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`default_dir` resolved both the cache and the data directory from
LOCALAPPDATA, then XDG_CACHE_HOME, then `$HOME/.cache`. On any host without
LOCALAPPDATA — Linux, or Windows with it unset — the data directory therefore
landed at `<cache>/victory/data`, inside a root the docs say may be deleted at
any time:

    /// What titles write and must keep (persistent local storage). Never
    /// inside the cache, which may be deleted at any time.

Split the two defaults. Windows behaviour is unchanged: LOCALAPPDATA still
provides both. Elsewhere the cache keeps XDG_CACHE_HOME or `$HOME/.cache`, and
the data directory moves to XDG_DATA_HOME or `$HOME/.local/share`.

Both take the environment lookup as a parameter, so the new test
`data_dir_not_under_cache_without_localappdata` needs no unsafe env mutation.

Review fixes:
- `env_dir` filters each variable before the `or_else` chain. A set-but-empty
  LOCALAPPDATA no longer hides XDG_CACHE_HOME / XDG_DATA_HOME, and an empty
  HOME no longer yields a relative `.cache/victory/cache`.
- `empty_test_titles_env_is_ignored` and `test_titles_env_splits_paths`, added
  on main after this branch point, now give their mock environment a HOME.
  Without it the mock hid the real environment and resolve() errored.
- New tests: empty LOCALAPPDATA falls through to XDG, XDG with no HOME, and an
  empty HOME errors instead of resolving to a relative path.

Existing saves under the old `<cache>/victory/data` are not migrated; set
VICTORY_DATA_DIR to that path to keep using them.

Verified: cargo test -p victory-core 15 passed, clippy -D warnings clean,
cargo xtask policy 154 files ok.
Use an unaligned store for parser-accepted IAT slots. Protect and restore each crossed memory region independently, including cleanup after partial setup failure. Add synthetic CPU-only Windows regressions. AI-assisted.
write_if_changed used a shared <hash>.tmp file, so two concurrent cold launches of the same image could truncate each other's staging bytes or fail the rename after the other had published. Move publication into a portable module that stages under a unique pid/sequence name and removes it on failure. Two hermetic tests cover concurrent publishers and a failed rename.
`resolve` canonicalizes the longest existing prefix and re-appends the rest, but it walks up with
`Path::file_name()`, which is None for a trailing `..`. A path such as `<tmp>/a/../b` (nothing exists yet) hit the
`_` arm and returned PolicyError::Io, so a cache_dir or data_dir with a `..` in a directory that does not exist yet
was rejected, and `normalize`'s `..` handling for the missing tail was never reached.

A trailing `..` is now kept in `rest` so `normalize` resolves it lexically.

Test: resolves_dot_dot_in_a_path_that_does_not_exist_yet (fails before, passes after). cargo test -p victory-core,
cargo fmt --check and cargo clippy --tests are clean.
emulate_amd_only copies only the bytes left in the faulting page and
gated clwb_len on n >= 15 because clwb_len took a fixed [u8; 15]. A
4- to 10-byte clwb starting in the last 14 bytes of a page (or falling
back from a clwb_loop that straddles the page end) was therefore
skipped, leaving pre-Ice Lake Intel CPUs with an unhandled
STATUS_ILLEGAL_INSTRUCTION.

Change clwb_len to take &[u8], bounds-checking each byte read and
returning Some(len) only when len <= code.len(), and drop the n >= 15
guard in emulate_amd_only.

Fixes #924.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The hook was enabled by the variable being set at all, so =0 or an empty
value turned it on. Treat those as off, as a reviewer suggested.

Checked: cargo clippy -p victory-loader --target x86_64-pc-windows-msvc -- -D warnings is clean and the loader tests build (box, cross-compiled). Not run on Windows.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Merges #188 #213 #214 #219 #221 #311 #324 #363 #406 #454 #529 #560 #708 #937
#941 #963 #1111 #1159 #1304 #1306 onto main (ffe310e), each head unchanged,
no conflicts.

One change of mine: the long-format import descriptor code #963 adds nests
`if size == 0` in an `if let`, which clippy::collapsible_if rejects under
-D warnings; it is now one `if let ... && size == 0` (clippy --fix, no
change of behaviour).

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(388 passed, 7 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The shader chain moved: #306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The shader chain moved: #306 is at its author's new head (e3067ae), and the bundle's own
validator commit is reverted.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:32:36 +00:00
github-bot closed this pull request 2026-11-26 04:32:36 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 18:45 UTC · original

Runtime boot check on real hardware with a retail dump

Result: no difference from main in this test.

I merged head b99cbde onto main ffe310e (clean merge), built it (release), and ran victory run <title exe> --execute with an empty data folder for 100 s, without any input. I compared the run with main built and run the same way.

main ffe310e this PR
Reaches the first-boot screens yes yes
Caption at 100 s (one sample) 30 fps, 12 draws/frame 30 fps, 12 draws/frame
Frames presented 2,048 2,048
crashes.log entries 0 0
Committed memory 11.1 GB 11.1 GB

Warnings: 7, the same kinds and counts as on main. 0 errors.

Limits. Without input, the title stays on the first-boot screens. This run does not exercise saves, the intro video, the start screen, loading or the world. It shows only that the change does not break startup or the first menus on this machine. I did not run the PR's tests.

Machine: Ryzen 7 7800X3D, RTX 4070 SUPER, Windows 11 25H2, game 1.0.2.1. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 18:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1456#issuecomment-7141106375) ### Runtime boot check on real hardware with a retail dump **Result: no difference from `main` in this test.** I merged head b99cbde onto `main` ffe310e (clean merge), built it (release), and ran `victory run <title exe> --execute` with an empty data folder for 100 s, without any input. I compared the run with `main` built and run the same way. | | `main` ffe310e | this PR | |---|---|---| | Reaches the first-boot screens | yes | yes | | Caption at 100 s (one sample) | 30 fps, 12 draws/frame | 30 fps, 12 draws/frame | | Frames presented | 2,048 | 2,048 | | `crashes.log` entries | 0 | 0 | | Committed memory | 11.1 GB | 11.1 GB | **Warnings:** 7, the same kinds and counts as on `main`. 0 errors. **Limits.** Without input, the title stays on the first-boot screens. This run does not exercise saves, the intro video, the start screen, loading or the world. It shows only that the change does not break startup or the first menus on this machine. I did not run the PR's tests. Machine: Ryzen 7 7800X3D, RTX 4070 SUPER, Windows 11 25H2, game 1.0.2.1. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:40 UTC · original

Automated triage for the maintainers. Closing because this pull request re-packages other open pull requests. Each of those is reviewed on its own, so a bundle cannot be merged.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1456#issuecomment-7148763183) Automated triage for the maintainers. Closing because this pull request re-packages other open pull requests. Each of those is reviewed on its own, so a bundle cannot be merged. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1456
No description provided.