2006-05-18 14:49:52 +02:00
|
|
|
/*
|
2006-05-08 16:55:14 +02:00
|
|
|
* Class Monikers
|
|
|
|
*
|
|
|
|
* Copyright 1999 Noomen Hamza
|
2007-03-27 19:21:23 +02:00
|
|
|
* Copyright 2005-2007 Robert Shearman
|
2006-05-08 16:55:14 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wine/debug.h"
|
2021-09-14 10:47:56 +02:00
|
|
|
#include "wine/heap.h"
|
2006-05-08 16:55:14 +02:00
|
|
|
#include "ole2.h"
|
|
|
|
#include "moniker.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
#define CHARS_IN_GUID 39
|
|
|
|
|
|
|
|
/* ClassMoniker data structure */
|
|
|
|
typedef struct ClassMoniker
|
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
IMoniker IMoniker_iface;
|
|
|
|
IROTData IROTData_iface;
|
|
|
|
LONG ref;
|
2021-09-14 10:47:54 +02:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
CLSID clsid;
|
|
|
|
DWORD data_len;
|
|
|
|
} header;
|
2021-09-14 10:47:56 +02:00
|
|
|
WCHAR *data;
|
2021-09-14 10:47:54 +02:00
|
|
|
|
2006-05-08 16:55:14 +02:00
|
|
|
IUnknown *pMarshal; /* custom marshaler */
|
|
|
|
} ClassMoniker;
|
|
|
|
|
2011-08-23 10:18:37 +02:00
|
|
|
static inline ClassMoniker *impl_from_IMoniker(IMoniker *iface)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
return CONTAINING_RECORD(iface, ClassMoniker, IMoniker_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ClassMoniker *impl_from_IROTData(IROTData *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ClassMoniker, IROTData_iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:51 +02:00
|
|
|
static const IMonikerVtbl ClassMonikerVtbl;
|
|
|
|
|
|
|
|
static ClassMoniker *unsafe_impl_from_IMoniker(IMoniker *iface)
|
|
|
|
{
|
|
|
|
if (iface->lpVtbl != &ClassMonikerVtbl)
|
|
|
|
return NULL;
|
|
|
|
return CONTAINING_RECORD(iface, ClassMoniker, IMoniker_iface);
|
|
|
|
}
|
|
|
|
|
2006-05-08 16:55:14 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* ClassMoniker_QueryInterface
|
|
|
|
*******************************************************************************/
|
2020-01-31 11:37:36 +01:00
|
|
|
static HRESULT WINAPI ClassMoniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppvObject)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
ClassMoniker *This = impl_from_IMoniker(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2020-01-31 11:37:36 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppvObject);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
if (!ppvObject)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualIID(&IID_IPersist, riid) ||
|
|
|
|
IsEqualIID(&IID_IPersistStream, riid) ||
|
2020-01-31 11:37:36 +01:00
|
|
|
IsEqualIID(&IID_IMoniker, riid) ||
|
|
|
|
IsEqualGUID(&CLSID_ClassMoniker, riid))
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(&IID_IROTData, riid))
|
2011-08-23 10:18:37 +02:00
|
|
|
*ppvObject = &This->IROTData_iface;
|
2006-05-08 16:55:14 +02:00
|
|
|
else if (IsEqualIID(&IID_IMarshal, riid))
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
if (!This->pMarshal)
|
|
|
|
hr = MonikerMarshal_Create(iface, &This->pMarshal);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*ppvObject)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IMoniker_AddRef(iface);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_AddRef
|
|
|
|
******************************************************************************/
|
|
|
|
static ULONG WINAPI ClassMoniker_AddRef(IMoniker* iface)
|
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
ClassMoniker *This = impl_from_IMoniker(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassMoniker_Release(IMoniker* iface)
|
|
|
|
{
|
2021-09-14 10:47:56 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&moniker->ref);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2022-02-08 21:09:20 +01:00
|
|
|
TRACE("%p, refcount %lu.\n", iface, ref);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
if (!ref)
|
2013-12-31 10:12:21 +01:00
|
|
|
{
|
2021-09-14 10:47:56 +02:00
|
|
|
if (moniker->pMarshal) IUnknown_Release(moniker->pMarshal);
|
|
|
|
heap_free(moniker->data);
|
|
|
|
heap_free(moniker);
|
2013-12-31 10:12:21 +01:00
|
|
|
}
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_GetClassID
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_GetClassID(IMoniker* iface,CLSID *pClassID)
|
|
|
|
{
|
2019-11-05 12:34:08 +01:00
|
|
|
TRACE("(%p, %p)\n", iface, pClassID);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
if (pClassID==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pClassID = CLSID_ClassMoniker;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_IsDirty
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_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;
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_Load(IMoniker *iface, IStream *stream)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:54 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
|
|
|
ULONG length;
|
2006-05-08 16:55:14 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
TRACE("%p, %p\n", iface, stream);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
hr = IStream_Read(stream, &moniker->header, sizeof(moniker->header), &length);
|
|
|
|
if (hr != S_OK || length != sizeof(moniker->header)) return STG_E_READFAULT;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
if (moniker->header.data_len)
|
|
|
|
{
|
2021-09-14 10:47:56 +02:00
|
|
|
heap_free(moniker->data);
|
|
|
|
if (!(moniker->data = heap_alloc(moniker->header.data_len)))
|
|
|
|
{
|
2022-02-08 21:09:20 +01:00
|
|
|
WARN("Failed to allocate moniker data of size %lu.\n", moniker->header.data_len);
|
2021-09-14 10:47:56 +02:00
|
|
|
moniker->header.data_len = 0;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
hr = IStream_Read(stream, moniker->data, moniker->header.data_len, &length);
|
|
|
|
if (hr != S_OK || length != moniker->header.data_len) return STG_E_READFAULT;
|
2021-09-14 10:47:54 +02:00
|
|
|
}
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_Save(IMoniker *iface, IStream *stream, BOOL clear_dirty)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:54 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
2021-09-14 10:47:56 +02:00
|
|
|
HRESULT hr;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
TRACE("%p, %p, %d\n", iface, stream, clear_dirty);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
hr = IStream_Write(stream, &moniker->header, sizeof(moniker->header), NULL);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && moniker->header.data_len)
|
|
|
|
hr = IStream_Write(stream, moniker->data, moniker->header.data_len, NULL);
|
|
|
|
|
|
|
|
return hr;
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *size)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:56 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
TRACE("%p, %p\n", iface, size);
|
|
|
|
|
|
|
|
size->QuadPart = sizeof(moniker->header) + moniker->header.data_len;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_BindToObject
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_BindToObject(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvResult)
|
|
|
|
{
|
2021-09-14 10:47:54 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
2006-05-08 16:55:40 +02:00
|
|
|
BIND_OPTS2 bindopts;
|
|
|
|
IClassActivator *pActivator;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2016-07-22 12:01:59 +02:00
|
|
|
TRACE("(%p, %p, %s, %p)\n", pbc, pmkToLeft, debugstr_guid(riid), ppvResult);
|
2006-05-08 16:55:40 +02:00
|
|
|
|
|
|
|
bindopts.cbStruct = sizeof(bindopts);
|
|
|
|
IBindCtx_GetBindOptions(pbc, (BIND_OPTS *)&bindopts);
|
|
|
|
|
|
|
|
if (!pmkToLeft)
|
2021-09-14 10:47:54 +02:00
|
|
|
return CoGetClassObject(&moniker->header.clsid, bindopts.dwClassContext, NULL,
|
2006-05-08 16:55:40 +02:00
|
|
|
riid, ppvResult);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IMoniker_BindToObject(pmkToLeft, pbc, NULL, &IID_IClassActivator,
|
|
|
|
(void **)&pActivator);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
hr = IClassActivator_GetClassObject(pActivator, &moniker->header.clsid,
|
2006-05-08 16:55:40 +02:00
|
|
|
bindopts.dwClassContext,
|
|
|
|
bindopts.locale, riid, ppvResult);
|
|
|
|
|
|
|
|
IClassActivator_Release(pActivator);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_BindToStorage
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_BindToStorage(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvResult)
|
|
|
|
{
|
2016-07-22 12:01:59 +02:00
|
|
|
TRACE("(%p, %p, %s, %p)\n", pbc, pmkToLeft, debugstr_guid(riid), ppvResult);
|
2013-12-31 10:12:21 +01:00
|
|
|
return IMoniker_BindToObject(iface, pbc, pmkToLeft, riid, ppvResult);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
2022-02-08 21:09:20 +01:00
|
|
|
static HRESULT WINAPI ClassMoniker_Reduce(IMoniker* iface, IBindCtx *pbc,
|
|
|
|
DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2022-02-08 21:09:20 +01:00
|
|
|
TRACE("%p, %p, %ld, %p, %p.\n", iface, pbc, dwReduceHowFar, ppmkToLeft, ppmkReduced);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
if (!ppmkReduced)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2013-12-31 10:12:21 +01:00
|
|
|
IMoniker_AddRef(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
*ppmkReduced = iface;
|
|
|
|
|
|
|
|
return MK_S_REDUCED_TO_SELF;
|
|
|
|
}
|
|
|
|
|
2021-09-24 14:51:43 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_ComposeWith(IMoniker *iface, IMoniker *right,
|
|
|
|
BOOL only_if_not_generic, IMoniker **result)
|
|
|
|
{
|
|
|
|
DWORD order;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-24 14:51:43 +02:00
|
|
|
TRACE("%p, %p, %d, %p.\n", iface, right, only_if_not_generic, result);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-24 14:51:43 +02:00
|
|
|
if (!result || !right)
|
|
|
|
return E_POINTER;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-24 14:51:43 +02:00
|
|
|
*result = NULL;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-24 14:51:43 +02:00
|
|
|
if (is_anti_moniker(right, &order))
|
|
|
|
return S_OK;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-24 14:51:43 +02:00
|
|
|
return only_if_not_generic ? MK_E_NEEDGENERIC : CreateGenericComposite(iface, right, result);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_Enum
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_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;
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:51 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_IsEqual(IMoniker *iface, IMoniker *other)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:51 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface), *other_moniker;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:51 +02:00
|
|
|
TRACE("%p, %p.\n", iface, other);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:51 +02:00
|
|
|
if (!other)
|
|
|
|
return E_INVALIDARG;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:51 +02:00
|
|
|
other_moniker = unsafe_impl_from_IMoniker(other);
|
|
|
|
if (!other_moniker)
|
|
|
|
return S_FALSE;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
return IsEqualGUID(&moniker->header.clsid, &other_moniker->header.clsid) ? S_OK : S_FALSE;
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_Hash(IMoniker *iface, DWORD *hash)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:54 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
TRACE("%p, %p\n", iface, hash);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:54 +02:00
|
|
|
*hash = moniker->header.clsid.Data1;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_IsRunning
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_IsRunning(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
IMoniker* pmkNewlyRunning)
|
|
|
|
{
|
2006-05-08 16:55:40 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", pbc, pmkToLeft, pmkNewlyRunning);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2006-05-08 16:55:40 +02:00
|
|
|
/* as in native */
|
2006-05-08 16:55:14 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_GetTimeOfLastChange
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_GetTimeOfLastChange(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
FILETIME* pItemTime)
|
|
|
|
{
|
2006-05-08 16:55:40 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", pbc, pmkToLeft, pItemTime);
|
|
|
|
|
|
|
|
return MK_E_UNAVAILABLE;
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_Inverse
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_Inverse(IMoniker* iface,IMoniker** ppmk)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",ppmk);
|
|
|
|
|
|
|
|
if (!ppmk)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
return CreateAntiMoniker(ppmk);
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:53 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface), *other_moniker;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
TRACE("%p, %p, %p\n", iface, other, prefix);
|
2006-05-08 16:55:40 +02:00
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
*prefix = NULL;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
other_moniker = unsafe_impl_from_IMoniker(other);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
if (other_moniker)
|
2006-05-08 16:55:40 +02:00
|
|
|
{
|
2021-09-14 10:47:54 +02:00
|
|
|
if (!IsEqualGUID(&moniker->header.clsid, &other_moniker->header.clsid)) return MK_E_NOPREFIX;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
*prefix = iface;
|
|
|
|
IMoniker_AddRef(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:53 +02:00
|
|
|
return MK_S_US;
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
2021-09-14 10:47:53 +02:00
|
|
|
|
|
|
|
return MonikerCommonPrefixWith(iface, other, prefix);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_RelativePathTo
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n",pmOther,ppmkRelPath);
|
|
|
|
|
|
|
|
if (!ppmkRelPath)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppmkRelPath = NULL;
|
|
|
|
|
|
|
|
return MK_E_NOTBINDABLE;
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:50 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_GetDisplayName(IMoniker *iface,
|
|
|
|
IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *name)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:50 +02:00
|
|
|
ClassMoniker *moniker = impl_from_IMoniker(iface);
|
|
|
|
static const int name_len = CHARS_IN_GUID + 5 /* prefix */;
|
2021-09-14 10:47:54 +02:00
|
|
|
const GUID *guid = &moniker->header.clsid;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:50 +02:00
|
|
|
TRACE("%p, %p, %p, %p.\n", iface, pbc, pmkToLeft, name);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:50 +02:00
|
|
|
if (!name)
|
2006-05-08 16:55:14 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (pmkToLeft)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
if (!(*name = CoTaskMemAlloc(name_len * sizeof(WCHAR) + moniker->header.data_len)))
|
2021-09-14 10:47:50 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
swprintf(*name, name_len, L"clsid:%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
2021-09-14 10:47:50 +02:00
|
|
|
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2],
|
|
|
|
guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:56 +02:00
|
|
|
if (moniker->header.data_len)
|
|
|
|
lstrcatW(*name, moniker->data);
|
|
|
|
lstrcatW(*name, L":");
|
|
|
|
|
2021-09-14 10:47:50 +02:00
|
|
|
TRACE("Returning %s\n", debugstr_w(*name));
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:55 +02:00
|
|
|
static HRESULT WINAPI ClassMoniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
|
|
|
|
IMoniker *pmkToLeft, LPOLESTR display_name, ULONG *eaten, IMoniker **result)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:55 +02:00
|
|
|
IParseDisplayName *parser;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p, %s, %p, %p\n", iface, pbc, pmkToLeft, debugstr_w(display_name), eaten, result);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = IMoniker_BindToObject(iface, pbc, pmkToLeft, &IID_IParseDisplayName, (void **)&parser)))
|
|
|
|
{
|
|
|
|
hr = IParseDisplayName_ParseDisplayName(parser, pbc, display_name, eaten, result);
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ClassMoniker_IsSystemMoniker
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMoniker_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p)\n",iface,pwdMksys);
|
|
|
|
|
|
|
|
if (!pwdMksys)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pwdMksys = MKSYS_CLASSMONIKER;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* ClassMonikerIROTData_QueryInterface
|
|
|
|
*******************************************************************************/
|
|
|
|
static HRESULT WINAPI ClassMonikerROTData_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
|
|
|
|
{
|
|
|
|
|
2011-08-23 10:18:37 +02:00
|
|
|
ClassMoniker *This = impl_from_IROTData(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2016-07-22 12:01:59 +02:00
|
|
|
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvObject);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2013-12-31 10:12:21 +01:00
|
|
|
return IMoniker_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ClassMonikerIROTData_AddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI ClassMonikerROTData_AddRef(IROTData *iface)
|
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
ClassMoniker *This = impl_from_IROTData(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",iface);
|
|
|
|
|
2013-12-31 10:12:21 +01:00
|
|
|
return IMoniker_AddRef(&This->IMoniker_iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ClassMonikerIROTData_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI ClassMonikerROTData_Release(IROTData* iface)
|
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
ClassMoniker *This = impl_from_IROTData(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",iface);
|
|
|
|
|
2013-12-31 10:12:21 +01:00
|
|
|
return IMoniker_Release(&This->IMoniker_iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2008-04-14 01:01:50 +02:00
|
|
|
* ClassMonikerIROTData_GetComparisonData
|
2006-05-08 16:55:14 +02:00
|
|
|
******************************************************************************/
|
2008-04-14 01:01:50 +02:00
|
|
|
static HRESULT WINAPI ClassMonikerROTData_GetComparisonData(IROTData* iface,
|
2006-05-08 16:55:14 +02:00
|
|
|
BYTE* pbData,
|
|
|
|
ULONG cbMax,
|
|
|
|
ULONG* pcbData)
|
|
|
|
{
|
2011-08-23 10:18:37 +02:00
|
|
|
ClassMoniker *This = impl_from_IROTData(iface);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2022-02-08 21:09:20 +01:00
|
|
|
TRACE("%p, %p, %lu, %p.\n", iface, pbData, cbMax, pcbData);
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
*pcbData = 2*sizeof(CLSID);
|
|
|
|
if (cbMax < *pcbData)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* write CLSID of the moniker */
|
|
|
|
memcpy(pbData, &CLSID_ClassMoniker, sizeof(CLSID));
|
|
|
|
/* write CLSID the moniker represents */
|
2021-09-14 10:47:54 +02:00
|
|
|
memcpy(pbData+sizeof(CLSID), &This->header.clsid, sizeof(CLSID));
|
2006-05-08 16:55:14 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMonikerVtbl ClassMonikerVtbl =
|
|
|
|
{
|
|
|
|
ClassMoniker_QueryInterface,
|
|
|
|
ClassMoniker_AddRef,
|
|
|
|
ClassMoniker_Release,
|
|
|
|
ClassMoniker_GetClassID,
|
|
|
|
ClassMoniker_IsDirty,
|
|
|
|
ClassMoniker_Load,
|
|
|
|
ClassMoniker_Save,
|
|
|
|
ClassMoniker_GetSizeMax,
|
|
|
|
ClassMoniker_BindToObject,
|
|
|
|
ClassMoniker_BindToStorage,
|
|
|
|
ClassMoniker_Reduce,
|
|
|
|
ClassMoniker_ComposeWith,
|
|
|
|
ClassMoniker_Enum,
|
|
|
|
ClassMoniker_IsEqual,
|
|
|
|
ClassMoniker_Hash,
|
|
|
|
ClassMoniker_IsRunning,
|
|
|
|
ClassMoniker_GetTimeOfLastChange,
|
|
|
|
ClassMoniker_Inverse,
|
|
|
|
ClassMoniker_CommonPrefixWith,
|
|
|
|
ClassMoniker_RelativePathTo,
|
|
|
|
ClassMoniker_GetDisplayName,
|
|
|
|
ClassMoniker_ParseDisplayName,
|
|
|
|
ClassMoniker_IsSystemMoniker
|
|
|
|
};
|
|
|
|
|
|
|
|
/********************************************************************************/
|
|
|
|
/* Virtual function table for the IROTData class. */
|
|
|
|
static const IROTDataVtbl ROTDataVtbl =
|
|
|
|
{
|
|
|
|
ClassMonikerROTData_QueryInterface,
|
|
|
|
ClassMonikerROTData_AddRef,
|
|
|
|
ClassMonikerROTData_Release,
|
2008-04-14 01:01:50 +02:00
|
|
|
ClassMonikerROTData_GetComparisonData
|
2006-05-08 16:55:14 +02:00
|
|
|
};
|
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
static HRESULT create_class_moniker(const CLSID *clsid, const WCHAR *data,
|
|
|
|
unsigned int data_len, IMoniker **moniker)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
2021-09-14 10:47:52 +02:00
|
|
|
ClassMoniker *object;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2021-09-14 10:47:52 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:52 +02:00
|
|
|
object->IMoniker_iface.lpVtbl = &ClassMonikerVtbl;
|
|
|
|
object->IROTData_iface.lpVtbl = &ROTDataVtbl;
|
|
|
|
object->ref = 1;
|
2021-09-14 10:47:57 +02:00
|
|
|
object->header.clsid = *clsid;
|
|
|
|
if (data_len)
|
|
|
|
{
|
|
|
|
object->header.data_len = (data_len + 1) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
if (!(object->data = heap_alloc(object->header.data_len)))
|
|
|
|
{
|
|
|
|
IMoniker_Release(&object->IMoniker_iface);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(object->data, data, data_len * sizeof(WCHAR));
|
|
|
|
object->data[data_len] = 0;
|
|
|
|
}
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:52 +02:00
|
|
|
*moniker = &object->IMoniker_iface;
|
2006-05-08 16:55:14 +02:00
|
|
|
|
2021-09-14 10:47:52 +02:00
|
|
|
return S_OK;
|
2006-05-08 16:55:14 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CreateClassMoniker [OLE32.@]
|
|
|
|
******************************************************************************/
|
|
|
|
HRESULT WINAPI CreateClassMoniker(REFCLSID rclsid, IMoniker **moniker)
|
2007-03-27 19:21:23 +02:00
|
|
|
{
|
2021-09-14 10:47:57 +02:00
|
|
|
TRACE("%s, %p\n", debugstr_guid(rclsid), moniker);
|
|
|
|
|
|
|
|
return create_class_moniker(rclsid, NULL, 0, moniker);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT ClassMoniker_CreateFromDisplayName(LPBC pbc, const WCHAR *display_name,
|
|
|
|
DWORD *eaten, IMoniker **moniker)
|
|
|
|
{
|
|
|
|
const WCHAR *end, *s;
|
|
|
|
BOOL has_braces;
|
|
|
|
WCHAR uuid[37];
|
2007-03-27 19:21:23 +02:00
|
|
|
CLSID clsid;
|
2021-09-14 10:47:57 +02:00
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
s = display_name;
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
/* Skip prefix */
|
|
|
|
if (wcsnicmp(s, L"clsid:", 6)) return MK_E_SYNTAX;
|
|
|
|
s += 6;
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
/* Terminating marker is optional */
|
|
|
|
if (!(end = wcschr(s, ':')))
|
|
|
|
end = s + lstrlenW(s);
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
len = end - s;
|
|
|
|
if (len < 36)
|
|
|
|
return MK_E_SYNTAX;
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
if ((has_braces = *s == '{')) s++;
|
|
|
|
|
|
|
|
memcpy(uuid, s, 36 * sizeof(WCHAR));
|
|
|
|
uuid[36] = 0;
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
if (UuidFromStringW(uuid, &clsid))
|
2007-03-27 19:21:23 +02:00
|
|
|
{
|
2021-09-14 10:47:57 +02:00
|
|
|
WARN("Failed to parse clsid string.\n");
|
|
|
|
return MK_E_SYNTAX;
|
2007-03-27 19:21:23 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
s += 36;
|
|
|
|
if (has_braces)
|
2007-03-27 19:21:23 +02:00
|
|
|
{
|
2021-09-14 10:47:57 +02:00
|
|
|
if (*s != '}') return MK_E_SYNTAX;
|
|
|
|
s++;
|
2007-03-27 19:21:23 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
/* Consume terminal marker */
|
|
|
|
len = end - s;
|
|
|
|
if (*end == ':') end++;
|
2007-03-27 19:21:23 +02:00
|
|
|
|
2021-09-14 10:47:57 +02:00
|
|
|
hr = create_class_moniker(&clsid, len ? s : NULL, len, moniker);
|
2007-03-27 19:21:23 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2021-09-14 10:47:57 +02:00
|
|
|
*eaten = end - display_name;
|
2007-03-27 19:21:23 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-02-21 13:19:47 +01:00
|
|
|
HRESULT WINAPI ClassMoniker_CreateInstance(IClassFactory *iface,
|
|
|
|
IUnknown *pUnk, REFIID riid, void **ppv)
|
2006-05-08 16:55:14 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IMoniker *pmk;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnk)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
hr = CreateClassMoniker(&CLSID_NULL, &pmk);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
hr = IMoniker_QueryInterface(pmk, riid, ppv);
|
|
|
|
IMoniker_Release(pmk);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|