| 107 | } |
| 108 | |
| 109 | static inline void pageProtect(void* ptr, std::size_t bytes, int rules) { |
| 110 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 111 | DWORD oldp; |
| 112 | if (!VirtualProtect(ptr, bytes, (DWORD)rules, &oldp)) { |
| 113 | throw std::runtime_error(getErrorMessage("VirtualProtect")); |
| 114 | } |
| 115 | #else |
| 116 | if (-1 == mprotect(ptr, bytes, rules)) |
| 117 | throw std::runtime_error("mprotect failed"); |
| 118 | #endif |
| 119 | } |
| 120 | |
| 121 | void setPagesRW(void* ptr, std::size_t bytes) { |
| 122 | pageProtect(ptr, bytes, PAGE_READWRITE); |
no test coverage detected