This commit is contained in:
hailin 2025-07-31 09:54:17 +08:00
parent 770d4e5016
commit 638b3f4c3a
2 changed files with 22 additions and 6 deletions

View File

@ -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;

View File

@ -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);