pe: report offline package import closure #890

Manually merged
github merged 2 commits from gh-pr/890/head into gh-pr/890/base 2026-11-26 22:26:07 +00:00
Owner

@⁠Joacoorandom on GitHub · 2026-11-23 16:10 UTC · original
Joacoorandom:pe/offline-package-import-closure → main · +387 −0 · 7 files · 2 commits · merged 2026-11-23 16:40 UTC

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.

**@⁠Joacoorandom** on GitHub · 2026-11-23 16:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/890) `Joacoorandom:pe/offline-package-import-closure` → `main` · +387 −0 · 7 files · 2 commits · merged 2026-11-23 16:40 UTC ## 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`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:26:05 +00:00
github manually merged commit 320474dfbb into gh-pr/890/base 2026-11-26 22:26:07 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 16:26 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-23 16:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/890#issuecomment-7107150620) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.