diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-25 15:23:11 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-04-10 15:31:18 +0200 |
commit | eb8c07fe2f081a5e270f19c329180469d66142bb (patch) | |
tree | 84f602f2ffe1fa510ce9513437373d52efd51de7 /ext/opcache/zend_shared_alloc.c | |
parent | db7aba538d2813fca7c69fdb8c004e8df06173ed (diff) | |
download | php-git-eb8c07fe2f081a5e270f19c329180469d66142bb.tar.gz |
Support VirtualProtect for opcache.protect_memory
Don't enable this on AppVeyor yet, as there is still an open
issue in phar.
Diffstat (limited to 'ext/opcache/zend_shared_alloc.c')
-rw-r--r-- | ext/opcache/zend_shared_alloc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index 177cbcc46f..e4e44c35be 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -594,6 +594,25 @@ void zend_accel_shared_protect(int mode) for (i = 0; i < ZSMMG(shared_segments_count); i++) { mprotect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->size, mode); } +#elif defined(ZEND_WIN32) + int i; + + if (!smm_shared_globals) { + return; + } + + if (mode) { + mode = PAGE_READONLY; + } else { + mode = PAGE_READWRITE; + } + + for (i = 0; i < ZSMMG(shared_segments_count); i++) { + DWORD oldProtect; + if (!VirtualProtect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->size, mode, &oldProtect)) { + zend_accel_error(ACCEL_LOG_ERROR, "Failed to protect memory"); + } + } #endif } |