Zend 扩展,获取 echo 的参数?
我们已经制作了一个 Zend 扩展,我们想要写入 zval 的 echo 的地址应该写出,但我们无法弄清楚如何接收它们,因为我们注意到 echo "test"; 之间存在差异;和$a =“测试”;回显 $a;
.... Some stuff that overrides the echo opcode ....
FILE *tmpfile;
int echo_handler(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = execute_data->opline;
tmpfile = fopen("/tmp/echo.test","a+");
fprintf(tmpfile,"Echo was called\n");
fclose(tmpfile);
return ZEND_USER_OPCODE_DISPATCH;
}
无论参数是否是变量,我们如何获取参数?
We have made a Zend extension which we want to write the addresses of the zval's echo is supposed to write out, but we cannot figure how to receive them because we have noticed that there is difference between echo "test"; and $a = "test"; echo $a;
.... Some stuff that overrides the echo opcode ....
FILE *tmpfile;
int echo_handler(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = execute_data->opline;
tmpfile = fopen("/tmp/echo.test","a+");
fprintf(tmpfile,"Echo was called\n");
fclose(tmpfile);
return ZEND_USER_OPCODE_DISPATCH;
}
How do we get the arguments no matter if it is a variable or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
echo 的处理程序
来自
Zend/zend_vm_execute.h
,正如您所看到的,它基本上所做的就是调用zend_print_variable()
。挂钩该功能,您应该走在正确的轨道上。
奖励:它也适用于
print
语句。The handler for echo is
from
Zend/zend_vm_execute.h
, and as you can see all it basically does is to callzend_print_variable()
.Hook that function and you should be on the right track.
Bonus: it works for
print
statements too.