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.

85 lines
2.1 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. cmemorystream.h
  5. Abstract:
  6. Minimal implementation of IStream over an array of bytes.
  7. Author:
  8. Jay Krell (a-JayK, JayKrell) May 2000
  9. Revision History:
  10. --*/
  11. #pragma once
  12. #include "objidl.h"
  13. #include "fusiontrace.h"
  14. class CMemoryStream : public IStream
  15. {
  16. public:
  17. CMemoryStream();
  18. BOOL Initialize(const BYTE*, const BYTE*);
  19. virtual ~CMemoryStream();
  20. // IUnknown methods:
  21. ULONG __stdcall AddRef();
  22. ULONG __stdcall Release();
  23. HRESULT __stdcall QueryInterface(REFIID riid, LPVOID *ppvObj);
  24. // ISequentialStream methods:
  25. HRESULT __stdcall Read(void *pv, ULONG cb, ULONG *pcbRead);
  26. HRESULT __stdcall Write(void const *pv, ULONG cb, ULONG *pcbWritten);
  27. // IStream methods:
  28. HRESULT __stdcall Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
  29. HRESULT __stdcall SetSize(ULARGE_INTEGER libNewSize);
  30. HRESULT __stdcall CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
  31. HRESULT __stdcall Commit(DWORD grfCommitFlags);
  32. HRESULT __stdcall Revert();
  33. HRESULT __stdcall LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  34. HRESULT __stdcall UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  35. HRESULT __stdcall Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  36. HRESULT __stdcall Clone(IStream **ppIStream);
  37. protected:
  38. LONG m_cRef;
  39. const BYTE *m_pbCurrent;
  40. const BYTE *m_pbBegin;
  41. const BYTE *m_pbEnd;
  42. private: // intentionally not implemented
  43. CMemoryStream(const CMemoryStream &r);
  44. CMemoryStream &operator =(const CMemoryStream &r);
  45. };
  46. inline
  47. CMemoryStream::CMemoryStream(
  48. )
  49. :
  50. m_cRef(0),
  51. m_pbCurrent(NULL),
  52. m_pbBegin(NULL),
  53. m_pbEnd(NULL)
  54. {
  55. }
  56. inline
  57. BOOL
  58. CMemoryStream::Initialize(
  59. const BYTE *pbBegin,
  60. const BYTE *pbEnd
  61. )
  62. {
  63. m_pbBegin = pbBegin;
  64. m_pbEnd = pbEnd;
  65. m_pbCurrent = pbBegin;
  66. return TRUE;
  67. }