mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2024-12-22 15:58:53 +00:00
Add runtime checks
This commit is contained in:
parent
c7973839fa
commit
31b9b0f8fc
@ -36,12 +36,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <mach/vm_statistics.h>
|
#include <mach/vm_statistics.h>
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
# if TARGET_OS_OSX
|
# if TARGET_OS_OSX
|
||||||
# if TARGET_CPU_ARM64
|
# define USE_PTHREAD_JIT_WP 1
|
||||||
# define USE_PTHREAD_JIT_WP 1
|
|
||||||
# else
|
|
||||||
# undef USE_PTHREAD_JIT_WP
|
|
||||||
# endif
|
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@ -118,8 +115,11 @@ void* allocMemoryPages(std::size_t bytes) {
|
|||||||
mem = mmap(nullptr, bytes, PAGE_READWRITE | RESERVED_FLAGS | PEXTRA, MAP_ANONYMOUS | MAP_PRIVATE | MEXTRA, -1, 0);
|
mem = mmap(nullptr, bytes, PAGE_READWRITE | RESERVED_FLAGS | PEXTRA, MAP_ANONYMOUS | MAP_PRIVATE | MEXTRA, -1, 0);
|
||||||
if (mem == MAP_FAILED)
|
if (mem == MAP_FAILED)
|
||||||
throw std::runtime_error("allocMemoryPages - mmap failed");
|
throw std::runtime_error("allocMemoryPages - mmap failed");
|
||||||
#ifdef USE_PTHREAD_JIT_WP
|
#if defined(USE_PTHREAD_JIT_WP) && defined(MAC_OS_VERSION_11_0) \
|
||||||
pthread_jit_write_protect_np(false);
|
&& MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
|
||||||
|
if (__builtin_available(macOS 11.0, *)) {
|
||||||
|
pthread_jit_write_protect_np(false);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return mem;
|
return mem;
|
||||||
@ -138,16 +138,22 @@ static inline void pageProtect(void* ptr, std::size_t bytes, int rules) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setPagesRW(void* ptr, std::size_t bytes) {
|
void setPagesRW(void* ptr, std::size_t bytes) {
|
||||||
#ifdef USE_PTHREAD_JIT_WP
|
#if defined(USE_PTHREAD_JIT_WP) && defined(MAC_OS_VERSION_11_0) \
|
||||||
pthread_jit_write_protect_np(false);
|
&& MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
|
||||||
|
if (__builtin_available(macOS 11.0, *)) {
|
||||||
|
pthread_jit_write_protect_np(false);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
pageProtect(ptr, bytes, PAGE_READWRITE);
|
pageProtect(ptr, bytes, PAGE_READWRITE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPagesRX(void* ptr, std::size_t bytes) {
|
void setPagesRX(void* ptr, std::size_t bytes) {
|
||||||
#ifdef USE_PTHREAD_JIT_WP
|
#if defined(USE_PTHREAD_JIT_WP) && defined(MAC_OS_VERSION_11_0) \
|
||||||
pthread_jit_write_protect_np(true);
|
&& MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
|
||||||
|
if (__builtin_available(macOS 11.0, *)) {
|
||||||
|
pthread_jit_write_protect_np(true);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
pageProtect(ptr, bytes, PAGE_EXECUTE_READ);
|
pageProtect(ptr, bytes, PAGE_EXECUTE_READ);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user