Added support in winebuild for resolving function imports (-sym option).
[wine/multimedia.git] / dlls / ole32 / antimoniker.c
blob0c8da5c9ab49badfb76458b0060deddc6fdc3f31
1 /***************************************************************************************
2 * AntiMonikers implementation
4 * Copyright 1999 Noomen Hamza
5 ***************************************************************************************/
7 #include <assert.h>
8 #include "winbase.h"
9 #include "winerror.h"
10 #include "wine/unicode.h"
11 #include "wine/obj_base.h"
12 #include "wine/obj_misc.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_moniker.h"
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(ole);
19 /* AntiMoniker data structure */
20 typedef struct AntiMonikerImpl{
22 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/
24 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
25 * two monikers are equal. That's whay IROTData interface is implemented by monikers.
27 ICOM_VTABLE(IROTData)* lpvtbl2; /* VTable relative to the IROTData interface.*/
29 ULONG ref; /* reference counter for this object */
31 } AntiMonikerImpl;
33 /********************************************************************************/
34 /* AntiMoniker prototype functions : */
36 /* IUnknown prototype functions */
37 static HRESULT WINAPI AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject);
38 static ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface);
39 static ULONG WINAPI AntiMonikerImpl_Release(IMoniker* iface);
41 /* IPersist prototype functions */
42 static HRESULT WINAPI AntiMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID);
44 /* IPersistStream prototype functions */
45 static HRESULT WINAPI AntiMonikerImpl_IsDirty(IMoniker* iface);
46 static HRESULT WINAPI AntiMonikerImpl_Load(IMoniker* iface, IStream* pStm);
47 static HRESULT WINAPI AntiMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty);
48 static HRESULT WINAPI AntiMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize);
50 /* IMoniker prototype functions */
51 static HRESULT WINAPI AntiMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
52 static HRESULT WINAPI AntiMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
53 static HRESULT WINAPI AntiMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced);
54 static HRESULT WINAPI AntiMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite);
55 static HRESULT WINAPI AntiMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker);
56 static HRESULT WINAPI AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker);
57 static HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash);
58 static HRESULT WINAPI AntiMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning);
59 static HRESULT WINAPI AntiMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pAntiTime);
60 static HRESULT WINAPI AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk);
61 static HRESULT WINAPI AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix);
62 static HRESULT WINAPI AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath);
63 static HRESULT WINAPI AntiMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName);
64 static HRESULT WINAPI AntiMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut);
65 static HRESULT WINAPI AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys);
67 /********************************************************************************/
68 /* IROTData prototype functions */
70 /* IUnknown prototype functions */
71 static HRESULT WINAPI AntiMonikerROTDataImpl_QueryInterface(IROTData* iface,REFIID riid,VOID** ppvObject);
72 static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData* iface);
73 static ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface);
75 /* IROTData prototype function */
76 static HRESULT WINAPI AntiMonikerROTDataImpl_GetComparaisonData(IROTData* iface,BYTE* pbData,ULONG cbMax,ULONG* pcbData);
78 /* Local function used by AntiMoniker implementation */
79 HRESULT WINAPI AntiMonikerImpl_Construct(AntiMonikerImpl* iface);
80 HRESULT WINAPI AntiMonikerImpl_Destroy(AntiMonikerImpl* iface);
82 /********************************************************************************/
83 /* Virtual function table for the AntiMonikerImpl class witch include Ipersist,*/
84 /* IPersistStream and IMoniker functions. */
85 static ICOM_VTABLE(IMoniker) VT_AntiMonikerImpl =
87 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
88 AntiMonikerImpl_QueryInterface,
89 AntiMonikerImpl_AddRef,
90 AntiMonikerImpl_Release,
91 AntiMonikerImpl_GetClassID,
92 AntiMonikerImpl_IsDirty,
93 AntiMonikerImpl_Load,
94 AntiMonikerImpl_Save,
95 AntiMonikerImpl_GetSizeMax,
96 AntiMonikerImpl_BindToObject,
97 AntiMonikerImpl_BindToStorage,
98 AntiMonikerImpl_Reduce,
99 AntiMonikerImpl_ComposeWith,
100 AntiMonikerImpl_Enum,
101 AntiMonikerImpl_IsEqual,
102 AntiMonikerImpl_Hash,
103 AntiMonikerImpl_IsRunning,
104 AntiMonikerImpl_GetTimeOfLastChange,
105 AntiMonikerImpl_Inverse,
106 AntiMonikerImpl_CommonPrefixWith,
107 AntiMonikerImpl_RelativePathTo,
108 AntiMonikerImpl_GetDisplayName,
109 AntiMonikerImpl_ParseDisplayName,
110 AntiMonikerImpl_IsSystemMoniker
113 /********************************************************************************/
114 /* Virtual function table for the IROTData class. */
115 static ICOM_VTABLE(IROTData) VT_ROTDataImpl =
117 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
118 AntiMonikerROTDataImpl_QueryInterface,
119 AntiMonikerROTDataImpl_AddRef,
120 AntiMonikerROTDataImpl_Release,
121 AntiMonikerROTDataImpl_GetComparaisonData
124 /*******************************************************************************
125 * AntiMoniker_QueryInterface
126 *******************************************************************************/
127 HRESULT WINAPI AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
129 ICOM_THIS(AntiMonikerImpl,iface);
131 TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
133 /* Perform a sanity check on the parameters.*/
134 if ( (This==0) || (ppvObject==0) )
135 return E_INVALIDARG;
137 /* Initialize the return parameter */
138 *ppvObject = 0;
140 /* Compare the riid with the interface IDs implemented by this object.*/
141 if (IsEqualIID(&IID_IUnknown, riid) ||
142 IsEqualIID(&IID_IPersist, riid) ||
143 IsEqualIID(&IID_IPersistStream, riid) ||
144 IsEqualIID(&IID_IMoniker, riid)
146 *ppvObject = iface;
147 else if (IsEqualIID(&IID_IROTData, riid))
148 *ppvObject = (IROTData*)&(This->lpvtbl2);
150 /* Check that we obtained an interface.*/
151 if ((*ppvObject)==0)
152 return E_NOINTERFACE;
154 /* Query Interface always increases the reference count by one when it is successful */
155 AntiMonikerImpl_AddRef(iface);
157 return S_OK;
160 /******************************************************************************
161 * AntiMoniker_AddRef
162 ******************************************************************************/
163 ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface)
165 ICOM_THIS(AntiMonikerImpl,iface);
167 TRACE("(%p)\n",This);
169 return ++(This->ref);
172 /******************************************************************************
173 * AntiMoniker_Release
174 ******************************************************************************/
175 ULONG WINAPI AntiMonikerImpl_Release(IMoniker* iface)
177 ICOM_THIS(AntiMonikerImpl,iface);
179 TRACE("(%p)\n",This);
181 This->ref--;
183 /* destroy the object if there's no more reference on it */
184 if (This->ref==0){
186 AntiMonikerImpl_Destroy(This);
188 return 0;
190 return This->ref;;
193 /******************************************************************************
194 * AntiMoniker_GetClassID
195 ******************************************************************************/
196 HRESULT WINAPI AntiMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID)
198 TRACE("(%p,%p),stub!\n",iface,pClassID);
200 if (pClassID==NULL)
201 return E_POINTER;
203 *pClassID = CLSID_AntiMoniker;
205 return S_OK;
208 /******************************************************************************
209 * AntiMoniker_IsDirty
210 ******************************************************************************/
211 HRESULT WINAPI AntiMonikerImpl_IsDirty(IMoniker* iface)
213 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
214 method in the OLE-provided moniker interfaces always return S_FALSE because
215 their internal state never changes. */
217 TRACE("(%p)\n",iface);
219 return S_FALSE;
222 /******************************************************************************
223 * AntiMoniker_Load
224 ******************************************************************************/
225 HRESULT WINAPI AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm)
227 DWORD constant=1,dwbuffer;
228 HRESULT res;
230 /* data read by this function is only a DWORD constant (must be 1) ! */
231 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),NULL);
233 if (SUCCEEDED(res)&& dwbuffer!=constant)
234 return E_FAIL;
236 return res;
239 /******************************************************************************
240 * AntiMoniker_Save
241 ******************************************************************************/
242 HRESULT WINAPI AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
244 DWORD constant=1;
245 HRESULT res;
247 /* data writen by this function is only a DWORD constant seted to 1 ! */
248 res=IStream_Write(pStm,&constant,sizeof(constant),NULL);
250 return res;
253 /******************************************************************************
254 * AntiMoniker_GetSizeMax
255 ******************************************************************************/
256 HRESULT WINAPI AntiMonikerImpl_GetSizeMax(IMoniker* iface,
257 ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */
259 TRACE("(%p,%p)\n",iface,pcbSize);
261 if (pcbSize!=NULL)
262 return E_POINTER;
264 /* for more details see AntiMonikerImpl_Save coments */
266 /* Normaly the sizemax must be the size of DWORD ! but I tested this function it ususlly return 16 bytes */
267 /* more than the number of bytes used by AntiMoniker::Save function */
268 pcbSize->s.LowPart = sizeof(DWORD)+16;
270 pcbSize->s.HighPart=0;
272 return S_OK;
275 /******************************************************************************
276 * AntiMoniker_Construct (local function)
277 *******************************************************************************/
278 HRESULT WINAPI AntiMonikerImpl_Construct(AntiMonikerImpl* This)
281 TRACE("(%p)\n",This);
283 /* Initialize the virtual fgunction table. */
284 This->lpvtbl1 = &VT_AntiMonikerImpl;
285 This->lpvtbl2 = &VT_ROTDataImpl;
286 This->ref = 0;
288 return S_OK;
291 /******************************************************************************
292 * AntiMoniker_Destroy (local function)
293 *******************************************************************************/
294 HRESULT WINAPI AntiMonikerImpl_Destroy(AntiMonikerImpl* This)
296 TRACE("(%p)\n",This);
298 return HeapFree(GetProcessHeap(),0,This);
301 /******************************************************************************
302 * AntiMoniker_BindToObject
303 ******************************************************************************/
304 HRESULT WINAPI AntiMonikerImpl_BindToObject(IMoniker* iface,
305 IBindCtx* pbc,
306 IMoniker* pmkToLeft,
307 REFIID riid,
308 VOID** ppvResult)
310 TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
311 return E_NOTIMPL;
314 /******************************************************************************
315 * AntiMoniker_BindToStorage
316 ******************************************************************************/
317 HRESULT WINAPI AntiMonikerImpl_BindToStorage(IMoniker* iface,
318 IBindCtx* pbc,
319 IMoniker* pmkToLeft,
320 REFIID riid,
321 VOID** ppvResult)
323 TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
324 return E_NOTIMPL;
327 /******************************************************************************
328 * AntiMoniker_Reduce
329 ******************************************************************************/
330 HRESULT WINAPI AntiMonikerImpl_Reduce(IMoniker* iface,
331 IBindCtx* pbc,
332 DWORD dwReduceHowFar,
333 IMoniker** ppmkToLeft,
334 IMoniker** ppmkReduced)
336 TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
338 if (ppmkReduced==NULL)
339 return E_POINTER;
341 AntiMonikerImpl_AddRef(iface);
343 *ppmkReduced=iface;
345 return MK_S_REDUCED_TO_SELF;
347 /******************************************************************************
348 * AntiMoniker_ComposeWith
349 ******************************************************************************/
350 HRESULT WINAPI AntiMonikerImpl_ComposeWith(IMoniker* iface,
351 IMoniker* pmkRight,
352 BOOL fOnlyIfNotGeneric,
353 IMoniker** ppmkComposite)
356 TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
358 if ((ppmkComposite==NULL)||(pmkRight==NULL))
359 return E_POINTER;
361 *ppmkComposite=0;
363 if (fOnlyIfNotGeneric)
364 return MK_E_NEEDGENERIC;
365 else
366 return CreateGenericComposite(iface,pmkRight,ppmkComposite);
369 /******************************************************************************
370 * AntiMoniker_Enum
371 ******************************************************************************/
372 HRESULT WINAPI AntiMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
374 TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
376 if (ppenumMoniker == NULL)
377 return E_POINTER;
379 *ppenumMoniker = NULL;
381 return S_OK;
384 /******************************************************************************
385 * AntiMoniker_IsEqual
386 ******************************************************************************/
387 HRESULT WINAPI AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
389 DWORD mkSys;
391 TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
393 if (pmkOtherMoniker==NULL)
394 return S_FALSE;
396 IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys);
398 if (mkSys==MKSYS_ANTIMONIKER)
399 return S_OK;
400 else
401 return S_FALSE;
404 /******************************************************************************
405 * AntiMoniker_Hash
406 ******************************************************************************/
407 HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
409 if (pdwHash==NULL)
410 return E_POINTER;
412 *pdwHash=0;
414 return S_OK;
417 /******************************************************************************
418 * AntiMoniker_IsRunning
419 ******************************************************************************/
420 HRESULT WINAPI AntiMonikerImpl_IsRunning(IMoniker* iface,
421 IBindCtx* pbc,
422 IMoniker* pmkToLeft,
423 IMoniker* pmkNewlyRunning)
425 IRunningObjectTable* rot;
426 HRESULT res;
428 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
430 if (pbc==NULL)
431 return E_INVALIDARG;
433 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
435 if (FAILED(res))
436 return res;
438 res = IRunningObjectTable_IsRunning(rot,iface);
440 IRunningObjectTable_Release(rot);
442 return res;
445 /******************************************************************************
446 * AntiMoniker_GetTimeOfLastChange
447 ******************************************************************************/
448 HRESULT WINAPI AntiMonikerImpl_GetTimeOfLastChange(IMoniker* iface,
449 IBindCtx* pbc,
450 IMoniker* pmkToLeft,
451 FILETIME* pAntiTime)
453 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pAntiTime);
454 return E_NOTIMPL;
457 /******************************************************************************
458 * AntiMoniker_Inverse
459 ******************************************************************************/
460 HRESULT WINAPI AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
462 TRACE("(%p,%p)\n",iface,ppmk);
464 if (ppmk==NULL)
465 return E_POINTER;
467 *ppmk=0;
469 return MK_E_NOINVERSE;
472 /******************************************************************************
473 * AntiMoniker_CommonPrefixWith
474 ******************************************************************************/
475 HRESULT WINAPI AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
477 DWORD mkSys;
479 IMoniker_IsSystemMoniker(pmkOther,&mkSys);
481 if(mkSys==MKSYS_ITEMMONIKER){
483 IMoniker_AddRef(iface);
485 *ppmkPrefix=iface;
487 IMoniker_AddRef(iface);
489 return MK_S_US;
491 else
492 return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
495 /******************************************************************************
496 * AntiMoniker_RelativePathTo
497 ******************************************************************************/
498 HRESULT WINAPI AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
500 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
502 if (ppmkRelPath==NULL)
503 return E_POINTER;
505 IMoniker_AddRef(pmOther);
507 *ppmkRelPath=pmOther;
509 return MK_S_HIM;
512 /******************************************************************************
513 * AntiMoniker_GetDisplayName
514 ******************************************************************************/
515 HRESULT WINAPI AntiMonikerImpl_GetDisplayName(IMoniker* iface,
516 IBindCtx* pbc,
517 IMoniker* pmkToLeft,
518 LPOLESTR *ppszDisplayName)
520 WCHAR back[]={'\\','.','.',0};
522 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
524 if (ppszDisplayName==NULL)
525 return E_POINTER;
527 if (pmkToLeft!=NULL){
528 FIXME("() pmkToLeft!=NULL not implemented \n");
529 return E_NOTIMPL;
532 *ppszDisplayName=CoTaskMemAlloc(sizeof(back));
534 if (*ppszDisplayName==NULL)
535 return E_OUTOFMEMORY;
537 strcpyW(*ppszDisplayName,back);
539 return S_OK;
542 /******************************************************************************
543 * AntiMoniker_ParseDisplayName
544 ******************************************************************************/
545 HRESULT WINAPI AntiMonikerImpl_ParseDisplayName(IMoniker* iface,
546 IBindCtx* pbc,
547 IMoniker* pmkToLeft,
548 LPOLESTR pszDisplayName,
549 ULONG* pchEaten,
550 IMoniker** ppmkOut)
552 TRACE("(%p,%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
553 return E_NOTIMPL;
556 /******************************************************************************
557 * AntiMoniker_IsSystemMonker
558 ******************************************************************************/
559 HRESULT WINAPI AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
561 TRACE("(%p,%p)\n",iface,pwdMksys);
563 if (!pwdMksys)
564 return E_POINTER;
566 (*pwdMksys)=MKSYS_ANTIMONIKER;
568 return S_OK;
571 /*******************************************************************************
572 * AntiMonikerIROTData_QueryInterface
573 *******************************************************************************/
574 HRESULT WINAPI AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
577 ICOM_THIS_From_IROTData(IMoniker, iface);
579 TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
581 return AntiMonikerImpl_QueryInterface(This, riid, ppvObject);
584 /***********************************************************************
585 * AntiMonikerIROTData_AddRef
587 ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface)
589 ICOM_THIS_From_IROTData(IMoniker, iface);
591 TRACE("(%p)\n",iface);
593 return AntiMonikerImpl_AddRef(This);
596 /***********************************************************************
597 * AntiMonikerIROTData_Release
599 ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface)
601 ICOM_THIS_From_IROTData(IMoniker, iface);
603 TRACE("(%p)\n",iface);
605 return AntiMonikerImpl_Release(This);
608 /******************************************************************************
609 * AntiMonikerIROTData_GetComparaisonData
610 ******************************************************************************/
611 HRESULT WINAPI AntiMonikerROTDataImpl_GetComparaisonData(IROTData* iface,
612 BYTE* pbData,
613 ULONG cbMax,
614 ULONG* pcbData)
616 FIXME("(),stub!\n");
617 return E_NOTIMPL;
620 /******************************************************************************
621 * CreateAntiMoniker [OLE.55]
622 ******************************************************************************/
623 HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
625 AntiMonikerImpl* newAntiMoniker = 0;
626 HRESULT hr = S_OK;
627 IID riid=IID_IMoniker;
629 TRACE("(%p)\n",ppmk);
631 newAntiMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(AntiMonikerImpl));
633 if (newAntiMoniker == 0)
634 return STG_E_INSUFFICIENTMEMORY;
636 hr = AntiMonikerImpl_Construct(newAntiMoniker);
638 if (FAILED(hr)){
640 HeapFree(GetProcessHeap(),0,newAntiMoniker);
641 return hr;
644 hr = AntiMonikerImpl_QueryInterface((IMoniker*)newAntiMoniker,&riid,(void**)ppmk);
646 return hr;