1998-03-15 21:29:56 +01:00
|
|
|
/*
|
|
|
|
* Monikers
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
1999-01-28 18:56:14 +01:00
|
|
|
* Copyright 1999 Noomen Hamza
|
2005-05-23 11:54:53 +02:00
|
|
|
* Copyright 2005 Robert Shearman (for CodeWeavers)
|
2002-03-10 00:29:33 +01: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
|
2004-07-29 04:44:09 +02:00
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* - IRunningObjectTable should work interprocess, but currently doesn't.
|
|
|
|
* Native (on Win2k at least) uses an undocumented RPC interface, IROT, to
|
|
|
|
* communicate with RPCSS which contains the table of marshalled data.
|
1998-03-15 21:29:56 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2000-11-08 06:05:15 +01:00
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
1998-03-15 21:29:56 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "winbase.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2000-11-08 06:05:15 +01:00
|
|
|
#include "wtypes.h"
|
2000-03-08 19:25:22 +01:00
|
|
|
#include "ole2.h"
|
1998-03-15 21:29:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2000-11-25 04:08:23 +01:00
|
|
|
#include "compobj_private.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* define the structure of the running object table elements */
|
2005-05-23 11:54:53 +02:00
|
|
|
struct rot_entry
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
MInterfacePointer* object; /* marshaled running object*/
|
|
|
|
MInterfacePointer* moniker; /* marshaled moniker that identifies this object */
|
|
|
|
MInterfacePointer* moniker_data; /* moniker comparison data that identifies this object */
|
|
|
|
DWORD cookie; /* cookie identifying this object */
|
|
|
|
FILETIME last_modified;
|
|
|
|
};
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2000-02-20 20:17:53 +01:00
|
|
|
/* define the RunningObjectTableImpl structure */
|
2005-05-23 11:54:53 +02:00
|
|
|
typedef struct RunningObjectTableImpl
|
|
|
|
{
|
|
|
|
const IRunningObjectTableVtbl *lpVtbl;
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
struct list rot; /* list of ROT entries */
|
|
|
|
CRITICAL_SECTION lock;
|
1999-03-23 14:48:56 +01:00
|
|
|
} RunningObjectTableImpl;
|
|
|
|
|
2005-04-15 18:11:29 +02:00
|
|
|
static RunningObjectTableImpl* runningObjectTableInstance = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
static inline HRESULT WINAPI
|
|
|
|
IrotRegister(DWORD *cookie)
|
|
|
|
{
|
2005-07-05 13:02:54 +02:00
|
|
|
static LONG last_cookie = 1;
|
2005-05-23 11:54:53 +02:00
|
|
|
*cookie = InterlockedIncrement(&last_cookie);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
/* define the EnumMonikerImpl structure */
|
|
|
|
typedef struct EnumMonikerImpl
|
|
|
|
{
|
|
|
|
const IEnumMonikerVtbl *lpVtbl;
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
MInterfacePointer **monikers;
|
|
|
|
ULONG moniker_count;
|
|
|
|
ULONG pos;
|
2005-05-14 20:50:14 +02:00
|
|
|
} EnumMonikerImpl;
|
|
|
|
|
|
|
|
|
|
|
|
/* IEnumMoniker Local functions*/
|
2005-05-23 11:54:53 +02:00
|
|
|
static HRESULT WINAPI EnumMonikerImpl_CreateEnumROTMoniker(MInterfacePointer **monikers,
|
|
|
|
ULONG moniker_count, ULONG pos, IEnumMoniker **ppenumMoniker);
|
|
|
|
|
|
|
|
static HRESULT create_stream_on_mip_ro(const MInterfacePointer *mip, IStream **stream)
|
|
|
|
{
|
|
|
|
HGLOBAL hglobal = GlobalAlloc(0, mip->ulCntData);
|
|
|
|
void *pv = GlobalLock(hglobal);
|
|
|
|
memcpy(pv, mip->abData, mip->ulCntData);
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
return CreateStreamOnHGlobal(hglobal, TRUE, stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rot_entry_delete(struct rot_entry *rot_entry)
|
|
|
|
{
|
|
|
|
/* FIXME: revoke entry from rpcss's copy of the ROT */
|
|
|
|
if (rot_entry->object)
|
|
|
|
{
|
|
|
|
IStream *stream;
|
|
|
|
HRESULT hr;
|
|
|
|
hr = create_stream_on_mip_ro(rot_entry->object, &stream);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
CoReleaseMarshalData(stream);
|
|
|
|
IUnknown_Release(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rot_entry->moniker)
|
|
|
|
{
|
|
|
|
IStream *stream;
|
|
|
|
HRESULT hr;
|
|
|
|
hr = create_stream_on_mip_ro(rot_entry->moniker, &stream);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
CoReleaseMarshalData(stream);
|
|
|
|
IUnknown_Release(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, rot_entry->object);
|
|
|
|
HeapFree(GetProcessHeap(), 0, rot_entry->moniker);
|
|
|
|
HeapFree(GetProcessHeap(), 0, rot_entry->moniker_data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, rot_entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* moniker_data must be freed with HeapFree when no longer in use */
|
|
|
|
static HRESULT get_moniker_comparison_data(IMoniker *pMoniker, MInterfacePointer **moniker_data)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IROTData *pROTData = NULL;
|
|
|
|
ULONG size = 0;
|
|
|
|
hr = IMoniker_QueryInterface(pMoniker, &IID_IROTData, (void *)&pROTData);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
ERR("Failed to query moniker for IROTData interface, hr = 0x%08lx\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
IROTData_GetComparisonData(pROTData, NULL, 0, &size);
|
|
|
|
*moniker_data = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer, abData[size]));
|
|
|
|
(*moniker_data)->ulCntData = size;
|
|
|
|
hr = IROTData_GetComparisonData(pROTData, (*moniker_data)->abData, size, &size);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
ERR("Failed to copy comparison data into buffer, hr = 0x%08lx\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, *moniker_data);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_QueryInterface
|
1998-03-15 21:29:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_QueryInterface(IRunningObjectTable* iface,
|
|
|
|
REFIID riid,void** ppvObject)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2000-02-20 20:17:53 +01:00
|
|
|
/* validate arguments */
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (ppvObject==0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
2005-05-11 17:56:45 +02:00
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualIID(&IID_IRunningObjectTable, riid))
|
1999-03-23 14:48:56 +01:00
|
|
|
*ppvObject = (IRunningObjectTable*)This;
|
|
|
|
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
2005-05-11 17:56:45 +02:00
|
|
|
IRunningObjectTable_AddRef(iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_AddRef
|
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
RunningObjectTableImpl_AddRef(IRunningObjectTable* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_Initialize
|
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_Destroy(void)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2005-05-23 11:54:53 +02:00
|
|
|
struct list *cursor, *cursor2;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (runningObjectTableInstance==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* free the ROT table memory */
|
2005-05-23 11:54:53 +02:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &runningObjectTableInstance->rot)
|
|
|
|
{
|
|
|
|
struct rot_entry *rot_entry = LIST_ENTRY(cursor, struct rot_entry, entry);
|
|
|
|
list_remove(&rot_entry->entry);
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* free the ROT structure memory */
|
|
|
|
HeapFree(GetProcessHeap(),0,runningObjectTableInstance);
|
2005-04-15 18:11:29 +02:00
|
|
|
runningObjectTableInstance = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_Release
|
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static ULONG WINAPI
|
|
|
|
RunningObjectTableImpl_Release(IRunningObjectTable* iface)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n",This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
/* uninitialize ROT structure if there's no more references to it */
|
|
|
|
if (ref == 0)
|
|
|
|
{
|
|
|
|
struct list *cursor, *cursor2;
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->rot)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2005-05-23 11:54:53 +02:00
|
|
|
struct rot_entry *rot_entry = LIST_ENTRY(cursor, struct rot_entry, entry);
|
|
|
|
list_remove(&rot_entry->entry);
|
|
|
|
rot_entry_delete(rot_entry);
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2005-05-23 11:54:53 +02:00
|
|
|
/* RunningObjectTable data structure will be not destroyed here ! the destruction will be done only
|
|
|
|
* when RunningObjectTableImpl_UnInitialize function is called
|
|
|
|
*/
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_Register
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* grfFlags [in] Registration options
|
|
|
|
* punkObject [in] the object being registered
|
|
|
|
* pmkObjectName [in] the moniker of the object being registered
|
|
|
|
* pdwRegister [in] the value identifying the registration
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags,
|
|
|
|
IUnknown *punkObject, IMoniker *pmkObjectName, DWORD *pdwRegister)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
struct rot_entry *rot_entry;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
IStream *pStream = NULL;
|
|
|
|
DWORD mshlflags;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%ld,%p,%p,%p)\n",This,grfFlags,punkObject,pmkObjectName,pdwRegister);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-11 17:56:45 +02:00
|
|
|
/*
|
|
|
|
* there's only two types of register : strong and or weak registration
|
|
|
|
* (only one must be passed on parameter)
|
|
|
|
*/
|
1999-03-23 14:48:56 +01:00
|
|
|
if ( ( (grfFlags & ROTFLAGS_REGISTRATIONKEEPSALIVE) || !(grfFlags & ROTFLAGS_ALLOWANYCLIENT)) &&
|
|
|
|
(!(grfFlags & ROTFLAGS_REGISTRATIONKEEPSALIVE) || (grfFlags & ROTFLAGS_ALLOWANYCLIENT)) &&
|
|
|
|
(grfFlags) )
|
2005-05-23 11:54:53 +02:00
|
|
|
{
|
|
|
|
ERR("Invalid combination of ROTFLAGS: %lx\n", grfFlags);
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_INVALIDARG;
|
2005-05-23 11:54:53 +02:00
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (punkObject==NULL || pmkObjectName==NULL || pdwRegister==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
rot_entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*rot_entry));
|
|
|
|
if (!rot_entry)
|
|
|
|
return E_OUTOFMEMORY;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
CoFileTimeNow(&rot_entry->last_modified);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
/* marshal object */
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
mshlflags = (grfFlags & ROTFLAGS_REGISTRATIONKEEPSALIVE) ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_TABLEWEAK;
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IUnknown, punkObject, MSHCTX_LOCAL | MSHCTX_NOSHAREDMEM, NULL, mshlflags);
|
|
|
|
/* FIXME: a cleaner way would be to create an IStream class that writes
|
|
|
|
* directly to an MInterfacePointer */
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
hr = GetHGlobalFromStream(pStream, &hglobal);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
SIZE_T size = GlobalSize(hglobal);
|
|
|
|
const void *pv = GlobalLock(hglobal);
|
|
|
|
rot_entry->object = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer, abData[size]));
|
|
|
|
rot_entry->object->ulCntData = size;
|
|
|
|
memcpy(&rot_entry->object->abData, pv, size);
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IStream_Release(pStream);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return hr;
|
2001-09-11 02:32:32 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = get_moniker_comparison_data(pmkObjectName, &rot_entry->moniker_data);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return hr;
|
|
|
|
}
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2005-05-23 11:54:53 +02:00
|
|
|
/* marshal moniker */
|
|
|
|
hr = CoMarshalInterface(pStream, &IID_IMoniker, (IUnknown *)pmkObjectName, MSHCTX_LOCAL | MSHCTX_NOSHAREDMEM, NULL, MSHLFLAGS_TABLESTRONG);
|
|
|
|
/* FIXME: a cleaner way would be to create an IStream class that writes
|
|
|
|
* directly to an MInterfacePointer */
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
hr = GetHGlobalFromStream(pStream, &hglobal);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
SIZE_T size = GlobalSize(hglobal);
|
|
|
|
const void *pv = GlobalLock(hglobal);
|
|
|
|
rot_entry->moniker = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer, abData[size]));
|
|
|
|
rot_entry->moniker->ulCntData = size;
|
|
|
|
memcpy(&rot_entry->moniker->abData, pv, size);
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IStream_Release(pStream);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return hr;
|
2004-07-29 04:44:09 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
/* FIXME: not the right signature of IrotRegister function */
|
|
|
|
hr = IrotRegister(&rot_entry->cookie);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* gives a registration identifier to the registered object*/
|
|
|
|
*pdwRegister = rot_entry->cookie;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
/* FIXME: see if object was registered before and return MK_S_MONIKERALREADYREGISTERED */
|
|
|
|
list_add_tail(&This->rot, &rot_entry->entry);
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_Revoke
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* dwRegister [in] Value identifying registration to be revoked
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_Revoke( IRunningObjectTable* iface, DWORD dwRegister)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
struct rot_entry *rot_entry;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%ld)\n",This,dwRegister);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
LIST_FOR_EACH_ENTRY(rot_entry, &This->rot, struct rot_entry, entry)
|
|
|
|
{
|
|
|
|
if (rot_entry->cookie == dwRegister)
|
|
|
|
{
|
|
|
|
list_remove(&rot_entry->entry);
|
|
|
|
LeaveCriticalSection(&This->lock);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
rot_entry_delete(rot_entry);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2004-07-29 04:44:09 +02:00
|
|
|
}
|
2005-05-23 11:54:53 +02:00
|
|
|
LeaveCriticalSection(&This->lock);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
1998-10-11 16:21:42 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_IsRunning
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pmkObjectName [in] moniker of the object whose status is desired
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_IsRunning( IRunningObjectTable* iface, IMoniker *pmkObjectName)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
MInterfacePointer *moniker_data;
|
|
|
|
HRESULT hr;
|
|
|
|
struct rot_entry *rot_entry;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pmkObjectName);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = get_moniker_comparison_data(pmkObjectName, &moniker_data);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = S_FALSE;
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
LIST_FOR_EACH_ENTRY(rot_entry, &This->rot, struct rot_entry, entry)
|
|
|
|
{
|
|
|
|
if ((rot_entry->moniker_data->ulCntData == moniker_data->ulCntData) &&
|
2006-08-09 19:15:46 +02:00
|
|
|
!memcmp(&moniker_data->abData, &rot_entry->moniker_data->abData, moniker_data->ulCntData))
|
2005-05-23 11:54:53 +02:00
|
|
|
{
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
/* FIXME: call IrotIsRunning */
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, moniker_data);
|
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_GetObject
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pmkObjectName [in] Pointer to the moniker on the object
|
|
|
|
* ppunkObject [out] variable that receives the IUnknown interface pointer
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_GetObject( IRunningObjectTable* iface,
|
|
|
|
IMoniker *pmkObjectName, IUnknown **ppunkObject)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
MInterfacePointer *moniker_data;
|
|
|
|
HRESULT hr;
|
|
|
|
struct rot_entry *rot_entry;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,pmkObjectName,ppunkObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
if (ppunkObject == NULL)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
*ppunkObject = NULL;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = get_moniker_comparison_data(pmkObjectName, &moniker_data);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
LIST_FOR_EACH_ENTRY(rot_entry, &This->rot, struct rot_entry, entry)
|
|
|
|
{
|
|
|
|
if ((rot_entry->moniker_data->ulCntData == moniker_data->ulCntData) &&
|
2006-08-09 19:15:46 +02:00
|
|
|
!memcmp(&moniker_data->abData, &rot_entry->moniker_data->abData, moniker_data->ulCntData))
|
2005-05-23 11:54:53 +02:00
|
|
|
{
|
|
|
|
IStream *pStream;
|
|
|
|
hr = create_stream_on_mip_ro(rot_entry->object, &pStream);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = CoUnmarshalInterface(pStream, &IID_IUnknown, (void **)ppunkObject);
|
|
|
|
IStream_Release(pStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
HeapFree(GetProcessHeap(), 0, moniker_data);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
2004-07-29 04:44:09 +02:00
|
|
|
}
|
2005-05-23 11:54:53 +02:00
|
|
|
LeaveCriticalSection(&This->lock);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
/* FIXME: call IrotGetObject */
|
|
|
|
WARN("Moniker unavailable - app may require interprocess running object table\n");
|
|
|
|
hr = MK_E_UNAVAILABLE;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, moniker_data);
|
|
|
|
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
1998-11-22 18:56:07 +01:00
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
/***********************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* RunningObjectTable_NoteChangeTime
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* dwRegister [in] Value identifying registration being updated
|
|
|
|
* pfiletime [in] Pointer to structure containing object's last change time
|
1998-11-22 18:56:07 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable* iface,
|
|
|
|
DWORD dwRegister, FILETIME *pfiletime)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
struct rot_entry *rot_entry;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%ld,%p)\n",This,dwRegister,pfiletime);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
LIST_FOR_EACH_ENTRY(rot_entry, &This->rot, struct rot_entry, entry)
|
|
|
|
{
|
|
|
|
if (rot_entry->cookie == dwRegister)
|
|
|
|
{
|
|
|
|
rot_entry->last_modified = *pfiletime;
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
/* FIXME: call IrotNoteChangeTime */
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
return E_INVALIDARG;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_GetTimeOfLastChange
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pmkObjectName [in] moniker of the object whose status is desired
|
|
|
|
* pfiletime [out] structure that receives object's last change time
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable* iface,
|
|
|
|
IMoniker *pmkObjectName, FILETIME *pfiletime)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2005-05-23 11:54:53 +02:00
|
|
|
HRESULT hr = MK_E_UNAVAILABLE;
|
2004-09-09 23:03:58 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
MInterfacePointer *moniker_data;
|
|
|
|
struct rot_entry *rot_entry;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,pmkObjectName,pfiletime);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (pmkObjectName==NULL || pfiletime==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = get_moniker_comparison_data(pmkObjectName, &moniker_data);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = MK_E_UNAVAILABLE;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
|
|
|
LIST_FOR_EACH_ENTRY(rot_entry, &This->rot, struct rot_entry, entry)
|
|
|
|
{
|
|
|
|
if ((rot_entry->moniker_data->ulCntData == moniker_data->ulCntData) &&
|
2006-08-09 19:15:46 +02:00
|
|
|
!memcmp(&moniker_data->abData, &rot_entry->moniker_data->abData, moniker_data->ulCntData))
|
2005-05-23 11:54:53 +02:00
|
|
|
{
|
|
|
|
*pfiletime = rot_entry->last_modified;
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
/* FIXME: if (hr != S_OK) call IrotGetTimeOfLastChange */
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, moniker_data);
|
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_EnumRunning
|
2005-05-11 17:56:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ppenumMoniker [out] receives the IEnumMoniker interface pointer
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
RunningObjectTableImpl_EnumRunning(IRunningObjectTable* iface,
|
|
|
|
IEnumMoniker **ppenumMoniker)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
2005-05-23 11:54:53 +02:00
|
|
|
HRESULT hr;
|
2005-05-14 20:50:14 +02:00
|
|
|
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
MInterfacePointer **monikers;
|
|
|
|
ULONG moniker_count = 0;
|
|
|
|
const struct rot_entry *rot_entry;
|
|
|
|
ULONG i = 0;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
EnterCriticalSection(&This->lock);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( rot_entry, &This->rot, const struct rot_entry, entry )
|
|
|
|
moniker_count++;
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
monikers = HeapAlloc(GetProcessHeap(), 0, moniker_count * sizeof(*monikers));
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( rot_entry, &This->rot, const struct rot_entry, entry )
|
|
|
|
{
|
|
|
|
SIZE_T size = FIELD_OFFSET(MInterfacePointer, abData[rot_entry->moniker->ulCntData]);
|
|
|
|
monikers[i] = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
memcpy(monikers[i], rot_entry->moniker, size);
|
|
|
|
i++;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
LeaveCriticalSection(&This->lock);
|
|
|
|
|
|
|
|
/* FIXME: call IrotEnumRunning and append data */
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
hr = EnumMonikerImpl_CreateEnumROTMoniker(monikers, moniker_count, 0, ppenumMoniker);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* GetRunningObjectTable (OLE32.@)
|
1999-03-23 14:48:56 +01:00
|
|
|
*/
|
2005-05-11 17:56:45 +02:00
|
|
|
HRESULT WINAPI
|
|
|
|
GetRunningObjectTable(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
|
1999-03-23 14:48:56 +01:00
|
|
|
{
|
|
|
|
IID riid=IID_IRunningObjectTable;
|
|
|
|
HRESULT res;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
if (reserved!=0)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if(runningObjectTableInstance==NULL)
|
|
|
|
return CO_E_NOTINITIALIZED;
|
|
|
|
|
2005-05-11 17:56:45 +02:00
|
|
|
res = IRunningObjectTable_QueryInterface((IRunningObjectTable*)runningObjectTableInstance,&riid,(void**)pprot);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
return res;
|
1998-11-22 18:56:07 +01:00
|
|
|
}
|
2000-01-15 23:14:20 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* OleRun [OLE32.@]
|
2000-01-15 23:14:20 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
|
|
|
|
{
|
2005-05-11 17:56:45 +02:00
|
|
|
IRunnableObject *runable;
|
2006-08-02 21:29:04 +02:00
|
|
|
HRESULT hres;
|
2005-05-11 17:56:45 +02:00
|
|
|
|
2006-08-02 21:29:04 +02:00
|
|
|
TRACE("(%p)\n", pUnknown);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(pUnknown, &IID_IRunnableObject, (void**)&runable);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return S_OK; /* Appears to return no error. */
|
|
|
|
|
|
|
|
hres = IRunnableObject_Run(runable, NULL);
|
2005-05-11 17:56:45 +02:00
|
|
|
IRunnableObject_Release(runable);
|
2006-08-02 21:29:04 +02:00
|
|
|
return hres;
|
2000-01-15 23:14:20 +01:00
|
|
|
}
|
2000-02-20 20:17:53 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* MkParseDisplayName [OLE32.@]
|
2000-02-20 20:17:53 +01:00
|
|
|
*/
|
2000-06-07 04:15:39 +02:00
|
|
|
HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
|
2000-02-20 20:17:53 +01:00
|
|
|
LPDWORD pchEaten, LPMONIKER *ppmk)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk);
|
2005-05-11 17:56:45 +02:00
|
|
|
|
2000-03-08 19:25:22 +01:00
|
|
|
if (!(IsValidInterface((LPUNKNOWN) pbc)))
|
2005-05-11 17:56:45 +02:00
|
|
|
return E_INVALIDARG;
|
2000-02-20 20:17:53 +01:00
|
|
|
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
2003-07-19 00:59:58 +02:00
|
|
|
|
2005-05-11 17:56:45 +02:00
|
|
|
/* Virtual function table for the IRunningObjectTable class. */
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IRunningObjectTableVtbl VT_RunningObjectTableImpl =
|
2005-05-11 17:56:45 +02:00
|
|
|
{
|
|
|
|
RunningObjectTableImpl_QueryInterface,
|
|
|
|
RunningObjectTableImpl_AddRef,
|
|
|
|
RunningObjectTableImpl_Release,
|
|
|
|
RunningObjectTableImpl_Register,
|
|
|
|
RunningObjectTableImpl_Revoke,
|
|
|
|
RunningObjectTableImpl_IsRunning,
|
|
|
|
RunningObjectTableImpl_GetObject,
|
|
|
|
RunningObjectTableImpl_NoteChangeTime,
|
|
|
|
RunningObjectTableImpl_GetTimeOfLastChange,
|
|
|
|
RunningObjectTableImpl_EnumRunning
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_Initialize
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RunningObjectTableImpl_Initialize(void)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/* create the unique instance of the RunningObjectTableImpl structure */
|
|
|
|
runningObjectTableInstance = HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl));
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
if (!runningObjectTableInstance)
|
2005-05-11 17:56:45 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* initialize the virtual table function */
|
|
|
|
runningObjectTableInstance->lpVtbl = &VT_RunningObjectTableImpl;
|
|
|
|
|
|
|
|
/* the initial reference is set to "1" ! because if set to "0" it will be not practis when */
|
|
|
|
/* the ROT referred many times not in the same time (all the objects in the ROT will */
|
|
|
|
/* be removed every time the ROT is removed ) */
|
|
|
|
runningObjectTableInstance->ref = 1;
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
list_init(&runningObjectTableInstance->rot);
|
|
|
|
InitializeCriticalSection(&runningObjectTableInstance->lock);
|
2005-05-11 17:56:45 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RunningObjectTable_UnInitialize
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RunningObjectTableImpl_UnInitialize()
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (runningObjectTableInstance==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance);
|
|
|
|
|
|
|
|
RunningObjectTableImpl_Destroy();
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnumMoniker_QueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID riid,void** ppvObject)
|
|
|
|
{
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
|
|
|
|
|
|
|
|
/* validate arguments */
|
|
|
|
if (ppvObject == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid))
|
|
|
|
*ppvObject = (IEnumMoniker*)This;
|
|
|
|
else
|
|
|
|
if (IsEqualIID(&IID_IEnumMoniker, riid))
|
|
|
|
*ppvObject = (IEnumMoniker*)This;
|
|
|
|
|
|
|
|
if ((*ppvObject)==NULL)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IEnumMoniker_AddRef(iface);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnumMoniker_AddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface)
|
|
|
|
{
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnumMoniker_release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI EnumMonikerImpl_Release(IEnumMoniker* iface)
|
|
|
|
{
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
/* unitialize rot structure if there's no more reference to it*/
|
2005-05-23 11:54:53 +02:00
|
|
|
if (ref == 0)
|
|
|
|
{
|
|
|
|
ULONG i;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
TRACE("(%p) Deleting\n",This);
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
for (i = 0; i < This->moniker_count; i++)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->monikers[i]);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->monikers);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2005-05-14 20:50:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* EnmumMoniker_Next
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI EnumMonikerImpl_Next(IEnumMoniker* iface, ULONG celt, IMoniker** rgelt, ULONG * pceltFetched)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p) TabCurrentPos %ld Tablastindx %ld\n", This, This->pos, This->moniker_count);
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
/* retrieve the requested number of moniker from the current position */
|
2005-05-23 11:54:53 +02:00
|
|
|
for(i = 0; (This->pos < This->moniker_count) && (i < celt); i++)
|
|
|
|
{
|
|
|
|
IStream *stream;
|
|
|
|
hr = create_stream_on_mip_ro(This->monikers[This->pos++], &stream);
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
hr = CoUnmarshalInterface(stream, &IID_IMoniker, (void **)&rgelt[i]);
|
|
|
|
IStream_Release(stream);
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
}
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
if (pceltFetched != NULL)
|
2005-05-14 20:50:14 +02:00
|
|
|
*pceltFetched= i;
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (i == celt)
|
2005-05-14 20:50:14 +02:00
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnmumMoniker_Skip
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI EnumMonikerImpl_Skip(IEnumMoniker* iface, ULONG celt)
|
|
|
|
{
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
if (This->pos + celt >= This->moniker_count)
|
|
|
|
return S_FALSE;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
This->pos += celt;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnmumMoniker_Reset
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI EnumMonikerImpl_Reset(IEnumMoniker* iface)
|
|
|
|
{
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
This->pos = 0; /* set back to start of list */
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnmumMoniker_Clone
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI EnumMonikerImpl_Clone(IEnumMoniker* iface, IEnumMoniker ** ppenum)
|
|
|
|
{
|
|
|
|
EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
|
2005-05-23 11:54:53 +02:00
|
|
|
MInterfacePointer **monikers = HeapAlloc(GetProcessHeap(), 0, sizeof(*monikers)*This->moniker_count);
|
|
|
|
ULONG i;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
2005-05-23 11:54:53 +02:00
|
|
|
|
|
|
|
for (i = 0; i < This->moniker_count; i++)
|
|
|
|
{
|
|
|
|
SIZE_T size = FIELD_OFFSET(MInterfacePointer, abData[This->monikers[i]->ulCntData]);
|
|
|
|
monikers[i] = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
memcpy(monikers[i], This->monikers[i], size);
|
|
|
|
}
|
|
|
|
|
2005-05-14 20:50:14 +02:00
|
|
|
/* copy the enum structure */
|
2005-05-23 11:54:53 +02:00
|
|
|
return EnumMonikerImpl_CreateEnumROTMoniker(monikers, This->moniker_count,
|
|
|
|
This->pos, ppenum);
|
2005-05-14 20:50:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Virtual function table for the IEnumMoniker class. */
|
2005-05-23 11:54:53 +02:00
|
|
|
static const IEnumMonikerVtbl VT_EnumMonikerImpl =
|
2005-05-14 20:50:14 +02:00
|
|
|
{
|
|
|
|
EnumMonikerImpl_QueryInterface,
|
|
|
|
EnumMonikerImpl_AddRef,
|
|
|
|
EnumMonikerImpl_Release,
|
|
|
|
EnumMonikerImpl_Next,
|
|
|
|
EnumMonikerImpl_Skip,
|
|
|
|
EnumMonikerImpl_Reset,
|
|
|
|
EnumMonikerImpl_Clone
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnumMonikerImpl_CreateEnumROTMoniker
|
|
|
|
* Used by EnumRunning to create the structure and EnumClone
|
|
|
|
* to copy the structure
|
|
|
|
*/
|
2005-05-23 11:54:53 +02:00
|
|
|
static HRESULT WINAPI EnumMonikerImpl_CreateEnumROTMoniker(MInterfacePointer **monikers,
|
|
|
|
ULONG moniker_count,
|
|
|
|
ULONG current_pos,
|
|
|
|
IEnumMoniker **ppenumMoniker)
|
2005-05-14 20:50:14 +02:00
|
|
|
{
|
|
|
|
EnumMonikerImpl* This = NULL;
|
|
|
|
|
2005-05-23 11:54:53 +02:00
|
|
|
if (!ppenumMoniker)
|
2005-05-14 20:50:14 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl));
|
2005-05-23 11:54:53 +02:00
|
|
|
if (!This) return E_OUTOFMEMORY;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
/* initialize the virtual table function */
|
|
|
|
This->lpVtbl = &VT_EnumMonikerImpl;
|
|
|
|
|
|
|
|
/* the initial reference is set to "1" */
|
|
|
|
This->ref = 1; /* set the ref count to one */
|
2005-06-02 22:06:22 +02:00
|
|
|
This->pos = current_pos; /* Set the list start posn */
|
2005-05-23 11:54:53 +02:00
|
|
|
This->moniker_count = moniker_count; /* Need the same size table as ROT */
|
|
|
|
This->monikers = monikers;
|
2005-05-14 20:50:14 +02:00
|
|
|
|
|
|
|
*ppenumMoniker = (IEnumMoniker*)This;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-05-19 16:22:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Shared implementation of moniker marshaler based on saving and loading of
|
|
|
|
* monikers */
|
|
|
|
|
|
|
|
typedef struct MonikerMarshal
|
|
|
|
{
|
|
|
|
const IUnknownVtbl *lpVtbl;
|
|
|
|
const IMarshalVtbl *lpVtblMarshal;
|
|
|
|
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
2005-05-19 16:22:14 +02:00
|
|
|
IMoniker *moniker;
|
|
|
|
} MonikerMarshal;
|
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
static inline MonikerMarshal *impl_from_IMarshal( IMarshal *iface )
|
|
|
|
{
|
|
|
|
return (MonikerMarshal *)((char*)iface - FIELD_OFFSET(MonikerMarshal, lpVtblMarshal));
|
|
|
|
}
|
|
|
|
|
2005-05-19 16:22:14 +02:00
|
|
|
static HRESULT WINAPI MonikerMarshalInner_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
MonikerMarshal *This = (MonikerMarshal *)iface;
|
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IMarshal, riid))
|
|
|
|
{
|
|
|
|
*ppv = &This->lpVtblMarshal;
|
|
|
|
IUnknown_AddRef((IUnknown *)&This->lpVtblMarshal);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME("No interface for %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MonikerMarshalInner_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
MonikerMarshal *This = (MonikerMarshal *)iface;
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MonikerMarshalInner_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
MonikerMarshal *This = (MonikerMarshal *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if (!ref) HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl VT_MonikerMarshalInner =
|
|
|
|
{
|
|
|
|
MonikerMarshalInner_QueryInterface,
|
|
|
|
MonikerMarshalInner_AddRef,
|
|
|
|
MonikerMarshalInner_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_QueryInterface(IMarshal *iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
return IMoniker_QueryInterface(This->moniker, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MonikerMarshal_AddRef(IMarshal *iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
return IMoniker_AddRef(This->moniker);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MonikerMarshal_Release(IMarshal *iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
return IMoniker_Release(This->moniker);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_GetUnmarshalClass(
|
|
|
|
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
|
|
|
|
void* pvDestContext, DWORD mshlflags, CLSID* pCid)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
|
|
|
|
TRACE("(%s, %p, %lx, %p, %lx, %p)\n", debugstr_guid(riid), pv,
|
|
|
|
dwDestContext, pvDestContext, mshlflags, pCid);
|
|
|
|
|
|
|
|
return IMoniker_GetClassID(This->moniker, pCid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_GetMarshalSizeMax(
|
|
|
|
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
|
|
|
|
void* pvDestContext, DWORD mshlflags, DWORD* pSize)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
HRESULT hr;
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %lx, %p, %lx, %p)\n", debugstr_guid(riid), pv,
|
|
|
|
dwDestContext, pvDestContext, mshlflags, pSize);
|
|
|
|
|
|
|
|
hr = IMoniker_GetSizeMax(This->moniker, &size);
|
|
|
|
if (hr == S_OK)
|
|
|
|
*pSize = (DWORD)size.QuadPart;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_MarshalInterface(LPMARSHAL iface, IStream *pStm,
|
|
|
|
REFIID riid, void* pv, DWORD dwDestContext,
|
|
|
|
void* pvDestContext, DWORD mshlflags)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %p, %lx, %p, %lx)\n", pStm, debugstr_guid(riid), pv,
|
|
|
|
dwDestContext, pvDestContext, mshlflags);
|
|
|
|
|
|
|
|
return IMoniker_Save(This->moniker, pStm, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_UnmarshalInterface(LPMARSHAL iface, IStream *pStm, REFIID riid, void **ppv)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
MonikerMarshal *This = impl_from_IMarshal(iface);
|
2005-05-19 16:22:14 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pStm, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
hr = IMoniker_Load(This->moniker, pStm);
|
|
|
|
if (hr == S_OK)
|
|
|
|
hr = IMoniker_QueryInterface(This->moniker, riid, ppv);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
/* can't release a state-based marshal as nothing on server side to
|
|
|
|
* release */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MonikerMarshal_DisconnectObject(LPMARSHAL iface, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
/* can't disconnect a state-based marshal as nothing on server side to
|
|
|
|
* disconnect from */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMarshalVtbl VT_MonikerMarshal =
|
|
|
|
{
|
|
|
|
MonikerMarshal_QueryInterface,
|
|
|
|
MonikerMarshal_AddRef,
|
|
|
|
MonikerMarshal_Release,
|
|
|
|
MonikerMarshal_GetUnmarshalClass,
|
|
|
|
MonikerMarshal_GetMarshalSizeMax,
|
|
|
|
MonikerMarshal_MarshalInterface,
|
|
|
|
MonikerMarshal_UnmarshalInterface,
|
|
|
|
MonikerMarshal_ReleaseMarshalData,
|
|
|
|
MonikerMarshal_DisconnectObject
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT MonikerMarshal_Create(IMoniker *inner, IUnknown **outer)
|
|
|
|
{
|
|
|
|
MonikerMarshal *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->lpVtbl = &VT_MonikerMarshalInner;
|
|
|
|
This->lpVtblMarshal = &VT_MonikerMarshal;
|
|
|
|
This->ref = 1;
|
|
|
|
This->moniker = inner;
|
|
|
|
|
|
|
|
*outer = (IUnknown *)&This->lpVtbl;
|
|
|
|
return S_OK;
|
|
|
|
}
|