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.

129 lines
5.7 KiB

  1. // --------------------------------------------------------------------------------
  2. // Stmlock.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #ifndef __STMLOCK_H
  7. #define __STMLOCK_H
  8. // -----------------------------------------------------------------------------
  9. // IID_CStreamLockBytes - {62A83701-52A2-11d0-8205-00C04FD85AB4}
  10. // -----------------------------------------------------------------------------
  11. DEFINE_GUID(IID_CStreamLockBytes, 0x62a83701, 0x52a2, 0x11d0, 0x82, 0x5, 0x0, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);
  12. // -----------------------------------------------------------------------------
  13. // CStreamLockBytes
  14. // -----------------------------------------------------------------------------
  15. class CStreamLockBytes : public ILockBytes
  16. {
  17. public:
  18. // -------------------------------------------------------------------------
  19. // Construction
  20. // -------------------------------------------------------------------------
  21. CStreamLockBytes(IStream *pStream);
  22. ~CStreamLockBytes(void);
  23. // -------------------------------------------------------------------------
  24. // IUnknown
  25. // -------------------------------------------------------------------------
  26. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  27. STDMETHODIMP_(ULONG) AddRef(void);
  28. STDMETHODIMP_(ULONG) Release(void);
  29. // -------------------------------------------------------------------------
  30. // ILockBytes methods
  31. // -------------------------------------------------------------------------
  32. STDMETHODIMP Flush(void);
  33. STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  34. #ifndef WIN16
  35. STDMETHODIMP ReadAt(ULARGE_INTEGER ulOffset, void *pv, ULONG cb, ULONG *pcbRead);
  36. #else
  37. STDMETHODIMP ReadAt(ULARGE_INTEGER ulOffset, void HUGEP *pv, ULONG cb, ULONG *pcbRead);
  38. #endif // !WIN16
  39. STDMETHODIMP SetSize(ULARGE_INTEGER cb);
  40. STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  41. STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  42. #ifndef WIN16
  43. STDMETHODIMP WriteAt(ULARGE_INTEGER ulOffset, void const *pv, ULONG cb, ULONG *pcbWritten);
  44. #else
  45. STDMETHODIMP WriteAt(ULARGE_INTEGER ulOffset, void const HUGEP *pv, ULONG cb, ULONG *pcbWritten);
  46. #endif // !WIN16
  47. // -------------------------------------------------------------------------
  48. // CStreamLockBytes
  49. // -------------------------------------------------------------------------
  50. void ReplaceInternalStream(IStream *pStream);
  51. HRESULT HrHandsOffStorage(void);
  52. HRESULT HrSetPosition(ULARGE_INTEGER uliOffset);
  53. void GetCurrentStream(IStream **ppStream);
  54. private:
  55. // -------------------------------------------------------------------------
  56. // Private Data
  57. // -------------------------------------------------------------------------
  58. LONG m_cRef; // Ref count
  59. IStream *m_pStream; // Protected stream
  60. CRITICAL_SECTION m_cs; // Critical Section for m_pStream
  61. };
  62. // -----------------------------------------------------------------------------
  63. // CLockedStream
  64. // -----------------------------------------------------------------------------
  65. class CLockedStream : public IStream
  66. {
  67. public:
  68. // -------------------------------------------------------------------------
  69. // Construction
  70. // -------------------------------------------------------------------------
  71. CLockedStream(ILockBytes *pLockBytes, ULONG cbSize);
  72. ~CLockedStream(void);
  73. // -------------------------------------------------------------------------
  74. // IUnknown
  75. // -------------------------------------------------------------------------
  76. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  77. STDMETHODIMP_(ULONG) AddRef(void);
  78. STDMETHODIMP_(ULONG) Release(void);
  79. // -------------------------------------------------------------------------
  80. // IStream
  81. // -------------------------------------------------------------------------
  82. #ifndef WIN16
  83. STDMETHODIMP Read(LPVOID, ULONG, ULONG *);
  84. #else
  85. STDMETHODIMP Read(VOID HUGEP *, ULONG, ULONG *);
  86. #endif // !WIN16
  87. STDMETHODIMP Seek(LARGE_INTEGER, DWORD, ULARGE_INTEGER *);
  88. STDMETHODIMP Stat(STATSTG *, DWORD);
  89. #ifndef WIN16
  90. STDMETHODIMP Write(const void *, ULONG, ULONG *) {
  91. #else
  92. STDMETHODIMP Write(const void HUGEP *, ULONG, ULONG *) {
  93. #endif // !WIN16
  94. return TrapError(STG_E_ACCESSDENIED); }
  95. STDMETHODIMP SetSize(ULARGE_INTEGER) {
  96. return E_NOTIMPL; }
  97. STDMETHODIMP CopyTo(LPSTREAM, ULARGE_INTEGER, ULARGE_INTEGER *, ULARGE_INTEGER *);
  98. STDMETHODIMP Commit(DWORD) {
  99. return E_NOTIMPL; }
  100. STDMETHODIMP Revert(void) {
  101. return E_NOTIMPL; }
  102. STDMETHODIMP LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) {
  103. return E_NOTIMPL; }
  104. STDMETHODIMP UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) {
  105. return E_NOTIMPL; }
  106. STDMETHODIMP Clone(LPSTREAM *) {
  107. return E_NOTIMPL; }
  108. private:
  109. // -------------------------------------------------------------------------
  110. // Private Data
  111. // -------------------------------------------------------------------------
  112. LONG m_cRef; // Reference count
  113. ILockBytes *m_pLockBytes; // Protected data stream
  114. ULARGE_INTEGER m_uliOffset; // 64bit Addressable internal lockbyte space
  115. ULARGE_INTEGER m_uliSize; // Size of internal lockbytes
  116. CRITICAL_SECTION m_cs; // Critical Section for m_pStream
  117. };
  118. #endif // __STMLOCK_H