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
25 #include "wine/port.h"
39 #include "wine/list.h"
40 #include "wine/debug.h"
41 #include "wine/unicode.h"
42 #include "wine/exception.h"
44 #include "compobj_private.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
50 /* see MSDN docs for IROTData::GetComparisonData, which states what this
53 #define MAX_COMPARISON_DATA 2048
55 static LONG WINAPI
rpc_filter(EXCEPTION_POINTERS
*eptr
)
57 return I_RpcExceptionFilter(eptr
->ExceptionRecord
->ExceptionCode
);
60 /* define the structure of the running object table elements */
64 InterfaceData
* object
; /* marshaled running object*/
65 MonikerComparisonData
* moniker_data
; /* moniker comparison data that identifies this object */
66 DWORD cookie
; /* cookie identifying this object */
67 FILETIME last_modified
;
68 IrotContextHandle ctxt_handle
;
71 /* define the RunningObjectTableImpl structure */
72 typedef struct RunningObjectTableImpl
74 IRunningObjectTable IRunningObjectTable_iface
;
77 struct list rot
; /* list of ROT entries */
78 CRITICAL_SECTION lock
;
79 } RunningObjectTableImpl
;
81 static RunningObjectTableImpl
* runningObjectTableInstance
= NULL
;
82 static IrotHandle irot_handle
;
84 /* define the EnumMonikerImpl structure */
85 typedef struct EnumMonikerImpl
87 IEnumMoniker IEnumMoniker_iface
;
90 InterfaceList
*moniker_list
;
94 static inline RunningObjectTableImpl
*impl_from_IRunningObjectTable(IRunningObjectTable
*iface
)
96 return CONTAINING_RECORD(iface
, RunningObjectTableImpl
, IRunningObjectTable_iface
);
99 static inline EnumMonikerImpl
*impl_from_IEnumMoniker(IEnumMoniker
*iface
)
101 return CONTAINING_RECORD(iface
, EnumMonikerImpl
, IEnumMoniker_iface
);
104 /* IEnumMoniker Local functions*/
105 static HRESULT
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
106 ULONG pos
, IEnumMoniker
**ppenumMoniker
);
108 static IrotHandle
get_irot_handle(void)
114 IrotHandle new_handle
;
115 unsigned short ncacn_np
[] = IROT_PROTSEQ
;
116 unsigned short endpoint
[] = IROT_ENDPOINT
;
117 status
= RpcStringBindingComposeW(NULL
, ncacn_np
, NULL
, endpoint
, NULL
, &binding
);
118 if (status
== RPC_S_OK
)
120 status
= RpcBindingFromStringBindingW(binding
, &new_handle
);
121 RpcStringFreeW(&binding
);
123 if (status
!= RPC_S_OK
)
125 if (InterlockedCompareExchangePointer(&irot_handle
, new_handle
, NULL
))
126 /* another thread beat us to it */
127 RpcBindingFree(&new_handle
);
132 static BOOL
start_rpcss(void)
134 PROCESS_INFORMATION pi
;
137 static const WCHAR rpcss
[] = {'\\','r','p','c','s','s','.','e','x','e',0};
143 ZeroMemory(&si
, sizeof(STARTUPINFOA
));
144 si
.cb
= sizeof(STARTUPINFOA
);
145 GetSystemDirectoryW( cmd
, MAX_PATH
- sizeof(rpcss
)/sizeof(WCHAR
) );
146 strcatW( cmd
, rpcss
);
148 Wow64DisableWow64FsRedirection( &redir
);
149 rslt
= CreateProcessW( cmd
, cmd
, NULL
, NULL
, FALSE
, DETACHED_PROCESS
, NULL
, NULL
, &si
, &pi
);
150 Wow64RevertWow64FsRedirection( redir
);
154 CloseHandle(pi
.hProcess
);
155 CloseHandle(pi
.hThread
);
162 static HRESULT
create_stream_on_mip_ro(const InterfaceData
*mip
, IStream
**stream
)
164 HGLOBAL hglobal
= GlobalAlloc(0, mip
->ulCntData
);
165 void *pv
= GlobalLock(hglobal
);
166 memcpy(pv
, mip
->abData
, mip
->ulCntData
);
167 GlobalUnlock(hglobal
);
168 return CreateStreamOnHGlobal(hglobal
, TRUE
, stream
);
171 static void rot_entry_delete(struct rot_entry
*rot_entry
)
173 if (rot_entry
->cookie
)
175 InterfaceData
*object
= NULL
;
176 InterfaceData
*moniker
= NULL
;
179 IrotRevoke(get_irot_handle(), rot_entry
->cookie
,
180 &rot_entry
->ctxt_handle
, &object
, &moniker
);
186 MIDL_user_free(object
);
191 hr
= create_stream_on_mip_ro(moniker
, &stream
);
194 CoReleaseMarshalData(stream
);
195 IStream_Release(stream
);
198 MIDL_user_free(moniker
);
200 if (rot_entry
->object
)
204 hr
= create_stream_on_mip_ro(rot_entry
->object
, &stream
);
207 CoReleaseMarshalData(stream
);
208 IStream_Release(stream
);
211 HeapFree(GetProcessHeap(), 0, rot_entry
->object
);
212 HeapFree(GetProcessHeap(), 0, rot_entry
->moniker_data
);
213 HeapFree(GetProcessHeap(), 0, rot_entry
);
216 /* moniker_data must be freed with HeapFree when no longer in use */
217 static HRESULT
get_moniker_comparison_data(IMoniker
*pMoniker
, MonikerComparisonData
**moniker_data
)
220 IROTData
*pROTData
= NULL
;
221 hr
= IMoniker_QueryInterface(pMoniker
, &IID_IROTData
, (void *)&pROTData
);
224 ULONG size
= MAX_COMPARISON_DATA
;
225 *moniker_data
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MonikerComparisonData
, abData
[size
]));
228 IROTData_Release(pROTData
);
229 return E_OUTOFMEMORY
;
231 hr
= IROTData_GetComparisonData(pROTData
, (*moniker_data
)->abData
, size
, &size
);
232 IROTData_Release(pROTData
);
235 ERR("Failed to copy comparison data into buffer, hr = 0x%08x\n", hr
);
236 HeapFree(GetProcessHeap(), 0, *moniker_data
);
239 (*moniker_data
)->ulCntData
= size
;
244 LPOLESTR pszDisplayName
;
248 TRACE("generating comparison data from display name\n");
250 hr
= CreateBindCtx(0, &pbc
);
253 hr
= IMoniker_GetDisplayName(pMoniker
, pbc
, NULL
, &pszDisplayName
);
254 IBindCtx_Release(pbc
);
257 hr
= IMoniker_GetClassID(pMoniker
, &clsid
);
260 CoTaskMemFree(pszDisplayName
);
264 len
= strlenW(pszDisplayName
);
265 *moniker_data
= HeapAlloc(GetProcessHeap(), 0,
266 FIELD_OFFSET(MonikerComparisonData
, abData
[sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
)]));
269 CoTaskMemFree(pszDisplayName
);
270 return E_OUTOFMEMORY
;
272 (*moniker_data
)->ulCntData
= sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
);
274 memcpy(&(*moniker_data
)->abData
[0], &clsid
, sizeof(clsid
));
275 memcpy(&(*moniker_data
)->abData
[sizeof(clsid
)], pszDisplayName
, (len
+1)*sizeof(WCHAR
));
276 CoTaskMemFree(pszDisplayName
);
281 static HRESULT
reduce_moniker(IMoniker
*pmk
, IBindCtx
*pbc
, IMoniker
**pmkReduced
)
283 IBindCtx
*pbcNew
= NULL
;
287 hr
= CreateBindCtx(0, &pbcNew
);
292 hr
= IMoniker_Reduce(pmk
, pbc
, MKRREDUCE_ALL
, NULL
, pmkReduced
);
294 ERR("reducing moniker failed with error 0x%08x\n", hr
);
295 if (pbcNew
) IBindCtx_Release(pbcNew
);
299 /***********************************************************************
300 * RunningObjectTable_QueryInterface
302 static HRESULT WINAPI
303 RunningObjectTableImpl_QueryInterface(IRunningObjectTable
* iface
,
304 REFIID riid
,void** ppvObject
)
306 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
308 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
310 /* validate arguments */
317 if (IsEqualIID(&IID_IUnknown
, riid
) ||
318 IsEqualIID(&IID_IRunningObjectTable
, riid
))
319 *ppvObject
= &This
->IRunningObjectTable_iface
;
322 return E_NOINTERFACE
;
324 IRunningObjectTable_AddRef(iface
);
329 /***********************************************************************
330 * RunningObjectTable_AddRef
333 RunningObjectTableImpl_AddRef(IRunningObjectTable
* iface
)
335 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
337 TRACE("(%p)\n",This
);
339 return InterlockedIncrement(&This
->ref
);
342 /***********************************************************************
343 * RunningObjectTable_Destroy
346 RunningObjectTableImpl_Destroy(void)
348 struct list
*cursor
, *cursor2
;
349 IrotHandle old_handle
;
353 if (runningObjectTableInstance
==NULL
)
356 /* free the ROT table memory */
357 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &runningObjectTableInstance
->rot
)
359 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
360 list_remove(&rot_entry
->entry
);
361 rot_entry_delete(rot_entry
);
364 DEBUG_CLEAR_CRITSEC_NAME(&runningObjectTableInstance
->lock
);
365 DeleteCriticalSection(&runningObjectTableInstance
->lock
);
367 /* free the ROT structure memory */
368 HeapFree(GetProcessHeap(),0,runningObjectTableInstance
);
369 runningObjectTableInstance
= NULL
;
371 old_handle
= irot_handle
;
374 RpcBindingFree(&old_handle
);
379 /***********************************************************************
380 * RunningObjectTable_Release
383 RunningObjectTableImpl_Release(IRunningObjectTable
* iface
)
385 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
388 TRACE("(%p)\n",This
);
390 ref
= InterlockedDecrement(&This
->ref
);
392 /* uninitialize ROT structure if there are no more references to it */
395 struct list
*cursor
, *cursor2
;
396 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &This
->rot
)
398 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
399 list_remove(&rot_entry
->entry
);
400 rot_entry_delete(rot_entry
);
402 /* RunningObjectTable data structure will be not destroyed here ! the destruction will be done only
403 * when RunningObjectTableImpl_UnInitialize function is called
410 /***********************************************************************
411 * RunningObjectTable_Register
414 * grfFlags [in] Registration options
415 * punkObject [in] the object being registered
416 * pmkObjectName [in] the moniker of the object being registered
417 * pdwRegister [out] the value identifying the registration
419 static HRESULT WINAPI
420 RunningObjectTableImpl_Register(IRunningObjectTable
* iface
, DWORD grfFlags
,
421 IUnknown
*punkObject
, IMoniker
*pmkObjectName
, DWORD
*pdwRegister
)
423 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
424 struct rot_entry
*rot_entry
;
426 IStream
*pStream
= NULL
;
429 InterfaceData
*moniker
= NULL
;
431 TRACE("(%p,%d,%p,%p,%p)\n",This
,grfFlags
,punkObject
,pmkObjectName
,pdwRegister
);
433 if (grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
))
435 ERR("Invalid grfFlags: 0x%08x\n", grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
));
439 if (punkObject
==NULL
|| pmkObjectName
==NULL
|| pdwRegister
==NULL
)
442 rot_entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*rot_entry
));
444 return E_OUTOFMEMORY
;
447 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
450 rot_entry_delete(rot_entry
);
453 mshlflags
= (grfFlags
& ROTFLAGS_REGISTRATIONKEEPSALIVE
) ? MSHLFLAGS_TABLESTRONG
: MSHLFLAGS_TABLEWEAK
;
454 hr
= CoMarshalInterface(pStream
, &IID_IUnknown
, punkObject
, MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, mshlflags
);
455 /* FIXME: a cleaner way would be to create an IStream class that writes
456 * directly to an MInterfacePointer */
460 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
463 SIZE_T size
= GlobalSize(hglobal
);
464 const void *pv
= GlobalLock(hglobal
);
465 rot_entry
->object
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer
, abData
[size
]));
466 rot_entry
->object
->ulCntData
= size
;
467 memcpy(rot_entry
->object
->abData
, pv
, size
);
468 GlobalUnlock(hglobal
);
471 IStream_Release(pStream
);
474 rot_entry_delete(rot_entry
);
478 hr
= CreateBindCtx(0, &pbc
);
481 rot_entry_delete(rot_entry
);
485 hr
= reduce_moniker(pmkObjectName
, pbc
, &pmkObjectName
);
488 rot_entry_delete(rot_entry
);
489 IBindCtx_Release(pbc
);
493 hr
= IMoniker_GetTimeOfLastChange(pmkObjectName
, pbc
, NULL
,
494 &rot_entry
->last_modified
);
495 IBindCtx_Release(pbc
);
498 CoFileTimeNow(&rot_entry
->last_modified
);
502 hr
= get_moniker_comparison_data(pmkObjectName
,
503 &rot_entry
->moniker_data
);
506 rot_entry_delete(rot_entry
);
507 IMoniker_Release(pmkObjectName
);
511 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
514 rot_entry_delete(rot_entry
);
515 IMoniker_Release(pmkObjectName
);
518 /* marshal moniker */
519 hr
= CoMarshalInterface(pStream
, &IID_IMoniker
, (IUnknown
*)pmkObjectName
,
520 MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, MSHLFLAGS_TABLESTRONG
);
521 /* FIXME: a cleaner way would be to create an IStream class that writes
522 * directly to an MInterfacePointer */
526 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
529 SIZE_T size
= GlobalSize(hglobal
);
530 const void *pv
= GlobalLock(hglobal
);
531 moniker
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceData
, abData
[size
]));
532 moniker
->ulCntData
= size
;
533 memcpy(moniker
->abData
, pv
, size
);
534 GlobalUnlock(hglobal
);
537 IStream_Release(pStream
);
538 IMoniker_Release(pmkObjectName
);
541 HeapFree(GetProcessHeap(), 0, moniker
);
542 rot_entry_delete(rot_entry
);
551 hr
= IrotRegister(get_irot_handle(), rot_entry
->moniker_data
,
552 rot_entry
->object
, moniker
,
553 &rot_entry
->last_modified
, grfFlags
,
554 &rot_entry
->cookie
, &rot_entry
->ctxt_handle
);
558 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
561 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
568 HeapFree(GetProcessHeap(), 0, moniker
);
571 rot_entry_delete(rot_entry
);
575 /* gives a registration identifier to the registered object*/
576 *pdwRegister
= rot_entry
->cookie
;
578 EnterCriticalSection(&This
->lock
);
579 list_add_tail(&This
->rot
, &rot_entry
->entry
);
580 LeaveCriticalSection(&This
->lock
);
585 /***********************************************************************
586 * RunningObjectTable_Revoke
589 * dwRegister [in] Value identifying registration to be revoked
591 static HRESULT WINAPI
592 RunningObjectTableImpl_Revoke( IRunningObjectTable
* iface
, DWORD dwRegister
)
594 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
595 struct rot_entry
*rot_entry
;
597 TRACE("(%p,%d)\n",This
,dwRegister
);
599 EnterCriticalSection(&This
->lock
);
600 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
602 if (rot_entry
->cookie
== dwRegister
)
604 list_remove(&rot_entry
->entry
);
605 LeaveCriticalSection(&This
->lock
);
607 rot_entry_delete(rot_entry
);
611 LeaveCriticalSection(&This
->lock
);
616 /***********************************************************************
617 * RunningObjectTable_IsRunning
620 * pmkObjectName [in] moniker of the object whose status is desired
622 static HRESULT WINAPI
623 RunningObjectTableImpl_IsRunning( IRunningObjectTable
* iface
, IMoniker
*pmkObjectName
)
625 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
626 MonikerComparisonData
*moniker_data
;
628 const struct rot_entry
*rot_entry
;
630 TRACE("(%p,%p)\n",This
,pmkObjectName
);
632 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
635 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
636 IMoniker_Release(pmkObjectName
);
641 EnterCriticalSection(&This
->lock
);
642 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
644 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
645 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
651 LeaveCriticalSection(&This
->lock
);
659 hr
= IrotIsRunning(get_irot_handle(), moniker_data
);
663 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
666 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
675 HeapFree(GetProcessHeap(), 0, moniker_data
);
680 /***********************************************************************
681 * RunningObjectTable_GetObject
684 * pmkObjectName [in] Pointer to the moniker on the object
685 * ppunkObject [out] variable that receives the IUnknown interface pointer
687 static HRESULT WINAPI
688 RunningObjectTableImpl_GetObject( IRunningObjectTable
* iface
,
689 IMoniker
*pmkObjectName
, IUnknown
**ppunkObject
)
691 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
692 MonikerComparisonData
*moniker_data
;
693 InterfaceData
*object
= NULL
;
696 struct rot_entry
*rot_entry
;
698 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,ppunkObject
);
700 if (ppunkObject
== NULL
)
705 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
708 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
709 IMoniker_Release(pmkObjectName
);
713 EnterCriticalSection(&This
->lock
);
714 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
716 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
717 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
720 hr
= create_stream_on_mip_ro(rot_entry
->object
, &pStream
);
723 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
724 IStream_Release(pStream
);
727 LeaveCriticalSection(&This
->lock
);
728 HeapFree(GetProcessHeap(), 0, moniker_data
);
733 LeaveCriticalSection(&This
->lock
);
735 TRACE("moniker unavailable locally, calling SCM\n");
741 hr
= IrotGetObject(get_irot_handle(), moniker_data
, &object
, &cookie
);
745 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
748 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
759 hr
= create_stream_on_mip_ro(object
, &pStream
);
762 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
763 IStream_Release(pStream
);
767 WARN("Moniker unavailable, IrotGetObject returned 0x%08x\n", hr
);
769 HeapFree(GetProcessHeap(), 0, moniker_data
);
774 /***********************************************************************
775 * RunningObjectTable_NoteChangeTime
778 * dwRegister [in] Value identifying registration being updated
779 * pfiletime [in] Pointer to structure containing object's last change time
781 static HRESULT WINAPI
782 RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable
* iface
,
783 DWORD dwRegister
, FILETIME
*pfiletime
)
785 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
786 struct rot_entry
*rot_entry
;
787 HRESULT hr
= E_INVALIDARG
;
789 TRACE("(%p,%d,%p)\n",This
,dwRegister
,pfiletime
);
791 EnterCriticalSection(&This
->lock
);
792 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
794 if (rot_entry
->cookie
== dwRegister
)
796 rot_entry
->last_modified
= *pfiletime
;
797 LeaveCriticalSection(&This
->lock
);
803 hr
= IrotNoteChangeTime(get_irot_handle(), dwRegister
, pfiletime
);
807 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
810 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
821 LeaveCriticalSection(&This
->lock
);
824 TRACE("-- 0x08%x\n", hr
);
828 /***********************************************************************
829 * RunningObjectTable_GetTimeOfLastChange
832 * pmkObjectName [in] moniker of the object whose status is desired
833 * pfiletime [out] structure that receives object's last change time
835 static HRESULT WINAPI
836 RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable
* iface
,
837 IMoniker
*pmkObjectName
, FILETIME
*pfiletime
)
839 HRESULT hr
= MK_E_UNAVAILABLE
;
840 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
841 MonikerComparisonData
*moniker_data
;
842 const struct rot_entry
*rot_entry
;
844 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,pfiletime
);
846 if (pmkObjectName
==NULL
|| pfiletime
==NULL
)
849 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
852 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
853 IMoniker_Release(pmkObjectName
);
857 hr
= MK_E_UNAVAILABLE
;
859 EnterCriticalSection(&This
->lock
);
860 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
862 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
863 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
865 *pfiletime
= rot_entry
->last_modified
;
870 LeaveCriticalSection(&This
->lock
);
878 hr
= IrotGetTimeOfLastChange(get_irot_handle(), moniker_data
, pfiletime
);
882 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
885 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
894 HeapFree(GetProcessHeap(), 0, moniker_data
);
896 TRACE("-- 0x%08x\n", hr
);
900 /***********************************************************************
901 * RunningObjectTable_EnumRunning
904 * ppenumMoniker [out] receives the IEnumMoniker interface pointer
906 static HRESULT WINAPI
907 RunningObjectTableImpl_EnumRunning(IRunningObjectTable
* iface
,
908 IEnumMoniker
**ppenumMoniker
)
910 RunningObjectTableImpl
*This
= impl_from_IRunningObjectTable(iface
);
911 InterfaceList
*interface_list
= NULL
;
914 TRACE("(%p, %p)\n", This
, ppenumMoniker
);
916 *ppenumMoniker
= NULL
;
922 hr
= IrotEnumRunning(get_irot_handle(), &interface_list
);
926 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
929 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
938 hr
= EnumMonikerImpl_CreateEnumROTMoniker(interface_list
,
944 /* Virtual function table for the IRunningObjectTable class. */
945 static const IRunningObjectTableVtbl VT_RunningObjectTableImpl
=
947 RunningObjectTableImpl_QueryInterface
,
948 RunningObjectTableImpl_AddRef
,
949 RunningObjectTableImpl_Release
,
950 RunningObjectTableImpl_Register
,
951 RunningObjectTableImpl_Revoke
,
952 RunningObjectTableImpl_IsRunning
,
953 RunningObjectTableImpl_GetObject
,
954 RunningObjectTableImpl_NoteChangeTime
,
955 RunningObjectTableImpl_GetTimeOfLastChange
,
956 RunningObjectTableImpl_EnumRunning
959 /***********************************************************************
960 * RunningObjectTable_Initialize
962 HRESULT WINAPI
RunningObjectTableImpl_Initialize(void)
966 /* create the unique instance of the RunningObjectTableImpl structure */
967 runningObjectTableInstance
= HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl
));
969 if (!runningObjectTableInstance
)
970 return E_OUTOFMEMORY
;
972 /* initialize the virtual table function */
973 runningObjectTableInstance
->IRunningObjectTable_iface
.lpVtbl
= &VT_RunningObjectTableImpl
;
975 /* the initial reference is set to "1" so that it isn't destroyed after its
976 * first use until the process is destroyed, as the running object table is
977 * a process-wide cache of a global table */
978 runningObjectTableInstance
->ref
= 1;
980 list_init(&runningObjectTableInstance
->rot
);
981 InitializeCriticalSection(&runningObjectTableInstance
->lock
);
982 DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance
->lock
, "RunningObjectTableImpl.lock");
987 /***********************************************************************
988 * RunningObjectTable_UnInitialize
990 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize(void)
994 if (runningObjectTableInstance
==NULL
)
997 RunningObjectTableImpl_Release(&runningObjectTableInstance
->IRunningObjectTable_iface
);
999 RunningObjectTableImpl_Destroy();
1004 /***********************************************************************
1005 * GetRunningObjectTable (OLE32.@)
1007 * Retrieves the global running object table.
1010 * reserved [I] Reserved. Set to 0.
1011 * pprot [O] Address that receives the pointer to the running object table.
1015 * Failure: Any HRESULT code.
1018 GetRunningObjectTable(DWORD reserved
, LPRUNNINGOBJECTTABLE
*pprot
)
1020 IID riid
=IID_IRunningObjectTable
;
1026 return E_UNEXPECTED
;
1028 if(runningObjectTableInstance
==NULL
)
1029 return CO_E_NOTINITIALIZED
;
1031 res
= IRunningObjectTable_QueryInterface(&runningObjectTableInstance
->IRunningObjectTable_iface
,
1032 &riid
,(void**)pprot
);
1037 static HRESULT
get_moniker_for_progid_display_name(LPBC pbc
,
1038 LPCOLESTR szDisplayName
,
1045 LPCWSTR start
= szDisplayName
;
1048 IMoniker
*class_moniker
;
1053 /* find end delimiter */
1054 for (end
= start
; *end
; end
++)
1060 /* must start with '@' or have a ':' somewhere and mustn't be one character
1061 * long (since that looks like an absolute path) */
1062 if (((start
== szDisplayName
) && (*end
== '\0')) || (len
<= 1))
1065 progid
= HeapAlloc(GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
));
1068 memcpy(progid
, start
, len
* sizeof(WCHAR
));
1071 hr
= CLSIDFromProgID(progid
, &clsid
);
1072 HeapFree(GetProcessHeap(), 0, progid
);
1076 hr
= CreateClassMoniker(&clsid
, &class_moniker
);
1079 IParseDisplayName
*pdn
;
1080 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1081 &IID_IParseDisplayName
, (void **)&pdn
);
1082 /* fallback to using IClassFactory to get IParseDisplayName -
1083 * adsldp.dll depends on this */
1087 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1088 &IID_IClassFactory
, (void **)&pcf
);
1091 hr
= IClassFactory_CreateInstance(pcf
, NULL
,
1092 &IID_IParseDisplayName
,
1094 IClassFactory_Release(pcf
);
1097 IMoniker_Release(class_moniker
);
1100 hr
= IParseDisplayName_ParseDisplayName(pdn
, pbc
,
1101 (LPOLESTR
)szDisplayName
,
1103 IParseDisplayName_Release(pdn
);
1109 /******************************************************************************
1110 * MkParseDisplayName [OLE32.@]
1112 HRESULT WINAPI
MkParseDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
,
1113 LPDWORD pchEaten
, LPMONIKER
*ppmk
)
1115 HRESULT hr
= MK_E_SYNTAX
;
1116 static const WCHAR wszClsidColon
[] = {'c','l','s','i','d',':'};
1120 TRACE("(%p, %s, %p, %p)\n", pbc
, debugstr_w(szDisplayName
), pchEaten
, ppmk
);
1122 if (!pbc
|| !IsValidInterface((LPUNKNOWN
) pbc
))
1123 return E_INVALIDARG
;
1125 if (!szDisplayName
|| !*szDisplayName
)
1126 return E_INVALIDARG
;
1128 if (!pchEaten
|| !ppmk
)
1129 return E_INVALIDARG
;
1134 if (!strncmpiW(szDisplayName
, wszClsidColon
, sizeof(wszClsidColon
)/sizeof(wszClsidColon
[0])))
1136 hr
= ClassMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1137 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1142 hr
= get_moniker_for_progid_display_name(pbc
, szDisplayName
, &chEaten
, &moniker
);
1143 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1149 hr
= FileMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1150 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1158 IMoniker
*next_moniker
;
1159 *pchEaten
+= chEaten
;
1160 szDisplayName
+= chEaten
;
1161 if (!*szDisplayName
)
1167 hr
= IMoniker_ParseDisplayName(moniker
, pbc
, NULL
,
1168 (LPOLESTR
)szDisplayName
, &chEaten
,
1170 IMoniker_Release(moniker
);
1176 moniker
= next_moniker
;
1183 /***********************************************************************
1184 * GetClassFile (OLE32.@)
1186 * Retrieves the class ID associated with the given filename.
1189 * filePathName [I] Filename to retrieve the class ID for.
1190 * pclsid [O] Address that receives the class ID for the file.
1194 * Failure: Any HRESULT code.
1196 HRESULT WINAPI
GetClassFile(LPCOLESTR filePathName
,CLSID
*pclsid
)
1200 int nbElm
, length
, i
;
1201 LONG sizeProgId
, ret
;
1202 LPOLESTR
*pathDec
=0,absFile
=0,progId
=0;
1204 static const WCHAR bkslashW
[] = {'\\',0};
1205 static const WCHAR dotW
[] = {'.',0};
1207 TRACE("%s, %p\n", debugstr_w(filePathName
), pclsid
);
1209 /* if the file contain a storage object the return the CLSID written by IStorage_SetClass method*/
1210 if((StgIsStorageFile(filePathName
))==S_OK
){
1212 res
=StgOpenStorage(filePathName
,NULL
,STGM_READ
| STGM_SHARE_DENY_WRITE
,NULL
,0,&pstg
);
1214 if (SUCCEEDED(res
)) {
1215 res
=ReadClassStg(pstg
,pclsid
);
1216 IStorage_Release(pstg
);
1221 /* If the file is not a storage object then attempt to match various bits in the file against a
1222 pattern in the registry. This case is not frequently used, so I present only the pseudocode for
1225 for(i=0;i<nFileTypes;i++)
1227 for(i=0;j<nPatternsForType;j++){
1232 pat=ReadPatternFromRegistry(i,j);
1233 hFile=CreateFileW(filePathName,,,,,,hFile);
1234 SetFilePosition(hFile,pat.offset);
1235 ReadFile(hFile,buf,pat.size,&r,NULL);
1236 if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
1238 *pclsid=ReadCLSIDFromRegistry(i);
1244 /* if the above strategies fail then search for the extension key in the registry */
1246 /* get the last element (absolute file) in the path name */
1247 nbElm
=FileMonikerImpl_DecomposePath(filePathName
,&pathDec
);
1248 absFile
=pathDec
[nbElm
-1];
1250 /* failed if the path represents a directory and not an absolute file name*/
1251 if (!lstrcmpW(absFile
, bkslashW
)) {
1252 CoTaskMemFree(pathDec
);
1253 return MK_E_INVALIDEXTENSION
;
1256 /* get the extension of the file */
1258 length
=lstrlenW(absFile
);
1259 for(i
= length
-1; (i
>= 0) && *(extension
= &absFile
[i
]) != '.'; i
--)
1262 if (!extension
|| !lstrcmpW(extension
, dotW
)) {
1263 CoTaskMemFree(pathDec
);
1264 return MK_E_INVALIDEXTENSION
;
1267 ret
= RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, NULL
, &sizeProgId
);
1269 /* get the progId associated to the extension */
1270 progId
= CoTaskMemAlloc(sizeProgId
);
1271 ret
= RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, progId
, &sizeProgId
);
1273 /* return the clsid associated to the progId */
1274 res
= CLSIDFromProgID(progId
,pclsid
);
1276 res
= HRESULT_FROM_WIN32(ret
);
1278 for(i
=0; pathDec
[i
]!=NULL
;i
++)
1279 CoTaskMemFree(pathDec
[i
]);
1280 CoTaskMemFree(pathDec
);
1282 CoTaskMemFree(progId
);
1283 return res
!= S_OK
? MK_E_INVALIDEXTENSION
: res
;
1286 /***********************************************************************
1287 * EnumMoniker_QueryInterface
1289 static HRESULT WINAPI
EnumMonikerImpl_QueryInterface(IEnumMoniker
* iface
,REFIID riid
,void** ppvObject
)
1291 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(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
) || IsEqualIID(&IID_IEnumMoniker
, riid
))
1302 *ppvObject
= &This
->IEnumMoniker_iface
;
1304 return E_NOINTERFACE
;
1306 IEnumMoniker_AddRef(iface
);
1310 /***********************************************************************
1311 * EnumMoniker_AddRef
1313 static ULONG WINAPI
EnumMonikerImpl_AddRef(IEnumMoniker
* iface
)
1315 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1317 TRACE("(%p)\n",This
);
1319 return InterlockedIncrement(&This
->ref
);
1322 /***********************************************************************
1323 * EnumMoniker_release
1325 static ULONG WINAPI
EnumMonikerImpl_Release(IEnumMoniker
* iface
)
1327 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1330 TRACE("(%p)\n",This
);
1332 ref
= InterlockedDecrement(&This
->ref
);
1334 /* uninitialize ROT structure if there are no more references to it */
1339 TRACE("(%p) Deleting\n",This
);
1341 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1342 HeapFree(GetProcessHeap(), 0, This
->moniker_list
->interfaces
[i
]);
1343 HeapFree(GetProcessHeap(), 0, This
->moniker_list
);
1344 HeapFree(GetProcessHeap(), 0, This
);
1349 /***********************************************************************
1352 static HRESULT WINAPI
EnumMonikerImpl_Next(IEnumMoniker
* iface
, ULONG celt
, IMoniker
** rgelt
, ULONG
* pceltFetched
)
1355 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1358 TRACE("(%p) TabCurrentPos %d Tablastindx %d\n", This
, This
->pos
, This
->moniker_list
->size
);
1360 /* retrieve the requested number of moniker from the current position */
1361 for(i
= 0; (This
->pos
< This
->moniker_list
->size
) && (i
< celt
); i
++)
1364 hr
= create_stream_on_mip_ro(This
->moniker_list
->interfaces
[This
->pos
++], &stream
);
1365 if (hr
!= S_OK
) break;
1366 hr
= CoUnmarshalInterface(stream
, &IID_IMoniker
, (void **)&rgelt
[i
]);
1367 IStream_Release(stream
);
1368 if (hr
!= S_OK
) break;
1371 if (pceltFetched
!= NULL
)
1384 /***********************************************************************
1387 static HRESULT WINAPI
EnumMonikerImpl_Skip(IEnumMoniker
* iface
, ULONG celt
)
1389 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1391 TRACE("(%p)\n",This
);
1393 if (This
->pos
+ celt
>= This
->moniker_list
->size
)
1401 /***********************************************************************
1404 static HRESULT WINAPI
EnumMonikerImpl_Reset(IEnumMoniker
* iface
)
1406 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1408 This
->pos
= 0; /* set back to start of list */
1410 TRACE("(%p)\n",This
);
1415 /***********************************************************************
1418 static HRESULT WINAPI
EnumMonikerImpl_Clone(IEnumMoniker
* iface
, IEnumMoniker
** ppenum
)
1420 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
1421 InterfaceList
*moniker_list
;
1424 TRACE("(%p)\n",This
);
1428 moniker_list
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceList
, interfaces
[This
->moniker_list
->size
]));
1430 return E_OUTOFMEMORY
;
1432 moniker_list
->size
= This
->moniker_list
->size
;
1433 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1435 SIZE_T size
= FIELD_OFFSET(InterfaceData
, abData
[This
->moniker_list
->interfaces
[i
]->ulCntData
]);
1436 moniker_list
->interfaces
[i
] = HeapAlloc(GetProcessHeap(), 0, size
);
1437 if (!moniker_list
->interfaces
[i
])
1440 for (i
= 0; i
< end
; i
++)
1441 HeapFree(GetProcessHeap(), 0, moniker_list
->interfaces
[i
]);
1442 HeapFree(GetProcessHeap(), 0, moniker_list
);
1443 return E_OUTOFMEMORY
;
1445 memcpy(moniker_list
->interfaces
[i
], This
->moniker_list
->interfaces
[i
], size
);
1448 /* copy the enum structure */
1449 return EnumMonikerImpl_CreateEnumROTMoniker(moniker_list
, This
->pos
, ppenum
);
1452 /* Virtual function table for the IEnumMoniker class. */
1453 static const IEnumMonikerVtbl VT_EnumMonikerImpl
=
1455 EnumMonikerImpl_QueryInterface
,
1456 EnumMonikerImpl_AddRef
,
1457 EnumMonikerImpl_Release
,
1458 EnumMonikerImpl_Next
,
1459 EnumMonikerImpl_Skip
,
1460 EnumMonikerImpl_Reset
,
1461 EnumMonikerImpl_Clone
1464 /***********************************************************************
1465 * EnumMonikerImpl_CreateEnumROTMoniker
1466 * Used by EnumRunning to create the structure and EnumClone
1467 * to copy the structure
1469 static HRESULT
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
1471 IEnumMoniker
**ppenumMoniker
)
1473 EnumMonikerImpl
* This
= NULL
;
1476 return E_INVALIDARG
;
1478 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl
));
1479 if (!This
) return E_OUTOFMEMORY
;
1481 TRACE("(%p)\n", This
);
1483 /* initialize the virtual table function */
1484 This
->IEnumMoniker_iface
.lpVtbl
= &VT_EnumMonikerImpl
;
1486 /* the initial reference is set to "1" */
1487 This
->ref
= 1; /* set the ref count to one */
1488 This
->pos
= current_pos
; /* Set the list start posn */
1489 This
->moniker_list
= moniker_list
;
1491 *ppenumMoniker
= &This
->IEnumMoniker_iface
;
1497 /* Shared implementation of moniker marshaler based on saving and loading of
1500 typedef struct MonikerMarshal
1502 IUnknown IUnknown_iface
;
1503 IMarshal IMarshal_iface
;
1509 static inline MonikerMarshal
*impl_from_IUnknown(IUnknown
*iface
)
1511 return CONTAINING_RECORD(iface
, MonikerMarshal
, IUnknown_iface
);
1514 static inline MonikerMarshal
*impl_from_IMarshal( IMarshal
*iface
)
1516 return CONTAINING_RECORD(iface
, MonikerMarshal
, IMarshal_iface
);
1519 static HRESULT WINAPI
MonikerMarshalInner_QueryInterface(IUnknown
*iface
, REFIID riid
, LPVOID
*ppv
)
1521 MonikerMarshal
*This
= impl_from_IUnknown(iface
);
1522 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
1524 if (IsEqualIID(&IID_IUnknown
, riid
) || IsEqualIID(&IID_IMarshal
, riid
))
1526 *ppv
= &This
->IMarshal_iface
;
1527 IUnknown_AddRef((IUnknown
*)&This
->IMarshal_iface
);
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
= impl_from_IUnknown(iface
);
1537 return InterlockedIncrement(&This
->ref
);
1540 static ULONG WINAPI
MonikerMarshalInner_Release(IUnknown
*iface
)
1542 MonikerMarshal
*This
= impl_from_IUnknown(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
->IUnknown_iface
.lpVtbl
= &VT_MonikerMarshalInner
;
1663 This
->IMarshal_iface
.lpVtbl
= &VT_MonikerMarshal
;
1665 This
->moniker
= inner
;
1667 *outer
= &This
->IUnknown_iface
;
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
);