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.

193 lines
5.3 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. ADAPPERF.H
  5. Abstract:
  6. History:
  7. --*/
  8. // Use this guy to build a map of index to display name from a localized
  9. // Name Database 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 __ADAPPERF_H__
  12. #define __ADAPPERF_H__
  13. #include <wbemcomn.h>
  14. #include "adapelem.h"
  15. #include "ntreg.h"
  16. #include "perfthrd.h"
  17. #include "perflibschema.h"
  18. // Registry definitions
  19. // ====================
  20. #define ADAP_PERFLIB_STATUS_KEY L"WbemAdapStatus"
  21. #define ADAP_PERFLIB_SIGNATURE L"WbemAdapFileSignature"
  22. #define ADAP_PERFLIB_SIZE L"WbemAdapFileSize"
  23. #define ADAP_PERFLIB_TIME L"WbemAdapFileTime"
  24. #define KNOWN_SERVICES L"KnownSvcs"
  25. #define ADAP_TIMESTAMP_FULL L"LastFullDredgeTimestamp"
  26. #define ADAP_PERFLIB_LASTCHANCE 3L
  27. #define ADAP_PERFLIB_BOOBOO 2L
  28. #define ADAP_PERFLIB_PROCESSING 1L
  29. #define ADAP_PERFLIB_OK 0L
  30. #define ADAP_PERFLIB_CORRUPT -1L
  31. // Run time definitions
  32. // ====================
  33. #define ADAP_PERFLIB_IS_OK 0x0000L
  34. #define ADAP_PERFLIB_IS_CORRUPT 0x0001L
  35. #define ADAP_PERFLIB_IS_INACTIVE 0x0002L
  36. #define ADAP_PERFLIB_FAILED 0x0004L
  37. #define ADAP_PERFLIB_PREVIOUSLY_PROCESSED 0x0008L
  38. #define ADAP_PERFLIB_IS_LOADED 0x0010L
  39. #define ADAP_PERFLIB_IS_UNAVAILABLE ADAP_PERFLIB_IS_CORRUPT | ADAP_PERFLIB_IS_INACTIVE // | ADAP_PERFLIB_IS_UNLOADED
  40. // others
  41. // the library has NO FirstCounter/LastCounter key
  42. #define EX_STATUS_UNLOADED 0
  43. // the library has al least FirstCounter/LastCounter key
  44. #define EX_STATUS_LOADABLE 1
  45. // the library has a Collect Function that fails
  46. #define EX_STATUS_COLLECTFAIL 2
  47. typedef struct tagCheckLibStruct {
  48. BYTE Signature[16];
  49. FILETIME FileTime;
  50. DWORD FileSize;
  51. } CheckLibStruct;
  52. class CAdapSafeBuffer
  53. {
  54. HANDLE m_hPerfLibHeap; // A handle to the private heap for the data block
  55. DWORD m_dwGuardSize;
  56. BYTE* m_pRawBuffer;
  57. BYTE* m_pSafeBuffer;
  58. DWORD m_dwSafeBufferSize;
  59. BYTE* m_pCurrentPtr;
  60. DWORD m_dwDataBlobSize;
  61. DWORD m_dwNumObjects;
  62. HRESULT ValidateSafePointer( BYTE* pPtr );
  63. WString m_wstrServiceName;
  64. static BYTE s_pGuardBytes[];
  65. public:
  66. CAdapSafeBuffer( WString wstrServiceName );
  67. virtual ~CAdapSafeBuffer();
  68. HRESULT SetSize( DWORD dwNumBytes );
  69. HRESULT Validate(BOOL * pSentToEventLog);
  70. HRESULT CopyData( BYTE** ppData, DWORD* pdwNumBytes, DWORD* pdwNumObjects );
  71. void** GetSafeBufferPtrPtr() { m_pCurrentPtr = m_pSafeBuffer; return (void**) &m_pCurrentPtr; }
  72. DWORD* GetDataBlobSizePtr() { m_dwDataBlobSize = m_dwSafeBufferSize; return &m_dwDataBlobSize; }
  73. DWORD* GetNumObjTypesPtr() {m_dwNumObjects = 0; return &m_dwNumObjects; }
  74. };
  75. class CPerfThread;
  76. class CPerfLibSchema;
  77. class CAdapPerfLib : public CAdapElement
  78. {
  79. private:
  80. CPerfThread* m_pPerfThread;
  81. BOOL m_EventLogCalled;
  82. BOOL m_CollectOK;
  83. WString m_wstrServiceName; // The service name of the perflib
  84. WCHAR* m_pwcsLibrary; // The file name of the perflib
  85. WCHAR* m_pwcsOpenProc; // The name of the perflib's open function
  86. WCHAR* m_pwcsCollectProc; // The name of the perflib's collect function
  87. WCHAR* m_pwcsCloseProc; // The name of the perflib's close function
  88. PM_OPEN_PROC* m_pfnOpenProc; // The function pointer to the perflib's open function
  89. PM_COLLECT_PROC* m_pfnCollectProc; // The function pointer to the perflib's collect function
  90. PM_CLOSE_PROC* m_pfnCloseProc; // The function pointer to the perflib's close function
  91. HANDLE m_hPLMutex; // Used for serializing the calls to open/collect/close
  92. HRESULT m_dwStatus; // The status of the perflib
  93. BOOL m_fOK;
  94. BOOL m_fOpen; // Flags whether the perflib's open function has been called
  95. HINSTANCE m_hLib; // The handle to the perflib
  96. DWORD m_dwFirstCtr;
  97. DWORD m_dwLastCtr;
  98. HRESULT Load(void);
  99. protected:
  100. HRESULT InitializeEntryPoints(CNTRegistry & reg,WString & wszRegPath);
  101. HRESULT BeginProcessingStatus();
  102. HRESULT EndProcessingStatus();
  103. HRESULT GetFileSignature( CheckLibStruct * pCheckLib );
  104. HRESULT SetFileSignature();
  105. HRESULT CheckFileSignature();
  106. HRESULT VerifyLoaded();
  107. public:
  108. CAdapPerfLib( LPCWSTR pwcsServiceName, DWORD * pLoadStatus );
  109. ~CAdapPerfLib();
  110. DWORD GetFirstCtr(){ return m_dwFirstCtr; };
  111. DWORD GetLastCtr(){ return m_dwLastCtr; }
  112. HRESULT _Open( void );
  113. HRESULT _Close( void );
  114. HRESULT _GetPerfBlock( PERF_OBJECT_TYPE** ppData, DWORD* pdwBytes, DWORD* pdwNumObjTypes, BOOL fCostly );
  115. HRESULT Initialize();
  116. HRESULT Close();
  117. HRESULT Cleanup();
  118. BOOL IsOK( void )
  119. {
  120. return m_fOK;
  121. }
  122. LPCWSTR GetServiceName( void )
  123. {
  124. return m_wstrServiceName;
  125. }
  126. LPCWSTR GetLibraryName( void )
  127. {
  128. return m_pwcsLibrary;
  129. }
  130. HRESULT GetBlob( PERF_OBJECT_TYPE** ppPerfBlock, DWORD* pdwNumBytes, DWORD* pdwNumObjects, BOOL fCostly );
  131. HRESULT SetStatus( DWORD dwStatus );
  132. HRESULT ClearStatus( DWORD dwStatus );
  133. BOOL CheckStatus( DWORD dwStatus );
  134. BOOL IsCollectOK( void ){ return m_CollectOK; };
  135. BOOL GetEventLogCalled(){ return m_EventLogCalled; };
  136. void SetEventLogCalled(BOOL bVal){ m_EventLogCalled = bVal; };
  137. static DWORD s_MaxSizeCollect;
  138. };
  139. #endif