ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

antimoniker.c
Go to the documentation of this file.
00001 /*
00002  *                        AntiMonikers implementation
00003  *
00004  *               Copyright 1999  Noomen Hamza
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <assert.h>
00022 #include <stdarg.h>
00023 #include <string.h>
00024 
00025 #define COBJMACROS
00026 #define NONAMELESSUNION
00027 #define NONAMELESSSTRUCT
00028 
00029 #include "windef.h"
00030 #include "winbase.h"
00031 #include "winerror.h"
00032 #include "objbase.h"
00033 #include "wine/debug.h"
00034 #include "moniker.h"
00035 
00036 WINE_DEFAULT_DEBUG_CHANNEL(ole);
00037 
00038 /* AntiMoniker data structure */
00039 typedef struct AntiMonikerImpl{
00040     IMoniker IMoniker_iface;
00041     IROTData IROTData_iface;
00042     LONG ref;
00043     IUnknown *pMarshal; /* custom marshaler */
00044 } AntiMonikerImpl;
00045 
00046 static inline AntiMonikerImpl *impl_from_IMoniker(IMoniker *iface)
00047 {
00048     return CONTAINING_RECORD(iface, AntiMonikerImpl, IMoniker_iface);
00049 }
00050 
00051 static inline AntiMonikerImpl *impl_from_IROTData(IROTData *iface)
00052 {
00053     return CONTAINING_RECORD(iface, AntiMonikerImpl, IROTData_iface);
00054 }
00055 
00056 
00057 /*******************************************************************************
00058  *        AntiMoniker_QueryInterface
00059  *******************************************************************************/
00060 static HRESULT WINAPI
00061 AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
00062 {
00063     AntiMonikerImpl *This = impl_from_IMoniker(iface);
00064 
00065     TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
00066 
00067     /* Perform a sanity check on the parameters.*/
00068     if ( ppvObject==0 )
00069     return E_INVALIDARG;
00070 
00071     /* Initialize the return parameter */
00072     *ppvObject = 0;
00073 
00074     /* Compare the riid with the interface IDs implemented by this object.*/
00075     if (IsEqualIID(&IID_IUnknown, riid) ||
00076         IsEqualIID(&IID_IPersist, riid) ||
00077         IsEqualIID(&IID_IPersistStream, riid) ||
00078         IsEqualIID(&IID_IMoniker, riid))
00079         *ppvObject = iface;
00080     else if (IsEqualIID(&IID_IROTData, riid))
00081         *ppvObject = &This->IROTData_iface;
00082     else if (IsEqualIID(&IID_IMarshal, riid))
00083     {
00084         HRESULT hr = S_OK;
00085         if (!This->pMarshal)
00086             hr = MonikerMarshal_Create(iface, &This->pMarshal);
00087         if (hr != S_OK)
00088             return hr;
00089         return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
00090     }
00091 
00092     /* Check that we obtained an interface.*/
00093     if ((*ppvObject)==0)
00094         return E_NOINTERFACE;
00095 
00096     /* always increase the reference count by one when it is successful */
00097     IMoniker_AddRef(iface);
00098 
00099     return S_OK;
00100 }
00101 
00102 /******************************************************************************
00103  *        AntiMoniker_AddRef
00104  ******************************************************************************/
00105 static ULONG WINAPI
00106 AntiMonikerImpl_AddRef(IMoniker* iface)
00107 {
00108     AntiMonikerImpl *This = impl_from_IMoniker(iface);
00109 
00110     TRACE("(%p)\n",This);
00111 
00112     return InterlockedIncrement(&This->ref);
00113 }
00114 
00115 /******************************************************************************
00116  *        AntiMoniker_Release
00117  ******************************************************************************/
00118 static ULONG WINAPI
00119 AntiMonikerImpl_Release(IMoniker* iface)
00120 {
00121     AntiMonikerImpl *This = impl_from_IMoniker(iface);
00122     ULONG ref;
00123 
00124     TRACE("(%p)\n",This);
00125 
00126     ref = InterlockedDecrement(&This->ref);
00127 
00128     /* destroy the object if there's no more reference on it */
00129     if (ref == 0)
00130     {
00131         if (This->pMarshal) IUnknown_Release(This->pMarshal);
00132         HeapFree(GetProcessHeap(),0,This);
00133     }
00134 
00135     return ref;
00136 }
00137 
00138 /******************************************************************************
00139  *        AntiMoniker_GetClassID
00140  ******************************************************************************/
00141 static HRESULT WINAPI
00142 AntiMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID)
00143 {
00144     TRACE("(%p,%p)\n",iface,pClassID);
00145 
00146     if (pClassID==NULL)
00147         return E_POINTER;
00148 
00149     *pClassID = CLSID_AntiMoniker;
00150 
00151     return S_OK;
00152 }
00153 
00154 /******************************************************************************
00155  *        AntiMoniker_IsDirty
00156  ******************************************************************************/
00157 static HRESULT WINAPI
00158 AntiMonikerImpl_IsDirty(IMoniker* iface)
00159 {
00160     /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
00161        method in the OLE-provided moniker interfaces always return S_FALSE because
00162        their internal state never changes. */
00163 
00164     TRACE("(%p)\n",iface);
00165 
00166     return S_FALSE;
00167 }
00168 
00169 /******************************************************************************
00170  *        AntiMoniker_Load
00171  ******************************************************************************/
00172 static HRESULT WINAPI
00173 AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm)
00174 {
00175     DWORD constant=1,dwbuffer;
00176     HRESULT res;
00177 
00178     /* data read by this function is only a DWORD constant (must be 1) ! */
00179     res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),NULL);
00180 
00181     if (SUCCEEDED(res)&& dwbuffer!=constant)
00182         return E_FAIL;
00183 
00184     return res;
00185 }
00186 
00187 /******************************************************************************
00188  *        AntiMoniker_Save
00189  ******************************************************************************/
00190 static HRESULT WINAPI
00191 AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
00192 {
00193     static const DWORD constant = 1;
00194     /* data written by this function is only a DWORD constant set to 1 ! */
00195     return IStream_Write(pStm,&constant,sizeof(constant),NULL);
00196 }
00197 
00198 /******************************************************************************
00199  *        AntiMoniker_GetSizeMax
00200  *
00201  * PARAMS
00202  * pcbSize [out] Pointer to size of stream needed to save object
00203  ******************************************************************************/
00204 static HRESULT WINAPI
00205 AntiMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
00206 {
00207     TRACE("(%p,%p)\n",iface,pcbSize);
00208 
00209     if (!pcbSize)
00210         return E_POINTER;
00211 
00212     /* for more details see AntiMonikerImpl_Save comments */
00213 
00214     /*
00215      * Normally the sizemax must be sizeof DWORD, but
00216      * I tested this function it usually return 16 bytes
00217      * more than the number of bytes used by AntiMoniker::Save function
00218      */
00219     pcbSize->u.LowPart =  sizeof(DWORD)+16;
00220 
00221     pcbSize->u.HighPart=0;
00222 
00223     return S_OK;
00224 }
00225 
00226 /******************************************************************************
00227  *                  AntiMoniker_BindToObject
00228  ******************************************************************************/
00229 static HRESULT WINAPI
00230 AntiMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
00231                              REFIID riid, VOID** ppvResult)
00232 {
00233     TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
00234     return E_NOTIMPL;
00235 }
00236 
00237 /******************************************************************************
00238  *        AntiMoniker_BindToStorage
00239  ******************************************************************************/
00240 static HRESULT WINAPI
00241 AntiMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
00242                               REFIID riid, VOID** ppvResult)
00243 {
00244     TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
00245     return E_NOTIMPL;
00246 }
00247 
00248 /******************************************************************************
00249  *        AntiMoniker_Reduce
00250  ******************************************************************************/
00251 static HRESULT WINAPI
00252 AntiMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar,
00253                        IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
00254 {
00255     TRACE("(%p,%p,%d,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
00256 
00257     if (ppmkReduced==NULL)
00258         return E_POINTER;
00259 
00260     AntiMonikerImpl_AddRef(iface);
00261 
00262     *ppmkReduced=iface;
00263 
00264     return MK_S_REDUCED_TO_SELF;
00265 }
00266 /******************************************************************************
00267  *        AntiMoniker_ComposeWith
00268  ******************************************************************************/
00269 static HRESULT WINAPI
00270 AntiMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
00271                             BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
00272 {
00273 
00274     TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
00275 
00276     if ((ppmkComposite==NULL)||(pmkRight==NULL))
00277     return E_POINTER;
00278 
00279     *ppmkComposite=0;
00280 
00281     if (fOnlyIfNotGeneric)
00282         return MK_E_NEEDGENERIC;
00283     else
00284         return CreateGenericComposite(iface,pmkRight,ppmkComposite);
00285 }
00286 
00287 /******************************************************************************
00288  *        AntiMoniker_Enum
00289  ******************************************************************************/
00290 static HRESULT WINAPI
00291 AntiMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
00292 {
00293     TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
00294 
00295     if (ppenumMoniker == NULL)
00296         return E_POINTER;
00297 
00298     *ppenumMoniker = NULL;
00299 
00300     return S_OK;
00301 }
00302 
00303 /******************************************************************************
00304  *        AntiMoniker_IsEqual
00305  ******************************************************************************/
00306 static HRESULT WINAPI
00307 AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
00308 {
00309     DWORD mkSys;
00310 
00311     TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
00312 
00313     if (pmkOtherMoniker==NULL)
00314         return S_FALSE;
00315 
00316     IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys);
00317 
00318     if (mkSys==MKSYS_ANTIMONIKER)
00319         return S_OK;
00320     else
00321         return S_FALSE;
00322 }
00323 
00324 /******************************************************************************
00325  *        AntiMoniker_Hash
00326  ******************************************************************************/
00327 static HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
00328 {
00329     if (pdwHash==NULL)
00330         return E_POINTER;
00331 
00332     *pdwHash = 0x80000001;
00333 
00334     return S_OK;
00335 }
00336 
00337 /******************************************************************************
00338  *        AntiMoniker_IsRunning
00339  ******************************************************************************/
00340 static HRESULT WINAPI
00341 AntiMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
00342                           IMoniker* pmkNewlyRunning)
00343 {
00344     IRunningObjectTable* rot;
00345     HRESULT res;
00346 
00347     TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
00348 
00349     if (pbc==NULL)
00350         return E_INVALIDARG;
00351 
00352     res=IBindCtx_GetRunningObjectTable(pbc,&rot);
00353 
00354     if (FAILED(res))
00355         return res;
00356 
00357     res = IRunningObjectTable_IsRunning(rot,iface);
00358 
00359     IRunningObjectTable_Release(rot);
00360 
00361     return res;
00362 }
00363 
00364 /******************************************************************************
00365  *        AntiMoniker_GetTimeOfLastChange
00366  ******************************************************************************/
00367 static HRESULT WINAPI AntiMonikerImpl_GetTimeOfLastChange(IMoniker* iface,
00368                                                    IBindCtx* pbc,
00369                                                    IMoniker* pmkToLeft,
00370                                                    FILETIME* pAntiTime)
00371 {
00372     TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pAntiTime);
00373     return E_NOTIMPL;
00374 }
00375 
00376 /******************************************************************************
00377  *        AntiMoniker_Inverse
00378  ******************************************************************************/
00379 static HRESULT WINAPI
00380 AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
00381 {
00382     TRACE("(%p,%p)\n",iface,ppmk);
00383 
00384     if (ppmk==NULL)
00385         return E_POINTER;
00386 
00387     *ppmk=0;
00388 
00389     return MK_E_NOINVERSE;
00390 }
00391 
00392 /******************************************************************************
00393  *        AntiMoniker_CommonPrefixWith
00394  ******************************************************************************/
00395 static HRESULT WINAPI
00396 AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
00397 {
00398     DWORD mkSys;
00399 
00400     IMoniker_IsSystemMoniker(pmkOther,&mkSys);
00401 
00402     if(mkSys==MKSYS_ANTIMONIKER){
00403 
00404         IMoniker_AddRef(iface);
00405 
00406         *ppmkPrefix=iface;
00407 
00408         IMoniker_AddRef(iface);
00409 
00410         return MK_S_US;
00411     }
00412     else
00413         return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
00414 }
00415 
00416 /******************************************************************************
00417  *        AntiMoniker_RelativePathTo
00418  ******************************************************************************/
00419 static HRESULT WINAPI
00420 AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
00421 {
00422     TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
00423 
00424     if (ppmkRelPath==NULL)
00425         return E_POINTER;
00426 
00427     IMoniker_AddRef(pmOther);
00428 
00429     *ppmkRelPath=pmOther;
00430 
00431     return MK_S_HIM;
00432 }
00433 
00434 /******************************************************************************
00435  *        AntiMoniker_GetDisplayName
00436  ******************************************************************************/
00437 static HRESULT WINAPI
00438 AntiMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
00439                                IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
00440 {
00441     static const WCHAR back[]={'\\','.','.',0};
00442 
00443     TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
00444 
00445     if (ppszDisplayName==NULL)
00446         return E_POINTER;
00447 
00448     if (pmkToLeft!=NULL){
00449         FIXME("() pmkToLeft!=NULL not implemented\n");
00450         return E_NOTIMPL;
00451     }
00452 
00453     *ppszDisplayName=CoTaskMemAlloc(sizeof(back));
00454 
00455     if (*ppszDisplayName==NULL)
00456         return E_OUTOFMEMORY;
00457 
00458     lstrcpyW(*ppszDisplayName,back);
00459 
00460     return S_OK;
00461 }
00462 
00463 /******************************************************************************
00464  *        AntiMoniker_ParseDisplayName
00465  ******************************************************************************/
00466 static HRESULT WINAPI
00467 AntiMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc,
00468                                  IMoniker* pmkToLeft, LPOLESTR pszDisplayName,
00469                                  ULONG* pchEaten, IMoniker** ppmkOut)
00470 {
00471     TRACE("(%p,%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
00472     return E_NOTIMPL;
00473 }
00474 
00475 /******************************************************************************
00476  *        AntiMoniker_IsSystemMoniker
00477  ******************************************************************************/
00478 static HRESULT WINAPI
00479 AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
00480 {
00481     TRACE("(%p,%p)\n",iface,pwdMksys);
00482 
00483     if (!pwdMksys)
00484         return E_POINTER;
00485 
00486     (*pwdMksys)=MKSYS_ANTIMONIKER;
00487 
00488     return S_OK;
00489 }
00490 
00491 /*******************************************************************************
00492  *        AntiMonikerIROTData_QueryInterface
00493  *******************************************************************************/
00494 static HRESULT WINAPI
00495 AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
00496 {
00497     AntiMonikerImpl *This = impl_from_IROTData(iface);
00498 
00499     TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
00500 
00501     return AntiMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
00502 }
00503 
00504 /***********************************************************************
00505  *        AntiMonikerIROTData_AddRef
00506  */
00507 static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface)
00508 {
00509     AntiMonikerImpl *This = impl_from_IROTData(iface);
00510 
00511     TRACE("(%p)\n",iface);
00512 
00513     return AntiMonikerImpl_AddRef(&This->IMoniker_iface);
00514 }
00515 
00516 /***********************************************************************
00517  *        AntiMonikerIROTData_Release
00518  */
00519 static ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface)
00520 {
00521     AntiMonikerImpl *This = impl_from_IROTData(iface);
00522 
00523     TRACE("(%p)\n",iface);
00524 
00525     return AntiMonikerImpl_Release(&This->IMoniker_iface);
00526 }
00527 
00528 /******************************************************************************
00529  *        AntiMonikerIROTData_GetComparisonData
00530  ******************************************************************************/
00531 static HRESULT WINAPI
00532 AntiMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
00533                                           ULONG cbMax, ULONG* pcbData)
00534 {
00535     DWORD constant = 1;
00536 
00537     TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData);
00538 
00539     *pcbData = sizeof(CLSID) + sizeof(DWORD);
00540     if (cbMax < *pcbData)
00541         return E_OUTOFMEMORY;
00542 
00543     memcpy(pbData, &CLSID_AntiMoniker, sizeof(CLSID));
00544     memcpy(pbData+sizeof(CLSID), &constant, sizeof(DWORD));
00545 
00546     return S_OK;
00547 }
00548 
00549 /********************************************************************************/
00550 /* Virtual function table for the AntiMonikerImpl class which  include IPersist,*/
00551 /* IPersistStream and IMoniker functions.                                       */
00552 static const IMonikerVtbl VT_AntiMonikerImpl =
00553 {
00554     AntiMonikerImpl_QueryInterface,
00555     AntiMonikerImpl_AddRef,
00556     AntiMonikerImpl_Release,
00557     AntiMonikerImpl_GetClassID,
00558     AntiMonikerImpl_IsDirty,
00559     AntiMonikerImpl_Load,
00560     AntiMonikerImpl_Save,
00561     AntiMonikerImpl_GetSizeMax,
00562     AntiMonikerImpl_BindToObject,
00563     AntiMonikerImpl_BindToStorage,
00564     AntiMonikerImpl_Reduce,
00565     AntiMonikerImpl_ComposeWith,
00566     AntiMonikerImpl_Enum,
00567     AntiMonikerImpl_IsEqual,
00568     AntiMonikerImpl_Hash,
00569     AntiMonikerImpl_IsRunning,
00570     AntiMonikerImpl_GetTimeOfLastChange,
00571     AntiMonikerImpl_Inverse,
00572     AntiMonikerImpl_CommonPrefixWith,
00573     AntiMonikerImpl_RelativePathTo,
00574     AntiMonikerImpl_GetDisplayName,
00575     AntiMonikerImpl_ParseDisplayName,
00576     AntiMonikerImpl_IsSystemMoniker
00577 };
00578 
00579 /********************************************************************************/
00580 /* Virtual function table for the IROTData class.                               */
00581 static const IROTDataVtbl VT_ROTDataImpl =
00582 {
00583     AntiMonikerROTDataImpl_QueryInterface,
00584     AntiMonikerROTDataImpl_AddRef,
00585     AntiMonikerROTDataImpl_Release,
00586     AntiMonikerROTDataImpl_GetComparisonData
00587 };
00588 
00589 /******************************************************************************
00590  *         AntiMoniker_Construct (local function)
00591  *******************************************************************************/
00592 static HRESULT AntiMonikerImpl_Construct(AntiMonikerImpl* This)
00593 {
00594 
00595     TRACE("(%p)\n",This);
00596 
00597     /* Initialize the virtual function table. */
00598     This->IMoniker_iface.lpVtbl = &VT_AntiMonikerImpl;
00599     This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
00600     This->ref          = 0;
00601     This->pMarshal     = NULL;
00602 
00603     return S_OK;
00604 }
00605 
00606 /******************************************************************************
00607  *        CreateAntiMoniker [OLE32.@]
00608  ******************************************************************************/
00609 HRESULT WINAPI CreateAntiMoniker(IMoniker **ppmk)
00610 {
00611     AntiMonikerImpl* newAntiMoniker;
00612     HRESULT hr;
00613 
00614     TRACE("(%p)\n",ppmk);
00615 
00616     newAntiMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(AntiMonikerImpl));
00617 
00618     if (newAntiMoniker == 0)
00619         return STG_E_INSUFFICIENTMEMORY;
00620 
00621     hr = AntiMonikerImpl_Construct(newAntiMoniker);
00622     if (FAILED(hr))
00623     {
00624         HeapFree(GetProcessHeap(),0,newAntiMoniker);
00625         return hr;
00626     }
00627 
00628     return AntiMonikerImpl_QueryInterface(&newAntiMoniker->IMoniker_iface, &IID_IMoniker,
00629             (void**)ppmk);
00630 }
00631 
00632 static HRESULT WINAPI AntiMonikerCF_QueryInterface(LPCLASSFACTORY iface,
00633                                                   REFIID riid, LPVOID *ppv)
00634 {
00635     *ppv = NULL;
00636     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
00637     {
00638         *ppv = iface;
00639         IUnknown_AddRef(iface);
00640         return S_OK;
00641     }
00642     return E_NOINTERFACE;
00643 }
00644 
00645 static ULONG WINAPI AntiMonikerCF_AddRef(LPCLASSFACTORY iface)
00646 {
00647     return 2; /* non-heap based object */
00648 }
00649 
00650 static ULONG WINAPI AntiMonikerCF_Release(LPCLASSFACTORY iface)
00651 {
00652     return 1; /* non-heap based object */
00653 }
00654 
00655 static HRESULT WINAPI AntiMonikerCF_CreateInstance(LPCLASSFACTORY iface,
00656     LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
00657 {
00658     IMoniker *pMoniker;
00659     HRESULT  hr;
00660 
00661     TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
00662 
00663     *ppv = NULL;
00664 
00665     if (pUnk)
00666         return CLASS_E_NOAGGREGATION;
00667 
00668     hr = CreateAntiMoniker(&pMoniker);
00669     if (FAILED(hr))
00670         return hr;
00671 
00672     hr = IMoniker_QueryInterface(pMoniker, riid, ppv);
00673 
00674     if (FAILED(hr))
00675         IMoniker_Release(pMoniker);
00676 
00677     return hr;
00678 }
00679 
00680 static HRESULT WINAPI AntiMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
00681 {
00682     FIXME("(%d), stub!\n",fLock);
00683     return S_OK;
00684 }
00685 
00686 static const IClassFactoryVtbl AntiMonikerCFVtbl =
00687 {
00688     AntiMonikerCF_QueryInterface,
00689     AntiMonikerCF_AddRef,
00690     AntiMonikerCF_Release,
00691     AntiMonikerCF_CreateInstance,
00692     AntiMonikerCF_LockServer
00693 };
00694 static const IClassFactoryVtbl *AntiMonikerCF = &AntiMonikerCFVtbl;
00695 
00696 HRESULT AntiMonikerCF_Create(REFIID riid, LPVOID *ppv)
00697 {
00698     return IClassFactory_QueryInterface((IClassFactory *)&AntiMonikerCF, riid, ppv);
00699 }

Generated on Sat May 26 2012 04:24:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.