loader(hooks): nop debug int3 assertion before common exit #248

Manually merged
github merged 1 commit from gh-pr/248/head into gh-pr/248/base 2026-12-01 20:22:27 +00:00
Owner

@⁠Androtim on GitHub · 2026-11-30 11:50 UTC · original
Androtim:feat/iter242-loader-nop-assert-exit → main · +92 −12 · 2 files · 1 commits · merged 2026-11-30 12:07 UTC

Summary

  • Extract shared PatchSite and apply_sites helper in crates/victory-loader/src/hooks.rs, keeping the BUILD_1_0_2_1 BLAKE3 check and exact byte-signature guard.
  • Add ASSERT_EXIT (+0x4dcbc97, length 9) replacing the int3 (0xCC) before the common exit jump with nop (0x90), avoiding fatal 0x80000003 breakpoint traps on host setups where that assertion fires during play (VICTORY_NOP_ASSERT_EXIT=0 disables it).
  • Invoke nop_assert_exit during title image mapping in crates/victory-loader/src/windows.rs.
  • Add unit tests assert_exit_flag_defaults_on_and_honors_zero, assert_exit_patch_only_nops_int3_byte, and non-matching build coverage in unknown_build_skips_watchdog_hooks.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy: asset policy: 313 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-loader --lib hooks::: all tests passed
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings: exit 0
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings: exit 0
**@⁠Androtim** on GitHub · 2026-11-30 11:50 UTC · [original](https://github.com/Androtim/MiniVI/pull/248) `Androtim:feat/iter242-loader-nop-assert-exit` → `main` · +92 −12 · 2 files · 1 commits · merged 2026-11-30 12:07 UTC ## Summary - Extract shared `PatchSite` and `apply_sites` helper in `crates/victory-loader/src/hooks.rs`, keeping the `BUILD_1_0_2_1` BLAKE3 check and exact byte-signature guard. - Add `ASSERT_EXIT` (`+0x4dcbc97`, length 9) replacing the `int3` (`0xCC`) before the common exit jump with `nop` (`0x90`), avoiding fatal `0x80000003` breakpoint traps on host setups where that assertion fires during play (`VICTORY_NOP_ASSERT_EXIT=0` disables it). - Invoke `nop_assert_exit` during title image mapping in `crates/victory-loader/src/windows.rs`. - Add unit tests `assert_exit_flag_defaults_on_and_honors_zero`, `assert_exit_patch_only_nops_int3_byte`, and non-matching build coverage in `unknown_build_skips_watchdog_hooks`. ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy`: `asset policy: 313 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-loader --lib hooks::`: all tests passed - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings`: exit 0 - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings`: exit 0
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:22:25 +00:00
github manually merged commit 33bcf22ab6 into gh-pr/248/base 2026-12-01 20:22:27 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 12:04 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: merge-candidate · CI (check): passing

Summary

Clean, tightly scoped loader hook addition with passing CI.

Review Notes

  • Refactoring (crates/victory-loader/src/hooks.rs): Extracting PatchSite and apply_sites keeps disarm_watchdog and nop_assert_exit sharing the same BUILD_1_0_2_1 BLAKE3 prefix gate, bounds checks in write_site, exact byte-signature verification, VirtualProtect restore, and FlushInstructionCache.
  • Patch correctness (ASSERT_EXIT): At +0x4dcbc97 (9 bytes: mov eax, [rsp+0x2c]; jmp -0x1d; int3; jmp -0x16), only byte index 6 (+0x4dcbc9d) changes from 0xCC (int3) to 0x90 (nop), preserving instruction boundaries and relative jump offsets.
  • Load-time wiring (crates/victory-loader/src/windows.rs): nop_assert_exit runs only for non-DLL images (!loaded.info.is_dll()) immediately after LoadLibraryExW and before any title code executes, matching the disarm_watchdog safety invariant.
  • Default behavior & tests: Unlike VICTORY_NO_WATCHDOG (opt-in), VICTORY_NOP_ASSERT_EXIT defaults to enabled and is disabled with =0. Unit tests cover flag parsing (assert_exit_flag_defaults_on_and_honors_zero), the single-byte 0xCC -> 0x90 invariant (assert_exit_patch_only_nops_int3_byte), and unknown-build no-op behavior (unknown_build_skips_watchdog_hooks).
  • Minor non-blocking nit: The module doc comment at the top of crates/victory-loader/src/hooks.rs still says Opt-in compatibility hooks, whereas VICTORY_NOP_ASSERT_EXIT is opt-out.

(Automated triage review; not formal maintainer approval.)


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-30 12:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/248#issuecomment-7277915939) <!-- minivi-triage v1 head=33bcf22ab68f3213e1eb8d5416110b8c2dde5019 verdict=merge-candidate ci=passing at=2026-11-30T12:05:23Z --> Automated triage for the maintainers (not an approval). **Verdict:** `merge-candidate` · **CI (`check`):** `passing` ### Summary Clean, tightly scoped loader hook addition with passing CI. ### Review Notes - **Refactoring (`crates/victory-loader/src/hooks.rs`)**: Extracting `PatchSite` and `apply_sites` keeps `disarm_watchdog` and `nop_assert_exit` sharing the same `BUILD_1_0_2_1` BLAKE3 prefix gate, bounds checks in `write_site`, exact byte-signature verification, `VirtualProtect` restore, and `FlushInstructionCache`. - **Patch correctness (`ASSERT_EXIT`)**: At `+0x4dcbc97` (9 bytes: `mov eax, [rsp+0x2c]; jmp -0x1d; int3; jmp -0x16`), only byte index 6 (`+0x4dcbc9d`) changes from `0xCC` (`int3`) to `0x90` (`nop`), preserving instruction boundaries and relative jump offsets. - **Load-time wiring (`crates/victory-loader/src/windows.rs`)**: `nop_assert_exit` runs only for non-DLL images (`!loaded.info.is_dll()`) immediately after `LoadLibraryExW` and before any title code executes, matching the `disarm_watchdog` safety invariant. - **Default behavior & tests**: Unlike `VICTORY_NO_WATCHDOG` (opt-in), `VICTORY_NOP_ASSERT_EXIT` defaults to enabled and is disabled with `=0`. Unit tests cover flag parsing (`assert_exit_flag_defaults_on_and_honors_zero`), the single-byte `0xCC -> 0x90` invariant (`assert_exit_patch_only_nops_int3_byte`), and unknown-build no-op behavior (`unknown_build_skips_watchdog_hooks`). - **Minor non-blocking nit**: The module doc comment at the top of `crates/victory-loader/src/hooks.rs` still says `Opt-in compatibility hooks`, whereas `VICTORY_NOP_ASSERT_EXIT` is opt-out. *(Automated triage review; not formal maintainer approval.)* --- _Generated with Antigravity CLI (`agy`)._
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/Androtim--MiniVI!248
No description provided.