Returns windows-specific protect_flags from \ref MemoryFlags.
| 189 | |
| 190 | // Returns windows-specific protect_flags from \ref MemoryFlags. |
| 191 | static DWORD protect_flags_from_memory_flags(MemoryFlags memory_flags) noexcept { |
| 192 | DWORD protect_flags; |
| 193 | |
| 194 | // READ|WRITE|EXECUTE. |
| 195 | if (Support::test(memory_flags, MemoryFlags::kAccessExecute)) { |
| 196 | protect_flags = Support::test(memory_flags, MemoryFlags::kAccessWrite) ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ; |
| 197 | } |
| 198 | else if (Support::test(memory_flags, MemoryFlags::kAccessRW)) { |
| 199 | protect_flags = Support::test(memory_flags, MemoryFlags::kAccessWrite) ? PAGE_READWRITE : PAGE_READONLY; |
| 200 | } |
| 201 | else { |
| 202 | protect_flags = PAGE_NOACCESS; |
| 203 | } |
| 204 | |
| 205 | // Any other flags to consider? |
| 206 | return protect_flags; |
| 207 | } |
| 208 | |
| 209 | static DWORD desired_access_from_memory_flags(MemoryFlags memory_flags) noexcept { |
| 210 | DWORD access = Support::test(memory_flags, MemoryFlags::kAccessWrite) ? FILE_MAP_WRITE : FILE_MAP_READ; |