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.

184 lines
5.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1998
  5. //
  6. // File: FatNot.hxx
  7. //
  8. // Contents: Downlevel notification.
  9. //
  10. // Classes: CGenericNotify
  11. //
  12. // History: 2-23-96 KyleP Lifed from DLNotify.?xx
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. class CImpersonateRemoteAccess;
  17. class PCatalog;
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Class: CGenericNotify
  21. //
  22. // Purpose: A single scope to watch for notifications.
  23. //
  24. // History: 1-17-96 srikants Created
  25. //
  26. //----------------------------------------------------------------------------
  27. class CGenericNotify : public CDoubleLink
  28. {
  29. //
  30. // size of the buffer used for retrieving notifications. Too small
  31. // a buffer can cause overflows requiring expensive full scans of the
  32. // scope.
  33. //
  34. enum { CB_NOTIFYBUFFER = 32 * 1024,
  35. CB_REMOTENOTIFYBUFFER = 64 * 1024, // start big
  36. CB_DELTAINCR = 4 * 1024,
  37. CB_MAXSIZE = 64 * 1024 };
  38. friend class CRemoteNotifications;
  39. friend class CStartRemoteNotifications;
  40. friend class COpenRemoteNotifications;
  41. public:
  42. //
  43. // Constructors, Destructors, and Initializers
  44. //
  45. CGenericNotify( PCatalog * pCatalog,
  46. WCHAR const * wcsScope,
  47. unsigned cwcScope,
  48. BOOL fDeep = TRUE,
  49. BOOL fLogEvents = FALSE );
  50. virtual ~CGenericNotify();
  51. //
  52. // The magic API
  53. //
  54. virtual void DoIt() = 0;
  55. virtual void ClearNotifyEnabled()
  56. {
  57. //
  58. // override if necessary to set the flag. MUST be done under some
  59. // kind of lock to prevent races.
  60. //
  61. }
  62. //
  63. // Refcounting
  64. //
  65. void AddRef();
  66. void Release();
  67. //
  68. // Member variable access
  69. //
  70. WCHAR const * GetScope() const { return _wcsScope; }
  71. unsigned ScopeLength() const { return _cwcScope; }
  72. BOOL LokIsNotifyEnabled() const { return _fNotifyActive; }
  73. void LokClearNotifyEnabled() { _fNotifyActive = FALSE; }
  74. void LokStartIf()
  75. {
  76. if ( !_fNotifyActive )
  77. StartNotification();
  78. }
  79. void LokEnableIf()
  80. {
  81. if ( 0 == _hNotify )
  82. {
  83. EnableNotification();
  84. }
  85. else if ( !_fNotifyActive )
  86. {
  87. StartNotification();
  88. }
  89. }
  90. protected:
  91. void StartNotification( NTSTATUS * pStatus = 0 );
  92. void EnableNotification();
  93. void DisableNotification();
  94. BYTE * GetBuf() { return _pbBuffer; }
  95. unsigned BufLength() { return (unsigned)_iosNotify.Information; }
  96. BOOL BufferOverflow() { return _fOverflow; }
  97. void LogNoNotifications( DWORD dwError ) const;
  98. void LogNotificationsFailed( DWORD dwError ) const;
  99. void LogDfsShare() const;
  100. const BOOL _fLogEvents; // Set to TRUE if events should be logged on
  101. // serious failures.
  102. BOOL _fAbort; // Set to TRUE when an abort is in
  103. // progress.
  104. PCatalog * GetCatalog() { return _pCat; }
  105. static BOOL IsDfsShare( WCHAR const * wszPath, ULONG len );
  106. static BOOL IsFixedDrive( WCHAR const * wszPath, ULONG len );
  107. # ifdef CIEXTMODE
  108. void CiExtDump(void *ciExtSelf) const;
  109. # endif
  110. private:
  111. static void WINAPI APC( void * ApcContext,
  112. IO_STATUS_BLOCK * IoStatusBlock,
  113. ULONG Reserved );
  114. void AdjustForOverflow();
  115. NTSTATUS OpenDirectory( OBJECT_ATTRIBUTES & objAttr );
  116. void CloseDirectory();
  117. static DWORD GetNotifyFlags()
  118. {
  119. return FILE_NOTIFY_CHANGE_FILE_NAME |
  120. FILE_NOTIFY_CHANGE_DIR_NAME |
  121. FILE_NOTIFY_CHANGE_SIZE |
  122. FILE_NOTIFY_CHANGE_LAST_WRITE |
  123. FILE_NOTIFY_CHANGE_ATTRIBUTES |
  124. FILE_NOTIFY_CHANGE_SECURITY;
  125. }
  126. long _refCount;
  127. PCatalog * _pCat;
  128. WCHAR _wcsScope[MAX_PATH]; // Notification scope
  129. ULONG _cwcScope; // Length of the path - for quick compare
  130. BOOL _fNotifyActive; // Set to TRUE if notifications are active
  131. BOOL _fDeep; // Set to TRUE if deep scope notifications
  132. // are being used
  133. BOOL _fRemoteDrive; // Set to TRUE if this is a remote
  134. // drive.
  135. // NtIoApi related data members
  136. HANDLE _hNotify; // Handle of the root for notifications
  137. IO_STATUS_BLOCK _iosNotify;
  138. BOOL _fOverflow; // TRUE if notification overflowed buffer
  139. unsigned _cbBuffer; // Size of buffer in use (smaller for net drives)
  140. BYTE * _pbBuffer; // Buffer for storing the notifications
  141. };