2 * Pointer and Objref Monikers Implementation
4 * Copyright 1999 Noomen Hamza
5 * Copyright 2008 Robert Shearman (for CodeWeavers)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
34 #include "wine/debug.h"
35 #include "wine/heap.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
40 /* PointerMoniker data structure */
41 typedef struct PointerMonikerImpl
43 IMoniker IMoniker_iface
;
44 IMarshal IMarshal_iface
;
51 static inline PointerMonikerImpl
*impl_from_IMoniker(IMoniker
*iface
)
53 return CONTAINING_RECORD(iface
, PointerMonikerImpl
, IMoniker_iface
);
56 static PointerMonikerImpl
*impl_from_IMarshal(IMarshal
*iface
)
58 return CONTAINING_RECORD(iface
, PointerMonikerImpl
, IMarshal_iface
);
61 static PointerMonikerImpl
*unsafe_impl_from_IMoniker(IMoniker
*iface
);
63 static HRESULT WINAPI
PointerMonikerImpl_QueryInterface(IMoniker
*iface
, REFIID riid
, void **ppvObject
)
65 PointerMonikerImpl
*moniker
= impl_from_IMoniker(iface
);
67 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), ppvObject
);
74 if (IsEqualIID(&IID_IUnknown
, riid
) ||
75 IsEqualIID(&IID_IPersist
, riid
) ||
76 IsEqualIID(&IID_IPersistStream
, riid
) ||
77 IsEqualIID(&IID_IMoniker
, riid
) ||
78 IsEqualGUID(&CLSID_PointerMoniker
, riid
))
82 else if (IsEqualIID(&IID_IMarshal
, riid
))
83 *ppvObject
= &moniker
->IMarshal_iface
;
88 IMoniker_AddRef(iface
);
93 static ULONG WINAPI
PointerMonikerImpl_AddRef(IMoniker
*iface
)
95 PointerMonikerImpl
*moniker
= impl_from_IMoniker(iface
);
96 ULONG refcount
= InterlockedIncrement(&moniker
->refcount
);
98 TRACE("%p, refcount %lu.\n", iface
, refcount
);
103 static ULONG WINAPI
PointerMonikerImpl_Release(IMoniker
*iface
)
105 PointerMonikerImpl
*moniker
= impl_from_IMoniker(iface
);
106 ULONG refcount
= InterlockedDecrement(&moniker
->refcount
);
108 TRACE("%p, refcount %lu.\n", iface
, refcount
);
112 if (moniker
->pObject
) IUnknown_Release(moniker
->pObject
);
119 /******************************************************************************
120 * PointerMoniker_GetClassID
121 ******************************************************************************/
122 static HRESULT WINAPI
123 PointerMonikerImpl_GetClassID(IMoniker
* iface
,CLSID
*pClassID
)
125 TRACE("(%p,%p)\n",iface
,pClassID
);
130 *pClassID
= CLSID_PointerMoniker
;
135 /******************************************************************************
136 * PointerMoniker_IsDirty
137 ******************************************************************************/
138 static HRESULT WINAPI
139 PointerMonikerImpl_IsDirty(IMoniker
* iface
)
141 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
142 method in the OLE-provided moniker interfaces always return S_FALSE because
143 their internal state never changes. */
145 TRACE("(%p)\n",iface
);
150 /******************************************************************************
151 * PointerMoniker_Load
152 ******************************************************************************/
153 static HRESULT WINAPI
154 PointerMonikerImpl_Load(IMoniker
* iface
,IStream
* pStm
)
156 TRACE("(%p)\n", pStm
);
161 /******************************************************************************
162 * PointerMoniker_Save
163 ******************************************************************************/
164 static HRESULT WINAPI
165 PointerMonikerImpl_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
)
167 TRACE("(%p, %d)\n", pStm
, fClearDirty
);
172 /******************************************************************************
173 * PointerMoniker_GetSizeMax
176 * pcbSize [out] Pointer to size of stream needed to save object
177 ******************************************************************************/
178 static HRESULT WINAPI
179 PointerMonikerImpl_GetSizeMax(IMoniker
* iface
, ULARGE_INTEGER
* pcbSize
)
181 TRACE("(%p,%p)\n",iface
,pcbSize
);
186 pcbSize
->u
.LowPart
= 0;
187 pcbSize
->u
.HighPart
= 0;
192 /******************************************************************************
193 * PointerMoniker_BindToObject
194 ******************************************************************************/
195 static HRESULT WINAPI
196 PointerMonikerImpl_BindToObject(IMoniker
* iface
, IBindCtx
* pbc
, IMoniker
* pmkToLeft
,
197 REFIID riid
, VOID
** ppvResult
)
199 PointerMonikerImpl
*This
= impl_from_IMoniker(iface
);
201 TRACE("(%p,%p,%p,%s,%p)\n",iface
,pbc
,pmkToLeft
,debugstr_guid(riid
),ppvResult
);
206 return IUnknown_QueryInterface(This
->pObject
, riid
, ppvResult
);
209 /******************************************************************************
210 * PointerMoniker_BindToStorage
211 ******************************************************************************/
212 static HRESULT WINAPI
213 PointerMonikerImpl_BindToStorage(IMoniker
* iface
, IBindCtx
* pbc
, IMoniker
* pmkToLeft
,
214 REFIID riid
, VOID
** ppvResult
)
216 PointerMonikerImpl
*This
= impl_from_IMoniker(iface
);
218 TRACE("(%p,%p,%p,%s,%p)\n",iface
,pbc
,pmkToLeft
,debugstr_guid(riid
),ppvResult
);
223 return IUnknown_QueryInterface(This
->pObject
, riid
, ppvResult
);
226 /******************************************************************************
227 * PointerMoniker_Reduce
228 ******************************************************************************/
229 static HRESULT WINAPI
230 PointerMonikerImpl_Reduce(IMoniker
* iface
, IBindCtx
* pbc
, DWORD dwReduceHowFar
,
231 IMoniker
** ppmkToLeft
, IMoniker
** ppmkReduced
)
233 TRACE("%p, %p, %ld, %p, %p.\n", iface
, pbc
, dwReduceHowFar
, ppmkToLeft
, ppmkReduced
);
235 if (ppmkReduced
==NULL
)
238 PointerMonikerImpl_AddRef(iface
);
242 return MK_S_REDUCED_TO_SELF
;
245 static HRESULT WINAPI
PointerMonikerImpl_ComposeWith(IMoniker
*iface
, IMoniker
*right
,
246 BOOL only_if_not_generic
, IMoniker
**result
)
250 TRACE("%p, %p, %d, %p.\n", iface
, right
, only_if_not_generic
, result
);
252 if (!result
|| !right
)
257 if (is_anti_moniker(right
, &order
))
258 return order
> 1 ? create_anti_moniker(order
- 1, result
) : S_OK
;
260 return only_if_not_generic
? MK_E_NEEDGENERIC
: CreateGenericComposite(iface
, right
, result
);
263 /******************************************************************************
264 * PointerMoniker_Enum
265 ******************************************************************************/
266 static HRESULT WINAPI
PointerMonikerImpl_Enum(IMoniker
*iface
, BOOL fForward
, IEnumMoniker
**ppenumMoniker
)
268 TRACE("%p, %d, %p.\n", iface
, fForward
, ppenumMoniker
);
273 *ppenumMoniker
= NULL
;
278 /******************************************************************************
279 * PointerMoniker_IsEqual
280 ******************************************************************************/
281 static HRESULT WINAPI
PointerMonikerImpl_IsEqual(IMoniker
*iface
, IMoniker
*other
)
283 PointerMonikerImpl
*moniker
= impl_from_IMoniker(iface
), *other_moniker
;
285 TRACE("%p, %p.\n", iface
, other
);
290 other_moniker
= unsafe_impl_from_IMoniker(other
);
294 return moniker
->pObject
== other_moniker
->pObject
? S_OK
: S_FALSE
;
297 /******************************************************************************
298 * PointerMoniker_Hash
299 ******************************************************************************/
300 static HRESULT WINAPI
PointerMonikerImpl_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
302 PointerMonikerImpl
*This
= impl_from_IMoniker(iface
);
307 *pdwHash
= PtrToUlong(This
->pObject
);
312 /******************************************************************************
313 * PointerMoniker_IsRunning
314 ******************************************************************************/
315 static HRESULT WINAPI
316 PointerMonikerImpl_IsRunning(IMoniker
* iface
, IBindCtx
* pbc
, IMoniker
* pmkToLeft
,
317 IMoniker
* pmkNewlyRunning
)
319 TRACE("(%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,pmkNewlyRunning
);
324 /******************************************************************************
325 * PointerMoniker_GetTimeOfLastChange
326 ******************************************************************************/
327 static HRESULT WINAPI
PointerMonikerImpl_GetTimeOfLastChange(IMoniker
* iface
,
332 TRACE("(%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,pAntiTime
);
336 /******************************************************************************
337 * PointerMoniker_Inverse
338 ******************************************************************************/
339 static HRESULT WINAPI
340 PointerMonikerImpl_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
342 TRACE("(%p,%p)\n",iface
,ppmk
);
344 return CreateAntiMoniker(ppmk
);
347 /******************************************************************************
348 * PointerMoniker_CommonPrefixWith
349 ******************************************************************************/
350 static HRESULT WINAPI
PointerMonikerImpl_CommonPrefixWith(IMoniker
*iface
, IMoniker
*other
, IMoniker
**prefix
)
352 TRACE("%p, %p, %p.\n", iface
, other
, prefix
);
354 if (!prefix
|| !other
)
359 if (PointerMonikerImpl_IsEqual(iface
, other
) == S_OK
)
361 IMoniker_AddRef(iface
);
368 return MK_E_NOPREFIX
;
371 static HRESULT WINAPI
PointerMonikerImpl_RelativePathTo(IMoniker
*iface
, IMoniker
*other
, IMoniker
**result
)
373 TRACE("%p, %p, %p.\n", iface
, other
, result
);
380 return other
? E_NOTIMPL
: E_INVALIDARG
;
383 static HRESULT WINAPI
PointerMonikerImpl_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
384 IMoniker
*toleft
, LPOLESTR
*name
)
386 TRACE("%p, %p, %p, %p.\n", iface
, pbc
, toleft
, name
);
390 if (name
) *name
= NULL
;
397 /******************************************************************************
398 * PointerMoniker_ParseDisplayName
399 ******************************************************************************/
400 static HRESULT WINAPI
401 PointerMonikerImpl_ParseDisplayName(IMoniker
* iface
, IBindCtx
* pbc
,
402 IMoniker
* pmkToLeft
, LPOLESTR pszDisplayName
,
403 ULONG
* pchEaten
, IMoniker
** ppmkOut
)
405 PointerMonikerImpl
*This
= impl_from_IMoniker(iface
);
407 IParseDisplayName
*pPDN
;
409 TRACE("(%p,%p,%p,%p,%p,%p)\n",iface
,pbc
,pmkToLeft
,pszDisplayName
,pchEaten
,ppmkOut
);
417 hr
= IUnknown_QueryInterface(This
->pObject
, &IID_IParseDisplayName
, (void **)&pPDN
);
421 hr
= IParseDisplayName_ParseDisplayName(pPDN
, pbc
, pszDisplayName
, pchEaten
, ppmkOut
);
422 IParseDisplayName_Release(pPDN
);
427 /******************************************************************************
428 * PointerMoniker_IsSystemMoniker
429 ******************************************************************************/
430 static HRESULT WINAPI
431 PointerMonikerImpl_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
433 TRACE("(%p,%p)\n",iface
,pwdMksys
);
438 *pwdMksys
= MKSYS_POINTERMONIKER
;
443 /********************************************************************************/
444 /* Virtual function table for the PointerMonikerImpl class which include IPersist,*/
445 /* IPersistStream and IMoniker functions. */
446 static const IMonikerVtbl VT_PointerMonikerImpl
=
448 PointerMonikerImpl_QueryInterface
,
449 PointerMonikerImpl_AddRef
,
450 PointerMonikerImpl_Release
,
451 PointerMonikerImpl_GetClassID
,
452 PointerMonikerImpl_IsDirty
,
453 PointerMonikerImpl_Load
,
454 PointerMonikerImpl_Save
,
455 PointerMonikerImpl_GetSizeMax
,
456 PointerMonikerImpl_BindToObject
,
457 PointerMonikerImpl_BindToStorage
,
458 PointerMonikerImpl_Reduce
,
459 PointerMonikerImpl_ComposeWith
,
460 PointerMonikerImpl_Enum
,
461 PointerMonikerImpl_IsEqual
,
462 PointerMonikerImpl_Hash
,
463 PointerMonikerImpl_IsRunning
,
464 PointerMonikerImpl_GetTimeOfLastChange
,
465 PointerMonikerImpl_Inverse
,
466 PointerMonikerImpl_CommonPrefixWith
,
467 PointerMonikerImpl_RelativePathTo
,
468 PointerMonikerImpl_GetDisplayName
,
469 PointerMonikerImpl_ParseDisplayName
,
470 PointerMonikerImpl_IsSystemMoniker
473 static PointerMonikerImpl
*unsafe_impl_from_IMoniker(IMoniker
*iface
)
475 if (iface
->lpVtbl
!= &VT_PointerMonikerImpl
)
477 return CONTAINING_RECORD(iface
, PointerMonikerImpl
, IMoniker_iface
);
480 static HRESULT WINAPI
pointer_moniker_marshal_QueryInterface(IMarshal
*iface
, REFIID riid
, LPVOID
*ppv
)
482 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
484 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), ppv
);
486 return IMoniker_QueryInterface(&moniker
->IMoniker_iface
, riid
, ppv
);
489 static ULONG WINAPI
pointer_moniker_marshal_AddRef(IMarshal
*iface
)
491 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
493 TRACE("%p.\n",iface
);
495 return IMoniker_AddRef(&moniker
->IMoniker_iface
);
498 static ULONG WINAPI
pointer_moniker_marshal_Release(IMarshal
*iface
)
500 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
502 TRACE("%p.\n",iface
);
504 return IMoniker_Release(&moniker
->IMoniker_iface
);
507 static HRESULT WINAPI
pointer_moniker_marshal_GetUnmarshalClass(IMarshal
*iface
, REFIID riid
, void *pv
,
508 DWORD dwDestContext
, void *pvDestContext
, DWORD mshlflags
, CLSID
*clsid
)
510 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
512 TRACE("%p, %s, %p, %lx, %p, %lx, %p.\n", iface
, debugstr_guid(riid
), pv
, dwDestContext
, pvDestContext
,
515 return IMoniker_GetClassID(&moniker
->IMoniker_iface
, clsid
);
518 static HRESULT WINAPI
pointer_moniker_marshal_GetMarshalSizeMax(IMarshal
*iface
, REFIID riid
, void *pv
,
519 DWORD dwDestContext
, void *pvDestContext
, DWORD mshlflags
, DWORD
*size
)
521 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
523 TRACE("%p, %s, %p, %ld, %p, %#lx, %p.\n", iface
, debugstr_guid(riid
), pv
, dwDestContext
, pvDestContext
,
526 return CoGetMarshalSizeMax(size
, &IID_IUnknown
, moniker
->pObject
, dwDestContext
, pvDestContext
, mshlflags
);
529 static HRESULT WINAPI
pointer_moniker_marshal_MarshalInterface(IMarshal
*iface
, IStream
*stream
, REFIID riid
,
530 void *pv
, DWORD dwDestContext
, void *pvDestContext
, DWORD mshlflags
)
532 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
534 TRACE("%p, %s, %p, %lx, %p, %lx.\n", stream
, debugstr_guid(riid
), pv
,
535 dwDestContext
, pvDestContext
, mshlflags
);
537 return CoMarshalInterface(stream
, &IID_IUnknown
, moniker
->pObject
, dwDestContext
,
538 pvDestContext
, mshlflags
);
541 static HRESULT WINAPI
pointer_moniker_marshal_UnmarshalInterface(IMarshal
*iface
, IStream
*stream
,
542 REFIID riid
, void **ppv
)
544 PointerMonikerImpl
*moniker
= impl_from_IMarshal(iface
);
548 TRACE("%p, %p, %s, %p.\n", iface
, stream
, debugstr_guid(riid
), ppv
);
550 hr
= CoUnmarshalInterface(stream
, &IID_IUnknown
, (void **)&object
);
553 ERR("Couldn't unmarshal moniker, hr = %#lx.\n", hr
);
557 if (moniker
->pObject
)
558 IUnknown_Release(moniker
->pObject
);
559 moniker
->pObject
= object
;
561 return IMoniker_QueryInterface(&moniker
->IMoniker_iface
, riid
, ppv
);
564 static HRESULT WINAPI
pointer_moniker_marshal_ReleaseMarshalData(IMarshal
*iface
, IStream
*stream
)
566 TRACE("%p, %p.\n", iface
, stream
);
571 static HRESULT WINAPI
pointer_moniker_marshal_DisconnectObject(IMarshal
*iface
, DWORD reserved
)
573 TRACE("%p, %#lx.\n", iface
, reserved
);
578 static const IMarshalVtbl pointer_moniker_marshal_vtbl
=
580 pointer_moniker_marshal_QueryInterface
,
581 pointer_moniker_marshal_AddRef
,
582 pointer_moniker_marshal_Release
,
583 pointer_moniker_marshal_GetUnmarshalClass
,
584 pointer_moniker_marshal_GetMarshalSizeMax
,
585 pointer_moniker_marshal_MarshalInterface
,
586 pointer_moniker_marshal_UnmarshalInterface
,
587 pointer_moniker_marshal_ReleaseMarshalData
,
588 pointer_moniker_marshal_DisconnectObject
591 /***********************************************************************
592 * CreatePointerMoniker (OLE32.@)
594 HRESULT WINAPI
CreatePointerMoniker(IUnknown
*object
, IMoniker
**ret
)
596 PointerMonikerImpl
*moniker
;
598 TRACE("(%p, %p)\n", object
, ret
);
603 moniker
= heap_alloc(sizeof(*moniker
));
607 return E_OUTOFMEMORY
;
610 moniker
->IMoniker_iface
.lpVtbl
= &VT_PointerMonikerImpl
;
611 moniker
->IMarshal_iface
.lpVtbl
= &pointer_moniker_marshal_vtbl
;
612 moniker
->refcount
= 1;
613 moniker
->pObject
= object
;
614 if (moniker
->pObject
)
615 IUnknown_AddRef(moniker
->pObject
);
617 *ret
= &moniker
->IMoniker_iface
;
622 HRESULT WINAPI
PointerMoniker_CreateInstance(IClassFactory
*iface
,
623 IUnknown
*pUnk
, REFIID riid
, void **ppv
)
628 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
633 return CLASS_E_NOAGGREGATION
;
635 hr
= CreatePointerMoniker(NULL
, &pMoniker
);
639 hr
= IMoniker_QueryInterface(pMoniker
, riid
, ppv
);
640 IMoniker_Release(pMoniker
);
645 /* ObjrefMoniker implementation */
649 IMoniker IMoniker_iface
;
650 IMarshal IMarshal_iface
;
657 static inline ObjrefMonikerImpl
*objref_impl_from_IMoniker(IMoniker
*iface
)
659 return CONTAINING_RECORD(iface
, ObjrefMonikerImpl
, IMoniker_iface
);
662 static ObjrefMonikerImpl
*objref_impl_from_IMarshal(IMarshal
*iface
)
664 return CONTAINING_RECORD(iface
, ObjrefMonikerImpl
, IMarshal_iface
);
667 static HRESULT WINAPI
ObjrefMonikerImpl_QueryInterface(IMoniker
*iface
, REFIID iid
, void **obj
)
669 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMoniker(iface
);
671 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), obj
);
678 if (IsEqualIID(iid
, &IID_IUnknown
) ||
679 IsEqualIID(iid
, &IID_IPersist
) ||
680 IsEqualIID(iid
, &IID_IPersistStream
) ||
681 IsEqualIID(iid
, &IID_IMoniker
) ||
682 IsEqualGUID(iid
, &CLSID_ObjrefMoniker
) ||
683 IsEqualGUID(iid
, &CLSID_PointerMoniker
))
687 else if (IsEqualIID(iid
, &IID_IMarshal
))
688 *obj
= &moniker
->IMarshal_iface
;
690 return E_NOINTERFACE
;
692 IMoniker_AddRef(iface
);
697 static ULONG WINAPI
ObjrefMonikerImpl_AddRef(IMoniker
*iface
)
699 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMoniker(iface
);
700 ULONG refcount
= InterlockedIncrement(&moniker
->refcount
);
702 TRACE("%p, refcount %lu\n", iface
, refcount
);
707 static ULONG WINAPI
ObjrefMonikerImpl_Release(IMoniker
*iface
)
709 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMoniker(iface
);
710 ULONG refcount
= InterlockedDecrement(&moniker
->refcount
);
712 TRACE("%p, refcount %lu\n", iface
, refcount
);
716 if (moniker
->pObject
) IUnknown_Release(moniker
->pObject
);
723 static HRESULT WINAPI
ObjrefMonikerImpl_GetClassID(IMoniker
*iface
, CLSID
*clsid
)
725 TRACE("(%p,%p)\n", iface
, clsid
);
730 *clsid
= CLSID_ObjrefMoniker
;
734 static HRESULT WINAPI
ObjrefMonikerImpl_IsDirty(IMoniker
*iface
)
736 FIXME("(%p): stub\n", iface
);
740 static HRESULT WINAPI
ObjrefMonikerImpl_Load(IMoniker
*iface
, IStream
*stream
)
742 FIXME("(%p,%p): stub\n", iface
, stream
);
746 static HRESULT WINAPI
ObjrefMonikerImpl_Save(IMoniker
*iface
, IStream
*stream
, BOOL dirty
)
748 FIXME("(%p,%p,%d): stub\n", iface
, stream
, dirty
);
752 static HRESULT WINAPI
ObjrefMonikerImpl_GetSizeMax(IMoniker
*iface
, ULARGE_INTEGER
*size
)
754 FIXME("(%p,%p): stub\n", iface
, size
);
758 static HRESULT WINAPI
ObjrefMonikerImpl_BindToObject(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*left
,
759 REFIID riid
, void **result
)
761 FIXME("(%p,%p,%p,%s,%p): stub\n", iface
, pbc
, left
, debugstr_guid(riid
), result
);
765 static HRESULT WINAPI
ObjrefMonikerImpl_BindToStorage(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*left
,
766 REFIID riid
, void **result
)
768 FIXME("(%p,%p,%p,%s,%p): stub\n", iface
, pbc
, left
, debugstr_guid(riid
), result
);
772 static HRESULT WINAPI
ObjrefMonikerImpl_Reduce(IMoniker
*iface
, IBindCtx
*pbc
, DWORD howfar
,
773 IMoniker
**left
, IMoniker
**reduced
)
775 FIXME("%p, %p, %ld, %p, %p: stub\n", iface
, pbc
, howfar
, left
, reduced
);
779 static HRESULT WINAPI
ObjrefMonikerImpl_ComposeWith(IMoniker
*iface
, IMoniker
*right
,
780 BOOL only_if_not_generic
, IMoniker
**result
)
782 FIXME("(%p,%p,%d,%p): stub\n", iface
, right
, only_if_not_generic
, result
);
786 static HRESULT WINAPI
ObjrefMonikerImpl_Enum(IMoniker
*iface
, BOOL forward
, IEnumMoniker
**enummoniker
)
788 TRACE("(%p,%d,%p)\n", iface
, forward
, enummoniker
);
797 static HRESULT WINAPI
ObjrefMonikerImpl_IsEqual(IMoniker
*iface
, IMoniker
*other
)
799 FIXME("(%p,%p): stub\n", iface
, other
);
803 static HRESULT WINAPI
ObjrefMonikerImpl_Hash(IMoniker
*iface
, DWORD
*hash
)
805 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMoniker(iface
);
807 TRACE("(%p,%p)\n", iface
, hash
);
812 *hash
= PtrToUlong(moniker
->pObject
);
817 static HRESULT WINAPI
ObjrefMonikerImpl_IsRunning(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*left
,
820 FIXME("(%p,%p,%p,%p): stub\n", iface
, pbc
, left
, running
);
824 static HRESULT WINAPI
ObjrefMonikerImpl_GetTimeOfLastChange(IMoniker
*iface
,
825 IBindCtx
*pbc
, IMoniker
*left
, FILETIME
*time
)
827 FIXME("(%p,%p,%p,%p): stub\n", iface
, pbc
, left
, time
);
828 return MK_E_UNAVAILABLE
;
831 static HRESULT WINAPI
ObjrefMonikerImpl_Inverse(IMoniker
*iface
, IMoniker
**moniker
)
833 FIXME("(%p,%p): stub\n", iface
, moniker
);
837 static HRESULT WINAPI
ObjrefMonikerImpl_CommonPrefixWith(IMoniker
*iface
, IMoniker
*other
, IMoniker
**prefix
)
839 FIXME("(%p,%p,%p): stub\n", iface
, other
, prefix
);
843 static HRESULT WINAPI
ObjrefMonikerImpl_RelativePathTo(IMoniker
*iface
, IMoniker
*other
, IMoniker
**result
)
845 FIXME("(%p,%p,%p): stub\n", iface
, other
, result
);
849 static HRESULT WINAPI
ObjrefMonikerImpl_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
850 IMoniker
*left
, LPOLESTR
*name
)
852 FIXME("(%p,%p,%p,%p): stub\n", iface
, pbc
, left
, name
);
856 static HRESULT WINAPI
ObjrefMonikerImpl_ParseDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
857 IMoniker
*left
, LPOLESTR name
, ULONG
*eaten
, IMoniker
**out
)
859 FIXME("(%p,%p,%p,%p,%p,%p): stub\n", iface
, pbc
, left
, name
, eaten
, out
);
863 static HRESULT WINAPI
ObjrefMonikerImpl_IsSystemMoniker(IMoniker
*iface
, DWORD
*mksys
)
865 TRACE("(%p,%p)\n", iface
, mksys
);
870 *mksys
= MKSYS_OBJREFMONIKER
;
874 static const IMonikerVtbl VT_ObjrefMonikerImpl
=
876 ObjrefMonikerImpl_QueryInterface
,
877 ObjrefMonikerImpl_AddRef
,
878 ObjrefMonikerImpl_Release
,
879 ObjrefMonikerImpl_GetClassID
,
880 ObjrefMonikerImpl_IsDirty
,
881 ObjrefMonikerImpl_Load
,
882 ObjrefMonikerImpl_Save
,
883 ObjrefMonikerImpl_GetSizeMax
,
884 ObjrefMonikerImpl_BindToObject
,
885 ObjrefMonikerImpl_BindToStorage
,
886 ObjrefMonikerImpl_Reduce
,
887 ObjrefMonikerImpl_ComposeWith
,
888 ObjrefMonikerImpl_Enum
,
889 ObjrefMonikerImpl_IsEqual
,
890 ObjrefMonikerImpl_Hash
,
891 ObjrefMonikerImpl_IsRunning
,
892 ObjrefMonikerImpl_GetTimeOfLastChange
,
893 ObjrefMonikerImpl_Inverse
,
894 ObjrefMonikerImpl_CommonPrefixWith
,
895 ObjrefMonikerImpl_RelativePathTo
,
896 ObjrefMonikerImpl_GetDisplayName
,
897 ObjrefMonikerImpl_ParseDisplayName
,
898 ObjrefMonikerImpl_IsSystemMoniker
901 static HRESULT WINAPI
objref_moniker_marshal_QueryInterface(IMarshal
*iface
, REFIID riid
, LPVOID
*ppv
)
903 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
905 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(riid
), ppv
);
907 return IMoniker_QueryInterface(&moniker
->IMoniker_iface
, riid
, ppv
);
910 static ULONG WINAPI
objref_moniker_marshal_AddRef(IMarshal
*iface
)
912 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
914 TRACE("(%p)\n", iface
);
916 return IMoniker_AddRef(&moniker
->IMoniker_iface
);
919 static ULONG WINAPI
objref_moniker_marshal_Release(IMarshal
*iface
)
921 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
923 TRACE("(%p)\n", iface
);
925 return IMoniker_Release(&moniker
->IMoniker_iface
);
928 static HRESULT WINAPI
objref_moniker_marshal_GetUnmarshalClass(IMarshal
*iface
, REFIID riid
, void *pv
,
929 DWORD dwDestContext
, void *pvDestContext
, DWORD mshlflags
, CLSID
*clsid
)
931 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
933 TRACE("%p, %s, %p, %#lx, %p, %#lx, %p.\n", iface
, debugstr_guid(riid
), pv
, dwDestContext
, pvDestContext
,
936 return IMoniker_GetClassID(&moniker
->IMoniker_iface
, clsid
);
939 static HRESULT WINAPI
objref_moniker_marshal_GetMarshalSizeMax(IMarshal
*iface
, REFIID riid
, void *pv
,
940 DWORD dwDestContext
, void *pvDestContext
, DWORD mshlflags
, DWORD
*size
)
942 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
944 TRACE("%p, %s, %p, %#lx, %p, %#lx, %p.\n", iface
, debugstr_guid(riid
), pv
, dwDestContext
, pvDestContext
,
947 return CoGetMarshalSizeMax(size
, &IID_IUnknown
, moniker
->pObject
, dwDestContext
, pvDestContext
, mshlflags
);
950 static HRESULT WINAPI
objref_moniker_marshal_MarshalInterface(IMarshal
*iface
, IStream
*stream
, REFIID riid
,
951 void *pv
, DWORD dwDestContext
, void *pvDestContext
, DWORD mshlflags
)
953 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
955 TRACE("%p, %s, %p, %#lx, %p, %#lx\n", stream
, debugstr_guid(riid
), pv
, dwDestContext
, pvDestContext
, mshlflags
);
957 return CoMarshalInterface(stream
, &IID_IUnknown
, moniker
->pObject
, dwDestContext
, pvDestContext
, mshlflags
);
960 static HRESULT WINAPI
objref_moniker_marshal_UnmarshalInterface(IMarshal
*iface
, IStream
*stream
,
961 REFIID riid
, void **ppv
)
963 ObjrefMonikerImpl
*moniker
= objref_impl_from_IMarshal(iface
);
967 TRACE("(%p,%p,%s,%p)\n", iface
, stream
, debugstr_guid(riid
), ppv
);
969 hr
= CoUnmarshalInterface(stream
, &IID_IUnknown
, (void **)&object
);
972 ERR("Couldn't unmarshal moniker, hr = %#lx.\n", hr
);
976 if (moniker
->pObject
)
977 IUnknown_Release(moniker
->pObject
);
978 moniker
->pObject
= object
;
980 return IMoniker_QueryInterface(&moniker
->IMoniker_iface
, riid
, ppv
);
983 static HRESULT WINAPI
objref_moniker_marshal_ReleaseMarshalData(IMarshal
*iface
, IStream
*stream
)
985 TRACE("(%p,%p)\n", iface
, stream
);
989 static HRESULT WINAPI
objref_moniker_marshal_DisconnectObject(IMarshal
*iface
, DWORD reserved
)
991 TRACE("%p, %#lx.\n", iface
, reserved
);
995 static const IMarshalVtbl objref_moniker_marshal_vtbl
=
997 objref_moniker_marshal_QueryInterface
,
998 objref_moniker_marshal_AddRef
,
999 objref_moniker_marshal_Release
,
1000 objref_moniker_marshal_GetUnmarshalClass
,
1001 objref_moniker_marshal_GetMarshalSizeMax
,
1002 objref_moniker_marshal_MarshalInterface
,
1003 objref_moniker_marshal_UnmarshalInterface
,
1004 objref_moniker_marshal_ReleaseMarshalData
,
1005 objref_moniker_marshal_DisconnectObject
1008 /***********************************************************************
1009 * CreateObjrefMoniker (OLE32.@)
1011 HRESULT WINAPI
CreateObjrefMoniker(IUnknown
*obj
, IMoniker
**ret
)
1013 ObjrefMonikerImpl
*moniker
;
1015 TRACE("(%p,%p)\n", obj
, ret
);
1018 return E_INVALIDARG
;
1020 moniker
= heap_alloc(sizeof(*moniker
));
1024 return E_OUTOFMEMORY
;
1027 moniker
->IMoniker_iface
.lpVtbl
= &VT_ObjrefMonikerImpl
;
1028 moniker
->IMarshal_iface
.lpVtbl
= &objref_moniker_marshal_vtbl
;
1029 moniker
->refcount
= 1;
1030 moniker
->pObject
= obj
;
1031 if (moniker
->pObject
)
1032 IUnknown_AddRef(moniker
->pObject
);
1034 *ret
= &moniker
->IMoniker_iface
;
1039 HRESULT WINAPI
ObjrefMoniker_CreateInstance(IClassFactory
*iface
, IUnknown
*unk
, REFIID iid
, void **obj
)
1044 TRACE("(%p,%s,%p)\n", unk
, debugstr_guid(iid
), obj
);
1049 return CLASS_E_NOAGGREGATION
;
1051 hr
= CreateObjrefMoniker(NULL
, &moniker
);
1055 hr
= IMoniker_QueryInterface(moniker
, iid
, obj
);
1056 IMoniker_Release(moniker
);