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
= &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
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 return IStream_Write(pStm
, &zero
, sizeof(zero
), NULL
);
216 /******************************************************************************
217 * ClassMoniker_GetSizeMax
218 ******************************************************************************/
219 static HRESULT WINAPI
ClassMoniker_GetSizeMax(IMoniker
* iface
,
220 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
222 TRACE("(%p)\n", pcbSize
);
224 pcbSize
->QuadPart
= sizeof(CLSID
) + sizeof(DWORD
);
229 /******************************************************************************
230 * ClassMoniker_BindToObject
231 ******************************************************************************/
232 static HRESULT WINAPI
ClassMoniker_BindToObject(IMoniker
* iface
,
238 ClassMoniker
*This
= (ClassMoniker
*)iface
;
240 IClassActivator
*pActivator
;
243 TRACE("(%p,%p,%p,%p)\n", pbc
, pmkToLeft
, riid
, ppvResult
);
245 bindopts
.cbStruct
= sizeof(bindopts
);
246 IBindCtx_GetBindOptions(pbc
, (BIND_OPTS
*)&bindopts
);
249 return CoGetClassObject(&This
->clsid
, bindopts
.dwClassContext
, NULL
,
253 hr
= IMoniker_BindToObject(pmkToLeft
, pbc
, NULL
, &IID_IClassActivator
,
254 (void **)&pActivator
);
255 if (FAILED(hr
)) return hr
;
257 hr
= IClassActivator_GetClassObject(pActivator
, &This
->clsid
,
258 bindopts
.dwClassContext
,
259 bindopts
.locale
, riid
, ppvResult
);
261 IClassActivator_Release(pActivator
);
267 /******************************************************************************
268 * ClassMoniker_BindToStorage
269 ******************************************************************************/
270 static HRESULT WINAPI
ClassMoniker_BindToStorage(IMoniker
* iface
,
276 TRACE("(%p,%p,%p,%p)\n",pbc
, pmkToLeft
, riid
, ppvResult
);
277 return ClassMoniker_BindToObject(iface
, pbc
, pmkToLeft
, riid
, ppvResult
);
280 /******************************************************************************
281 * ClassMoniker_Reduce
282 ******************************************************************************/
283 static HRESULT WINAPI
ClassMoniker_Reduce(IMoniker
* iface
,
285 DWORD dwReduceHowFar
,
286 IMoniker
** ppmkToLeft
,
287 IMoniker
** ppmkReduced
)
289 TRACE("(%p,%p,%d,%p,%p)\n",iface
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
294 ClassMoniker_AddRef(iface
);
296 *ppmkReduced
= iface
;
298 return MK_S_REDUCED_TO_SELF
;
300 /******************************************************************************
301 * ClassMoniker_ComposeWith
302 ******************************************************************************/
303 static HRESULT WINAPI
ClassMoniker_ComposeWith(IMoniker
* iface
,
305 BOOL fOnlyIfNotGeneric
,
306 IMoniker
** ppmkComposite
)
310 IEnumMoniker
* penumMk
=0;
311 IMoniker
*pmostLeftMk
=0;
312 IMoniker
* tempMkComposite
=0;
314 TRACE("(%p,%d,%p)\n", pmkRight
, fOnlyIfNotGeneric
, ppmkComposite
);
316 if ((ppmkComposite
==NULL
)||(pmkRight
==NULL
))
321 IMoniker_IsSystemMoniker(pmkRight
,&mkSys
);
323 /* If pmkRight is an anti-moniker, the returned moniker is NULL */
324 if(mkSys
==MKSYS_ANTIMONIKER
)
328 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */
329 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
331 if(mkSys
==MKSYS_GENERICCOMPOSITE
){
333 res
=IMoniker_Enum(pmkRight
,TRUE
,&penumMk
);
338 res
=IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
);
340 IMoniker_IsSystemMoniker(pmostLeftMk
,&mkSys2
);
342 if(mkSys2
==MKSYS_ANTIMONIKER
){
344 IMoniker_Release(pmostLeftMk
);
346 tempMkComposite
=iface
;
347 IMoniker_AddRef(iface
);
349 while(IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
)==S_OK
){
351 res
=CreateGenericComposite(tempMkComposite
,pmostLeftMk
,ppmkComposite
);
353 IMoniker_Release(tempMkComposite
);
354 IMoniker_Release(pmostLeftMk
);
356 tempMkComposite
=*ppmkComposite
;
357 IMoniker_AddRef(tempMkComposite
);
362 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
364 /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
365 composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
366 a NULL moniker and a return value of MK_E_NEEDGENERIC */
368 if (!fOnlyIfNotGeneric
)
369 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
372 return MK_E_NEEDGENERIC
;
375 /******************************************************************************
377 ******************************************************************************/
378 static HRESULT WINAPI
ClassMoniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
380 TRACE("(%p,%d,%p)\n",iface
,fForward
,ppenumMoniker
);
382 if (ppenumMoniker
== NULL
)
385 *ppenumMoniker
= NULL
;
390 /******************************************************************************
391 * ClassMoniker_IsEqual
392 ******************************************************************************/
393 static HRESULT WINAPI
ClassMoniker_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
397 LPOLESTR dispName1
,dispName2
;
399 HRESULT res
= S_FALSE
;
401 TRACE("(%p,%p)\n",iface
,pmkOtherMoniker
);
403 if (!pmkOtherMoniker
) return S_FALSE
;
406 /* check if both are ClassMoniker */
407 if(FAILED (IMoniker_GetClassID(pmkOtherMoniker
,&clsid
))) return S_FALSE
;
408 if(!IsEqualCLSID(&clsid
,&CLSID_ClassMoniker
)) return S_FALSE
;
410 /* check if both displaynames are the same */
411 if(SUCCEEDED ((res
= CreateBindCtx(0,&bind
)))) {
412 if(SUCCEEDED (IMoniker_GetDisplayName(iface
,bind
,NULL
,&dispName1
))) {
413 if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&dispName2
))) {
414 if(lstrcmpW(dispName1
,dispName2
)==0) res
= S_OK
;
415 CoTaskMemFree(dispName2
);
417 CoTaskMemFree(dispName1
);
423 /******************************************************************************
425 ******************************************************************************/
426 static HRESULT WINAPI
ClassMoniker_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
428 ClassMoniker
*This
= (ClassMoniker
*)iface
;
430 TRACE("(%p)\n", pdwHash
);
432 *pdwHash
= This
->clsid
.Data1
;
437 /******************************************************************************
438 * ClassMoniker_IsRunning
439 ******************************************************************************/
440 static HRESULT WINAPI
ClassMoniker_IsRunning(IMoniker
* iface
,
443 IMoniker
* pmkNewlyRunning
)
445 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pmkNewlyRunning
);
451 /******************************************************************************
452 * ClassMoniker_GetTimeOfLastChange
453 ******************************************************************************/
454 static HRESULT WINAPI
ClassMoniker_GetTimeOfLastChange(IMoniker
* iface
,
459 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pItemTime
);
461 return MK_E_UNAVAILABLE
;
464 /******************************************************************************
465 * ClassMoniker_Inverse
466 ******************************************************************************/
467 static HRESULT WINAPI
ClassMoniker_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
469 TRACE("(%p)\n",ppmk
);
474 return CreateAntiMoniker(ppmk
);
477 /******************************************************************************
478 * ClassMoniker_CommonPrefixWith
479 ******************************************************************************/
480 static HRESULT WINAPI
ClassMoniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
484 TRACE("(%p, %p)\n", pmkOther
, ppmkPrefix
);
488 IMoniker_IsSystemMoniker(pmkOther
, &mkSys
);
490 /* If the other moniker is an class moniker that is equal to this moniker, this method sets *ppmkPrefix */
491 /* to this moniker and returns MK_S_US */
493 if (mkSys
== MKSYS_CLASSMONIKER
)
495 if (IMoniker_IsEqual(iface
, pmkOther
) == S_OK
)
499 IMoniker_AddRef(iface
);
504 return MK_E_NOPREFIX
;
507 /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
508 /* the case where the other moniker is a generic composite. */
509 return MonikerCommonPrefixWith(iface
, pmkOther
, ppmkPrefix
);
512 /******************************************************************************
513 * ClassMoniker_RelativePathTo
514 ******************************************************************************/
515 static HRESULT WINAPI
ClassMoniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
517 TRACE("(%p, %p)\n",pmOther
,ppmkRelPath
);
524 return MK_E_NOTBINDABLE
;
527 /******************************************************************************
528 * ClassMoniker_GetDisplayName
529 ******************************************************************************/
530 static HRESULT WINAPI
ClassMoniker_GetDisplayName(IMoniker
* iface
,
533 LPOLESTR
*ppszDisplayName
)
535 ClassMoniker
*This
= (ClassMoniker
*)iface
;
536 static const WCHAR wszClsidPrefix
[] = {'c','l','s','i','d',':',0};
538 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, ppszDisplayName
);
540 if (!ppszDisplayName
)
546 *ppszDisplayName
= CoTaskMemAlloc(sizeof(wszClsidPrefix
) + (CHARS_IN_GUID
-2) * sizeof(WCHAR
));
548 StringFromGUID2(&This
->clsid
, *ppszDisplayName
+sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2, CHARS_IN_GUID
);
550 /* note: this overwrites the opening curly bracket of the CLSID string generated above */
551 memcpy(*ppszDisplayName
, wszClsidPrefix
, sizeof(wszClsidPrefix
)-sizeof(WCHAR
));
553 /* note: this overwrites the closing curly bracket of the CLSID string generated above */
554 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-2] = ':';
555 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-1] = '\0';
557 TRACE("string is %s\n", debugstr_w(*ppszDisplayName
));
561 /******************************************************************************
562 * ClassMoniker_ParseDisplayName
563 ******************************************************************************/
564 static HRESULT WINAPI
ClassMoniker_ParseDisplayName(IMoniker
* iface
,
567 LPOLESTR pszDisplayName
,
571 FIXME("(%p, %p, %s, %p, %p)\n", pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
575 /******************************************************************************
576 * ClassMoniker_IsSystemMoniker
577 ******************************************************************************/
578 static HRESULT WINAPI
ClassMoniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
580 TRACE("(%p,%p)\n",iface
,pwdMksys
);
585 *pwdMksys
= MKSYS_CLASSMONIKER
;
590 /*******************************************************************************
591 * ClassMonikerIROTData_QueryInterface
592 *******************************************************************************/
593 static HRESULT WINAPI
ClassMonikerROTData_QueryInterface(IROTData
*iface
,REFIID riid
,VOID
** ppvObject
)
596 IMoniker
*This
= impl_from_IROTData(iface
);
598 TRACE("(%p,%p,%p)\n",iface
,riid
,ppvObject
);
600 return ClassMoniker_QueryInterface(This
, riid
, ppvObject
);
603 /***********************************************************************
604 * ClassMonikerIROTData_AddRef
606 static ULONG WINAPI
ClassMonikerROTData_AddRef(IROTData
*iface
)
608 IMoniker
*This
= impl_from_IROTData(iface
);
610 TRACE("(%p)\n",iface
);
612 return ClassMoniker_AddRef(This
);
615 /***********************************************************************
616 * ClassMonikerIROTData_Release
618 static ULONG WINAPI
ClassMonikerROTData_Release(IROTData
* iface
)
620 IMoniker
*This
= impl_from_IROTData(iface
);
622 TRACE("(%p)\n",iface
);
624 return ClassMoniker_Release(This
);
627 /******************************************************************************
628 * ClassMonikerIROTData_GetComparisonData
629 ******************************************************************************/
630 static HRESULT WINAPI
ClassMonikerROTData_GetComparisonData(IROTData
* iface
,
635 ClassMoniker
*This
= (ClassMoniker
*)impl_from_IROTData(iface
);
637 TRACE("(%p, %u, %p)\n", pbData
, cbMax
, pcbData
);
639 *pcbData
= 2*sizeof(CLSID
);
640 if (cbMax
< *pcbData
)
641 return E_OUTOFMEMORY
;
643 /* write CLSID of the moniker */
644 memcpy(pbData
, &CLSID_ClassMoniker
, sizeof(CLSID
));
645 /* write CLSID the moniker represents */
646 memcpy(pbData
+sizeof(CLSID
), &This
->clsid
, sizeof(CLSID
));
651 /********************************************************************************/
652 /* Virtual function table for the ClassMoniker class which include IPersist,*/
653 /* IPersistStream and IMoniker functions. */
654 static const IMonikerVtbl ClassMonikerVtbl
=
656 ClassMoniker_QueryInterface
,
658 ClassMoniker_Release
,
659 ClassMoniker_GetClassID
,
660 ClassMoniker_IsDirty
,
663 ClassMoniker_GetSizeMax
,
664 ClassMoniker_BindToObject
,
665 ClassMoniker_BindToStorage
,
667 ClassMoniker_ComposeWith
,
669 ClassMoniker_IsEqual
,
671 ClassMoniker_IsRunning
,
672 ClassMoniker_GetTimeOfLastChange
,
673 ClassMoniker_Inverse
,
674 ClassMoniker_CommonPrefixWith
,
675 ClassMoniker_RelativePathTo
,
676 ClassMoniker_GetDisplayName
,
677 ClassMoniker_ParseDisplayName
,
678 ClassMoniker_IsSystemMoniker
681 /********************************************************************************/
682 /* Virtual function table for the IROTData class. */
683 static const IROTDataVtbl ROTDataVtbl
=
685 ClassMonikerROTData_QueryInterface
,
686 ClassMonikerROTData_AddRef
,
687 ClassMonikerROTData_Release
,
688 ClassMonikerROTData_GetComparisonData
691 /******************************************************************************
692 * ClassMoniker_Construct (local function)
693 *******************************************************************************/
694 static HRESULT
ClassMoniker_Construct(ClassMoniker
* This
, REFCLSID rclsid
)
696 TRACE("(%p,%s)\n",This
,debugstr_guid(rclsid
));
698 /* Initialize the virtual function table. */
699 This
->lpVtbl
= &ClassMonikerVtbl
;
700 This
->lpVtblRotData
= &ROTDataVtbl
;
702 This
->clsid
= *rclsid
;
703 This
->pMarshal
= NULL
;
708 /******************************************************************************
709 * CreateClassMoniker [OLE32.@]
710 ******************************************************************************/
711 HRESULT WINAPI
CreateClassMoniker(REFCLSID rclsid
, IMoniker
**ppmk
)
713 ClassMoniker
* newClassMoniker
;
716 TRACE("(%s,%p)\n", debugstr_guid(rclsid
), ppmk
);
718 newClassMoniker
= HeapAlloc(GetProcessHeap(), 0, sizeof(ClassMoniker
));
720 if (!newClassMoniker
)
721 return STG_E_INSUFFICIENTMEMORY
;
723 hr
= ClassMoniker_Construct(newClassMoniker
, rclsid
);
727 HeapFree(GetProcessHeap(), 0, newClassMoniker
);
731 return ClassMoniker_QueryInterface((IMoniker
*)newClassMoniker
, &IID_IMoniker
, (void**)ppmk
);
734 HRESULT
ClassMoniker_CreateFromDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
,
735 LPDWORD pchEaten
, LPMONIKER
*ppmk
)
738 LPCWSTR s
= strchrW(szDisplayName
, ':');
749 for (end
= s
; *end
&& (*end
!= ':'); end
++)
752 TRACE("parsing %s\n", debugstr_wn(s
, end
- s
));
754 /* validate the CLSID string */
757 if ((end
- s
!= 38) || (s
[37] != '}'))
769 if ((i
== 8)||(i
== 13)||(i
== 18)||(i
== 23))
775 if (!(((s
[i
] >= '0') && (s
[i
] <= '9')) ||
776 ((s
[i
] >= 'a') && (s
[i
] <= 'f')) ||
777 ((s
[i
] >= 'A') && (s
[i
] <= 'F'))))
781 /* quick lookup table */
782 memset(table
, 0, 256);
784 for (i
= 0; i
< 10; i
++)
786 for (i
= 0; i
< 6; i
++)
788 table
['A' + i
] = i
+10;
789 table
['a' + i
] = i
+10;
792 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
794 clsid
.Data1
= (table
[s
[0]] << 28 | table
[s
[1]] << 24 | table
[s
[2]] << 20 | table
[s
[3]] << 16 |
795 table
[s
[4]] << 12 | table
[s
[5]] << 8 | table
[s
[6]] << 4 | table
[s
[7]]);
796 clsid
.Data2
= table
[s
[9]] << 12 | table
[s
[10]] << 8 | table
[s
[11]] << 4 | table
[s
[12]];
797 clsid
.Data3
= table
[s
[14]] << 12 | table
[s
[15]] << 8 | table
[s
[16]] << 4 | table
[s
[17]];
799 /* these are just sequential bytes */
800 clsid
.Data4
[0] = table
[s
[19]] << 4 | table
[s
[20]];
801 clsid
.Data4
[1] = table
[s
[21]] << 4 | table
[s
[22]];
802 clsid
.Data4
[2] = table
[s
[24]] << 4 | table
[s
[25]];
803 clsid
.Data4
[3] = table
[s
[26]] << 4 | table
[s
[27]];
804 clsid
.Data4
[4] = table
[s
[28]] << 4 | table
[s
[29]];
805 clsid
.Data4
[5] = table
[s
[30]] << 4 | table
[s
[31]];
806 clsid
.Data4
[6] = table
[s
[32]] << 4 | table
[s
[33]];
807 clsid
.Data4
[7] = table
[s
[34]] << 4 | table
[s
[35]];
809 hr
= CreateClassMoniker(&clsid
, ppmk
);
811 *pchEaten
= (*end
== ':' ? end
+ 1 : end
) - szDisplayName
;
815 static HRESULT WINAPI
ClassMonikerCF_QueryInterface(LPCLASSFACTORY iface
,
816 REFIID riid
, LPVOID
*ppv
)
819 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
822 IUnknown_AddRef(iface
);
825 return E_NOINTERFACE
;
828 static ULONG WINAPI
ClassMonikerCF_AddRef(LPCLASSFACTORY iface
)
830 return 2; /* non-heap based object */
833 static ULONG WINAPI
ClassMonikerCF_Release(LPCLASSFACTORY iface
)
835 return 1; /* non-heap based object */
838 static HRESULT WINAPI
ClassMonikerCF_CreateInstance(LPCLASSFACTORY iface
,
839 LPUNKNOWN pUnk
, REFIID riid
, LPVOID
*ppv
)
844 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
849 return CLASS_E_NOAGGREGATION
;
851 hr
= CreateClassMoniker(&CLSID_NULL
, &pmk
);
852 if (FAILED(hr
)) return hr
;
854 hr
= IMoniker_QueryInterface(pmk
, riid
, ppv
);
855 IMoniker_Release(pmk
);
860 static HRESULT WINAPI
ClassMonikerCF_LockServer(LPCLASSFACTORY iface
, BOOL fLock
)
862 FIXME("(%d), stub!\n",fLock
);
866 static const IClassFactoryVtbl ClassMonikerCFVtbl
=
868 ClassMonikerCF_QueryInterface
,
869 ClassMonikerCF_AddRef
,
870 ClassMonikerCF_Release
,
871 ClassMonikerCF_CreateInstance
,
872 ClassMonikerCF_LockServer
874 static const IClassFactoryVtbl
*ClassMonikerCF
= &ClassMonikerCFVtbl
;
876 HRESULT
ClassMonikerCF_Create(REFIID riid
, LPVOID
*ppv
)
878 return IClassFactory_QueryInterface((IClassFactory
*)&ClassMonikerCF
, riid
, ppv
);