|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12925 PHP could not pass binary string to COM
Submitted: 2001-08-23 11:02 UTC Modified: 2001-09-23 07:03 UTC
From: bin dot yang at daytonrcs dot com Assigned:
Status: Closed Package: COM related
PHP Version: 4.0.6 OS: W2K pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bin dot yang at daytonrcs dot com
New email:
PHP Version: OS:


 [2001-08-23 11:02 UTC] bin dot yang at daytonrcs dot com
Here is the PHP code.

$bp = new COM("AG2.Beepoj") or die("Unable to instanciate");
$bp-> beeeep(101,"\x0\x0\xff");

The other end is a COM object, the beeeep method defined as

STDMETHODIMP Cbeepoj::Beeeep(int iDuration, BSTR b_str)

	// TODO: Add your implementation code here
	if(wcslen(b_str)!=0) AfxMessageBox((CString)b_str);
	else AfxMessageBox("null string.");
	return S_OK;

If I use $bp-> beeeep(101,"111111"); I will get 111111 displayed in a message box. However, If the input is
$bp-> beeeep(101,"\x0\x0\xff"); The COM will say it is a
null string.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-27 11:53 UTC] bin dot yang at daytonrcs dot com
found the problem in conversion.c

 [2001-08-27 12:00 UTC] bin dot yang at daytonrcs dot com
In conversion.c:

      case IS_STRING:
         var_arg->vt = VT_BSTR;
         unicode_str = php_char_to_OLECHAR(pval_arg->value.str.val, pval_arg->value.str.len, codepage);
         var_arg->bstrVal = SysAllocString(unicode_str);

MSN document:
BSTR SysAllocString(OLECHAR FAR* sz);
Parameter :
sz:   a zero terminated string to copy. The sz parameter must be a unicode string in 32-bit applications, and an ANSI string in 16-bit applications.

What I did in my c++ file to send a binary string in c++

char tmpbuf[] = {0x00,0x20,.....0x11};
BSTR SEF = SysAllocStringByteLen(NULL,sizeof(tmpbuf));
memcpy(SEF,tmpbuf, sizeof(tmpbuf));

I can receive the binary string on the other end.
 [2001-09-23 07:03 UTC]
applied locally, will commit this after testing

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 03:03:50 2022 UTC