Loader: write IAT slots as bytes, so an IAT at an odd RVA is not UB (debug builds aborted at load) #260
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/260"
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?
Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T13:33:26Z.
windows.rswrite_slotspatched IAT slots withwrite_volatilethrough a*mut u64. Its SAFETY comment said the slots are "8-byte aligned by the PE format", but the format doesn't require that, and the parser doesn't check it. A title image whose IAT sits at an odd RVA is undefined behaviour, and a debug build aborts at load with "ptr::write_volatile requires that the pointer argument is aligned".Fix: the slot is written as
[u8; 8](little-endian), still volatile, so no alignment is assumed. The SAFETY comment now says so.Test:
an_unaligned_iat_slot_is_writtenwrites two misaligned slots, one of them across a page boundary, into read-only pages, the same as an image's import table. Before the fix it aborted; after it, it passes (10 runs out of 10).Results:
cargo test -p victory-loader --lockedpasses.-D warningsis clean, apart fromdescriptor_sites.rs:277, which is already failing onmainand which #169 fixes.🤖 Generated with 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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.