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 IMoniker IMoniker_iface
;
47 IROTData IROTData_iface
;
49 CLSID clsid
; /* clsid identified by this moniker */
50 IUnknown
*pMarshal
; /* custom marshaler */
53 static inline ClassMoniker
*impl_from_IMoniker(IMoniker
*iface
)
55 return CONTAINING_RECORD(iface
, ClassMoniker
, IMoniker_iface
);
58 static inline ClassMoniker
*impl_from_IROTData(IROTData
*iface
)
60 return CONTAINING_RECORD(iface
, ClassMoniker
, IROTData_iface
);
63 /*******************************************************************************
64 * ClassMoniker_QueryInterface
65 *******************************************************************************/
66 static HRESULT WINAPI
ClassMoniker_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
)
68 ClassMoniker
*This
= impl_from_IMoniker(iface
);
70 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
72 /* Perform a sanity check on the parameters.*/
76 /* Initialize the return parameter */
79 /* Compare the riid with the interface IDs implemented by this object.*/
80 if (IsEqualIID(&IID_IUnknown
, riid
) ||
81 IsEqualIID(&IID_IPersist
, riid
) ||
82 IsEqualIID(&IID_IPersistStream
, riid
) ||
83 IsEqualIID(&IID_IMoniker
, riid
))
87 else if (IsEqualIID(&IID_IROTData
, riid
))
88 *ppvObject
= &This
->IROTData_iface
;
89 else if (IsEqualIID(&IID_IMarshal
, riid
))
93 hr
= MonikerMarshal_Create(iface
, &This
->pMarshal
);
96 return IUnknown_QueryInterface(This
->pMarshal
, riid
, ppvObject
);
99 /* Check that we obtained an interface.*/
101 return E_NOINTERFACE
;
103 /* Query Interface always increases the reference count by one when it is successful */
104 IMoniker_AddRef(iface
);
109 /******************************************************************************
110 * ClassMoniker_AddRef
111 ******************************************************************************/
112 static ULONG WINAPI
ClassMoniker_AddRef(IMoniker
* iface
)
114 ClassMoniker
*This
= impl_from_IMoniker(iface
);
116 TRACE("(%p)\n",This
);
118 return InterlockedIncrement(&This
->ref
);
121 /******************************************************************************
122 * ClassMoniker_Release
123 ******************************************************************************/
124 static ULONG WINAPI
ClassMoniker_Release(IMoniker
* iface
)
126 ClassMoniker
*This
= impl_from_IMoniker(iface
);
129 TRACE("(%p)\n",This
);
131 ref
= InterlockedDecrement(&This
->ref
);
133 /* destroy the object if there are no more references to it */
136 if (This
->pMarshal
) IUnknown_Release(This
->pMarshal
);
137 HeapFree(GetProcessHeap(),0,This
);
143 /******************************************************************************
144 * ClassMoniker_GetClassID
145 ******************************************************************************/
146 static HRESULT WINAPI
ClassMoniker_GetClassID(IMoniker
* iface
,CLSID
*pClassID
)
148 TRACE("(%p,%p),stub!\n",iface
,pClassID
);
153 *pClassID
= CLSID_ClassMoniker
;
158 /******************************************************************************
159 * ClassMoniker_IsDirty
160 ******************************************************************************/
161 static HRESULT WINAPI
ClassMoniker_IsDirty(IMoniker
* iface
)
163 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
164 method in the OLE-provided moniker interfaces always return S_FALSE because
165 their internal state never changes. */
167 TRACE("(%p)\n",iface
);
172 /******************************************************************************
174 ******************************************************************************/
175 static HRESULT WINAPI
ClassMoniker_Load(IMoniker
* iface
,IStream
* pStm
)
177 ClassMoniker
*This
= impl_from_IMoniker(iface
);
181 TRACE("(%p)\n", pStm
);
183 hr
= IStream_Read(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
184 if (hr
!= S_OK
) return STG_E_READFAULT
;
186 hr
= IStream_Read(pStm
, &zero
, sizeof(zero
), NULL
);
187 if ((hr
!= S_OK
) || (zero
!= 0)) return STG_E_READFAULT
;
192 /******************************************************************************
194 ******************************************************************************/
195 static HRESULT WINAPI
ClassMoniker_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
)
197 ClassMoniker
*This
= impl_from_IMoniker(iface
);
201 TRACE("(%p, %s)\n", pStm
, fClearDirty
? "TRUE" : "FALSE");
203 hr
= IStream_Write(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
204 if (FAILED(hr
)) return hr
;
206 return IStream_Write(pStm
, &zero
, sizeof(zero
), NULL
);
209 /******************************************************************************
210 * ClassMoniker_GetSizeMax
211 ******************************************************************************/
212 static HRESULT WINAPI
ClassMoniker_GetSizeMax(IMoniker
* iface
,
213 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
215 TRACE("(%p)\n", pcbSize
);
217 pcbSize
->QuadPart
= sizeof(CLSID
) + sizeof(DWORD
);
222 /******************************************************************************
223 * ClassMoniker_BindToObject
224 ******************************************************************************/
225 static HRESULT WINAPI
ClassMoniker_BindToObject(IMoniker
* iface
,
231 ClassMoniker
*This
= impl_from_IMoniker(iface
);
233 IClassActivator
*pActivator
;
236 TRACE("(%p,%p,%p,%p)\n", pbc
, pmkToLeft
, riid
, ppvResult
);
238 bindopts
.cbStruct
= sizeof(bindopts
);
239 IBindCtx_GetBindOptions(pbc
, (BIND_OPTS
*)&bindopts
);
242 return CoGetClassObject(&This
->clsid
, bindopts
.dwClassContext
, NULL
,
246 hr
= IMoniker_BindToObject(pmkToLeft
, pbc
, NULL
, &IID_IClassActivator
,
247 (void **)&pActivator
);
248 if (FAILED(hr
)) return hr
;
250 hr
= IClassActivator_GetClassObject(pActivator
, &This
->clsid
,
251 bindopts
.dwClassContext
,
252 bindopts
.locale
, riid
, ppvResult
);
254 IClassActivator_Release(pActivator
);
260 /******************************************************************************
261 * ClassMoniker_BindToStorage
262 ******************************************************************************/
263 static HRESULT WINAPI
ClassMoniker_BindToStorage(IMoniker
* iface
,
269 TRACE("(%p,%p,%p,%p)\n",pbc
, pmkToLeft
, riid
, ppvResult
);
270 return IMoniker_BindToObject(iface
, pbc
, pmkToLeft
, riid
, ppvResult
);
273 /******************************************************************************
274 * ClassMoniker_Reduce
275 ******************************************************************************/
276 static HRESULT WINAPI
ClassMoniker_Reduce(IMoniker
* iface
,
278 DWORD dwReduceHowFar
,
279 IMoniker
** ppmkToLeft
,
280 IMoniker
** ppmkReduced
)
282 TRACE("(%p,%p,%d,%p,%p)\n",iface
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
287 IMoniker_AddRef(iface
);
289 *ppmkReduced
= iface
;
291 return MK_S_REDUCED_TO_SELF
;
293 /******************************************************************************
294 * ClassMoniker_ComposeWith
295 ******************************************************************************/
296 static HRESULT WINAPI
ClassMoniker_ComposeWith(IMoniker
* iface
,
298 BOOL fOnlyIfNotGeneric
,
299 IMoniker
** ppmkComposite
)
303 IEnumMoniker
* penumMk
=0;
304 IMoniker
*pmostLeftMk
=0;
305 IMoniker
* tempMkComposite
=0;
307 TRACE("(%p,%d,%p)\n", pmkRight
, fOnlyIfNotGeneric
, ppmkComposite
);
309 if ((ppmkComposite
==NULL
)||(pmkRight
==NULL
))
314 IMoniker_IsSystemMoniker(pmkRight
,&mkSys
);
316 /* If pmkRight is an anti-moniker, the returned moniker is NULL */
317 if(mkSys
==MKSYS_ANTIMONIKER
)
321 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */
322 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
324 if(mkSys
==MKSYS_GENERICCOMPOSITE
){
326 res
=IMoniker_Enum(pmkRight
,TRUE
,&penumMk
);
331 res
=IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
);
333 IMoniker_IsSystemMoniker(pmostLeftMk
,&mkSys2
);
335 if(mkSys2
==MKSYS_ANTIMONIKER
){
337 IMoniker_Release(pmostLeftMk
);
339 tempMkComposite
=iface
;
340 IMoniker_AddRef(iface
);
342 while(IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
)==S_OK
){
344 res
=CreateGenericComposite(tempMkComposite
,pmostLeftMk
,ppmkComposite
);
346 IMoniker_Release(tempMkComposite
);
347 IMoniker_Release(pmostLeftMk
);
349 tempMkComposite
=*ppmkComposite
;
350 IMoniker_AddRef(tempMkComposite
);
355 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
357 /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
358 composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
359 a NULL moniker and a return value of MK_E_NEEDGENERIC */
361 if (!fOnlyIfNotGeneric
)
362 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
365 return MK_E_NEEDGENERIC
;
368 /******************************************************************************
370 ******************************************************************************/
371 static HRESULT WINAPI
ClassMoniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
373 TRACE("(%p,%d,%p)\n",iface
,fForward
,ppenumMoniker
);
375 if (ppenumMoniker
== NULL
)
378 *ppenumMoniker
= NULL
;
383 /******************************************************************************
384 * ClassMoniker_IsEqual
385 ******************************************************************************/
386 static HRESULT WINAPI
ClassMoniker_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
390 LPOLESTR dispName1
,dispName2
;
392 HRESULT res
= S_FALSE
;
394 TRACE("(%p,%p)\n",iface
,pmkOtherMoniker
);
396 if (!pmkOtherMoniker
) return S_FALSE
;
399 /* check if both are ClassMoniker */
400 if(FAILED (IMoniker_GetClassID(pmkOtherMoniker
,&clsid
))) return S_FALSE
;
401 if(!IsEqualCLSID(&clsid
,&CLSID_ClassMoniker
)) return S_FALSE
;
403 /* check if both displaynames are the same */
404 if(SUCCEEDED ((res
= CreateBindCtx(0,&bind
)))) {
405 if(SUCCEEDED (IMoniker_GetDisplayName(iface
,bind
,NULL
,&dispName1
))) {
406 if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&dispName2
))) {
407 if(lstrcmpW(dispName1
,dispName2
)==0) res
= S_OK
;
408 CoTaskMemFree(dispName2
);
410 CoTaskMemFree(dispName1
);
416 /******************************************************************************
418 ******************************************************************************/
419 static HRESULT WINAPI
ClassMoniker_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
421 ClassMoniker
*This
= impl_from_IMoniker(iface
);
423 TRACE("(%p)\n", pdwHash
);
425 *pdwHash
= This
->clsid
.Data1
;
430 /******************************************************************************
431 * ClassMoniker_IsRunning
432 ******************************************************************************/
433 static HRESULT WINAPI
ClassMoniker_IsRunning(IMoniker
* iface
,
436 IMoniker
* pmkNewlyRunning
)
438 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pmkNewlyRunning
);
444 /******************************************************************************
445 * ClassMoniker_GetTimeOfLastChange
446 ******************************************************************************/
447 static HRESULT WINAPI
ClassMoniker_GetTimeOfLastChange(IMoniker
* iface
,
452 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pItemTime
);
454 return MK_E_UNAVAILABLE
;
457 /******************************************************************************
458 * ClassMoniker_Inverse
459 ******************************************************************************/
460 static HRESULT WINAPI
ClassMoniker_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
462 TRACE("(%p)\n",ppmk
);
467 return CreateAntiMoniker(ppmk
);
470 /******************************************************************************
471 * ClassMoniker_CommonPrefixWith
472 ******************************************************************************/
473 static HRESULT WINAPI
ClassMoniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
477 TRACE("(%p, %p)\n", pmkOther
, ppmkPrefix
);
481 IMoniker_IsSystemMoniker(pmkOther
, &mkSys
);
483 /* If the other moniker is an class moniker that is equal to this moniker, this method sets *ppmkPrefix */
484 /* to this moniker and returns MK_S_US */
486 if (mkSys
== MKSYS_CLASSMONIKER
)
488 if (IMoniker_IsEqual(iface
, pmkOther
) == S_OK
)
492 IMoniker_AddRef(iface
);
497 return MK_E_NOPREFIX
;
500 /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
501 /* the case where the other moniker is a generic composite. */
502 return MonikerCommonPrefixWith(iface
, pmkOther
, ppmkPrefix
);
505 /******************************************************************************
506 * ClassMoniker_RelativePathTo
507 ******************************************************************************/
508 static HRESULT WINAPI
ClassMoniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
510 TRACE("(%p, %p)\n",pmOther
,ppmkRelPath
);
517 return MK_E_NOTBINDABLE
;
520 /******************************************************************************
521 * ClassMoniker_GetDisplayName
522 ******************************************************************************/
523 static HRESULT WINAPI
ClassMoniker_GetDisplayName(IMoniker
* iface
,
526 LPOLESTR
*ppszDisplayName
)
528 ClassMoniker
*This
= impl_from_IMoniker(iface
);
529 static const WCHAR wszClsidPrefix
[] = {'c','l','s','i','d',':',0};
531 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, ppszDisplayName
);
533 if (!ppszDisplayName
)
539 *ppszDisplayName
= CoTaskMemAlloc(sizeof(wszClsidPrefix
) + (CHARS_IN_GUID
-2) * sizeof(WCHAR
));
541 StringFromGUID2(&This
->clsid
, *ppszDisplayName
+sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2, CHARS_IN_GUID
);
543 /* note: this overwrites the opening curly bracket of the CLSID string generated above */
544 memcpy(*ppszDisplayName
, wszClsidPrefix
, sizeof(wszClsidPrefix
)-sizeof(WCHAR
));
546 /* note: this overwrites the closing curly bracket of the CLSID string generated above */
547 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-2] = ':';
548 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-1] = '\0';
550 TRACE("string is %s\n", debugstr_w(*ppszDisplayName
));
554 /******************************************************************************
555 * ClassMoniker_ParseDisplayName
556 ******************************************************************************/
557 static HRESULT WINAPI
ClassMoniker_ParseDisplayName(IMoniker
* iface
,
560 LPOLESTR pszDisplayName
,
564 FIXME("(%p, %p, %s, %p, %p)\n", pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
568 /******************************************************************************
569 * ClassMoniker_IsSystemMoniker
570 ******************************************************************************/
571 static HRESULT WINAPI
ClassMoniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
573 TRACE("(%p,%p)\n",iface
,pwdMksys
);
578 *pwdMksys
= MKSYS_CLASSMONIKER
;
583 /*******************************************************************************
584 * ClassMonikerIROTData_QueryInterface
585 *******************************************************************************/
586 static HRESULT WINAPI
ClassMonikerROTData_QueryInterface(IROTData
*iface
,REFIID riid
,VOID
** ppvObject
)
589 ClassMoniker
*This
= impl_from_IROTData(iface
);
591 TRACE("(%p,%p,%p)\n",iface
,riid
,ppvObject
);
593 return IMoniker_QueryInterface(&This
->IMoniker_iface
, riid
, ppvObject
);
596 /***********************************************************************
597 * ClassMonikerIROTData_AddRef
599 static ULONG WINAPI
ClassMonikerROTData_AddRef(IROTData
*iface
)
601 ClassMoniker
*This
= impl_from_IROTData(iface
);
603 TRACE("(%p)\n",iface
);
605 return IMoniker_AddRef(&This
->IMoniker_iface
);
608 /***********************************************************************
609 * ClassMonikerIROTData_Release
611 static ULONG WINAPI
ClassMonikerROTData_Release(IROTData
* iface
)
613 ClassMoniker
*This
= impl_from_IROTData(iface
);
615 TRACE("(%p)\n",iface
);
617 return IMoniker_Release(&This
->IMoniker_iface
);
620 /******************************************************************************
621 * ClassMonikerIROTData_GetComparisonData
622 ******************************************************************************/
623 static HRESULT WINAPI
ClassMonikerROTData_GetComparisonData(IROTData
* iface
,
628 ClassMoniker
*This
= impl_from_IROTData(iface
);
630 TRACE("(%p, %u, %p)\n", pbData
, cbMax
, pcbData
);
632 *pcbData
= 2*sizeof(CLSID
);
633 if (cbMax
< *pcbData
)
634 return E_OUTOFMEMORY
;
636 /* write CLSID of the moniker */
637 memcpy(pbData
, &CLSID_ClassMoniker
, sizeof(CLSID
));
638 /* write CLSID the moniker represents */
639 memcpy(pbData
+sizeof(CLSID
), &This
->clsid
, sizeof(CLSID
));
644 /********************************************************************************/
645 /* Virtual function table for the ClassMoniker class which include IPersist,*/
646 /* IPersistStream and IMoniker functions. */
647 static const IMonikerVtbl ClassMonikerVtbl
=
649 ClassMoniker_QueryInterface
,
651 ClassMoniker_Release
,
652 ClassMoniker_GetClassID
,
653 ClassMoniker_IsDirty
,
656 ClassMoniker_GetSizeMax
,
657 ClassMoniker_BindToObject
,
658 ClassMoniker_BindToStorage
,
660 ClassMoniker_ComposeWith
,
662 ClassMoniker_IsEqual
,
664 ClassMoniker_IsRunning
,
665 ClassMoniker_GetTimeOfLastChange
,
666 ClassMoniker_Inverse
,
667 ClassMoniker_CommonPrefixWith
,
668 ClassMoniker_RelativePathTo
,
669 ClassMoniker_GetDisplayName
,
670 ClassMoniker_ParseDisplayName
,
671 ClassMoniker_IsSystemMoniker
674 /********************************************************************************/
675 /* Virtual function table for the IROTData class. */
676 static const IROTDataVtbl ROTDataVtbl
=
678 ClassMonikerROTData_QueryInterface
,
679 ClassMonikerROTData_AddRef
,
680 ClassMonikerROTData_Release
,
681 ClassMonikerROTData_GetComparisonData
684 /******************************************************************************
685 * ClassMoniker_Construct (local function)
686 *******************************************************************************/
687 static HRESULT
ClassMoniker_Construct(ClassMoniker
* This
, REFCLSID rclsid
)
689 TRACE("(%p,%s)\n",This
,debugstr_guid(rclsid
));
691 /* Initialize the virtual function table. */
692 This
->IMoniker_iface
.lpVtbl
= &ClassMonikerVtbl
;
693 This
->IROTData_iface
.lpVtbl
= &ROTDataVtbl
;
695 This
->clsid
= *rclsid
;
696 This
->pMarshal
= NULL
;
701 /******************************************************************************
702 * CreateClassMoniker [OLE32.@]
703 ******************************************************************************/
704 HRESULT WINAPI
CreateClassMoniker(REFCLSID rclsid
, IMoniker
**ppmk
)
706 ClassMoniker
* newClassMoniker
;
709 TRACE("(%s,%p)\n", debugstr_guid(rclsid
), ppmk
);
711 newClassMoniker
= HeapAlloc(GetProcessHeap(), 0, sizeof(ClassMoniker
));
713 if (!newClassMoniker
)
714 return STG_E_INSUFFICIENTMEMORY
;
716 hr
= ClassMoniker_Construct(newClassMoniker
, rclsid
);
720 HeapFree(GetProcessHeap(), 0, newClassMoniker
);
724 return ClassMoniker_QueryInterface(&newClassMoniker
->IMoniker_iface
, &IID_IMoniker
,
728 HRESULT
ClassMoniker_CreateFromDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
, LPDWORD pchEaten
,
732 LPCWSTR s
= strchrW(szDisplayName
, ':');
743 for (end
= s
; *end
&& (*end
!= ':'); end
++)
746 TRACE("parsing %s\n", debugstr_wn(s
, end
- s
));
748 /* validate the CLSID string */
751 if ((end
- s
!= 38) || (s
[37] != '}'))
763 if ((i
== 8)||(i
== 13)||(i
== 18)||(i
== 23))
769 if (!(((s
[i
] >= '0') && (s
[i
] <= '9')) ||
770 ((s
[i
] >= 'a') && (s
[i
] <= 'f')) ||
771 ((s
[i
] >= 'A') && (s
[i
] <= 'F'))))
775 /* quick lookup table */
776 memset(table
, 0, 256);
778 for (i
= 0; i
< 10; i
++)
780 for (i
= 0; i
< 6; i
++)
782 table
['A' + i
] = i
+10;
783 table
['a' + i
] = i
+10;
786 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
788 clsid
.Data1
= (table
[s
[0]] << 28 | table
[s
[1]] << 24 | table
[s
[2]] << 20 | table
[s
[3]] << 16 |
789 table
[s
[4]] << 12 | table
[s
[5]] << 8 | table
[s
[6]] << 4 | table
[s
[7]]);
790 clsid
.Data2
= table
[s
[9]] << 12 | table
[s
[10]] << 8 | table
[s
[11]] << 4 | table
[s
[12]];
791 clsid
.Data3
= table
[s
[14]] << 12 | table
[s
[15]] << 8 | table
[s
[16]] << 4 | table
[s
[17]];
793 /* these are just sequential bytes */
794 clsid
.Data4
[0] = table
[s
[19]] << 4 | table
[s
[20]];
795 clsid
.Data4
[1] = table
[s
[21]] << 4 | table
[s
[22]];
796 clsid
.Data4
[2] = table
[s
[24]] << 4 | table
[s
[25]];
797 clsid
.Data4
[3] = table
[s
[26]] << 4 | table
[s
[27]];
798 clsid
.Data4
[4] = table
[s
[28]] << 4 | table
[s
[29]];
799 clsid
.Data4
[5] = table
[s
[30]] << 4 | table
[s
[31]];
800 clsid
.Data4
[6] = table
[s
[32]] << 4 | table
[s
[33]];
801 clsid
.Data4
[7] = table
[s
[34]] << 4 | table
[s
[35]];
803 hr
= CreateClassMoniker(&clsid
, ppmk
);
805 *pchEaten
= (*end
== ':' ? end
+ 1 : end
) - szDisplayName
;
809 static HRESULT WINAPI
ClassMonikerCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
812 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
815 IClassFactory_AddRef(iface
);
818 return E_NOINTERFACE
;
821 static ULONG WINAPI
ClassMonikerCF_AddRef(LPCLASSFACTORY iface
)
823 return 2; /* non-heap based object */
826 static ULONG WINAPI
ClassMonikerCF_Release(LPCLASSFACTORY iface
)
828 return 1; /* non-heap based object */
831 static HRESULT WINAPI
ClassMonikerCF_CreateInstance(LPCLASSFACTORY iface
,
832 LPUNKNOWN pUnk
, REFIID riid
, LPVOID
*ppv
)
837 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
842 return CLASS_E_NOAGGREGATION
;
844 hr
= CreateClassMoniker(&CLSID_NULL
, &pmk
);
845 if (FAILED(hr
)) return hr
;
847 hr
= IMoniker_QueryInterface(pmk
, riid
, ppv
);
848 IMoniker_Release(pmk
);
853 static HRESULT WINAPI
ClassMonikerCF_LockServer(LPCLASSFACTORY iface
, BOOL fLock
)
855 FIXME("(%d), stub!\n",fLock
);
859 static const IClassFactoryVtbl ClassMonikerCFVtbl
=
861 ClassMonikerCF_QueryInterface
,
862 ClassMonikerCF_AddRef
,
863 ClassMonikerCF_Release
,
864 ClassMonikerCF_CreateInstance
,
865 ClassMonikerCF_LockServer
868 static IClassFactory ClassMonikerCF
= { &ClassMonikerCFVtbl
};
870 HRESULT
ClassMonikerCF_Create(REFIID riid
, LPVOID
*ppv
)
872 return IClassFactory_QueryInterface(&ClassMonikerCF
, riid
, ppv
);