php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25235 win32api problem in arguments
Submitted: 2003-08-25 08:24 UTC Modified: 2011-01-01 21:03 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: fgarcia at uef dot es Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.3 OS: win32
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fgarcia at uef dot es
New email:
PHP Version: OS:

 

 [2003-08-25 08:24 UTC] 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.




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-03 02:17 UTC] foxkill at gmx dot de
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.
 [2011-01-01 21:03 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2011-01-01 21:03 UTC] jani@php.net
w32api is in PECL nowadays.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 14 08:01:28 2024 UTC