Huw Davies (@huw) commented about dlls/ole32/tests/marshal.c:
- DWORD size, read;
- IStream *pStream = NULL;
- hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
- ok_ole_success(hr, CreateStreamOnHGlobal);
- hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
- ok_ole_success(hr, CoMarshalInterface);
- hr = IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
- ok_ole_success(hr, IStream_Seek);
- size = FIELD_OFFSET(OBJREF, u_objref.u_standard.saResAddr);
- hr = IStream_Read(pStream, &objref, size, &read);
- ok_ole_success(hr, IStream_Read);
You need to reset the stream to the start and call `CoReleaseMarshalData()`.