Zero-fill a mapped section that has no file offset, as Windows does #106
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/107"
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 danielradosa on 2026-11-21T16:01:40Z.
Change
pe_map_imagecopiedmin(SizeOfRawData, VirtualSize)bytes fromPointerToRawDataeven when that pointer was zero. A section with no file offset therefore received the DOS and NT headers from the start of the file. The Windows loader leaves such a section zero-filled. The mapper now copies nothing for a section whosePointerToRawDatais zero, so the section keeps the zeroed memory it was allocated with. This is the open case listed at the end of #85. Refs #46.Verification
The new
cpu_native_sectiontest loads the source-built register probe (no entry point, no imports, so no code runs) withLoadLibraryExWand withpe_map, and compares every section byte for byte. It then repeats this on a copy whose.rsrcheader hasPointerToRawDataset to zero andSizeOfRawDataunchanged. It also checks that the patch changes only.rsrcand that Windows zero-fills it.Windows 11 build 26300.9974, MSVC 19.51.36256, Python 3.14.4:
mainat88fd8c5pe_map .rsrc holds file bytes from offset 0, Windows .rsrc differsFull suite on this branch: 74 passed, 2 skipped (
bvh_wave64_*, capability skips on an RTX 4060 and WARP), 0 failed.Evidence and follow-up
LoadLibraryExWwithLOAD_LIBRARY_AS_IMAGE_RESOURCEalso zero-fills the patched section. The fixture is the existingcpu_register_probe; the patched copy is made at test time in a temporary directory, so there is no new fixture file.Correction: an earlier version of this description, and the docs note in the first commit, said
LoadLibraryExWrejects aPointerToRawDataof0x100or0x1ffbecause it is below the0x200file alignment. Further runs show that Windows rounds a nonzero offset down to a multiple of0x200instead. In.rsrcthat reads the headers as the resource directory, and that is what fails; with the resource directory entry cleared, the same copy loads. The second commit corrects the docs note. Matching the sector rounding inpe_mapis a separate behavior, proposed in #111.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T16:01:49Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
2ce2b96ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.