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

Closed
OlaiFG7 wants to merge 1 commit from upstream-pr/977 into main
OlaiFG7 commented 2026-11-24 16:10:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OlaiFG7 on 2026-11-24T16:10:50Z.


Claimed in the coordination issue as: FS-MAXIMUM-ALLOWED-WINE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136888814)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475886445 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/977). Originally posted by [OlaiFG7](https://github.com/OlaiFG7) on 2026-11-24T16:10:50Z. --- Claimed in the coordination issue as: FS-MAXIMUM-ALLOWED-WINE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136888814) ### 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)
morodirule commented 2026-11-24 16:18:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by morodirule on 2026-11-24T16:18:59Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137466328 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/977#issuecomment-7137466328). Originally posted by [morodirule](https://github.com/morodirule) on 2026-11-24T16:18:59Z. --- 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.
aslan2142 commented 2026-12-01 16:32:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:32:42Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317782960 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/977#issuecomment-7317782960). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:32:42Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!977
No description provided.