kernelx: implement GetModuleFileNameEx and GetModuleBaseName for mapped images #1183

Open
github-bot wants to merge 1 commit from github-bot/gh-1183 into main AGit
Owner

@⁠Ivankiosan on GitHub · 2026-11-24 12:56 UTC · original
Ivankiosan:kernelx-module-filename-and-basename → main · +228 −1 · 2 files · 1 commits · open

Implements GetModuleFileNameExW, GetModuleFileNameExA, K32GetModuleFileNameExW, K32GetModuleFileNameExA, GetModuleBaseNameW, GetModuleBaseNameA, K32GetModuleBaseNameW, and K32GetModuleBaseNameA in kernelx so titles, crash reporters, profilers, and diagnostics querying XCL-mapped executables and DLLs get their real file paths and base names rather than failing with ERROR_INVALID_HANDLE from Windows' native PEB module list.

What is in it

  • Implements GetModuleFileNameExW, GetModuleFileNameExA, K32GetModuleFileNameExW, K32GetModuleFileNameExA, GetModuleBaseNameW, GetModuleBaseNameA, K32GetModuleBaseNameW, and K32GetModuleBaseNameA in crates/xcl/src/hle/kernelx.rs for XCL's manually-mapped images (the title executable and console/runtime DLLs).
  • Routes psapi.dll through kernelx with fallback to native psapi.dll in crates/xcl/src/hle/mod.rs.
  • When called on the current process (process == GetCurrentProcess() or GetProcessId(process) == GetCurrentProcessId()):
    • Resolves hModule == 0 (or m.base) to the title executable or mapped image path/basename instead of failing under Windows' native PEB loader list.
    • Rejects null destination buffer or zero capacity with ERROR_INVALID_PARAMETER and returns 0.
    • Forwards native modules (such as kernel32.dll or ntdll.dll) and cross-process queries to the native psapi/kernel32 APIs.
  • Adds comprehensive unit test hle::kernelx::tests::get_module_file_name_ex_and_base_name_answer_for_mapped_images covering wide and ANSI variants, current process pseudo-handle and real OpenProcess handle, null/zero-capacity validation, and native module fallback.

Tested

  • Hardware/OS: AMD Radeon RX 7600 (driver 32.0.12028.1005), Windows 11, rustc 1.99.1 (58cf8f9c3 2026-10-13) / MSVC 14.51.
  • cargo test --workspace -- --test-threads=4: all 699 unit tests passed, all integration tests passed, 0 failures across the workspace.
  • Unit test: cargo test -p xcl --lib get_module_file_name_ex_and_base_name_answer_for_mapped_images: 1 passed, 0 failed.
  • Built release binary target/release/xcl.exe (cargo build --release -p xcl).

Regression run

main:
text xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 7600 title: 419239bf seconds: 10 exit: 0x0 frames shown: 26 (PresentX 26) presents per 2 s (last 3): 0 0 23 device removals: 0 crashes: 0 peak commit: 8172 MB

PR head:
text xcl-smoke v1 commit: a72a430471aecaae37bdb710d08986f701756d78 gpu: AMD Radeon RX 7600 title: 419239bf seconds: 10 exit: 0x0 frames shown: 26 (PresentX 26) presents per 2 s (last 3): 0 0 23 device removals: 0 crashes: 0 peak commit: 8366 MB

Not tested

  • Cross-process module inspection from an external process querying XCL.
  • Linux / Wine / Proton environment (smoke run and unit tests executed on native Windows 11).

AI use

  • Google Antigravity (Gemini): audited module resolution in kernelx.rs and mod.rs, implemented the GetModuleFileNameEx and GetModuleBaseName functions and unit tests, verified workspace tests and executed the local GPU smoke regression.
**@⁠Ivankiosan** on GitHub · 2026-11-24 12:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1183) `Ivankiosan:kernelx-module-filename-and-basename` → `main` · +228 −1 · 2 files · 1 commits · open Implements `GetModuleFileNameExW`, `GetModuleFileNameExA`, `K32GetModuleFileNameExW`, `K32GetModuleFileNameExA`, `GetModuleBaseNameW`, `GetModuleBaseNameA`, `K32GetModuleBaseNameW`, and `K32GetModuleBaseNameA` in `kernelx` so titles, crash reporters, profilers, and diagnostics querying XCL-mapped executables and DLLs get their real file paths and base names rather than failing with `ERROR_INVALID_HANDLE` from Windows' native PEB module list. **What is in it** - Implements `GetModuleFileNameExW`, `GetModuleFileNameExA`, `K32GetModuleFileNameExW`, `K32GetModuleFileNameExA`, `GetModuleBaseNameW`, `GetModuleBaseNameA`, `K32GetModuleBaseNameW`, and `K32GetModuleBaseNameA` in `crates/xcl/src/hle/kernelx.rs` for XCL's manually-mapped images (the title executable and console/runtime DLLs). - Routes `psapi.dll` through `kernelx` with fallback to native `psapi.dll` in `crates/xcl/src/hle/mod.rs`. - When called on the current process (`process == GetCurrentProcess()` or `GetProcessId(process) == GetCurrentProcessId()`): - Resolves `hModule == 0` (or `m.base`) to the title executable or mapped image path/basename instead of failing under Windows' native PEB loader list. - Rejects null destination buffer or zero capacity with `ERROR_INVALID_PARAMETER` and returns `0`. - Forwards native modules (such as `kernel32.dll` or `ntdll.dll`) and cross-process queries to the native `psapi`/`kernel32` APIs. - Adds comprehensive unit test `hle::kernelx::tests::get_module_file_name_ex_and_base_name_answer_for_mapped_images` covering wide and ANSI variants, current process pseudo-handle and real OpenProcess handle, null/zero-capacity validation, and native module fallback. **Tested** - Hardware/OS: AMD Radeon RX 7600 (driver 32.0.12028.1005), Windows 11, `rustc 1.99.1 (58cf8f9c3 2026-10-13)` / MSVC 14.51. - `cargo test --workspace -- --test-threads=4`: all 699 unit tests passed, all integration tests passed, 0 failures across the workspace. - Unit test: `cargo test -p xcl --lib get_module_file_name_ex_and_base_name_answer_for_mapped_images`: 1 passed, 0 failed. - Built release binary `target/release/xcl.exe` (`cargo build --release -p xcl`). **Regression run** main: ``text xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 7600 title: 419239bf seconds: 10 exit: 0x0 frames shown: 26 (PresentX 26) presents per 2 s (last 3): 0 0 23 device removals: 0 crashes: 0 peak commit: 8172 MB `` PR head: ``text xcl-smoke v1 commit: a72a430471aecaae37bdb710d08986f701756d78 gpu: AMD Radeon RX 7600 title: 419239bf seconds: 10 exit: 0x0 frames shown: 26 (PresentX 26) presents per 2 s (last 3): 0 0 23 device removals: 0 crashes: 0 peak commit: 8366 MB `` **Not tested** - Cross-process module inspection from an external process querying XCL. - Linux / Wine / Proton environment (smoke run and unit tests executed on native Windows 11). **AI use** - Google Antigravity (Gemini): audited module resolution in `kernelx.rs` and `mod.rs`, implemented the `GetModuleFileNameEx` and `GetModuleBaseName` functions and unit tests, verified workspace tests and executed the local GPU smoke regression.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:46:19 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:13 UTC · original

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug.

  • cargo test -p xcl --lib module_file: 1 passed, 0 failed — get_module_file_name_ex_and_base_name_answer_for_mapped_images covers the new GetModuleFileNameEx/GetModuleBaseName implementation; cargo test -p xcl --lib module: 6 passed overall.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

**@⁠DavidM1911** on GitHub · 2026-11-24 13:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1183#issuecomment-7132528282) Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug. - `cargo test -p xcl --lib module_file`: **1 passed, 0 failed** — `get_module_file_name_ex_and_base_name_answer_for_mapped_images` covers the new GetModuleFileNameEx/GetModuleBaseName implementation; `cargo test -p xcl --lib module`: 6 passed overall. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-24 14:34 UTC · original

A run on Linux under Wine.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. a72a430 as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact). GetModuleFileNameEx / GetModuleBaseName for host modules come from Wine here.
  • hle::kernelx::tests::get_module_file_name_ex_and_base_name_answer_for_mapped_images: ok, no SKIPPED.

Not tested

  • whether the new tests fail without the change on this stack; the rest of the suite on this head; a retail title; native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
**@⁠JoaoPauluu** on GitHub · 2026-11-24 14:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1183#issuecomment-7134609404) A run on Linux under Wine. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `a72a430` as it is (based on `47efa2e`), no uncommitted changes. The lib test binary runs under Wine, one test per process (`--exact`). `GetModuleFileNameEx` / `GetModuleBaseName` for host modules come from Wine here. - `hle::kernelx::tests::get_module_file_name_ex_and_base_name_answer_for_mapped_images`: **ok**, no SKIPPED. **Not tested** - whether the new tests fail without the change on this stack; the rest of the suite on this head; a retail title; native Windows. **AI use** - Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/kernelx.rs
  • crates/xcl/src/hle/mod.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1183/head:github-bot/gh-1183'
git switch 'github-bot/gh-1183'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1183'
git switch 'github-bot/gh-1183'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1183'
git switch 'github-bot/gh-1183'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1183'
git switch 'main'
git merge --squash 'github-bot/gh-1183'
git switch 'main'
git merge --ff-only 'github-bot/gh-1183'
git switch 'main'
git merge 'github-bot/gh-1183'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.