diff --git a/dlls/ole32/antimoniker.c b/dlls/ole32/antimoniker.c index e919993e6f7..f08f7aa1908 100644 --- a/dlls/ole32/antimoniker.c +++ b/dlls/ole32/antimoniker.c @@ -29,7 +29,6 @@ #include "windef.h" #include "winbase.h" #include "winerror.h" -#include "wine/unicode.h" #include "objbase.h" #include "wine/debug.h" #include "moniker.h" @@ -54,54 +53,479 @@ typedef struct AntiMonikerImpl{ } AntiMonikerImpl; -/********************************************************************************/ -/* AntiMoniker prototype functions : */ -/* IUnknown prototype functions */ -static HRESULT WINAPI AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject); -static ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface); -static ULONG WINAPI AntiMonikerImpl_Release(IMoniker* iface); +/******************************************************************************* + * AntiMoniker_QueryInterface + *******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject) +{ + AntiMonikerImpl *This = (AntiMonikerImpl *)iface; -/* IPersist prototype functions */ -static HRESULT WINAPI AntiMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID); + TRACE("(%p,%p,%p)\n",This,riid,ppvObject); -/* IPersistStream prototype functions */ -static HRESULT WINAPI AntiMonikerImpl_IsDirty(IMoniker* iface); -static HRESULT WINAPI AntiMonikerImpl_Load(IMoniker* iface, IStream* pStm); -static HRESULT WINAPI AntiMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty); -static HRESULT WINAPI AntiMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize); + /* Perform a sanity check on the parameters.*/ + if ( (This==0) || (ppvObject==0) ) + return E_INVALIDARG; -/* IMoniker prototype functions */ -static HRESULT WINAPI AntiMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult); -static HRESULT WINAPI AntiMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult); -static HRESULT WINAPI AntiMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced); -static HRESULT WINAPI AntiMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite); -static HRESULT WINAPI AntiMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker); -static HRESULT WINAPI AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker); -static HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash); -static HRESULT WINAPI AntiMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning); -static HRESULT WINAPI AntiMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pAntiTime); -static HRESULT WINAPI AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk); -static HRESULT WINAPI AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix); -static HRESULT WINAPI AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath); -static HRESULT WINAPI AntiMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName); -static HRESULT WINAPI AntiMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut); -static HRESULT WINAPI AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys); + /* Initialize the return parameter */ + *ppvObject = 0; -/********************************************************************************/ -/* IROTData prototype functions */ + /* Compare the riid with the interface IDs implemented by this object.*/ + if (IsEqualIID(&IID_IUnknown, riid) || + IsEqualIID(&IID_IPersist, riid) || + IsEqualIID(&IID_IPersistStream, riid) || + IsEqualIID(&IID_IMoniker, riid)) + *ppvObject = iface; + else if (IsEqualIID(&IID_IROTData, riid)) + *ppvObject = (IROTData*)&(This->lpvtbl2); -/* IUnknown prototype functions */ -static HRESULT WINAPI AntiMonikerROTDataImpl_QueryInterface(IROTData* iface,REFIID riid,VOID** ppvObject); -static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData* iface); -static ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface); + /* Check that we obtained an interface.*/ + if ((*ppvObject)==0) + return E_NOINTERFACE; -/* IROTData prototype function */ -static HRESULT WINAPI AntiMonikerROTDataImpl_GetComparaisonData(IROTData* iface,BYTE* pbData,ULONG cbMax,ULONG* pcbData); + /* always increase the reference count by one when it is successful */ + IMoniker_AddRef(iface); -/* Local function used by AntiMoniker implementation */ -HRESULT WINAPI AntiMonikerImpl_Construct(AntiMonikerImpl* iface); -HRESULT WINAPI AntiMonikerImpl_Destroy(AntiMonikerImpl* iface); + return S_OK; +} + +/****************************************************************************** + * AntiMoniker_AddRef + ******************************************************************************/ +static ULONG WINAPI +AntiMonikerImpl_AddRef(IMoniker* iface) +{ + AntiMonikerImpl *This = (AntiMonikerImpl *)iface; + + TRACE("(%p)\n",This); + + return InterlockedIncrement(&This->ref); +} + +/****************************************************************************** + * AntiMoniker_Release + ******************************************************************************/ +static ULONG WINAPI +AntiMonikerImpl_Release(IMoniker* iface) +{ + AntiMonikerImpl *This = (AntiMonikerImpl *)iface; + ULONG ref; + + TRACE("(%p)\n",This); + + ref = InterlockedDecrement(&This->ref); + + /* destroy the object if there's no more reference on it */ + if (ref == 0) HeapFree(GetProcessHeap(),0,This); + + return ref; +} + +/****************************************************************************** + * AntiMoniker_GetClassID + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID) +{ + TRACE("(%p,%p),stub!\n",iface,pClassID); + + if (pClassID==NULL) + return E_POINTER; + + *pClassID = CLSID_AntiMoniker; + + return S_OK; +} + +/****************************************************************************** + * AntiMoniker_IsDirty + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_IsDirty(IMoniker* iface) +{ + /* Note that the OLE-provided implementations of the IPersistStream::IsDirty + method in the OLE-provided moniker interfaces always return S_FALSE because + their internal state never changes. */ + + TRACE("(%p)\n",iface); + + return S_FALSE; +} + +/****************************************************************************** + * AntiMoniker_Load + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm) +{ + DWORD constant=1,dwbuffer; + HRESULT res; + + /* data read by this function is only a DWORD constant (must be 1) ! */ + res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),NULL); + + if (SUCCEEDED(res)&& dwbuffer!=constant) + return E_FAIL; + + return res; +} + +/****************************************************************************** + * AntiMoniker_Save + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty) +{ + DWORD constant=1; + HRESULT res; + + /* data written by this function is only a DWORD constant set to 1 ! */ + res=IStream_Write(pStm,&constant,sizeof(constant),NULL); + + return res; +} + +/****************************************************************************** + * AntiMoniker_GetSizeMax + * + * PARAMS + * pcbSize [out] Pointer to size of stream needed to save object + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize) +{ + TRACE("(%p,%p)\n",iface,pcbSize); + + if (pcbSize!=NULL) + return E_POINTER; + + /* for more details see AntiMonikerImpl_Save coments */ + + /* + * Normally the sizemax must be sizeof DWORD, but + * I tested this function it usually return 16 bytes + * more than the number of bytes used by AntiMoniker::Save function + */ + pcbSize->u.LowPart = sizeof(DWORD)+16; + + pcbSize->u.HighPart=0; + + return S_OK; +} + +/****************************************************************************** + * AntiMoniker_BindToObject + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, + REFIID riid, VOID** ppvResult) +{ + TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); + return E_NOTIMPL; +} + +/****************************************************************************** + * AntiMoniker_BindToStorage + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, + REFIID riid, VOID** ppvResult) +{ + TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); + return E_NOTIMPL; +} + +/****************************************************************************** + * AntiMoniker_Reduce + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar, + IMoniker** ppmkToLeft, IMoniker** ppmkReduced) +{ + TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced); + + if (ppmkReduced==NULL) + return E_POINTER; + + AntiMonikerImpl_AddRef(iface); + + *ppmkReduced=iface; + + return MK_S_REDUCED_TO_SELF; +} +/****************************************************************************** + * AntiMoniker_ComposeWith + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight, + BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite) +{ + + TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite); + + if ((ppmkComposite==NULL)||(pmkRight==NULL)) + return E_POINTER; + + *ppmkComposite=0; + + if (fOnlyIfNotGeneric) + return MK_E_NEEDGENERIC; + else + return CreateGenericComposite(iface,pmkRight,ppmkComposite); +} + +/****************************************************************************** + * AntiMoniker_Enum + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker) +{ + TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker); + + if (ppenumMoniker == NULL) + return E_POINTER; + + *ppenumMoniker = NULL; + + return S_OK; +} + +/****************************************************************************** + * AntiMoniker_IsEqual + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) +{ + DWORD mkSys; + + TRACE("(%p,%p)\n",iface,pmkOtherMoniker); + + if (pmkOtherMoniker==NULL) + return S_FALSE; + + IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys); + + if (mkSys==MKSYS_ANTIMONIKER) + return S_OK; + else + return S_FALSE; +} + +/****************************************************************************** + * AntiMoniker_Hash + ******************************************************************************/ +static HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) +{ + if (pdwHash==NULL) + return E_POINTER; + + *pdwHash=0; + + return S_OK; +} + +/****************************************************************************** + * AntiMoniker_IsRunning + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, + IMoniker* pmkNewlyRunning) +{ + IRunningObjectTable* rot; + HRESULT res; + + TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning); + + if (pbc==NULL) + return E_INVALIDARG; + + res=IBindCtx_GetRunningObjectTable(pbc,&rot); + + if (FAILED(res)) + return res; + + res = IRunningObjectTable_IsRunning(rot,iface); + + IRunningObjectTable_Release(rot); + + return res; +} + +/****************************************************************************** + * AntiMoniker_GetTimeOfLastChange + ******************************************************************************/ +static HRESULT WINAPI AntiMonikerImpl_GetTimeOfLastChange(IMoniker* iface, + IBindCtx* pbc, + IMoniker* pmkToLeft, + FILETIME* pAntiTime) +{ + TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pAntiTime); + return E_NOTIMPL; +} + +/****************************************************************************** + * AntiMoniker_Inverse + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) +{ + TRACE("(%p,%p)\n",iface,ppmk); + + if (ppmk==NULL) + return E_POINTER; + + *ppmk=0; + + return MK_E_NOINVERSE; +} + +/****************************************************************************** + * AntiMoniker_CommonPrefixWith + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix) +{ + DWORD mkSys; + + IMoniker_IsSystemMoniker(pmkOther,&mkSys); + + if(mkSys==MKSYS_ITEMMONIKER){ + + IMoniker_AddRef(iface); + + *ppmkPrefix=iface; + + IMoniker_AddRef(iface); + + return MK_S_US; + } + else + return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix); +} + +/****************************************************************************** + * AntiMoniker_RelativePathTo + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath) +{ + TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); + + if (ppmkRelPath==NULL) + return E_POINTER; + + IMoniker_AddRef(pmOther); + + *ppmkRelPath=pmOther; + + return MK_S_HIM; +} + +/****************************************************************************** + * AntiMoniker_GetDisplayName + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc, + IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName) +{ + static const WCHAR back[]={'\\','.','.',0}; + + TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName); + + if (ppszDisplayName==NULL) + return E_POINTER; + + if (pmkToLeft!=NULL){ + FIXME("() pmkToLeft!=NULL not implemented \n"); + return E_NOTIMPL; + } + + *ppszDisplayName=CoTaskMemAlloc(sizeof(back)); + + if (*ppszDisplayName==NULL) + return E_OUTOFMEMORY; + + lstrcpyW(*ppszDisplayName,back); + + return S_OK; +} + +/****************************************************************************** + * AntiMoniker_ParseDisplayName + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, + IMoniker* pmkToLeft, LPOLESTR pszDisplayName, + ULONG* pchEaten, IMoniker** ppmkOut) +{ + TRACE("(%p,%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut); + return E_NOTIMPL; +} + +/****************************************************************************** + * AntiMoniker_IsSystemMoniker + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys) +{ + TRACE("(%p,%p)\n",iface,pwdMksys); + + if (!pwdMksys) + return E_POINTER; + + (*pwdMksys)=MKSYS_ANTIMONIKER; + + return S_OK; +} + +/******************************************************************************* + * AntiMonikerIROTData_QueryInterface + *******************************************************************************/ +static HRESULT WINAPI +AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject) +{ + ICOM_THIS_From_IROTData(IMoniker, iface); + + TRACE("(%p,%p,%p)\n",iface,riid,ppvObject); + + return AntiMonikerImpl_QueryInterface(This, riid, ppvObject); +} + +/*********************************************************************** + * AntiMonikerIROTData_AddRef + */ +static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface) +{ + ICOM_THIS_From_IROTData(IMoniker, iface); + + TRACE("(%p)\n",iface); + + return AntiMonikerImpl_AddRef(This); +} + +/*********************************************************************** + * AntiMonikerIROTData_Release + */ +static ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface) +{ + ICOM_THIS_From_IROTData(IMoniker, iface); + + TRACE("(%p)\n",iface); + + return AntiMonikerImpl_Release(This); +} + +/****************************************************************************** + * AntiMonikerIROTData_GetComparaisonData + ******************************************************************************/ +static HRESULT WINAPI +AntiMonikerROTDataImpl_GetComparaisonData(IROTData* iface, BYTE* pbData, + ULONG cbMax, ULONG* pcbData) +{ + FIXME("(),stub!\n"); + return E_NOTIMPL; +} /********************************************************************************/ /* Virtual function table for the AntiMonikerImpl class which include IPersist,*/ @@ -143,158 +567,10 @@ static IROTDataVtbl VT_ROTDataImpl = AntiMonikerROTDataImpl_GetComparaisonData }; -/******************************************************************************* - * AntiMoniker_QueryInterface - *******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject) -{ - AntiMonikerImpl *This = (AntiMonikerImpl *)iface; - - TRACE("(%p,%p,%p)\n",This,riid,ppvObject); - - /* Perform a sanity check on the parameters.*/ - if ( (This==0) || (ppvObject==0) ) - return E_INVALIDARG; - - /* Initialize the return parameter */ - *ppvObject = 0; - - /* Compare the riid with the interface IDs implemented by this object.*/ - if (IsEqualIID(&IID_IUnknown, riid) || - IsEqualIID(&IID_IPersist, riid) || - IsEqualIID(&IID_IPersistStream, riid) || - IsEqualIID(&IID_IMoniker, riid) - ) - *ppvObject = iface; - else if (IsEqualIID(&IID_IROTData, riid)) - *ppvObject = (IROTData*)&(This->lpvtbl2); - - /* Check that we obtained an interface.*/ - if ((*ppvObject)==0) - return E_NOINTERFACE; - - /* Query Interface always increases the reference count by one when it is successful */ - AntiMonikerImpl_AddRef(iface); - - return S_OK; -} - -/****************************************************************************** - * AntiMoniker_AddRef - ******************************************************************************/ -ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface) -{ - AntiMonikerImpl *This = (AntiMonikerImpl *)iface; - - TRACE("(%p)\n",This); - - return InterlockedIncrement(&This->ref); -} - -/****************************************************************************** - * AntiMoniker_Release - ******************************************************************************/ -ULONG WINAPI AntiMonikerImpl_Release(IMoniker* iface) -{ - AntiMonikerImpl *This = (AntiMonikerImpl *)iface; - ULONG ref; - - TRACE("(%p)\n",This); - - ref = InterlockedDecrement(&This->ref); - - /* destroy the object if there's no more reference on it */ - if (ref == 0) AntiMonikerImpl_Destroy(This); - - return ref; -} - -/****************************************************************************** - * AntiMoniker_GetClassID - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_GetClassID(IMoniker* iface,CLSID *pClassID) -{ - TRACE("(%p,%p),stub!\n",iface,pClassID); - - if (pClassID==NULL) - return E_POINTER; - - *pClassID = CLSID_AntiMoniker; - - return S_OK; -} - -/****************************************************************************** - * AntiMoniker_IsDirty - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_IsDirty(IMoniker* iface) -{ - /* Note that the OLE-provided implementations of the IPersistStream::IsDirty - method in the OLE-provided moniker interfaces always return S_FALSE because - their internal state never changes. */ - - TRACE("(%p)\n",iface); - - return S_FALSE; -} - -/****************************************************************************** - * AntiMoniker_Load - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm) -{ - DWORD constant=1,dwbuffer; - HRESULT res; - - /* data read by this function is only a DWORD constant (must be 1) ! */ - res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),NULL); - - if (SUCCEEDED(res)&& dwbuffer!=constant) - return E_FAIL; - - return res; -} - -/****************************************************************************** - * AntiMoniker_Save - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty) -{ - DWORD constant=1; - HRESULT res; - - /* data written by this function is only a DWORD constant set to 1 ! */ - res=IStream_Write(pStm,&constant,sizeof(constant),NULL); - - return res; -} - -/****************************************************************************** - * AntiMoniker_GetSizeMax - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_GetSizeMax(IMoniker* iface, - ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */ -{ - TRACE("(%p,%p)\n",iface,pcbSize); - - if (pcbSize!=NULL) - return E_POINTER; - - /* for more details see AntiMonikerImpl_Save coments */ - - /* Normaly the sizemax must be the size of DWORD ! but I tested this function it ususlly return 16 bytes */ - /* more than the number of bytes used by AntiMoniker::Save function */ - pcbSize->u.LowPart = sizeof(DWORD)+16; - - pcbSize->u.HighPart=0; - - return S_OK; -} - /****************************************************************************** * AntiMoniker_Construct (local function) *******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Construct(AntiMonikerImpl* This) +static HRESULT AntiMonikerImpl_Construct(AntiMonikerImpl* This) { TRACE("(%p)\n",This); @@ -307,335 +583,6 @@ HRESULT WINAPI AntiMonikerImpl_Construct(AntiMonikerImpl* This) return S_OK; } -/****************************************************************************** - * AntiMoniker_Destroy (local function) - *******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Destroy(AntiMonikerImpl* This) -{ - TRACE("(%p)\n",This); - - return HeapFree(GetProcessHeap(),0,This); -} - -/****************************************************************************** - * AntiMoniker_BindToObject - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_BindToObject(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - REFIID riid, - VOID** ppvResult) -{ - TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); - return E_NOTIMPL; -} - -/****************************************************************************** - * AntiMoniker_BindToStorage - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_BindToStorage(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - REFIID riid, - VOID** ppvResult) -{ - TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); - return E_NOTIMPL; -} - -/****************************************************************************** - * AntiMoniker_Reduce - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Reduce(IMoniker* iface, - IBindCtx* pbc, - DWORD dwReduceHowFar, - IMoniker** ppmkToLeft, - IMoniker** ppmkReduced) -{ - TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced); - - if (ppmkReduced==NULL) - return E_POINTER; - - AntiMonikerImpl_AddRef(iface); - - *ppmkReduced=iface; - - return MK_S_REDUCED_TO_SELF; -} -/****************************************************************************** - * AntiMoniker_ComposeWith - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_ComposeWith(IMoniker* iface, - IMoniker* pmkRight, - BOOL fOnlyIfNotGeneric, - IMoniker** ppmkComposite) -{ - - TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite); - - if ((ppmkComposite==NULL)||(pmkRight==NULL)) - return E_POINTER; - - *ppmkComposite=0; - - if (fOnlyIfNotGeneric) - return MK_E_NEEDGENERIC; - else - return CreateGenericComposite(iface,pmkRight,ppmkComposite); -} - -/****************************************************************************** - * AntiMoniker_Enum - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker) -{ - TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker); - - if (ppenumMoniker == NULL) - return E_POINTER; - - *ppenumMoniker = NULL; - - return S_OK; -} - -/****************************************************************************** - * AntiMoniker_IsEqual - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) -{ - DWORD mkSys; - - TRACE("(%p,%p)\n",iface,pmkOtherMoniker); - - if (pmkOtherMoniker==NULL) - return S_FALSE; - - IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys); - - if (mkSys==MKSYS_ANTIMONIKER) - return S_OK; - else - return S_FALSE; -} - -/****************************************************************************** - * AntiMoniker_Hash - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) -{ - if (pdwHash==NULL) - return E_POINTER; - - *pdwHash=0; - - return S_OK; -} - -/****************************************************************************** - * AntiMoniker_IsRunning - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_IsRunning(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - IMoniker* pmkNewlyRunning) -{ - IRunningObjectTable* rot; - HRESULT res; - - TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning); - - if (pbc==NULL) - return E_INVALIDARG; - - res=IBindCtx_GetRunningObjectTable(pbc,&rot); - - if (FAILED(res)) - return res; - - res = IRunningObjectTable_IsRunning(rot,iface); - - IRunningObjectTable_Release(rot); - - return res; -} - -/****************************************************************************** - * AntiMoniker_GetTimeOfLastChange - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_GetTimeOfLastChange(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - FILETIME* pAntiTime) -{ - TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pAntiTime); - return E_NOTIMPL; -} - -/****************************************************************************** - * AntiMoniker_Inverse - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) -{ - TRACE("(%p,%p)\n",iface,ppmk); - - if (ppmk==NULL) - return E_POINTER; - - *ppmk=0; - - return MK_E_NOINVERSE; -} - -/****************************************************************************** - * AntiMoniker_CommonPrefixWith - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix) -{ - DWORD mkSys; - - IMoniker_IsSystemMoniker(pmkOther,&mkSys); - - if(mkSys==MKSYS_ITEMMONIKER){ - - IMoniker_AddRef(iface); - - *ppmkPrefix=iface; - - IMoniker_AddRef(iface); - - return MK_S_US; - } - else - return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix); -} - -/****************************************************************************** - * AntiMoniker_RelativePathTo - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath) -{ - TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); - - if (ppmkRelPath==NULL) - return E_POINTER; - - IMoniker_AddRef(pmOther); - - *ppmkRelPath=pmOther; - - return MK_S_HIM; -} - -/****************************************************************************** - * AntiMoniker_GetDisplayName - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_GetDisplayName(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - LPOLESTR *ppszDisplayName) -{ - static const WCHAR back[]={'\\','.','.',0}; - - TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName); - - if (ppszDisplayName==NULL) - return E_POINTER; - - if (pmkToLeft!=NULL){ - FIXME("() pmkToLeft!=NULL not implemented \n"); - return E_NOTIMPL; - } - - *ppszDisplayName=CoTaskMemAlloc(sizeof(back)); - - if (*ppszDisplayName==NULL) - return E_OUTOFMEMORY; - - strcpyW(*ppszDisplayName,back); - - return S_OK; -} - -/****************************************************************************** - * AntiMoniker_ParseDisplayName - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_ParseDisplayName(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - LPOLESTR pszDisplayName, - ULONG* pchEaten, - IMoniker** ppmkOut) -{ - TRACE("(%p,%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut); - return E_NOTIMPL; -} - -/****************************************************************************** - * AntiMoniker_IsSystemMoniker - ******************************************************************************/ -HRESULT WINAPI AntiMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys) -{ - TRACE("(%p,%p)\n",iface,pwdMksys); - - if (!pwdMksys) - return E_POINTER; - - (*pwdMksys)=MKSYS_ANTIMONIKER; - - return S_OK; -} - -/******************************************************************************* - * AntiMonikerIROTData_QueryInterface - *******************************************************************************/ -HRESULT WINAPI AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject) -{ - - ICOM_THIS_From_IROTData(IMoniker, iface); - - TRACE("(%p,%p,%p)\n",iface,riid,ppvObject); - - return AntiMonikerImpl_QueryInterface(This, riid, ppvObject); -} - -/*********************************************************************** - * AntiMonikerIROTData_AddRef - */ -ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface) -{ - ICOM_THIS_From_IROTData(IMoniker, iface); - - TRACE("(%p)\n",iface); - - return AntiMonikerImpl_AddRef(This); -} - -/*********************************************************************** - * AntiMonikerIROTData_Release - */ -ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface) -{ - ICOM_THIS_From_IROTData(IMoniker, iface); - - TRACE("(%p)\n",iface); - - return AntiMonikerImpl_Release(This); -} - -/****************************************************************************** - * AntiMonikerIROTData_GetComparaisonData - ******************************************************************************/ -HRESULT WINAPI AntiMonikerROTDataImpl_GetComparaisonData(IROTData* iface, - BYTE* pbData, - ULONG cbMax, - ULONG* pcbData) -{ - FIXME("(),stub!\n"); - return E_NOTIMPL; -} - /****************************************************************************** * CreateAntiMoniker [OLE32.@] ******************************************************************************/ @@ -653,9 +600,8 @@ HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk) return STG_E_INSUFFICIENTMEMORY; hr = AntiMonikerImpl_Construct(newAntiMoniker); - - if (FAILED(hr)){ - + if (FAILED(hr)) + { HeapFree(GetProcessHeap(),0,newAntiMoniker); return hr; } diff --git a/dlls/ole32/bindctx.c b/dlls/ole32/bindctx.c index 104c016f9be..1992e62edb2 100644 --- a/dlls/ole32/bindctx.c +++ b/dlls/ole32/bindctx.c @@ -27,7 +27,6 @@ #include "winerror.h" #include "windef.h" #include "winbase.h" -#include "wine/unicode.h" #include "objbase.h" #include "wine/debug.h" @@ -64,82 +63,42 @@ typedef struct BindCtxImpl{ } BindCtxImpl; /* IBindCtx prototype functions : */ - -/* IUnknown functions*/ -static HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject); -static ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface); -static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface); -/* IBindCtx functions */ -static HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk); -static HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk); -static HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface); -static HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts); -static HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts); -static HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot); -static HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk); -static HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk); -static HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum); -static HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey); -/* Local functions*/ -HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This); -HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This); -HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This,IUnknown* punk,LPOLESTR pszkey,DWORD *index); - -/* Virtual function table for the BindCtx class. */ -static IBindCtxVtbl VT_BindCtxImpl = - { - BindCtxImpl_QueryInterface, - BindCtxImpl_AddRef, - BindCtxImpl_Release, - BindCtxImpl_RegisterObjectBound, - BindCtxImpl_RevokeObjectBound, - BindCtxImpl_ReleaseBoundObjects, - BindCtxImpl_SetBindOptions, - BindCtxImpl_GetBindOptions, - BindCtxImpl_GetRunningObjectTable, - BindCtxImpl_RegisterObjectParam, - BindCtxImpl_GetObjectParam, - BindCtxImpl_EnumObjectParam, - BindCtxImpl_RevokeObjectParam -}; +static HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx*); +static HRESULT BindCtxImpl_GetObjectIndex(BindCtxImpl*, IUnknown*, LPOLESTR, DWORD *); /******************************************************************************* * BindCtx_QueryInterface *******************************************************************************/ -HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject) +static HRESULT WINAPI +BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject) { - BindCtxImpl *This = (BindCtxImpl *)iface; + BindCtxImpl *This = (BindCtxImpl *)iface; - TRACE("(%p,%p,%p)\n",This,riid,ppvObject); + TRACE("(%p,%p,%p)\n",This,riid,ppvObject); - /* Perform a sanity check on the parameters.*/ - if ( (This==0) || (ppvObject==0) ) - return E_INVALIDARG; + /* Perform a sanity check on the parameters.*/ + if ( (This==0) || (ppvObject==0) ) + return E_INVALIDARG; - /* Initialize the return parameter.*/ - *ppvObject = 0; + /* Initialize the return parameter.*/ + *ppvObject = 0; - /* Compare the riid with the interface IDs implemented by this object.*/ - if (IsEqualIID(&IID_IUnknown, riid)) - *ppvObject = (IBindCtx*)This; - else - if (IsEqualIID(&IID_IBindCtx, riid)) - *ppvObject = (IBindCtx*)This; + /* Compare the riid with the interface IDs implemented by this object.*/ + if (IsEqualIID(&IID_IUnknown, riid) || + IsEqualIID(&IID_IBindCtx, riid)) + { + *ppvObject = (IBindCtx*)This; + IBindCtx_AddRef(iface); + return S_OK; + } - /* Check that we obtained an interface.*/ - if ((*ppvObject)==0) - return E_NOINTERFACE; - - /* Query Interface always increases the reference count by one when it is successful */ - BindCtxImpl_AddRef(iface); - - return S_OK; + return E_NOINTERFACE; } /****************************************************************************** * BindCtx_AddRef ******************************************************************************/ -ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface) +static ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface) { BindCtxImpl *This = (BindCtxImpl *)iface; @@ -148,65 +107,10 @@ ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface) return InterlockedIncrement(&This->ref); } -/****************************************************************************** - * BindCtx_Release - ******************************************************************************/ -ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface) -{ - BindCtxImpl *This = (BindCtxImpl *)iface; - ULONG ref; - - TRACE("(%p)\n",This); - - ref = InterlockedDecrement(&This->ref); - - if (ref == 0){ - /* release all registered objects */ - BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This); - - BindCtxImpl_Destroy(This); - } - return ref; -} - - -/****************************************************************************** - * BindCtx_Construct (local function) - *******************************************************************************/ -HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This) -{ - TRACE("(%p)\n",This); - - /* Initialize the virtual function table.*/ - This->lpVtbl = &VT_BindCtxImpl; - This->ref = 0; - - /* Initialize the BIND_OPTS2 structure */ - This->bindOption2.cbStruct = sizeof(BIND_OPTS2); - This->bindOption2.grfFlags = 0; - This->bindOption2.grfMode = STGM_READWRITE; - This->bindOption2.dwTickCountDeadline = 0; - - This->bindOption2.dwTrackFlags = 0; - This->bindOption2.dwClassContext = CLSCTX_SERVER; - This->bindOption2.locale = 1033; - This->bindOption2.pServerInfo = 0; - - /* Initialize the bindctx table */ - This->bindCtxTableSize=BLOCK_TAB_SIZE; - This->bindCtxTableLastIndex=0; - This->bindCtxTable= HeapAlloc(GetProcessHeap(), 0,This->bindCtxTableSize*sizeof(BindCtxObject)); - - if (This->bindCtxTable==NULL) - return E_OUTOFMEMORY; - - return S_OK; -} - /****************************************************************************** * BindCtx_Destroy (local function) *******************************************************************************/ -HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This) +static HRESULT BindCtxImpl_Destroy(BindCtxImpl* This) { TRACE("(%p)\n",This); @@ -219,11 +123,33 @@ HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This) return S_OK; } +/****************************************************************************** + * BindCtx_Release + ******************************************************************************/ +static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface) +{ + BindCtxImpl *This = (BindCtxImpl *)iface; + ULONG ref; + + TRACE("(%p)\n",This); + + ref = InterlockedDecrement(&This->ref); + if (ref == 0) + { + /* release all registered objects */ + BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This); + + BindCtxImpl_Destroy(This); + } + return ref; +} + /****************************************************************************** * BindCtx_RegisterObjectBound ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk) +static HRESULT WINAPI +BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk) { BindCtxImpl *This = (BindCtxImpl *)iface; DWORD lastIndex=This->bindCtxTableLastIndex; @@ -261,7 +187,8 @@ HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk) /****************************************************************************** * BindCtx_RevokeObjectBound ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk) +static HRESULT WINAPI +BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk) { DWORD index,j; @@ -289,7 +216,8 @@ HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk) /****************************************************************************** * BindCtx_ReleaseBoundObjects ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface) +static HRESULT WINAPI +BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface) { DWORD i; @@ -312,7 +240,8 @@ HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface) /****************************************************************************** * BindCtx_SetBindOptions ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts) +static HRESULT WINAPI +BindCtxImpl_SetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts) { BindCtxImpl *This = (BindCtxImpl *)iface; @@ -333,7 +262,8 @@ HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts) /****************************************************************************** * BindCtx_GetBindOptions ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts) +static HRESULT WINAPI +BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts) { BindCtxImpl *This = (BindCtxImpl *)iface; @@ -354,7 +284,8 @@ HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts) /****************************************************************************** * BindCtx_GetRunningObjectTable ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot) +static HRESULT WINAPI +BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot) { HRESULT res; @@ -373,7 +304,8 @@ HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectT /****************************************************************************** * BindCtx_RegisterObjectParam ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk) +static HRESULT WINAPI +BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk) { DWORD index=0; BindCtxImpl *This = (BindCtxImpl *)iface; @@ -399,23 +331,26 @@ HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj=NULL; - else{ + else + { This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj= HeapAlloc(GetProcessHeap(),0,(sizeof(WCHAR)*(1+lstrlenW(pszkey)))); if (This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj==NULL) return E_OUTOFMEMORY; - strcpyW(This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj,pszkey); + lstrcpyW(This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj,pszkey); } This->bindCtxTableLastIndex++; - if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */ + if (This->bindCtxTableLastIndex == This->bindCtxTableSize) + { + /* table is full ! must be resized */ This->bindCtxTableSize+=BLOCK_TAB_SIZE; /* new table size */ - - if (This->bindCtxTableSize > (MAX_TAB_SIZE-BLOCK_TAB_SIZE)){ + if (This->bindCtxTableSize > (MAX_TAB_SIZE-BLOCK_TAB_SIZE)) + { FIXME("This->bindCtxTableSize: %ld is out of data limite \n",This->bindCtxTableSize); return E_FAIL; } @@ -431,7 +366,8 @@ HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, /****************************************************************************** * BindCtx_GetObjectParam ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk) +static HRESULT WINAPI +BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk) { DWORD index; BindCtxImpl *This = (BindCtxImpl *)iface; @@ -456,7 +392,8 @@ HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnkn /****************************************************************************** * BindCtx_RevokeObjectParam ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR ppenum) +static HRESULT WINAPI +BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR ppenum) { DWORD index,j; @@ -484,7 +421,8 @@ HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR ppenum) /****************************************************************************** * BindCtx_EnumObjectParam ******************************************************************************/ -HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** pszkey) +static HRESULT WINAPI +BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** pszkey) { FIXME("(%p,%p),stub!\n",iface,pszkey); return E_NOTIMPL; @@ -493,7 +431,7 @@ HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** pszkey) /******************************************************************************** * GetObjectIndex (local function) ********************************************************************************/ -HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This, +static HRESULT BindCtxImpl_GetObjectIndex(BindCtxImpl* This, IUnknown* punk, LPOLESTR pszkey, DWORD *index) @@ -506,8 +444,8 @@ HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This, if (punk==NULL) /* search object identified by a register key */ - for(i=0; ( (ibindCtxTableLastIndex) && (!found));i++){ - + for(i=0; ( (ibindCtxTableLastIndex) && (!found));i++) + { if(This->bindCtxTable[i].regType==1){ if ( ( (This->bindCtxTable[i].pkeyObj==NULL) && (pszkey==NULL) ) || @@ -535,6 +473,58 @@ HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This, return S_FALSE; } +/* Virtual function table for the BindCtx class. */ +static IBindCtxVtbl VT_BindCtxImpl = +{ + BindCtxImpl_QueryInterface, + BindCtxImpl_AddRef, + BindCtxImpl_Release, + BindCtxImpl_RegisterObjectBound, + BindCtxImpl_RevokeObjectBound, + BindCtxImpl_ReleaseBoundObjects, + BindCtxImpl_SetBindOptions, + BindCtxImpl_GetBindOptions, + BindCtxImpl_GetRunningObjectTable, + BindCtxImpl_RegisterObjectParam, + BindCtxImpl_GetObjectParam, + BindCtxImpl_EnumObjectParam, + BindCtxImpl_RevokeObjectParam +}; + +/****************************************************************************** + * BindCtx_Construct (local function) + *******************************************************************************/ +static HRESULT BindCtxImpl_Construct(BindCtxImpl* This) +{ + TRACE("(%p)\n",This); + + /* Initialize the virtual function table.*/ + This->lpVtbl = &VT_BindCtxImpl; + This->ref = 0; + + /* Initialize the BIND_OPTS2 structure */ + This->bindOption2.cbStruct = sizeof(BIND_OPTS2); + This->bindOption2.grfFlags = 0; + This->bindOption2.grfMode = STGM_READWRITE; + This->bindOption2.dwTickCountDeadline = 0; + + This->bindOption2.dwTrackFlags = 0; + This->bindOption2.dwClassContext = CLSCTX_SERVER; + This->bindOption2.locale = 1033; + This->bindOption2.pServerInfo = 0; + + /* Initialize the bindctx table */ + This->bindCtxTableSize=BLOCK_TAB_SIZE; + This->bindCtxTableLastIndex=0; + This->bindCtxTable = HeapAlloc(GetProcessHeap(), 0, + This->bindCtxTableSize*sizeof(BindCtxObject)); + + if (This->bindCtxTable==NULL) + return E_OUTOFMEMORY; + + return S_OK; +} + /****************************************************************************** * CreateBindCtx16 ******************************************************************************/ @@ -556,14 +546,12 @@ HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc) TRACE("(%ld,%p)\n",reserved,ppbc); newBindCtx = HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl)); - if (newBindCtx == 0) return E_OUTOFMEMORY; hr = BindCtxImpl_Construct(newBindCtx); - - if (FAILED(hr)){ - + if (FAILED(hr)) + { HeapFree(GetProcessHeap(),0,newBindCtx); return hr; }