Loader: preserve an empty import table for Windows 10 static TLS #28
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!28
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/28/head"
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?
@ifBars on GitHub · 2026-11-23 23:20 UTC · original
ifBars:fix/windows10-import-directory→main· +91 −6 · 2 files · 4 commits · merged 2026-11-24 00:31 UTCWhat changed
Keep a valid empty import table in the DLL VIctory prepares for Windows. Point the import-directory entry at the existing null descriptor and retain the original IAT directory. VIctory binds the slots recorded when it parsed the original image.
The PE parser already walks the descriptors to their null terminator. Using the number of descriptors it read handles linkers whose import-directory size excludes the terminator.
Tested
AI assistance: Codex prepared the patch and ran the checks above.
@Sunkiller-qc on GitHub · 2026-11-23 23:46 UTC · original
Looks good to me, and the fallback when the last 20 bytes aren't a zero descriptor keeps the old behaviour (
prepare.rs:116). Question: since the description says the loader goes there because an IAT is still advertised, did you also try clearing the IAT directory (IMAGE_DIRECTORY_ENTRY_IAT, index 12) alongside the import entry? That might avoid relying on the import directory'sSizeincluding the terminator, which not every linker guarantees. Static review, not built or run.@DaviTostes on GitHub · 2026-11-24 00:06 UTC · original
Tested
4da3d63stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass (no regression only).cargo test --workspace: 155 passed, 0 failed, 3 ignored; the merge with #39 is clean.crates/victory-loader/src/prepare.rs/victory-pe/src/layout.rs; the behaviour itself needs a Windows 10 host, so what runs here is the portable loader/PE suite around it.AI-assisted (DeepSeek V4.1 Flash coding agent).
@ifBars on GitHub · 2026-11-24 00:03 UTC · original · edited 2026-11-24 00:07 UTC
@Sunkiller-qc, correction to my previous result: mapping and binding succeeded, but my test missed Windows static TLS initialization. I checked the index through the mapped TLS directory on Windows 10 19045.7846, before running any title code. In fresh processes, the executable and both TLS-bearing DLLs each received index 6 with an empty import descriptor. With both directory entries cleared, all three index slots remained at their on-disk zero. The execution test failed during startup with that layout.
25a3e95restores the empty descriptor and locates it using the parsed descriptor count, so the linker can exclude the terminator from its reported size. All five prepared images match the original working layout byte for byte, and the corrected map-only command reported static TLS redirection and zero missing imports. All 14 loader and PE tests passed, including a Windows test that checks the assigned TLS index on a prepared DLL.@ifBars on GitHub · 2026-11-23 23:55 UTC · original · edited 2026-11-24 00:07 UTC
Update: A static TLS check changed the conclusion below. See the corrected results and fix.
@Sunkiller-qc I tested your suggestion on Windows 10 22H2 (19045.7846). The prepared executable and all four DLLs mapped and unloaded with both layouts. VIctory's map-only run with the import and IAT directories cleared also bound all five images with zero missing imports.
I switched to clearing both entries in
4da3d63. The binder uses the slot RVAs saved from the original image. A regression test now covers an import-directory size that excludes the terminator and checks that the original IAT slots survive preparation. All 13 loader and PE library tests passed.@DaviTostes on GitHub · 2026-11-24 00:07 UTC · original
Re-checked the new head
25a3e95("Keep an empty import descriptor so Windows assigns static TLS") stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass (no regression only).cargo test --workspace: 155 passed, 0 failed, 3 ignored; merge with #39 clean.AI-assisted (DeepSeek V4.1 Flash coding agent).
@Proudnoob4 on GitHub · 2026-11-24 00:21 UTC · original
Tested
25a3e95on Windows 10 22H2 (19045.6456), i5-13600K, RTX 4080 (driver 621.01), title buildb99f876b…, merged onto main97c78d1. AI-assisted (Claude); I ran all of this myself.victory run(no--execute): maps and binds with 0 missing imports and logsstatic TLS redirected index=12 patched=53246. Your earlierd85097agives the same line.static TLS redirectedline, so Windows 10 left the index at 0. That matches your correction.--execute, with a local Agility SDK export (#84; without it the host device stops at SM 6.5 on Windows 10):25a3e95ran the first-boot screens for 70 s with no errors.d85097aand keys pressed, the title went through the account prompt, intro, legal notices and start screen to the story loading screens at about 30 fps.slow host submission ms=11341 lists=33, then device removed). That looks like the known world GPU hang, not the loader.cargo test --workspaceon main +25a3e95: 225 pass, includingload_probe.net::only_loopback_is_reachablefails on Windows 10 becauseWinHttpGetProxySettingsExis Windows 11 only; #44 skips it in that test.@DaviTostes on GitHub · 2026-11-24 00:28 UTC · original
Re-checked the new head
0e5953d(merge ofmaininto the branch) stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass (no regression only).cargo test --workspace: 155 passed, 0 failed, 3 ignored; merge with #39 clean.AI-assisted (DeepSeek V4.1 Flash coding agent).
@erLCoder on GitHub · 2026-11-24 06:09 UTC · original
Additional Windows 10 execution data for the merged change, included in main
d2a4bae(not tested in isolation): Windows 10 Enterprise 22H2, Ryzen 5 3600, GTX 1660 Ti, Agility SDK 1.620.2. The prepared title executable had an empty import descriptor and retained its IAT directory. The executable and four DLLs mapped and bound with zero missing imports, and the title reached the prologue in two runs. The build also had diagnostic logging and local Agility exports; one run included PR #233. The loader library tests passed 19/19, including windows_assigns_static_tls_to_a_prepared_dll. The later GPU DEVICE_HUNG does not establish a loader defect. AI-assisted testing and report (OpenAI Codex).