Bug #64130 [Com]: COM obj parameters passed by reference are not updated
Edit report at https://bugs.php.net/bug.php?id=64130&edit=1
ID: 64130
Comment by: fherrero at noticiasdenavarra dot com
Reported by: bmiller dot qw at gmail dot com
Summary: COM obj parameters passed by reference are not
updated
Status: Closed
Type: Bug
Package: COM related
Operating System: Windows
PHP Version: 5.4.11
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I've a dll with a method with doble params:
dll_method([out] dobule* DoubleParam);
When I call this method:
<?php
$double_param = (float) 0.1;
dll_method($double_param);
Throws this error:
Parameter 1: The types do not match.
When copy php_com_dotnet.dll from PHP-7.4.10 to PHP-7.4.11 (or 7.4.12) the are no error.
Previous Comments:
------------------------------------------------------------------------
[2020-08-26 12:58:06] cmb@php.net
Fixed as <http://git.php.net/?p=php-src.git;a=commit;h=5ff15e2651850ba30dde69056436b8774fac9166>.
------------------------------------------------------------------------
[2013-02-01 19:14:19] bmiller dot qw at gmail dot com
Description:
------------
I found that COM ByRef parameters where still being treated as ByVal parameters - only for "out
of process" com objects.
I debugged the COM extension (or COM_DOTNET) and found that in function;
php_com_get_id_of_name() (in com_com.c)
was calling "hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid);" to
get the com object dispatch id from the member name.
For out of process objects this will always return E_NOTIMPL.
Thus the iTypeInfo object (obj->typeinfo) would be destroyed.
The final result would be that ByRef parameters would NOT be detected.
Easy fix; Just ALWAYS use the IDispatch_GetIDsOfNames and only use iTypeInfo for the
ITypeInfo_GetTypeComp call - which is what we need.
Test script:
---------------
//(need MS word) or any app that has a COM interface
$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Visible = 1;
/*
In the com_com.c, place a breakpoint at:
hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid);
It will always return E_NOTIMPL then the code deletes obj->typeinfo which
ultimately causes the problem
*/
Expected result:
----------------
If the com object function call used references then the variable would be changed.
Sorry I couldn't find a public COM object off hand that passed variables by reference.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64130&edit=1
Thread (6 messages)