fix(loader): preserve protection regions when binding unaligned imports #1111
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1111
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1111"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@divyeshganta on GitHub · 2026-11-24 15:48 UTC · original
divyeshganta:fix/unaligned-iat-binding→main· +219 −15 · 2 files · 1 commits · openRelated to #923. Import binding now supports unaligned IAT slots and restores each crossed memory region’s protection, including cleanup after partial setup failure. Adds synthetic Windows regressions. Patch by DocBlack89 (
5f8800dd93).@Kal0s-design on GitHub · 2026-11-24 16:31 UTC · original
Independent check of
5f8800d, merged locally ontomainffe310e(fast-forward). Windows 11, MSVC, Rust 1.98.1 as pinned. It adds to DenRakEiw's run on the same head with a repeat count and a check of the old behaviour.cargo test -p victory-loader --locked: 25 unit + 2load_probe+ 1title_dllspassed, 0 failed. The lib suite was run 10 more times: 10/10 green.cargo clippy -p victory-loader --all-targets --locked -- -D warnings, with and without--all-features: clean.--lockedholds with the newWin32_System_SystemInformationfeature.main. Instead I replayedmain'swrite_slotssequence in a scratch test that is not part of the PR:VirtualProtect(slot, 8, PAGE_READWRITE), a write, thenVirtualProtect(slot, 8, old), with the slot straddling a PAGE_READONLY page and a PAGE_EXECUTE_READ page. After the sequence the second page reads back as PAGE_READONLY, not PAGE_EXECUTE_READ, 3 runs out of 3: the singleoldvalue restores only the first page's protection. This is what the per-region restore in this PR fixes.Not covered: that case needs a slot that is not 8-aligned, which a normal linker output does not produce, so this is hardening against malformed images; nothing was run against a real title.
AI-assisted: yes. Every number above is from my own runs.
@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
5f8800d:cargo test -p victory-loaderpasses, 28 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 01:26 UTC · original
Automated triage for the maintainers.
Needs work.
LoadedImage::write_slots(crates/victory-loader/src/windows.rs) now writes IAT slots withwrite_unaligned. The newwrite_protected_iat_slotwalks each memory region the slot crosses withVirtualQuery, makes each one writable, and restores all of them, including after a partial failure. The code reads correctly and the tests check it, but it handles a case real images don't produce. An 8-byte-aligned slot can't cross a page boundary, so only an unaligned slot can span two regions, and linker-built PE32+ images align their import tables. The bug shown in the comments needs a straddling slot, which the tests build by hand.What would make this mergeable: a short change that checks the one real assumption. The loader or
victory-peparser could reject (or report) an IAT slot that isn't 8-byte aligned, and the comment "8-byte aligned by the PE format" would then be enforced instead of assumed. If you know of a real image with unaligned IAT slots, please name it. That would justify the multi-region handling as it is.The
Win32_System_SystemInformationfeature is only used by the tests.CI: not run.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.