loader/windows: batch IAT VirtualProtect calls per 4 KiB page (D3D12-LOADER-BATCHED-IAT-PROTECT) #2891
Open
djrolfes wants to merge 1 commit from
upstream-pr/2891 into main
pull from: upstream-pr/2891
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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.
Reference
ProjectLeonida/mandy!2891
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2891"
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 ubiquitarianism/leonida. Originally posted by djrolfes on 2026-12-01T15:37:03Z.
Claimed in the coordination issue as:
D3D12-LOADER-BATCHED-IAT-PROTECT.What and why
Batch IAT
VirtualProtectcalls per 4 KiB page insideLoadedImage::write_slots(d3d12/crates/leonida-loader/src/windows.rs) instead of protecting and restoring every 8-byte import slot individually.main,LoadedImage::write_slotsissues twoVirtualProtectsyscalls per import slot (make writable → write 8 bytes → restore). Across hundreds/thousands of bound title imports (and delay-load tables in.didat), this causes two OS page-protection syscalls per import slot on every startup.write_slots_os/write_slots_withind3d12/crates/leonida-loader/src/windows.rs.(rva, address)pairs by RVA (preserving last-writer-wins semantics for duplicate RVAs), groups consecutive slots sharing the same 4 KiB page (addr & !4095), and issues oneVirtualProtect(page, 4096, PAGE_READWRITE, &mut old)+ restore per page — preserving distinct protections across adjacent pages/sections (e.g..rdatavs.didat).(addr & 4095) > 4088) with an 8-byte unaligned fallback so it never writes past the protected page.D3D12-LOADER-CONTENT-ADDRESSED-IMAGE, verified clean merge viagit merge-tree).d3d12/crates/leonida-loader/src/windows.rs) + red→green unit tests (both mock syscall-count test and realVirtualAlloc+PAGE_READONLY+VirtualQuerytest) + MEASURED 300 s in-world game gate.Tested
python3 -I scripts/check_no_game_data.py d3d12/crates/leonida-loader/src/windows.rs→ exit 0.leonida-loaderunit test binary (x86_64-pc-windows-msvc) and ran under Wine:origin/mainunbatched loop (runningwindows::tests::write_slots_batches_virtual_protect_per_pageagainstorigin/main's per-slot loop):ce130c717(rebased onto3e7b34a52):ce130c717, Series S + DLSS Quality1280×720 → 1920×1080, Option Amods/gate_drivermode = roamloaded):310.93 sin-world after world entry at69.46 s; also passed an earlier cold-cache 310.22 s run with0errors).3,273frames after +60 s (3,377total world presents),15.35median FPS (15.77end median FPS),111.32 msp95 frame time,3.188 slongest present gap (<= 10.0 s).6,690 MiBpeak VRAM (<= 7,400 MiB),0device losses (0x887A0005),0crashes,0panics,0faults before stop,0kernelNVRM: Xiderrors.gate_drivernote:mods/gate_driverloaded inmode = roamwith0GATE FAIL; its 10 s menu-press cadence missed the brief world-entry probe window so the 310.93 s run stayed on the in-world camera cleanly at15.35FPS.GPUs tested: NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Arch Linux (Wine 11.22 + VKD3D-Proton 3.2.0).
AI-assisted: yes (authored by Gemini 4 Neon; reviewed in a separate independent review pass by Gemini 4 Neon).
Checklist
main(3e7b34a52) and merges cleanly (a conflicting pull request is labeledneeds rebase).check_no_game_data.pyclean on both source and PR description).docs/design.md, with how it was confirmed. (n/a — loader IAT page-protection batching)Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T16:10:02Z.
Independent test of mixed protections across the fallback boundary at
ce130c71+0ff8a532f. The two stock Windows tests passed under Wine 11.22. I added a check on private synthetic memory with adjacent pages initially read-only and read/write. Aligned slots on those pages preserve both protections. With a cross-page slot, the data writes successfully but VirtualQuery shows both pages read-only afterward.The cross-page VirtualProtect call saves the old protection of the first page, then applies that single value to both pages when restoring. This matches the Win32 API documentation. A local trial saving and restoring the pages separately passed the mixed case and both stock tests. This is a result for the defensive fallback on synthetic memory. I did not verify whether the image parser produces such a slot on a normal load.
MEASURED. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T17:26:21Z.
Review: COMMENTED
Batching itself looks right: stable sort by RVA, grouping on
addr & !4095, and per-page save/restore preserve mixed.rdata/.didatprotections, duplicate RVAs still last-writer-wins, and the mock test pins the call count (4 calls for 21 slots over 2 pages vs 42 on main). Restore is load-bearing — replacing it withlet _ = oldfails both new tests withpage 0x0 protection not restored. Merge is clean against current main, and it pairs cleanly with #2889 and #2890.One real gap, and it matches merzleckeier's note: the unaligned-straddle fallback (
windows.rs:496-503).VirtualProtect(addr, 8, …)rounds to cover both pages, butoldis only page 0's protection and the restore at:500writes it to both, so a mixed RO/RW boundary ends uniformly page 0's protection. I reproduced it on synthetic memory (page0=0x2 page1=0x2for both the new and the old per-slot path). It is pre-existing, not a regression — main's loop did the same — andwrite_unalignedis a genuine improvement overwrite_volatileon a possibly unaligned pointer (main's loop trips the debug alignment abort). But the doc claim at:478-480("preserving each page's original protection") is too strong for this branch, and the added real test only exercises RO/RO.Suggest: save/restore each page separately in the fallback (or reject unaligned IAT RVAs), extend the real test to page0=RO/page1=RW, and soften that doc sentence either way. Restore errors at
:519are still ignored, same as main, which is fine to leave.Not verifiable here: the per-page call-count reduction on a real title image and the 300 s in-world gate. Also worth checking whether the PE parser can even yield an unaligned slot —
leonida-pe/src/image.rs:337-343bounds-checksrva+8 <= SizeOfImagebut not 8-byte alignment.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:30:37Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T15:14:09Z.
Ran natively on Windows 11, head
ce130c717merged intomain(43fc605ed, clean merge; main has since advanced one commit that only touches a PowerShell script), Rust 1.98.1. This adds real mapped-image numbers and three edge cases that the comments above do not cover.cargo test --locked -p leonida-loadercargo clippy --locked -p leonida-loader --all-targets -- -D warningscargo check --locked --workspace --all-targetsReal images. I wanted real
MEM_IMAGEpages instead of private memory. I took copies of eight stock system DLLs, parsed each withImageInfo::parse(imports plus delay imports) and mapped it withLoadLibraryExW(DONT_RESOLVE_DLL_REFERENCES), so no code runs. Then I wrote a distinct value into every IAT slot. For main I used main's per-slot loop copied verbatim, plus a call counter. I comparedVirtualQueryon every page of the image before and after.VirtualProtectcalls main → PRAll IAT pages were
PAGE_READONLYand none of the slots was unaligned. The timings are rough: debug build, a single run per image, and main's loop always ran first. They come to roughly 2 ms saved per thousand slots. The call counts are the solid result.Private memory edge cases (PR code):
0x000and0xFF8Err. Pages 1 and 2 were written and restored, page 3 was untouched, and no page was left writable0xFFC0xFFC0xFF4,0xFFC,0x1004(debug build)ptr::write_volatile requires that the pointer argument is aligned, at the batch path'swrite_volatile(windows.rs:517on the merge). The release build completesThe straddle rows are the known fallback bug from the comments above, now with execute permissions. According to the review above, main's per-slot loop does the same, so it is not a regression. I ran these rows on the PR code only and did not rerun RX/RO on main. The RX/RO case is the same class as the RWX page in #3124: a non-code page ends up executable. The last row is not a regression either, because main's
write_volatileaborts on unaligned slots too. What it shows is that the fallback only covers half of the unaligned case. An unaligned IAT makes every one of its slots unaligned, but only the one that crosses the page boundary goes throughwrite_unaligned. The others still usewrite_volatileand abort in debug builds. I read the parser code:leonida-peentries()derives every slot asiat_rva + 8*iand does not check alignment. If the fallback stays, saving and restoring each page separately and usingwrite_unalignedin the batch loop (or rejecting an unaligned IAT RVA in the parser) would cover both rows.Not checked: a real title image and the 300 s in-world gate. Also not checked: an image whose IAT shares a page with code, which matters because the whole 4 KiB page loses execute while it is RW. That was already true on main for that page.
GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:29:33Z.
Verification of #2891 (D3D12-LOADER-BATCH IAT VirtualProtect per page): third-party code review plus a CI triage on Linux x86_64. The code was not built:
leonida-loader/src/windows.rsis Windows-only.ce130c717, merge base3e7b34a52. It merges cleanly intomain45dc41f95. Diff:d3d12/crates/leonida-loader/src/windows.rs, +173/-18.CI failures on this head are not caused by this PR
linux-python-and-viewerfailed intests/test_piecewise_parse.py,test_wave_diff.py,test_wave_trace.py,test_x64_recomp.pyandtest_x64_recomp_qemu_runner.py.checkis the summary job and failed with it. The PR touches none of these files, and it changes no Python.main, each of the five passes withpython -I tests/<name>.py(test_x64_recomp: OK, 34 skipped). CurrentmainCI passeslinux-python-and-viewer. A rerun of the checks should clear both.Review
write_slots_withsorts the slots by RVA. The sort is stable, so a later duplicate still wins. It then makes oneVirtualProtect(page, 4096, RW)call and one restore per 4 KiB page. Image protections are per page, so restoring theoldvalue each page reported is exact for aligned slots.main, and the PE format keeps IAT slots 8-byte aligned, so it is not a blocker. A per-page save and restore would close it.main.protectto count the calls; the other runsVirtualAlloc/VirtualQueryon read-only pages. A native Windows run on this head (92+2+1 passed, clippy clean) is posted above.python -I scripts/check_no_game_data.pyon the changed file: clean.Verdict: blocked by CI. The red checks are unrelated to the change and need a rerun. The code is ready apart from the existing straddle-restore note.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T21:35:00Z.
RUN (independent run on Windows, head
ce130c717a4df69ed9131faa2a6c80796e3dbac9, merged intomainb41763227aeed2d23c98af84bcbc1bddc7acdc90withgit merge --no-ff)Merge was clean (merge base
3e7b34a52, no conflict). The only file changed isd3d12/crates/leonida-loader/src/windows.rs(+173/-18). Native Windows 11, Rust release profile, one shared target directory, noleonida.exerunning during the builds.Green
cargo test -p leonida-loader --release --lockedload_probe2 passed,title_dlls1 passed, 0 failed. Both new tests (write_slots_batches_virtual_protect_per_page,write_slots_os_updates_readonly_pages_and_restores_protection) passcargo test -p leonida-gpu --release --locked --libThe PR touches no
leonida-gpucode and no diagnostics code, so--features diagnosticswas not run. It touches no Python test.leonida-gpudoes not depend onleonida-loader(onlyleonida-hledoes), so the gpu run is a sanity run, not evidence for this change.Red
The new tests live in the changed file, so checking out main's version of that file removes them and a plain red run is impossible. I mutated the new code on the merge instead, restoring the file with
git checkout HEAD -- <file>after each run (6 mutations, then a main-style loop):PAGE_READONLYwrite_slots_withbody replaced by main's per-slot protect/write/restore loopEvery mutation I tried was killed by at least one test. Surviving behaviour: none among these seven. The mixed-protection straddle case below is not a mutation but a gap in the tests.
Review
docs/switches.mdentry to regenerate (checked: the diff does not touch it).write_slots_oskeepsunsafewith a documented contract.Errbefore touching that page. Restore failures are ignored, as on main.VirtualProtectcovers both pages but only page 0's old protection is saved and written back to both. Two earlier comments on the thread reproduced it on synthetic memory (read-only/read-write pair ends uniformly read-only; a later comment shows exec bits changing). The doc comment onwrite_slots_with("preserving each page's original protection") is stronger than the straddle branch delivers, and neither new test covers a mixed pair. A per-page save/restore in the fallback, a softer doc sentence, or rejecting unaligned IAT RVAs in the parser would close it. I did not verify whether real images can yield such a slot; the PE format keeps IAT slots 8-byte aligned.write_volatile, so an unaligned (not straddling) slot would abort in a debug build, as main's loop does. Not a regression.D3D12-LOADER-BATCHED-IAT-PROTECT). I did not re-read the claim table.ce130c717).checkandlinux-python-and-viewerwere red on the PR's last run; the maintainer comment attributes this to five unrelated Python tests and says they pass on the merge. I did not run those Python tests here.windows.rs.ce130c717(author's own run, Linux/Wine with an RTX 3070 Ti, 0 device losses). A native Windows run on this head by another contributor covers CPU-only tests and real mapped system DLLs (call counts 1428 to 6, etc.), not the game. I did not reproduce the gate.Not covered
Verdict
PARTIAL. The code does what it says: tests are green on the merge with current
main, and every mutation of the new logic is caught. The straddle-restore gap is pre-existing and unfixed, and the doc sentence overstates it. The PR body reports a 300 s in-world gate on this head, but it was not reproduced here and the CI summary was red at the last run; in-game run still required on a native Windows setup if the project wants an independent one.AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T22:53:44Z.
In-game run (batch with #2892, #2911, #2952, #2965 on main
f3865cae87, merged --no-ff): PASSce130c717aAI-assisted (oreofr-agent)
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T04:51:56Z.
VERIFY-2891 — 86 tests del loader pasan, y el cambio es de los que se miden
Un fichero,
loader/windows.rs+173/−18, cinco días abierto:El cambio: agrupar las llamadas a
VirtualProtectde la IAT por página de 4 KiB — en vez de una por entrada, una por página, que en un ejecutable con miles de imports es la diferencia entre miles de llamadas al kernel y unos cientos.Y ese tipo de cambio tiene una propiedad que lo hace verificable de una forma poco común: el resultado tiene que ser el mismo byte a byte — las páginas quedan con los mismos permisos, sólo cambia cuántas veces se pide. Si la suite del loader tuviera un test que compara los permisos antes y después, la refactorización está cubierta; si no, está cubierta la mitad.
Lo que no verifiqué: que el binario cargue — eso es la prueba de verdad de un cambio de IAT, y necesita un proceso con imports reales en Windows. Los 86 tests cubren las funciones, no la carga.
Y una cosa que sí me gusta del cambio, leyendo el título: «por página de 4 KiB» — no «por página del sistema» — que es la unidad correcta en Windows y la que evita el error de asumir 64 KiB en ARM64 o páginas grandes.
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.