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.

137 lines
3.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: regevent.hxx
  7. //
  8. // Contents: Classes for tracking registry changes
  9. //
  10. // Classes: CRegNotifyKey
  11. // CRegChangeEvent
  12. // CRegNotify
  13. //
  14. // History: 04-Jul-94 DwightKr Created
  15. //
  16. //--------------------------------------------------------------------------
  17. #pragma once
  18. //+-------------------------------------------------------------------------
  19. //
  20. // Class: CRegNotifyKey
  21. //
  22. // Purpose: An encapsulation of a registry key name
  23. //
  24. // History: 07-Jun-94 DwightKr Created
  25. //
  26. //--------------------------------------------------------------------------
  27. class CRegNotifyKey
  28. {
  29. public:
  30. CRegNotifyKey( const WCHAR * wcsRegKey );
  31. protected:
  32. //
  33. // Name of key.
  34. //
  35. WCHAR _wcsKey[MAX_PATH];
  36. UNICODE_STRING _KeyName;
  37. OBJECT_ATTRIBUTES _ObjectAttr;
  38. };
  39. //+-------------------------------------------------------------------------
  40. //
  41. // Class: CRegChangeEvent
  42. //
  43. // Purpose: Sets up basic functionality of waiting on a registry change event
  44. //
  45. // History: 07-Jun-94 DwightKr Created
  46. //
  47. //--------------------------------------------------------------------------
  48. class CRegChangeEvent : public CRegNotifyKey
  49. {
  50. public:
  51. CRegChangeEvent( const WCHAR * wcsRegKey, BOOL fDeferInit = FALSE );
  52. ~CRegChangeEvent();
  53. const HANDLE GetEventHandle() const { return _regEvent.GetHandle(); }
  54. const WCHAR * GetKeyName() const { return _wcsKey; }
  55. void Reset();
  56. void Register();
  57. void Init();
  58. private:
  59. HANDLE _hKey;
  60. IO_STATUS_BLOCK _IoStatus;
  61. CEventSem _regEvent;
  62. BOOL _fDeferInit;
  63. BOOL _fNotifyEnabled;
  64. };
  65. //+-------------------------------------------------------------------------
  66. //
  67. // Class: CRegNotify
  68. //
  69. // Purpose: APC based version of CRegChangeEvent
  70. //
  71. // History: 20-Feb-96 KyleP Created
  72. // 16 Dec 97 AlanW Fixed race in Register/DisableNotification
  73. //
  74. //--------------------------------------------------------------------------
  75. class CRegNotify : public CRegNotifyKey
  76. {
  77. public:
  78. CRegNotify( const WCHAR * wcsRegKey );
  79. void DisableNotification();
  80. virtual void DoIt() = 0;
  81. protected:
  82. virtual ~CRegNotify();
  83. private:
  84. //
  85. // Refcounting
  86. //
  87. void AddRef();
  88. void Release();
  89. void Register();
  90. static void WINAPI APC( void * ApcContext,
  91. IO_STATUS_BLOCK * IoStatusBlock,
  92. ULONG Reserved );
  93. //
  94. // this is necessary so that if shutdown is called while processing an APC
  95. // just before re-registering, DisableNotification to forbid Register from
  96. // re-opening the key.
  97. //
  98. BOOL _fShutdown;
  99. long _refCount;
  100. HANDLE _hKey;
  101. IO_STATUS_BLOCK _IoStatus;
  102. CMutexSem _mtx;
  103. };