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 const IRunningObjectTableVtbl
*lpVtbl
;
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 const IEnumMonikerVtbl
*lpVtbl
;
90 InterfaceList
*moniker_list
;
95 /* IEnumMoniker Local functions*/
96 static HRESULT
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
97 ULONG pos
, IEnumMoniker
**ppenumMoniker
);
99 static IrotHandle
get_irot_handle(void)
105 IrotHandle new_handle
;
106 unsigned short ncacn_np
[] = IROT_PROTSEQ
;
107 unsigned short endpoint
[] = IROT_ENDPOINT
;
108 status
= RpcStringBindingComposeW(NULL
, ncacn_np
, NULL
, endpoint
, NULL
, &binding
);
109 if (status
== RPC_S_OK
)
111 status
= RpcBindingFromStringBindingW(binding
, &new_handle
);
112 RpcStringFreeW(&binding
);
114 if (status
!= RPC_S_OK
)
116 if (InterlockedCompareExchangePointer(&irot_handle
, new_handle
, NULL
))
117 /* another thread beat us to it */
118 RpcBindingFree(&new_handle
);
123 static BOOL
start_rpcss(void)
125 PROCESS_INFORMATION pi
;
128 static const WCHAR rpcss
[] = {'\\','r','p','c','s','s','.','e','x','e',0};
133 ZeroMemory(&si
, sizeof(STARTUPINFOA
));
134 si
.cb
= sizeof(STARTUPINFOA
);
135 GetSystemDirectoryW( cmd
, MAX_PATH
- sizeof(rpcss
)/sizeof(WCHAR
) );
136 strcatW( cmd
, rpcss
);
138 rslt
= CreateProcessW( cmd
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
142 CloseHandle(pi
.hProcess
);
143 CloseHandle(pi
.hThread
);
150 static HRESULT
create_stream_on_mip_ro(const InterfaceData
*mip
, IStream
**stream
)
152 HGLOBAL hglobal
= GlobalAlloc(0, mip
->ulCntData
);
153 void *pv
= GlobalLock(hglobal
);
154 memcpy(pv
, mip
->abData
, mip
->ulCntData
);
155 GlobalUnlock(hglobal
);
156 return CreateStreamOnHGlobal(hglobal
, TRUE
, stream
);
159 static inline void rot_entry_delete(struct rot_entry
*rot_entry
)
161 if (rot_entry
->cookie
)
163 InterfaceData
*object
= NULL
;
164 InterfaceData
*moniker
= NULL
;
167 IrotRevoke(get_irot_handle(), rot_entry
->cookie
,
168 &rot_entry
->ctxt_handle
, &object
, &moniker
);
174 MIDL_user_free(object
);
179 hr
= create_stream_on_mip_ro(moniker
, &stream
);
182 CoReleaseMarshalData(stream
);
183 IUnknown_Release(stream
);
186 MIDL_user_free(moniker
);
188 if (rot_entry
->object
)
192 hr
= create_stream_on_mip_ro(rot_entry
->object
, &stream
);
195 CoReleaseMarshalData(stream
);
196 IUnknown_Release(stream
);
199 HeapFree(GetProcessHeap(), 0, rot_entry
->object
);
200 HeapFree(GetProcessHeap(), 0, rot_entry
->moniker_data
);
201 HeapFree(GetProcessHeap(), 0, rot_entry
);
204 /* moniker_data must be freed with HeapFree when no longer in use */
205 static HRESULT
get_moniker_comparison_data(IMoniker
*pMoniker
, MonikerComparisonData
**moniker_data
)
208 IROTData
*pROTData
= NULL
;
209 hr
= IMoniker_QueryInterface(pMoniker
, &IID_IROTData
, (void *)&pROTData
);
212 ULONG size
= MAX_COMPARISON_DATA
;
213 *moniker_data
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MonikerComparisonData
, abData
[size
]));
216 IROTData_Release(pROTData
);
217 return E_OUTOFMEMORY
;
219 hr
= IROTData_GetComparisonData(pROTData
, (*moniker_data
)->abData
, size
, &size
);
220 IROTData_Release(pROTData
);
223 ERR("Failed to copy comparison data into buffer, hr = 0x%08x\n", hr
);
224 HeapFree(GetProcessHeap(), 0, *moniker_data
);
227 (*moniker_data
)->ulCntData
= size
;
232 LPOLESTR pszDisplayName
;
236 TRACE("generating comparison data from display name\n");
238 hr
= CreateBindCtx(0, &pbc
);
241 hr
= IMoniker_GetDisplayName(pMoniker
, pbc
, NULL
, &pszDisplayName
);
242 IBindCtx_Release(pbc
);
245 hr
= IMoniker_GetClassID(pMoniker
, &clsid
);
248 CoTaskMemFree(pszDisplayName
);
252 len
= strlenW(pszDisplayName
);
253 *moniker_data
= HeapAlloc(GetProcessHeap(), 0,
254 FIELD_OFFSET(MonikerComparisonData
, abData
[sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
)]));
257 CoTaskMemFree(pszDisplayName
);
258 return E_OUTOFMEMORY
;
260 (*moniker_data
)->ulCntData
= sizeof(CLSID
) + (len
+1)*sizeof(WCHAR
);
262 memcpy(&(*moniker_data
)->abData
[0], &clsid
, sizeof(clsid
));
263 memcpy(&(*moniker_data
)->abData
[sizeof(clsid
)], pszDisplayName
, (len
+1)*sizeof(WCHAR
));
264 CoTaskMemFree(pszDisplayName
);
269 static HRESULT
reduce_moniker(IMoniker
*pmk
, IBindCtx
*pbc
, IMoniker
**pmkReduced
)
271 IBindCtx
*pbcNew
= NULL
;
275 hr
= CreateBindCtx(0, &pbcNew
);
280 hr
= IMoniker_Reduce(pmk
, pbc
, MKRREDUCE_ALL
, NULL
, pmkReduced
);
282 ERR("reducing moniker failed with error 0x%08x\n", hr
);
283 if (pbcNew
) IBindCtx_Release(pbcNew
);
287 /***********************************************************************
288 * RunningObjectTable_QueryInterface
290 static HRESULT WINAPI
291 RunningObjectTableImpl_QueryInterface(IRunningObjectTable
* iface
,
292 REFIID riid
,void** ppvObject
)
294 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
296 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
298 /* validate arguments */
305 if (IsEqualIID(&IID_IUnknown
, riid
) ||
306 IsEqualIID(&IID_IRunningObjectTable
, riid
))
310 return E_NOINTERFACE
;
312 IRunningObjectTable_AddRef(iface
);
317 /***********************************************************************
318 * RunningObjectTable_AddRef
321 RunningObjectTableImpl_AddRef(IRunningObjectTable
* iface
)
323 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
325 TRACE("(%p)\n",This
);
327 return InterlockedIncrement(&This
->ref
);
330 /***********************************************************************
331 * RunningObjectTable_Destroy
334 RunningObjectTableImpl_Destroy(void)
336 struct list
*cursor
, *cursor2
;
337 IrotHandle old_handle
;
341 if (runningObjectTableInstance
==NULL
)
344 /* free the ROT table memory */
345 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &runningObjectTableInstance
->rot
)
347 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
348 list_remove(&rot_entry
->entry
);
349 rot_entry_delete(rot_entry
);
352 DEBUG_CLEAR_CRITSEC_NAME(&runningObjectTableInstance
->lock
);
353 DeleteCriticalSection(&runningObjectTableInstance
->lock
);
355 /* free the ROT structure memory */
356 HeapFree(GetProcessHeap(),0,runningObjectTableInstance
);
357 runningObjectTableInstance
= NULL
;
359 old_handle
= irot_handle
;
362 RpcBindingFree(&old_handle
);
367 /***********************************************************************
368 * RunningObjectTable_Release
371 RunningObjectTableImpl_Release(IRunningObjectTable
* iface
)
373 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
376 TRACE("(%p)\n",This
);
378 ref
= InterlockedDecrement(&This
->ref
);
380 /* uninitialize ROT structure if there's no more references to it */
383 struct list
*cursor
, *cursor2
;
384 LIST_FOR_EACH_SAFE(cursor
, cursor2
, &This
->rot
)
386 struct rot_entry
*rot_entry
= LIST_ENTRY(cursor
, struct rot_entry
, entry
);
387 list_remove(&rot_entry
->entry
);
388 rot_entry_delete(rot_entry
);
390 /* RunningObjectTable data structure will be not destroyed here ! the destruction will be done only
391 * when RunningObjectTableImpl_UnInitialize function is called
398 /***********************************************************************
399 * RunningObjectTable_Register
402 * grfFlags [in] Registration options
403 * punkObject [in] the object being registered
404 * pmkObjectName [in] the moniker of the object being registered
405 * pdwRegister [out] the value identifying the registration
407 static HRESULT WINAPI
408 RunningObjectTableImpl_Register(IRunningObjectTable
* iface
, DWORD grfFlags
,
409 IUnknown
*punkObject
, IMoniker
*pmkObjectName
, DWORD
*pdwRegister
)
411 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
412 struct rot_entry
*rot_entry
;
414 IStream
*pStream
= NULL
;
417 InterfaceData
*moniker
= NULL
;
419 TRACE("(%p,%d,%p,%p,%p)\n",This
,grfFlags
,punkObject
,pmkObjectName
,pdwRegister
);
421 if (grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
))
423 ERR("Invalid grfFlags: 0x%08x\n", grfFlags
& ~(ROTFLAGS_REGISTRATIONKEEPSALIVE
|ROTFLAGS_ALLOWANYCLIENT
));
427 if (punkObject
==NULL
|| pmkObjectName
==NULL
|| pdwRegister
==NULL
)
430 rot_entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*rot_entry
));
432 return E_OUTOFMEMORY
;
435 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
438 rot_entry_delete(rot_entry
);
441 mshlflags
= (grfFlags
& ROTFLAGS_REGISTRATIONKEEPSALIVE
) ? MSHLFLAGS_TABLESTRONG
: MSHLFLAGS_TABLEWEAK
;
442 hr
= CoMarshalInterface(pStream
, &IID_IUnknown
, punkObject
, MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, mshlflags
);
443 /* FIXME: a cleaner way would be to create an IStream class that writes
444 * directly to an MInterfacePointer */
448 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
451 SIZE_T size
= GlobalSize(hglobal
);
452 const void *pv
= GlobalLock(hglobal
);
453 rot_entry
->object
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MInterfacePointer
, abData
[size
]));
454 rot_entry
->object
->ulCntData
= size
;
455 memcpy(rot_entry
->object
->abData
, pv
, size
);
456 GlobalUnlock(hglobal
);
459 IStream_Release(pStream
);
462 rot_entry_delete(rot_entry
);
466 hr
= CreateBindCtx(0, &pbc
);
469 rot_entry_delete(rot_entry
);
473 hr
= reduce_moniker(pmkObjectName
, pbc
, &pmkObjectName
);
476 rot_entry_delete(rot_entry
);
477 IBindCtx_Release(pbc
);
481 hr
= IMoniker_GetTimeOfLastChange(pmkObjectName
, pbc
, NULL
,
482 &rot_entry
->last_modified
);
483 IBindCtx_Release(pbc
);
486 CoFileTimeNow(&rot_entry
->last_modified
);
490 hr
= get_moniker_comparison_data(pmkObjectName
,
491 &rot_entry
->moniker_data
);
494 rot_entry_delete(rot_entry
);
495 IMoniker_Release(pmkObjectName
);
499 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &pStream
);
502 rot_entry_delete(rot_entry
);
503 IMoniker_Release(pmkObjectName
);
506 /* marshal moniker */
507 hr
= CoMarshalInterface(pStream
, &IID_IMoniker
, (IUnknown
*)pmkObjectName
,
508 MSHCTX_LOCAL
| MSHCTX_NOSHAREDMEM
, NULL
, MSHLFLAGS_TABLESTRONG
);
509 /* FIXME: a cleaner way would be to create an IStream class that writes
510 * directly to an MInterfacePointer */
514 hr
= GetHGlobalFromStream(pStream
, &hglobal
);
517 SIZE_T size
= GlobalSize(hglobal
);
518 const void *pv
= GlobalLock(hglobal
);
519 moniker
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceData
, abData
[size
]));
520 moniker
->ulCntData
= size
;
521 memcpy(moniker
->abData
, pv
, size
);
522 GlobalUnlock(hglobal
);
525 IStream_Release(pStream
);
526 IMoniker_Release(pmkObjectName
);
529 HeapFree(GetProcessHeap(), 0, moniker
);
530 rot_entry_delete(rot_entry
);
539 hr
= IrotRegister(get_irot_handle(), rot_entry
->moniker_data
,
540 rot_entry
->object
, moniker
,
541 &rot_entry
->last_modified
, grfFlags
,
542 &rot_entry
->cookie
, &rot_entry
->ctxt_handle
);
546 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
549 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
556 HeapFree(GetProcessHeap(), 0, moniker
);
559 rot_entry_delete(rot_entry
);
563 /* gives a registration identifier to the registered object*/
564 *pdwRegister
= rot_entry
->cookie
;
566 EnterCriticalSection(&This
->lock
);
567 list_add_tail(&This
->rot
, &rot_entry
->entry
);
568 LeaveCriticalSection(&This
->lock
);
573 /***********************************************************************
574 * RunningObjectTable_Revoke
577 * dwRegister [in] Value identifying registration to be revoked
579 static HRESULT WINAPI
580 RunningObjectTableImpl_Revoke( IRunningObjectTable
* iface
, DWORD dwRegister
)
582 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
583 struct rot_entry
*rot_entry
;
585 TRACE("(%p,%d)\n",This
,dwRegister
);
587 EnterCriticalSection(&This
->lock
);
588 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
590 if (rot_entry
->cookie
== dwRegister
)
592 list_remove(&rot_entry
->entry
);
593 LeaveCriticalSection(&This
->lock
);
595 rot_entry_delete(rot_entry
);
599 LeaveCriticalSection(&This
->lock
);
604 /***********************************************************************
605 * RunningObjectTable_IsRunning
608 * pmkObjectName [in] moniker of the object whose status is desired
610 static HRESULT WINAPI
611 RunningObjectTableImpl_IsRunning( IRunningObjectTable
* iface
, IMoniker
*pmkObjectName
)
613 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
614 MonikerComparisonData
*moniker_data
;
616 const struct rot_entry
*rot_entry
;
618 TRACE("(%p,%p)\n",This
,pmkObjectName
);
620 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
623 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
624 IMoniker_Release(pmkObjectName
);
629 EnterCriticalSection(&This
->lock
);
630 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
632 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
633 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
639 LeaveCriticalSection(&This
->lock
);
647 hr
= IrotIsRunning(get_irot_handle(), moniker_data
);
651 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
654 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
663 HeapFree(GetProcessHeap(), 0, moniker_data
);
668 /***********************************************************************
669 * RunningObjectTable_GetObject
672 * pmkObjectName [in] Pointer to the moniker on the object
673 * ppunkObject [out] variable that receives the IUnknown interface pointer
675 static HRESULT WINAPI
676 RunningObjectTableImpl_GetObject( IRunningObjectTable
* iface
,
677 IMoniker
*pmkObjectName
, IUnknown
**ppunkObject
)
679 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
680 MonikerComparisonData
*moniker_data
;
681 InterfaceData
*object
= NULL
;
684 struct rot_entry
*rot_entry
;
686 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,ppunkObject
);
688 if (ppunkObject
== NULL
)
693 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
696 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
697 IMoniker_Release(pmkObjectName
);
701 EnterCriticalSection(&This
->lock
);
702 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
704 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
705 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
708 hr
= create_stream_on_mip_ro(rot_entry
->object
, &pStream
);
711 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
712 IStream_Release(pStream
);
715 LeaveCriticalSection(&This
->lock
);
716 HeapFree(GetProcessHeap(), 0, moniker_data
);
721 LeaveCriticalSection(&This
->lock
);
723 TRACE("moniker unavailable locally, calling SCM\n");
729 hr
= IrotGetObject(get_irot_handle(), moniker_data
, &object
, &cookie
);
733 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
736 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
747 hr
= create_stream_on_mip_ro(object
, &pStream
);
750 hr
= CoUnmarshalInterface(pStream
, &IID_IUnknown
, (void **)ppunkObject
);
751 IStream_Release(pStream
);
755 WARN("Moniker unavailable, IrotGetObject returned 0x%08x\n", hr
);
757 HeapFree(GetProcessHeap(), 0, moniker_data
);
762 /***********************************************************************
763 * RunningObjectTable_NoteChangeTime
766 * dwRegister [in] Value identifying registration being updated
767 * pfiletime [in] Pointer to structure containing object's last change time
769 static HRESULT WINAPI
770 RunningObjectTableImpl_NoteChangeTime(IRunningObjectTable
* iface
,
771 DWORD dwRegister
, FILETIME
*pfiletime
)
773 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
774 struct rot_entry
*rot_entry
;
775 HRESULT hr
= E_INVALIDARG
;
777 TRACE("(%p,%d,%p)\n",This
,dwRegister
,pfiletime
);
779 EnterCriticalSection(&This
->lock
);
780 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, struct rot_entry
, entry
)
782 if (rot_entry
->cookie
== dwRegister
)
784 rot_entry
->last_modified
= *pfiletime
;
785 LeaveCriticalSection(&This
->lock
);
791 hr
= IrotNoteChangeTime(get_irot_handle(), dwRegister
, pfiletime
);
795 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
798 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
809 LeaveCriticalSection(&This
->lock
);
812 TRACE("-- 0x08%x\n", hr
);
816 /***********************************************************************
817 * RunningObjectTable_GetTimeOfLastChange
820 * pmkObjectName [in] moniker of the object whose status is desired
821 * pfiletime [out] structure that receives object's last change time
823 static HRESULT WINAPI
824 RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable
* iface
,
825 IMoniker
*pmkObjectName
, FILETIME
*pfiletime
)
827 HRESULT hr
= MK_E_UNAVAILABLE
;
828 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
829 MonikerComparisonData
*moniker_data
;
830 const struct rot_entry
*rot_entry
;
832 TRACE("(%p,%p,%p)\n",This
,pmkObjectName
,pfiletime
);
834 if (pmkObjectName
==NULL
|| pfiletime
==NULL
)
837 hr
= reduce_moniker(pmkObjectName
, NULL
, &pmkObjectName
);
840 hr
= get_moniker_comparison_data(pmkObjectName
, &moniker_data
);
841 IMoniker_Release(pmkObjectName
);
845 hr
= MK_E_UNAVAILABLE
;
847 EnterCriticalSection(&This
->lock
);
848 LIST_FOR_EACH_ENTRY(rot_entry
, &This
->rot
, const struct rot_entry
, entry
)
850 if ((rot_entry
->moniker_data
->ulCntData
== moniker_data
->ulCntData
) &&
851 !memcmp(moniker_data
->abData
, rot_entry
->moniker_data
->abData
, moniker_data
->ulCntData
))
853 *pfiletime
= rot_entry
->last_modified
;
858 LeaveCriticalSection(&This
->lock
);
866 hr
= IrotGetTimeOfLastChange(get_irot_handle(), moniker_data
, pfiletime
);
870 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
873 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
882 HeapFree(GetProcessHeap(), 0, moniker_data
);
884 TRACE("-- 0x%08x\n", hr
);
888 /***********************************************************************
889 * RunningObjectTable_EnumRunning
892 * ppenumMoniker [out] receives the IEnumMoniker interface pointer
894 static HRESULT WINAPI
895 RunningObjectTableImpl_EnumRunning(IRunningObjectTable
* iface
,
896 IEnumMoniker
**ppenumMoniker
)
898 RunningObjectTableImpl
*This
= (RunningObjectTableImpl
*)iface
;
899 InterfaceList
*interface_list
= NULL
;
902 TRACE("(%p, %p)\n", This
, ppenumMoniker
);
904 *ppenumMoniker
= NULL
;
910 hr
= IrotEnumRunning(get_irot_handle(), &interface_list
);
914 hr
= HRESULT_FROM_WIN32(GetExceptionCode());
917 if (hr
== HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE
))
926 hr
= EnumMonikerImpl_CreateEnumROTMoniker(interface_list
,
932 /* Virtual function table for the IRunningObjectTable class. */
933 static const IRunningObjectTableVtbl VT_RunningObjectTableImpl
=
935 RunningObjectTableImpl_QueryInterface
,
936 RunningObjectTableImpl_AddRef
,
937 RunningObjectTableImpl_Release
,
938 RunningObjectTableImpl_Register
,
939 RunningObjectTableImpl_Revoke
,
940 RunningObjectTableImpl_IsRunning
,
941 RunningObjectTableImpl_GetObject
,
942 RunningObjectTableImpl_NoteChangeTime
,
943 RunningObjectTableImpl_GetTimeOfLastChange
,
944 RunningObjectTableImpl_EnumRunning
947 /***********************************************************************
948 * RunningObjectTable_Initialize
950 HRESULT WINAPI
RunningObjectTableImpl_Initialize(void)
954 /* create the unique instance of the RunningObjectTableImpl structure */
955 runningObjectTableInstance
= HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl
));
957 if (!runningObjectTableInstance
)
958 return E_OUTOFMEMORY
;
960 /* initialize the virtual table function */
961 runningObjectTableInstance
->lpVtbl
= &VT_RunningObjectTableImpl
;
963 /* the initial reference is set to "1" so that it isn't destroyed after its
964 * first use until the process is destroyed, as the running object table is
965 * a process-wide cache of a global table */
966 runningObjectTableInstance
->ref
= 1;
968 list_init(&runningObjectTableInstance
->rot
);
969 InitializeCriticalSection(&runningObjectTableInstance
->lock
);
970 DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance
->lock
, "RunningObjectTableImpl.lock");
975 /***********************************************************************
976 * RunningObjectTable_UnInitialize
978 HRESULT WINAPI
RunningObjectTableImpl_UnInitialize(void)
982 if (runningObjectTableInstance
==NULL
)
985 RunningObjectTableImpl_Release((IRunningObjectTable
*)runningObjectTableInstance
);
987 RunningObjectTableImpl_Destroy();
992 /***********************************************************************
993 * GetRunningObjectTable (OLE32.@)
995 * Retrieves the global running object table.
998 * reserved [I] Reserved. Set to 0.
999 * pprot [O] Address that receives the pointer to the running object table.
1003 * Failure: Any HRESULT code.
1006 GetRunningObjectTable(DWORD reserved
, LPRUNNINGOBJECTTABLE
*pprot
)
1008 IID riid
=IID_IRunningObjectTable
;
1014 return E_UNEXPECTED
;
1016 if(runningObjectTableInstance
==NULL
)
1017 return CO_E_NOTINITIALIZED
;
1019 res
= IRunningObjectTable_QueryInterface((IRunningObjectTable
*)runningObjectTableInstance
,&riid
,(void**)pprot
);
1024 static HRESULT
get_moniker_for_progid_display_name(LPBC pbc
,
1025 LPCOLESTR szDisplayName
,
1032 LPCWSTR start
= szDisplayName
;
1035 IMoniker
*class_moniker
;
1040 /* find end delimiter */
1041 for (end
= start
; *end
; end
++)
1047 /* must start with '@' or have a ':' somewhere and mustn't be one character
1048 * long (since that looks like an absolute path) */
1049 if (((start
== szDisplayName
) && (*end
== '\0')) || (len
<= 1))
1052 progid
= HeapAlloc(GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
));
1055 memcpy(progid
, start
, len
* sizeof(WCHAR
));
1058 hr
= CLSIDFromProgID(progid
, &clsid
);
1059 HeapFree(GetProcessHeap(), 0, progid
);
1063 hr
= CreateClassMoniker(&clsid
, &class_moniker
);
1066 IParseDisplayName
*pdn
;
1067 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1068 &IID_IParseDisplayName
, (void **)&pdn
);
1069 /* fallback to using IClassFactory to get IParseDisplayName -
1070 * adsldp.dll depends on this */
1074 hr
= IMoniker_BindToObject(class_moniker
, pbc
, NULL
,
1075 &IID_IClassFactory
, (void **)&pcf
);
1078 hr
= IClassFactory_CreateInstance(pcf
, NULL
,
1079 &IID_IParseDisplayName
,
1081 IClassFactory_Release(pcf
);
1084 IMoniker_Release(class_moniker
);
1087 hr
= IParseDisplayName_ParseDisplayName(pdn
, pbc
,
1088 (LPOLESTR
)szDisplayName
,
1090 IParseDisplayName_Release(pdn
);
1096 /******************************************************************************
1097 * MkParseDisplayName [OLE32.@]
1099 HRESULT WINAPI
MkParseDisplayName(LPBC pbc
, LPCOLESTR szDisplayName
,
1100 LPDWORD pchEaten
, LPMONIKER
*ppmk
)
1102 HRESULT hr
= MK_E_SYNTAX
;
1103 static const WCHAR wszClsidColon
[] = {'c','l','s','i','d',':'};
1107 TRACE("(%p, %s, %p, %p)\n", pbc
, debugstr_w(szDisplayName
), pchEaten
, ppmk
);
1109 if (!(IsValidInterface((LPUNKNOWN
) pbc
)))
1110 return E_INVALIDARG
;
1115 if (!strncmpiW(szDisplayName
, wszClsidColon
, sizeof(wszClsidColon
)/sizeof(wszClsidColon
[0])))
1117 hr
= ClassMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1118 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1123 hr
= get_moniker_for_progid_display_name(pbc
, szDisplayName
, &chEaten
, &moniker
);
1124 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1130 hr
= FileMoniker_CreateFromDisplayName(pbc
, szDisplayName
, &chEaten
, &moniker
);
1131 if (FAILED(hr
) && (hr
!= MK_E_SYNTAX
))
1139 IMoniker
*next_moniker
;
1140 *pchEaten
+= chEaten
;
1141 szDisplayName
+= chEaten
;
1142 if (!*szDisplayName
)
1148 hr
= IMoniker_ParseDisplayName(moniker
, pbc
, NULL
,
1149 (LPOLESTR
)szDisplayName
, &chEaten
,
1151 IMoniker_Release(moniker
);
1157 moniker
= next_moniker
;
1164 /***********************************************************************
1165 * GetClassFile (OLE32.@)
1167 * Retrieves the class ID associated with the given filename.
1170 * filePathName [I] Filename to retrieve the class ID for.
1171 * pclsid [O] Address that receives the class ID for the file.
1175 * Failure: Any HRESULT code.
1177 HRESULT WINAPI
GetClassFile(LPCOLESTR filePathName
,CLSID
*pclsid
)
1181 int nbElm
, length
, i
;
1183 LPOLESTR
*pathDec
=0,absFile
=0,progId
=0;
1185 static const WCHAR bkslashW
[] = {'\\',0};
1186 static const WCHAR dotW
[] = {'.',0};
1188 TRACE("%s, %p\n", debugstr_w(filePathName
), pclsid
);
1190 /* if the file contain a storage object the return the CLSID written by IStorage_SetClass method*/
1191 if((StgIsStorageFile(filePathName
))==S_OK
){
1193 res
=StgOpenStorage(filePathName
,NULL
,STGM_READ
| STGM_SHARE_DENY_WRITE
,NULL
,0,&pstg
);
1196 res
=ReadClassStg(pstg
,pclsid
);
1198 IStorage_Release(pstg
);
1202 /* If the file is not a storage object then attempt to match various bits in the file against a
1203 pattern in the registry. This case is not frequently used, so I present only the pseudocode for
1206 for(i=0;i<nFileTypes;i++)
1208 for(i=0;j<nPatternsForType;j++){
1213 pat=ReadPatternFromRegistry(i,j);
1214 hFile=CreateFileW(filePathName,,,,,,hFile);
1215 SetFilePosition(hFile,pat.offset);
1216 ReadFile(hFile,buf,pat.size,&r,NULL);
1217 if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
1219 *pclsid=ReadCLSIDFromRegistry(i);
1225 /* if the above strategies fail then search for the extension key in the registry */
1227 /* get the last element (absolute file) in the path name */
1228 nbElm
=FileMonikerImpl_DecomposePath(filePathName
,&pathDec
);
1229 absFile
=pathDec
[nbElm
-1];
1231 /* failed if the path represents a directory and not an absolute file name*/
1232 if (!lstrcmpW(absFile
, bkslashW
))
1233 return MK_E_INVALIDEXTENSION
;
1235 /* get the extension of the file */
1237 length
=lstrlenW(absFile
);
1238 for(i
= length
-1; (i
>= 0) && *(extension
= &absFile
[i
]) != '.'; i
--)
1241 if (!extension
|| !lstrcmpW(extension
, dotW
))
1242 return MK_E_INVALIDEXTENSION
;
1244 res
=RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, NULL
, &sizeProgId
);
1246 /* get the progId associated to the extension */
1247 progId
= CoTaskMemAlloc(sizeProgId
);
1248 res
= RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, progId
, &sizeProgId
);
1250 if (res
==ERROR_SUCCESS
)
1251 /* return the clsid associated to the progId */
1252 res
= CLSIDFromProgID(progId
,pclsid
);
1254 for(i
=0; pathDec
[i
]!=NULL
;i
++)
1255 CoTaskMemFree(pathDec
[i
]);
1256 CoTaskMemFree(pathDec
);
1258 CoTaskMemFree(progId
);
1260 if (res
==ERROR_SUCCESS
)
1263 return MK_E_INVALIDEXTENSION
;
1266 /***********************************************************************
1267 * EnumMoniker_QueryInterface
1269 static HRESULT WINAPI
EnumMonikerImpl_QueryInterface(IEnumMoniker
* iface
,REFIID riid
,void** ppvObject
)
1271 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1273 TRACE("(%p,%p,%p)\n",This
,riid
,ppvObject
);
1275 /* validate arguments */
1276 if (ppvObject
== NULL
)
1277 return E_INVALIDARG
;
1281 if (IsEqualIID(&IID_IUnknown
, riid
))
1284 if (IsEqualIID(&IID_IEnumMoniker
, riid
))
1287 if ((*ppvObject
)==NULL
)
1288 return E_NOINTERFACE
;
1290 IEnumMoniker_AddRef(iface
);
1295 /***********************************************************************
1296 * EnumMoniker_AddRef
1298 static ULONG WINAPI
EnumMonikerImpl_AddRef(IEnumMoniker
* iface
)
1300 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1302 TRACE("(%p)\n",This
);
1304 return InterlockedIncrement(&This
->ref
);
1307 /***********************************************************************
1308 * EnumMoniker_release
1310 static ULONG WINAPI
EnumMonikerImpl_Release(IEnumMoniker
* iface
)
1312 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1315 TRACE("(%p)\n",This
);
1317 ref
= InterlockedDecrement(&This
->ref
);
1319 /* uninitialize rot structure if there's no more reference to it*/
1324 TRACE("(%p) Deleting\n",This
);
1326 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1327 HeapFree(GetProcessHeap(), 0, This
->moniker_list
->interfaces
[i
]);
1328 HeapFree(GetProcessHeap(), 0, This
->moniker_list
);
1329 HeapFree(GetProcessHeap(), 0, This
);
1334 /***********************************************************************
1337 static HRESULT WINAPI
EnumMonikerImpl_Next(IEnumMoniker
* iface
, ULONG celt
, IMoniker
** rgelt
, ULONG
* pceltFetched
)
1340 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1343 TRACE("(%p) TabCurrentPos %d Tablastindx %d\n", This
, This
->pos
, This
->moniker_list
->size
);
1345 /* retrieve the requested number of moniker from the current position */
1346 for(i
= 0; (This
->pos
< This
->moniker_list
->size
) && (i
< celt
); i
++)
1349 hr
= create_stream_on_mip_ro(This
->moniker_list
->interfaces
[This
->pos
++], &stream
);
1350 if (hr
!= S_OK
) break;
1351 hr
= CoUnmarshalInterface(stream
, &IID_IMoniker
, (void **)&rgelt
[i
]);
1352 IStream_Release(stream
);
1353 if (hr
!= S_OK
) break;
1356 if (pceltFetched
!= NULL
)
1369 /***********************************************************************
1372 static HRESULT WINAPI
EnumMonikerImpl_Skip(IEnumMoniker
* iface
, ULONG celt
)
1374 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1376 TRACE("(%p)\n",This
);
1378 if (This
->pos
+ celt
>= This
->moniker_list
->size
)
1386 /***********************************************************************
1389 static HRESULT WINAPI
EnumMonikerImpl_Reset(IEnumMoniker
* iface
)
1391 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1393 This
->pos
= 0; /* set back to start of list */
1395 TRACE("(%p)\n",This
);
1400 /***********************************************************************
1403 static HRESULT WINAPI
EnumMonikerImpl_Clone(IEnumMoniker
* iface
, IEnumMoniker
** ppenum
)
1405 EnumMonikerImpl
*This
= (EnumMonikerImpl
*)iface
;
1406 InterfaceList
*moniker_list
;
1409 TRACE("(%p)\n",This
);
1413 moniker_list
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceList
, interfaces
[This
->moniker_list
->size
]));
1415 return E_OUTOFMEMORY
;
1417 moniker_list
->size
= This
->moniker_list
->size
;
1418 for (i
= 0; i
< This
->moniker_list
->size
; i
++)
1420 SIZE_T size
= FIELD_OFFSET(InterfaceData
, abData
[This
->moniker_list
->interfaces
[i
]->ulCntData
]);
1421 moniker_list
->interfaces
[i
] = HeapAlloc(GetProcessHeap(), 0, size
);
1422 if (!moniker_list
->interfaces
[i
])
1425 for (i
= 0; i
< end
; i
++)
1426 HeapFree(GetProcessHeap(), 0, moniker_list
->interfaces
[i
]);
1427 HeapFree(GetProcessHeap(), 0, moniker_list
);
1428 return E_OUTOFMEMORY
;
1430 memcpy(moniker_list
->interfaces
[i
], This
->moniker_list
->interfaces
[i
], size
);
1433 /* copy the enum structure */
1434 return EnumMonikerImpl_CreateEnumROTMoniker(moniker_list
, This
->pos
, ppenum
);
1437 /* Virtual function table for the IEnumMoniker class. */
1438 static const IEnumMonikerVtbl VT_EnumMonikerImpl
=
1440 EnumMonikerImpl_QueryInterface
,
1441 EnumMonikerImpl_AddRef
,
1442 EnumMonikerImpl_Release
,
1443 EnumMonikerImpl_Next
,
1444 EnumMonikerImpl_Skip
,
1445 EnumMonikerImpl_Reset
,
1446 EnumMonikerImpl_Clone
1449 /***********************************************************************
1450 * EnumMonikerImpl_CreateEnumROTMoniker
1451 * Used by EnumRunning to create the structure and EnumClone
1452 * to copy the structure
1454 static HRESULT
EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList
*moniker_list
,
1456 IEnumMoniker
**ppenumMoniker
)
1458 EnumMonikerImpl
* This
= NULL
;
1461 return E_INVALIDARG
;
1463 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl
));
1464 if (!This
) return E_OUTOFMEMORY
;
1466 TRACE("(%p)\n", This
);
1468 /* initialize the virtual table function */
1469 This
->lpVtbl
= &VT_EnumMonikerImpl
;
1471 /* the initial reference is set to "1" */
1472 This
->ref
= 1; /* set the ref count to one */
1473 This
->pos
= current_pos
; /* Set the list start posn */
1474 This
->moniker_list
= moniker_list
;
1476 *ppenumMoniker
= (IEnumMoniker
*)This
;
1482 /* Shared implementation of moniker marshaler based on saving and loading of
1485 typedef struct MonikerMarshal
1487 const IUnknownVtbl
*lpVtbl
;
1488 const IMarshalVtbl
*lpVtblMarshal
;
1494 static inline MonikerMarshal
*impl_from_IMarshal( IMarshal
*iface
)
1496 return (MonikerMarshal
*)((char*)iface
- FIELD_OFFSET(MonikerMarshal
, lpVtblMarshal
));
1499 static HRESULT WINAPI
MonikerMarshalInner_QueryInterface(IUnknown
*iface
, REFIID riid
, LPVOID
*ppv
)
1501 MonikerMarshal
*This
= (MonikerMarshal
*)iface
;
1502 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
1504 if (IsEqualIID(&IID_IUnknown
, riid
) || IsEqualIID(&IID_IMarshal
, riid
))
1506 *ppv
= &This
->lpVtblMarshal
;
1507 IUnknown_AddRef((IUnknown
*)&This
->lpVtblMarshal
);
1510 FIXME("No interface for %s\n", debugstr_guid(riid
));
1511 return E_NOINTERFACE
;
1514 static ULONG WINAPI
MonikerMarshalInner_AddRef(IUnknown
*iface
)
1516 MonikerMarshal
*This
= (MonikerMarshal
*)iface
;
1517 return InterlockedIncrement(&This
->ref
);
1520 static ULONG WINAPI
MonikerMarshalInner_Release(IUnknown
*iface
)
1522 MonikerMarshal
*This
= (MonikerMarshal
*)iface
;
1523 ULONG ref
= InterlockedDecrement(&This
->ref
);
1525 if (!ref
) HeapFree(GetProcessHeap(), 0, This
);
1529 static const IUnknownVtbl VT_MonikerMarshalInner
=
1531 MonikerMarshalInner_QueryInterface
,
1532 MonikerMarshalInner_AddRef
,
1533 MonikerMarshalInner_Release
1536 static HRESULT WINAPI
MonikerMarshal_QueryInterface(IMarshal
*iface
, REFIID riid
, LPVOID
*ppv
)
1538 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1539 return IMoniker_QueryInterface(This
->moniker
, riid
, ppv
);
1542 static ULONG WINAPI
MonikerMarshal_AddRef(IMarshal
*iface
)
1544 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1545 return IMoniker_AddRef(This
->moniker
);
1548 static ULONG WINAPI
MonikerMarshal_Release(IMarshal
*iface
)
1550 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1551 return IMoniker_Release(This
->moniker
);
1554 static HRESULT WINAPI
MonikerMarshal_GetUnmarshalClass(
1555 LPMARSHAL iface
, REFIID riid
, void* pv
, DWORD dwDestContext
,
1556 void* pvDestContext
, DWORD mshlflags
, CLSID
* pCid
)
1558 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1560 TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid
), pv
,
1561 dwDestContext
, pvDestContext
, mshlflags
, pCid
);
1563 return IMoniker_GetClassID(This
->moniker
, pCid
);
1566 static HRESULT WINAPI
MonikerMarshal_GetMarshalSizeMax(
1567 LPMARSHAL iface
, REFIID riid
, void* pv
, DWORD dwDestContext
,
1568 void* pvDestContext
, DWORD mshlflags
, DWORD
* pSize
)
1570 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1572 ULARGE_INTEGER size
;
1574 TRACE("(%s, %p, %x, %p, %x, %p)\n", debugstr_guid(riid
), pv
,
1575 dwDestContext
, pvDestContext
, mshlflags
, pSize
);
1577 hr
= IMoniker_GetSizeMax(This
->moniker
, &size
);
1579 *pSize
= (DWORD
)size
.QuadPart
;
1583 static HRESULT WINAPI
MonikerMarshal_MarshalInterface(LPMARSHAL iface
, IStream
*pStm
,
1584 REFIID riid
, void* pv
, DWORD dwDestContext
,
1585 void* pvDestContext
, DWORD mshlflags
)
1587 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1589 TRACE("(%p, %s, %p, %x, %p, %x)\n", pStm
, debugstr_guid(riid
), pv
,
1590 dwDestContext
, pvDestContext
, mshlflags
);
1592 return IMoniker_Save(This
->moniker
, pStm
, FALSE
);
1595 static HRESULT WINAPI
MonikerMarshal_UnmarshalInterface(LPMARSHAL iface
, IStream
*pStm
, REFIID riid
, void **ppv
)
1597 MonikerMarshal
*This
= impl_from_IMarshal(iface
);
1600 TRACE("(%p, %s, %p)\n", pStm
, debugstr_guid(riid
), ppv
);
1602 hr
= IMoniker_Load(This
->moniker
, pStm
);
1604 hr
= IMoniker_QueryInterface(This
->moniker
, riid
, ppv
);
1608 static HRESULT WINAPI
MonikerMarshal_ReleaseMarshalData(LPMARSHAL iface
, IStream
*pStm
)
1611 /* can't release a state-based marshal as nothing on server side to
1616 static HRESULT WINAPI
MonikerMarshal_DisconnectObject(LPMARSHAL iface
, DWORD dwReserved
)
1619 /* can't disconnect a state-based marshal as nothing on server side to
1620 * disconnect from */
1624 static const IMarshalVtbl VT_MonikerMarshal
=
1626 MonikerMarshal_QueryInterface
,
1627 MonikerMarshal_AddRef
,
1628 MonikerMarshal_Release
,
1629 MonikerMarshal_GetUnmarshalClass
,
1630 MonikerMarshal_GetMarshalSizeMax
,
1631 MonikerMarshal_MarshalInterface
,
1632 MonikerMarshal_UnmarshalInterface
,
1633 MonikerMarshal_ReleaseMarshalData
,
1634 MonikerMarshal_DisconnectObject
1637 HRESULT
MonikerMarshal_Create(IMoniker
*inner
, IUnknown
**outer
)
1639 MonikerMarshal
*This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1640 if (!This
) return E_OUTOFMEMORY
;
1642 This
->lpVtbl
= &VT_MonikerMarshalInner
;
1643 This
->lpVtblMarshal
= &VT_MonikerMarshal
;
1645 This
->moniker
= inner
;
1647 *outer
= (IUnknown
*)&This
->lpVtbl
;
1651 void * __RPC_USER
MIDL_user_allocate(SIZE_T size
)
1653 return HeapAlloc(GetProcessHeap(), 0, size
);
1656 void __RPC_USER
MIDL_user_free(void *p
)
1658 HeapFree(GetProcessHeap(), 0, p
);