Problem in Win32api.c
| From: | Fabian Cenedese | Date: | Wed, 17 Sep 2003 09:04:01 +0000 |
| Subject: | Problem in Win32api.c | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-21403@lists.php.net to get a copy of this message | ||
Hi
I try to register and call some functions of my own dll. After working (and
failing) with PHP 4.3.3 I tried the new PHP 5.0.0b1. I was suprised to see
that it didn't work much better, some errors still remain.
In (win32, invokefunction) following variables are declared:
void *w32api_return_buffer = NULL;
int w32api_return_buffer_size = 0;
zval **func_arguments = NULL;
func_arguments gets later filled with
if(zend_get_parameters_array_ex(argc, &func_arguments) == FAILURE)
But this only works if there are not more than one arguments. If there are two or more
the values get filled in w32api_return_buffer_size (second) and w32api_return_buffer
(third) etc...
I hardly believe that this was the intention. I temporarily fixed it by declaring
func_arguments as array like func_arguments[10] so it will work for up to ten
arguments, but I guess the right solution should be better than that.
In PHP4 was an error where it always crashed in zend_hash_find when I tried to
register more than 6 functions. This seems to be solved in PHP5 now.
On the other hand I got a new problem in PHP5 that wasn't there in PHP4.
In zend_std_get_method there's a variable
zend_function *fbc;
being filled later with
if (zend_hash_find(&zobj->ce->function_table, lc_method_name, method_len+1, (void
**)&fbc) == FAILURE) {
Then comes a check for access rights:
if (fbc->op_array.fn_flags & ZEND_ACC_PUBLIC) {
The problem now is that these flags (and many more members of op_array) are
bogus like 0xcccccccc. If I fill in by hand the value for ZEND_ACC_PUBLIC (0x100)
then it works.
I then tried to find out how I could tell from the beginning, what rights a function has.
The registerfunction in Win32api.c has a second argument 'flags' which is nowhere
explained. I just tried and filled in the 0x100 but to no avail. So:
1. What is this second argument 'flags' in registerfunction for?
2. How can I register a function with public access rights? (Do I even have to?)
And to round it up I always get errors in the end for zend_hash_destroy. Looks like
there are some problems with the memory handling.
I hope this info is useful for some developers to fix it.
F. Cenedese
INDEL AG