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.

156 lines
4.8 KiB

  1. /*==========================================================================*\
  2. Module: exprfdll.h
  3. Copyright Microsoft Corporation 1998, All Rights Reserved.
  4. Author: WayneC
  5. Descriptions: This is the declaration for exprfdll, a perf dll. This
  6. is for the dll that runs in perfmon. It supports multiple
  7. libraries (monitored services.)
  8. \*==========================================================================*/
  9. #ifndef _exprfdll_h_
  10. #define _exprfdll_h_
  11. #include "snprflib.h"
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //
  14. // Misc defines
  15. //
  16. ///////////////////////////////////////////////////////////////////////////////
  17. #define DWORD_MULTIPLE(x) (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
  18. #define QWORD_MULTIPLE(x) (((x+sizeof(QWORD)-1)/sizeof(QWORD))*sizeof(QWORD))
  19. #define MAX_PERF_LIBS 8
  20. #define DIGIT 1
  21. #define DELIMITER 2
  22. #define INVALID 3
  23. #define QUERY_GLOBAL 1
  24. #define QUERY_ITEMS 2
  25. #define QUERY_FOREIGN 3
  26. #define QUERY_COSTLY 4
  27. ///////////////////////////////////////////////////////////////////////////////
  28. //
  29. // Declare utility functions
  30. //
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // Figure out the query type of the perf request
  34. //
  35. DWORD GetQueryType (LPWSTR lpValue);
  36. //
  37. // Determines if a number is in a space delimited unicode string.
  38. // this is used to parse the request to see which object counters are
  39. // asked for.
  40. //
  41. BOOL IsNumberInUnicodeList (DWORD dwNumber, LPCWSTR lpwszUnicodeList);
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //
  44. // PerfObjectData defines the data retrieved from the shared memory for
  45. // each perf object exposed by a library (see PerfLibraryData below)
  46. //
  47. ///////////////////////////////////////////////////////////////////////////////
  48. class PerfObjectData
  49. {
  50. private:
  51. //
  52. // Internal variables
  53. //
  54. BOOL m_fObjectRequested;
  55. DWORD m_dwSpaceNeeded;
  56. //
  57. // These are pointers to things inside the shared memory...
  58. //
  59. // First the object definition
  60. PERF_OBJECT_TYPE* m_pObjType;
  61. // Array of counter defintions
  62. PERF_COUNTER_DEFINITION* m_prgCounterDef;
  63. // Pointer to a dword that tells the size of the counter data
  64. // (PERF_COUNTER_BLOCK + all the counter values)
  65. DWORD* m_pdwCounterData;
  66. // The following point to the actual data for the counters...
  67. // use pCounterBlock for numInst == -1, else use m_pbCounterBlockTotal for
  68. // the first instanced counters (_Total)
  69. PERF_COUNTER_BLOCK* m_pCounterBlock;
  70. PBYTE m_pbCounterBlockTotal;
  71. // This points to the first shared memory mapping.
  72. SharedMemorySegment* m_pSMS;
  73. // These tell us how many instances can be stored in each mapping.
  74. DWORD m_dwInstancesPerMapping;
  75. DWORD m_dwInstances1stMapping;
  76. // This is the length of the object definition in the first mapping.
  77. DWORD m_dwDefinitionLength;
  78. // Keep the object name around to create more named mappings when needed.
  79. WCHAR m_wszObjectName[MAX_OBJECT_NAME];
  80. public:
  81. PerfObjectData();
  82. ~PerfObjectData();
  83. BOOL GetPerformanceStatistics (LPCWSTR pcwstrObjectName);
  84. DWORD SpaceNeeded (DWORD, LPCWSTR pcwstrObjects);
  85. void SavePerformanceData (VOID**, DWORD*, DWORD*);
  86. void CopyInstanceData(PBYTE pb, INSTANCE_DATA *pInst);
  87. void AddToTotal (
  88. PERF_COUNTER_BLOCK *pcbTotalCounter,
  89. PERF_COUNTER_BLOCK *pcbInstCounter);
  90. void Close (void);
  91. };
  92. ///////////////////////////////////////////////////////////////////////////////
  93. //
  94. // PerfLibraryData is data from the shared memory about a single perf library.
  95. //
  96. ///////////////////////////////////////////////////////////////////////////////
  97. class PerfLibraryData
  98. {
  99. private:
  100. //
  101. // Handle and pointer for the shared memory
  102. //
  103. HANDLE m_hShMem;
  104. PBYTE m_pbShMem;
  105. // Data from the shared memory
  106. DWORD m_dwObjects;
  107. OBJECTNAME* m_prgObjectNames;
  108. // Data for each of the objects exposed by the library
  109. PerfObjectData m_rgObjectData[MAX_PERF_OBJECTS];
  110. public:
  111. // Methods for dealing with the library data
  112. PerfLibraryData();
  113. ~PerfLibraryData();
  114. BOOL GetPerformanceStatistics (LPCWSTR pcwstrLibrary);
  115. DWORD SpaceNeeded (DWORD, LPCWSTR pcwstrObjects);
  116. void SavePerformanceData (VOID**, DWORD*, DWORD*);
  117. void Close (void);
  118. };
  119. #endif