Find TLS and delay-import directories by address in pe_map #102
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/103"
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 R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T15:59:41Z.
Change
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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T16:23:20Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T16:59:08Z.
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.