OLD-7282: restore old upstream PR 7282 - pe_inspect: read the resource directory and the RT_VERSION block without its strings #649
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!649
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/649/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?
@aslan2142 on GitHub · 2026-11-24 10:57 UTC · original
aslan2142:pe-inspect-rt-version→main· +498 −0 · 3 files · 1 commits · merged 2026-11-25 22:20 UTCClaimed in the coordination issue as: OLD-7282 #14
Restoration of my original pull request, old upstream PR 7282 in
ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at21625bca8c; no changes beyond the rebase.Depends on: #45 (draft; not a dependency, but both change
tools/pe_inspect.pyand conflict there)What and why
tools/pe_inspect.pynever read data directory 2, so the report said nothing about the version block, the one part of a PE that names its build.problems(offsets and counts only). The rest of the report is still written.docs/design.mddescribes the newresourcesfield next to the PE report steps.Tested
Linux, Python 3.14.10, CPU only, synthetic inputs (the tests build the resource tree and the version block by hand; no game files).
python -I tests/test_pe_inspect.py:python -I tests/test_docs_design_rows.pyandpython -I tests/test_design_contract_rows.py: OK.python -m compileall -q tools tests,git diff --checkandpython -I scripts/check_no_game_data.pyon the three changed files: clean.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code, Claude Opus 5.5).
@kirigayakazima on GitHub · 2026-11-24 11:48 UTC · original
Reviewed on Windows 11 x64 (
Python 3.14.7, CPU only, synthetic PEs only — no game files) against head commitb8951357f12bf7bdc80e46b8f31d42fb1bdc3c9c.Verdict: Looks good — clean implementation of PE resource /
RT_VERSIONmetadata extraction with strong redaction/hashing guarantees and bounds/cycle handling.Checks run locally
main(21625bca):git merge-tree --write-tree upstream/main HEADexited0;git diff --check upstream/main...HEADclean.python -I tests/test_pe_inspect.py -v: 69 tests, OK (0 skipped) (note: unlike Linux wheretest_system_dll_is_classified_systemskips, all 69 execute and pass on Windows).python -I): all 13 files passed —test_docs_cli_flags.py(4),test_docs_design_rows.py(5),test_docs_encoding.py(1),test_docs_env_vars.py(4),test_docs_links.py(16),test_docs_list_items.py(3),test_docs_pr_template.py(2),test_docs_python_deps.py(3),test_docs_repeated_lines.py(2),test_docs_repo_paths.py(3),test_docs_table_ids.py(2),test_docs_table_rows.py(2),test_design_contract_rows.py(5).python -I tests/test_ci_registration.py: 15 tests, OK.python -I tests/test_text_write_line_endings.py: 3 tests, OK.python -I scripts/check_no_game_data.py tools/pe_inspect.py tests/test_pe_inspect.py docs/design.mdandpython -m compileall -q tools tests: exit0.Synthetic edge-case probes
StringFileInfovalues, a customStringFileInfokey, a non-8-hexStringTablekey, a non-VS_VERSION_INFOroot key, unknown top-level /VarFileInfochild keys, and two distinct named resource types. Runningpe_inspect.mainleaked zero sentinel strings across JSON, Markdown, and stdout, and aggregated both named resource types intonamed_types: 2((named)).RT_VERSIONcases:RT_VERSIONleaf withdata_size = 0followed by a validRT_VERSIONleaf: recorded the0 bytesproblem and continued parsing the second leaf cleanly.VarFileInfoTranslationwith odd byte counts (6and2bytes): safely ignored trailing incomplete bytes (['040904b0'],[]).VS_VERSIONINFOwithwValueLength = 0(omittedVS_FIXEDFILEINFO):fixed: None, no spurious problem, parsed tables/translations and printed"no fixed info"summary._version_info, string values slicedata[s["value"]:s["end"]]rather thans["value"]:s["value_end"]and split at the first\0. That sensibly tolerates builders with miscountedwValueLengthwhen a NUL terminator is present, though on a synthetic string without\0before trailing block padding/slack bytes (e.g.,wValueLength = 0with non-zero slack orwValueLength = 3without NUL), those trailing bytes insidewLengthget included inchars/sha256. Worth keeping as-is if real binaries rely on NUL termination, or clamping bywValueLengthonly when non-zero if strict header lengths are desired.AI-assisted: yes
@aslan2142 on GitHub · 2026-11-24 19:30 UTC · original
Thanks for the review and the probes.
_version_infoslice: reading a string tos["end"]and stopping at the first NUL is on purpose. AStringblock'swValueLengthisn't reliable across resource compilers (some count characters with the NUL, some count bytes, some write 0), so clamping tovalue_endwould cut real values short or read past them depending on the builder.chars/sha256for that malformed value. No text is written either way. I'd keep it as is unless a real file shows otherwise.stdlib-tests-linux/macos-pythonchecks aretest_tool_stdout_encodingontools/exe_sha.pyandtools/pr_conflict_label.py, which this PR doesn't touch.mainhas those guards now (#605).AI-assisted (Claude Code, Claude Opus 5.5).
@aslan2142 on GitHub · 2026-11-25 22:20 UTC · original
Merged:
pe_inspectreads the resource directory and the RT_VERSION block without its strings.mainand with #653. On the_version_infoslice from review: reading to the block end and stopping at the first NUL is on purpose, becausewValueLengthdiffers between resource compilers. A string with no NUL is malformed, and no text is written either way.tests/test_pe_inspect.pypasses onmain+ #653 + this head (Linux, CPython 3.14).mainb4ae8916e+b8951357f: the semantic suite passes (492 files, 6,315 tests, 0 files failed);test_pe_inspectpass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 3 changed files.AI-assisted (Claude Code, Claude Opus 5.5).