file_system: MAXIMUM_ALLOWED open of an overlay copy names read+write to the host (FS-MAXIMUM-ALLOWED-WINE) #977

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

@⁠OlaiFG7 on GitHub · 2026-11-24 16:10 UTC · original
OlaiFG7:fix/fs-maximum-allowed-wine → main · +55 −2 · 3 files · 1 commits · draft

Claimed in the coordination issue as: FS-MAXIMUM-ALLOWED-WINE (#14)

What and why

Under Wine a handle opened with MAXIMUM_ALLOWED reads but cannot write (finding by milk4sale in #14); Windows grants every right. The file-system shim already treats MAXIMUM_ALLOWED as a write-open and hands the title an overlay copy, but passed the mask to the host unchanged.

  • host_open_access() in runtime/shims/file_system.{h,cpp} adds GENERIC_READ | GENERIC_WRITE to a mask that has MAXIMUM_ALLOWED; other masks are unchanged. Used by the CreateFileW/A and CreateFile2 shims.
  • If the host answers ERROR_ACCESS_DENIED to the widened mask (read-only overlay copy), the open is retried with the title's own mask.
  • runtime/test/file_system_test.cpp: mask checks and a read-only overlay copy check. No game files.

Tested

Not built and not run: the machine used to write this has no C++ toolchain. Draft until file_system_test is built and run on Windows and under Wine.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly
  • One topic
  • No game data, keys or decryption
  • Not a translator rule

🤖 Generated with Claude Code

**@⁠OlaiFG7** on GitHub · 2026-11-24 16:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/977) `OlaiFG7:fix/fs-maximum-allowed-wine` → `main` · +55 −2 · 3 files · 1 commits · draft Claimed in the coordination issue as: FS-MAXIMUM-ALLOWED-WINE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Under Wine a handle opened with `MAXIMUM_ALLOWED` reads but cannot write (finding by milk4sale in #14); Windows grants every right. The file-system shim already treats `MAXIMUM_ALLOWED` as a write-open and hands the title an overlay copy, but passed the mask to the host unchanged. - `host_open_access()` in `runtime/shims/file_system.{h,cpp}` adds `GENERIC_READ | GENERIC_WRITE` to a mask that has `MAXIMUM_ALLOWED`; other masks are unchanged. Used by the CreateFileW/A and CreateFile2 shims. - If the host answers `ERROR_ACCESS_DENIED` to the widened mask (read-only overlay copy), the open is retried with the title's own mask. - `runtime/test/file_system_test.cpp`: mask checks and a read-only overlay copy check. No game files. ### Tested **Not built and not run**: the machine used to write this has no C++ toolchain. Draft until `file_system_test` is built and run on Windows and under Wine. GPUs tested: n/a AI-assisted: yes ### Checklist - [ ] Based on current `main` and merges cleanly - [x] One topic - [x] No game data, keys or decryption - [x] Not a translator rule 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Wine gives a handle opened with MAXIMUM_ALLOWED read access only, so a WriteFile through the handle the shim returned
failed there where Windows grants every right. host_open_access adds GENERIC_READ and GENERIC_WRITE to such a mask for
CreateFileW/A and CreateFile2; a host that answers ERROR_ACCESS_DENIED (a read-only overlay copy) is asked again with the
title's own mask. The mask check and the read-only fallback check are in file_system_test.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:31:33 +00:00
Author
Owner

@⁠morodirule on GitHub · 2026-11-24 16:18 UTC · original

Wine + MinGW check as requested (Arch Linux, x86_64-w64-mingw32-g++, Wine 11.22, static link with test-only _ReturnAddress shims):

Build: the draft head does not compile under MinGW as-is — file_system.cpp still has the unguarded __try (it predates #903). Cherry-picking 93511b1fa applied cleanly with no conflicts, so a rebase onto current main should be trivial; all results below are head + that guard.

Run: file_system_test under Wine: 498 checks, 5 failures (was 496/11 on the same setup without this PR). The 3 new host_open_access checks all pass, the read-only overlay-copy check passes, and all 6 previously-failing MAXIMUM_ALLOWED checks now pass (CreateFileW/A/2 opens + overlay-copy writes). The 5 remaining failures are the pre-existing Wine-environment set, unrelated to this PR: the host ReadFile into uncommitted pages, and 4 long-path listing/deletion cases.

So the fallback works as described on Wine: named read+write gets a writable handle, and the read-only-copy retry path succeeds. Not claiming; verification only.

**@⁠morodirule** on GitHub · 2026-11-24 16:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/977#issuecomment-7137466328) Wine + MinGW check as requested (Arch Linux, x86_64-w64-mingw32-g++, Wine 11.22, static link with test-only _ReturnAddress shims): Build: the draft head does not compile under MinGW as-is — file_system.cpp still has the unguarded __try (it predates #903). Cherry-picking 93511b1fa applied cleanly with no conflicts, so a rebase onto current main should be trivial; all results below are head + that guard. Run: file_system_test under Wine: 498 checks, 5 failures (was 496/11 on the same setup without this PR). The 3 new host_open_access checks all pass, the read-only overlay-copy check passes, and all 6 previously-failing MAXIMUM_ALLOWED checks now pass (CreateFileW/A/2 opens + overlay-copy writes). The 5 remaining failures are the pre-existing Wine-environment set, unrelated to this PR: the host ReadFile into uncommitted pages, and 4 long-path listing/deletion cases. So the fallback works as described on Wine: named read+write gets a writable handle, and the read-only-copy retry path succeeds. Not claiming; verification only.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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