diff --git a/dec_interceptor/dec_interceptor.c b/dec_interceptor/dec_interceptor.c index 33d32857..3600ac6d 100644 --- a/dec_interceptor/dec_interceptor.c +++ b/dec_interceptor/dec_interceptor.c @@ -19,6 +19,16 @@ zend_op_array *hook_compile_file(zend_file_handle *file_handle, int type) return prev_compile_file ? prev_compile_file(file_handle, type) : NULL; } +PHP_RINIT_FUNCTION(dec_interceptor) +{ + FILE *f = fopen("/tmp/dec_interceptor.log", "a"); + if (f) { + fprintf(f, "[%ld] RINIT: zend_compile_file = %p\n", (long)time(NULL), zend_compile_file); + fclose(f); + } + return SUCCESS; +} + /* hook zend_compile_string */ zend_op_array *hook_compile_string(zval *source_string, const char *filename) { @@ -32,21 +42,26 @@ zend_op_array *hook_compile_string(zval *source_string, const char *filename) PHP_MINIT_FUNCTION(dec_interceptor) { + FILE *f = fopen("/tmp/dec_interceptor.log", "a"); + if (f) { + fprintf(f, "[%ld] MINIT: dec_interceptor initialized\n", (long)time(NULL)); + fprintf(f, " zend_compile_file addr: %p\n", zend_compile_file); + fprintf(f, " hook_compile_file addr: %p\n", hook_compile_file); + fprintf(f, " zend_compile_string addr: %p\n", zend_compile_string); + fprintf(f, " hook_compile_string addr: %p\n", hook_compile_string); + fclose(f); + } + prev_compile_file = zend_compile_file; zend_compile_file = hook_compile_file; prev_compile_string = zend_compile_string; zend_compile_string = hook_compile_string; - FILE *f = fopen("/tmp/dec_interceptor.log", "a"); - if (f) { - fprintf(f, "[%ld] MINIT: dec_interceptor initialized\n", (long)time(NULL)); - fclose(f); - } - return SUCCESS; } + PHP_MSHUTDOWN_FUNCTION(dec_interceptor) { zend_compile_file = prev_compile_file; diff --git a/dec_interceptor/php_dec_interceptor.h b/dec_interceptor/php_dec_interceptor.h index 848aa0dd..ffd940be 100644 --- a/dec_interceptor/php_dec_interceptor.h +++ b/dec_interceptor/php_dec_interceptor.h @@ -15,6 +15,7 @@ extern zend_op_array *(*prev_compile_string)(zval *source_string, const char *fi zend_op_array *hook_compile_file(zend_file_handle *file_handle, int type); zend_op_array *hook_compile_string(zval *source_string, const char *filename); +PHP_RINIT_FUNCTION(dec_interceptor); PHP_MINIT_FUNCTION(dec_interceptor); PHP_MSHUTDOWN_FUNCTION(dec_interceptor); PHP_MINFO_FUNCTION(dec_interceptor);