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.

155 lines
4.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: dfunmfct.hxx
  7. //
  8. // Contents: OLE2 unmarshalling support for docfiles
  9. //
  10. // Classes: CDocfileUnmarshalFactory
  11. //
  12. // History: 25-Jan-93 DrewB Created
  13. //
  14. // Notes: Adapted from OLE2 dfmarshl.h and defcf.cpp
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __DFUNMFCT_HXX__
  18. #define __DFUNMFCT_HXX__
  19. #include <dfentry.hxx>
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Class: CDocfileUnmarshalFactory (dfuf)
  23. //
  24. // Purpose: Implements OLE2 unmarshalling support
  25. //
  26. // Interface: See below
  27. //
  28. // History: 25-Jan-93 DrewB Created
  29. //
  30. // Notes: This class is intended to be used statically
  31. // rather than dynamically with initialization being
  32. // deferred past construction to avoid unnecessary
  33. // initialization of static objects.
  34. // Init should be called to initialize in place of
  35. // a constructor.
  36. //
  37. //----------------------------------------------------------------------------
  38. #ifndef FLAT
  39. // C700 - C7 doesn't like long interface+method names
  40. #define CDocfileUnmarshalFactory CDFUF
  41. #endif
  42. class CDocfileUnmarshalFactory : public IMarshal, public IClassFactory
  43. {
  44. public:
  45. inline void *operator new(size_t size);
  46. inline void operator delete(void *pv);
  47. inline CDocfileUnmarshalFactory(void);
  48. // IUnknown
  49. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  50. STDMETHOD_(ULONG,AddRef)(void);
  51. STDMETHOD_(ULONG,Release)(void);
  52. // IMarshal
  53. STDMETHOD(GetUnmarshalClass)(REFIID riid,
  54. LPVOID pv,
  55. DWORD dwDestContext,
  56. LPVOID pvDestContext,
  57. DWORD mshlflags,
  58. LPCLSID pCid);
  59. STDMETHOD(GetMarshalSizeMax)(REFIID riid,
  60. LPVOID pv,
  61. DWORD dwDestContext,
  62. LPVOID pvDestContext,
  63. DWORD mshlflags,
  64. LPDWORD pSize);
  65. STDMETHOD(MarshalInterface)(IStream *pStm,
  66. REFIID riid,
  67. LPVOID pv,
  68. DWORD dwDestContext,
  69. LPVOID pvDestContext,
  70. DWORD mshlflags);
  71. STDMETHOD(UnmarshalInterface)(IStream *pStm,
  72. REFIID riid,
  73. LPVOID *ppv);
  74. STDMETHOD(ReleaseMarshalData)(IStream *pStm);
  75. STDMETHOD(DisconnectObject)(DWORD dwReserved);
  76. // IClassFactory
  77. STDMETHOD(CreateInstance)(IUnknown *pUnkOuter,
  78. REFIID riid,
  79. LPVOID *ppunkObject);
  80. STDMETHOD(LockServer)(BOOL fLock);
  81. // New methods
  82. inline SCODE Validate(void) const;
  83. private:
  84. inline LONG _AddRef(void);
  85. ULONG _sig;
  86. };
  87. #define CDOCFILEUNMARSHALFACTORY_SIG LONGSIG('D', 'F', 'U', 'F')
  88. #define CDOCFILEUNMARSHALFACTORY_SIGDEL LONGSIG('D', 'f', 'U', 'f')
  89. //+--------------------------------------------------------------
  90. //
  91. // Member: CDocfileUnmarshalFactory::Validate, public
  92. //
  93. // Synopsis: Validates the class signature
  94. //
  95. // Returns: Returns STG_E_INVALIDHANDLE for failure
  96. //
  97. // History: 25-Jan-93 DrewB Created
  98. //
  99. //---------------------------------------------------------------
  100. inline SCODE CDocfileUnmarshalFactory::Validate(void) const
  101. {
  102. return (this == NULL || _sig != CDOCFILEUNMARSHALFACTORY_SIG) ?
  103. STG_E_INVALIDHANDLE : S_OK;
  104. }
  105. //+---------------------------------------------------------------------------
  106. //
  107. // Member: CDocfileUnmarshalFactory::AddRef, private
  108. //
  109. // Synopsis: Increments the ref count
  110. //
  111. // History: 27-Jan-93 DrewB Created
  112. //
  113. // Notes: Currently does nothing because we don't maintain a ref count
  114. // This is present to make switching to a ref counted
  115. // implementation easy
  116. //
  117. //----------------------------------------------------------------------------
  118. inline LONG CDocfileUnmarshalFactory::_AddRef(void)
  119. {
  120. return 1;
  121. }
  122. //+---------------------------------------------------------------------------
  123. //
  124. // Member: CDocfileUnmarshalFactory::CDocfileUnmarshalFactory, public
  125. //
  126. // Synopsis: Constructor
  127. //
  128. // History: 27-Jan-93 DrewB Created
  129. //
  130. //----------------------------------------------------------------------------
  131. inline CDocfileUnmarshalFactory::CDocfileUnmarshalFactory(void)
  132. {
  133. _sig = CDOCFILEUNMARSHALFACTORY_SIG;
  134. }
  135. #endif // #ifndef __DFUNMFCT_HXX__