diff options
| author | 2021-06-06 20:53:26 -0300 | |
|---|---|---|
| committer | 2021-06-11 17:27:17 +0200 | |
| commit | ee67460ff0e12a1603431d86fe3919a24b3858fb (patch) | |
| tree | a8d0955b2bd1cf69fb54a970d0996c3affcbff62 /src | |
| parent | General: Add settings for fastmem and disabling adress space check. (diff) | |
| download | yuzu-ee67460ff0e12a1603431d86fe3919a24b3858fb.tar.gz yuzu-ee67460ff0e12a1603431d86fe3919a24b3858fb.tar.xz yuzu-ee67460ff0e12a1603431d86fe3919a24b3858fb.zip | |
host_memory: Support staged VirtualProtect calls
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/host_memory.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 8a328f916..c6d65aab9 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp | |||
| @@ -110,9 +110,18 @@ public: | |||
| 110 | } else { | 110 | } else { |
| 111 | UNIMPLEMENTED_MSG("Protection flag combination read={} write={}", read, write); | 111 | UNIMPLEMENTED_MSG("Protection flag combination read={} write={}", read, write); |
| 112 | } | 112 | } |
| 113 | DWORD old_flags{}; | 113 | const size_t virtual_end = virtual_offset + length; |
| 114 | if (!VirtualProtect(virtual_base + virtual_offset, length, new_flags, &old_flags)) { | 114 | |
| 115 | LOG_CRITICAL(HW_Memory, "Failed to change virtual memory protect rules"); | 115 | std::lock_guard lock{placeholder_mutex}; |
| 116 | auto [it, end] = placeholders.equal_range({virtual_offset, virtual_end}); | ||
| 117 | while (it != end) { | ||
| 118 | const size_t offset = std::max(it->lower(), virtual_offset); | ||
| 119 | const size_t protect_length = std::min(it->upper(), virtual_end) - offset; | ||
| 120 | DWORD old_flags{}; | ||
| 121 | if (!VirtualProtect(virtual_base + offset, protect_length, new_flags, &old_flags)) { | ||
| 122 | LOG_CRITICAL(HW_Memory, "Failed to change virtual memory protect rules"); | ||
| 123 | } | ||
| 124 | ++it; | ||
| 116 | } | 125 | } |
| 117 | } | 126 | } |
| 118 | 127 | ||