pe_inventory: name import providers as the loader looks them up #227

Merged
Vonsek merged 1 commit from upstream-pr/230 into main 2026-11-21 19:12:04 +00:00
Vonsek commented 2026-11-21 18:49:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T18:49:25Z.


Change

An import descriptor can name a DLL without an extension (intake_forward) or with a trailing dot (intake_forward.). The loader treats these names as LoadLibrary does: a name without an extension gets .dll appended, and a trailing dot suppresses the append and is not part of the file name. pe_inventory.py used the stored name as is, so an import of intake_forward did not match the package's intake_forward.dll and was reported as provider_not_found with no package resolution.

  • tools/pe_inventory.py: module_name() returns the file name the loader looks for. import_tables() uses it for normal and delay descriptors. Names that already carry an extension are unchanged apart from the existing lower-casing.
  • tests/intake/forwarders_check.py: bundled_export_forwarders rewrites the caller's intake_forward.dll descriptor name in place (same length, zero padded) to INTAKE_FORWARD and to intake_forward.. The first must give the same rows, bundle matches and forwarder chains as the original. The second must name intake_forward and find no provider, since the package holds no file of that name.
  • docs/experiments.md: the inventory section describes the rule.

Verification

  • Linux stand-in: fixtures built from source with clang --target=x86_64-pc-windows-msvc and lld-link, forwarders_check.check() run with pefile and the Windows-only calls replaced. Without the pe_inventory.py change the new check fails (AssertionError: {'intake_forward'}: the extension-less descriptor produces a separate, unresolved intake_forward provider). With it the test passes. tests/intake/paths_check.py and tests/dependency_paths_check.py still pass.
  • Windows: ctest --preset dev --no-tests=error -R 'static_exe_intake|bundled_export_forwarders|conditional_import_paths|dependency_paths_controls' -V at 6fb2404 on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12: 4/4 passed. The full ctest --preset dev --no-tests=error passed 114/114, with bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp skipped.
  • Windows loader, measured on the same machine: the import descriptor name of a copy of the source-built cpu_import_original.dll (no entry point) was rewritten in place, zero padded, and the copy was loaded with LoadLibraryExW(..., LOAD_WITH_ALTERED_SEARCH_PATH) from a folder that also holds cpu_import_provider.dll, one child process per case:
    Descriptor name Result
    cpu_import_provider.dll (as built) loads; IAT slot holds mix_args from cpu_import_provider.dll
    cpu_import_provider loads; the module is reported as cpu_import_provider.DLL and the slot holds mix_args
    CPU_IMPORT_PROVIDER loads; reported as CPU_IMPORT_PROVIDER.DLL, slot holds mix_args
    cpu_import_provider. fails with error 126 (module not found)

Evidence and follow-up

  • The extension rule is documented for LoadLibraryW. The measurement above shows the Windows 11 loader applies it to static imports: an extension-less name gets .DLL appended and binds, and a trailing dot suppresses the append, so no file is found. The inventory test itself reads the images and never loads them.
  • Forwarder strings (module.symbol) already always get .dll appended and are unchanged here. Forwarded export resolution is the subject of #208.
  • pe_map passes the stored descriptor name to the host resolver; whether resolvers should see the normalized name is left open.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532960201 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/230). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T18:49:25Z. --- ## Change An import descriptor can name a DLL without an extension (`intake_forward`) or with a trailing dot (`intake_forward.`). The loader treats these names as `LoadLibrary` does: a name without an extension gets `.dll` appended, and a trailing dot suppresses the append and is not part of the file name. `pe_inventory.py` used the stored name as is, so an import of `intake_forward` did not match the package's `intake_forward.dll` and was reported as `provider_not_found` with no package resolution. - `tools/pe_inventory.py`: `module_name()` returns the file name the loader looks for. `import_tables()` uses it for normal and delay descriptors. Names that already carry an extension are unchanged apart from the existing lower-casing. - `tests/intake/forwarders_check.py`: `bundled_export_forwarders` rewrites the caller's `intake_forward.dll` descriptor name in place (same length, zero padded) to `INTAKE_FORWARD` and to `intake_forward.`. The first must give the same rows, bundle matches and forwarder chains as the original. The second must name `intake_forward` and find no provider, since the package holds no file of that name. - `docs/experiments.md`: the inventory section describes the rule. ## Verification - Linux stand-in: fixtures built from source with clang `--target=x86_64-pc-windows-msvc` and lld-link, `forwarders_check.check()` run with pefile and the Windows-only calls replaced. Without the `pe_inventory.py` change the new check fails (`AssertionError: {'intake_forward'}`: the extension-less descriptor produces a separate, unresolved `intake_forward` provider). With it the test passes. `tests/intake/paths_check.py` and `tests/dependency_paths_check.py` still pass. - Windows: `ctest --preset dev --no-tests=error -R 'static_exe_intake|bundled_export_forwarders|conditional_import_paths|dependency_paths_controls' -V` at 6fb2404 on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12: 4/4 passed. The full `ctest --preset dev --no-tests=error` passed 114/114, with `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp` skipped. - Windows loader, measured on the same machine: the import descriptor name of a copy of the source-built `cpu_import_original.dll` (no entry point) was rewritten in place, zero padded, and the copy was loaded with `LoadLibraryExW(..., LOAD_WITH_ALTERED_SEARCH_PATH)` from a folder that also holds `cpu_import_provider.dll`, one child process per case: | Descriptor name | Result | |---|---| | `cpu_import_provider.dll` (as built) | loads; IAT slot holds `mix_args` from `cpu_import_provider.dll` | | `cpu_import_provider` | loads; the module is reported as `cpu_import_provider.DLL` and the slot holds `mix_args` | | `CPU_IMPORT_PROVIDER` | loads; reported as `CPU_IMPORT_PROVIDER.DLL`, slot holds `mix_args` | | `cpu_import_provider.` | fails with error 126 (module not found) | ## Evidence and follow-up - The extension rule is documented for [`LoadLibraryW`](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryw). The measurement above shows the Windows 11 loader applies it to static imports: an extension-less name gets `.DLL` appended and binds, and a trailing dot suppresses the append, so no file is found. The inventory test itself reads the images and never loads them. - Forwarder strings (`module.symbol`) already always get `.dll` appended and are unchanged here. Forwarded export resolution is the subject of #208. - `pe_map` passes the stored descriptor name to the host resolver; whether resolvers should see the normalized name is left open.
upstream-sync closed this pull request 2026-11-24 06:41:55 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T18:51:50Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T18:55:14.608716Z 6fb2404 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067568977 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/230#issuecomment-7067568977). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T18:51:50Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6fb240413162193f7bcb91011a6ad71ebd180230","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T18:55:14.608716Z">2026-11-21T18:55:14.608716Z</relative-time> | `6fb2404` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
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!227
No description provided.