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.

146 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: filllkb.hxx
  7. //
  8. // Contents: CFillLockBytes class header
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 28-Dec-95 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __FILLLKB_HXX__
  18. #define __FILLLKB_HXX__
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CFillLockBytes
  22. //
  23. // Purpose:
  24. //
  25. // Interface:
  26. //
  27. // History: 28-Dec-95 PhilipLa Created
  28. //
  29. // Notes:
  30. //
  31. //----------------------------------------------------------------------------
  32. class CFillLockBytes: public ILockBytes,
  33. public IFillLockBytes
  34. #ifdef ASYNC
  35. , public IFillInfo
  36. #endif
  37. {
  38. public:
  39. CFillLockBytes(ILockBytes *pilb);
  40. ~CFillLockBytes();
  41. SCODE Init(void);
  42. // IUnknown
  43. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  44. STDMETHOD_(ULONG, AddRef)(void);
  45. STDMETHOD_(ULONG, Release)(void);
  46. // ILockBytes
  47. STDMETHOD(ReadAt)(ULARGE_INTEGER ulOffset,
  48. VOID HUGEP *pv,
  49. ULONG cb,
  50. ULONG *pcbRead);
  51. STDMETHOD(WriteAt)(ULARGE_INTEGER ulOffset,
  52. VOID const HUGEP *pv,
  53. ULONG cb,
  54. ULONG *pcbWritten);
  55. STDMETHOD(Flush)(void);
  56. STDMETHOD(SetSize)(ULARGE_INTEGER cb);
  57. STDMETHOD(LockRegion)(ULARGE_INTEGER libOffset,
  58. ULARGE_INTEGER cb,
  59. DWORD dwLockType);
  60. STDMETHOD(UnlockRegion)(ULARGE_INTEGER libOffset,
  61. ULARGE_INTEGER cb,
  62. DWORD dwLockType);
  63. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  64. //From IFillLockBytes
  65. STDMETHOD(FillAppend)(void const *pv,
  66. ULONG cb,
  67. ULONG *pcbWritten);
  68. STDMETHOD(FillAt)(ULARGE_INTEGER ulOffset,
  69. void const *pv,
  70. ULONG cb,
  71. ULONG *pcbWritten);
  72. STDMETHOD(SetFillSize)(ULARGE_INTEGER ulSize);
  73. STDMETHOD(Terminate)(BOOL bCanceled);
  74. //From IFillInfo
  75. STDMETHOD(GetFailureInfo)(ULONG *pulWaterMark, ULONG *pulFailurePoint);
  76. STDMETHOD(GetTerminationStatus)(DWORD *pdwFlags);
  77. #ifndef ASYNC
  78. HANDLE GetNotificationEvent(void);
  79. #endif
  80. #ifdef ASYNC
  81. inline void SetContext(CPerContext *ppc);
  82. #endif
  83. SCODE SetFailureInfo(ULONG ulWaterMark,ULONG ulFailurePoint);
  84. #if DBG==1
  85. void PulseFillEvent(void);
  86. #endif
  87. inline void TakeCriticalSection(void);
  88. inline void ReleaseCriticalSection(void);
  89. private:
  90. ILockBytes *_pilb;
  91. LONG _cRefs;
  92. ULONG _ulHighWater;
  93. DWORD _dwTerminate;
  94. ULONG _ulFailurePoint;
  95. #ifdef ASYNC
  96. CPerContext *_ppc;
  97. #else
  98. HANDLE _hNotifyEvent;
  99. #endif
  100. BOOL _fCSInitialized;
  101. CRITICAL_SECTION _csThreadProtect;
  102. };
  103. inline void CFillLockBytes::TakeCriticalSection(void)
  104. {
  105. EnterCriticalSection(&_csThreadProtect);
  106. }
  107. inline void CFillLockBytes::ReleaseCriticalSection(void)
  108. {
  109. LeaveCriticalSection(&_csThreadProtect);
  110. }
  111. #ifdef ASYNC
  112. inline void CFillLockBytes::SetContext(CPerContext *ppc)
  113. {
  114. _ppc = ppc;
  115. _ppc->AddRefSharedMem();
  116. if (_dwTerminate != UNTERMINATED)
  117. {
  118. if (_ppc->GetNotificationEvent() != INVALID_HANDLE_VALUE)
  119. SetEvent(_ppc->GetNotificationEvent());
  120. }
  121. }
  122. #endif
  123. #endif // #ifndef __FILLLKB_HXX__