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.

220 lines
6.0 KiB

  1. #ifndef _PCLIB_H_
  2. #define _PCLIB_H_
  3. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. //
  5. // PCLIB.H
  6. //
  7. // Public interface to PCLIB to be used by perf counter data
  8. // generating and monitoring components.
  9. //
  10. // Copyright 1986-1998 Microsoft Corporation, All Rights Reserved
  11. //
  12. //
  13. // A signature that uniquely identifies the component whose perf counters are
  14. // being implemented. This must be identical to the value of the drivername
  15. // key in the [info] section of the perf counter INI file. It is used to
  16. // locate the counters' "first counter" information in the registry.
  17. //
  18. EXTERN_C const WCHAR gc_wszSignature[];
  19. // ************************************************************************
  20. //
  21. // INTERFACE for counter data generating processes
  22. //
  23. // ========================================================================
  24. //
  25. // CLASS IPerfCounterBlock
  26. //
  27. // Created by IPerfObject::NewInstance(). A perf counter block
  28. // encapsulates the set of counters for a given instance. The
  29. // methods of this interface define the mechanism for changing
  30. // the values of the counters in the counter block.
  31. //
  32. class IPerfCounterBlock
  33. {
  34. public:
  35. // CREATORS
  36. //
  37. virtual ~IPerfCounterBlock() = 0;
  38. // MANIPULATORS
  39. //
  40. virtual VOID IncrementCounter( UINT iCounter ) = 0;
  41. virtual VOID DecrementCounter( UINT iCounter ) = 0;
  42. virtual VOID SetCounter( UINT iCounter, LONG lValue ) = 0;
  43. };
  44. // ========================================================================
  45. //
  46. // CLASS IPerfObject
  47. //
  48. // Created by PCLIB::NewPerfObject(). A perf object defines a set of
  49. // counters. In terms of the NT perf counter structures, a perf object
  50. // encapsulates a PERF_OBJECT_TYPE and its PERF_COUNTER_DEFINITIONs.
  51. //
  52. // IPerfObject::NewInstance() creates a new instance of this perf object
  53. // from a PERF_INSTANCE_DEFINITION and a PERF_COUNTER_BLOCK. All values
  54. // of both structures must be properly initialized prior to calling
  55. // IPerfObject::NewInstance() following standard conventions for these
  56. // structures. I.e. the instance name must immediately follow the
  57. // PERF_INSTANCE_DEFINITION structure, and the PERF_COUNTER_BLOCK must
  58. // be DWORD-aligned following the name. The PERF_COUNTER_BLOCK should
  59. // be followed by the counters themselves. Read the documentation for
  60. // these structures if you're confused.
  61. //
  62. class IPerfObject
  63. {
  64. public:
  65. // CREATORS
  66. //
  67. virtual ~IPerfObject() = 0;
  68. // MANIPULATORS
  69. //
  70. virtual IPerfCounterBlock *
  71. NewInstance( const PERF_INSTANCE_DEFINITION& pid,
  72. const PERF_COUNTER_BLOCK& pcb ) = 0;
  73. };
  74. // ========================================================================
  75. //
  76. // NAMESPACE PCLIB
  77. //
  78. // The top level of the PCLIB interface. PCLIB::FInitialize() should be
  79. // called once per process to initialize the library. Similarly,
  80. // PCLIB::Deinitialize() should be called once per process to deinitialize
  81. // it. NOTE: To simplify your error code cleanup, it is safe to call
  82. // PCLIB::Deinitialize() even if you did not call PCLIB::FInitialize().
  83. //
  84. // PCLIB::NewPerfObject() creates a new perf object from a
  85. // PERF_OBJECT_TYPE and subsequent PERF_COUNTER_DEFINITIONs. All values
  86. // of both structures must be properly initialized prior to calling
  87. // PCLIB::NewPerfObject() following standard conventions for these
  88. // structures, with one exception: PERF_OBJECT_TYPE::NumInstances and
  89. // PERF_OBJECT_TYPE::TotalByteLength should both be initialized to 0.
  90. // These values are computed in the monitor process because the number
  91. // of instances is not generally fixed at the time the object is created.
  92. //
  93. namespace PCLIB
  94. {
  95. //
  96. // Initialization/Deinitialization
  97. //
  98. BOOL __fastcall FInitialize( LPCWSTR lpwszSignature );
  99. VOID __fastcall Deinitialize();
  100. //
  101. // Instance registration
  102. //
  103. IPerfObject * __fastcall NewPerfObject( const PERF_OBJECT_TYPE& pot );
  104. };
  105. // ========================================================================
  106. //
  107. // CLASS CPclibInit
  108. //
  109. // PCLIB initializer class. Simplifies PCLIB initialization and
  110. // deinitialization.
  111. //
  112. class CPclibInit
  113. {
  114. // NOT IMPLEMENTED
  115. //
  116. CPclibInit& operator=( const CPclibInit& );
  117. CPclibInit( const CPclibInit& );
  118. public:
  119. CPclibInit()
  120. {
  121. }
  122. BOOL FInitialize( LPCWSTR lpwszSignature )
  123. {
  124. return PCLIB::FInitialize( lpwszSignature );
  125. }
  126. ~CPclibInit()
  127. {
  128. PCLIB::Deinitialize();
  129. }
  130. };
  131. // ************************************************************************
  132. //
  133. // INTERFACE for counter monitors
  134. //
  135. // ------------------------------------------------------------------------
  136. //
  137. // The interface for monitors *IS* the perfmon interface!
  138. // Just define these as EXPORTS for your monitor DLL and you're done.
  139. //
  140. EXTERN_C BOOL WINAPI
  141. FDllEntry( HINSTANCE hinst,
  142. DWORD dwReason,
  143. LPVOID lpvReserved );
  144. EXTERN_C DWORD APIENTRY
  145. OpenPerformanceData( LPCWSTR );
  146. EXTERN_C DWORD APIENTRY
  147. CollectPerformanceData( LPCWSTR lpwszCounterIndices,
  148. LPVOID * plpvPerfData,
  149. LPDWORD lpdwcbPerfData,
  150. LPDWORD lpcObjectTypes );
  151. EXTERN_C DWORD APIENTRY
  152. ClosePerformanceData();
  153. EXTERN_C STDAPI
  154. DllRegisterServer(VOID);
  155. EXTERN_C STDAPI
  156. DllUnregisterServer(VOID);
  157. // ------------------------------------------------------------------------
  158. //
  159. // Or, for the do-it-yourself'er....
  160. //
  161. // Step 1) Initialize shared memory (see inc\smh.h)
  162. // Step 2) Call NewCounterPublisher() or NewCounterMonitor() (depending
  163. // on which you are!) passing in the string you used in Step 1.
  164. //
  165. class ICounterData
  166. {
  167. protected:
  168. // CREATORS
  169. // Only create this object through it's descendents!
  170. //
  171. ICounterData() {};
  172. public:
  173. // CREATORS
  174. //
  175. virtual ~ICounterData() = 0;
  176. // MANIPULATORS
  177. //
  178. virtual IPerfObject *
  179. CreatePerfObject( const PERF_OBJECT_TYPE& pot ) = 0;
  180. virtual DWORD
  181. DwCollectData( LPCWSTR lpwszCounterIndices,
  182. DWORD dwFirstCounter,
  183. LPVOID * plpvPerfData,
  184. LPDWORD lpdwcbPerfData,
  185. LPDWORD lpcObjectTypes ) = 0;
  186. };
  187. ICounterData * __fastcall
  188. NewCounterPublisher( LPCWSTR lpwszSignature );
  189. ICounterData * __fastcall
  190. NewCounterMonitor( LPCWSTR lpwszSignature );
  191. #endif // !defined(_PCLIB_H_)