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.

83 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 2000 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) 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 CMemoryStream::CMemoryStream(
  47. )
  48. :
  49. m_cRef(0),
  50. m_pbCurrent(NULL),
  51. m_pbBegin(NULL),
  52. m_pbEnd(NULL)
  53. {
  54. }
  55. inline BOOL
  56. CMemoryStream::Initialize(
  57. const BYTE *pbBegin,
  58. const BYTE *pbEnd
  59. )
  60. {
  61. m_pbBegin = pbBegin;
  62. m_pbEnd = pbEnd;
  63. m_pbCurrent = pbBegin;
  64. return TRUE;
  65. }