pe: bind bundled ordinal-only imports during EXE startup #961

Manually merged
github merged 3 commits from gh-pr/961/head into gh-pr/961/base 2026-11-26 22:31:28 +00:00
Owner

@⁠Joacoorandom on GitHub · 2026-11-23 18:49 UTC · original
Joacoorandom:pe/package-ordinal-startup → main · +310 −4 · 12 files · 3 commits · merged 2026-11-23 19:26 UTC

Change

Extend pe_map and pe_run_package.py to bind bundled DLL imports by ordinal, including NONAME exports, during a source-built EXE startup. The offline preflight already classifies ordinal imports such as dll!#77 correctly, but the package runner previously refused them before mapping. This closes that specific import-binding gap without changing the runtime ABI or claiming title execution.

  • Export pe_map_export_ordinal(mapped, ordinal) and use the mapped image's export address table (not its name/ordinal-name tables). Validate the public ordinal range 1..65535, export bounds, live readable pages and nonempty final address; refuse forwarded/empty entries and invalid pointers.
  • Resolve #ordinal symbols in pe_run_package.py after its existing static package-forwarder resolution. A chain that ends at an ordinal is served from its actual terminal mapped DLL. An unresolved mapped export fails before starting the EXE.
  • Add an explicitly CRT-free, source-built EXE importing #77 from a source-built DLL exporting mix_args @77 NONAME, plus altered/mismatched-export providers. The Windows test compares ordinary process startup with pe_run_package, validates the PE import/export tables, calls the mapped ordinal export directly, and checks that missing/wrong providers are refused before the guest entry.
  • Include a cross-platform planning suite and register both suites with CTest and the Linux Python job.

Refs #870, #165. Independent of the TLS slot-0, DirectStorage and runtime provider slices currently in progress.

Tests

On Linux/Python 3.14, based on 0f0c3eb:

python -B tests/pe_package_ordinal_plan_check.py -v
python -B tests/pe_package_preflight_check.py
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: 3/3 new planning tests passed, 8/8 preflight tests passed; existing dependency/import path controls passed; 13 Markdown files / 192 links passed; 791 tracked files passed the bidi scan. No compiler or Windows runner was available on the local Linux host, so the new native-vs-mapped EXE test has not yet been executed locally.

Windows CI is expected to compile and exercise this specific test:

ctest --preset dev --no-tests=error -R '^cpu_native_package_ordinal_startup$' -V
ctest --preset release --no-tests=error -R '^cpu_native_package_ordinal_startup$' -V

Expected: native and mapped startup return 13 for the normal ordinal-only provider and 14 for the altered implementation; wrong #78 and missing-DLL controls fail before mapped entry; direct mapped #77 returns the correct output while six invalid ordinals fail. These Windows expectations are not represented as observed results until CI completes.

Scope

Only static package-internal ordinal binding; the mapper cannot resolve a forwarder on its own, so it refuses forwarded entries. The package planner must resolve the terminal module beforehand. This does not implement console APIs, main-image TLS slot 0, dynamic imports, or a retail executable run. No game files, executable binaries, dumps, archives, secrets or private traces are committed.

AI-assisted implementation and tests. Commit cbe4fcb.

**@⁠Joacoorandom** on GitHub · 2026-11-23 18:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/961) `Joacoorandom:pe/package-ordinal-startup` → `main` · +310 −4 · 12 files · 3 commits · merged 2026-11-23 19:26 UTC ## Change Extend `pe_map` and `pe_run_package.py` to **bind bundled DLL imports by ordinal**, including `NONAME` exports, during a source-built EXE startup. The offline preflight already classifies ordinal imports such as `dll!#77` correctly, but the package runner previously refused them before mapping. This closes that specific import-binding gap without changing the runtime ABI or claiming title execution. - Export `pe_map_export_ordinal(mapped, ordinal)` and use the mapped image's export **address** table (not its name/ordinal-name tables). Validate the public ordinal range 1..65535, export bounds, live readable pages and nonempty final address; refuse forwarded/empty entries and invalid pointers. - Resolve `#ordinal` symbols in `pe_run_package.py` after its existing static package-forwarder resolution. A chain that ends at an ordinal is served from its actual terminal mapped DLL. An unresolved mapped export fails before starting the EXE. - Add an explicitly CRT-free, source-built EXE importing `#77` from a source-built DLL exporting `mix_args @77 NONAME`, plus altered/mismatched-export providers. The Windows test compares ordinary process startup with `pe_run_package`, validates the PE import/export tables, calls the mapped ordinal export directly, and checks that missing/wrong providers are refused before the guest entry. - Include a cross-platform planning suite and register both suites with CTest and the Linux Python job. Refs #870, #165. Independent of the TLS slot-0, DirectStorage and runtime provider slices currently in progress. ## Tests On Linux/Python 3.14, based on `0f0c3eb`: ```sh python -B tests/pe_package_ordinal_plan_check.py -v python -B tests/pe_package_preflight_check.py 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:** 3/3 new planning tests passed, 8/8 preflight tests passed; existing dependency/import path controls passed; 13 Markdown files / 192 links passed; 791 tracked files passed the bidi scan. No compiler or Windows runner was available on the local Linux host, so **the new native-vs-mapped EXE test has not yet been executed locally**. Windows CI is expected to compile and exercise this specific test: ```powershell ctest --preset dev --no-tests=error -R '^cpu_native_package_ordinal_startup$' -V ctest --preset release --no-tests=error -R '^cpu_native_package_ordinal_startup$' -V ``` **Expected:** native and mapped startup return 13 for the normal ordinal-only provider and 14 for the altered implementation; wrong `#78` and missing-DLL controls fail before mapped entry; direct mapped `#77` returns the correct output while six invalid ordinals fail. These Windows expectations are not represented as observed results until CI completes. ## Scope Only static **package-internal** ordinal binding; the mapper cannot resolve a forwarder on its own, so it refuses forwarded entries. The package planner must resolve the terminal module beforehand. This does not implement console APIs, main-image TLS slot 0, dynamic imports, or a retail executable run. No game files, executable binaries, dumps, archives, secrets or private traces are committed. AI-assisted implementation and tests. Commit `cbe4fcb`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:31:26 +00:00
github manually merged commit 1c9667eb2a into gh-pr/961/base 2026-11-26 22:31:28 +00:00
Author
Owner

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

I independently ran the source-built ordinal fixture. The normal and altered providers returned 13 and 14 in Windows and pe_map, and the wrong ordinal and missing DLL were refused. With your Debug compile fix included, the ordinal startup and planning tests passed in Debug. The compatibility update also passed the four targeted Release CTests with #950 integrated, and I verified that a pre-change mapper still runs a name-only package and gives a clear diagnostic for an ordinal package. The C export documents the live-mapping precondition and returns null for a null mapping.

**@⁠R0Y00** on GitHub · 2026-11-23 19:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/961#issuecomment-7111227203) I independently ran the source-built ordinal fixture. The normal and altered providers returned 13 and 14 in Windows and pe_map, and the wrong ordinal and missing DLL were refused. With your Debug compile fix included, the ordinal startup and planning tests passed in Debug. The compatibility update also passed the four targeted Release CTests with #950 integrated, and I verified that a pre-change mapper still runs a name-only package and gives a clear diagnostic for an ordinal package. The C export documents the live-mapping precondition and returns null for a null mapping.
This discussion has been locked. Commenting is limited to contributors.
No description provided.