Loader: under Wine, PEB.ImageBaseAddress keeps the real main image #93

Manually merged
github merged 1 commit from gh-pr/93/head into gh-pr/93/base 2026-11-26 04:09:38 +00:00
Owner

@⁠ozimchuk on GitHub · 2026-11-23 10:42 UTC · original
ozimchuk:wine-keep-image-base → main · +7 −1 · 1 files · 1 commits · merged 2026-11-23 11:02 UTC

run_main writes the title's base into PEB.ImageBaseAddress so that GetModuleHandle(NULL) answers the title. Wine's loader looks that address up in its own module list whenever a thread starts (loader_init: get_modref(Peb->ImageBaseAddress)) and uses the result unchecked. A manually mapped image is not in that list, so the title's first thread dies in ntdll with an access violation (a read at address 0x6e).

Under Wine (ntdll exports wine_get_version) the field is now left alone, and a log line says so. Nothing changes on Windows.

Known cost under Wine: GetModuleHandle(NULL) answers xcl.exe there, not the title. The test title's check for it passes here; a title that reads resources from its own image through a NULL module may need more.

Validation

Linux, Wine with vkd3d-proton, GNU toolchain build, main at 1f82be3:

build test title (xcl run <testgame> -- --hello)
main + the other Wine fix (#92) only access violation in ntdll when the title's first thread starts, 0 checks run
main + this change + #92 47 [PASS], 2 [FAIL] on an AMD iGPU (RADV) and on an RTX 5060 Ti

The two failing checks are not about this change (xmem working-set statistics; the console window "not cloaked" under Wine). The run needs a locally patched vkd3d-proton for reasons that have nothing to do with this change either (it asserts on objects whose vtable XCL replaced); that is a separate topic. Not run on Windows.

AI-assisted.

🤖 Generated with Claude Code

**@⁠ozimchuk** on GitHub · 2026-11-23 10:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/93) `ozimchuk:wine-keep-image-base` → `main` · +7 −1 · 1 files · 1 commits · merged 2026-11-23 11:02 UTC `run_main` writes the title's base into `PEB.ImageBaseAddress` so that `GetModuleHandle(NULL)` answers the title. Wine's loader looks that address up in its own module list whenever a thread starts (`loader_init`: `get_modref(Peb->ImageBaseAddress)`) and uses the result unchecked. A manually mapped image is not in that list, so the title's first thread dies in ntdll with an access violation (a read at address `0x6e`). Under Wine (ntdll exports `wine_get_version`) the field is now left alone, and a log line says so. Nothing changes on Windows. **Known cost under Wine:** `GetModuleHandle(NULL)` answers `xcl.exe` there, not the title. The test title's check for it passes here; a title that reads resources from its own image through a NULL module may need more. ## Validation Linux, Wine with vkd3d-proton, GNU toolchain build, `main` at `1f82be3`: | build | test title (`xcl run <testgame> -- --hello`) | |---|---| | `main` + the other Wine fix (#92) only | access violation in ntdll when the title's first thread starts, 0 checks run | | `main` + this change + #92 | 47 `[PASS]`, 2 `[FAIL]` on an AMD iGPU (RADV) and on an RTX 5060 Ti | The two failing checks are not about this change (`xmem` working-set statistics; the console window "not cloaked" under Wine). The run needs a locally patched vkd3d-proton for reasons that have nothing to do with this change either (it asserts on objects whose vtable XCL replaced); that is a separate topic. Not run on Windows. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
run_main writes the title's base into PEB.ImageBaseAddress so that
GetModuleHandle(NULL) answers the title. Wine's loader looks that address
up in its own module list whenever a thread starts (loader_init:
get_modref(Peb->ImageBaseAddress)) and uses the result unchecked. A
manually mapped image is not in that list, so the title's first thread
died in ntdll with an access violation at address 0x6e.

Under Wine (ntdll exports wine_get_version) the field is now left alone
and a log line says so. GetModuleHandle(NULL) then answers xcl.exe there,
not the title. Nothing changes on Windows.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:09:35 +00:00
github manually merged commit 22d21f0519 into gh-pr/93/base 2026-11-26 04:09:38 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 11:03 UTC · original

Merged. On Windows nothing changes (wine_get_version is not exported), and the test title and games run as before. Noted the GetModuleHandle(NULL) cost under Wine in the log line. Checked on Windows 11 with an RX 9070 (RDNA4, MSVC build): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), natively and with XCL_SPLIT_WAVE64=1. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 11:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/93#issuecomment-7098953251) Merged. On Windows nothing changes (`wine_get_version` is not exported), and the test title and games run as before. Noted the `GetModuleHandle(NULL)` cost under Wine in the log line. Checked on Windows 11 with an RX 9070 (RDNA4, MSVC build): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), natively and with `XCL_SPLIT_WAVE64=1`. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.