Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在将函数名连接到php扩展时获取它_Php_Php Internals - Fatal编程技术网

如何在将函数名连接到php扩展时获取它

如何在将函数名连接到php扩展时获取它,php,php-internals,Php,Php Internals,我试图编写一个PHP模块,用于检测PHP cgi文件中调用的zend内部函数。喜欢下面显示的代码,我想在我的代码中得到它的名字--“printf” <?php printf("Hello SO!");?> 嘿,伙计们,我知道答案了。有两种不同的方法来实现挂钩函数的名称 首先,如果使用PHP5,则需要定义宏,因为该方法取决于PHP次要版本(小于或不小于4) 嘿,伙计们,我知道答案了。有两种不同的方法来实现挂钩函数的名称 首先,如果使用PHP5,则需要定义宏,因为该方法取决于PHP次要

我试图编写一个PHP模块,用于检测PHP cgi文件中调用的zend内部函数。喜欢下面显示的代码,我想在我的代码中得到它的名字--“printf”

<?php printf("Hello SO!");?>

嘿,伙计们,我知道答案了。有两种不同的方法来实现挂钩函数的名称

首先,如果使用PHP5,则需要定义宏,因为该方法取决于PHP次要版本(小于或不小于4)


嘿,伙计们,我知道答案了。有两种不同的方法来实现挂钩函数的名称

首先,如果使用PHP5,则需要定义宏,因为该方法取决于PHP次要版本(小于或不小于4)

int shellhook_handler(ZEND_OPCODE_HANDLER_ARGS){

 /* What should I do to catch function name here*/

 return ZEND_USER_OPCODE_DISPATCH;
}


PHP_MINIT_FUNCTION(shellhook)
{

    REGISTER_INI_ENTRIES();
    zend_set_user_opcode_handler(ZEND_DO_FCALL, hook_handler);
    return SUCCESS;
}
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4) 
                # define OP1_CONSTANT_PTR(n) (&(n)->op1.u.constant)
#else    
                #  define OP1_CONSTANT_PTR(n) ((n)->op1.zv)
#endif 

zend_op *opline = execute_data->opline;
zval *fname = OP1_CONSTANT_PTR(opline);
php_printf("FunctionName:%s\n",Z_STRVAL_P(fname));
    zend_execute_data *call = execute_data->call;
    zend_function *fbc = call->func;
    zend_string *fname = fbc->common.function_name;
    php_printf("FunctionName:%s\n",ZSTR_VAL(fname));