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.

247 lines
7.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: expst.hxx
  7. //
  8. // Contents: CExposedStream definition
  9. //
  10. // Classes: CExposedStream
  11. //
  12. // Functions:
  13. //
  14. // History: 28-Feb-92 PhilipLa Created.
  15. //
  16. //--------------------------------------------------------------------------
  17. #ifndef __EXPST_HXX__
  18. #define __EXPST_HXX__
  19. #include <dfmsp.hxx>
  20. #include <debug.hxx>
  21. #include "lock.hxx"
  22. #include <dfmem.hxx>
  23. #include <pbstream.hxx>
  24. #include <mrshlist.hxx>
  25. #include <astgconn.hxx>
  26. class CPubStream;
  27. class CPubMappedStream;
  28. class CDFBasis;
  29. interface ILockBytes;
  30. class CSeekPointer;
  31. SAFE_DFBASED_PTR(CBasedSeekPointerPtr, CSeekPointer);
  32. //+--------------------------------------------------------------
  33. //
  34. // Class: CExposedStream (est)
  35. //
  36. // Purpose: Public stream interface
  37. //
  38. // Interface: See below
  39. //
  40. // History: 28-Feb-92 PhilipLa Created.
  41. //
  42. //---------------------------------------------------------------
  43. interface CExposedStream: public IStream, public IMarshal, public CMallocBased
  44. #ifdef NEWPROPS
  45. , public IMappedStream
  46. #endif
  47. #ifdef POINTER_IDENTITY
  48. , public CMarshalList
  49. #endif
  50. #ifdef ASYNC
  51. , public CAsyncConnectionContainer
  52. #endif
  53. {
  54. public:
  55. CExposedStream(void);
  56. SCODE Init(CPubStream *pst,
  57. CDFBasis *pdfb,
  58. CPerContext *ppc,
  59. CSeekPointer *psp);
  60. #ifdef ASYNC
  61. SCODE InitMarshal(CPubStream *pst,
  62. CDFBasis *pdfb,
  63. CPerContext *ppc,
  64. DWORD dwAsyncFlags,
  65. IDocfileAsyncConnectionPoint *pdacp,
  66. CSeekPointer *psp);
  67. #endif
  68. ~CExposedStream(void);
  69. // From IUnknown
  70. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  71. STDMETHOD_(ULONG,AddRef)(void);
  72. STDMETHOD_(ULONG,Release)(void);
  73. // IMarshal
  74. STDMETHOD(GetUnmarshalClass)(REFIID riid,
  75. LPVOID pv,
  76. DWORD dwDestContext,
  77. LPVOID pvDestContext,
  78. DWORD mshlflags,
  79. LPCLSID pCid);
  80. STDMETHOD(GetMarshalSizeMax)(REFIID riid,
  81. LPVOID pv,
  82. DWORD dwDestContext,
  83. LPVOID pvDestContext,
  84. DWORD mshlflags,
  85. LPDWORD pSize);
  86. STDMETHOD(MarshalInterface)(IStream *pStm,
  87. REFIID riid,
  88. LPVOID pv,
  89. DWORD dwDestContext,
  90. LPVOID pvDestContext,
  91. DWORD mshlflags);
  92. STDMETHOD(UnmarshalInterface)(IStream *pStm,
  93. REFIID riid,
  94. LPVOID *ppv);
  95. static SCODE StaticReleaseMarshalData(IStream *pstStm,
  96. DWORD mshlflags);
  97. STDMETHOD(ReleaseMarshalData)(IStream *pStm);
  98. STDMETHOD(DisconnectObject)(DWORD dwReserved);
  99. // New methods
  100. STDMETHOD(Read)(VOID HUGEP *pv,
  101. ULONG cb,
  102. ULONG *pcbRead);
  103. STDMETHOD(Write)(VOID const HUGEP *pv,
  104. ULONG cb,
  105. ULONG *pcbWritten);
  106. STDMETHOD(Seek)(LARGE_INTEGER dlibMove,
  107. DWORD dwOrigin,
  108. ULARGE_INTEGER *plibNewPosition);
  109. STDMETHOD(SetSize)(ULARGE_INTEGER cb);
  110. STDMETHOD(CopyTo)(IStream *pstm,
  111. ULARGE_INTEGER cb,
  112. ULARGE_INTEGER *pcbRead,
  113. ULARGE_INTEGER *pcbWritten);
  114. STDMETHOD(Commit)(DWORD grfCommitFlags);
  115. STDMETHOD(Revert)(void);
  116. STDMETHOD(LockRegion)(ULARGE_INTEGER libOffset,
  117. ULARGE_INTEGER cb,
  118. DWORD dwLockType);
  119. STDMETHOD(UnlockRegion)(ULARGE_INTEGER libOffset,
  120. ULARGE_INTEGER cb,
  121. DWORD dwLockType);
  122. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  123. STDMETHOD(Clone)(IStream **ppstm);
  124. // IMappedStream methods
  125. STDMETHODIMP_(VOID) Open(IN NTPROP np, OUT LONG *phr);
  126. STDMETHODIMP_(VOID) Close(OUT LONG *phr);
  127. STDMETHODIMP_(VOID) ReOpen(IN OUT VOID **ppv, OUT LONG *phr);
  128. STDMETHODIMP_(VOID) Quiesce(VOID);
  129. STDMETHODIMP_(VOID) Map(IN BOOLEAN fCreate, OUT VOID **ppv);
  130. STDMETHODIMP_(VOID) Unmap(IN BOOLEAN fFlush, IN OUT VOID **ppv);
  131. STDMETHODIMP_(VOID) Flush(OUT LONG *phr);
  132. STDMETHODIMP_(ULONG) GetSize(OUT LONG *phr);
  133. STDMETHODIMP_(VOID) SetSize(IN ULONG cb, IN BOOLEAN fPersistent, IN OUT VOID **ppv, OUT LONG *phr);
  134. STDMETHODIMP_(NTSTATUS) Lock(IN BOOLEAN fExclusive);
  135. STDMETHODIMP_(NTSTATUS) Unlock(VOID);
  136. STDMETHODIMP_(VOID) QueryTimeStamps(OUT STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const;
  137. STDMETHODIMP_(BOOLEAN) QueryModifyTime(OUT LONGLONG *pll) const;
  138. STDMETHODIMP_(BOOLEAN) QuerySecurity(OUT ULONG *pul) const;
  139. STDMETHODIMP_(BOOLEAN) IsWriteable(VOID) const;
  140. STDMETHODIMP_(BOOLEAN) IsModified(VOID) const;
  141. STDMETHODIMP_(VOID) SetModified(OUT LONG *phr);
  142. STDMETHODIMP_(HANDLE) GetHandle(VOID) const;
  143. #if DBG
  144. STDMETHODIMP_(BOOLEAN) SetChangePending(BOOLEAN fChangePending);
  145. STDMETHODIMP_(BOOLEAN) IsNtMappedStream(VOID) const;
  146. #endif
  147. inline CPubMappedStream & GetMappedStream(void) const;
  148. inline const CPubMappedStream & GetConstMappedStream(void) const;
  149. inline SCODE Validate(void) const;
  150. inline CPubStream *GetPub(void) const;
  151. static SCODE Unmarshal(IStream *pstm,
  152. void **ppv,
  153. DWORD mshlflags);
  154. private:
  155. SCODE CopyToWorker(IStream *pstm,
  156. ULARGE_INTEGER cb,
  157. ULARGE_INTEGER *pcbRead,
  158. ULARGE_INTEGER *pcbWritten,
  159. CSafeSem *pss);
  160. CBasedPubStreamPtr _pst;
  161. CBasedDFBasisPtr _pdfb;
  162. CPerContext *_ppc;
  163. ULONG _sig;
  164. LONG _cReferences;
  165. CBasedSeekPointerPtr _psp;
  166. #ifdef DIRECTWRITERLOCK
  167. HRESULT ValidateWriteAccess();
  168. #endif
  169. };
  170. SAFE_INTERFACE_PTR(SafeCExposedStream, CExposedStream);
  171. #define CEXPOSEDSTREAM_SIG LONGSIG('E', 'X', 'S', 'T')
  172. #define CEXPOSEDSTREAM_SIGDEL LONGSIG('E', 'x', 'S', 't')
  173. //+--------------------------------------------------------------
  174. //
  175. // Member: CExposedStream::Validate, public
  176. //
  177. // Synopsis: Validates the object signature
  178. //
  179. // Returns: Returns STG_E_INVALIDHANDLE for bad signatures
  180. //
  181. // History: 17-Mar-92 DrewB Created
  182. //
  183. //---------------------------------------------------------------
  184. inline SCODE CExposedStream::Validate(void) const
  185. {
  186. olChkBlocks((DBG_FAST));
  187. return (this == NULL || _sig != CEXPOSEDSTREAM_SIG) ?
  188. STG_E_INVALIDHANDLE : S_OK;
  189. }
  190. //+--------------------------------------------------------------
  191. //
  192. // Member: CExposedStream::GetPub, public
  193. //
  194. // Synopsis: Returns the public
  195. //
  196. // History: 28-Feb-92 DrewB Created
  197. //
  198. //---------------------------------------------------------------
  199. inline CPubStream *CExposedStream::GetPub(void) const
  200. {
  201. #ifdef MULTIHEAP
  202. // The tree mutex must be taken before calling this routine
  203. // CSafeMultiHeap smh(_ppc); // optimization
  204. #endif
  205. return BP_TO_P(CPubStream *, _pst);
  206. }
  207. #ifdef NEWPROPS
  208. inline CPubMappedStream & CExposedStream::GetMappedStream(void) const
  209. {
  210. return _pst->GetMappedStream();
  211. }
  212. inline const CPubMappedStream & CExposedStream::GetConstMappedStream(void) const
  213. {
  214. return _pst->GetConstMappedStream();
  215. }
  216. #endif
  217. #endif // #ifndef __EXPST_HXX__