Skip to content

Wine memory helper: run inside a Proton or Flatpak container - #14

Merged
wleeaf merged 1 commit into
mainfrom
wine-helper-in-containers
Nov 20, 2026
Merged

wleeaf merged 1 commit into
mainfrom
wine-helper-in-containers

Conversation

@wleeaf

@wleeaf wleeaf commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Fixes #9 for games in a Proton (Steam Runtime) or Flatpak container.

When Wine reserves the space a hook needs, Cheat Engine asks Wine for the block through a small generated Windows program. Until now that program was refused for a target in another mount namespace, because it could not reach the container's Wine, prefix and wineserver.

What changes

  • The helper joins the target's namespaces before starting Wine. The user namespace goes first, because its owner may then join the rest. Mount, IPC, network, UTS and PID follow, then one more fork so Wine runs in the container's PID namespace and is killed with its parent.
  • The helper file goes to the container's /tmp (falling back to its runtime directory, then the prefix). It is written through /proc/<pid>/root with openat2(RESOLVE_IN_ROOT), so no link in the container can lead outside it. The loader is checked the same way.
  • Entering the container needs the user who started it (Steam and Flatpak run games as you) or root. Otherwise the request fails with not_supported, and the Auto Assembler's message says so.

Tests

  • wine_integration calls the helper directly on the busy targets, after the register-preservation check, since Wine interrupts a target thread to do the work. It prints whether the target shared our namespaces.

  • The Proton gate requires the helper to pass, and to have run in the container in the Steam Runtime job.

  • On workhorse with Ubuntu's Wine 9.0, the helper allocated and released a 64-bit block in three setups:

    • a plain prefix;
    • a bwrap container with a user namespace, run as an ordinary user;
    • a bwrap container without one, run as root.

    Each container had its own PID namespace and a private /tmp with its own wineserver. The full regression suite passed.

When Wine reserves the space a hook needs, Cheat Engine asks Wine itself
for the block through a small generated Windows program. For a game in a
Proton (Steam Runtime) or Flatpak container, the program could not reach
the container's Wine, prefix and wineserver, so this failed with
not_supported.

The helper now joins the target's namespaces before starting Wine: the
user namespace first (its owner may then join the rest), then mount, IPC,
network, UTS and PID, with one more fork so the Wine process lives in
the container's PID namespace and dies with its parent. The helper file
is written to the container's /tmp (else its runtime directory or the
prefix) through /proc/<pid>/root with openat2(RESOLVE_IN_ROOT), so no
link in the container leads outside it, and the loader is checked the
same way. A failure to enter the container is reported as not_supported.

wine_integration calls the helper directly on the busy 64-bit and 32-bit
targets and prints whether the target shared our namespaces. The Proton
gate requires the helper to pass, and inside the Steam Runtime to have
run in the container.

Fixes #9
@wleeaf
wleeaf merged commit f839902 into main Nov 20, 2026
15 checks passed
@wleeaf
wleeaf deleted the wine-helper-in-containers branch November 20, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allocate through Wine for targets inside a Proton or Flatpak container

1 participant