4 * Copyright 1998 Marcus Meissner
5 * Copyright 1999 Noomen Hamza
6 * Copyright 2005 Robert Shearman (for CodeWeavers)
7 * Copyright 2007 Robert Shearman
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WIN32_NO_STATUS
28 //#include "wine/port.h"
35 //#include "winerror.h"
38 //#include "winuser.h"
42 //#include "wine/list.h"
43 #include <wine/debug.h>
44 #include <wine/unicode.h>
45 #include <wine/exception.h>
47 #include "compobj_private.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
53 /* see MSDN docs for IROTData::GetComparisonData, which states what this
56 #define MAX_COMPARISON_DATA 2048
58 static LONG WINAPI
rpc_filter(EXCEPTION_POINTERS
*eptr
)
60 return I_RpcExceptionFilter(eptr
->ExceptionRecord
->ExceptionCode
);
63 /* define the structure of the running object table elements */
67 InterfaceData
* object
; /* marshaled running object*/
68 MonikerComparisonData
* moniker_data
; /* moniker comparison data that identifies this object */
69 DWORD cookie
; /* cookie identifying this object */
70 FILETIME last_modified
;
71 IrotContextHandle ctxt_handle
;
74 /* define the RunningObjectTableImpl structure */
75 typedef struct RunningObjectTableImpl
77 IRunningObjectTable IRunningObjectTable_iface
;
80 struct list rot
; /* list of ROT entries */
81 CRITICAL_SECTION lock
;
82 } RunningObjectTableImpl
;
84 static RunningObjectTableImpl
* runningObjectTableInstance
= NULL
;
85 static IrotHandle irot_handle
;
87 /* define the EnumMonikerImpl structure */
88 typedef struct EnumMonikerImpl
90 IEnumMoniker IEnumMoniker_iface
;
93 InterfaceList
*moniker_list
;
97 static inline RunningObjectTableImpl
*impl_from_IRunningObjectTable(IRunningObjectTable
*iface
)
99 return CONTAINING_RECORD(iface
, RunningObjectTableImpl
, IRunningObjectTable_iface
);
102 static inline EnumMonikerImpl
*impl_from_IEnumMoniker(IEnumMoniker
*iface
)
104 return CONTAINING_RECORD(iface
, EnumMonikerImpl
, IEnumMoniker_iface
);
107 /* IEnumMoniker Local functions*/
108 static HRESULT
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
109 ULONG pos
, IEnumMoniker
**ppenumMoniker
);
111 static IrotHandle
get_irot_handle(void)
117 IrotHandle new_handle
;
118 unsigned short ncacn_np
[] = IROT_PROTSEQ
;
119 unsigned short endpoint
[] = IROT_ENDPOINT
;
120 status
= RpcStringBindingComposeW(NULL
, ncacn_np
, NULL
, endpoint
, NULL
, &binding
);
121 if (status
== RPC_S_OK
)
123 status
= RpcBindingFromStringBindingW(binding
, &new_handle
);
124 RpcStringFreeW(&binding
);
126 if (status
!= RPC_S_OK
)
128 if (InterlockedCompareExchangePointer(&irot_handle
, new_handle
, NULL
))
129 /* another thread beat us to it */
130 RpcBindingFree(&new_handle
);
135 static BOOL
start_rpcss(void)
137 PROCESS_INFORMATION pi
;
140 static const WCHAR rpcss
[] = {'\\','r','p','c','s','s','.','e','x','e',0};
146 ZeroMemory(&si
, sizeof(STARTUPINFOA
));
147 si
.cb
= sizeof(STARTUPINFOA
);
148 GetSystemDirectoryW( cmd
, MAX_PATH
- sizeof(rpcss
)/sizeof(WCHAR
) );
149 strcatW( cmd
, rpcss
);
151 Wow64DisableWow64FsRedirection( &redir
);
152 rslt
= CreateProcessW( cmd
, cmd
, NULL
, NULL
, FALSE
, DETACHED_PROCESS
, NULL
, NULL
, &si
, &pi
);
153 Wow64RevertWow64FsRedirection( redir
);
157 CloseHandle(pi
.hProcess
);
158 CloseHandle(pi
.hThread
);
165 static HRESULT
create_stream_on_mip_ro(const InterfaceData
*mip
, IStream
**stream
)
167 HGLOBAL hglobal
= GlobalAlloc(0, mip
->ulCntData
);
168 void *pv
= GlobalLock(hglobal
);
169 memcpy(pv
, mip
->abData
, mip
->ulCntData
);
170 GlobalUnlock(hglobal
);
171 return CreateStreamOnHGlobal(hglobal
, TRUE
, stream
);
174 static void rot_entry_delete(struct rot_entry
*rot_entry
)
176 if (rot_entry
->cookie
)
178 InterfaceData
*object
= NULL
;
179 InterfaceData
*moniker
= NULL
;
182 IrotRevoke(get_irot_handle(), rot_entry
->cookie
,
183 &rot_entry
->ctxt_handle
, &object
, &moniker
);
189 MIDL_user_free(object
);
194 hr
= create_stream_on_mip_ro(moniker
, &stream
);
197 CoReleaseMarshalData(stream
);
198 IStream_Release(stream
);
201 MIDL_user_free(moniker
);
203 if (rot_entry
->object
)
207 hr
= create_stream_on_mip_ro(rot_entry
->object
, &stream
);
210 CoReleaseMarshalData(stream
);
211 IStream_Release(stream
);
214 HeapFree(GetProcessHeap(), 0, rot_entry
->object
);
215 HeapFree(GetProcessHeap(), 0, rot_entry
->moniker_data
);
216 HeapFree(GetProcessHeap(), 0, rot_entry
);
219 /* moniker_data must be freed with HeapFree when no longer in use */
220 static HRESULT
get_moniker_comparison_data(IMoniker
*pMoniker
, MonikerComparisonData
**moniker_data
)
223 IROTData
*pROTData
= NULL
;
224 hr
= IMoniker_QueryInterface(pMoniker
, &IID_IROTData
, (void *)&pROTData
);
227 ULONG size
= MAX_COMPARISON_DATA
;
228 *moniker_data
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MonikerComparisonData
, abData
[size
]));
231 IROTData_Release(pROTData
);
232 return E_OUTOFMEMORY
;
234 hr
= IROTData_GetComparisonData(pROTData
, (*moniker_data
)->abData
, size
, &size
);
235 IROTData_Release(pROTData
);
238 ERR("Failed to copy comparison data into buffer, hr = 0x%08x\n", hr
);
239 HeapFree(GetProcessHeap(), 0, *moniker_data
);
242 (*moniker_data
)->ulCntData
= size
;
247 LPOLESTR pszDisplayName
;
251 TRACE("generating comparison data from display name\n");
253 hr
= CreateBindCtx(0, &pbc
);
256 hr
= IMoniker_GetDisplayName(pMoniker
, pbc
, NULL
, &pszDisplayName
);
257 IBindCtx_Release(pbc
);
260 hr
= IMoniker_GetClassID(pMoniker
, &clsid
);
263 CoTaskMemFree(pszDisplayName
);
267 len
= strlenW(pszDisplayName
);
268 *moniker_data
= HeapAlloc(GetProcessHeap(), 0,
269 FIELD_OFFSET(MonikerComparisonData
, abData
[sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
)]));
272 CoTaskMemFree(pszDisplayName
);
273 return E_OUTOFMEMORY
;
275 (*moniker_data
)->ulCntData
= sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
);
277 memcpy(&(*moniker_data
)->abData
[0], &clsid
, sizeof(clsid
));
278 memcpy(&(*moniker_data
)->abData
[sizeof(clsid
)], pszDisplayName
, (len
+1)*sizeof(WCHAR
));
279 CoTaskMemFree(pszDisplayName
);
284 static HRESULT
reduce_moniker(IMoniker
*pmk
, IBindCtx
*pbc
, IMoniker
**pmkReduced
)
286 IBindCtx
*pbcNew
= NULL
;
290 hr
= CreateBindCtx(0, &pbcNew
);
295 hr
= IMoniker_Reduce(pmk
, pbc
, MKRREDUCE_ALL
, NULL
, pmkReduced
);
297 ERR("reducing moniker failed with error 0x%08x\n", hr
);
298 if (pbcNew
) IBindCtx_Release(pbcNew
);
302 /***********************************************************************
303 * RunningObjectTable_QueryInterface
305 static HRESULT WINAPI
306 RunningObjectTableImpl_QueryInterface(IRunningObjectTable
* iface
,
307 REFIID riid
,void** ppvObject
)
309 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
311 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
313 /* validate arguments */
320 if (IsEqualIID(&IID_IUnknown
, riid
) ||
321 IsEqualIID(&IID_IRunningObjectTable
, riid
))
325 return E_NOINTERFACE
;
327 IRunningObjectTable_AddRef(iface
);
332 /***********************************************************************
333 * RunningObjectTable_AddRef
336 RunningObjectTableImpl_AddRef(IRunningObjectTable
* iface
)
338 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
340 TRACE("(%p)\n",This
);
342 return InterlockedIncrement(&This
->ref
);
345 /***********************************************************************
346 * RunningObjectTable_Destroy
349 RunningObjectTableImpl_Destroy(void)
351 struct list
*cursor
, *cursor2
;
352 IrotHandle old_handle
;
356 if (runningObjectTableInstance
==NULL
)
359 /* free the ROT table memory */
360 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &runningObjectTableInstance
->rot
)
362 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
363 list_remove(&rot_entry
->entry
);
364 rot_entry_delete(rot_entry
);
367 DEBUG_CLEAR_CRITSEC_NAME(&runningObjectTableInstance
->lock
);
368 DeleteCriticalSection(&runningObjectTableInstance
->lock
);
370 /* free the ROT structure memory */
371 HeapFree(GetProcessHeap(),0,runningObjectTableInstance
);
372 runningObjectTableInstance
= NULL
;
374 old_handle
= irot_handle
;
377 RpcBindingFree(&old_handle
);
382 /***********************************************************************
383 * RunningObjectTable_Release
386 RunningObjectTableImpl_Release(IRunningObjectTable
* iface
)
388 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
391 TRACE("(%p)\n",This
);
393 ref
= InterlockedDecrement(&This
->ref
);
395 /* uninitialize ROT structure if there's no more references to it */
398 struct list
*cursor
, *cursor2
;
399 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &This
->rot
)
401 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
402 list_remove(&rot_entry
->entry
);
403 rot_entry_delete(rot_entry
);
405 /* RunningObjectTable data structure will be not destroyed here ! the destruction will be done only
406 * when RunningObjectTableImpl_UnInitialize function is called
413 /***********************************************************************
414 * RunningObjectTable_Register
417 * grfFlags [in] Registration options
418 * punkObject [in] the object being registered
419 * pmkObjectName [in] the moniker of the object being registered
420 * pdwRegister [out] the value identifying the registration
422 static HRESULT WINAPI
423 RunningObjectTableImpl_Register(IRunningObjectTable
* iface
, DWORD grfFlags
,
424 IUnknown
*punkObject
, IMoniker
*pmkObjectName
, DWORD
*pdwRegister
)
426 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
427 struct rot_entry
*rot_entry
;
429 IStream
*pStream
= NULL
;
432 InterfaceData
*moniker
= NULL
;
434 TRACE("(%p,%d,%p,%p,%p)\n",This
,grfFlags
,punkObject
,pmkObjectName
,pdwRegister
);
436 if (grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
))
438 ERR("Invalid grfFlags: 0x%08x\n", grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
));
442 if (punkObject
==NULL
|| pmkObjectName
==NULL
|| pdwRegister
==NULL
)
445 rot_entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*rot_entry
));
447 return E_OUTOFMEMORY
;
450 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
453 rot_entry_delete(rot_entry
);
456 mshlflags
= (grfFlags
& ROTFLAGS_REGISTRATIONKEEPSALIVE
) ? MSHLFLAGS_TABLESTRONG
: MSHLFLAGS_TABLEWEAK
;
457 hr
= CoMarshalInterface(pStream
, &IID_IUnknown
, punkObject
, MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, mshlflags
);
458 /* FIXME: a cleaner way would be to create an IStream class that writes
459 * directly to an MInterfacePointer */
463 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
466 SIZE_T size
= GlobalSize(hglobal
);
467 const void *pv
= GlobalLock(hglobal
);
468 rot_entry
->object
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer
, abData
[size
]));
469 rot_entry
->object
->ulCntData
= size
;
470 memcpy(rot_entry
->object
->abData
, pv
, size
);
471 GlobalUnlock(hglobal
);
474 IStream_Release(pStream
);
477 rot_entry_delete(rot_entry
);
481 hr
= CreateBindCtx(0, &pbc
);
484 rot_entry_delete(rot_entry
);
488 hr
= reduce_moniker(pmkObjectName
, pbc
, &pmkObjectName
);
491 rot_entry_delete(rot_entry
);
492 IBindCtx_Release(pbc
);
496 hr
= IMoniker_GetTimeOfLastChange(pmkObjectName
, pbc
, NULL
,
497 &rot_entry
->last_modified
);
498 IBindCtx_Release(pbc
);
501 CoFileTimeNow(&rot_entry
->last_modified
);
505 hr
= get_moniker_comparison_data(pmkObjectName
,
506 &rot_entry
->moniker_data
);
509 rot_entry_delete(rot_entry
);
510 IMoniker_Release(pmkObjectName
);
514 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
517 rot_entry_delete(rot_entry
);
518 IMoniker_Release(pmkObjectName
);
521 /* marshal moniker */
522 hr
= CoMarshalInterface(pStream
, &IID_IMoniker
, (IUnknown
*)pmkObjectName
,
523 MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, MSHLFLAGS_TABLESTRONG
);
524 /* FIXME: a cleaner way would be to create an IStream class that writes
525 * directly to an MInterfacePointer */
529 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
532 SIZE_T size
= GlobalSize(hglobal
);
533 const void *pv
= GlobalLock(hglobal
);
534 moniker
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceData
, abData
[size
]));
535 moniker
->ulCntData
= size
;
536 memcpy(moniker
->abData
, pv
, size
);
537 GlobalUnlock(hglobal
);
540 IStream_Release(pStream
);
541 IMoniker_Release(pmkObjectName
);
544 HeapFree(GetProcessHeap(), 0, moniker
);
545 rot_entry_delete(rot_entry
);
554 hr
= IrotRegister(get_irot_handle(), rot_entry
->moniker_data
,
555 rot_entry
->object
, moniker
,
556 &rot_entry
->last_modified
, grfFlags
,
557 &rot_entry
->cookie
, &rot_entry
->ctxt_handle
);
561 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
564 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
571 HeapFree(GetProcessHeap(), 0, moniker
);
574 rot_entry_delete(rot_entry
);
578 /* gives a registration identifier to the registered object*/
579 *pdwRegister
= rot_entry
->cookie
;
581 EnterCriticalSection(&This
->lock
);
582 list_add_tail(&This
->rot
, &rot_entry
->entry
);
583 LeaveCriticalSection(&This
->lock
);
588 /***********************************************************************
589 * RunningObjectTable_Revoke
592 * dwRegister [in] Value identifying registration to be revoked
594 static HRESULT WINAPI
595 RunningObjectTableImpl_Revoke( IRunningObjectTable
* iface
, DWORD dwRegister
)
597 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
598 struct rot_entry
*rot_entry
;
600 TRACE("(%p,%d)\n",This
,dwRegister
);
602 EnterCriticalSection(&This
->lock
);
603 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
605 if (rot_entry
->cookie
== dwRegister
)
607 list_remove(&rot_entry
->entry
);
608 LeaveCriticalSection(&This
->lock
);
610 rot_entry_delete(rot_entry
);
614 LeaveCriticalSection(&This
->lock
);
619 /***********************************************************************
620 * RunningObjectTable_IsRunning
623 * pmkObjectName [in] moniker of the object whose status is desired
625 static HRESULT WINAPI
626 RunningObjectTableImpl_IsRunning( IRunningObjectTable
* iface
, IMoniker
*pmkObjectName
)
628 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
629 MonikerComparisonData
*moniker_data
;
631 const struct rot_entry
*rot_entry
;
633 TRACE("(%p,%p)\n",This
,pmkObjectName
);
635 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
638 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
639 IMoniker_Release(pmkObjectName
);
644 EnterCriticalSection(&This
->lock
);
645 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
647 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
648 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
654 LeaveCriticalSection(&This
->lock
);
662 hr
= IrotIsRunning(get_irot_handle(), moniker_data
);
666 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
669 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
678 HeapFree(GetProcessHeap(), 0, moniker_data
);
683 /***********************************************************************
684 * RunningObjectTable_GetObject
687 * pmkObjectName [in] Pointer to the moniker on the object
688 * ppunkObject [out] variable that receives the IUnknown interface pointer
690 static HRESULT WINAPI
691 RunningObjectTableImpl_GetObject( IRunningObjectTable
* iface
,
692 IMoniker
*pmkObjectName
, IUnknown
**ppunkObject
)
694 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
695 MonikerComparisonData
*moniker_data
;
696 InterfaceData
*object
= NULL
;
699 struct rot_entry
*rot_entry
;
701 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,ppunkObject
);
703 if (ppunkObject
== NULL
)
708 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
711 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
712 IMoniker_Release(pmkObjectName
);
716 EnterCriticalSection(&This
->lock
);
717 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
719 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
720 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
723 hr
= create_stream_on_mip_ro(rot_entry
->object
, &pStream
);
726 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
727 IStream_Release(pStream
);
730 LeaveCriticalSection(&This
->lock
);
731 HeapFree(GetProcessHeap(), 0, moniker_data
);
736 LeaveCriticalSection(&This
->lock
);
738 TRACE("moniker unavailable locally, calling SCM\n");
744 hr
= IrotGetObject(get_irot_handle(), moniker_data
, &object
, &cookie
);
748 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
751 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
762 hr
= create_stream_on_mip_ro(object
, &pStream
);
765 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
766 IStream_Release(pStream
);
770 WARN("Moniker unavailable, IrotGetObject returned 0x%08x\n", hr
);
772 HeapFree(GetProcessHeap(), 0, moniker_data
);
777 /***********************************************************************
778 * RunningObjectTable_NoteChangeTime
781 * dwRegister [in] Value identifying registration being updated
782 * pfiletime [in] Pointer to structure containing object's last change time
784 static HRESULT WINAPI
785 RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable
* iface
,
786 DWORD dwRegister
, FILETIME
*pfiletime
)
788 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
789 struct rot_entry
*rot_entry
;
790 HRESULT hr
= E_INVALIDARG
;
792 TRACE("(%p,%d,%p)\n",This
,dwRegister
,pfiletime
);
794 EnterCriticalSection(&This
->lock
);
795 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
797 if (rot_entry
->cookie
== dwRegister
)
799 rot_entry
->last_modified
= *pfiletime
;
800 LeaveCriticalSection(&This
->lock
);
806 hr
= IrotNoteChangeTime(get_irot_handle(), dwRegister
, pfiletime
);
810 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
813 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
824 LeaveCriticalSection(&This
->lock
);
827 TRACE("-- 0x08%x\n", hr
);
831 /***********************************************************************
832 * RunningObjectTable_GetTimeOfLastChange
835 * pmkObjectName [in] moniker of the object whose status is desired
836 * pfiletime [out] structure that receives object's last change time
838 static HRESULT WINAPI
839 RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable
* iface
,
840 IMoniker
*pmkObjectName
, FILETIME
*pfiletime
)
842 HRESULT hr
= MK_E_UNAVAILABLE
;
843 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
844 MonikerComparisonData
*moniker_data
;
845 const struct rot_entry
*rot_entry
;
847 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,pfiletime
);
849 if (pmkObjectName
==NULL
|| pfiletime
==NULL
)
852 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
855 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
856 IMoniker_Release(pmkObjectName
);
860 hr
= MK_E_UNAVAILABLE
;
862 EnterCriticalSection(&This
->lock
);
863 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
865 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
866 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
868 *pfiletime
= rot_entry
->last_modified
;
873 LeaveCriticalSection(&This
->lock
);
881 hr
= IrotGetTimeOfLastChange(get_irot_handle(), moniker_data
, pfiletime
);
885 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
888 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
897 HeapFree(GetProcessHeap(), 0, moniker_data
);
899 TRACE("-- 0x%08x\n", hr
);
903 /***********************************************************************
904 * RunningObjectTable_EnumRunning
907 * ppenumMoniker [out] receives the IEnumMoniker interface pointer
909 static HRESULT WINAPI
910 RunningObjectTableImpl_EnumRunning(IRunningObjectTable
* iface
,
911 IEnumMoniker
**ppenumMoniker
)
913 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
914 InterfaceList
*interface_list
= NULL
;
917 TRACE("(%p, %p)\n", This
, ppenumMoniker
);
919 *ppenumMoniker
= NULL
;
925 hr
= IrotEnumRunning(get_irot_handle(), &interface_list
);
929 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
932 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
941 hr
= EnumMonikerImpl_CreateEnumROTMoniker(interface_list
,
947 /* Virtual function table for the IRunningObjectTable class. */
948 static const IRunningObjectTableVtbl VT_RunningObjectTableImpl
=
950 RunningObjectTableImpl_QueryInterface
,
951 RunningObjectTableImpl_AddRef
,
952 RunningObjectTableImpl_Release
,
953 RunningObjectTableImpl_Register
,
954 RunningObjectTableImpl_Revoke
,
955 RunningObjectTableImpl_IsRunning
,
956 RunningObjectTableImpl_GetObject
,
957 RunningObjectTableImpl_NoteChangeTime
,
958 RunningObjectTableImpl_GetTimeOfLastChange
,
959 RunningObjectTableImpl_EnumRunning
962 /***********************************************************************
963 * RunningObjectTable_Initialize
965 HRESULT WINAPI
RunningObjectTableImpl_Initialize(void)
969 /* create the unique instance of the RunningObjectTableImpl structure */
970 runningObjectTableInstance
= HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl
));
972 if (!runningObjectTableInstance
)
973 return E_OUTOFMEMORY
;
975 /* initialize the virtual table function */
976 runningObjectTableInstance
->IRunningObjectTable_iface
.lpVtbl
= &VT_RunningObjectTableImpl
;
978 /* the initial reference is set to "1" so that it isn't destroyed after its
979 * first use until the process is destroyed, as the running object table is
980 * a process-wide cache of a global table */
981 runningObjectTableInstance
->ref
= 1;
983 list_init(&runningObjectTableInstance
->rot
);
984 InitializeCriticalSection(&runningObjectTableInstance
->lock
);
985 DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance
->lock
, "RunningObjectTableImpl.lock");
990 /***********************************************************************
991 * RunningObjectTable_UnInitialize
993 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize(void)
997 if (runningObjectTableInstance
==NULL
)
1000 RunningObjectTableImpl_Release(&runningObjectTableInstance
->IRunningObjectTable_iface
);
1002 RunningObjectTableImpl_Destroy();
1007 /***********************************************************************
1008 * GetRunningObjectTable (OLE32.@)
1010 * Retrieves the global running object table.
1013 * reserved [I] Reserved. Set to 0.
1014 * pprot [O] Address that receives the pointer to the running object table.
1018 * Failure: Any HRESULT code.
1021 GetRunningObjectTable(DWORD reserved
, LPRUNNINGOBJECTTABLE
*pprot
)
1023 IID riid
=IID_IRunningObjectTable
;
1029 return E_UNEXPECTED
;
1031 if(runningObjectTableInstance
==NULL
)
1032 return CO_E_NOTINITIALIZED
;
1034 res
= IRunningObjectTable_QueryInterface(&runningObjectTableInstance
->IRunningObjectTable_iface
,
1035 &riid
,(void**)pprot
);
1040 static HRESULT
get_moniker_for_progid_display_name(LPBC pbc
,
1041 LPCOLESTR szDisplayName
,
1048 LPCWSTR start
= szDisplayName
;
1051 IMoniker
*class_moniker
;
1056 /* find end delimiter */
1057 for (end
= start
; *end
; end
++)
1063 /* must start with '@' or have a ':' somewhere and mustn't be one character
1064 * long (since that looks like an absolute path) */
1065 if (((start
== szDisplayName
) && (*end
== '\0')) || (len
<= 1))
1068 progid
= HeapAlloc(GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
));
1071 memcpy(progid
, start
, len
* sizeof(WCHAR
));
1074 hr
= CLSIDFromProgID(progid
, &clsid
);
1075 HeapFree(GetProcessHeap(), 0, progid
);
1079 hr
= CreateClassMoniker(&clsid
, &class_moniker
);
1082 IParseDisplayName
*pdn
;
1083 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1084 &IID_IParseDisplayName
, (void **)&pdn
);
1085 /* fallback to using IClassFactory to get IParseDisplayName -
1086 * adsldp.dll depends on this */
1090 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1091 &IID_IClassFactory
, (void **)&pcf
);
1094 hr
= IClassFactory_CreateInstance(pcf
, NULL
,
1095 &IID_IParseDisplayName
,
1097 IClassFactory_Release(pcf
);
1100 IMoniker_Release(class_moniker
);
1103 hr
= IParseDisplayName_ParseDisplayName(pdn
, pbc
,
1104 (LPOLESTR
)szDisplayName
,
1106 IParseDisplayName_Release(pdn
);
1112 /******************************************************************************
1113 * MkParseDisplayName [OLE32.@]
1115 HRESULT WINAPI
MkParseDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
,
1116 LPDWORD pchEaten
, LPMONIKER
*ppmk
)
1118 HRESULT hr
= MK_E_SYNTAX
;
1119 static const WCHAR wszClsidColon
[] = {'c','l','s','i','d',':'};
1123 TRACE("(%p, %s, %p, %p)\n", pbc
, debugstr_w(szDisplayName
), pchEaten
, ppmk
);
1125 if (!pbc
|| !IsValidInterface((LPUNKNOWN
) pbc
))
1126 return E_INVALIDARG
;
1128 if (!szDisplayName
|| !*szDisplayName
)
1129 return E_INVALIDARG
;
1131 if (!pchEaten
|| !ppmk
)
1132 return E_INVALIDARG
;
1137 if (!strncmpiW(szDisplayName
, wszClsidColon
, sizeof(wszClsidColon
)/sizeof(wszClsidColon
[0])))
1139 hr
= ClassMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1140 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1145 hr
= get_moniker_for_progid_display_name(pbc
, szDisplayName
, &chEaten
, &moniker
);
1146 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1152 hr
= FileMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1153 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1161 IMoniker
*next_moniker
;
1162 *pchEaten
+= chEaten
;
1163 szDisplayName
+= chEaten
;
1164 if (!*szDisplayName
)
1170 hr
= IMoniker_ParseDisplayName(moniker
, pbc
, NULL
,
1171 (LPOLESTR
)szDisplayName
, &chEaten
,
1173 IMoniker_Release(moniker
);
1179 moniker
= next_moniker
;
1186 /***********************************************************************
1187 * GetClassFile (OLE32.@)
1189 * Retrieves the class ID associated with the given filename.
1192 * filePathName [I] Filename to retrieve the class ID for.
1193 * pclsid [O] Address that receives the class ID for the file.
1197 * Failure: Any HRESULT code.
1199 HRESULT WINAPI
GetClassFile(LPCOLESTR filePathName
,CLSID
*pclsid
)
1203 int nbElm
, length
, i
;
1205 LPOLESTR
*pathDec
=0,absFile
=0,progId
=0;
1207 static const WCHAR bkslashW
[] = {'\\',0};
1208 static const WCHAR dotW
[] = {'.',0};
1210 TRACE("%s, %p\n", debugstr_w(filePathName
), pclsid
);
1212 /* if the file contain a storage object the return the CLSID written by IStorage_SetClass method*/
1213 if((StgIsStorageFile(filePathName
))==S_OK
){
1215 res
=StgOpenStorage(filePathName
,NULL
,STGM_READ
| STGM_SHARE_DENY_WRITE
,NULL
,0,&pstg
);
1218 res
=ReadClassStg(pstg
,pclsid
);
1220 IStorage_Release(pstg
);
1224 /* If the file is not a storage object then attempt to match various bits in the file against a
1225 pattern in the registry. This case is not frequently used, so I present only the pseudocode for
1228 for(i=0;i<nFileTypes;i++)
1230 for(i=0;j<nPatternsForType;j++){
1235 pat=ReadPatternFromRegistry(i,j);
1236 hFile=CreateFileW(filePathName,,,,,,hFile);
1237 SetFilePosition(hFile,pat.offset);
1238 ReadFile(hFile,buf,pat.size,&r,NULL);
1239 if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
1241 *pclsid=ReadCLSIDFromRegistry(i);
1247 /* if the above strategies fail then search for the extension key in the registry */
1249 /* get the last element (absolute file) in the path name */
1250 nbElm
=FileMonikerImpl_DecomposePath(filePathName
,&pathDec
);
1251 absFile
=pathDec
[nbElm
-1];
1253 /* failed if the path represents a directory and not an absolute file name*/
1254 if (!lstrcmpW(absFile
, bkslashW
))
1255 return MK_E_INVALIDEXTENSION
;
1257 /* get the extension of the file */
1259 length
=lstrlenW(absFile
);
1260 for(i
= length
-1; (i
>= 0) && *(extension
= &absFile
[i
]) != '.'; i
--)
1263 if (!extension
|| !lstrcmpW(extension
, dotW
))
1264 return MK_E_INVALIDEXTENSION
;
1266 res
=RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, NULL
, &sizeProgId
);
1268 /* get the progId associated to the extension */
1269 progId
= CoTaskMemAlloc(sizeProgId
);
1270 res
= RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, progId
, &sizeProgId
);
1272 if (res
==ERROR_SUCCESS
)
1273 /* return the clsid associated to the progId */
1274 res
= CLSIDFromProgID(progId
,pclsid
);
1276 for(i
=0; pathDec
[i
]!=NULL
;i
++)
1277 CoTaskMemFree(pathDec
[i
]);
1278 CoTaskMemFree(pathDec
);
1280 CoTaskMemFree(progId
);
1282 if (res
==ERROR_SUCCESS
)
1285 return MK_E_INVALIDEXTENSION
;
1288 /***********************************************************************
1289 * EnumMoniker_QueryInterface
1291 static HRESULT WINAPI
EnumMonikerImpl_QueryInterface(IEnumMoniker
* iface
,REFIID riid
,void** ppvObject
)
1293 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1295 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
1297 /* validate arguments */
1298 if (ppvObject
== NULL
)
1299 return E_INVALIDARG
;
1303 if (IsEqualIID(&IID_IUnknown
, riid
))
1306 if (IsEqualIID(&IID_IEnumMoniker
, riid
))
1309 if ((*ppvObject
)==NULL
)
1310 return E_NOINTERFACE
;
1312 IEnumMoniker_AddRef(iface
);
1317 /***********************************************************************
1318 * EnumMoniker_AddRef
1320 static ULONG WINAPI
EnumMonikerImpl_AddRef(IEnumMoniker
* iface
)
1322 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1324 TRACE("(%p)\n",This
);
1326 return InterlockedIncrement(&This
->ref
);
1329 /***********************************************************************
1330 * EnumMoniker_release
1332 static ULONG WINAPI
EnumMonikerImpl_Release(IEnumMoniker
* iface
)
1334 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1337 TRACE("(%p)\n",This
);
1339 ref
= InterlockedDecrement(&This
->ref
);
1341 /* uninitialize rot structure if there's no more reference to it*/
1346 TRACE("(%p) Deleting\n",This
);
1348 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1349 HeapFree(GetProcessHeap(), 0, This
->moniker_list
->interfaces
[i
]);
1350 HeapFree(GetProcessHeap(), 0, This
->moniker_list
);
1351 HeapFree(GetProcessHeap(), 0, This
);
1356 /***********************************************************************
1359 static HRESULT WINAPI
EnumMonikerImpl_Next(IEnumMoniker
* iface
, ULONG celt
, IMoniker
** rgelt
, ULONG
* pceltFetched
)
1362 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1365 TRACE("(%p) TabCurrentPos %d Tablastindx %d\n", This
, This
->pos
, This
->moniker_list
->size
);
1367 /* retrieve the requested number of moniker from the current position */
1368 for(i
= 0; (This
->pos
< This
->moniker_list
->size
) && (i
< celt
); i
++)
1371 hr
= create_stream_on_mip_ro(This
->moniker_list
->interfaces
[This
->pos
++], &stream
);
1372 if (hr
!= S_OK
) break;
1373 hr
= CoUnmarshalInterface(stream
, &IID_IMoniker
, (void **)&rgelt
[i
]);
1374 IStream_Release(stream
);
1375 if (hr
!= S_OK
) break;
1378 if (pceltFetched
!= NULL
)
1391 /***********************************************************************
1394 static HRESULT WINAPI
EnumMonikerImpl_Skip(IEnumMoniker
* iface
, ULONG celt
)
1396 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1398 TRACE("(%p)\n",This
);
1400 if (This
->pos
+ celt
>= This
->moniker_list
->size
)
1408 /***********************************************************************
1411 static HRESULT WINAPI
EnumMonikerImpl_Reset(IEnumMoniker
* iface
)
1413 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1415 This
->pos
= 0; /* set back to start of list */
1417 TRACE("(%p)\n",This
);
1422 /***********************************************************************
1425 static HRESULT WINAPI
EnumMonikerImpl_Clone(IEnumMoniker
* iface
, IEnumMoniker
** ppenum
)
1427 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1428 InterfaceList
*moniker_list
;
1431 TRACE("(%p)\n",This
);
1435 moniker_list
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceList
, interfaces
[This
->moniker_list
->size
]));
1437 return E_OUTOFMEMORY
;
1439 moniker_list
->size
= This
->moniker_list
->size
;
1440 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1442 SIZE_T size
= FIELD_OFFSET(InterfaceData
, abData
[This
->moniker_list
->interfaces
[i
]->ulCntData
]);
1443 moniker_list
->interfaces
[i
] = HeapAlloc(GetProcessHeap(), 0, size
);
1444 if (!moniker_list
->interfaces
[i
])
1447 for (i
= 0; i
< end
; i
++)
1448 HeapFree(GetProcessHeap(), 0, moniker_list
->interfaces
[i
]);
1449 HeapFree(GetProcessHeap(), 0, moniker_list
);
1450 return E_OUTOFMEMORY
;
1452 memcpy(moniker_list
->interfaces
[i
], This
->moniker_list
->interfaces
[i
], size
);
1455 /* copy the enum structure */
1456 return EnumMonikerImpl_CreateEnumROTMoniker(moniker_list
, This
->pos
, ppenum
);
1459 /* Virtual function table for the IEnumMoniker class. */
1460 static const IEnumMonikerVtbl VT_EnumMonikerImpl
=
1462 EnumMonikerImpl_QueryInterface
,
1463 EnumMonikerImpl_AddRef
,
1464 EnumMonikerImpl_Release
,
1465 EnumMonikerImpl_Next
,
1466 EnumMonikerImpl_Skip
,
1467 EnumMonikerImpl_Reset
,
1468 EnumMonikerImpl_Clone
1471 /***********************************************************************
1472 * EnumMonikerImpl_CreateEnumROTMoniker
1473 * Used by EnumRunning to create the structure and EnumClone
1474 * to copy the structure
1476 static HRESULT
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
1478 IEnumMoniker
**ppenumMoniker
)
1480 EnumMonikerImpl
* This
= NULL
;
1483 return E_INVALIDARG
;
1485 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl
));
1486 if (!This
) return E_OUTOFMEMORY
;
1488 TRACE("(%p)\n", This
);
1490 /* initialize the virtual table function */
1491 This
->IEnumMoniker_iface
.lpVtbl
= &VT_EnumMonikerImpl
;
1493 /* the initial reference is set to "1" */
1494 This
->ref
= 1; /* set the ref count to one */
1495 This
->pos
= current_pos
; /* Set the list start posn */
1496 This
->moniker_list
= moniker_list
;
1498 *ppenumMoniker
= &This
->IEnumMoniker_iface
;
1504 /* Shared implementation of moniker marshaler based on saving and loading of
1507 typedef struct MonikerMarshal
1509 IUnknown IUnknown_iface
;
1510 IMarshal IMarshal_iface
;
1516 static inline MonikerMarshal
*impl_from_IUnknown(IUnknown
*iface
)
1518 return CONTAINING_RECORD(iface
, MonikerMarshal
, IUnknown_iface
);
1521 static inline MonikerMarshal
*impl_from_IMarshal( IMarshal
*iface
)
1523 return CONTAINING_RECORD(iface
, MonikerMarshal
, IMarshal_iface
);
1526 static HRESULT WINAPI
MonikerMarshalInner_QueryInterface(IUnknown
*iface
, REFIID riid
, LPVOID
*ppv
)
1528 MonikerMarshal
*This
= impl_from_IUnknown(iface
);
1529 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
1531 if (IsEqualIID(&IID_IUnknown
, riid
) || IsEqualIID(&IID_IMarshal
, riid
))
1533 *ppv
= &This
->IMarshal_iface
;
1534 IUnknown_AddRef((IUnknown
*)&This
->IMarshal_iface
);
1537 FIXME("No interface for %s\n", debugstr_guid(riid
));
1538 return E_NOINTERFACE
;
1541 static ULONG WINAPI
MonikerMarshalInner_AddRef(IUnknown
*iface
)
1543 MonikerMarshal
*This
= impl_from_IUnknown(iface
);
1544 return InterlockedIncrement(&This
->ref
);
1547 static ULONG WINAPI
MonikerMarshalInner_Release(IUnknown
*iface
)
1549 MonikerMarshal
*This
= impl_from_IUnknown(iface
);
1550 ULONG ref
= InterlockedDecrement(&This
->ref
);
1552 if (!ref
) HeapFree(GetProcessHeap(), 0, This
);
1556 static const IUnknownVtbl VT_MonikerMarshalInner
=
1558 MonikerMarshalInner_QueryInterface
,
1559 MonikerMarshalInner_AddRef
,
1560 MonikerMarshalInner_Release
1563 static HRESULT WINAPI
MonikerMarshal_QueryInterface(IMarshal
*iface
, REFIID riid
, LPVOID
*ppv
)
1565 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1566 return IMoniker_QueryInterface(This
->moniker
, riid
, ppv
);
1569 static ULONG WINAPI
MonikerMarshal_AddRef(IMarshal
*iface
)
1571 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1572 return IMoniker_AddRef(This
->moniker
);
1575 static ULONG WINAPI
MonikerMarshal_Release(IMarshal
*iface
)
1577 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1578 return IMoniker_Release(This
->moniker
);
1581 static HRESULT WINAPI
MonikerMarshal_GetUnmarshalClass(
1582 LPMARSHAL iface
, REFIID riid
, void* pv
, DWORD dwDestContext
,
1583 void* pvDestContext
, DWORD mshlflags
, CLSID
* pCid
)
1585 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1587 TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid
), pv
,
1588 dwDestContext
, pvDestContext
, mshlflags
, pCid
);
1590 return IMoniker_GetClassID(This
->moniker
, pCid
);
1593 static HRESULT WINAPI
MonikerMarshal_GetMarshalSizeMax(
1594 LPMARSHAL iface
, REFIID riid
, void* pv
, DWORD dwDestContext
,
1595 void* pvDestContext
, DWORD mshlflags
, DWORD
* pSize
)
1597 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1599 ULARGE_INTEGER size
;
1601 TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid
), pv
,
1602 dwDestContext
, pvDestContext
, mshlflags
, pSize
);
1604 hr
= IMoniker_GetSizeMax(This
->moniker
, &size
);
1606 *pSize
= (DWORD
)size
.QuadPart
;
1610 static HRESULT WINAPI
MonikerMarshal_MarshalInterface(LPMARSHAL iface
, IStream
*pStm
,
1611 REFIID riid
, void* pv
, DWORD dwDestContext
,
1612 void* pvDestContext
, DWORD mshlflags
)
1614 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1616 TRACE("(%p, %s, %p, %x, %p, %x)\n", pStm
, debugstr_guid(riid
), pv
,
1617 dwDestContext
, pvDestContext
, mshlflags
);
1619 return IMoniker_Save(This
->moniker
, pStm
, FALSE
);
1622 static HRESULT WINAPI
MonikerMarshal_UnmarshalInterface(LPMARSHAL iface
, IStream
*pStm
, REFIID riid
, void **ppv
)
1624 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1627 TRACE("(%p, %s, %p)\n", pStm
, debugstr_guid(riid
), ppv
);
1629 hr
= IMoniker_Load(This
->moniker
, pStm
);
1631 hr
= IMoniker_QueryInterface(This
->moniker
, riid
, ppv
);
1635 static HRESULT WINAPI
MonikerMarshal_ReleaseMarshalData(LPMARSHAL iface
, IStream
*pStm
)
1638 /* can't release a state-based marshal as nothing on server side to
1643 static HRESULT WINAPI
MonikerMarshal_DisconnectObject(LPMARSHAL iface
, DWORD dwReserved
)
1646 /* can't disconnect a state-based marshal as nothing on server side to
1647 * disconnect from */
1651 static const IMarshalVtbl VT_MonikerMarshal
=
1653 MonikerMarshal_QueryInterface
,
1654 MonikerMarshal_AddRef
,
1655 MonikerMarshal_Release
,
1656 MonikerMarshal_GetUnmarshalClass
,
1657 MonikerMarshal_GetMarshalSizeMax
,
1658 MonikerMarshal_MarshalInterface
,
1659 MonikerMarshal_UnmarshalInterface
,
1660 MonikerMarshal_ReleaseMarshalData
,
1661 MonikerMarshal_DisconnectObject
1664 HRESULT
MonikerMarshal_Create(IMoniker
*inner
, IUnknown
**outer
)
1666 MonikerMarshal
*This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1667 if (!This
) return E_OUTOFMEMORY
;
1669 This
->IUnknown_iface
.lpVtbl
= &VT_MonikerMarshalInner
;
1670 This
->IMarshal_iface
.lpVtbl
= &VT_MonikerMarshal
;
1672 This
->moniker
= inner
;
1674 *outer
= &This
->IUnknown_iface
;
1678 void * __RPC_USER
MIDL_user_allocate(SIZE_T size
)
1680 return HeapAlloc(GetProcessHeap(), 0, size
);
1683 void __RPC_USER
MIDL_user_free(void *p
)
1685 HeapFree(GetProcessHeap(), 0, p
);