Leaked source code of windows server 2003
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.

846 lines
24 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. InstantiationInfo* pii = GetInstantiationInfo();
  368. if (pii)
  369. return pii->GetClsid(pClsid);
  370. else
  371. return E_OUTOFMEMORY;
  372. }
  373. STDMETHOD(GetClsctx) (OUT DWORD *pdwClsctx);
  374. STDMETHOD(GetActivationFlags) (OUT DWORD* pactvflags);
  375. STDMETHOD(AddRequestedIIDs) (IN DWORD cIfs,
  376. IN IID *pIID);
  377. STDMETHOD(GetRequestedIIDs)(OUT DWORD *pcIfs,
  378. OUT IID **ppIID);
  379. STDMETHOD(GetActivationID) (OUT GUID *pActivationID);
  380. STDMETHOD(DelegateGetClassObject) (
  381. OUT IActivationPropertiesOut **pActPropsOut);
  382. STDMETHOD(DelegateCreateInstance) (
  383. IN IUnknown *pUnkOuter,
  384. OUT IActivationPropertiesOut **pActPropsOut);
  385. STDMETHOD(DelegateCIAndGetCF) (
  386. IN IUnknown *pUnkOuter,
  387. OUT IActivationPropertiesOut **ppActPropsOut,
  388. OUT IClassFactory **ppCF);
  389. STDMETHOD(GetReturnActivationProperties)(
  390. IUnknown *pUnk,
  391. OUT IActivationPropertiesOut **ppActOut);
  392. //Methods from IPrivActivationPropertiesIn
  393. STDMETHOD(PrivGetReturnActivationProperties)(
  394. IPrivActivationPropertiesOut **ppActOut);
  395. inline HRESULT GetReturnActivationPropertiesWithCF(
  396. IUnknown *pUnk,
  397. IClassFactory *pCF,
  398. OUT IActivationPropertiesOut **ppActOut)
  399. {
  400. return GetReturnActivationProperties(pUnk, ppActOut);
  401. }
  402. STDMETHOD(GetCOMVersion)(COMVERSION *pVersion)
  403. {
  404. COMVERSION *pver;
  405. InstantiationInfo* pii = GetInstantiationInfo();
  406. if (pii)
  407. {
  408. pii->GetClientCOMVersion(&pver);
  409. *pVersion = *pver;
  410. return S_OK;
  411. }
  412. else
  413. return E_OUTOFMEMORY;
  414. }
  415. STDMETHOD(GetClientToken)(OUT HANDLE *pHandle)
  416. {
  417. *pHandle = _clientToken;
  418. return S_OK;
  419. }
  420. STDMETHOD(GetDestCtx)(OUT DWORD *pdwDestCtx)
  421. {
  422. *pdwDestCtx = _serHeader.destCtx;
  423. return S_OK;
  424. }
  425. //Non interface Methods
  426. inline void SetClientToken(HANDLE token)
  427. {
  428. _clientToken = token;
  429. }
  430. inline void GetRemoteActivationFlags(BOOL *pfComplusOnly,
  431. BOOL *pfUseSystemIdentity)
  432. {
  433. *pfComplusOnly = _fComplusOnly;
  434. *pfUseSystemIdentity = _fUseSystemIdentity;
  435. }
  436. // Used by SCM for down-level interop where we have
  437. // theoretically delegated but the activation object
  438. // is not unmarshalled
  439. inline void SetDelegated()
  440. {
  441. _delegated = TRUE;
  442. }
  443. STDMETHOD(GetReturnActivationProperties)(
  444. ActivationPropertiesOut **ppActOut);
  445. // Methods from IActivationStageInfo
  446. STDMETHOD(SetStageAndIndex) (IN ACTIVATION_STAGE stage, IN int index);
  447. STDMETHOD(GetStage) (OUT ACTIVATION_STAGE* pstage)
  448. {
  449. *pstage = _stage;
  450. return S_OK;
  451. }
  452. STDMETHOD(GetIndex) (OUT int* pindex)
  453. {
  454. *pindex = _customIndex;
  455. return S_OK;
  456. }
  457. virtual HRESULT GetClass(REFIID iid,
  458. SerializableProperty **ppSer,
  459. BOOL forQI,
  460. BOOL *pbZeroSizeOk=NULL);
  461. // HanyR, 4/26/02, COM+ 29823
  462. // Modified to return NULL if we failed during deserialization
  463. // ideally the rest of the GetXYZ() API's would also be modified to do the same
  464. inline InstantiationInfo *GetInstantiationInfo()
  465. {
  466. if (!_pinst)
  467. {
  468. _pinst = &_instantiationInfo;
  469. if (!_unSerialized)
  470. AddSerializableIfs(_pinst);
  471. else
  472. {
  473. if (FAILED(UnSerializeCallBack(IID_IInstantiationInfo, NULL)))
  474. _pinst = NULL;
  475. }
  476. }
  477. return _pinst;
  478. }
  479. inline ContextInfo *GetContextInfo()
  480. {
  481. if (!_pContextInfo)
  482. {
  483. _pContextInfo = &_contextInfo;
  484. if (!_unSerialized)
  485. AddSerializableIfs(_pContextInfo);
  486. else
  487. UnSerializeCallBack(IID_IActivationContextInfo, NULL);
  488. }
  489. return _pContextInfo;
  490. }
  491. inline ServerLocationInfo *GetServerLocationInfo()
  492. {
  493. if (!_pServerLocationInfo)
  494. {
  495. _pServerLocationInfo = &_serverLocationInfo;
  496. if (!_unSerialized)
  497. AddSerializableIfs(_pServerLocationInfo);
  498. else
  499. UnSerializeCallBack(IID_IServerLocationInfo, NULL);
  500. }
  501. return _pServerLocationInfo;
  502. }
  503. inline SpecialProperties *GetSpecialProperties()
  504. {
  505. if (!_pSpecialProperties)
  506. {
  507. _pSpecialProperties = &_specialProperties;
  508. if (!_unSerialized)
  509. AddSerializableIfs(_pSpecialProperties);
  510. else
  511. UnSerializeCallBack(IID_ISpecialSystemProperties, NULL);
  512. }
  513. return _pSpecialProperties;
  514. }
  515. inline SecurityInfo *GetSecurityInfo()
  516. {
  517. if (!_pSecurityInfo)
  518. {
  519. _pSecurityInfo = &_securityInfo;
  520. if (!_unSerialized)
  521. AddSerializableIfs(_pSecurityInfo);
  522. else
  523. UnSerializeCallBack(IID_IActivationSecurityInfo, NULL);
  524. }
  525. return _pSecurityInfo;
  526. }
  527. inline InstanceInfo *GetPersistInfo()
  528. {
  529. if (!_pPersist)
  530. {
  531. _pPersist = &_instanceInfo;
  532. if (!_unSerialized)
  533. AddSerializableIfs(_pPersist);
  534. else
  535. UnSerializeCallBack(IID_IInstanceInfo, NULL);
  536. }
  537. return _pPersist;
  538. }
  539. inline void SetDip(void *pDip)
  540. {
  541. _pDip = pDip;
  542. }
  543. inline void *GetDip()
  544. {
  545. return _pDip;
  546. }
  547. inline void CleanupLocalState(void)
  548. {
  549. _instanceInfo.CleanupLocalState();
  550. }
  551. private:
  552. ACTIVATION_STAGE _stage;
  553. DWORD _cCustomAct;
  554. DWORD _customIndex;
  555. DWORD _dwInitialContext;
  556. BOOL _delegated;
  557. // Used in the SCM by LBA
  558. HANDLE _clientToken;
  559. BOOL _fUseSystemIdentity;
  560. BOOL _fComplusOnly;
  561. // class info object and custom activators
  562. IComClassInfo * _pClassInfo;
  563. ISystemActivator ** _customActList;
  564. //Fast cached copies of objects
  565. InstantiationInfo *_pinst;
  566. InstanceInfo *_pPersist;
  567. ContextInfo *_pContextInfo;
  568. ServerLocationInfo *_pServerLocationInfo;
  569. SecurityInfo *_pSecurityInfo;
  570. SpecialProperties *_pSpecialProperties;
  571. // Locally allocated objects for efficiency
  572. ActivationPropertiesOut _actOut;
  573. SecurityInfo _securityInfo;
  574. ServerLocationInfo _serverLocationInfo;
  575. InstantiationInfo _instantiationInfo;
  576. ContextInfo _contextInfo;
  577. InstanceInfo _instanceInfo;
  578. ScmRequestInfo _scmRequestInfo;
  579. SpecialProperties _specialProperties;
  580. void *_pDip;
  581. IClassFactory *_pCF;
  582. };
  583. //----------------------------------------------------------------------
  584. // Inproc unmarshalling class
  585. // NOTE: Assumption is that this is stateless so can use a singleton
  586. // in the internal instance creation
  587. //----------------------------------------------------------------------
  588. class InprocActpropsUnmarshaller:public IMarshal
  589. {
  590. public:
  591. // Methods from IUnknown
  592. STDMETHOD (QueryInterface) ( REFIID riid, LPVOID* ppv)
  593. {
  594. if (IsEqualIID(riid, IID_IUnknown))
  595. *ppv = (IUnknown*) this;
  596. else
  597. if (IsEqualIID(riid, IID_IMarshal))
  598. *ppv = (IMarshal*) this;
  599. else
  600. return E_NOINTERFACE;
  601. return S_OK;
  602. }
  603. STDMETHOD_(ULONG,AddRef) ( void )
  604. {
  605. return 1;
  606. }
  607. STDMETHOD_(ULONG,Release) ( void )
  608. {
  609. return 1;
  610. }
  611. // Methods from IMarshal
  612. STDMETHOD (GetUnmarshalClass)(
  613. REFIID riid,
  614. void *pv,
  615. DWORD dwDestContext,
  616. void *pvDestContext,
  617. DWORD mshlflags,
  618. CLSID *pCid)
  619. {
  620. return E_NOTIMPL;
  621. }
  622. STDMETHOD (GetMarshalSizeMax)(
  623. REFIID riid,
  624. void *pv,
  625. DWORD dwDestContext,
  626. void *pvDestContext,
  627. DWORD mshlflags,
  628. DWORD *pSize)
  629. {
  630. return E_NOTIMPL;
  631. }
  632. STDMETHOD (MarshalInterface)(
  633. IStream *pStm,
  634. REFIID riid,
  635. void *pv,
  636. DWORD dwDestContext,
  637. void *pvDestContext,
  638. DWORD mshlflags)
  639. {
  640. return E_NOTIMPL;
  641. }
  642. STDMETHOD (UnmarshalInterface)(IStream *pStm,REFIID riid,void **ppv);
  643. STDMETHOD (ReleaseMarshalData)(IStream *pStm)
  644. {
  645. return E_NOTIMPL;
  646. }
  647. STDMETHOD (DisconnectObject)(DWORD dwReserved)
  648. {
  649. return E_NOTIMPL;
  650. }
  651. static InprocActpropsUnmarshaller *GetInstance()
  652. {
  653. return &_InprocActUnmarshaller;
  654. }
  655. private:
  656. InprocActpropsUnmarshaller()
  657. {
  658. }
  659. static InprocActpropsUnmarshaller _InprocActUnmarshaller;
  660. };
  661. //----------------------------------------------------------------------
  662. // Definitions of functions used for marshalling the above objects
  663. //----------------------------------------------------------------------
  664. extern HRESULT ActPropsMarshalHelper(IActivationProperties *pact,
  665. REFIID riid,
  666. DWORD destCtx,
  667. DWORD mshlflags,
  668. MInterfacePointer **ppIRD);
  669. extern HRESULT ActPropsUnMarshalHelper(IActivationProperties *pAct,
  670. MInterfacePointer *pIFP,
  671. REFIID riid,
  672. void **ppv
  673. );
  674. //----------------------------------------------------------------------
  675. // Miscellaneous helper functions
  676. //----------------------------------------------------------------------
  677. extern HRESULT LoadPersistentObject(IUnknown *, IInstanceInfo *);
  678. extern HRESULT GetIFDFromInterface(
  679. IUnknown *pUnk,
  680. REFIID riid,
  681. DWORD destCtx,
  682. DWORD mshlflags,
  683. MInterfacePointer **ppIRD);
  684. extern HRESULT ReleaseIFD(
  685. MInterfacePointer *pIRD);
  686. extern void *GetDestCtxPtr(COMVERSION *pComVersion);
  687. extern BOOL IsBrokenRefCount(CLSID *pClsId);
  688. #endif //__ACTPROPS_HXX__