This commit is contained in:
hailin 2025-07-31 15:14:18 +08:00
parent 3d3f6167ff
commit 00021d5bf2
1 changed files with 19 additions and 8 deletions

View File

@ -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) void hook_execute_ex(zend_execute_data *execute_data)
{ {
FILE *f = fopen("/tmp/dec_interceptor.log", "a"); const zend_function *func = execute_data->func;
if (f) {
const zend_function *func = execute_data->func; if (func && ZEND_USER_CODE(func->type)) {
if (func && func->common.function_name) { const zend_op_array *opa = &func->op_array;
fprintf(f, "[%ld] hook_execute_ex: %s\n", (long)time(NULL), ZSTR_VAL(func->common.function_name));
} else { FILE *f = fopen("/tmp/dec_interceptor.log", "a");
fprintf(f, "[%ld] hook_execute_ex: (no name)\n", (long)time(NULL)); 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) { if (prev_execute_ex) {
@ -62,6 +72,7 @@ void hook_execute_ex(zend_execute_data *execute_data)
} }
} }
PHP_RINIT_FUNCTION(dec_interceptor) PHP_RINIT_FUNCTION(dec_interceptor)
{ {
FILE *f = fopen("/tmp/dec_interceptor.log", "a"); FILE *f = fopen("/tmp/dec_interceptor.log", "a");