php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64130 COM obj parameters passed by reference are not updated
Submitted: 2013-02-01 19:14 UTC Modified: 2020-11-07 18:01 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: bmiller dot qw at gmail dot com Assigned: cmb (profile)
Status: Closed Package: COM related
PHP Version: 5.4.11 OS: Windows
Private report: No CVE-ID: None
 [2013-02-01 19:14 UTC] 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.


Patches

php-com-dotnet-itypeinfo-fix (last revision 2013-02-01 19:16 UTC by bmiller dot qw at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-26 12:44 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2020-08-26 12:58 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2020-11-07 17:34 UTC] fherrero at noticiasdenavarra dot com
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.
 [2020-11-07 18:01 UTC] cmb@php.net
Please file a new bug report about this issue.  Also, if possible,
please provide that DLL for download.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC