MCPcopy Create free account
hub / github.com/LUX-Core/lux / pageProtect

Function pageProtect

src/crypto/RandomX/virtual_memory.cpp:109–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static 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
121void setPagesRW(void* ptr, std::size_t bytes) {
122 pageProtect(ptr, bytes, PAGE_READWRITE);

Callers 3

setPagesRWFunction · 0.85
setPagesRXFunction · 0.85
setPagesRWXFunction · 0.85

Calls 1

getErrorMessageFunction · 0.85

Tested by

no test coverage detected