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
32 #include "wine/debug.h"
34 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
39 #define CHARS_IN_GUID 39
41 /* ClassMoniker data structure */
42 typedef struct ClassMoniker
44 IMoniker IMoniker_iface
;
45 IROTData IROTData_iface
;
47 CLSID clsid
; /* clsid identified by this moniker */
48 IUnknown
*pMarshal
; /* custom marshaler */
51 static inline ClassMoniker
*impl_from_IMoniker(IMoniker
*iface
)
53 return CONTAINING_RECORD(iface
, ClassMoniker
, IMoniker_iface
);
56 static inline ClassMoniker
*impl_from_IROTData(IROTData
*iface
)
58 return CONTAINING_RECORD(iface
, ClassMoniker
, IROTData_iface
);
61 /*******************************************************************************
62 * ClassMoniker_QueryInterface
63 *******************************************************************************/
64 static HRESULT WINAPI
ClassMoniker_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
)
66 ClassMoniker
*This
= impl_from_IMoniker(iface
);
68 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
70 /* Perform a sanity check on the parameters.*/
74 /* Initialize the return parameter */
77 /* Compare the riid with the interface IDs implemented by this object.*/
78 if (IsEqualIID(&IID_IUnknown
, riid
) ||
79 IsEqualIID(&IID_IPersist
, riid
) ||
80 IsEqualIID(&IID_IPersistStream
, riid
) ||
81 IsEqualIID(&IID_IMoniker
, riid
))
85 else if (IsEqualIID(&IID_IROTData
, riid
))
86 *ppvObject
= &This
->IROTData_iface
;
87 else if (IsEqualIID(&IID_IMarshal
, riid
))
91 hr
= MonikerMarshal_Create(iface
, &This
->pMarshal
);
94 return IUnknown_QueryInterface(This
->pMarshal
, riid
, ppvObject
);
97 /* Check that we obtained an interface.*/
101 /* Query Interface always increases the reference count by one when it is successful */
102 IMoniker_AddRef(iface
);
107 /******************************************************************************
108 * ClassMoniker_AddRef
109 ******************************************************************************/
110 static ULONG WINAPI
ClassMoniker_AddRef(IMoniker
* iface
)
112 ClassMoniker
*This
= impl_from_IMoniker(iface
);
114 TRACE("(%p)\n",This
);
116 return InterlockedIncrement(&This
->ref
);
119 /******************************************************************************
120 * ClassMoniker_Release
121 ******************************************************************************/
122 static ULONG WINAPI
ClassMoniker_Release(IMoniker
* iface
)
124 ClassMoniker
*This
= impl_from_IMoniker(iface
);
127 TRACE("(%p)\n",This
);
129 ref
= InterlockedDecrement(&This
->ref
);
131 /* destroy the object if there are no more references to it */
134 if (This
->pMarshal
) IUnknown_Release(This
->pMarshal
);
135 HeapFree(GetProcessHeap(),0,This
);
141 /******************************************************************************
142 * ClassMoniker_GetClassID
143 ******************************************************************************/
144 static HRESULT WINAPI
ClassMoniker_GetClassID(IMoniker
* iface
,CLSID
*pClassID
)
146 TRACE("(%p,%p),stub!\n",iface
,pClassID
);
151 *pClassID
= CLSID_ClassMoniker
;
156 /******************************************************************************
157 * ClassMoniker_IsDirty
158 ******************************************************************************/
159 static HRESULT WINAPI
ClassMoniker_IsDirty(IMoniker
* iface
)
161 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
162 method in the OLE-provided moniker interfaces always return S_FALSE because
163 their internal state never changes. */
165 TRACE("(%p)\n",iface
);
170 /******************************************************************************
172 ******************************************************************************/
173 static HRESULT WINAPI
ClassMoniker_Load(IMoniker
* iface
,IStream
* pStm
)
175 ClassMoniker
*This
= impl_from_IMoniker(iface
);
179 TRACE("(%p)\n", pStm
);
181 hr
= IStream_Read(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
182 if (hr
!= S_OK
) return STG_E_READFAULT
;
184 hr
= IStream_Read(pStm
, &zero
, sizeof(zero
), NULL
);
185 if ((hr
!= S_OK
) || (zero
!= 0)) return STG_E_READFAULT
;
190 /******************************************************************************
192 ******************************************************************************/
193 static HRESULT WINAPI
ClassMoniker_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
)
195 ClassMoniker
*This
= impl_from_IMoniker(iface
);
199 TRACE("(%p, %s)\n", pStm
, fClearDirty
? "TRUE" : "FALSE");
201 hr
= IStream_Write(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
202 if (FAILED(hr
)) return hr
;
204 return IStream_Write(pStm
, &zero
, sizeof(zero
), NULL
);
207 /******************************************************************************
208 * ClassMoniker_GetSizeMax
209 ******************************************************************************/
210 static HRESULT WINAPI
ClassMoniker_GetSizeMax(IMoniker
* iface
,
211 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
213 TRACE("(%p)\n", pcbSize
);
215 pcbSize
->QuadPart
= sizeof(CLSID
) + sizeof(DWORD
);
220 /******************************************************************************
221 * ClassMoniker_BindToObject
222 ******************************************************************************/
223 static HRESULT WINAPI
ClassMoniker_BindToObject(IMoniker
* iface
,
229 ClassMoniker
*This
= impl_from_IMoniker(iface
);
231 IClassActivator
*pActivator
;
234 TRACE("(%p,%p,%p,%p)\n", pbc
, pmkToLeft
, riid
, ppvResult
);
236 bindopts
.cbStruct
= sizeof(bindopts
);
237 IBindCtx_GetBindOptions(pbc
, (BIND_OPTS
*)&bindopts
);
240 return CoGetClassObject(&This
->clsid
, bindopts
.dwClassContext
, NULL
,
244 hr
= IMoniker_BindToObject(pmkToLeft
, pbc
, NULL
, &IID_IClassActivator
,
245 (void **)&pActivator
);
246 if (FAILED(hr
)) return hr
;
248 hr
= IClassActivator_GetClassObject(pActivator
, &This
->clsid
,
249 bindopts
.dwClassContext
,
250 bindopts
.locale
, riid
, ppvResult
);
252 IClassActivator_Release(pActivator
);
258 /******************************************************************************
259 * ClassMoniker_BindToStorage
260 ******************************************************************************/
261 static HRESULT WINAPI
ClassMoniker_BindToStorage(IMoniker
* iface
,
267 TRACE("(%p,%p,%p,%p)\n",pbc
, pmkToLeft
, riid
, ppvResult
);
268 return IMoniker_BindToObject(iface
, pbc
, pmkToLeft
, riid
, ppvResult
);
271 /******************************************************************************
272 * ClassMoniker_Reduce
273 ******************************************************************************/
274 static HRESULT WINAPI
ClassMoniker_Reduce(IMoniker
* iface
,
276 DWORD dwReduceHowFar
,
277 IMoniker
** ppmkToLeft
,
278 IMoniker
** ppmkReduced
)
280 TRACE("(%p,%p,%d,%p,%p)\n",iface
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
285 IMoniker_AddRef(iface
);
287 *ppmkReduced
= iface
;
289 return MK_S_REDUCED_TO_SELF
;
291 /******************************************************************************
292 * ClassMoniker_ComposeWith
293 ******************************************************************************/
294 static HRESULT WINAPI
ClassMoniker_ComposeWith(IMoniker
* iface
,
296 BOOL fOnlyIfNotGeneric
,
297 IMoniker
** ppmkComposite
)
301 IEnumMoniker
* penumMk
=0;
302 IMoniker
*pmostLeftMk
=0;
303 IMoniker
* tempMkComposite
=0;
305 TRACE("(%p,%d,%p)\n", pmkRight
, fOnlyIfNotGeneric
, ppmkComposite
);
307 if ((ppmkComposite
==NULL
)||(pmkRight
==NULL
))
312 IMoniker_IsSystemMoniker(pmkRight
,&mkSys
);
314 /* If pmkRight is an anti-moniker, the returned moniker is NULL */
315 if(mkSys
==MKSYS_ANTIMONIKER
)
319 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */
320 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
322 if(mkSys
==MKSYS_GENERICCOMPOSITE
){
324 res
=IMoniker_Enum(pmkRight
,TRUE
,&penumMk
);
329 res
=IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
);
331 IMoniker_IsSystemMoniker(pmostLeftMk
,&mkSys2
);
333 if(mkSys2
==MKSYS_ANTIMONIKER
){
335 IMoniker_Release(pmostLeftMk
);
337 tempMkComposite
=iface
;
338 IMoniker_AddRef(iface
);
340 while(IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
)==S_OK
){
342 res
=CreateGenericComposite(tempMkComposite
,pmostLeftMk
,ppmkComposite
);
344 IMoniker_Release(tempMkComposite
);
345 IMoniker_Release(pmostLeftMk
);
347 tempMkComposite
=*ppmkComposite
;
348 IMoniker_AddRef(tempMkComposite
);
353 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
355 /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
356 composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
357 a NULL moniker and a return value of MK_E_NEEDGENERIC */
359 if (!fOnlyIfNotGeneric
)
360 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
363 return MK_E_NEEDGENERIC
;
366 /******************************************************************************
368 ******************************************************************************/
369 static HRESULT WINAPI
ClassMoniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
371 TRACE("(%p,%d,%p)\n",iface
,fForward
,ppenumMoniker
);
373 if (ppenumMoniker
== NULL
)
376 *ppenumMoniker
= NULL
;
381 /******************************************************************************
382 * ClassMoniker_IsEqual
383 ******************************************************************************/
384 static HRESULT WINAPI
ClassMoniker_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
388 LPOLESTR dispName1
,dispName2
;
390 HRESULT res
= S_FALSE
;
392 TRACE("(%p,%p)\n",iface
,pmkOtherMoniker
);
394 if (!pmkOtherMoniker
) return S_FALSE
;
397 /* check if both are ClassMoniker */
398 if(FAILED (IMoniker_GetClassID(pmkOtherMoniker
,&clsid
))) return S_FALSE
;
399 if(!IsEqualCLSID(&clsid
,&CLSID_ClassMoniker
)) return S_FALSE
;
401 /* check if both displaynames are the same */
402 if(SUCCEEDED ((res
= CreateBindCtx(0,&bind
)))) {
403 if(SUCCEEDED (IMoniker_GetDisplayName(iface
,bind
,NULL
,&dispName1
))) {
404 if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&dispName2
))) {
405 if(lstrcmpW(dispName1
,dispName2
)==0) res
= S_OK
;
406 CoTaskMemFree(dispName2
);
408 CoTaskMemFree(dispName1
);
414 /******************************************************************************
416 ******************************************************************************/
417 static HRESULT WINAPI
ClassMoniker_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
419 ClassMoniker
*This
= impl_from_IMoniker(iface
);
421 TRACE("(%p)\n", pdwHash
);
423 *pdwHash
= This
->clsid
.Data1
;
428 /******************************************************************************
429 * ClassMoniker_IsRunning
430 ******************************************************************************/
431 static HRESULT WINAPI
ClassMoniker_IsRunning(IMoniker
* iface
,
434 IMoniker
* pmkNewlyRunning
)
436 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pmkNewlyRunning
);
442 /******************************************************************************
443 * ClassMoniker_GetTimeOfLastChange
444 ******************************************************************************/
445 static HRESULT WINAPI
ClassMoniker_GetTimeOfLastChange(IMoniker
* iface
,
450 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pItemTime
);
452 return MK_E_UNAVAILABLE
;
455 /******************************************************************************
456 * ClassMoniker_Inverse
457 ******************************************************************************/
458 static HRESULT WINAPI
ClassMoniker_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
460 TRACE("(%p)\n",ppmk
);
465 return CreateAntiMoniker(ppmk
);
468 /******************************************************************************
469 * ClassMoniker_CommonPrefixWith
470 ******************************************************************************/
471 static HRESULT WINAPI
ClassMoniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
475 TRACE("(%p, %p)\n", pmkOther
, ppmkPrefix
);
479 IMoniker_IsSystemMoniker(pmkOther
, &mkSys
);
481 /* If the other moniker is an class moniker that is equal to this moniker, this method sets *ppmkPrefix */
482 /* to this moniker and returns MK_S_US */
484 if (mkSys
== MKSYS_CLASSMONIKER
)
486 if (IMoniker_IsEqual(iface
, pmkOther
) == S_OK
)
490 IMoniker_AddRef(iface
);
495 return MK_E_NOPREFIX
;
498 /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
499 /* the case where the other moniker is a generic composite. */
500 return MonikerCommonPrefixWith(iface
, pmkOther
, ppmkPrefix
);
503 /******************************************************************************
504 * ClassMoniker_RelativePathTo
505 ******************************************************************************/
506 static HRESULT WINAPI
ClassMoniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
508 TRACE("(%p, %p)\n",pmOther
,ppmkRelPath
);
515 return MK_E_NOTBINDABLE
;
518 /******************************************************************************
519 * ClassMoniker_GetDisplayName
520 ******************************************************************************/
521 static HRESULT WINAPI
ClassMoniker_GetDisplayName(IMoniker
* iface
,
524 LPOLESTR
*ppszDisplayName
)
526 ClassMoniker
*This
= impl_from_IMoniker(iface
);
527 static const WCHAR wszClsidPrefix
[] = {'c','l','s','i','d',':',0};
529 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, ppszDisplayName
);
531 if (!ppszDisplayName
)
537 *ppszDisplayName
= CoTaskMemAlloc(sizeof(wszClsidPrefix
) + (CHARS_IN_GUID
-2) * sizeof(WCHAR
));
539 StringFromGUID2(&This
->clsid
, *ppszDisplayName
+sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2, CHARS_IN_GUID
);
541 /* note: this overwrites the opening curly bracket of the CLSID string generated above */
542 memcpy(*ppszDisplayName
, wszClsidPrefix
, sizeof(wszClsidPrefix
)-sizeof(WCHAR
));
544 /* note: this overwrites the closing curly bracket of the CLSID string generated above */
545 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-2] = ':';
546 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-1] = '\0';
548 TRACE("string is %s\n", debugstr_w(*ppszDisplayName
));
552 /******************************************************************************
553 * ClassMoniker_ParseDisplayName
554 ******************************************************************************/
555 static HRESULT WINAPI
ClassMoniker_ParseDisplayName(IMoniker
* iface
,
558 LPOLESTR pszDisplayName
,
562 FIXME("(%p, %p, %s, %p, %p)\n", pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
566 /******************************************************************************
567 * ClassMoniker_IsSystemMoniker
568 ******************************************************************************/
569 static HRESULT WINAPI
ClassMoniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
571 TRACE("(%p,%p)\n",iface
,pwdMksys
);
576 *pwdMksys
= MKSYS_CLASSMONIKER
;
581 /*******************************************************************************
582 * ClassMonikerIROTData_QueryInterface
583 *******************************************************************************/
584 static HRESULT WINAPI
ClassMonikerROTData_QueryInterface(IROTData
*iface
,REFIID riid
,VOID
** ppvObject
)
587 ClassMoniker
*This
= impl_from_IROTData(iface
);
589 TRACE("(%p,%p,%p)\n",iface
,riid
,ppvObject
);
591 return IMoniker_QueryInterface(&This
->IMoniker_iface
, riid
, ppvObject
);
594 /***********************************************************************
595 * ClassMonikerIROTData_AddRef
597 static ULONG WINAPI
ClassMonikerROTData_AddRef(IROTData
*iface
)
599 ClassMoniker
*This
= impl_from_IROTData(iface
);
601 TRACE("(%p)\n",iface
);
603 return IMoniker_AddRef(&This
->IMoniker_iface
);
606 /***********************************************************************
607 * ClassMonikerIROTData_Release
609 static ULONG WINAPI
ClassMonikerROTData_Release(IROTData
* iface
)
611 ClassMoniker
*This
= impl_from_IROTData(iface
);
613 TRACE("(%p)\n",iface
);
615 return IMoniker_Release(&This
->IMoniker_iface
);
618 /******************************************************************************
619 * ClassMonikerIROTData_GetComparisonData
620 ******************************************************************************/
621 static HRESULT WINAPI
ClassMonikerROTData_GetComparisonData(IROTData
* iface
,
626 ClassMoniker
*This
= impl_from_IROTData(iface
);
628 TRACE("(%p, %u, %p)\n", pbData
, cbMax
, pcbData
);
630 *pcbData
= 2*sizeof(CLSID
);
631 if (cbMax
< *pcbData
)
632 return E_OUTOFMEMORY
;
634 /* write CLSID of the moniker */
635 memcpy(pbData
, &CLSID_ClassMoniker
, sizeof(CLSID
));
636 /* write CLSID the moniker represents */
637 memcpy(pbData
+sizeof(CLSID
), &This
->clsid
, sizeof(CLSID
));
642 /********************************************************************************/
643 /* Virtual function table for the ClassMoniker class which include IPersist,*/
644 /* IPersistStream and IMoniker functions. */
645 static const IMonikerVtbl ClassMonikerVtbl
=
647 ClassMoniker_QueryInterface
,
649 ClassMoniker_Release
,
650 ClassMoniker_GetClassID
,
651 ClassMoniker_IsDirty
,
654 ClassMoniker_GetSizeMax
,
655 ClassMoniker_BindToObject
,
656 ClassMoniker_BindToStorage
,
658 ClassMoniker_ComposeWith
,
660 ClassMoniker_IsEqual
,
662 ClassMoniker_IsRunning
,
663 ClassMoniker_GetTimeOfLastChange
,
664 ClassMoniker_Inverse
,
665 ClassMoniker_CommonPrefixWith
,
666 ClassMoniker_RelativePathTo
,
667 ClassMoniker_GetDisplayName
,
668 ClassMoniker_ParseDisplayName
,
669 ClassMoniker_IsSystemMoniker
672 /********************************************************************************/
673 /* Virtual function table for the IROTData class. */
674 static const IROTDataVtbl ROTDataVtbl
=
676 ClassMonikerROTData_QueryInterface
,
677 ClassMonikerROTData_AddRef
,
678 ClassMonikerROTData_Release
,
679 ClassMonikerROTData_GetComparisonData
682 /******************************************************************************
683 * ClassMoniker_Construct (local function)
684 *******************************************************************************/
685 static HRESULT
ClassMoniker_Construct(ClassMoniker
* This
, REFCLSID rclsid
)
687 TRACE("(%p,%s)\n",This
,debugstr_guid(rclsid
));
689 /* Initialize the virtual function table. */
690 This
->IMoniker_iface
.lpVtbl
= &ClassMonikerVtbl
;
691 This
->IROTData_iface
.lpVtbl
= &ROTDataVtbl
;
693 This
->clsid
= *rclsid
;
694 This
->pMarshal
= NULL
;
699 /******************************************************************************
700 * CreateClassMoniker [OLE32.@]
701 ******************************************************************************/
702 HRESULT WINAPI
CreateClassMoniker(REFCLSID rclsid
, IMoniker
**ppmk
)
704 ClassMoniker
* newClassMoniker
;
707 TRACE("(%s,%p)\n", debugstr_guid(rclsid
), ppmk
);
709 newClassMoniker
= HeapAlloc(GetProcessHeap(), 0, sizeof(ClassMoniker
));
711 if (!newClassMoniker
)
712 return STG_E_INSUFFICIENTMEMORY
;
714 hr
= ClassMoniker_Construct(newClassMoniker
, rclsid
);
718 HeapFree(GetProcessHeap(), 0, newClassMoniker
);
722 return ClassMoniker_QueryInterface(&newClassMoniker
->IMoniker_iface
, &IID_IMoniker
,
726 HRESULT
ClassMoniker_CreateFromDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
, LPDWORD pchEaten
,
730 LPCWSTR s
= strchrW(szDisplayName
, ':');
741 for (end
= s
; *end
&& (*end
!= ':'); end
++)
744 TRACE("parsing %s\n", debugstr_wn(s
, end
- s
));
746 /* validate the CLSID string */
749 if ((end
- s
!= 38) || (s
[37] != '}'))
761 if ((i
== 8)||(i
== 13)||(i
== 18)||(i
== 23))
767 if (!(((s
[i
] >= '0') && (s
[i
] <= '9')) ||
768 ((s
[i
] >= 'a') && (s
[i
] <= 'f')) ||
769 ((s
[i
] >= 'A') && (s
[i
] <= 'F'))))
773 /* quick lookup table */
774 memset(table
, 0, 256);
776 for (i
= 0; i
< 10; i
++)
778 for (i
= 0; i
< 6; i
++)
780 table
['A' + i
] = i
+10;
781 table
['a' + i
] = i
+10;
784 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
786 clsid
.Data1
= (table
[s
[0]] << 28 | table
[s
[1]] << 24 | table
[s
[2]] << 20 | table
[s
[3]] << 16 |
787 table
[s
[4]] << 12 | table
[s
[5]] << 8 | table
[s
[6]] << 4 | table
[s
[7]]);
788 clsid
.Data2
= table
[s
[9]] << 12 | table
[s
[10]] << 8 | table
[s
[11]] << 4 | table
[s
[12]];
789 clsid
.Data3
= table
[s
[14]] << 12 | table
[s
[15]] << 8 | table
[s
[16]] << 4 | table
[s
[17]];
791 /* these are just sequential bytes */
792 clsid
.Data4
[0] = table
[s
[19]] << 4 | table
[s
[20]];
793 clsid
.Data4
[1] = table
[s
[21]] << 4 | table
[s
[22]];
794 clsid
.Data4
[2] = table
[s
[24]] << 4 | table
[s
[25]];
795 clsid
.Data4
[3] = table
[s
[26]] << 4 | table
[s
[27]];
796 clsid
.Data4
[4] = table
[s
[28]] << 4 | table
[s
[29]];
797 clsid
.Data4
[5] = table
[s
[30]] << 4 | table
[s
[31]];
798 clsid
.Data4
[6] = table
[s
[32]] << 4 | table
[s
[33]];
799 clsid
.Data4
[7] = table
[s
[34]] << 4 | table
[s
[35]];
801 hr
= CreateClassMoniker(&clsid
, ppmk
);
803 *pchEaten
= (*end
== ':' ? end
+ 1 : end
) - szDisplayName
;
807 static HRESULT WINAPI
ClassMonikerCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
810 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
813 IClassFactory_AddRef(iface
);
816 return E_NOINTERFACE
;
819 static ULONG WINAPI
ClassMonikerCF_AddRef(LPCLASSFACTORY iface
)
821 return 2; /* non-heap based object */
824 static ULONG WINAPI
ClassMonikerCF_Release(LPCLASSFACTORY iface
)
826 return 1; /* non-heap based object */
829 static HRESULT WINAPI
ClassMonikerCF_CreateInstance(LPCLASSFACTORY iface
,
830 LPUNKNOWN pUnk
, REFIID riid
, LPVOID
*ppv
)
835 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
840 return CLASS_E_NOAGGREGATION
;
842 hr
= CreateClassMoniker(&CLSID_NULL
, &pmk
);
843 if (FAILED(hr
)) return hr
;
845 hr
= IMoniker_QueryInterface(pmk
, riid
, ppv
);
846 IMoniker_Release(pmk
);
851 static HRESULT WINAPI
ClassMonikerCF_LockServer(LPCLASSFACTORY iface
, BOOL fLock
)
853 FIXME("(%d), stub!\n",fLock
);
857 static const IClassFactoryVtbl ClassMonikerCFVtbl
=
859 ClassMonikerCF_QueryInterface
,
860 ClassMonikerCF_AddRef
,
861 ClassMonikerCF_Release
,
862 ClassMonikerCF_CreateInstance
,
863 ClassMonikerCF_LockServer
866 static IClassFactory ClassMonikerCF
= { &ClassMonikerCFVtbl
};
868 HRESULT
ClassMonikerCF_Create(REFIID riid
, LPVOID
*ppv
)
870 return IClassFactory_QueryInterface(&ClassMonikerCF
, riid
, ppv
);