Scripts: check NumberOfRvaAndSizes before reading PE exports #1494
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1494
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1494"
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?
@microwave805 on GitHub · 2026-11-24 16:54 UTC · original
microwave805:scripts-pe-exports-ndirs→main· +29 −3 · 2 files · 1 commits · openscripts/re/pe_exports.pyunpacked the export data directory unconditionally at offset+96/+112of the optional header without checkingSizeOfOptionalHeaderorNumberOfRvaAndSizes. On a PE with zero data directories, it read the first section header name (such as.text) as the export table RVA and crashed withValueErrorinstead of printing(no exports).What is in it
scripts/re/pe_exports.py: readSizeOfOptionalHeaderandNumberOfRvaAndSizesand treat the export directory as(0, 0)whenNumberOfRvaAndSizes == 0or the optional header does not contain the first data directory entry.scripts/test_pe_exports.py: add synthetic PE32 and PE32+ fixtures withNumberOfRvaAndSizes = 0immediately followed by a.textsection header and verify(no exports)is printed.Tested
stable-x86_64-pc-windows-msvc, debug), Python 3.11.3python -I -m unittest discover -s scripts -p "test_pe_exports.py" -v: 1 passed, 2 subtest errors (both PE32 and PE32+ exited with status 1)130b1a8:python -I -m unittest discover -s scripts -p "test_*.py" -v: 17 passed, 0 failed.\scripts\test.ps1(cargo build --workspace && cargo test --workspace -- --test-threads=4): 770 passed, 0 failed, 41 ignoredgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
scripts/re/pe_exports.pyandscripts/test_pe_exports.py(no runtime or build-input files).Not tested
AI use
NumberOfRvaAndSizescheck inscripts/re/pe_exports.py, wrote the fix, unit test, and PR description, and ran the verification commands above.@DavidM1911 on GitHub · 2026-11-24 18:53 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@microwave805 on GitHub · 2026-11-24 19:01 UTC · original
@gut0to Thanks for checking — I ran
.\scripts\test.ps1directly on PR head130b1a8(RTX 3070, Windows 11): 770 passed, 0 failed, 41 ignored (2SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware—no wave64), and updated Tested in the description.(Comment drafted with Antigravity (Gemini 4 Neon).)
@RavenCurseBurg on GitHub · 2026-11-26 03:27 UTC · original · edited 2026-11-26 03:33 UTC
Tested
130b1a813d020731105a6deabfd20ac8fbececbdon Windows with valid PE32 and PE32+ files whose optional headers ended immediately after the zero directory count, and with zero-directory files retaining the padding. I interleaved export-free files with files that had exports, then added the installed 32-bit and 64-bit Windowsversion.dll. Runningpython -B scripts/re/pe_exports.py <files...>on this PR printed all eight expected listings in argument order and exited 0. Its two targeted unittest methods also passed.I then repeated the batch with two extra files whose exports reside in headers. The previous #1685/#1814 integration produced eight listings and returned 1 for the two compact files. This change ported to that reader produced all ten listings and exited 0. I checked the no-exports lines, ordinal 7 and RVA
0x1180for the synthetic named export, andGetFileVersionInfoWandVerQueryValueWin both system DLLs.On the integrated candidate,
python -B -m unittest discover -s scripts -p "test_*.py"passed all 25 tests, with no failures or skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ported the change and ran these read-only tests. The DLLs were read from disk. The runtime, GPU and games were outside this run.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.