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.

147 lines
3.3 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. ADAPREG.H
  5. Abstract:
  6. History:
  7. --*/
  8. // Use this guy to build a list of class objects we can retrieve via
  9. // class name. At this time, it just brute forces a class and a flex
  10. // array, but could be modified to use an STL map just as easily.
  11. #ifndef __ADAPREG_H__
  12. #define __ADAPREG_H__
  13. #include <wbemcomn.h>
  14. #include "ntreg.h"
  15. #include "adapcls.h"
  16. #define HKEY_PERFORMANCE_TEXT (( HKEY ) (ULONG_PTR)((LONG)0x80000050) )
  17. #define HKEY_PERFORMANCE_NLSTEXT (( HKEY ) (ULONG_PTR)((LONG)0x80000060) )
  18. //
  19. // common THROTTLING PARAMS
  20. //
  21. #define ADAP_IDLE_USER 3000
  22. #define ADAP_IDLE_IO 500000
  23. #define ADAP_LOOP_SLEEP 200
  24. #define ADAP_MAX_WAIT (2*60*1000)
  25. #define ADAP_LOCALE_KEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\PerfLib"
  26. #define WMI_ADAP_REVERSE_PERFLIB L"WMIAPRPL"
  27. #define ADAP_EVENT_MESSAGE_LENGTH 2048
  28. #define ADAP_EVENT_MESSAGE_PREFIX "An unhandled exception occured. The following performance libraries were processed: "
  29. #define ADAP_EVENT_MESSAGE_DELIM L", "
  30. // These are the various statuses we can set while ADAP is running
  31. typedef enum
  32. {
  33. eADAPStatusPending,
  34. eADAPStatusRunning,
  35. eADAPStatusProcessLibs,
  36. eADAPStatusCommit,
  37. eADAPStatusFinished
  38. } eADAPStatus;
  39. // HRESULT GetServicePID( WCHAR* wszService, DWORD* pdwPID );
  40. class CPerfLibList
  41. {
  42. WCHAR* m_wszPerfLibList;
  43. CRITICAL_SECTION m_csPerfLibList;
  44. public:
  45. CPerfLibList() : m_wszPerfLibList( NULL )
  46. {
  47. InitializeCriticalSection( &m_csPerfLibList );
  48. }
  49. ~CPerfLibList()
  50. {
  51. if ( NULL != m_wszPerfLibList )
  52. delete m_wszPerfLibList;
  53. DeleteCriticalSection( &m_csPerfLibList );
  54. }
  55. HRESULT AddPerfLib( WCHAR* wszPerfLib );
  56. HRESULT HandleFailure();
  57. };
  58. class CAdapRegPerf : public CNTRegistry
  59. ///////////////////////////////////////////////////////////////////////////////
  60. //
  61. // This is the control mechanism which interfaces with the
  62. //
  63. ///////////////////////////////////////////////////////////////////////////////
  64. {
  65. private:
  66. // The unified 'master' class lists for both the raw and the cooked classes
  67. // ========================================================================
  68. CMasterClassList* m_apMasterClassList[WMI_ADAP_NUM_TYPES];
  69. // The repository containing all names databases
  70. // =============================================
  71. CLocaleCache* m_pLocaleCache;
  72. // The winmgmt synchronization members
  73. // ===================================
  74. DWORD m_dwPID;
  75. HANDLE m_hSyncThread;
  76. HANDLE m_hTerminationEvent;
  77. BOOL m_fQuit;
  78. IWbemServices* m_pRootDefault;
  79. IWbemClassObject* m_pADAPStatus;
  80. // Registry change notification members
  81. // ====================================
  82. HKEY m_hPerflibKey;
  83. HANDLE m_hRegChangeEvent;
  84. //
  85. //
  86. CKnownSvcs * m_pKnownSvcs;
  87. BOOL m_bFull;
  88. // Private methods
  89. // ===============
  90. HRESULT ProcessLibrary( WCHAR* pwcsServiceName, BOOL bDelta );
  91. static unsigned int __stdcall GoGershwin( void * pParam );
  92. static LONG __stdcall AdapUnhandledExceptionFilter( LPEXCEPTION_POINTERS lpexpExceptionInfo );
  93. HRESULT GetADAPStatusObject( void );
  94. void SetADAPStatus( eADAPStatus status );
  95. void GetTime( LPWSTR Buff );
  96. public:
  97. CAdapRegPerf(BOOL bFull);
  98. ~CAdapRegPerf();
  99. HRESULT Initialize(BOOL bDelta, BOOL bThrottle);
  100. HRESULT Dredge( BOOL bDelta, BOOL bThrottle );
  101. static HRESULT Clean();
  102. };
  103. #endif