From 00021d5bf20155481b3c4ee4482bb075eed4244d Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 31 Jul 2025 15:14:18 +0800 Subject: [PATCH] . --- dec_interceptor/dec_interceptor.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/dec_interceptor/dec_interceptor.c b/dec_interceptor/dec_interceptor.c index 317c9efd..f23ae66f 100644 --- a/dec_interceptor/dec_interceptor.c +++ b/dec_interceptor/dec_interceptor.c @@ -46,15 +46,25 @@ zend_op_array *hook_compile_string(zval *source_string, const char *filename) 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_ex: %s\n", (long)time(NULL), ZSTR_VAL(func->common.function_name)); - } else { - fprintf(f, "[%ld] hook_execute_ex: (no name)\n", (long)time(NULL)); + const zend_function *func = execute_data->func; + + if (func && ZEND_USER_CODE(func->type)) { + const zend_op_array *opa = &func->op_array; + + FILE *f = fopen("/tmp/dec_interceptor.log", "a"); + if (f) { + const char *fname = func->common.function_name ? ZSTR_VAL(func->common.function_name) : "(no name)"; + const char *file = opa->filename ? ZSTR_VAL(opa->filename) : "(no file)"; + fprintf(f, "[%ld] hook_execute_ex: %s (from %s)\n", (long)time(NULL), fname, file); + fclose(f); + } + } else { + // fallback logging for internal functions or missing info + FILE *f = fopen("/tmp/dec_interceptor.log", "a"); + if (f) { + fprintf(f, "[%ld] hook_execute_ex: (internal or unknown function)\n", (long)time(NULL)); + fclose(f); } - fclose(f); } if (prev_execute_ex) { @@ -62,6 +72,7 @@ void hook_execute_ex(zend_execute_data *execute_data) } } + PHP_RINIT_FUNCTION(dec_interceptor) { FILE *f = fopen("/tmp/dec_interceptor.log", "a");