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 * - IRunningObjectTable should work interprocess, but currently doesn't.
25 * Native (on Win2k at least) uses an undocumented RPC interface, IROT, to
26 * communicate with RPCSS which contains the table of marshalled data.
41 #include "wine/list.h"
42 #include "wine/debug.h"
43 #include "wine/unicode.h"
44 #include "wine/exception.h"
46 #include "compobj_private.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
52 /* see MSDN docs for IROTData::GetComparisonData, which states what this
53 * constant is (http://msdn2.microsoft.com/en-us/library/ms693773.aspx) */
54 #define MAX_COMPARISON_DATA 2048
56 static LONG WINAPI
rpc_filter(EXCEPTION_POINTERS
*eptr
)
58 switch (eptr
->ExceptionRecord
->ExceptionCode
)
60 case EXCEPTION_ACCESS_VIOLATION
:
61 case EXCEPTION_ILLEGAL_INSTRUCTION
:
62 return EXCEPTION_CONTINUE_SEARCH
;
64 return EXCEPTION_EXECUTE_HANDLER
;
68 /* define the structure of the running object table elements */
72 InterfaceData
* object
; /* marshaled running object*/
73 MonikerComparisonData
* moniker_data
; /* moniker comparison data that identifies this object */
74 DWORD cookie
; /* cookie identifying this object */
75 FILETIME last_modified
;
76 IrotContextHandle ctxt_handle
;
79 /* define the RunningObjectTableImpl structure */
80 typedef struct RunningObjectTableImpl
82 const IRunningObjectTableVtbl
*lpVtbl
;
85 struct list rot
; /* list of ROT entries */
86 CRITICAL_SECTION lock
;
87 } RunningObjectTableImpl
;
89 static RunningObjectTableImpl
* runningObjectTableInstance
= NULL
;
90 static IrotHandle irot_handle
;
92 /* define the EnumMonikerImpl structure */
93 typedef struct EnumMonikerImpl
95 const IEnumMonikerVtbl
*lpVtbl
;
98 InterfaceList
*moniker_list
;
103 /* IEnumMoniker Local functions*/
104 static HRESULT WINAPI
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
105 ULONG pos
, IEnumMoniker
**ppenumMoniker
);
107 static IrotHandle
get_irot_handle(void)
113 IrotHandle new_handle
;
114 unsigned short ncacn_np
[] = IROT_PROTSEQ
;
115 unsigned short endpoint
[] = IROT_ENDPOINT
;
116 status
= RpcStringBindingComposeW(NULL
, ncacn_np
, NULL
, endpoint
, NULL
, &binding
);
117 if (status
== RPC_S_OK
)
119 status
= RpcBindingFromStringBindingW(binding
, &new_handle
);
120 RpcStringFreeW(&binding
);
122 if (status
!= RPC_S_OK
)
124 if (InterlockedCompareExchangePointer(&irot_handle
, new_handle
, NULL
))
125 /* another thread beat us to it */
126 RpcBindingFree(&new_handle
);
131 static BOOL
start_rpcss(void)
133 PROCESS_INFORMATION pi
;
136 static const WCHAR rpcss
[] = {'r','p','c','s','s',0};
141 ZeroMemory(&pi
, sizeof(PROCESS_INFORMATION
));
142 ZeroMemory(&si
, sizeof(STARTUPINFOA
));
143 si
.cb
= sizeof(STARTUPINFOA
);
145 memcpy(cmd
, rpcss
, sizeof(rpcss
));
147 rslt
= CreateProcessW(
148 NULL
, /* executable */
149 cmd
, /* command line */
150 NULL
, /* process security attributes */
151 NULL
, /* primary thread security attributes */
152 FALSE
, /* inherit handles */
153 0, /* creation flags */
154 NULL
, /* use parent's environment */
155 NULL
, /* use parent's current directory */
156 &si
, /* STARTUPINFO pointer */
157 &pi
/* PROCESS_INFORMATION */
162 CloseHandle(pi
.hProcess
);
163 CloseHandle(pi
.hThread
);
170 static HRESULT
create_stream_on_mip_ro(const InterfaceData
*mip
, IStream
**stream
)
172 HGLOBAL hglobal
= GlobalAlloc(0, mip
->ulCntData
);
173 void *pv
= GlobalLock(hglobal
);
174 memcpy(pv
, mip
->abData
, mip
->ulCntData
);
175 GlobalUnlock(hglobal
);
176 return CreateStreamOnHGlobal(hglobal
, TRUE
, stream
);
179 static inline void rot_entry_delete(struct rot_entry
*rot_entry
)
181 if (rot_entry
->cookie
)
183 InterfaceData
*object
= NULL
;
184 InterfaceData
*moniker
= NULL
;
187 IrotRevoke(get_irot_handle(), rot_entry
->cookie
,
188 &rot_entry
->ctxt_handle
, &object
, &moniker
);
194 MIDL_user_free(object
);
199 hr
= create_stream_on_mip_ro(moniker
, &stream
);
202 CoReleaseMarshalData(stream
);
203 IUnknown_Release(stream
);
206 MIDL_user_free(moniker
);
208 if (rot_entry
->object
)
212 hr
= create_stream_on_mip_ro(rot_entry
->object
, &stream
);
215 CoReleaseMarshalData(stream
);
216 IUnknown_Release(stream
);
219 HeapFree(GetProcessHeap(), 0, rot_entry
->object
);
220 HeapFree(GetProcessHeap(), 0, rot_entry
->moniker_data
);
221 HeapFree(GetProcessHeap(), 0, rot_entry
);
224 /* moniker_data must be freed with HeapFree when no longer in use */
225 static HRESULT
get_moniker_comparison_data(IMoniker
*pMoniker
, MonikerComparisonData
**moniker_data
)
228 IROTData
*pROTData
= NULL
;
229 hr
= IMoniker_QueryInterface(pMoniker
, &IID_IROTData
, (void *)&pROTData
);
232 ULONG size
= MAX_COMPARISON_DATA
;
233 *moniker_data
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MonikerComparisonData
, abData
[size
]));
236 IROTData_Release(pROTData
);
237 return E_OUTOFMEMORY
;
239 hr
= IROTData_GetComparisonData(pROTData
, (*moniker_data
)->abData
, size
, &size
);
240 IROTData_Release(pROTData
);
243 ERR("Failed to copy comparison data into buffer, hr = 0x%08x\n", hr
);
244 HeapFree(GetProcessHeap(), 0, *moniker_data
);
247 (*moniker_data
)->ulCntData
= size
;
252 LPOLESTR pszDisplayName
;
256 TRACE("generating comparison data from display name\n");
258 hr
= CreateBindCtx(0, &pbc
);
261 hr
= IMoniker_GetDisplayName(pMoniker
, pbc
, NULL
, &pszDisplayName
);
262 IBindCtx_Release(pbc
);
265 hr
= IMoniker_GetClassID(pMoniker
, &clsid
);
268 CoTaskMemFree(pszDisplayName
);
272 len
= strlenW(pszDisplayName
);
273 *moniker_data
= HeapAlloc(GetProcessHeap(), 0,
274 FIELD_OFFSET(MonikerComparisonData
, abData
[sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
)]));
277 CoTaskMemFree(pszDisplayName
);
278 return E_OUTOFMEMORY
;
280 (*moniker_data
)->ulCntData
= sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
);
282 memcpy(&(*moniker_data
)->abData
[0], &clsid
, sizeof(clsid
));
283 memcpy(&(*moniker_data
)->abData
[sizeof(clsid
)], pszDisplayName
, (len
+1)*sizeof(WCHAR
));
284 CoTaskMemFree(pszDisplayName
);
289 static HRESULT
reduce_moniker(IMoniker
*pmk
, IBindCtx
*pbc
, IMoniker
**pmkReduced
)
291 IBindCtx
*pbcNew
= NULL
;
295 hr
= CreateBindCtx(0, &pbcNew
);
300 hr
= IMoniker_Reduce(pmk
, pbc
, MKRREDUCE_ALL
, NULL
, pmkReduced
);
302 ERR("reducing moniker failed with error 0x%08x\n", hr
);
303 if (pbcNew
) IBindCtx_Release(pbcNew
);
307 /***********************************************************************
308 * RunningObjectTable_QueryInterface
310 static HRESULT WINAPI
311 RunningObjectTableImpl_QueryInterface(IRunningObjectTable
* iface
,
312 REFIID riid
,void** ppvObject
)
314 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
316 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
318 /* validate arguments */
325 if (IsEqualIID(&IID_IUnknown
, riid
) ||
326 IsEqualIID(&IID_IRunningObjectTable
, riid
))
327 *ppvObject
= (IRunningObjectTable
*)This
;
330 return E_NOINTERFACE
;
332 IRunningObjectTable_AddRef(iface
);
337 /***********************************************************************
338 * RunningObjectTable_AddRef
341 RunningObjectTableImpl_AddRef(IRunningObjectTable
* iface
)
343 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
345 TRACE("(%p)\n",This
);
347 return InterlockedIncrement(&This
->ref
);
350 /***********************************************************************
351 * RunningObjectTable_Initialize
353 static HRESULT WINAPI
354 RunningObjectTableImpl_Destroy(void)
356 struct list
*cursor
, *cursor2
;
357 IrotHandle old_handle
;
361 if (runningObjectTableInstance
==NULL
)
364 /* free the ROT table memory */
365 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &runningObjectTableInstance
->rot
)
367 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
368 list_remove(&rot_entry
->entry
);
369 rot_entry_delete(rot_entry
);
372 DEBUG_CLEAR_CRITSEC_NAME(&runningObjectTableInstance
->lock
);
373 DeleteCriticalSection(&runningObjectTableInstance
->lock
);
375 /* free the ROT structure memory */
376 HeapFree(GetProcessHeap(),0,runningObjectTableInstance
);
377 runningObjectTableInstance
= NULL
;
379 old_handle
= irot_handle
;
382 RpcBindingFree(&old_handle
);
387 /***********************************************************************
388 * RunningObjectTable_Release
391 RunningObjectTableImpl_Release(IRunningObjectTable
* iface
)
393 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
396 TRACE("(%p)\n",This
);
398 ref
= InterlockedDecrement(&This
->ref
);
400 /* uninitialize ROT structure if there's no more references to it */
403 struct list
*cursor
, *cursor2
;
404 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &This
->rot
)
406 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
407 list_remove(&rot_entry
->entry
);
408 rot_entry_delete(rot_entry
);
410 /* RunningObjectTable data structure will be not destroyed here ! the destruction will be done only
411 * when RunningObjectTableImpl_UnInitialize function is called
418 /***********************************************************************
419 * RunningObjectTable_Register
422 * grfFlags [in] Registration options
423 * punkObject [in] the object being registered
424 * pmkObjectName [in] the moniker of the object being registered
425 * pdwRegister [in] the value identifying the registration
427 static HRESULT WINAPI
428 RunningObjectTableImpl_Register(IRunningObjectTable
* iface
, DWORD grfFlags
,
429 IUnknown
*punkObject
, IMoniker
*pmkObjectName
, DWORD
*pdwRegister
)
431 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
432 struct rot_entry
*rot_entry
;
434 IStream
*pStream
= NULL
;
437 InterfaceData
*moniker
= NULL
;
439 TRACE("(%p,%d,%p,%p,%p)\n",This
,grfFlags
,punkObject
,pmkObjectName
,pdwRegister
);
441 if (grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
))
443 ERR("Invalid grfFlags: 0x%08x\n", grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
));
447 if (punkObject
==NULL
|| pmkObjectName
==NULL
|| pdwRegister
==NULL
)
450 rot_entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*rot_entry
));
452 return E_OUTOFMEMORY
;
455 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
458 rot_entry_delete(rot_entry
);
461 mshlflags
= (grfFlags
& ROTFLAGS_REGISTRATIONKEEPSALIVE
) ? MSHLFLAGS_TABLESTRONG
: MSHLFLAGS_TABLEWEAK
;
462 hr
= CoMarshalInterface(pStream
, &IID_IUnknown
, punkObject
, MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, mshlflags
);
463 /* FIXME: a cleaner way would be to create an IStream class that writes
464 * directly to an MInterfacePointer */
468 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
471 SIZE_T size
= GlobalSize(hglobal
);
472 const void *pv
= GlobalLock(hglobal
);
473 rot_entry
->object
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer
, abData
[size
]));
474 rot_entry
->object
->ulCntData
= size
;
475 memcpy(&rot_entry
->object
->abData
, pv
, size
);
476 GlobalUnlock(hglobal
);
479 IStream_Release(pStream
);
482 rot_entry_delete(rot_entry
);
486 hr
= CreateBindCtx(0, &pbc
);
489 rot_entry_delete(rot_entry
);
493 hr
= reduce_moniker(pmkObjectName
, pbc
, &pmkObjectName
);
496 rot_entry_delete(rot_entry
);
497 IBindCtx_Release(pbc
);
501 hr
= IMoniker_GetTimeOfLastChange(pmkObjectName
, pbc
, NULL
,
502 &rot_entry
->last_modified
);
503 IBindCtx_Release(pbc
);
506 CoFileTimeNow(&rot_entry
->last_modified
);
510 hr
= get_moniker_comparison_data(pmkObjectName
,
511 &rot_entry
->moniker_data
);
514 rot_entry_delete(rot_entry
);
515 IMoniker_Release(pmkObjectName
);
519 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
522 rot_entry_delete(rot_entry
);
523 IMoniker_Release(pmkObjectName
);
526 /* marshal moniker */
527 hr
= CoMarshalInterface(pStream
, &IID_IMoniker
, (IUnknown
*)pmkObjectName
,
528 MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, MSHLFLAGS_TABLESTRONG
);
529 /* FIXME: a cleaner way would be to create an IStream class that writes
530 * directly to an MInterfacePointer */
534 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
537 SIZE_T size
= GlobalSize(hglobal
);
538 const void *pv
= GlobalLock(hglobal
);
539 moniker
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceData
, abData
[size
]));
540 moniker
->ulCntData
= size
;
541 memcpy(&moniker
->abData
, pv
, size
);
542 GlobalUnlock(hglobal
);
545 IStream_Release(pStream
);
546 IMoniker_Release(pmkObjectName
);
549 HeapFree(GetProcessHeap(), 0, moniker
);
550 rot_entry_delete(rot_entry
);
559 hr
= IrotRegister(get_irot_handle(), rot_entry
->moniker_data
,
560 rot_entry
->object
, moniker
,
561 &rot_entry
->last_modified
, grfFlags
,
562 &rot_entry
->cookie
, &rot_entry
->ctxt_handle
);
566 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
569 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
576 HeapFree(GetProcessHeap(), 0, moniker
);
579 rot_entry_delete(rot_entry
);
583 /* gives a registration identifier to the registered object*/
584 *pdwRegister
= rot_entry
->cookie
;
586 EnterCriticalSection(&This
->lock
);
587 list_add_tail(&This
->rot
, &rot_entry
->entry
);
588 LeaveCriticalSection(&This
->lock
);
593 /***********************************************************************
594 * RunningObjectTable_Revoke
597 * dwRegister [in] Value identifying registration to be revoked
599 static HRESULT WINAPI
600 RunningObjectTableImpl_Revoke( IRunningObjectTable
* iface
, DWORD dwRegister
)
602 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
603 struct rot_entry
*rot_entry
;
605 TRACE("(%p,%d)\n",This
,dwRegister
);
607 EnterCriticalSection(&This
->lock
);
608 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
610 if (rot_entry
->cookie
== dwRegister
)
612 list_remove(&rot_entry
->entry
);
613 LeaveCriticalSection(&This
->lock
);
615 rot_entry_delete(rot_entry
);
619 LeaveCriticalSection(&This
->lock
);
624 /***********************************************************************
625 * RunningObjectTable_IsRunning
628 * pmkObjectName [in] moniker of the object whose status is desired
630 static HRESULT WINAPI
631 RunningObjectTableImpl_IsRunning( IRunningObjectTable
* iface
, IMoniker
*pmkObjectName
)
633 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
634 MonikerComparisonData
*moniker_data
;
636 const struct rot_entry
*rot_entry
;
638 TRACE("(%p,%p)\n",This
,pmkObjectName
);
640 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
643 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
644 IMoniker_Release(pmkObjectName
);
649 EnterCriticalSection(&This
->lock
);
650 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
652 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
653 !memcmp(&moniker_data
->abData
, &rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
659 LeaveCriticalSection(&This
->lock
);
667 hr
= IrotIsRunning(get_irot_handle(), moniker_data
);
671 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
674 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
683 HeapFree(GetProcessHeap(), 0, moniker_data
);
688 /***********************************************************************
689 * RunningObjectTable_GetObject
692 * pmkObjectName [in] Pointer to the moniker on the object
693 * ppunkObject [out] variable that receives the IUnknown interface pointer
695 static HRESULT WINAPI
696 RunningObjectTableImpl_GetObject( IRunningObjectTable
* iface
,
697 IMoniker
*pmkObjectName
, IUnknown
**ppunkObject
)
699 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
700 MonikerComparisonData
*moniker_data
;
701 InterfaceData
*object
= NULL
;
704 struct rot_entry
*rot_entry
;
706 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,ppunkObject
);
708 if (ppunkObject
== NULL
)
713 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
716 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
717 IMoniker_Release(pmkObjectName
);
721 EnterCriticalSection(&This
->lock
);
722 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
724 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
725 !memcmp(&moniker_data
->abData
, &rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
728 hr
= create_stream_on_mip_ro(rot_entry
->object
, &pStream
);
731 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
732 IStream_Release(pStream
);
735 LeaveCriticalSection(&This
->lock
);
736 HeapFree(GetProcessHeap(), 0, moniker_data
);
741 LeaveCriticalSection(&This
->lock
);
743 TRACE("moniker unavailable locally, calling SCM\n");
749 hr
= IrotGetObject(get_irot_handle(), moniker_data
, &object
, &cookie
);
753 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
756 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
767 hr
= create_stream_on_mip_ro(object
, &pStream
);
770 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
771 IStream_Release(pStream
);
775 WARN("Moniker unavailable, IrotGetObject returned 0x%08x\n", hr
);
777 HeapFree(GetProcessHeap(), 0, moniker_data
);
782 /***********************************************************************
783 * RunningObjectTable_NoteChangeTime
786 * dwRegister [in] Value identifying registration being updated
787 * pfiletime [in] Pointer to structure containing object's last change time
789 static HRESULT WINAPI
790 RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable
* iface
,
791 DWORD dwRegister
, FILETIME
*pfiletime
)
793 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
794 struct rot_entry
*rot_entry
;
795 HRESULT hr
= E_INVALIDARG
;
797 TRACE("(%p,%d,%p)\n",This
,dwRegister
,pfiletime
);
799 EnterCriticalSection(&This
->lock
);
800 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
802 if (rot_entry
->cookie
== dwRegister
)
804 rot_entry
->last_modified
= *pfiletime
;
805 LeaveCriticalSection(&This
->lock
);
811 hr
= IrotNoteChangeTime(get_irot_handle(), dwRegister
, pfiletime
);
815 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
818 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
829 LeaveCriticalSection(&This
->lock
);
832 TRACE("-- 0x08%x\n", hr
);
836 /***********************************************************************
837 * RunningObjectTable_GetTimeOfLastChange
840 * pmkObjectName [in] moniker of the object whose status is desired
841 * pfiletime [out] structure that receives object's last change time
843 static HRESULT WINAPI
844 RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable
* iface
,
845 IMoniker
*pmkObjectName
, FILETIME
*pfiletime
)
847 HRESULT hr
= MK_E_UNAVAILABLE
;
848 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
849 MonikerComparisonData
*moniker_data
;
850 const struct rot_entry
*rot_entry
;
852 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,pfiletime
);
854 if (pmkObjectName
==NULL
|| pfiletime
==NULL
)
857 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
860 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
861 IMoniker_Release(pmkObjectName
);
865 hr
= MK_E_UNAVAILABLE
;
867 EnterCriticalSection(&This
->lock
);
868 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
870 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
871 !memcmp(&moniker_data
->abData
, &rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
873 *pfiletime
= rot_entry
->last_modified
;
878 LeaveCriticalSection(&This
->lock
);
886 hr
= IrotGetTimeOfLastChange(get_irot_handle(), moniker_data
, pfiletime
);
890 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
893 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
902 HeapFree(GetProcessHeap(), 0, moniker_data
);
904 TRACE("-- 0x%08x\n", hr
);
908 /***********************************************************************
909 * RunningObjectTable_EnumRunning
912 * ppenumMoniker [out] receives the IEnumMoniker interface pointer
914 static HRESULT WINAPI
915 RunningObjectTableImpl_EnumRunning(IRunningObjectTable
* iface
,
916 IEnumMoniker
**ppenumMoniker
)
918 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
919 InterfaceList
*interface_list
= NULL
;
922 TRACE("(%p, %p)\n", This
, ppenumMoniker
);
924 *ppenumMoniker
= NULL
;
930 hr
= IrotEnumRunning(get_irot_handle(), &interface_list
);
934 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
937 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
946 hr
= EnumMonikerImpl_CreateEnumROTMoniker(interface_list
,
952 /* Virtual function table for the IRunningObjectTable class. */
953 static const IRunningObjectTableVtbl VT_RunningObjectTableImpl
=
955 RunningObjectTableImpl_QueryInterface
,
956 RunningObjectTableImpl_AddRef
,
957 RunningObjectTableImpl_Release
,
958 RunningObjectTableImpl_Register
,
959 RunningObjectTableImpl_Revoke
,
960 RunningObjectTableImpl_IsRunning
,
961 RunningObjectTableImpl_GetObject
,
962 RunningObjectTableImpl_NoteChangeTime
,
963 RunningObjectTableImpl_GetTimeOfLastChange
,
964 RunningObjectTableImpl_EnumRunning
967 /***********************************************************************
968 * RunningObjectTable_Initialize
970 HRESULT WINAPI
RunningObjectTableImpl_Initialize(void)
974 /* create the unique instance of the RunningObjectTableImpl structure */
975 runningObjectTableInstance
= HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl
));
977 if (!runningObjectTableInstance
)
978 return E_OUTOFMEMORY
;
980 /* initialize the virtual table function */
981 runningObjectTableInstance
->lpVtbl
= &VT_RunningObjectTableImpl
;
983 /* the initial reference is set to "1" ! because if set to "0" it will be not practis when */
984 /* the ROT referred many times not in the same time (all the objects in the ROT will */
985 /* be removed every time the ROT is removed ) */
986 runningObjectTableInstance
->ref
= 1;
988 list_init(&runningObjectTableInstance
->rot
);
989 InitializeCriticalSection(&runningObjectTableInstance
->lock
);
990 DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance
->lock
, "RunningObjectTableImpl.lock");
995 /***********************************************************************
996 * RunningObjectTable_UnInitialize
998 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize(void)
1002 if (runningObjectTableInstance
==NULL
)
1005 RunningObjectTableImpl_Release((IRunningObjectTable
*)runningObjectTableInstance
);
1007 RunningObjectTableImpl_Destroy();
1012 /***********************************************************************
1013 * GetRunningObjectTable (OLE32.@)
1015 * Retrieves the global running object table.
1018 * reserved [I] Reserved. Set to 0.
1019 * pprot [O] Address that receives the pointer to the running object table.
1023 * Failure: Any HRESULT code.
1026 GetRunningObjectTable(DWORD reserved
, LPRUNNINGOBJECTTABLE
*pprot
)
1028 IID riid
=IID_IRunningObjectTable
;
1034 return E_UNEXPECTED
;
1036 if(runningObjectTableInstance
==NULL
)
1037 return CO_E_NOTINITIALIZED
;
1039 res
= IRunningObjectTable_QueryInterface((IRunningObjectTable
*)runningObjectTableInstance
,&riid
,(void**)pprot
);
1044 static HRESULT
get_moniker_for_progid_display_name(LPBC pbc
,
1045 LPCOLESTR szDisplayName
,
1052 LPCWSTR start
= szDisplayName
;
1055 IMoniker
*class_moniker
;
1060 /* find end delimiter */
1061 for (end
= start
; *end
; end
++)
1067 /* must start with '@' or have a ':' somewhere and mustn't be one character
1068 * long (since that looks like an absolute path) */
1069 if (((start
== szDisplayName
) && (*end
== '\0')) || (len
<= 1))
1072 progid
= HeapAlloc(GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
));
1075 memcpy(progid
, start
, len
* sizeof(WCHAR
));
1078 hr
= CLSIDFromProgID(progid
, &clsid
);
1079 HeapFree(GetProcessHeap(), 0, progid
);
1083 hr
= CreateClassMoniker(&clsid
, &class_moniker
);
1086 IParseDisplayName
*pdn
;
1087 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1088 &IID_IParseDisplayName
, (void **)&pdn
);
1089 /* fallback to using IClassFactory to get IParseDisplayName -
1090 * adsldp.dll depends on this */
1094 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1095 &IID_IClassFactory
, (void **)&pcf
);
1098 hr
= IClassFactory_CreateInstance(pcf
, NULL
,
1099 &IID_IParseDisplayName
,
1101 IClassFactory_Release(pcf
);
1104 IMoniker_Release(class_moniker
);
1107 hr
= IParseDisplayName_ParseDisplayName(pdn
, pbc
,
1108 (LPOLESTR
)szDisplayName
,
1110 IParseDisplayName_Release(pdn
);
1116 /******************************************************************************
1117 * MkParseDisplayName [OLE32.@]
1119 HRESULT WINAPI
MkParseDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
,
1120 LPDWORD pchEaten
, LPMONIKER
*ppmk
)
1122 HRESULT hr
= MK_E_SYNTAX
;
1123 static const WCHAR wszClsidColon
[] = {'c','l','s','i','d',':'};
1127 TRACE("(%p, %s, %p, %p)\n", pbc
, debugstr_w(szDisplayName
), pchEaten
, ppmk
);
1129 if (!(IsValidInterface((LPUNKNOWN
) pbc
)))
1130 return E_INVALIDARG
;
1135 if (!strncmpiW(szDisplayName
, wszClsidColon
, sizeof(wszClsidColon
)/sizeof(wszClsidColon
[0])))
1137 hr
= ClassMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1138 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1143 hr
= get_moniker_for_progid_display_name(pbc
, szDisplayName
, &chEaten
, &moniker
);
1144 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1150 hr
= FileMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1151 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1159 IMoniker
*next_moniker
;
1160 *pchEaten
+= chEaten
;
1161 szDisplayName
+= chEaten
;
1162 if (!*szDisplayName
)
1168 hr
= IMoniker_ParseDisplayName(moniker
, pbc
, NULL
,
1169 (LPOLESTR
)szDisplayName
, &chEaten
,
1171 IMoniker_Release(moniker
);
1177 moniker
= next_moniker
;
1184 /***********************************************************************
1185 * GetClassFile (OLE32.@)
1187 * Retrieves the class ID associated with the given filename.
1190 * filePathName [I] Filename to retrieve the class ID for.
1191 * pclsid [O] Address that receives the class ID for the file.
1195 * Failure: Any HRESULT code.
1197 HRESULT WINAPI
GetClassFile(LPCOLESTR filePathName
,CLSID
*pclsid
)
1201 int nbElm
, length
, i
;
1203 LPOLESTR
*pathDec
=0,absFile
=0,progId
=0;
1205 static const WCHAR bkslashW
[] = {'\\',0};
1206 static const WCHAR dotW
[] = {'.',0};
1208 TRACE("%s, %p\n", debugstr_w(filePathName
), pclsid
);
1210 /* if the file contain a storage object the return the CLSID written by IStorage_SetClass method*/
1211 if((StgIsStorageFile(filePathName
))==S_OK
){
1213 res
=StgOpenStorage(filePathName
,NULL
,STGM_READ
| STGM_SHARE_DENY_WRITE
,NULL
,0,&pstg
);
1216 res
=ReadClassStg(pstg
,pclsid
);
1218 IStorage_Release(pstg
);
1222 /* if the file is not a storage object then attemps to match various bits in the file against a
1223 pattern in the registry. this case is not frequently used ! so I present only the psodocode for
1226 for(i=0;i<nFileTypes;i++)
1228 for(i=0;j<nPatternsForType;j++){
1233 pat=ReadPatternFromRegistry(i,j);
1234 hFile=CreateFileW(filePathName,,,,,,hFile);
1235 SetFilePosition(hFile,pat.offset);
1236 ReadFile(hFile,buf,pat.size,&r,NULL);
1237 if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
1239 *pclsid=ReadCLSIDFromRegistry(i);
1245 /* if the above strategies fail then search for the extension key in the registry */
1247 /* get the last element (absolute file) in the path name */
1248 nbElm
=FileMonikerImpl_DecomposePath(filePathName
,&pathDec
);
1249 absFile
=pathDec
[nbElm
-1];
1251 /* failed if the path represente a directory and not an absolute file name*/
1252 if (!lstrcmpW(absFile
, bkslashW
))
1253 return MK_E_INVALIDEXTENSION
;
1255 /* get the extension of the file */
1257 length
=lstrlenW(absFile
);
1258 for(i
= length
-1; (i
>= 0) && *(extension
= &absFile
[i
]) != '.'; i
--)
1261 if (!extension
|| !lstrcmpW(extension
, dotW
))
1262 return MK_E_INVALIDEXTENSION
;
1264 res
=RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, NULL
, &sizeProgId
);
1266 /* get the progId associated to the extension */
1267 progId
= CoTaskMemAlloc(sizeProgId
);
1268 res
= RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, progId
, &sizeProgId
);
1270 if (res
==ERROR_SUCCESS
)
1271 /* return the clsid associated to the progId */
1272 res
= CLSIDFromProgID(progId
,pclsid
);
1274 for(i
=0; pathDec
[i
]!=NULL
;i
++)
1275 CoTaskMemFree(pathDec
[i
]);
1276 CoTaskMemFree(pathDec
);
1278 CoTaskMemFree(progId
);
1280 if (res
==ERROR_SUCCESS
)
1283 return MK_E_INVALIDEXTENSION
;
1286 /***********************************************************************
1287 * EnumMoniker_QueryInterface
1289 static HRESULT WINAPI
EnumMonikerImpl_QueryInterface(IEnumMoniker
* iface
,REFIID riid
,void** ppvObject
)
1291 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1293 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
1295 /* validate arguments */
1296 if (ppvObject
== NULL
)
1297 return E_INVALIDARG
;
1301 if (IsEqualIID(&IID_IUnknown
, riid
))
1302 *ppvObject
= (IEnumMoniker
*)This
;
1304 if (IsEqualIID(&IID_IEnumMoniker
, riid
))
1305 *ppvObject
= (IEnumMoniker
*)This
;
1307 if ((*ppvObject
)==NULL
)
1308 return E_NOINTERFACE
;
1310 IEnumMoniker_AddRef(iface
);
1315 /***********************************************************************
1316 * EnumMoniker_AddRef
1318 static ULONG WINAPI
EnumMonikerImpl_AddRef(IEnumMoniker
* iface
)
1320 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1322 TRACE("(%p)\n",This
);
1324 return InterlockedIncrement(&This
->ref
);
1327 /***********************************************************************
1328 * EnumMoniker_release
1330 static ULONG WINAPI
EnumMonikerImpl_Release(IEnumMoniker
* iface
)
1332 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1335 TRACE("(%p)\n",This
);
1337 ref
= InterlockedDecrement(&This
->ref
);
1339 /* uninitialize rot structure if there's no more reference to it*/
1344 TRACE("(%p) Deleting\n",This
);
1346 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1347 HeapFree(GetProcessHeap(), 0, This
->moniker_list
->interfaces
[i
]);
1348 HeapFree(GetProcessHeap(), 0, This
->moniker_list
);
1349 HeapFree(GetProcessHeap(), 0, This
);
1354 /***********************************************************************
1357 static HRESULT WINAPI
EnumMonikerImpl_Next(IEnumMoniker
* iface
, ULONG celt
, IMoniker
** rgelt
, ULONG
* pceltFetched
)
1360 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1363 TRACE("(%p) TabCurrentPos %d Tablastindx %d\n", This
, This
->pos
, This
->moniker_list
->size
);
1365 /* retrieve the requested number of moniker from the current position */
1366 for(i
= 0; (This
->pos
< This
->moniker_list
->size
) && (i
< celt
); i
++)
1369 hr
= create_stream_on_mip_ro(This
->moniker_list
->interfaces
[This
->pos
++], &stream
);
1370 if (hr
!= S_OK
) break;
1371 hr
= CoUnmarshalInterface(stream
, &IID_IMoniker
, (void **)&rgelt
[i
]);
1372 IStream_Release(stream
);
1373 if (hr
!= S_OK
) break;
1376 if (pceltFetched
!= NULL
)
1389 /***********************************************************************
1392 static HRESULT WINAPI
EnumMonikerImpl_Skip(IEnumMoniker
* iface
, ULONG celt
)
1394 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1396 TRACE("(%p)\n",This
);
1398 if (This
->pos
+ celt
>= This
->moniker_list
->size
)
1406 /***********************************************************************
1407 * EnmumMoniker_Reset
1409 static HRESULT WINAPI
EnumMonikerImpl_Reset(IEnumMoniker
* iface
)
1411 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1413 This
->pos
= 0; /* set back to start of list */
1415 TRACE("(%p)\n",This
);
1420 /***********************************************************************
1421 * EnmumMoniker_Clone
1423 static HRESULT WINAPI
EnumMonikerImpl_Clone(IEnumMoniker
* iface
, IEnumMoniker
** ppenum
)
1425 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1426 InterfaceList
*moniker_list
;
1429 TRACE("(%p)\n",This
);
1433 moniker_list
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceList
, interfaces
[This
->moniker_list
->size
]));
1435 return E_OUTOFMEMORY
;
1437 moniker_list
->size
= This
->moniker_list
->size
;
1438 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1440 SIZE_T size
= FIELD_OFFSET(InterfaceData
, abData
[This
->moniker_list
->interfaces
[i
]->ulCntData
]);
1441 moniker_list
->interfaces
[i
] = HeapAlloc(GetProcessHeap(), 0, size
);
1442 if (!moniker_list
->interfaces
[i
])
1445 for (i
= 0; i
< end
; i
++)
1446 HeapFree(GetProcessHeap(), 0, moniker_list
->interfaces
[i
]);
1447 HeapFree(GetProcessHeap(), 0, moniker_list
);
1448 return E_OUTOFMEMORY
;
1450 memcpy(moniker_list
->interfaces
[i
], This
->moniker_list
->interfaces
[i
], size
);
1453 /* copy the enum structure */
1454 return EnumMonikerImpl_CreateEnumROTMoniker(moniker_list
, This
->pos
, ppenum
);
1457 /* Virtual function table for the IEnumMoniker class. */
1458 static const IEnumMonikerVtbl VT_EnumMonikerImpl
=
1460 EnumMonikerImpl_QueryInterface
,
1461 EnumMonikerImpl_AddRef
,
1462 EnumMonikerImpl_Release
,
1463 EnumMonikerImpl_Next
,
1464 EnumMonikerImpl_Skip
,
1465 EnumMonikerImpl_Reset
,
1466 EnumMonikerImpl_Clone
1469 /***********************************************************************
1470 * EnumMonikerImpl_CreateEnumROTMoniker
1471 * Used by EnumRunning to create the structure and EnumClone
1472 * to copy the structure
1474 static HRESULT WINAPI
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
1476 IEnumMoniker
**ppenumMoniker
)
1478 EnumMonikerImpl
* This
= NULL
;
1481 return E_INVALIDARG
;
1483 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl
));
1484 if (!This
) return E_OUTOFMEMORY
;
1486 TRACE("(%p)\n", This
);
1488 /* initialize the virtual table function */
1489 This
->lpVtbl
= &VT_EnumMonikerImpl
;
1491 /* the initial reference is set to "1" */
1492 This
->ref
= 1; /* set the ref count to one */
1493 This
->pos
= current_pos
; /* Set the list start posn */
1494 This
->moniker_list
= moniker_list
;
1496 *ppenumMoniker
= (IEnumMoniker
*)This
;
1502 /* Shared implementation of moniker marshaler based on saving and loading of
1505 typedef struct MonikerMarshal
1507 const IUnknownVtbl
*lpVtbl
;
1508 const IMarshalVtbl
*lpVtblMarshal
;
1514 static inline MonikerMarshal
*impl_from_IMarshal( IMarshal
*iface
)
1516 return (MonikerMarshal
*)((char*)iface
- FIELD_OFFSET(MonikerMarshal
, lpVtblMarshal
));
1519 static HRESULT WINAPI
MonikerMarshalInner_QueryInterface(IUnknown
*iface
, REFIID riid
, LPVOID
*ppv
)
1521 MonikerMarshal
*This
= (MonikerMarshal
*)iface
;
1522 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
1524 if (IsEqualIID(&IID_IUnknown
, riid
) || IsEqualIID(&IID_IMarshal
, riid
))
1526 *ppv
= &This
->lpVtblMarshal
;
1527 IUnknown_AddRef((IUnknown
*)&This
->lpVtblMarshal
);
1530 FIXME("No interface for %s\n", debugstr_guid(riid
));
1531 return E_NOINTERFACE
;
1534 static ULONG WINAPI
MonikerMarshalInner_AddRef(IUnknown
*iface
)
1536 MonikerMarshal
*This
= (MonikerMarshal
*)iface
;
1537 return InterlockedIncrement(&This
->ref
);
1540 static ULONG WINAPI
MonikerMarshalInner_Release(IUnknown
*iface
)
1542 MonikerMarshal
*This
= (MonikerMarshal
*)iface
;
1543 ULONG ref
= InterlockedDecrement(&This
->ref
);
1545 if (!ref
) HeapFree(GetProcessHeap(), 0, This
);
1549 static const IUnknownVtbl VT_MonikerMarshalInner
=
1551 MonikerMarshalInner_QueryInterface
,
1552 MonikerMarshalInner_AddRef
,
1553 MonikerMarshalInner_Release
1556 static HRESULT WINAPI
MonikerMarshal_QueryInterface(IMarshal
*iface
, REFIID riid
, LPVOID
*ppv
)
1558 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1559 return IMoniker_QueryInterface(This
->moniker
, riid
, ppv
);
1562 static ULONG WINAPI
MonikerMarshal_AddRef(IMarshal
*iface
)
1564 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1565 return IMoniker_AddRef(This
->moniker
);
1568 static ULONG WINAPI
MonikerMarshal_Release(IMarshal
*iface
)
1570 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1571 return IMoniker_Release(This
->moniker
);
1574 static HRESULT WINAPI
MonikerMarshal_GetUnmarshalClass(
1575 LPMARSHAL iface
, REFIID riid
, void* pv
, DWORD dwDestContext
,
1576 void* pvDestContext
, DWORD mshlflags
, CLSID
* pCid
)
1578 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1580 TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid
), pv
,
1581 dwDestContext
, pvDestContext
, mshlflags
, pCid
);
1583 return IMoniker_GetClassID(This
->moniker
, pCid
);
1586 static HRESULT WINAPI
MonikerMarshal_GetMarshalSizeMax(
1587 LPMARSHAL iface
, REFIID riid
, void* pv
, DWORD dwDestContext
,
1588 void* pvDestContext
, DWORD mshlflags
, DWORD
* pSize
)
1590 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1592 ULARGE_INTEGER size
;
1594 TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid
), pv
,
1595 dwDestContext
, pvDestContext
, mshlflags
, pSize
);
1597 hr
= IMoniker_GetSizeMax(This
->moniker
, &size
);
1599 *pSize
= (DWORD
)size
.QuadPart
;
1603 static HRESULT WINAPI
MonikerMarshal_MarshalInterface(LPMARSHAL iface
, IStream
*pStm
,
1604 REFIID riid
, void* pv
, DWORD dwDestContext
,
1605 void* pvDestContext
, DWORD mshlflags
)
1607 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1609 TRACE("(%p, %s, %p, %x, %p, %x)\n", pStm
, debugstr_guid(riid
), pv
,
1610 dwDestContext
, pvDestContext
, mshlflags
);
1612 return IMoniker_Save(This
->moniker
, pStm
, FALSE
);
1615 static HRESULT WINAPI
MonikerMarshal_UnmarshalInterface(LPMARSHAL iface
, IStream
*pStm
, REFIID riid
, void **ppv
)
1617 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1620 TRACE("(%p, %s, %p)\n", pStm
, debugstr_guid(riid
), ppv
);
1622 hr
= IMoniker_Load(This
->moniker
, pStm
);
1624 hr
= IMoniker_QueryInterface(This
->moniker
, riid
, ppv
);
1628 static HRESULT WINAPI
MonikerMarshal_ReleaseMarshalData(LPMARSHAL iface
, IStream
*pStm
)
1631 /* can't release a state-based marshal as nothing on server side to
1636 static HRESULT WINAPI
MonikerMarshal_DisconnectObject(LPMARSHAL iface
, DWORD dwReserved
)
1639 /* can't disconnect a state-based marshal as nothing on server side to
1640 * disconnect from */
1644 static const IMarshalVtbl VT_MonikerMarshal
=
1646 MonikerMarshal_QueryInterface
,
1647 MonikerMarshal_AddRef
,
1648 MonikerMarshal_Release
,
1649 MonikerMarshal_GetUnmarshalClass
,
1650 MonikerMarshal_GetMarshalSizeMax
,
1651 MonikerMarshal_MarshalInterface
,
1652 MonikerMarshal_UnmarshalInterface
,
1653 MonikerMarshal_ReleaseMarshalData
,
1654 MonikerMarshal_DisconnectObject
1657 HRESULT
MonikerMarshal_Create(IMoniker
*inner
, IUnknown
**outer
)
1659 MonikerMarshal
*This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1660 if (!This
) return E_OUTOFMEMORY
;
1662 This
->lpVtbl
= &VT_MonikerMarshalInner
;
1663 This
->lpVtblMarshal
= &VT_MonikerMarshal
;
1665 This
->moniker
= inner
;
1667 *outer
= (IUnknown
*)&This
->lpVtbl
;
1671 void * __RPC_USER
MIDL_user_allocate(size_t size
)
1673 return HeapAlloc(GetProcessHeap(), 0, size
);
1676 void __RPC_USER
MIDL_user_free(void *p
)
1678 HeapFree(GetProcessHeap(), 0, p
);