source: trunk/src/ole32/marshal.c@ 10367

Last change on this file since 10367 was 9400, checked in by sandervl, 23 years ago

Wine resync

File size: 18.0 KB
Line 
1/*
2 * Marshaling library
3 *
4 * Copyright 2002 Marcus Meissner
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "config.h"
22
23#include <stdlib.h>
24#include <stdio.h>
25#include <string.h>
26#include <assert.h>
27
28#include "windef.h"
29#include "objbase.h"
30#include "ole2.h"
31#include "ole2ver.h"
32#include "rpc.h"
33#include "winerror.h"
34#include "winreg.h"
35#include "wownt32.h"
36#include "wtypes.h"
37#include "wine/unicode.h"
38#include "wine/obj_base.h"
39#include "wine/obj_clientserver.h"
40#include "wine/obj_misc.h"
41#include "wine/obj_marshal.h"
42#include "wine/obj_storage.h"
43#include "wine/obj_channel.h"
44#include "wine/winbase16.h"
45#include "compobj_private.h"
46#include "ifs.h"
47
48#include "wine/debug.h"
49
50WINE_DEFAULT_DEBUG_CHANNEL(ole);
51
52/* Marshaling just passes a unique identifier to the remote client,
53 * that makes it possible to find the passed interface again.
54 *
55 * So basically we need a set of values that make it unique.
56 *
57 * Process Identifier, Object IUnknown ptr, IID
58 *
59 * Note that the IUnknown_QI(ob,xiid,&ppv) always returns the SAME ppv value!
60 */
61
62typedef struct _mid2unknown {
63 wine_marshal_id mid;
64 LPUNKNOWN pUnk;
65} mid2unknown;
66
67typedef struct _mid2stub {
68 wine_marshal_id mid;
69 IRpcStubBuffer *stub;
70 LPUNKNOWN pUnkServer;
71} mid2stub;
72
73static mid2stub *stubs = NULL;
74static int nrofstubs = 0;
75
76static mid2unknown *proxies = NULL;
77static int nrofproxies = 0;
78
79HRESULT
80MARSHAL_Find_Stub_Server(wine_marshal_id *mid,LPUNKNOWN *punk) {
81 int i;
82
83 for (i=0;i<nrofstubs;i++) {
84 if (MARSHAL_Compare_Mids_NoInterface(mid,&(stubs[i].mid))) {
85 *punk = stubs[i].pUnkServer;
86 IUnknown_AddRef((*punk));
87 return S_OK;
88 }
89 }
90 return E_FAIL;
91}
92
93HRESULT
94MARSHAL_Find_Stub_Buffer(wine_marshal_id *mid,IRpcStubBuffer **stub) {
95 int i;
96
97 for (i=0;i<nrofstubs;i++) {
98 if (MARSHAL_Compare_Mids(mid,&(stubs[i].mid))) {
99 *stub = stubs[i].stub;
100 IUnknown_AddRef((*stub));
101 return S_OK;
102 }
103 }
104 return E_FAIL;
105}
106
107HRESULT
108MARSHAL_Find_Stub(wine_marshal_id *mid,LPUNKNOWN *pUnk) {
109 int i;
110
111 for (i=0;i<nrofstubs;i++) {
112 if (MARSHAL_Compare_Mids(mid,&(stubs[i].mid))) {
113 *pUnk = stubs[i].pUnkServer;
114 IUnknown_AddRef((*pUnk));
115 return S_OK;
116 }
117 }
118 return E_FAIL;
119}
120
121HRESULT
122MARSHAL_Register_Stub(wine_marshal_id *mid,LPUNKNOWN pUnk,IRpcStubBuffer *stub) {
123 LPUNKNOWN xPunk;
124 if (!MARSHAL_Find_Stub(mid,&xPunk)) {
125 FIXME("Already have entry for (%lx/%s)!\n",mid->objectid,debugstr_guid(&(mid->iid)));
126 return S_OK;
127 }
128 if (nrofstubs)
129 stubs=HeapReAlloc(GetProcessHeap(),0,stubs,sizeof(stubs[0])*(nrofstubs+1));
130 else
131 stubs=HeapAlloc(GetProcessHeap(),0,sizeof(stubs[0]));
132 if (!stubs) return E_OUTOFMEMORY;
133 stubs[nrofstubs].stub = stub;
134 stubs[nrofstubs].pUnkServer = pUnk;
135 memcpy(&(stubs[nrofstubs].mid),mid,sizeof(*mid));
136 nrofstubs++;
137 return S_OK;
138}
139
140HRESULT
141MARSHAL_Find_Proxy(wine_marshal_id *mid,LPUNKNOWN *punk) {
142 int i;
143
144 for (i=0;i<nrofproxies;i++)
145 if (MARSHAL_Compare_Mids(mid,&(proxies[i].mid))) {
146 *punk = proxies[i].pUnk;
147 IUnknown_AddRef((*punk));
148 return S_OK;
149 }
150 return E_FAIL;
151}
152
153HRESULT
154MARSHAL_Find_Proxy_Object(wine_marshal_id *mid,LPUNKNOWN *punk) {
155 int i;
156
157 for (i=0;i<nrofproxies;i++)
158 if (MARSHAL_Compare_Mids_NoInterface(mid,&(proxies[i].mid))) {
159 *punk = proxies[i].pUnk;
160 IUnknown_AddRef((*punk));
161 return S_OK;
162 }
163 return E_FAIL;
164}
165
166HRESULT
167MARSHAL_Register_Proxy(wine_marshal_id *mid,LPUNKNOWN punk) {
168 int i;
169
170 for (i=0;i<nrofproxies;i++) {
171 if (MARSHAL_Compare_Mids(mid,&(proxies[i].mid))) {
172 ERR("Already have mid?\n");
173 return E_FAIL;
174 }
175 }
176 if (nrofproxies)
177 proxies = HeapReAlloc(GetProcessHeap(),0,proxies,sizeof(proxies[0])*(nrofproxies+1));
178 else
179 proxies = HeapAlloc(GetProcessHeap(),0,sizeof(proxies[0]));
180 memcpy(&(proxies[nrofproxies].mid),mid,sizeof(*mid));
181 proxies[nrofproxies].pUnk = punk;
182 nrofproxies++;
183 IUnknown_AddRef(punk);
184 return S_OK;
185}
186
187/********************** StdMarshal implementation ****************************/
188typedef struct _StdMarshalImpl {
189 ICOM_VTABLE(IMarshal) *lpvtbl;
190 DWORD ref;
191
192 IID iid;
193 DWORD dwDestContext;
194 LPVOID pvDestContext;
195 DWORD mshlflags;
196} StdMarshalImpl;
197
198HRESULT WINAPI
199StdMarshalImpl_QueryInterface(LPMARSHAL iface,REFIID riid,LPVOID *ppv) {
200 *ppv = NULL;
201 if (IsEqualIID(&IID_IUnknown,riid) || IsEqualIID(&IID_IMarshal,riid)) {
202 *ppv = iface;
203 IUnknown_AddRef(iface);
204 return S_OK;
205 }
206 FIXME("No interface for %s.\n",debugstr_guid(riid));
207 return E_NOINTERFACE;
208}
209
210ULONG WINAPI
211StdMarshalImpl_AddRef(LPMARSHAL iface) {
212 ICOM_THIS(StdMarshalImpl,iface);
213 This->ref++;
214 return This->ref;
215}
216
217ULONG WINAPI
218StdMarshalImpl_Release(LPMARSHAL iface) {
219 ICOM_THIS(StdMarshalImpl,iface);
220 This->ref--;
221
222 if (This->ref)
223 return This->ref;
224 HeapFree(GetProcessHeap(),0,This);
225 return 0;
226}
227
228HRESULT WINAPI
229StdMarshalImpl_GetUnmarshalClass(
230 LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
231 void* pvDestContext, DWORD mshlflags, CLSID* pCid
232) {
233 memcpy(pCid,&CLSID_DfMarshal,sizeof(CLSID_DfMarshal));
234 return S_OK;
235}
236
237HRESULT WINAPI
238StdMarshalImpl_GetMarshalSizeMax(
239 LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
240 void* pvDestContext, DWORD mshlflags, DWORD* pSize
241) {
242 *pSize = sizeof(wine_marshal_id)+sizeof(wine_marshal_data);
243 return S_OK;
244}
245
246HRESULT WINAPI
247StdMarshalImpl_MarshalInterface(
248 LPMARSHAL iface, IStream *pStm,REFIID riid, void* pv, DWORD dwDestContext,
249 void* pvDestContext, DWORD mshlflags
250) {
251 wine_marshal_id mid;
252 wine_marshal_data md;
253 IUnknown *pUnk;
254 ULONG res;
255 HRESULT hres;
256 IRpcStubBuffer *stub;
257 IPSFactoryBuffer *psfacbuf;
258
259 TRACE("(...,%s,...)\n",debugstr_guid(riid));
260 IUnknown_QueryInterface((LPUNKNOWN)pv,&IID_IUnknown,(LPVOID*)&pUnk);
261 mid.processid = GetCurrentProcessId();
262 mid.objectid = (DWORD)pUnk; /* FIXME */
263 IUnknown_Release(pUnk);
264 memcpy(&mid.iid,riid,sizeof(mid.iid));
265 md.dwDestContext = dwDestContext;
266 md.mshlflags = mshlflags;
267 hres = IStream_Write(pStm,&mid,sizeof(mid),&res);
268 if (hres) return hres;
269 hres = IStream_Write(pStm,&md,sizeof(md),&res);
270 if (hres) return hres;
271
272 if (SUCCEEDED(MARSHAL_Find_Stub(&mid,&pUnk))) {
273 IUnknown_Release(pUnk);
274 return S_OK;
275 }
276 hres = get_facbuf_for_iid(riid,&psfacbuf);
277 if (hres) return hres;
278 hres = IPSFactoryBuffer_CreateStub(psfacbuf,riid,pv,&stub);
279 IPSFactoryBuffer_Release(psfacbuf);
280 if (hres) {
281 FIXME("Failed to create a stub for %s\n",debugstr_guid(riid));
282 return hres;
283 }
284 IUnknown_QueryInterface((LPUNKNOWN)pv,riid,(LPVOID*)&pUnk);
285 MARSHAL_Register_Stub(&mid,pUnk,stub);
286 IUnknown_Release(pUnk);
287 return S_OK;
288}
289
290HRESULT WINAPI
291StdMarshalImpl_UnmarshalInterface(
292 LPMARSHAL iface, IStream *pStm, REFIID riid, void **ppv
293) {
294 wine_marshal_id mid;
295 wine_marshal_data md;
296 ULONG res;
297 HRESULT hres;
298 IPSFactoryBuffer *psfacbuf;
299 IRpcProxyBuffer *rpcproxy;
300 IRpcChannelBuffer *chanbuf;
301
302 TRACE("(...,%s,....)\n",debugstr_guid(riid));
303 hres = IStream_Read(pStm,&mid,sizeof(mid),&res);
304 if (hres) return hres;
305 hres = IStream_Read(pStm,&md,sizeof(md),&res);
306 if (hres) return hres;
307 if (SUCCEEDED(MARSHAL_Find_Stub(&mid,(LPUNKNOWN*)ppv))) {
308 FIXME("Calling back to ourselves for %s!\n",debugstr_guid(riid));
309 return S_OK;
310 }
311 hres = get_facbuf_for_iid(riid,&psfacbuf);
312 if (hres) return hres;
313 hres = IPSFactoryBuffer_CreateProxy(psfacbuf,NULL,riid,&rpcproxy,ppv);
314 if (hres) {
315 FIXME("Failed to create a proxy for %s\n",debugstr_guid(riid));
316 return hres;
317 }
318 hres = PIPE_GetNewPipeBuf(&mid,&chanbuf);
319 if (hres) {
320 ERR("Failed to get an rpc channel buffer for %s\n",debugstr_guid(riid));
321 } else {
322 IRpcProxyBuffer_Connect(rpcproxy,chanbuf);
323 IRpcProxyBuffer_Release(rpcproxy); /* no need */
324 }
325 IPSFactoryBuffer_Release(psfacbuf);
326 return hres;
327}
328
329HRESULT WINAPI
330StdMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm) {
331 FIXME("(), stub!\n");
332 return S_OK;
333}
334
335HRESULT WINAPI
336StdMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwReserved) {
337 FIXME("(), stub!\n");
338 return S_OK;
339}
340
341ICOM_VTABLE(IMarshal) stdmvtbl = {
342 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
343 StdMarshalImpl_QueryInterface,
344 StdMarshalImpl_AddRef,
345 StdMarshalImpl_Release,
346 StdMarshalImpl_GetUnmarshalClass,
347 StdMarshalImpl_GetMarshalSizeMax,
348 StdMarshalImpl_MarshalInterface,
349 StdMarshalImpl_UnmarshalInterface,
350 StdMarshalImpl_ReleaseMarshalData,
351 StdMarshalImpl_DisconnectObject
352};
353
354/***********************************************************************
355 * CoGetStandardMarshal [OLE32.23]
356 *
357 * When the COM library in the client process receives a marshaled
358 * interface pointer, it looks for a CLSID to be used in creating a proxy
359 * for the purposes of unmarshaling the packet. If the packet does not
360 * contain a CLSID for the proxy, COM calls CoGetStandardMarshal, passing a
361 * NULL pUnk value.
362 * This function creates a standard proxy in the client process and returns
363 * a pointer to that proxy's implementation of IMarshal.
364 * COM uses this pointer to call CoUnmarshalInterface to retrieve the pointer
365 * to the requested interface.
366 */
367HRESULT WINAPI
368CoGetStandardMarshal(
369 REFIID riid,IUnknown *pUnk,DWORD dwDestContext,LPVOID pvDestContext,
370 DWORD mshlflags, LPMARSHAL *pMarshal
371) {
372 StdMarshalImpl *dm;
373
374 if (pUnk == NULL) {
375 FIXME("(%s,NULL,%lx,%p,%lx,%p), unimplemented yet.\n",
376 debugstr_guid(riid),dwDestContext,pvDestContext,mshlflags,pMarshal
377 );
378 return E_FAIL;
379 }
380 TRACE("(%s,%p,%lx,%p,%lx,%p)\n",
381 debugstr_guid(riid),pUnk,dwDestContext,pvDestContext,mshlflags,pMarshal
382 );
383#ifdef __WIN32OS2__
384 *pMarshal = HeapAlloc(GetProcessHeap(),0,sizeof(StdMarshalImpl));
385 dm = (StdMarshalImpl*) *pMarshal;
386#else
387 dm = (StdMarshalImpl*) *pMarshal = HeapAlloc(GetProcessHeap(),0,sizeof(StdMarshalImpl));
388#endif
389 if (!dm) return E_FAIL;
390 dm->lpvtbl = &stdmvtbl;
391 dm->ref = 1;
392
393 memcpy(&dm->iid,riid,sizeof(dm->iid));
394 dm->dwDestContext = dwDestContext;
395 dm->pvDestContext = pvDestContext;
396 dm->mshlflags = mshlflags;
397 return S_OK;
398}
399
400/* Helper function for getting Marshaler */
401static HRESULT WINAPI
402_GetMarshaller(REFIID riid, IUnknown *pUnk,DWORD dwDestContext,
403 void *pvDestContext, DWORD mshlFlags, LPMARSHAL *pMarshal
404) {
405 HRESULT hres;
406
407 if (!pUnk)
408 return E_POINTER;
409 hres = IUnknown_QueryInterface(pUnk,&IID_IMarshal,(LPVOID*)pMarshal);
410 if (hres)
411 hres = CoGetStandardMarshal(riid,pUnk,dwDestContext,pvDestContext,mshlFlags,pMarshal);
412 return hres;
413}
414
415/***********************************************************************
416 * CoGetMarshalSizeMax [OLE32.21]
417 */
418HRESULT WINAPI
419CoGetMarshalSizeMax(ULONG *pulSize, REFIID riid, IUnknown *pUnk,
420 DWORD dwDestContext, void *pvDestContext, DWORD mshlFlags
421) {
422 HRESULT hres;
423 LPMARSHAL pMarshal;
424
425 hres = _GetMarshaller(riid,pUnk,dwDestContext,pvDestContext,mshlFlags,&pMarshal);
426 if (hres)
427 return hres;
428 hres = IMarshal_GetMarshalSizeMax(pMarshal,riid,pUnk,dwDestContext,pvDestContext,mshlFlags,pulSize);
429 *pulSize += sizeof(wine_marshal_id)+sizeof(wine_marshal_data)+sizeof(CLSID);
430 IMarshal_Release(pMarshal);
431 return hres;
432}
433
434
435/***********************************************************************
436 * CoMarshalInterface [OLE32.34]
437 */
438HRESULT WINAPI
439CoMarshalInterface( IStream *pStm, REFIID riid, IUnknown *pUnk,
440 DWORD dwDestContext, void *pvDestContext, DWORD mshlflags
441) {
442 HRESULT hres;
443 LPMARSHAL pMarshal;
444 CLSID xclsid;
445 ULONG writeres;
446 wine_marshal_id mid;
447 wine_marshal_data md;
448 ULONG res;
449 IUnknown *pUnknown;
450
451 TRACE("(%p, %s, %p, %lx, %p, %lx)\n",
452 pStm,debugstr_guid(riid),pUnk,dwDestContext,pvDestContext,mshlflags
453 );
454 STUBMGR_Start(); /* Just to be sure we have one running. */
455 mid.processid = GetCurrentProcessId();
456 IUnknown_QueryInterface(pUnk,&IID_IUnknown,(LPVOID*)&pUnknown);
457 mid.objectid = (DWORD)pUnknown;
458 IUnknown_Release(pUnknown);
459 memcpy(&mid.iid,riid,sizeof(mid.iid));
460 md.dwDestContext = dwDestContext;
461 md.mshlflags = mshlflags;
462 hres = IStream_Write(pStm,&mid,sizeof(mid),&res);
463 if (hres) return hres;
464 hres = IStream_Write(pStm,&md,sizeof(md),&res);
465 if (hres) return hres;
466 hres = _GetMarshaller(riid,pUnk,dwDestContext,pvDestContext,mshlflags,&pMarshal);
467 if (hres) {
468 FIXME("Failed to get marshaller, %lx?\n",hres);
469 return hres;
470 }
471 hres = IMarshal_GetUnmarshalClass(pMarshal,riid,pUnk,dwDestContext,pvDestContext,mshlflags,&xclsid);
472 if (hres) {
473 FIXME("IMarshal:GetUnmarshalClass failed, %lx\n",hres);
474 goto release_marshal;
475 }
476 hres = IStream_Write(pStm,&xclsid,sizeof(xclsid),&writeres);
477 if (hres) {
478 FIXME("Stream write failed, %lx\n",hres);
479 goto release_marshal;
480 }
481 hres = IMarshal_MarshalInterface(pMarshal,pStm,riid,pUnk,dwDestContext,pvDestContext,mshlflags);
482 if (hres) {
483 if (IsEqualGUID(riid,&IID_IClassFactory)) {
484 MESSAGE("\nERROR: You need to merge the 'winedefault.reg' file into your\n");
485 MESSAGE(" Wine registry by running: `regedit winedefault.reg'\n\n");
486 } else {
487 if (IsEqualGUID(riid,&IID_IOleObject)) {
488 ERR("WINE currently cannot marshal IOleObject interfaces. This means you cannot embed/link OLE objects between applications.\n");
489 } else {
490 FIXME("Failed to marshal the interface %s, %lx?\n",debugstr_guid(riid),hres);
491 }
492 }
493 goto release_marshal;
494 }
495release_marshal:
496 IMarshal_Release(pMarshal);
497 return hres;
498}
499
500
501/***********************************************************************
502 * CoUnmarshalInterface [OLE32.50]
503 */
504HRESULT WINAPI
505CoUnmarshalInterface(IStream *pStm, REFIID riid, LPVOID *ppv) {
506 HRESULT hres;
507 wine_marshal_id mid;
508 wine_marshal_data md;
509 ULONG res;
510 LPMARSHAL pMarshal;
511 LPUNKNOWN pUnk;
512 CLSID xclsid;
513
514 TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(riid),ppv);
515
516 hres = IStream_Read(pStm,&mid,sizeof(mid),&res);
517 if (hres) {
518 FIXME("Stream read 1 failed, %lx, (%ld of %d)\n",hres,res,sizeof(mid));
519 return hres;
520 }
521 hres = IStream_Read(pStm,&md,sizeof(md),&res);
522 if (hres) {
523 FIXME("Stream read 2 failed, %lx, (%ld of %d)\n",hres,res,sizeof(md));
524 return hres;
525 }
526 hres = IStream_Read(pStm,&xclsid,sizeof(xclsid),&res);
527 if (hres) {
528 FIXME("Stream read 3 failed, %lx, (%ld of %d)\n",hres,res,sizeof(xclsid));
529 return hres;
530 }
531 hres=CoCreateInstance(&xclsid,NULL,CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER,&IID_IMarshal,(void**)&pUnk);
532 if (hres) {
533 FIXME("Failed to create instance of unmarshaller %s.\n",debugstr_guid(&xclsid));
534 return hres;
535 }
536 hres = _GetMarshaller(riid,pUnk,md.dwDestContext,NULL,md.mshlflags,&pMarshal);
537 if (hres) {
538 FIXME("Failed to get unmarshaller, %lx?\n",hres);
539 return hres;
540 }
541 hres = IMarshal_UnmarshalInterface(pMarshal,pStm,riid,ppv);
542 if (hres) {
543 FIXME("Failed to Unmarshal the interface, %lx?\n",hres);
544 goto release_marshal;
545 }
546release_marshal:
547 IMarshal_Release(pMarshal);
548 return hres;
549}
550
551/***********************************************************************
552 * CoMarshalInterThreadInterfaceInStream [OLE32.33]
553 *
554 * Marshal interfaces across threads. We don't have a thread distinction,
555 * meaning most interfaces just work across different threads, the RPC
556 * handles it.
557 */
558HRESULT WINAPI
559CoMarshalInterThreadInterfaceInStream(
560 REFIID riid, LPUNKNOWN pUnk, LPSTREAM * ppStm
561) {
562 ULONG res;
563 ULARGE_INTEGER xpos;
564 LARGE_INTEGER seekto;
565 HRESULT hres;
566
567 TRACE("(,%s,)\n",debugstr_guid(riid));
568 hres = CreateStreamOnHGlobal(0, TRUE, ppStm);
569 if (hres) return hres;
570 /* CoMarshalInterface(...); */
571 hres = IStream_Write(*ppStm,&pUnk,sizeof(LPUNKNOWN),&res);
572 if (hres) return hres;
573 memset(&seekto,0,sizeof(seekto));
574 IStream_Seek(*ppStm,seekto,SEEK_SET,&xpos);
575 return S_OK;
576}
577
578/***********************************************************************
579 * CoGetInterfaceAndReleaseStream [OLE32.19]
580 */
581HRESULT WINAPI
582CoGetInterfaceAndReleaseStream(LPSTREAM pStm,REFIID riid, LPVOID *ppv) {
583 ULONG res;
584 HRESULT hres;
585 LPUNKNOWN pUnk;
586
587 TRACE("(,%s,)\n",debugstr_guid(riid));
588 /* CoUnmarshalInterface(...); */
589 hres = IStream_Read(pStm,&pUnk,sizeof(LPUNKNOWN),&res);
590 if (hres) return hres;
591 IStream_Release(pStm);
592 return IUnknown_QueryInterface(pUnk,riid,ppv);
593}
594
595static HRESULT WINAPI
596SMCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv) {
597 *ppv = NULL;
598 if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IClassFactory)) {
599 *ppv = (LPVOID)iface;
600 return S_OK;
601 }
602 return E_NOINTERFACE;
603}
604static ULONG WINAPI SMCF_AddRef(LPCLASSFACTORY iface) { return 2; }
605static ULONG WINAPI SMCF_Release(LPCLASSFACTORY iface) { return 1; }
606
607static HRESULT WINAPI
608SMCF_CreateInstance(
609 LPCLASSFACTORY iface, LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv
610) {
611 if (IsEqualIID(riid,&IID_IMarshal)) {
612 StdMarshalImpl *dm;
613 dm=(StdMarshalImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(StdMarshalImpl));
614 if (!dm)
615 return E_FAIL;
616 dm->lpvtbl = &stdmvtbl;
617 dm->ref = 1;
618 *ppv = (LPVOID)dm;
619 return S_OK;
620 }
621 FIXME("(%s), not supported.\n",debugstr_guid(riid));
622 return E_NOINTERFACE;
623}
624
625static HRESULT WINAPI
626SMCF_LockServer(LPCLASSFACTORY iface, BOOL fLock) {
627 FIXME("(%d), stub!\n",fLock);
628 return S_OK;
629}
630
631static ICOM_VTABLE(IClassFactory) dfmarshalcfvtbl = {
632 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
633 SMCF_QueryInterface,
634 SMCF_AddRef,
635 SMCF_Release,
636 SMCF_CreateInstance,
637 SMCF_LockServer
638};
639static ICOM_VTABLE(IClassFactory) *pdfmarshalcfvtbl = &dfmarshalcfvtbl;
640
641HRESULT
642MARSHAL_GetStandardMarshalCF(LPVOID *ppv) {
643 *ppv = &pdfmarshalcfvtbl;
644 return S_OK;
645}
Note: See TracBrowser for help on using the repository browser.