mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 00:05:58 +03:00
[GH-ISSUE #369] Memory-mapped file bug on Windows #59
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.