Scripts: retain every name for a PE export ordinal #1075

Merged
anakatt merged 1 commit from upstream-pr/1084 into main 2026-11-24 15:52:00 +00:00
anakatt commented 2026-11-24 11:24:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by anakatt on 2026-11-24T11:24:46Z.


I fixed scripts/re/pe_exports.py dropping export aliases. Multiple names can refer to one ordinal, but the script overwrote each earlier name and printed only the last one. It now prints all names for that ordinal in table order.

What is in it

  • Preserve export-name lists instead of overwriting names by ordinal.
  • Add synthetic PE32 and PE32+ CLI regression cases, also checking ordinal-only exports and forwarders. No game files are included.

Tested

  • macOS Darwin 24.6.0, arm64; Python 3.15.2. No GPU used.

  • python3 -B -m unittest discover -s scripts -p test_pe_exports.py -v: both PE variants failed before the fix because Alpha was missing; afterward 1 test passed, 0 failed, 0 skipped (two format subcases).

  • Windows 11 Pro ARM64 10.0.26100.1742 in UTM, Python 3.14.0 ARM64; no GPU used. Exact source archive 3b6e9eafb732c55b1921508d9db76f70111a2569: C:\xcl-tests\python\python.exe -B -m unittest discover -s scripts -p test_pe_exports.py -v: 1 passed, 0 failed, 0 skipped (two subcases).

Not tested

  • real game DLLs, and the Rust/GPU suite. This changes only a Python analysis script and its regression test.

AI use

  • I used omp (openai-codex/gpt-6-astra) to investigate the bug, write the fix and synthetic regression, run the Python test, and prepare this description.
<!-- greyfinch-sync:ivall/xcl:issue:6580689369 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1084). Originally posted by [anakatt](https://github.com/anakatt) on 2026-11-24T11:24:46Z. --- I fixed `scripts/re/pe_exports.py` dropping export aliases. Multiple names can refer to one ordinal, but the script overwrote each earlier name and printed only the last one. It now prints all names for that ordinal in table order. **What is in it** - Preserve export-name lists instead of overwriting names by ordinal. - Add synthetic PE32 and PE32+ CLI regression cases, also checking ordinal-only exports and forwarders. No game files are included. **Tested** - macOS Darwin 24.6.0, arm64; Python 3.15.2. No GPU used. - `python3 -B -m unittest discover -s scripts -p test_pe_exports.py -v`: both PE variants failed before the fix because `Alpha` was missing; afterward 1 test passed, 0 failed, 0 skipped (two format subcases). - Windows 11 Pro ARM64 10.0.26100.1742 in UTM, Python 3.14.0 ARM64; no GPU used. Exact source archive `3b6e9eafb732c55b1921508d9db76f70111a2569`: `C:\xcl-tests\python\python.exe -B -m unittest discover -s scripts -p test_pe_exports.py -v`: 1 passed, 0 failed, 0 skipped (two subcases). **Not tested** - real game DLLs, and the Rust/GPU suite. This changes only a Python analysis script and its regression test. **AI use** - I used omp (`openai-codex/gpt-6-astra`) to investigate the bug, write the fix and synthetic regression, run the Python test, and prepare this description.
futurepro62 commented 2026-11-24 15:05:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:15:25Z.


Tested exact head 3b6e9ea, script tests only, since this PR has no test report yet.

Tested

  • Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here).
  • python -m pytest scripts/test_pe_exports.py at the head: 1 passed, 2 subtests passed.
  • The PR's test file(s) against current main's script (930e8b4): fails for both subtests (magic=0x10b, magic=0x20b) of test_all_names_for_an_ordinal_are_printed. So the new test catches the problem the PR fixes.
  • Same fix as #1095 (opened six minutes later): both change names[o] = cstr(nr) to names.setdefault(o, []).append(cstr(nr)) and join the names. The two PRs conflict (git merge-tree of the two heads reports a conflict), so only one can land.

Not tested

  • PowerShell 7, the CI workflow itself, a game (no runtime code changed).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7134083392 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1084#issuecomment-7134083392). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:15:25Z. --- Tested exact head `3b6e9ea`, script tests only, since this PR has no test report yet. **Tested** - Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here). - `python -m pytest scripts/test_pe_exports.py` at the head: 1 passed, 2 subtests passed. - The PR's test file(s) against current main's script (`930e8b4`): fails for both subtests (`magic=0x10b`, `magic=0x20b`) of `test_all_names_for_an_ordinal_are_printed`. So the new test catches the problem the PR fixes. - Same fix as #1095 (opened six minutes later): both change `names[o] = cstr(nr)` to `names.setdefault(o, []).append(cstr(nr))` and join the names. The two PRs conflict (`git merge-tree` of the two heads reports a conflict), so only one can land. **Not tested** - PowerShell 7, the CI workflow itself, a game (no runtime code changed). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
upstream-sync closed this pull request 2026-11-24 16:05:53 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1075
No description provided.