ReactOS 0.4.16-dev-136-g52192f1
usrmarshal.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 Piotr Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#define NONAMELESSUNION
20
21#include "urlmon_main.h"
22
23#include "wine/debug.h"
24
26
28 DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf, DWORD *pdwFlags,
30{
31 TRACE("(%p %x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuf, pdwFlags, pdwReserved);
32 return IWinInetHttpInfo_RemoteQueryInfo_Proxy(This, dwOption, pBuffer, pcbBuf, pdwFlags, pdwReserved);
33}
34
36 DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf, DWORD *pdwFlags,
38{
39 TRACE("(%p %x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuf, pdwFlags, pdwReserved);
40 return IWinInetHttpInfo_QueryInfo(This, dwOption, pBuffer, pcbBuf, pdwFlags, pdwReserved);
41}
42
44 DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf)
45{
46 TRACE("(%p %x %p %p)\n", This, dwOption, pBuffer, pcbBuf);
47 return IWinInetInfo_RemoteQueryOption_Proxy(This, dwOption, pBuffer, pcbBuf);
48}
49
51 DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf)
52{
53 TRACE("(%p %x %p %p)\n", This, dwOption, pBuffer, pcbBuf);
54 return IWinInetInfo_QueryOption(This, dwOption, pBuffer, pcbBuf);
55}
56
59 REFIID riid, void **obj)
60{
61 TRACE("(%p %p %p %p %s %p)\n", This, moniker, bc, bsc, debugstr_guid(riid), obj);
62 return IBindHost_RemoteMonikerBindToStorage_Proxy(This, moniker, bc, bsc, riid, (IUnknown**)obj);
63}
64
68{
69 TRACE("(%p %p %p %p %s %p)\n", This, moniker, bc, bsc, debugstr_guid(riid), obj);
70 return IBindHost_MonikerBindToStorage(This, moniker, bc, bsc, riid, (void**)obj);
71}
72
75 REFIID riid, void **obj)
76{
77 TRACE("(%p %p %p %p %s %p)\n", This, moniker, bc, bsc, debugstr_guid(riid), obj);
78 return IBindHost_RemoteMonikerBindToObject_Proxy(This, moniker, bc, bsc, riid, (IUnknown**)obj);
79}
80
84{
85 TRACE("(%p %p %p %p %s %p)\n", This, moniker, bc, bsc, debugstr_guid(riid), obj);
86 return IBindHost_MonikerBindToObject(This, moniker, bc, bsc, riid, (void**)obj);
87}
88
89static HRESULT marshal_stgmed(STGMEDIUM *stgmed, RemSTGMEDIUM **ret)
90{
91 RemSTGMEDIUM *rem_stgmed;
93 ULONG size = 0;
95
96 if((stgmed->tymed == TYMED_ISTREAM && stgmed->u.pstm) || stgmed->pUnkForRelease) {
98 if(FAILED(hres))
99 return hres;
100 }
101
102 switch(stgmed->tymed) {
103 case TYMED_NULL:
104 break;
105 case TYMED_ISTREAM:
106 if(stgmed->u.pstm)
107 hres = CoMarshalInterface(stream, &IID_IStream, (IUnknown*)stgmed->u.pstm,
108 MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
109 break;
110 default:
111 FIXME("unsupported tymed %u\n", stgmed->tymed);
112 break;
113 }
114
115 if(SUCCEEDED(hres) && stgmed->pUnkForRelease)
116 hres = CoMarshalInterface(stream, &IID_IUnknown, stgmed->pUnkForRelease,
117 MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
118 if(FAILED(hres)) {
119 if(stream)
120 IStream_Release(stream);
121 return hres;
122 }
123
124 if(stream) {
126 ULARGE_INTEGER off;
127
128 zero.QuadPart = 0;
129 IStream_Seek(stream, zero, STREAM_SEEK_CUR, &off);
130 size = off.QuadPart;
131 IStream_Seek(stream, zero, STREAM_SEEK_SET, &off);
132 }
133
134 rem_stgmed = heap_alloc_zero(FIELD_OFFSET(RemSTGMEDIUM, data[size]));
135 if(!rem_stgmed) {
136 if(stream)
137 IStream_Release(stream);
138 return E_OUTOFMEMORY;
139 }
140
141 rem_stgmed->tymed = stgmed->tymed;
142 rem_stgmed->dwHandleType = 0;
143 rem_stgmed->pData = stgmed->u.pstm != NULL;
144 rem_stgmed->pUnkForRelease = stgmed->pUnkForRelease != NULL;
145 rem_stgmed->cbData = size;
146 if(stream) {
147 IStream_Read(stream, rem_stgmed->data, size, &size);
148 IStream_Release(stream);
149 }
150
151 *ret = rem_stgmed;
152 return S_OK;
153}
154
155static HRESULT unmarshal_stgmed(RemSTGMEDIUM *rem_stgmed, STGMEDIUM *stgmed)
156{
158 HRESULT hres = S_OK;
159
160 stgmed->tymed = rem_stgmed->tymed;
161
162 if((stgmed->tymed == TYMED_ISTREAM && rem_stgmed->pData) || rem_stgmed->pUnkForRelease) {
164
166 if(FAILED(hres))
167 return hres;
168
169 hres = IStream_Write(stream, rem_stgmed->data, rem_stgmed->cbData, NULL);
170 if(FAILED(hres)) {
171 IStream_Release(stream);
172 return hres;
173 }
174
175 zero.QuadPart = 0;
176 IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
177 }
178
179 switch(stgmed->tymed) {
180 case TYMED_NULL:
181 break;
182 case TYMED_ISTREAM:
183 if(rem_stgmed->pData)
184 hres = CoUnmarshalInterface(stream, &IID_IStream, (void**)&stgmed->u.pstm);
185 break;
186 default:
187 FIXME("unsupported tymed %u\n", stgmed->tymed);
188 break;
189 }
190
191 if(SUCCEEDED(hres) && rem_stgmed->pUnkForRelease)
192 hres = CoUnmarshalInterface(stream, &IID_IUnknown, (void**)&stgmed->pUnkForRelease);
193 if(stream)
194 IStream_Release(stream);
195 return hres;
196}
197
198static void proxy_marshal_bindinfo(BINDINFO *bindinfo, RemBINDINFO *rem_bindinfo)
199{
200 rem_bindinfo->szExtraInfo = bindinfo->szExtraInfo;
201 rem_bindinfo->grfBindInfoF = bindinfo->grfBindInfoF;
202 rem_bindinfo->dwBindVerb = bindinfo->dwBindVerb;
203 rem_bindinfo->szCustomVerb = bindinfo->szCustomVerb;
204 rem_bindinfo->cbstgmedData = bindinfo->cbstgmedData;
205}
206
207static void proxy_unmarshal_bindinfo(RemBINDINFO *rem_bindinfo, BINDINFO *bindinfo)
208{
209 bindinfo->szExtraInfo = rem_bindinfo->szExtraInfo;
210 bindinfo->grfBindInfoF = rem_bindinfo->grfBindInfoF;
211 bindinfo->dwBindVerb = rem_bindinfo->dwBindVerb;
212 bindinfo->szCustomVerb = rem_bindinfo->szCustomVerb;
213 bindinfo->cbstgmedData = rem_bindinfo->cbstgmedData;
214 bindinfo->dwOptions = rem_bindinfo->dwOptions;
215 bindinfo->dwOptionsFlags = rem_bindinfo->dwOptionsFlags;
216 bindinfo->dwCodePage = rem_bindinfo->dwCodePage;
217 bindinfo->iid = IID_NULL;
218 bindinfo->pUnk = NULL;
219}
220
221static void stub_unmarshal_bindinfo(RemBINDINFO *rem_bindinfo, BINDINFO *bindinfo)
222{
223 bindinfo->szExtraInfo = rem_bindinfo->szExtraInfo;
224 bindinfo->grfBindInfoF = rem_bindinfo->grfBindInfoF;
225 bindinfo->dwBindVerb = rem_bindinfo->dwBindVerb;
226 bindinfo->szCustomVerb = rem_bindinfo->szCustomVerb;
227 bindinfo->cbstgmedData = rem_bindinfo->cbstgmedData;
228
229 if(bindinfo->stgmedData.tymed != TYMED_NULL)
230 WARN("stgmed data (tymed %u) will be lost!\n", bindinfo->stgmedData.tymed);
231}
232
233static void stub_marshal_bindinfo(BINDINFO *bindinfo, RemBINDINFO *rem_bindinfo)
234{
235 rem_bindinfo->cbSize = sizeof(*rem_bindinfo);
236 rem_bindinfo->szExtraInfo = bindinfo->szExtraInfo;
237 rem_bindinfo->grfBindInfoF = bindinfo->grfBindInfoF;
238 rem_bindinfo->dwBindVerb = bindinfo->dwBindVerb;
239 rem_bindinfo->szCustomVerb = bindinfo->szCustomVerb;
240 rem_bindinfo->cbstgmedData = bindinfo->cbstgmedData;
241 rem_bindinfo->dwOptions = bindinfo->dwOptions;
242 rem_bindinfo->dwOptionsFlags = bindinfo->dwOptionsFlags;
243 rem_bindinfo->dwCodePage = bindinfo->dwCodePage;
244 rem_bindinfo->pUnk = NULL;
245 rem_bindinfo->dwReserved = bindinfo->dwReserved;
246}
247
248
250 IBindStatusCallbackEx* This, DWORD *grfBINDF, BINDINFO *bindinfo,
251 DWORD *grfBINDF2, DWORD *pdwReserved)
252{
253 RemBINDINFO rem_bindinfo = {sizeof(rem_bindinfo)};
254 RemSTGMEDIUM rem_stgmed = {0};
256
257 TRACE("(%p)->(%p %p %p %p)\n", This, grfBINDF, bindinfo, grfBINDF2, pdwReserved);
258
260 hres = IBindStatusCallbackEx_RemoteGetBindInfoEx_Proxy(This, grfBINDF, &rem_bindinfo,
261 &rem_stgmed, grfBINDF2, pdwReserved);
263 return hres;
264}
265
267 IBindStatusCallbackEx* This, DWORD *grfBINDF, RemBINDINFO *rem_bindinfo,
268 RemSTGMEDIUM *rem_stgmed, DWORD *grfBINDF2, DWORD *pdwReserved)
269{
270 BINDINFO bindinfo = {sizeof(bindinfo)};
272
273 TRACE("(%p)->(%p %p %p %p %p)\n", This, grfBINDF, rem_bindinfo, rem_stgmed, grfBINDF2, pdwReserved);
274
275 /*
276 * Although arguments suggest support for STGMEDIUM from BINDINFO, tests show
277 * that it's not supported and returned data is lost.
278 */
280 hres = IBindStatusCallbackEx_GetBindInfoEx(This, grfBINDF, &bindinfo, grfBINDF2, pdwReserved);
282 return hres;
283}
285 IBindStatusCallback* This, DWORD *grfBINDF, BINDINFO *bindinfo)
286{
287 RemBINDINFO rem_bindinfo = {sizeof(rem_bindinfo)};
288 RemSTGMEDIUM rem_stgmed = {0};
290
291 TRACE("(%p)->(%p %p)\n", This, grfBINDF, bindinfo);
292
294 hres = IBindStatusCallback_RemoteGetBindInfo_Proxy(This, grfBINDF, &rem_bindinfo, &rem_stgmed);
296 return hres;
297}
298
300 IBindStatusCallback* This, DWORD *grfBINDF,
301 RemBINDINFO *rem_bindinfo, RemSTGMEDIUM *rem_stgmed)
302{
303 BINDINFO bindinfo = {sizeof(bindinfo)};
305
306 TRACE("(%p)->(%p %p %p)\n", This, grfBINDF, rem_bindinfo, rem_stgmed);
307
309 hres = IBindStatusCallback_GetBindInfo(This, grfBINDF, &bindinfo);
311 return hres;
312}
313
316 FORMATETC *pformatetc, STGMEDIUM *pstgmed)
317{
318 RemFORMATETC rem_formatetc;
319 RemSTGMEDIUM *rem_stgmed;
321
322 TRACE("(%p)->(%x %u %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
323
324 hres = marshal_stgmed(pstgmed, &rem_stgmed);
325 if(FAILED(hres))
326 return hres;
327
328 rem_formatetc.cfFormat = pformatetc->cfFormat;
329 rem_formatetc.ptd = 0;
330 rem_formatetc.dwAspect = pformatetc->dwAspect;
331 rem_formatetc.lindex = pformatetc->lindex;
332 rem_formatetc.tymed = pformatetc->tymed;
333
334 hres = IBindStatusCallback_RemoteOnDataAvailable_Proxy(This, grfBSCF, dwSize, &rem_formatetc, rem_stgmed);
335
337 return hres;
338}
339
342 RemFORMATETC *pformatetc, RemSTGMEDIUM *pstgmed)
343{
344 STGMEDIUM stgmed = { TYMED_NULL };
345 FORMATETC formatetc;
347
348 TRACE("(%p)->(%x %u %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
349
350 hres = unmarshal_stgmed(pstgmed, &stgmed);
351 if(FAILED(hres))
352 return hres;
353
354 formatetc.cfFormat = pformatetc->cfFormat;
355 formatetc.ptd = NULL;
356 formatetc.dwAspect = pformatetc->dwAspect;
357 formatetc.lindex = pformatetc->lindex;
358 formatetc.tymed = pformatetc->tymed;
359
360 hres = IBindStatusCallback_OnDataAvailable(This, grfBSCF, dwSize, &formatetc, &stgmed);
361
362 ReleaseStgMedium(&stgmed);
363 return hres;
364}
365
367 CLSID *pclsidProtocol, DWORD *pdwResult,
368 LPOLESTR *pszResult, DWORD *pdwReserved)
369{
370 FIXME("stub\n");
371 return E_NOTIMPL;
372}
373
375 CLSID *pclsidProtocol, DWORD *pdwResult,
376 LPOLESTR *pszResult, DWORD dwReserved)
377{
378 FIXME("stub\n");
379 return E_NOTIMPL;
380}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
PBATCH_CONTEXT bc
Definition: batch.c:67
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define CALLBACK
Definition: compat.h:35
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
HRESULT WINAPI CoUnmarshalInterface(IStream *pStream, REFIID riid, LPVOID *ppv)
Definition: marshal.c:1981
HRESULT WINAPI CoMarshalInterface(IStream *pStream, REFIID riid, IUnknown *pUnk, DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:1876
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
static void proxy_marshal_bindinfo(BINDINFO *bindinfo, RemBINDINFO *rem_bindinfo)
Definition: usrmarshal.c:198
HRESULT CALLBACK IBindHost_MonikerBindToStorage_Proxy(IBindHost *This, IMoniker *moniker, IBindCtx *bc, IBindStatusCallback *bsc, REFIID riid, void **obj)
Definition: usrmarshal.c:57
static void stub_unmarshal_bindinfo(RemBINDINFO *rem_bindinfo, BINDINFO *bindinfo)
Definition: usrmarshal.c:221
HRESULT CALLBACK IWinInetHttpInfo_QueryInfo_Proxy(IWinInetHttpInfo *This, DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, DWORD *pdwReserved)
Definition: usrmarshal.c:27
HRESULT CALLBACK IBindStatusCallbackEx_GetBindInfoEx_Proxy(IBindStatusCallbackEx *This, DWORD *grfBINDF, BINDINFO *bindinfo, DWORD *grfBINDF2, DWORD *pdwReserved)
Definition: usrmarshal.c:249
HRESULT CALLBACK IBinding_GetBindResult_Proxy(IBinding *This, CLSID *pclsidProtocol, DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
Definition: usrmarshal.c:366
HRESULT __RPC_STUB IBindStatusCallbackEx_GetBindInfoEx_Stub(IBindStatusCallbackEx *This, DWORD *grfBINDF, RemBINDINFO *rem_bindinfo, RemSTGMEDIUM *rem_stgmed, DWORD *grfBINDF2, DWORD *pdwReserved)
Definition: usrmarshal.c:266
HRESULT __RPC_STUB IBindHost_MonikerBindToObject_Stub(IBindHost *This, IMoniker *moniker, IBindCtx *bc, IBindStatusCallback *bsc, REFIID riid, IUnknown **obj)
Definition: usrmarshal.c:81
static void stub_marshal_bindinfo(BINDINFO *bindinfo, RemBINDINFO *rem_bindinfo)
Definition: usrmarshal.c:233
static HRESULT marshal_stgmed(STGMEDIUM *stgmed, RemSTGMEDIUM **ret)
Definition: usrmarshal.c:89
HRESULT CALLBACK IBindHost_MonikerBindToObject_Proxy(IBindHost *This, IMoniker *moniker, IBindCtx *bc, IBindStatusCallback *bsc, REFIID riid, void **obj)
Definition: usrmarshal.c:73
HRESULT CALLBACK IBindStatusCallback_OnDataAvailable_Proxy(IBindStatusCallback *This, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
Definition: usrmarshal.c:314
HRESULT __RPC_STUB IBindStatusCallback_GetBindInfo_Stub(IBindStatusCallback *This, DWORD *grfBINDF, RemBINDINFO *rem_bindinfo, RemSTGMEDIUM *rem_stgmed)
Definition: usrmarshal.c:299
HRESULT __RPC_STUB IBindHost_MonikerBindToStorage_Stub(IBindHost *This, IMoniker *moniker, IBindCtx *bc, IBindStatusCallback *bsc, REFIID riid, IUnknown **obj)
Definition: usrmarshal.c:65
HRESULT CALLBACK IWinInetInfo_QueryOption_Proxy(IWinInetInfo *This, DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf)
Definition: usrmarshal.c:43
HRESULT __RPC_STUB IBinding_GetBindResult_Stub(IBinding *This, CLSID *pclsidProtocol, DWORD *pdwResult, LPOLESTR *pszResult, DWORD dwReserved)
Definition: usrmarshal.c:374
HRESULT __RPC_STUB IBindStatusCallback_OnDataAvailable_Stub(IBindStatusCallback *This, DWORD grfBSCF, DWORD dwSize, RemFORMATETC *pformatetc, RemSTGMEDIUM *pstgmed)
Definition: usrmarshal.c:340
HRESULT CALLBACK IBindStatusCallback_GetBindInfo_Proxy(IBindStatusCallback *This, DWORD *grfBINDF, BINDINFO *bindinfo)
Definition: usrmarshal.c:284
HRESULT __RPC_STUB IWinInetHttpInfo_QueryInfo_Stub(IWinInetHttpInfo *This, DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, DWORD *pdwReserved)
Definition: usrmarshal.c:35
static HRESULT unmarshal_stgmed(RemSTGMEDIUM *rem_stgmed, STGMEDIUM *stgmed)
Definition: usrmarshal.c:155
static void proxy_unmarshal_bindinfo(RemBINDINFO *rem_bindinfo, BINDINFO *bindinfo)
Definition: usrmarshal.c:207
HRESULT __RPC_STUB IWinInetInfo_QueryOption_Stub(IWinInetInfo *This, DWORD dwOption, BYTE *pBuffer, DWORD *pcbBuf)
Definition: usrmarshal.c:50
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HRESULT hres
Definition: protocol.c:465
static LPOLESTR
Definition: stg_prop.c:27
static BINDINFO rem_bindinfo
Definition: misc.c:1960
static STGMEDIUM rem_stgmed
Definition: misc.c:2026
static IBindStatusCallbackEx bsc
Definition: url.c:2150
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
_In_ UINT _In_ DWORD _Out_ DWORD * pdwResult
Definition: ntgdi.h:250
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
PVOID pBuffer
#define __RPC_STUB
Definition: rpc.h:66
int zero
Definition: sehframes.cpp:29
#define TRACE(s)
Definition: solgame.cpp:4
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
Definition: main.c:40
Definition: parse.h:23
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
int ret
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
unsigned char BYTE
Definition: xxhash.c:193