pe: report offline package import closure #883

Merged
Joacoorandom merged 2 commits from upstream-pr/890 into main 2026-11-23 16:40:08 +00:00
Joacoorandom commented 2026-11-23 16:10:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-23T16:10:44Z.


Change

Add tools/pe_package_preflight.py, a read-only, cross-platform import-closure report for a directory of source-built PE images. Unlike the full pe_inventory.scan() desktop inventory, this diagnostic does not require an x64 Windows host, inspect System32, or load any EXE/DLL.

It reuses the existing strict PE parse_image() reader, export table handling and forwarded-export resolver to report:

  • Named/ordinal normal and delay imports fulfilled by packaged exports (including package-internal forwarder chains).
  • Bundled missing symbols, malformed/cyclic forwarders and ambiguous DLL basenames, without guessing a provider.
  • External DLL imports and forwarded external targets as unverified, rather than falsely labeling Windows-provided imports as missing.
  • Which packaged images are statically reachable from the chosen EXE, prioritizing normal-import paths over delay-import paths, and which package images are outside that graph.

The CLI refuses PE symlinks, entries outside the root, images over 512 MiB, and packages exceeding 1,024 PE images / 2 GiB of PE data. The JSON report contains no executable code and can be saved under out/.

Reproduction

On Linux with the existing requirements-dev.txt installed:

python -B tests/pe_package_preflight_check.py -v
python -B tests/dependency_paths_check.py
python -B tests/intake/paths_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff --check origin/main...HEAD

Observed locally on Python 3.14: all 6 new tests passed. Existing dependency-path and intake-path checks passed. Documentation: 13 Markdown files and 179 links passed; bidirectional-control scan: 718 tracked source/config files, no controls. A source-built x64 diagnostic executable (no bundled DLLs) produced a JSON report with 46 normal imports all classified external_unverified, zero local failures. This is an offline parsing smoke test, not an execution/compatibility result.

The new tests use only synthetic in-memory import/export metadata and temporary fake files. They check forwarded/ordinal resolution, malformed/cyclic forwarders, missing symbols, duplicate basenames, delay-import reachability, deterministic output, path escape/symlink rejection and clean CLI failure for a non-PE. The standalone tool and tests are registered in CMake/CTest and the existing Python Linux CI job.

Limits

Host DLL exports, Windows KnownDLLs, API-set remapping, runtime ABI compatibility, dynamic loads, TLS execution and full-program startup are not verified. The repository's Windows-only inventory remains the authoritative tool for desktop provider comparisons. No private binaries, archives, assets or distribution links are part of this change.

Checklist

  • One reviewable behavior, based on existing PE readers/resolver.
  • Exact commands and results included; negative controls exercised.
  • README, experiment documentation, CTest and Linux CI updated.
  • No game data, proprietary DLLs/EXEs, private logs or secrets.

AI-assisted implementation and tests. Commit: ddac8a7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6563521298 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/890). Originally posted by [Joacoorandom](https://github.com/Joacoorandom) on 2026-11-23T16:10:44Z. --- ## Change Add `tools/pe_package_preflight.py`, a **read-only, cross-platform** import-closure report for a directory of source-built PE images. Unlike the full `pe_inventory.scan()` desktop inventory, this diagnostic does not require an x64 Windows host, inspect System32, or load any EXE/DLL. It reuses the existing strict PE `parse_image()` reader, export table handling and forwarded-export resolver to report: - Named/ordinal normal and delay imports fulfilled by packaged exports (including package-internal forwarder chains). - Bundled missing symbols, malformed/cyclic forwarders and ambiguous DLL basenames, without guessing a provider. - External DLL imports and forwarded external targets as **unverified**, rather than falsely labeling Windows-provided imports as missing. - Which packaged images are statically reachable from the chosen EXE, prioritizing normal-import paths over delay-import paths, and which package images are outside that graph. The CLI refuses PE symlinks, entries outside the root, images over 512 MiB, and packages exceeding 1,024 PE images / 2 GiB of PE data. The JSON report contains no executable code and can be saved under `out/`. ## Reproduction On Linux with the existing `requirements-dev.txt` installed: ```sh python -B tests/pe_package_preflight_check.py -v python -B tests/dependency_paths_check.py python -B tests/intake/paths_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py git diff --check origin/main...HEAD ``` **Observed locally on Python 3.14:** all 6 new tests passed. Existing dependency-path and intake-path checks passed. Documentation: 13 Markdown files and 179 links passed; bidirectional-control scan: 718 tracked source/config files, no controls. A source-built x64 diagnostic executable (no bundled DLLs) produced a JSON report with 46 normal imports all classified `external_unverified`, zero local failures. This is an offline parsing smoke test, **not** an execution/compatibility result. The new tests use only synthetic in-memory import/export metadata and temporary fake files. They check forwarded/ordinal resolution, malformed/cyclic forwarders, missing symbols, duplicate basenames, delay-import reachability, deterministic output, path escape/symlink rejection and clean CLI failure for a non-PE. The standalone tool and tests are registered in CMake/CTest and the existing Python Linux CI job. ## Limits Host DLL exports, Windows KnownDLLs, API-set remapping, runtime ABI compatibility, dynamic loads, TLS execution and full-program startup are **not** verified. The repository's Windows-only inventory remains the authoritative tool for desktop provider comparisons. No private binaries, archives, assets or distribution links are part of this change. ## Checklist - [x] One reviewable behavior, based on existing PE readers/resolver. - [x] Exact commands and results included; negative controls exercised. - [x] README, experiment documentation, CTest and Linux CI updated. - [x] No game data, proprietary DLLs/EXEs, private logs or secrets. AI-assisted implementation and tests. Commit: `ddac8a7`.
upstream-sync closed this pull request 2026-11-24 06:45:16 +00:00
R0Y00 commented 2026-11-24 06:49:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:26:59Z.


Review update at 320474d. A report path outside the package could still overwrite an inspected PE if both paths were hard links to the same file. The report now replaces the output path, and the regression compares the input bytes after writing. Reachability paths also keep intermediate forwarded providers, with a check that a longer ordinary forwarder path beats a direct delay path. All 8 preflight checks passed on Windows and Linux. CI is rerunning.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107150620 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/890#issuecomment-7107150620). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T16:26:59Z. --- Review update at `320474d`. A report path outside the package could still overwrite an inspected PE if both paths were hard links to the same file. The report now replaces the output path, and the regression compares the input bytes after writing. Reachability paths also keep intermediate forwarded providers, with a check that a longer ordinary forwarder path beats a direct delay path. All 8 preflight checks passed on Windows and Linux. CI is rerunning.
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
R0Y00/Xbox2Windows!883
No description provided.