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

Merged
Joacoorandom merged 3 commits from upstream-pr/961 into main 2026-11-23 19:26:27 +00:00
Joacoorandom commented 2026-11-23 18:49:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-23T18:49:11Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6566452521 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/961). Originally posted by [Joacoorandom](https://github.com/Joacoorandom) on 2026-11-23T18:49:11Z. --- ## 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`.
upstream-sync closed this pull request 2026-11-24 06:45:36 +00:00
R0Y00 commented 2026-11-24 06:49:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:11:37Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7111227203 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/961#issuecomment-7111227203). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T19:11:37Z. --- 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.
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!954
No description provided.