pe: bound intake section spans by VirtualSize #754
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/760"
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 FZNull on 2026-11-23T01:22:19Z.
Problem
tools/intake_exe.pybounded RVA placement and the TLS callback slot count bySizeOfRawData. A section whoseMisc.VirtualSizeexceeds itsSizeOfRawDatamaps a zero-filled tail, and the Windows loader treats the section span asMisc.VirtualSize(tools/pe_map.cpp:95). A TLS directory or a callback-table terminator placed in that tail was rejected as unmapped or truncated, and the slot count stopped at the raw end.Reproduction against the source-built
intake_forward_caller.exe(.data:VirtualAddress0xc000,Misc_VirtualSize0x2b9,SizeOfRawData0x200) with the TLS directory at RVA 0xc200:Change
section_for()and the TLS callback slot bound useMisc_VirtualSize(falling back toSizeOfRawDatawhen it is zero, clamped toSizeOfImage), matching the loader.read_rva()reads the file-backed prefix and zero-fills the rest of a request from the uninitialized virtual tail; a short file-backed prefix still raisesTruncated data at RVA ....One behavior, no unrelated changes.
Test
tests/intake/check.pygainscheck_virtual_tail_tls(). It extends the last section'sVirtualSizepast its raw data so the tail exists under either linker layout (Debug and Release lay the fixtures out differently), then checks:Unmapped or unsuitable RVA ...);VirtualSizestops claiming the tail.The new test fails on
main(Unterminated TLS callback table or inspection limit reached) and passes with the fix, on bothdevandrelease.Verification
Environment: Windows 11, Python 3.13.12 (
out/pe-env, pefile 2024.8.26), MSVC 19.50.35726, Windows SDK 10.0.26100.0, CMake 4.5.1 + Ninja.Before the fix the issue reproduction exited 1 with
ValueError: Unmapped or unsuitable RVA 0xc200; after the fix it exits 0 and the intake report lists the parsed TLS callbacks. This is fixture evidence for the loader-bound behavior, not full-game startup evidence.Fixes #744