Core: Fix read-only file unmaps on Windows (#3246)

* Fix read-only file unmaps

Fixes Genshin Impact (CUSA23681)

* Slight cleanup

Don't need `post_merge_it` anymore.
This commit is contained in:
Stephen Miller 2025-07-15 06:11:56 -05:00 committed by GitHub
parent b68ca43166
commit 97daee836a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -537,6 +537,7 @@ u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma
vma_base_size - start_in_vma < size ? vma_base_size - start_in_vma : size; vma_base_size - start_in_vma < size ? vma_base_size - start_in_vma : size;
const bool has_backing = type == VMAType::Direct || type == VMAType::File; const bool has_backing = type == VMAType::Direct || type == VMAType::File;
const auto prot = vma_base.prot; const auto prot = vma_base.prot;
const bool readonly_file = prot == MemoryProt::CpuRead && type == VMAType::File;
if (type == VMAType::Free) { if (type == VMAType::Free) {
return adjusted_size; return adjusted_size;
@ -554,9 +555,8 @@ u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma
vma.phys_base = 0; vma.phys_base = 0;
vma.disallow_merge = false; vma.disallow_merge = false;
vma.name = ""; vma.name = "";
const auto post_merge_it = MergeAdjacent(vma_map, new_it); MergeAdjacent(vma_map, new_it);
auto& post_merge_vma = post_merge_it->second;
bool readonly_file = post_merge_vma.prot == MemoryProt::CpuRead && type == VMAType::File;
if (type != VMAType::Reserved && type != VMAType::PoolReserved) { if (type != VMAType::Reserved && type != VMAType::PoolReserved) {
// If this mapping has GPU access, unmap from GPU. // If this mapping has GPU access, unmap from GPU.
if (IsValidGpuMapping(virtual_addr, size)) { if (IsValidGpuMapping(virtual_addr, size)) {