Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

835 lines
23 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: actprops.hxx
  7. //
  8. // Contents: Common definitions for object activation.
  9. //
  10. // Classes:
  11. // ActivationProperties
  12. // ActivationPropertiesIn
  13. // ActivationPropertiesOut
  14. //
  15. // History: 24-Jan-98 Vinaykr Created
  16. //
  17. //--------------------------------------------------------------------------
  18. #ifndef __ACTPROPS_HXX__
  19. #define __ACTPROPS_HXX__
  20. #include <custmact.h>
  21. #include <privact.h>
  22. #include <catalog.h>
  23. #include <serial.hxx>
  24. #include <propifs.hxx>
  25. #include <partitions.h>
  26. #include <ole2com.h>
  27. //---------------------------------------------------------------------
  28. // Helper to find the end of delegation chain at each activation stage
  29. //----------------------------------------------------------------------
  30. ISystemActivator *GetComActivatorForStage(ACTIVATION_STAGE);
  31. //----------------------------------------------------------------------
  32. // Forward References
  33. //----------------------------------------------------------------------
  34. class ActivationPropertiesIn;
  35. class ActivationPropertiesOut;
  36. //----------------------------------------------------------------------
  37. // Macros for Stages
  38. //----------------------------------------------------------------------
  39. #define CLIENT_STAGE(stage) (stage==CLIENT_CONTEXT_STAGE)
  40. #define SERVER_STAGE(stage) ((stage==SERVER_PROCESS_STAGE) || \
  41. (stage==SERVER_CONTEXT_STAGE))
  42. #define SCM_STAGE(stage) ((stage==SERVER_MACHINE_STAGE) || \
  43. (stage==CLIENT_MACHINE_STAGE))
  44. //----------------------------------------------------------------------
  45. // Macros for context
  46. //----------------------------------------------------------------------
  47. #define MARSHALCTX_WITHIN_PROCESS(ctx) ((ctx == MSHCTX_CROSSCTX) || \
  48. (ctx == MSHCTX_INPROC))
  49. //----------------------------------------------------------------------
  50. // Base Class that provides Serialization support and some private
  51. // Methods via IActivationProperties for both in In and Out objects
  52. //----------------------------------------------------------------------
  53. class ActivationProperties : public IActivationProperties,
  54. public ISerializableParent,
  55. public IGetCatalogObject
  56. {
  57. public:
  58. ActivationProperties();
  59. virtual ~ActivationProperties();
  60. // Methods from IUnknown
  61. STDMETHOD (QueryInterface) ( REFIID riid, LPVOID* ppvObj);
  62. STDMETHOD_(ULONG,AddRef) ( void );
  63. STDMETHOD_(ULONG,Release) ( void );
  64. // Methods from IActivationProperties
  65. //-----------------------------------------------------------------
  66. //Remembers the maximum destination context.
  67. //-----------------------------------------------------------------
  68. inline DWORD SetUpMarshallingDistance(DWORD dwDestCtx)
  69. {
  70. static DWORD distance[5] = { MSHCTX_CROSSCTX,
  71. MSHCTX_INPROC,
  72. MSHCTX_LOCAL,
  73. MSHCTX_NOSHAREDMEM,
  74. MSHCTX_DIFFERENTMACHINE
  75. };
  76. int newind=-1;
  77. int oldind=-1;
  78. for (int i=0; i<5; i++)
  79. {
  80. if (distance[i] == dwDestCtx)
  81. {
  82. newind = i;
  83. if (oldind != -1)
  84. break;
  85. }
  86. if (distance[i] == _serHeader.destCtx)
  87. {
  88. oldind = i;
  89. if (newind != -1)
  90. break;
  91. }
  92. }
  93. ASSERT(newind != -1);
  94. ASSERT(oldind != -1);
  95. if (oldind < newind)
  96. _serHeader.destCtx = distance[newind];
  97. return _serHeader.destCtx;
  98. }
  99. // Sets up Destination context for marshalling and storage
  100. // for maximum distance
  101. STDMETHOD(SetDestCtx)(IN DWORD dwDestCtx)
  102. {
  103. SetUpMarshallingDistance(dwDestCtx);
  104. return S_OK;
  105. }
  106. inline HRESULT GetPropertyInfo(REFIID riid, void** ppv)
  107. {
  108. HRESULT hr;
  109. if ((hr = QueryInterface(riid, ppv))==S_OK)
  110. Release();
  111. return hr;
  112. }
  113. STDMETHOD(SetMarshalFlags)(IN DWORD marshalFlags)
  114. {
  115. _marshalFlags = marshalFlags;
  116. return S_OK;
  117. }
  118. STDMETHOD(GetMarshalFlags)(OUT DWORD *pdwMarshalFlags)
  119. {
  120. *pdwMarshalFlags = _marshalFlags;
  121. return S_OK;
  122. }
  123. //-----------------------------------------------------------------
  124. // Used to store\retrieve a COM private blob for retrieval. Currently
  125. // only used in the SCM. Ownership of the blob remains with the caller.
  126. //-----------------------------------------------------------------
  127. STDMETHOD(SetLocalBlob)(void* blob)
  128. {
  129. _blob = blob;
  130. return S_OK;
  131. }
  132. STDMETHOD(GetLocalBlob)(void** pBlob)
  133. {
  134. *pBlob = _blob;
  135. return S_OK;
  136. }
  137. HRESULT Serialize(Serializer &pSer);
  138. HRESULT GetSize(Serializer &pSer, DWORD *pSize);
  139. // methods from IMarshal
  140. STDMETHOD (GetUnmarshalClass)(
  141. REFIID riid,
  142. void *pv,
  143. DWORD dwDestContext,
  144. void *pvDestContext,
  145. DWORD mshlflags,
  146. CLSID *pCid);
  147. STDMETHOD (GetMarshalSizeMax)(
  148. REFIID riid,
  149. void *pv,
  150. DWORD dwDestContext,
  151. void *pvDestContext,
  152. DWORD mshlflags,
  153. DWORD *pSize);
  154. STDMETHOD (MarshalInterface)(
  155. IStream *pStm,
  156. REFIID riid,
  157. void *pv,
  158. DWORD dwDestContext,
  159. void *pvDestContext,
  160. DWORD mshlflags);
  161. STDMETHOD (UnmarshalInterface)(IStream *pStm,REFIID riid,void **ppv);
  162. STDMETHOD (ReleaseMarshalData)(IStream *pStm);
  163. STDMETHOD (DisconnectObject)(DWORD dwReserved);
  164. void SetSerializableIfs(DWORD index, SerializableProperty *pSer);
  165. void AddSerializableIfs(SerializableProperty *pSer);
  166. inline HRESULT UnSerializeCallBack(REFCLSID clsid, SerializableProperty **ppSer=0);
  167. HRESULT ReturnClass(REFIID iid, SerializableProperty *pSer);
  168. STDMETHOD(GetUnserialized)(REFCLSID clsid, void **ppISer,
  169. DWORD *pSize, DWORD *pPos);
  170. virtual HRESULT GetClass(REFIID iid,
  171. SerializableProperty **ppSer,
  172. BOOL forQI,
  173. BOOL *pbZeroSizeOk=NULL) = 0;
  174. HRESULT SetupForUnserializing(Serializer *pSer);
  175. // IGetCatalogObject
  176. STDMETHOD(GetCatalogObject)(REFIID riid, void **ppv)
  177. {
  178. HRESULT hr = InitializeCatalogIfNecessary();
  179. if (hr != S_OK)
  180. return hr;
  181. return gpCatalog->QueryInterface(riid, ppv);
  182. }
  183. //-----------------------------------------------------------------
  184. //Used to indicate whether heap allocation took place
  185. //-----------------------------------------------------------------
  186. inline void SetNotDelete(BOOL fDestruct=FALSE)
  187. {
  188. _toDelete = FALSE;
  189. _fDestruct = fDestruct;
  190. }
  191. // Sets opaque data -- actprops now responsible for freeing
  192. inline HRESULT SetOpaqueDataInfo(DWORD dwSize, OpaqueData *pData)
  193. {
  194. _serHeader.cOpaqueData = dwSize;
  195. _serHeader.opaqueData = (tagCustomOpaqueData*) pData;
  196. return S_OK;
  197. }
  198. // Gets opaque data -- actprops no longer responsible for freeing
  199. inline HRESULT GetOpaqueDataInfo(DWORD *pdwSize, OpaqueData **ppData)
  200. {
  201. *pdwSize = _serHeader.cOpaqueData;
  202. _serHeader.cOpaqueData = 0;
  203. *ppData = (OpaqueData*) _serHeader.opaqueData;
  204. _serHeader.opaqueData = NULL;
  205. return S_OK;
  206. }
  207. enum {NOT_MARSHALLED=1, SIZED=2, MARSHALLED=3, UNMARSHALLED=4} _marshalState;
  208. protected:
  209. #ifndef MAX_ACTARRAY_SIZE
  210. #define MAX_ACTARRAY_SIZE 10
  211. #endif
  212. CLSID _actCLSID;
  213. BOOL _unSerialized;
  214. BOOL _unSerializedInproc;
  215. LONG _refCount;
  216. CustomHeader _serHeader;
  217. CustomHeader _unSerHeader;
  218. DWORD _marshalFlags;
  219. DWORD _size;
  220. BOOL _toDelete;
  221. BOOL _fDestruct;
  222. BOOL _fInprocSerializationRequired;
  223. private:
  224. DWORD _totalSize;
  225. SerializableProperty * serializableIfsCollection[MAX_ACTARRAY_SIZE];
  226. DWORD _ifsIndex;
  227. CLSID _clsidArray[MAX_ACTARRAY_SIZE];
  228. DWORD _sizeArray[MAX_ACTARRAY_SIZE];
  229. DWORD _headerSize;
  230. Serializer *_pUnSer;
  231. void* _blob;
  232. };
  233. //----------------------------------------------------------------------
  234. // This is the "Out" object that is sent back on the return path
  235. // of an activation containing results.
  236. //----------------------------------------------------------------------
  237. class ActivationPropertiesOut: public ActivationProperties,
  238. public IPrivActivationPropertiesOut
  239. {
  240. public:
  241. ActivationPropertiesOut(BOOL fBrokenRefCount=FALSE);
  242. virtual ~ActivationPropertiesOut();
  243. void SetClientCOMVersion(COMVERSION &version)
  244. {
  245. _clientCOMVersion = version;
  246. }
  247. inline BOOL Initialize()
  248. {
  249. _pOutSer=0;
  250. _refCount = 1;
  251. _actCLSID=CLSID_ActivationPropertiesOut;
  252. _fInprocSerializationRequired = TRUE;
  253. return TRUE;
  254. }
  255. inline IClassFactory *GetCF()
  256. {
  257. return NULL;
  258. }
  259. inline void SetCF(IClassFactory* pCF)
  260. {
  261. }
  262. // Methods from IUnknown
  263. STDMETHOD (QueryInterface) ( REFIID riid, LPVOID* ppvObj);
  264. STDMETHOD_(ULONG,AddRef) ( void );
  265. STDMETHOD_(ULONG,Release) ( void );
  266. // Methods from IActivationPropertyOut
  267. STDMETHOD(GetActivationID) (OUT GUID *pActivationID);
  268. STDMETHOD(SetObjectInterfaces) (
  269. IN DWORD cIfs,
  270. IN IID *pIID,
  271. IN IUnknown *pUnk);
  272. STDMETHOD(GetObjectInterface) (
  273. IN REFIID riid,
  274. IN DWORD actvflags,
  275. OUT void **ppv);
  276. STDMETHOD(GetObjectInterfaces) (
  277. IN DWORD pcIfs,
  278. IN DWORD actvflags,
  279. IN MULTI_QI *pMultiQi);
  280. STDMETHOD(RemoveRequestedIIDs) (IN DWORD cIfs,
  281. IN IID *pIID);
  282. //Methods from IPrivActivationPropertiesOut
  283. STDMETHOD(SetMarshalledResults)(IN DWORD cIfs,
  284. IN IID *pIID,
  285. IN HRESULT *pHr,
  286. IN MInterfacePointer **pIntfData);
  287. STDMETHOD(GetMarshalledResults)(OUT DWORD *pcIfs,
  288. OUT IID **pIID,
  289. OUT HRESULT **pHr,
  290. OUT MInterfacePointer ***pIntfData);
  291. virtual HRESULT GetClass(REFIID iid,
  292. SerializableProperty **ppSer,
  293. BOOL forQI,
  294. BOOL *pbZeroSizeOk=NULL);
  295. //-----------------------------------------------------------------
  296. // This is a serializable object that has marshalling logic for
  297. // results of an activation
  298. //-----------------------------------------------------------------
  299. class OutSerializer:public SerializableProperty
  300. {
  301. public:
  302. OutSerializer(BOOL fBrokenRefcount=FALSE);
  303. ~OutSerializer();
  304. // Methods from IUnknown
  305. STDMETHOD (QueryInterface) ( REFIID riid, LPVOID* ppvObj);
  306. STDMETHOD_(ULONG,AddRef) ( void );
  307. STDMETHOD_(ULONG,Release) ( void );
  308. STDMETHOD(Serialize)(IN void *pSer);
  309. STDMETHOD(UnSerialize)(IN void *pSer);
  310. STDMETHOD(GetSize)(IN void *pSer, OUT DWORD *pdwSize);
  311. STDMETHOD(GetCLSID)(OUT CLSID *pclsid);
  312. STDMETHOD(SerializableQueryInterface) ( REFIID riid, LPVOID* ppvObj);
  313. void UnmarshalAtIndex(DWORD index);
  314. void SetBrokenRefCoun();
  315. PropsOutInfo _info;
  316. IUnknown *_pUnk;
  317. void **_ppvObj;
  318. DWORD _size;
  319. COMVERSION *_pClientCOMVersion;
  320. IID _pIIDs[MAX_ACTARRAY_SIZE];
  321. BOOL _fBrokenRefCount;
  322. BOOL _fToReleaseIFD;
  323. };
  324. private:
  325. OutSerializer *_pOutSer;
  326. OutSerializer _outSer;
  327. ScmReplyInfo _scmReplyInfo;
  328. COMVERSION _clientCOMVersion;
  329. BOOL _fBrokenRefCount;
  330. };
  331. //----------------------------------------------------------------------
  332. // This is the "In" object that is used in the "request" direction of
  333. // an activation and contains all parameters necessary for an activation
  334. //----------------------------------------------------------------------
  335. class ActivationPropertiesIn: public ActivationProperties,
  336. public IPrivActivationPropertiesIn,
  337. public IActivationStageInfo,
  338. public IInitActivationPropertiesIn
  339. {
  340. public:
  341. ActivationPropertiesIn();
  342. virtual ~ActivationPropertiesIn();
  343. // Methods from IUnknown
  344. STDMETHOD (QueryInterface) ( REFIID riid, LPVOID* ppvObj);
  345. STDMETHOD_(ULONG,AddRef) ( void );
  346. STDMETHOD_(ULONG,Release) ( void );
  347. STDMETHOD (UnmarshalInterface)(IStream *pStm,REFIID riid,void **ppv);
  348. // Methods from IInitActivationPropertiesIn
  349. STDMETHOD(SetClsctx) (IN DWORD clsctx);
  350. STDMETHOD(SetActivationFlags) (IN DWORD actvflags);
  351. STDMETHOD(SetClassInfo) (IN IUnknown* pUnkClassInfo);
  352. STDMETHOD(SetContextInfo) (IN IContext* pClientContext,
  353. IN IContext* pPrototypeContext);
  354. STDMETHOD(SetConstructFromStorage) (IN IStorage* pStorage);
  355. STDMETHOD(SetConstructFromFile) (IN WCHAR* wszFileName, IN DWORD dwMode);
  356. //Methods from IActivationPropertiesIn
  357. STDMETHOD(GetClassInfo) (REFIID riid, void **ppv)
  358. {
  359. return _pClassInfo->QueryInterface(riid,ppv);
  360. }
  361. inline IComClassInfo *GetComClassInfo()
  362. {
  363. return _pClassInfo;
  364. }
  365. STDMETHOD(GetClsid)(OUT CLSID *pClsid)
  366. {
  367. return GetInstantiationInfo()->GetClsid(pClsid);
  368. }
  369. STDMETHOD(GetClsctx) (OUT DWORD *pdwClsctx);
  370. STDMETHOD(GetActivationFlags) (OUT DWORD* pactvflags);
  371. STDMETHOD(AddRequestedIIDs) (IN DWORD cIfs,
  372. IN IID *pIID);
  373. STDMETHOD(GetRequestedIIDs)(OUT DWORD *pcIfs,
  374. OUT IID **ppIID);
  375. STDMETHOD(GetActivationID) (OUT GUID *pActivationID);
  376. STDMETHOD(DelegateGetClassObject) (
  377. OUT IActivationPropertiesOut **pActPropsOut);
  378. STDMETHOD(DelegateCreateInstance) (
  379. IN IUnknown *pUnkOuter,
  380. OUT IActivationPropertiesOut **pActPropsOut);
  381. STDMETHOD(DelegateCIAndGetCF) (
  382. IN IUnknown *pUnkOuter,
  383. OUT IActivationPropertiesOut **ppActPropsOut,
  384. OUT IClassFactory **ppCF);
  385. STDMETHOD(GetReturnActivationProperties)(
  386. IUnknown *pUnk,
  387. OUT IActivationPropertiesOut **ppActOut);
  388. //Methods from IPrivActivationPropertiesIn
  389. STDMETHOD(PrivGetReturnActivationProperties)(
  390. IPrivActivationPropertiesOut **ppActOut);
  391. inline HRESULT GetReturnActivationPropertiesWithCF(
  392. IUnknown *pUnk,
  393. IClassFactory *pCF,
  394. OUT IActivationPropertiesOut **ppActOut)
  395. {
  396. return GetReturnActivationProperties(pUnk, ppActOut);
  397. }
  398. STDMETHOD(GetCOMVersion)(COMVERSION *pVersion)
  399. {
  400. COMVERSION *pver;
  401. GetInstantiationInfo()->GetClientCOMVersion(&pver);
  402. *pVersion = *pver;
  403. return S_OK;
  404. }
  405. STDMETHOD(GetClientToken)(OUT HANDLE *pHandle)
  406. {
  407. *pHandle = _clientToken;
  408. return S_OK;
  409. }
  410. STDMETHOD(GetDestCtx)(OUT DWORD *pdwDestCtx)
  411. {
  412. *pdwDestCtx = _serHeader.destCtx;
  413. return S_OK;
  414. }
  415. //Non interface Methods
  416. inline void SetClientToken(HANDLE token)
  417. {
  418. _clientToken = token;
  419. }
  420. inline void GetRemoteActivationFlags(BOOL *pfComplusOnly,
  421. BOOL *pfUseSystemIdentity)
  422. {
  423. *pfComplusOnly = _fComplusOnly;
  424. *pfUseSystemIdentity = _fUseSystemIdentity;
  425. }
  426. // Used by SCM for down-level interop where we have
  427. // theoretically delegated but the activation object
  428. // is not unmarshalled
  429. inline void SetDelegated()
  430. {
  431. _delegated = TRUE;
  432. }
  433. STDMETHOD(GetReturnActivationProperties)(
  434. ActivationPropertiesOut **ppActOut);
  435. // Methods from IActivationStageInfo
  436. STDMETHOD(SetStageAndIndex) (IN ACTIVATION_STAGE stage, IN int index);
  437. STDMETHOD(GetStage) (OUT ACTIVATION_STAGE* pstage)
  438. {
  439. *pstage = _stage;
  440. return S_OK;
  441. }
  442. STDMETHOD(GetIndex) (OUT int* pindex)
  443. {
  444. *pindex = _customIndex;
  445. return S_OK;
  446. }
  447. virtual HRESULT GetClass(REFIID iid,
  448. SerializableProperty **ppSer,
  449. BOOL forQI,
  450. BOOL *pbZeroSizeOk=NULL);
  451. inline InstantiationInfo *GetInstantiationInfo()
  452. {
  453. if (!_pinst)
  454. {
  455. _pinst = &_instantiationInfo;
  456. if (!_unSerialized)
  457. AddSerializableIfs(_pinst);
  458. else
  459. UnSerializeCallBack(IID_IInstantiationInfo, NULL);
  460. }
  461. return _pinst;
  462. }
  463. inline ContextInfo *GetContextInfo()
  464. {
  465. if (!_pContextInfo)
  466. {
  467. _pContextInfo = &_contextInfo;
  468. if (!_unSerialized)
  469. AddSerializableIfs(_pContextInfo);
  470. else
  471. UnSerializeCallBack(IID_IActivationContextInfo, NULL);
  472. }
  473. return _pContextInfo;
  474. }
  475. inline ServerLocationInfo *GetServerLocationInfo()
  476. {
  477. if (!_pServerLocationInfo)
  478. {
  479. _pServerLocationInfo = &_serverLocationInfo;
  480. if (!_unSerialized)
  481. AddSerializableIfs(_pServerLocationInfo);
  482. else
  483. UnSerializeCallBack(IID_IServerLocationInfo, NULL);
  484. }
  485. return _pServerLocationInfo;
  486. }
  487. inline SpecialProperties *GetSpecialProperties()
  488. {
  489. if (!_pSpecialProperties)
  490. {
  491. _pSpecialProperties = &_specialProperties;
  492. if (!_unSerialized)
  493. AddSerializableIfs(_pSpecialProperties);
  494. else
  495. UnSerializeCallBack(IID_ISpecialSystemProperties, NULL);
  496. }
  497. return _pSpecialProperties;
  498. }
  499. inline SecurityInfo *GetSecurityInfo()
  500. {
  501. if (!_pSecurityInfo)
  502. {
  503. _pSecurityInfo = &_securityInfo;
  504. if (!_unSerialized)
  505. AddSerializableIfs(_pSecurityInfo);
  506. else
  507. UnSerializeCallBack(IID_IActivationSecurityInfo, NULL);
  508. }
  509. return _pSecurityInfo;
  510. }
  511. inline InstanceInfo *GetPersistInfo()
  512. {
  513. if (!_pPersist)
  514. {
  515. _pPersist = &_instanceInfo;
  516. if (!_unSerialized)
  517. AddSerializableIfs(_pPersist);
  518. else
  519. UnSerializeCallBack(IID_IInstanceInfo, NULL);
  520. }
  521. return _pPersist;
  522. }
  523. inline void SetDip(void *pDip)
  524. {
  525. _pDip = pDip;
  526. }
  527. inline void *GetDip()
  528. {
  529. return _pDip;
  530. }
  531. // FIXFIX (johnstra): InstanceInfo may hold onto an IStorage proxy.
  532. // If we don't Release it before going back across, we try to release
  533. // it from on a dispatch thread after the activation is done. This
  534. // causes us to possibly call the proxy from the wrong apartment.
  535. inline void CleanupLocalState(void)
  536. {
  537. _instanceInfo.CleanupLocalState();
  538. }
  539. private:
  540. ACTIVATION_STAGE _stage;
  541. DWORD _cCustomAct;
  542. DWORD _customIndex;
  543. DWORD _dwInitialContext;
  544. BOOL _delegated;
  545. // Used in the SCM by LBA
  546. HANDLE _clientToken;
  547. BOOL _fUseSystemIdentity;
  548. BOOL _fComplusOnly;
  549. // class info object and custom activators
  550. IComClassInfo * _pClassInfo;
  551. ISystemActivator ** _customActList;
  552. //Fast cached copies of objects
  553. InstantiationInfo *_pinst;
  554. InstanceInfo *_pPersist;
  555. ContextInfo *_pContextInfo;
  556. ServerLocationInfo *_pServerLocationInfo;
  557. SecurityInfo *_pSecurityInfo;
  558. SpecialProperties *_pSpecialProperties;
  559. // Locally allocated objects for efficiency
  560. ActivationPropertiesOut _actOut;
  561. SecurityInfo _securityInfo;
  562. ServerLocationInfo _serverLocationInfo;
  563. InstantiationInfo _instantiationInfo;
  564. ContextInfo _contextInfo;
  565. InstanceInfo _instanceInfo;
  566. ScmRequestInfo _scmRequestInfo;
  567. SpecialProperties _specialProperties;
  568. void *_pDip;
  569. IClassFactory *_pCF;
  570. };
  571. //----------------------------------------------------------------------
  572. // Inproc unmarshalling class
  573. // NOTE: Assumption is that this is stateless so can use a singleton
  574. // in the internal instance creation
  575. //----------------------------------------------------------------------
  576. class InprocActpropsUnmarshaller:public IMarshal
  577. {
  578. public:
  579. // Methods from IUnknown
  580. STDMETHOD (QueryInterface) ( REFIID riid, LPVOID* ppv)
  581. {
  582. if (IsEqualIID(riid, IID_IUnknown))
  583. *ppv = (IUnknown*) this;
  584. else
  585. if (IsEqualIID(riid, IID_IMarshal))
  586. *ppv = (IMarshal*) this;
  587. else
  588. return E_NOINTERFACE;
  589. return S_OK;
  590. }
  591. STDMETHOD_(ULONG,AddRef) ( void )
  592. {
  593. return 1;
  594. }
  595. STDMETHOD_(ULONG,Release) ( void )
  596. {
  597. return 1;
  598. }
  599. // Methods from IMarshal
  600. STDMETHOD (GetUnmarshalClass)(
  601. REFIID riid,
  602. void *pv,
  603. DWORD dwDestContext,
  604. void *pvDestContext,
  605. DWORD mshlflags,
  606. CLSID *pCid)
  607. {
  608. return E_NOTIMPL;
  609. }
  610. STDMETHOD (GetMarshalSizeMax)(
  611. REFIID riid,
  612. void *pv,
  613. DWORD dwDestContext,
  614. void *pvDestContext,
  615. DWORD mshlflags,
  616. DWORD *pSize)
  617. {
  618. return E_NOTIMPL;
  619. }
  620. STDMETHOD (MarshalInterface)(
  621. IStream *pStm,
  622. REFIID riid,
  623. void *pv,
  624. DWORD dwDestContext,
  625. void *pvDestContext,
  626. DWORD mshlflags)
  627. {
  628. return E_NOTIMPL;
  629. }
  630. STDMETHOD (UnmarshalInterface)(IStream *pStm,REFIID riid,void **ppv);
  631. STDMETHOD (ReleaseMarshalData)(IStream *pStm)
  632. {
  633. return E_NOTIMPL;
  634. }
  635. STDMETHOD (DisconnectObject)(DWORD dwReserved)
  636. {
  637. return E_NOTIMPL;
  638. }
  639. static InprocActpropsUnmarshaller *GetInstance()
  640. {
  641. return &_InprocActUnmarshaller;
  642. }
  643. private:
  644. InprocActpropsUnmarshaller()
  645. {
  646. }
  647. static InprocActpropsUnmarshaller _InprocActUnmarshaller;
  648. };
  649. //----------------------------------------------------------------------
  650. // Definitions of functions used for marshalling the above objects
  651. //----------------------------------------------------------------------
  652. extern HRESULT ActPropsMarshalHelper(IActivationProperties *pact,
  653. REFIID riid,
  654. DWORD destCtx,
  655. DWORD mshlflags,
  656. MInterfacePointer **ppIRD);
  657. extern HRESULT ActPropsUnMarshalHelper(IActivationProperties *pAct,
  658. MInterfacePointer *pIFP,
  659. REFIID riid,
  660. void **ppv
  661. );
  662. //----------------------------------------------------------------------
  663. // Miscellaneous helper functions
  664. //----------------------------------------------------------------------
  665. extern HRESULT LoadPersistentObject(IUnknown *, IInstanceInfo *);
  666. extern HRESULT GetIFDFromInterface(
  667. IUnknown *pUnk,
  668. REFIID riid,
  669. DWORD destCtx,
  670. DWORD mshlflags,
  671. MInterfacePointer **ppIRD);
  672. extern HRESULT ReleaseIFD(
  673. MInterfacePointer *pIRD);
  674. extern void *GetDestCtxPtr(COMVERSION *pComVersion);
  675. extern BOOL IsBrokenRefCount(CLSID *pClsId);
  676. #endif //__ACTPROPS_HXX__