4 * Copyright 1999 Noomen Hamza
5 * Copyright 2005-2007 Robert Shearman
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
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
34 #include "wine/debug.h"
36 #include "wine/unicode.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
41 #define CHARS_IN_GUID 39
43 /* ClassMoniker data structure */
44 typedef struct ClassMoniker
46 const IMonikerVtbl
* lpVtbl
; /* VTable relative to the IMoniker interface.*/
47 const IROTDataVtbl
* lpVtblRotData
; /* VTable relative to the IROTData interface.*/
48 LONG ref
; /* reference counter for this object */
49 CLSID clsid
; /* clsid identified by this moniker */
50 IUnknown
*pMarshal
; /* custom marshaler */
53 static inline IMoniker
*impl_from_IROTData( IROTData
*iface
)
55 return (IMoniker
*)((char*)iface
- FIELD_OFFSET(ClassMoniker
, lpVtblRotData
));
58 /*******************************************************************************
59 * ClassMoniker_QueryInterface
60 *******************************************************************************/
61 static HRESULT WINAPI
ClassMoniker_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
)
63 ClassMoniker
*This
= (ClassMoniker
*)iface
;
65 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
67 /* Perform a sanity check on the parameters.*/
71 /* Initialize the return parameter */
74 /* Compare the riid with the interface IDs implemented by this object.*/
75 if (IsEqualIID(&IID_IUnknown
, riid
) ||
76 IsEqualIID(&IID_IPersist
, riid
) ||
77 IsEqualIID(&IID_IPersistStream
, riid
) ||
78 IsEqualIID(&IID_IMoniker
, riid
))
82 else if (IsEqualIID(&IID_IROTData
, riid
))
83 *ppvObject
= (IROTData
*)&(This
->lpVtblRotData
);
84 else if (IsEqualIID(&IID_IMarshal
, riid
))
88 hr
= MonikerMarshal_Create(iface
, &This
->pMarshal
);
91 return IUnknown_QueryInterface(This
->pMarshal
, riid
, ppvObject
);
94 /* Check that we obtained an interface.*/
98 /* Query Interface always increases the reference count by one when it is successful */
99 IMoniker_AddRef(iface
);
104 /******************************************************************************
105 * ClassMoniker_AddRef
106 ******************************************************************************/
107 static ULONG WINAPI
ClassMoniker_AddRef(IMoniker
* iface
)
109 ClassMoniker
*This
= (ClassMoniker
*)iface
;
111 TRACE("(%p)\n",This
);
113 return InterlockedIncrement(&This
->ref
);
116 /******************************************************************************
117 * ClassMoniker_Destroy (local function)
118 *******************************************************************************/
119 static HRESULT WINAPI
ClassMoniker_Destroy(ClassMoniker
* This
)
121 TRACE("(%p)\n",This
);
123 if (This
->pMarshal
) IUnknown_Release(This
->pMarshal
);
125 HeapFree(GetProcessHeap(),0,This
);
130 /******************************************************************************
131 * ClassMoniker_Release
132 ******************************************************************************/
133 static ULONG WINAPI
ClassMoniker_Release(IMoniker
* iface
)
135 ClassMoniker
*This
= (ClassMoniker
*)iface
;
138 TRACE("(%p)\n",This
);
140 ref
= InterlockedDecrement(&This
->ref
);
142 /* destroy the object if there's no more reference on it */
143 if (ref
== 0) ClassMoniker_Destroy(This
);
148 /******************************************************************************
149 * ClassMoniker_GetClassID
150 ******************************************************************************/
151 static HRESULT WINAPI
ClassMoniker_GetClassID(IMoniker
* iface
,CLSID
*pClassID
)
153 TRACE("(%p,%p),stub!\n",iface
,pClassID
);
158 *pClassID
= CLSID_ClassMoniker
;
163 /******************************************************************************
164 * ClassMoniker_IsDirty
165 ******************************************************************************/
166 static HRESULT WINAPI
ClassMoniker_IsDirty(IMoniker
* iface
)
168 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
169 method in the OLE-provided moniker interfaces always return S_FALSE because
170 their internal state never changes. */
172 TRACE("(%p)\n",iface
);
177 /******************************************************************************
179 ******************************************************************************/
180 static HRESULT WINAPI
ClassMoniker_Load(IMoniker
* iface
,IStream
* pStm
)
182 ClassMoniker
*This
= (ClassMoniker
*)iface
;
186 TRACE("(%p)\n", pStm
);
188 hr
= IStream_Read(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
189 if (hr
!= S_OK
) return STG_E_READFAULT
;
191 hr
= IStream_Read(pStm
, &zero
, sizeof(zero
), NULL
);
192 if ((hr
!= S_OK
) || (zero
!= 0)) return STG_E_READFAULT
;
197 /******************************************************************************
199 ******************************************************************************/
200 static HRESULT WINAPI
ClassMoniker_Save(IMoniker
* iface
,
201 IStream
* pStm
,/* pointer to the stream where the object is to be saved */
202 BOOL fClearDirty
)/* Specifies whether to clear the dirty flag */
204 ClassMoniker
*This
= (ClassMoniker
*)iface
;
208 TRACE("(%p, %s)\n", pStm
, fClearDirty
? "TRUE" : "FALSE");
210 hr
= IStream_Write(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
211 if (FAILED(hr
)) return hr
;
213 hr
= IStream_Write(pStm
, &zero
, sizeof(zero
), NULL
);
218 /******************************************************************************
219 * ClassMoniker_GetSizeMax
220 ******************************************************************************/
221 static HRESULT WINAPI
ClassMoniker_GetSizeMax(IMoniker
* iface
,
222 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
224 TRACE("(%p)\n", pcbSize
);
226 pcbSize
->QuadPart
= sizeof(CLSID
) + sizeof(DWORD
);
231 /******************************************************************************
232 * ClassMoniker_BindToObject
233 ******************************************************************************/
234 static HRESULT WINAPI
ClassMoniker_BindToObject(IMoniker
* iface
,
240 ClassMoniker
*This
= (ClassMoniker
*)iface
;
242 IClassActivator
*pActivator
;
245 TRACE("(%p,%p,%p,%p)\n", pbc
, pmkToLeft
, riid
, ppvResult
);
247 bindopts
.cbStruct
= sizeof(bindopts
);
248 IBindCtx_GetBindOptions(pbc
, (BIND_OPTS
*)&bindopts
);
251 return CoGetClassObject(&This
->clsid
, bindopts
.dwClassContext
, NULL
,
255 hr
= IMoniker_BindToObject(pmkToLeft
, pbc
, NULL
, &IID_IClassActivator
,
256 (void **)&pActivator
);
257 if (FAILED(hr
)) return hr
;
259 hr
= IClassActivator_GetClassObject(pActivator
, &This
->clsid
,
260 bindopts
.dwClassContext
,
261 bindopts
.locale
, riid
, ppvResult
);
263 IClassActivator_Release(pActivator
);
269 /******************************************************************************
270 * ClassMoniker_BindToStorage
271 ******************************************************************************/
272 static HRESULT WINAPI
ClassMoniker_BindToStorage(IMoniker
* iface
,
278 TRACE("(%p,%p,%p,%p)\n",pbc
, pmkToLeft
, riid
, ppvResult
);
279 return ClassMoniker_BindToObject(iface
, pbc
, pmkToLeft
, riid
, ppvResult
);
282 /******************************************************************************
283 * ClassMoniker_Reduce
284 ******************************************************************************/
285 static HRESULT WINAPI
ClassMoniker_Reduce(IMoniker
* iface
,
287 DWORD dwReduceHowFar
,
288 IMoniker
** ppmkToLeft
,
289 IMoniker
** ppmkReduced
)
291 TRACE("(%p,%p,%d,%p,%p)\n",iface
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
296 ClassMoniker_AddRef(iface
);
298 *ppmkReduced
= iface
;
300 return MK_S_REDUCED_TO_SELF
;
302 /******************************************************************************
303 * ClassMoniker_ComposeWith
304 ******************************************************************************/
305 static HRESULT WINAPI
ClassMoniker_ComposeWith(IMoniker
* iface
,
307 BOOL fOnlyIfNotGeneric
,
308 IMoniker
** ppmkComposite
)
312 IEnumMoniker
* penumMk
=0;
313 IMoniker
*pmostLeftMk
=0;
314 IMoniker
* tempMkComposite
=0;
316 TRACE("(%p,%d,%p)\n", pmkRight
, fOnlyIfNotGeneric
, ppmkComposite
);
318 if ((ppmkComposite
==NULL
)||(pmkRight
==NULL
))
323 IMoniker_IsSystemMoniker(pmkRight
,&mkSys
);
325 /* If pmkRight is an anti-moniker, the returned moniker is NULL */
326 if(mkSys
==MKSYS_ANTIMONIKER
)
330 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */
331 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
333 if(mkSys
==MKSYS_GENERICCOMPOSITE
){
335 res
=IMoniker_Enum(pmkRight
,TRUE
,&penumMk
);
340 res
=IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
);
342 IMoniker_IsSystemMoniker(pmostLeftMk
,&mkSys2
);
344 if(mkSys2
==MKSYS_ANTIMONIKER
){
346 IMoniker_Release(pmostLeftMk
);
348 tempMkComposite
=iface
;
349 IMoniker_AddRef(iface
);
351 while(IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
)==S_OK
){
353 res
=CreateGenericComposite(tempMkComposite
,pmostLeftMk
,ppmkComposite
);
355 IMoniker_Release(tempMkComposite
);
356 IMoniker_Release(pmostLeftMk
);
358 tempMkComposite
=*ppmkComposite
;
359 IMoniker_AddRef(tempMkComposite
);
364 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
366 /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
367 composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
368 a NULL moniker and a return value of MK_E_NEEDGENERIC */
370 if (!fOnlyIfNotGeneric
)
371 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
374 return MK_E_NEEDGENERIC
;
377 /******************************************************************************
379 ******************************************************************************/
380 static HRESULT WINAPI
ClassMoniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
382 TRACE("(%p,%d,%p)\n",iface
,fForward
,ppenumMoniker
);
384 if (ppenumMoniker
== NULL
)
387 *ppenumMoniker
= NULL
;
392 /******************************************************************************
393 * ClassMoniker_IsEqual
394 ******************************************************************************/
395 static HRESULT WINAPI
ClassMoniker_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
399 LPOLESTR dispName1
,dispName2
;
401 HRESULT res
= S_FALSE
;
403 TRACE("(%p,%p)\n",iface
,pmkOtherMoniker
);
405 if (!pmkOtherMoniker
) return S_FALSE
;
408 /* check if both are ClassMoniker */
409 if(FAILED (IMoniker_GetClassID(pmkOtherMoniker
,&clsid
))) return S_FALSE
;
410 if(!IsEqualCLSID(&clsid
,&CLSID_ClassMoniker
)) return S_FALSE
;
412 /* check if both displaynames are the same */
413 if(SUCCEEDED ((res
= CreateBindCtx(0,&bind
)))) {
414 if(SUCCEEDED (IMoniker_GetDisplayName(iface
,bind
,NULL
,&dispName1
))) {
415 if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&dispName2
))) {
416 if(lstrcmpW(dispName1
,dispName2
)==0) res
= S_OK
;
417 CoTaskMemFree(dispName2
);
419 CoTaskMemFree(dispName1
);
425 /******************************************************************************
427 ******************************************************************************/
428 static HRESULT WINAPI
ClassMoniker_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
430 ClassMoniker
*This
= (ClassMoniker
*)iface
;
432 TRACE("(%p)\n", pdwHash
);
434 *pdwHash
= This
->clsid
.Data1
;
439 /******************************************************************************
440 * ClassMoniker_IsRunning
441 ******************************************************************************/
442 static HRESULT WINAPI
ClassMoniker_IsRunning(IMoniker
* iface
,
445 IMoniker
* pmkNewlyRunning
)
447 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pmkNewlyRunning
);
453 /******************************************************************************
454 * ClassMoniker_GetTimeOfLastChange
455 ******************************************************************************/
456 static HRESULT WINAPI
ClassMoniker_GetTimeOfLastChange(IMoniker
* iface
,
461 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pItemTime
);
463 return MK_E_UNAVAILABLE
;
466 /******************************************************************************
467 * ClassMoniker_Inverse
468 ******************************************************************************/
469 static HRESULT WINAPI
ClassMoniker_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
471 TRACE("(%p)\n",ppmk
);
476 return CreateAntiMoniker(ppmk
);
479 /******************************************************************************
480 * ClassMoniker_CommonPrefixWith
481 ******************************************************************************/
482 static HRESULT WINAPI
ClassMoniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
486 TRACE("(%p, %p)\n", pmkOther
, ppmkPrefix
);
490 IMoniker_IsSystemMoniker(pmkOther
, &mkSys
);
492 /* If the other moniker is an class moniker that is equal to this moniker, this method sets *ppmkPrefix */
493 /* to this moniker and returns MK_S_US */
495 if (mkSys
== MKSYS_CLASSMONIKER
)
497 if (IMoniker_IsEqual(iface
, pmkOther
) == S_OK
)
501 IMoniker_AddRef(iface
);
506 return MK_E_NOPREFIX
;
509 /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
510 /* the case where the other moniker is a generic composite. */
511 return MonikerCommonPrefixWith(iface
, pmkOther
, ppmkPrefix
);
514 /******************************************************************************
515 * ClassMoniker_RelativePathTo
516 ******************************************************************************/
517 static HRESULT WINAPI
ClassMoniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
519 TRACE("(%p, %p)\n",pmOther
,ppmkRelPath
);
526 return MK_E_NOTBINDABLE
;
529 /******************************************************************************
530 * ClassMoniker_GetDisplayName
531 ******************************************************************************/
532 static HRESULT WINAPI
ClassMoniker_GetDisplayName(IMoniker
* iface
,
535 LPOLESTR
*ppszDisplayName
)
537 ClassMoniker
*This
= (ClassMoniker
*)iface
;
538 static const WCHAR wszClsidPrefix
[] = {'c','l','s','i','d',':',0};
540 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, ppszDisplayName
);
542 if (!ppszDisplayName
)
548 *ppszDisplayName
= CoTaskMemAlloc(sizeof(wszClsidPrefix
) + (CHARS_IN_GUID
-2) * sizeof(WCHAR
));
550 StringFromGUID2(&This
->clsid
, *ppszDisplayName
+sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2, CHARS_IN_GUID
);
552 /* note: this overwrites the opening curly bracket of the CLSID string generated above */
553 memcpy(*ppszDisplayName
, wszClsidPrefix
, sizeof(wszClsidPrefix
)-sizeof(WCHAR
));
555 /* note: this overwrites the closing curly bracket of the CLSID string generated above */
556 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-2] = ':';
557 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-1] = '\0';
559 TRACE("string is %s\n", debugstr_w(*ppszDisplayName
));
563 /******************************************************************************
564 * ClassMoniker_ParseDisplayName
565 ******************************************************************************/
566 static HRESULT WINAPI
ClassMoniker_ParseDisplayName(IMoniker
* iface
,
569 LPOLESTR pszDisplayName
,
573 FIXME("(%p, %p, %s, %p, %p)\n", pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
577 /******************************************************************************
578 * ClassMoniker_IsSystemMoniker
579 ******************************************************************************/
580 static HRESULT WINAPI
ClassMoniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
582 TRACE("(%p,%p)\n",iface
,pwdMksys
);
587 *pwdMksys
= MKSYS_CLASSMONIKER
;
592 /*******************************************************************************
593 * ClassMonikerIROTData_QueryInterface
594 *******************************************************************************/
595 static HRESULT WINAPI
ClassMonikerROTData_QueryInterface(IROTData
*iface
,REFIID riid
,VOID
** ppvObject
)
598 IMoniker
*This
= impl_from_IROTData(iface
);
600 TRACE("(%p,%p,%p)\n",iface
,riid
,ppvObject
);
602 return ClassMoniker_QueryInterface(This
, riid
, ppvObject
);
605 /***********************************************************************
606 * ClassMonikerIROTData_AddRef
608 static ULONG WINAPI
ClassMonikerROTData_AddRef(IROTData
*iface
)
610 IMoniker
*This
= impl_from_IROTData(iface
);
612 TRACE("(%p)\n",iface
);
614 return ClassMoniker_AddRef(This
);
617 /***********************************************************************
618 * ClassMonikerIROTData_Release
620 static ULONG WINAPI
ClassMonikerROTData_Release(IROTData
* iface
)
622 IMoniker
*This
= impl_from_IROTData(iface
);
624 TRACE("(%p)\n",iface
);
626 return ClassMoniker_Release(This
);
629 /******************************************************************************
630 * ClassMonikerIROTData_GetComparisonData
631 ******************************************************************************/
632 static HRESULT WINAPI
ClassMonikerROTData_GetComparisonData(IROTData
* iface
,
637 ClassMoniker
*This
= (ClassMoniker
*)impl_from_IROTData(iface
);
639 TRACE("(%p, %u, %p)\n", pbData
, cbMax
, pcbData
);
641 *pcbData
= 2*sizeof(CLSID
);
642 if (cbMax
< *pcbData
)
643 return E_OUTOFMEMORY
;
645 /* write CLSID of the moniker */
646 memcpy(pbData
, &CLSID_ClassMoniker
, sizeof(CLSID
));
647 /* write CLSID the moniker represents */
648 memcpy(pbData
+sizeof(CLSID
), &This
->clsid
, sizeof(CLSID
));
653 /********************************************************************************/
654 /* Virtual function table for the ClassMoniker class which include IPersist,*/
655 /* IPersistStream and IMoniker functions. */
656 static const IMonikerVtbl ClassMonikerVtbl
=
658 ClassMoniker_QueryInterface
,
660 ClassMoniker_Release
,
661 ClassMoniker_GetClassID
,
662 ClassMoniker_IsDirty
,
665 ClassMoniker_GetSizeMax
,
666 ClassMoniker_BindToObject
,
667 ClassMoniker_BindToStorage
,
669 ClassMoniker_ComposeWith
,
671 ClassMoniker_IsEqual
,
673 ClassMoniker_IsRunning
,
674 ClassMoniker_GetTimeOfLastChange
,
675 ClassMoniker_Inverse
,
676 ClassMoniker_CommonPrefixWith
,
677 ClassMoniker_RelativePathTo
,
678 ClassMoniker_GetDisplayName
,
679 ClassMoniker_ParseDisplayName
,
680 ClassMoniker_IsSystemMoniker
683 /********************************************************************************/
684 /* Virtual function table for the IROTData class. */
685 static const IROTDataVtbl ROTDataVtbl
=
687 ClassMonikerROTData_QueryInterface
,
688 ClassMonikerROTData_AddRef
,
689 ClassMonikerROTData_Release
,
690 ClassMonikerROTData_GetComparisonData
693 /******************************************************************************
694 * ClassMoniker_Construct (local function)
695 *******************************************************************************/
696 static HRESULT WINAPI
ClassMoniker_Construct(ClassMoniker
* This
, REFCLSID rclsid
)
698 TRACE("(%p,%s)\n",This
,debugstr_guid(rclsid
));
700 /* Initialize the virtual function table. */
701 This
->lpVtbl
= &ClassMonikerVtbl
;
702 This
->lpVtblRotData
= &ROTDataVtbl
;
704 This
->clsid
= *rclsid
;
705 This
->pMarshal
= NULL
;
710 /******************************************************************************
711 * CreateClassMoniker [OLE32.@]
712 ******************************************************************************/
713 HRESULT WINAPI
CreateClassMoniker(REFCLSID rclsid
, IMoniker
**ppmk
)
715 ClassMoniker
* newClassMoniker
;
718 TRACE("(%s,%p)\n", debugstr_guid(rclsid
), ppmk
);
720 newClassMoniker
= HeapAlloc(GetProcessHeap(), 0, sizeof(ClassMoniker
));
722 if (!newClassMoniker
)
723 return STG_E_INSUFFICIENTMEMORY
;
725 hr
= ClassMoniker_Construct(newClassMoniker
, rclsid
);
729 HeapFree(GetProcessHeap(), 0, newClassMoniker
);
733 return ClassMoniker_QueryInterface((IMoniker
*)newClassMoniker
, &IID_IMoniker
, (void**)ppmk
);
736 HRESULT
ClassMoniker_CreateFromDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
,
737 LPDWORD pchEaten
, LPMONIKER
*ppmk
)
740 LPCWSTR s
= strchrW(szDisplayName
, ':');
751 for (end
= s
; *end
&& (*end
!= ':'); end
++)
754 TRACE("parsing %s\n", debugstr_wn(s
, end
- s
));
756 /* validate the CLSID string */
759 if ((end
- s
!= 38) || (s
[37] != '}'))
771 if ((i
== 8)||(i
== 13)||(i
== 18)||(i
== 23))
777 if (!(((s
[i
] >= '0') && (s
[i
] <= '9')) ||
778 ((s
[i
] >= 'a') && (s
[i
] <= 'f')) ||
779 ((s
[i
] >= 'A') && (s
[i
] <= 'F'))))
783 /* quick lookup table */
784 memset(table
, 0, 256);
786 for (i
= 0; i
< 10; i
++)
788 for (i
= 0; i
< 6; i
++)
790 table
['A' + i
] = i
+10;
791 table
['a' + i
] = i
+10;
794 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
796 clsid
.Data1
= (table
[s
[0]] << 28 | table
[s
[1]] << 24 | table
[s
[2]] << 20 | table
[s
[3]] << 16 |
797 table
[s
[4]] << 12 | table
[s
[5]] << 8 | table
[s
[6]] << 4 | table
[s
[7]]);
798 clsid
.Data2
= table
[s
[9]] << 12 | table
[s
[10]] << 8 | table
[s
[11]] << 4 | table
[s
[12]];
799 clsid
.Data3
= table
[s
[14]] << 12 | table
[s
[15]] << 8 | table
[s
[16]] << 4 | table
[s
[17]];
801 /* these are just sequential bytes */
802 clsid
.Data4
[0] = table
[s
[19]] << 4 | table
[s
[20]];
803 clsid
.Data4
[1] = table
[s
[21]] << 4 | table
[s
[22]];
804 clsid
.Data4
[2] = table
[s
[24]] << 4 | table
[s
[25]];
805 clsid
.Data4
[3] = table
[s
[26]] << 4 | table
[s
[27]];
806 clsid
.Data4
[4] = table
[s
[28]] << 4 | table
[s
[29]];
807 clsid
.Data4
[5] = table
[s
[30]] << 4 | table
[s
[31]];
808 clsid
.Data4
[6] = table
[s
[32]] << 4 | table
[s
[33]];
809 clsid
.Data4
[7] = table
[s
[34]] << 4 | table
[s
[35]];
811 hr
= CreateClassMoniker(&clsid
, ppmk
);
813 *pchEaten
= (*end
== ':' ? end
+ 1 : end
) - szDisplayName
;
817 static HRESULT WINAPI
ClassMonikerCF_QueryInterface(LPCLASSFACTORY iface
,
818 REFIID riid
, LPVOID
*ppv
)
821 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
824 IUnknown_AddRef(iface
);
827 return E_NOINTERFACE
;
830 static ULONG WINAPI
ClassMonikerCF_AddRef(LPCLASSFACTORY iface
)
832 return 2; /* non-heap based object */
835 static ULONG WINAPI
ClassMonikerCF_Release(LPCLASSFACTORY iface
)
837 return 1; /* non-heap based object */
840 static HRESULT WINAPI
ClassMonikerCF_CreateInstance(LPCLASSFACTORY iface
,
841 LPUNKNOWN pUnk
, REFIID riid
, LPVOID
*ppv
)
846 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
851 return CLASS_E_NOAGGREGATION
;
853 hr
= CreateClassMoniker(&CLSID_NULL
, &pmk
);
854 if (FAILED(hr
)) return hr
;
856 hr
= IMoniker_QueryInterface(pmk
, riid
, ppv
);
857 IMoniker_Release(pmk
);
862 static HRESULT WINAPI
ClassMonikerCF_LockServer(LPCLASSFACTORY iface
, BOOL fLock
)
864 FIXME("(%d), stub!\n",fLock
);
868 static const IClassFactoryVtbl ClassMonikerCFVtbl
=
870 ClassMonikerCF_QueryInterface
,
871 ClassMonikerCF_AddRef
,
872 ClassMonikerCF_Release
,
873 ClassMonikerCF_CreateInstance
,
874 ClassMonikerCF_LockServer
876 static const IClassFactoryVtbl
*ClassMonikerCF
= &ClassMonikerCFVtbl
;
878 HRESULT
ClassMonikerCF_Create(REFIID riid
, LPVOID
*ppv
)
880 return IClassFactory_QueryInterface((IClassFactory
*)&ClassMonikerCF
, riid
, ppv
);