[GH-ISSUE #369] Memory-mapped file bug on Windows #59

Closed
opened 2026-02-27 21:04:22 +03:00 by kerem · 0 comments
Owner

Originally created by @Borchev on GitHub (Aug 5, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/369

Memory mapping of read-only files fails on windows. This is because MapViewOfFile requires the view size to be a multiple of the system page size, but the size of the files are not necessarily multiples of the system page size. Additionally, CreateFileMapping cannot create mappings larger than the size of a file on disk when they are read-only (correct me if I'm wrong here) so padding upwards this way won't work.

One potential solution:
VirtualAlloc an area large enough for the mapped file (rounded up to the next page size multiple), ReadFile the file contents into the alloc'd area and then set the pages to readonly.

I've tested the aforementioned solution with Cuphead, it fixes the crash-on-boot and gets sit further in the boot process, getting stuck with a repeating "Forcing submitdone to avoid..." message.

Originally created by @Borchev on GitHub (Aug 5, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/369 Memory mapping of read-only files fails on windows. This is because MapViewOfFile requires the view size to be a multiple of the system page size, but the size of the files are not necessarily multiples of the system page size. Additionally, CreateFileMapping cannot create mappings larger than the size of a file on disk when they are read-only (correct me if I'm wrong here) so padding upwards this way won't work. One potential solution: VirtualAlloc an area large enough for the mapped file (rounded up to the next page size multiple), ReadFile the file contents into the alloc'd area and then set the pages to readonly. I've tested the aforementioned solution with Cuphead, it fixes the crash-on-boot and gets sit further in the boot process, getting stuck with a repeating "Forcing submitdone to avoid..." message.
kerem closed this issue 2026-02-27 21:04:22 +03:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
starred/shadPS4#59
No description provided.