Find TLS and delay-import directories by address in pe_map #103
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!103
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/103/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?
@Vonsek on GitHub · 2026-11-21 15:59 UTC · original
Vonsek:pe-map-tls-delay-dirs→main· +112 −7 · 4 files · 3 commits · merged 2026-11-21 17:07 UTCChange
pe_map_imagetested onlySizefor the TLS and delay-import directories. Measured on Windows 11 build 26200, the loader finds the TLS directory by its address:LoadLibrarype_mapbeforepe_mapnowThe loader does not read the delay-import directory at all: copies of the named import fixture with an empty table, address 0 with Size 32, an address past the image, or a descriptor that names a DLL all load.
pe_mapnow separates these cases instead of testingSize:LoadLibraryExWpe_mapbeforepe_mapnowSo TLS is present when its address is set and must fit in the image; supported TLS callbacks keep running, and TLS data templates stay unsupported. Malformed directory metadata is a format error, distinct from supported TLS and from unsupported delay imports. Refs #46.
Verification
Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, at
01aa32f(on maina2a62ee, with #78):The existing #78 TLS checks (notification order, FALSE entry point, rejections, non-DLL copies, release after the callback list changes) pass unchanged. Against main's
pe_map,cpu_native_tlsfails at "TLS Size 0" (callback missing underpe_map) andcpu_native_mapfails at "delay empty table, Size 32". The fullctest --preset dev --no-tests=errorpassed 78/78 (bvh_wave64_hardwareandbvh_wave64_warpskipped, lane range 32..32).Evidence and follow-up
No new fixtures. The TLS cases patch temporary copies of
cpu_tls_originaland compareLoadLibrarywithpe_mapin a child process per load, using the existing notification sink. The delay cases patch temporary copies ofcpu_import_original, which has no entry point, soLoadLibraryExWruns nothing in the image. The empty table is the zero-filled tail of the.rdatapage; the descriptor that names a DLL is the import descriptor read at offset 8, whoseForwarderChainandNameline up withAttributesandDllNameRVA.Assumption: an empty delay table is recognised by a zero
DllNameRVAin the first descriptor. #85 changes the ordinary import walk in the same file; the two touch different blocks, and whichever lands second needs a small rebase intests/cpu/native_map_check.py. Docs: the native mapping and TLS paragraphs indocs/experiments.md.@R0Y00 on GitHub · 2026-11-21 16:23 UTC · original
Thanks for finding the zero-size case. #78 has now landed. Please update on main and keep supported TLS callbacks working; distinguish malformed directory metadata from supported TLS and from unsupported delay imports. Include Windows comparisons for the disputed address/size cases.
@Vonsek on GitHub · 2026-11-21 16:59 UTC · original
Updated on main with #78 (
01aa32f):Size0, 1 or 39 run the callback and then the entry point under bothLoadLibraryandpe_map, and with the address set to 0 only the entry point runs under both. Before,pe_mapskipped the callback for Size 0, rejected Size 1 and 39, and reported "TLS data" for address 0 because it read the DOS header.LoadLibraryExW.pe_mapmaps an address of 0 and an empty table, and keeps a descriptor that names a DLL unsupported.The Windows comparisons for each address/size case are in
cpu_native_tlsandcpu_native_map, with before/after tables in the description.cpu_native_*4/4 and the full suite 78/78 pass on Windows 11 26200.9974.