From db32006e608fc0d959a9c3a5c0180123571b8b30 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 31 Jul 2025 10:06:08 +0800 Subject: [PATCH] . --- dec_interceptor/dec_interceptor.c | 36 ++++++++++++--------------- dec_interceptor/php_dec_interceptor.h | 4 +-- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/dec_interceptor/dec_interceptor.c b/dec_interceptor/dec_interceptor.c index 6b712343..db47932f 100644 --- a/dec_interceptor/dec_interceptor.c +++ b/dec_interceptor/dec_interceptor.c @@ -6,7 +6,7 @@ zend_op_array *(*prev_compile_file)(zend_file_handle *file_handle, int type) = NULL; zend_op_array *(*prev_compile_string)(zval *source_string, const char *filename) = NULL; -zend_internal_function_handler_t prev_execute_internal = NULL; +void (*prev_execute_ex)(zend_execute_data *execute_data) = NULL; zend_op_array *hook_compile_file(zend_file_handle *file_handle, int type) { @@ -28,21 +28,21 @@ zend_op_array *hook_compile_string(zval *source_string, const char *filename) return prev_compile_string ? prev_compile_string(source_string, filename) : NULL; } -void hook_execute_internal(zend_execute_data *execute_data, zval *return_value) +void hook_execute_ex(zend_execute_data *execute_data) { FILE *f = fopen("/tmp/dec_interceptor.log", "a"); if (f) { const zend_function *func = execute_data->func; if (func && func->common.function_name) { - fprintf(f, "[%ld] hook_execute_internal: %s\n", (long)time(NULL), ZSTR_VAL(func->common.function_name)); + fprintf(f, "[%ld] hook_execute_ex: %s\n", (long)time(NULL), ZSTR_VAL(func->common.function_name)); } else { - fprintf(f, "[%ld] hook_execute_internal: (anonymous internal)\n", (long)time(NULL)); + fprintf(f, "[%ld] hook_execute_ex: (no name)\n", (long)time(NULL)); } fclose(f); } - if (prev_execute_internal) { - prev_execute_internal(execute_data, return_value); + if (prev_execute_ex) { + prev_execute_ex(execute_data); } } @@ -58,24 +58,20 @@ PHP_RINIT_FUNCTION(dec_interceptor) 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; - prev_execute_internal = zend_execute_internal; - zend_execute_internal = hook_execute_internal; + prev_execute_ex = zend_execute_ex; + zend_execute_ex = hook_execute_ex; + + FILE *f = fopen("/tmp/dec_interceptor.log", "a"); + if (f) { + fprintf(f, "[%ld] MINIT done\n", (long)time(NULL)); + fclose(f); + } return SUCCESS; } @@ -84,11 +80,11 @@ PHP_MSHUTDOWN_FUNCTION(dec_interceptor) { zend_compile_file = prev_compile_file; zend_compile_string = prev_compile_string; - zend_execute_internal = prev_execute_internal; + zend_execute_ex = prev_execute_ex; FILE *f = fopen("/tmp/dec_interceptor.log", "a"); if (f) { - fprintf(f, "[%ld] MSHUTDOWN: dec_interceptor shutdown\n", (long)time(NULL)); + fprintf(f, "[%ld] MSHUTDOWN done\n", (long)time(NULL)); fclose(f); } diff --git a/dec_interceptor/php_dec_interceptor.h b/dec_interceptor/php_dec_interceptor.h index 355079bf..fece7351 100644 --- a/dec_interceptor/php_dec_interceptor.h +++ b/dec_interceptor/php_dec_interceptor.h @@ -12,11 +12,11 @@ extern zend_module_entry dec_interceptor_module_entry; extern zend_op_array *(*prev_compile_file)(zend_file_handle *file_handle, int type); extern zend_op_array *(*prev_compile_string)(zval *source_string, const char *filename); -extern zend_internal_function_handler_t prev_execute_internal; +extern void (*prev_execute_ex)(zend_execute_data *execute_data); 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); -void hook_execute_internal(zend_execute_data *execute_data, zval *return_value); +void hook_execute_ex(zend_execute_data *execute_data); PHP_RINIT_FUNCTION(dec_interceptor); PHP_MINIT_FUNCTION(dec_interceptor);