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_Destroy (local function)
123 *******************************************************************************/
124 static HRESULT
ClassMoniker_Destroy(ClassMoniker
* This
)
126 TRACE("(%p)\n",This
);
128 if (This
->pMarshal
) IUnknown_Release(This
->pMarshal
);
130 HeapFree(GetProcessHeap(),0,This
);
135 /******************************************************************************
136 * ClassMoniker_Release
137 ******************************************************************************/
138 static ULONG WINAPI
ClassMoniker_Release(IMoniker
* iface
)
140 ClassMoniker
*This
= impl_from_IMoniker(iface
);
143 TRACE("(%p)\n",This
);
145 ref
= InterlockedDecrement(&This
->ref
);
147 /* destroy the object if there's no more reference on it */
148 if (ref
== 0) ClassMoniker_Destroy(This
);
153 /******************************************************************************
154 * ClassMoniker_GetClassID
155 ******************************************************************************/
156 static HRESULT WINAPI
ClassMoniker_GetClassID(IMoniker
* iface
,CLSID
*pClassID
)
158 TRACE("(%p,%p),stub!\n",iface
,pClassID
);
163 *pClassID
= CLSID_ClassMoniker
;
168 /******************************************************************************
169 * ClassMoniker_IsDirty
170 ******************************************************************************/
171 static HRESULT WINAPI
ClassMoniker_IsDirty(IMoniker
* iface
)
173 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
174 method in the OLE-provided moniker interfaces always return S_FALSE because
175 their internal state never changes. */
177 TRACE("(%p)\n",iface
);
182 /******************************************************************************
184 ******************************************************************************/
185 static HRESULT WINAPI
ClassMoniker_Load(IMoniker
* iface
,IStream
* pStm
)
187 ClassMoniker
*This
= impl_from_IMoniker(iface
);
191 TRACE("(%p)\n", pStm
);
193 hr
= IStream_Read(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
194 if (hr
!= S_OK
) return STG_E_READFAULT
;
196 hr
= IStream_Read(pStm
, &zero
, sizeof(zero
), NULL
);
197 if ((hr
!= S_OK
) || (zero
!= 0)) return STG_E_READFAULT
;
202 /******************************************************************************
204 ******************************************************************************/
205 static HRESULT WINAPI
ClassMoniker_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
)
207 ClassMoniker
*This
= impl_from_IMoniker(iface
);
211 TRACE("(%p, %s)\n", pStm
, fClearDirty
? "TRUE" : "FALSE");
213 hr
= IStream_Write(pStm
, &This
->clsid
, sizeof(This
->clsid
), NULL
);
214 if (FAILED(hr
)) return hr
;
216 return IStream_Write(pStm
, &zero
, sizeof(zero
), NULL
);
219 /******************************************************************************
220 * ClassMoniker_GetSizeMax
221 ******************************************************************************/
222 static HRESULT WINAPI
ClassMoniker_GetSizeMax(IMoniker
* iface
,
223 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
225 TRACE("(%p)\n", pcbSize
);
227 pcbSize
->QuadPart
= sizeof(CLSID
) + sizeof(DWORD
);
232 /******************************************************************************
233 * ClassMoniker_BindToObject
234 ******************************************************************************/
235 static HRESULT WINAPI
ClassMoniker_BindToObject(IMoniker
* iface
,
241 ClassMoniker
*This
= impl_from_IMoniker(iface
);
243 IClassActivator
*pActivator
;
246 TRACE("(%p,%p,%p,%p)\n", pbc
, pmkToLeft
, riid
, ppvResult
);
248 bindopts
.cbStruct
= sizeof(bindopts
);
249 IBindCtx_GetBindOptions(pbc
, (BIND_OPTS
*)&bindopts
);
252 return CoGetClassObject(&This
->clsid
, bindopts
.dwClassContext
, NULL
,
256 hr
= IMoniker_BindToObject(pmkToLeft
, pbc
, NULL
, &IID_IClassActivator
,
257 (void **)&pActivator
);
258 if (FAILED(hr
)) return hr
;
260 hr
= IClassActivator_GetClassObject(pActivator
, &This
->clsid
,
261 bindopts
.dwClassContext
,
262 bindopts
.locale
, riid
, ppvResult
);
264 IClassActivator_Release(pActivator
);
270 /******************************************************************************
271 * ClassMoniker_BindToStorage
272 ******************************************************************************/
273 static HRESULT WINAPI
ClassMoniker_BindToStorage(IMoniker
* iface
,
279 TRACE("(%p,%p,%p,%p)\n",pbc
, pmkToLeft
, riid
, ppvResult
);
280 return ClassMoniker_BindToObject(iface
, pbc
, pmkToLeft
, riid
, ppvResult
);
283 /******************************************************************************
284 * ClassMoniker_Reduce
285 ******************************************************************************/
286 static HRESULT WINAPI
ClassMoniker_Reduce(IMoniker
* iface
,
288 DWORD dwReduceHowFar
,
289 IMoniker
** ppmkToLeft
,
290 IMoniker
** ppmkReduced
)
292 TRACE("(%p,%p,%d,%p,%p)\n",iface
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
297 ClassMoniker_AddRef(iface
);
299 *ppmkReduced
= iface
;
301 return MK_S_REDUCED_TO_SELF
;
303 /******************************************************************************
304 * ClassMoniker_ComposeWith
305 ******************************************************************************/
306 static HRESULT WINAPI
ClassMoniker_ComposeWith(IMoniker
* iface
,
308 BOOL fOnlyIfNotGeneric
,
309 IMoniker
** ppmkComposite
)
313 IEnumMoniker
* penumMk
=0;
314 IMoniker
*pmostLeftMk
=0;
315 IMoniker
* tempMkComposite
=0;
317 TRACE("(%p,%d,%p)\n", pmkRight
, fOnlyIfNotGeneric
, ppmkComposite
);
319 if ((ppmkComposite
==NULL
)||(pmkRight
==NULL
))
324 IMoniker_IsSystemMoniker(pmkRight
,&mkSys
);
326 /* If pmkRight is an anti-moniker, the returned moniker is NULL */
327 if(mkSys
==MKSYS_ANTIMONIKER
)
331 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */
332 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
334 if(mkSys
==MKSYS_GENERICCOMPOSITE
){
336 res
=IMoniker_Enum(pmkRight
,TRUE
,&penumMk
);
341 res
=IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
);
343 IMoniker_IsSystemMoniker(pmostLeftMk
,&mkSys2
);
345 if(mkSys2
==MKSYS_ANTIMONIKER
){
347 IMoniker_Release(pmostLeftMk
);
349 tempMkComposite
=iface
;
350 IMoniker_AddRef(iface
);
352 while(IEnumMoniker_Next(penumMk
,1,&pmostLeftMk
,NULL
)==S_OK
){
354 res
=CreateGenericComposite(tempMkComposite
,pmostLeftMk
,ppmkComposite
);
356 IMoniker_Release(tempMkComposite
);
357 IMoniker_Release(pmostLeftMk
);
359 tempMkComposite
=*ppmkComposite
;
360 IMoniker_AddRef(tempMkComposite
);
365 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
367 /* If pmkRight is not an anti-moniker, the method combines the two monikers into a generic
368 composite if fOnlyIfNotGeneric is FALSE; if fOnlyIfNotGeneric is TRUE, the method returns
369 a NULL moniker and a return value of MK_E_NEEDGENERIC */
371 if (!fOnlyIfNotGeneric
)
372 return CreateGenericComposite(iface
,pmkRight
,ppmkComposite
);
375 return MK_E_NEEDGENERIC
;
378 /******************************************************************************
380 ******************************************************************************/
381 static HRESULT WINAPI
ClassMoniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
383 TRACE("(%p,%d,%p)\n",iface
,fForward
,ppenumMoniker
);
385 if (ppenumMoniker
== NULL
)
388 *ppenumMoniker
= NULL
;
393 /******************************************************************************
394 * ClassMoniker_IsEqual
395 ******************************************************************************/
396 static HRESULT WINAPI
ClassMoniker_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
400 LPOLESTR dispName1
,dispName2
;
402 HRESULT res
= S_FALSE
;
404 TRACE("(%p,%p)\n",iface
,pmkOtherMoniker
);
406 if (!pmkOtherMoniker
) return S_FALSE
;
409 /* check if both are ClassMoniker */
410 if(FAILED (IMoniker_GetClassID(pmkOtherMoniker
,&clsid
))) return S_FALSE
;
411 if(!IsEqualCLSID(&clsid
,&CLSID_ClassMoniker
)) return S_FALSE
;
413 /* check if both displaynames are the same */
414 if(SUCCEEDED ((res
= CreateBindCtx(0,&bind
)))) {
415 if(SUCCEEDED (IMoniker_GetDisplayName(iface
,bind
,NULL
,&dispName1
))) {
416 if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&dispName2
))) {
417 if(lstrcmpW(dispName1
,dispName2
)==0) res
= S_OK
;
418 CoTaskMemFree(dispName2
);
420 CoTaskMemFree(dispName1
);
426 /******************************************************************************
428 ******************************************************************************/
429 static HRESULT WINAPI
ClassMoniker_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
431 ClassMoniker
*This
= impl_from_IMoniker(iface
);
433 TRACE("(%p)\n", pdwHash
);
435 *pdwHash
= This
->clsid
.Data1
;
440 /******************************************************************************
441 * ClassMoniker_IsRunning
442 ******************************************************************************/
443 static HRESULT WINAPI
ClassMoniker_IsRunning(IMoniker
* iface
,
446 IMoniker
* pmkNewlyRunning
)
448 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pmkNewlyRunning
);
454 /******************************************************************************
455 * ClassMoniker_GetTimeOfLastChange
456 ******************************************************************************/
457 static HRESULT WINAPI
ClassMoniker_GetTimeOfLastChange(IMoniker
* iface
,
462 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, pItemTime
);
464 return MK_E_UNAVAILABLE
;
467 /******************************************************************************
468 * ClassMoniker_Inverse
469 ******************************************************************************/
470 static HRESULT WINAPI
ClassMoniker_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
472 TRACE("(%p)\n",ppmk
);
477 return CreateAntiMoniker(ppmk
);
480 /******************************************************************************
481 * ClassMoniker_CommonPrefixWith
482 ******************************************************************************/
483 static HRESULT WINAPI
ClassMoniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
487 TRACE("(%p, %p)\n", pmkOther
, ppmkPrefix
);
491 IMoniker_IsSystemMoniker(pmkOther
, &mkSys
);
493 /* If the other moniker is an class moniker that is equal to this moniker, this method sets *ppmkPrefix */
494 /* to this moniker and returns MK_S_US */
496 if (mkSys
== MKSYS_CLASSMONIKER
)
498 if (IMoniker_IsEqual(iface
, pmkOther
) == S_OK
)
502 IMoniker_AddRef(iface
);
507 return MK_E_NOPREFIX
;
510 /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
511 /* the case where the other moniker is a generic composite. */
512 return MonikerCommonPrefixWith(iface
, pmkOther
, ppmkPrefix
);
515 /******************************************************************************
516 * ClassMoniker_RelativePathTo
517 ******************************************************************************/
518 static HRESULT WINAPI
ClassMoniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
520 TRACE("(%p, %p)\n",pmOther
,ppmkRelPath
);
527 return MK_E_NOTBINDABLE
;
530 /******************************************************************************
531 * ClassMoniker_GetDisplayName
532 ******************************************************************************/
533 static HRESULT WINAPI
ClassMoniker_GetDisplayName(IMoniker
* iface
,
536 LPOLESTR
*ppszDisplayName
)
538 ClassMoniker
*This
= impl_from_IMoniker(iface
);
539 static const WCHAR wszClsidPrefix
[] = {'c','l','s','i','d',':',0};
541 TRACE("(%p, %p, %p)\n", pbc
, pmkToLeft
, ppszDisplayName
);
543 if (!ppszDisplayName
)
549 *ppszDisplayName
= CoTaskMemAlloc(sizeof(wszClsidPrefix
) + (CHARS_IN_GUID
-2) * sizeof(WCHAR
));
551 StringFromGUID2(&This
->clsid
, *ppszDisplayName
+sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2, CHARS_IN_GUID
);
553 /* note: this overwrites the opening curly bracket of the CLSID string generated above */
554 memcpy(*ppszDisplayName
, wszClsidPrefix
, sizeof(wszClsidPrefix
)-sizeof(WCHAR
));
556 /* note: this overwrites the closing curly bracket of the CLSID string generated above */
557 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-2] = ':';
558 (*ppszDisplayName
)[sizeof(wszClsidPrefix
)/sizeof(WCHAR
)-2+CHARS_IN_GUID
-1] = '\0';
560 TRACE("string is %s\n", debugstr_w(*ppszDisplayName
));
564 /******************************************************************************
565 * ClassMoniker_ParseDisplayName
566 ******************************************************************************/
567 static HRESULT WINAPI
ClassMoniker_ParseDisplayName(IMoniker
* iface
,
570 LPOLESTR pszDisplayName
,
574 FIXME("(%p, %p, %s, %p, %p)\n", pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
578 /******************************************************************************
579 * ClassMoniker_IsSystemMoniker
580 ******************************************************************************/
581 static HRESULT WINAPI
ClassMoniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
583 TRACE("(%p,%p)\n",iface
,pwdMksys
);
588 *pwdMksys
= MKSYS_CLASSMONIKER
;
593 /*******************************************************************************
594 * ClassMonikerIROTData_QueryInterface
595 *******************************************************************************/
596 static HRESULT WINAPI
ClassMonikerROTData_QueryInterface(IROTData
*iface
,REFIID riid
,VOID
** ppvObject
)
599 ClassMoniker
*This
= impl_from_IROTData(iface
);
601 TRACE("(%p,%p,%p)\n",iface
,riid
,ppvObject
);
603 return ClassMoniker_QueryInterface(&This
->IMoniker_iface
, riid
, ppvObject
);
606 /***********************************************************************
607 * ClassMonikerIROTData_AddRef
609 static ULONG WINAPI
ClassMonikerROTData_AddRef(IROTData
*iface
)
611 ClassMoniker
*This
= impl_from_IROTData(iface
);
613 TRACE("(%p)\n",iface
);
615 return ClassMoniker_AddRef(&This
->IMoniker_iface
);
618 /***********************************************************************
619 * ClassMonikerIROTData_Release
621 static ULONG WINAPI
ClassMonikerROTData_Release(IROTData
* iface
)
623 ClassMoniker
*This
= impl_from_IROTData(iface
);
625 TRACE("(%p)\n",iface
);
627 return ClassMoniker_Release(&This
->IMoniker_iface
);
630 /******************************************************************************
631 * ClassMonikerIROTData_GetComparisonData
632 ******************************************************************************/
633 static HRESULT WINAPI
ClassMonikerROTData_GetComparisonData(IROTData
* iface
,
638 ClassMoniker
*This
= impl_from_IROTData(iface
);
640 TRACE("(%p, %u, %p)\n", pbData
, cbMax
, pcbData
);
642 *pcbData
= 2*sizeof(CLSID
);
643 if (cbMax
< *pcbData
)
644 return E_OUTOFMEMORY
;
646 /* write CLSID of the moniker */
647 memcpy(pbData
, &CLSID_ClassMoniker
, sizeof(CLSID
));
648 /* write CLSID the moniker represents */
649 memcpy(pbData
+sizeof(CLSID
), &This
->clsid
, sizeof(CLSID
));
654 /********************************************************************************/
655 /* Virtual function table for the ClassMoniker class which include IPersist,*/
656 /* IPersistStream and IMoniker functions. */
657 static const IMonikerVtbl ClassMonikerVtbl
=
659 ClassMoniker_QueryInterface
,
661 ClassMoniker_Release
,
662 ClassMoniker_GetClassID
,
663 ClassMoniker_IsDirty
,
666 ClassMoniker_GetSizeMax
,
667 ClassMoniker_BindToObject
,
668 ClassMoniker_BindToStorage
,
670 ClassMoniker_ComposeWith
,
672 ClassMoniker_IsEqual
,
674 ClassMoniker_IsRunning
,
675 ClassMoniker_GetTimeOfLastChange
,
676 ClassMoniker_Inverse
,
677 ClassMoniker_CommonPrefixWith
,
678 ClassMoniker_RelativePathTo
,
679 ClassMoniker_GetDisplayName
,
680 ClassMoniker_ParseDisplayName
,
681 ClassMoniker_IsSystemMoniker
684 /********************************************************************************/
685 /* Virtual function table for the IROTData class. */
686 static const IROTDataVtbl ROTDataVtbl
=
688 ClassMonikerROTData_QueryInterface
,
689 ClassMonikerROTData_AddRef
,
690 ClassMonikerROTData_Release
,
691 ClassMonikerROTData_GetComparisonData
694 /******************************************************************************
695 * ClassMoniker_Construct (local function)
696 *******************************************************************************/
697 static HRESULT
ClassMoniker_Construct(ClassMoniker
* This
, REFCLSID rclsid
)
699 TRACE("(%p,%s)\n",This
,debugstr_guid(rclsid
));
701 /* Initialize the virtual function table. */
702 This
->IMoniker_iface
.lpVtbl
= &ClassMonikerVtbl
;
703 This
->IROTData_iface
.lpVtbl
= &ROTDataVtbl
;
705 This
->clsid
= *rclsid
;
706 This
->pMarshal
= NULL
;
711 /******************************************************************************
712 * CreateClassMoniker [OLE32.@]
713 ******************************************************************************/
714 HRESULT WINAPI
CreateClassMoniker(REFCLSID rclsid
, IMoniker
**ppmk
)
716 ClassMoniker
* newClassMoniker
;
719 TRACE("(%s,%p)\n", debugstr_guid(rclsid
), ppmk
);
721 newClassMoniker
= HeapAlloc(GetProcessHeap(), 0, sizeof(ClassMoniker
));
723 if (!newClassMoniker
)
724 return STG_E_INSUFFICIENTMEMORY
;
726 hr
= ClassMoniker_Construct(newClassMoniker
, rclsid
);
730 HeapFree(GetProcessHeap(), 0, newClassMoniker
);
734 return ClassMoniker_QueryInterface(&newClassMoniker
->IMoniker_iface
, &IID_IMoniker
,
738 HRESULT
ClassMoniker_CreateFromDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
, LPDWORD pchEaten
,
742 LPCWSTR s
= strchrW(szDisplayName
, ':');
753 for (end
= s
; *end
&& (*end
!= ':'); end
++)
756 TRACE("parsing %s\n", debugstr_wn(s
, end
- s
));
758 /* validate the CLSID string */
761 if ((end
- s
!= 38) || (s
[37] != '}'))
773 if ((i
== 8)||(i
== 13)||(i
== 18)||(i
== 23))
779 if (!(((s
[i
] >= '0') && (s
[i
] <= '9')) ||
780 ((s
[i
] >= 'a') && (s
[i
] <= 'f')) ||
781 ((s
[i
] >= 'A') && (s
[i
] <= 'F'))))
785 /* quick lookup table */
786 memset(table
, 0, 256);
788 for (i
= 0; i
< 10; i
++)
790 for (i
= 0; i
< 6; i
++)
792 table
['A' + i
] = i
+10;
793 table
['a' + i
] = i
+10;
796 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
798 clsid
.Data1
= (table
[s
[0]] << 28 | table
[s
[1]] << 24 | table
[s
[2]] << 20 | table
[s
[3]] << 16 |
799 table
[s
[4]] << 12 | table
[s
[5]] << 8 | table
[s
[6]] << 4 | table
[s
[7]]);
800 clsid
.Data2
= table
[s
[9]] << 12 | table
[s
[10]] << 8 | table
[s
[11]] << 4 | table
[s
[12]];
801 clsid
.Data3
= table
[s
[14]] << 12 | table
[s
[15]] << 8 | table
[s
[16]] << 4 | table
[s
[17]];
803 /* these are just sequential bytes */
804 clsid
.Data4
[0] = table
[s
[19]] << 4 | table
[s
[20]];
805 clsid
.Data4
[1] = table
[s
[21]] << 4 | table
[s
[22]];
806 clsid
.Data4
[2] = table
[s
[24]] << 4 | table
[s
[25]];
807 clsid
.Data4
[3] = table
[s
[26]] << 4 | table
[s
[27]];
808 clsid
.Data4
[4] = table
[s
[28]] << 4 | table
[s
[29]];
809 clsid
.Data4
[5] = table
[s
[30]] << 4 | table
[s
[31]];
810 clsid
.Data4
[6] = table
[s
[32]] << 4 | table
[s
[33]];
811 clsid
.Data4
[7] = table
[s
[34]] << 4 | table
[s
[35]];
813 hr
= CreateClassMoniker(&clsid
, ppmk
);
815 *pchEaten
= (*end
== ':' ? end
+ 1 : end
) - szDisplayName
;
819 static HRESULT WINAPI
ClassMonikerCF_QueryInterface(LPCLASSFACTORY iface
,
820 REFIID riid
, LPVOID
*ppv
)
823 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
826 IUnknown_AddRef(iface
);
829 return E_NOINTERFACE
;
832 static ULONG WINAPI
ClassMonikerCF_AddRef(LPCLASSFACTORY iface
)
834 return 2; /* non-heap based object */
837 static ULONG WINAPI
ClassMonikerCF_Release(LPCLASSFACTORY iface
)
839 return 1; /* non-heap based object */
842 static HRESULT WINAPI
ClassMonikerCF_CreateInstance(LPCLASSFACTORY iface
,
843 LPUNKNOWN pUnk
, REFIID riid
, LPVOID
*ppv
)
848 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
853 return CLASS_E_NOAGGREGATION
;
855 hr
= CreateClassMoniker(&CLSID_NULL
, &pmk
);
856 if (FAILED(hr
)) return hr
;
858 hr
= IMoniker_QueryInterface(pmk
, riid
, ppv
);
859 IMoniker_Release(pmk
);
864 static HRESULT WINAPI
ClassMonikerCF_LockServer(LPCLASSFACTORY iface
, BOOL fLock
)
866 FIXME("(%d), stub!\n",fLock
);
870 static const IClassFactoryVtbl ClassMonikerCFVtbl
=
872 ClassMonikerCF_QueryInterface
,
873 ClassMonikerCF_AddRef
,
874 ClassMonikerCF_Release
,
875 ClassMonikerCF_CreateInstance
,
876 ClassMonikerCF_LockServer
878 static const IClassFactoryVtbl
*ClassMonikerCF
= &ClassMonikerCFVtbl
;
880 HRESULT
ClassMonikerCF_Create(REFIID riid
, LPVOID
*ppv
)
882 return IClassFactory_QueryInterface((IClassFactory
*)&ClassMonikerCF
, riid
, ppv
);