I looked around a lot and never got a good book or any online documentation on zend_extensions [found quite a lot on PHP extensions, but not much on zend_extensions]. I am writing an extension and would like to do the following:
1. Capture state (mainly function call arguments) of currently executing functions. [I found a structure that contains some data about the function and studies it to find the names of the parameters of the function, but I cannot find their values. if zend_execute_data *execdis a pointer to a structure.
execd->function_state.function->common.(arg_info+i)->name)gives the name of the variable name ith agrument for the current function]. How to get the valuefor the i-th parameter. I know what I need to read from the stack. How to get a link to parameters on the stack? Is there a hash table or something else?
2. Secondly, how to skip the current executable function and move on to the next function / instruction in php script or replace the current function code with code from a cleaner or safer version of this function? From the zend_execute function.
Larger image . I am trying to get the state of a function and make some kind of decision on the execution thread of the interpreter based on the state of the function. I am trying to do all this from zend_execute( )located in my zend_extension, so I only have an API zend_execute( )to perform the above two tasks. Below is a list of the structures I went through and checked to find the value of the arguments of the current function.
struct _zend_execute_data {
struct _zend_op *opline;
zend_function_state function_state;
zend_function *fbc; /* Function Being Called */
zend_class_entry *called_scope;
zend_op_array *op_array;
zval *object;
union _temp_variable *Ts;
zval ***CVs;
HashTable *symbol_table;
struct _zend_execute_data *prev_execute_data;
zval *old_error_reporting;
zend_bool nested;
zval **original_return_value;
zend_class_entry *current_scope;
zend_class_entry *current_called_scope;
zval *current_this;
zval *current_object;
};
links
typedef struct _zend_function_state {
zend_function *function;
void **arguments;
} zend_function_state;
link
typedef union _zend_function {
zend_uchar type; /* MUST be the first element of this struct! */
struct {
zend_uchar type; /* never used */
const char *function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
} common;
zend_op_array op_array;
zend_internal_function internal_function;
} zend_function;
, . , . PHP , " PHP" .., API .
, , . Stack Overflow, , - , . , .