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.

114 lines
2.7 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. #ifndef __BUFFER_H__
  8. #define __BUFFER_H__
  9. #include "corepol.h"
  10. /************************************************************************
  11. CBuffer
  12. *************************************************************************/
  13. class POLARITY CBuffer : public IStream
  14. {
  15. long m_cRefs;
  16. PBYTE m_pData;
  17. ULONG m_cData;
  18. ULONG m_iData;
  19. BOOL m_bDelete;
  20. void EnsureSize( ULONG ulSize );
  21. public:
  22. CBuffer( PBYTE pData=NULL, ULONG cData=0, BOOL bDelete=TRUE );
  23. CBuffer& operator= ( const CBuffer& );
  24. CBuffer( const CBuffer& );
  25. ~CBuffer();
  26. void Reset() { m_iData = 0; }
  27. ULONG GetIndex() { return m_iData; }
  28. ULONG GetSize() { return m_cData; }
  29. PBYTE GetRawData() { return m_pData; }
  30. HRESULT SetSize( ULONG ulSize )
  31. {
  32. ULARGE_INTEGER uliSize;
  33. uliSize.LowPart = ulSize;
  34. uliSize.HighPart = 0;
  35. return SetSize( uliSize );
  36. }
  37. HRESULT Advance( ULONG ulMove )
  38. {
  39. LARGE_INTEGER dlibMove;
  40. dlibMove.LowPart = ulMove;
  41. dlibMove.HighPart = 0;
  42. return Seek( dlibMove, STREAM_SEEK_CUR, NULL );
  43. }
  44. HRESULT ReadLPWSTR( LPCWSTR& rwszStr );
  45. HRESULT WriteLPWSTR( LPCWSTR wszStr );
  46. //
  47. // IUnknown
  48. //
  49. STDMETHOD_(ULONG, AddRef)();
  50. STDMETHOD_(ULONG, Release)();
  51. STDMETHOD(QueryInterface)(REFIID riid, void** ppv);
  52. //
  53. // ISequentialStream
  54. //
  55. STDMETHOD(Read)( void *pv, ULONG cb, ULONG *pcbRead );
  56. STDMETHOD(Write)( const void *pv, ULONG cb, ULONG *pcbWritten);
  57. //
  58. // IStream
  59. //
  60. STDMETHOD(Seek)( LARGE_INTEGER dlibMove,
  61. DWORD dwOrigin,
  62. ULARGE_INTEGER *plibNewPosition );
  63. STDMETHOD(SetSize)( ULARGE_INTEGER libNewSize );
  64. STDMETHOD(CopyTo)( IStream *pstm,
  65. ULARGE_INTEGER cb,
  66. ULARGE_INTEGER *pcbRead,
  67. ULARGE_INTEGER *pcbWritten );
  68. STDMETHOD(Commit)( DWORD grfCommitFlags ) { return E_NOTIMPL; }
  69. STDMETHOD(Revert)( void) { return E_NOTIMPL; }
  70. STDMETHOD(LockRegion)( ULARGE_INTEGER libOffset,
  71. ULARGE_INTEGER cb,
  72. DWORD dwLockType ) { return E_NOTIMPL; }
  73. STDMETHOD(UnlockRegion)( ULARGE_INTEGER libOffset,
  74. ULARGE_INTEGER cb,
  75. DWORD dwLockType ) { return E_NOTIMPL; }
  76. STDMETHOD(Stat)( STATSTG *pstatstg, DWORD grfStatFlag );
  77. STDMETHOD(Clone)( IStream **ppstm );
  78. };
  79. #endif __BUFFER_H__