#25235 [Com]: win32api problem in arguments

From: Date: Wed, 03 Sep 2003 07:17:37 +0000
Subject: #25235 [Com]: win32api problem in arguments
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-47121@lists.php.net to get a copy of this message
ID: 25235 Comment by: foxkill at gmx dot de Reported By: fgarcia at uef dot es Status: Open Bug Type: *Extensibility Functions Operating System: win32 PHP Version: 4.3.3 New Comment: The problem is within the WIN32API_CLASS_FUNCTION(win32, invokefunction). It declares the variable func_argument as zval** func_arguments = NULL and later on it calls zend_get_parameters_array_ex(argc, &func_arguments). If there are more than 2 arguments this call overwrites the stack and thereby the variable w32api_return_buffer (and some others). w32api_return_buffer is now not null in the following call to php_w32api_do_dynamic_call and the stack calculation in this function goes wrong. In my opinion the variable func_arguments should be allocated dynamically according to number of actual parameters. Previous Comments: ------------------------------------------------------------------------ [2003-08-25 08:24:04] fgarcia at uef dot es Description: ------------ I need to use a dll external function. My code in php 4.2.3 was: ------------------ w32api_register_function("MYLIB.DLL", "MYFUNC", "long"); $attr1="string1"; $attr2="string2"; $attr3="string3"; $attr4="string4"; $attr5="string5"; $attr6=long2Str(2);// long $iError=MYFUNC($attr1,$attr2,$attr3,$attr4,$attr5,$attr6); $iRtn=str2Long($siRtn); -------------- The code works. Now (php 4.3.2) my code is: -------------- $api = new win32(); $api->RegisterFunction("int MYFUNC(string attr1, string attr2, string attr3, string attr4, string attr5, int &attr6) From MYLIB.DLL"); $attr1="string1"; $attr2="string2"; $attr3="string3"; $attr4="string4"; $attr5="string5"; $attr6=2;// long $iError=$api->MYFUNC($attr1,$attr2,$attr3,$attr4,$attr5,$attr6); ------------------- and php crashes. I've traced the dll call and I've seen that arguments aren't pass well to the dll. In PHP 4.2.3 version, first argument (attr1) offsets 0x04 bytes (in the call stack) but in 4.3.3 version the same first argument offsets 0x08 bytes. It seems that PHP 4.3.3 version puts an extra (???) attribute in the call stack. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25235&edit=1

« previous php.bugs (#47121) next »