Repository navigation
Conversation
Windows 10's loader (19045) still reads the IAT directory of the prepared image after the import directory is cleared, and faults reading a descriptor's Name at 0xC inside LoadLibraryExW. Windows 11 skips it. Clear the IAT directory with the other two: we unprotect and fill every slot ourselves from the original's imports, so nothing needs it. Also skip WinHttpGetProxySettingsEx in net.rs's "every override names a real export" test: the export is Windows 11 only, and our override serves the title either way.
|
Tested
So what passed everything here on Windows 10 was #28's layout together with this PR's |
|
Now that #28 is merged, the The Static review, not built or run. |
What
On Windows 10 (19045),
LoadLibraryExWof the prepared image faults with0xC0000005inntdll, reading0xC(an import descriptor'sName).prepareclears the import directory but leaves the IAT directory, and Windows 10's loader still walks it; Windows 11 skips it.This clears the IAT directory together with the import and bound-import directories (
dir::IAT = 12added tovictory-pelayout). Nothing needs it afterwards:bind_importsunprotects and fills each slot itself (windows.rs,VirtualProtectper slot) frominfo.importsparsed from the original.It also skips
WinHttpGetProxySettingsExinnet.rs's "every override names a real export" test. That export only exists in Windows 11'swinhttp.dll; our override serves the title either way.Relation to #28
#28 fixes the same crash by pointing the import directory at the table's all-zero terminator. This is an alternative: it removes what Windows 10 trips on instead of feeding it an empty table, so there is no fallback path when an image has no readable terminator (#28 falls back to zeroing, which is the crashing case). Either is fine by me; happy to close this if #28 is preferred. The
net.rstest fix is independent of either.How the cause was found
I took the prepared image the crashing
load_probetest left behind and loaded copies with one data directory zeroed at a time, each in its own process. Only zeroing the IAT directory loaded; zeroing load config, TLS, relocations, exceptions, debug, exports or delay imports did not.Tested
cargo test --workspacefailedvictory-loader --test load_probe(STATUS_ACCESS_VIOLATIONinsidevictory_loader::load) andonly_loopback_is_reachable.cargo test --workspace --lockedpasses everything, includingloads_binds_and_calls_probeend to end (bind, calls into the image, TLS callbacks andDllMainon new threads, detach).prepare's test now also asserts the IAT directory is cleared.cargo xtask policypasses. Not tested with game data.AI assistance: Claude Code traced the crash, prepared the patch and ran the checks above.