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.

144 lines
5.1 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999 - 2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: perfinfo.h
  6. * Content: Performance tracking related code
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * ??-??-???? rodtoll Created
  12. * 12-12-2000 rodtoll Re-organize performance struct to handle data misalignment errors on IA64
  13. *
  14. ***************************************************************************/
  15. #ifndef __PERFINFO_H
  16. #define __PERFINFO_H
  17. //
  18. // This library provides support for exporting performance information from an application/DLL.
  19. //
  20. // An application can register will this library to be given a global memory block that other
  21. // processes can read. The application writes to the global memory block created by this
  22. // library. Applications wishing to retrieve performance data can retrieve a list of
  23. // applications who are using the library and optionally gain access to the performance
  24. // data from within their own process.
  25. //
  26. // The format of the central memory block is as follows:
  27. // <PERF_HEADER>
  28. // <PERF_APPLICATION> (For app 0)
  29. // <PERF_APPLICATION> (For app 1)
  30. // ...
  31. //
  32. // The # of applications which can track performance data is limited to PERF_INSTANCE_BLOCK_MAXENTRIES
  33. // which is defined in the perfinfo.cpp file.
  34. //
  35. // Applications must tell this library how large a performance data block they want. The format of the
  36. // data within the block is application specific, so applications must have knowledge of the format to
  37. // use it.
  38. //
  39. // Each process must make sure to call PERF_Initialize() in their process to enable access and must call
  40. // PERF_DeInitialize to cleanup.
  41. //
  42. // Each element of the array of PERF_APPLICATION structures contains a flag field, if an entry is in use
  43. // it will have the PERF_APPLICATION_VALID flag set. When an application removes themselves this flag
  44. // is cleared and the entry may be re-used. (However, all of this should be done through the
  45. // functions in this library).
  46. //
  47. // Everytime an element is added or removed the table is checked for entries left behind by dead processes.
  48. // If an entry exists for a process that has exited then it is removed from the table automatically.
  49. //
  50. // WARNING: Remember for 32/64bit interop you must ensure that the PERF_APPLICATION and PERF_HEADER are
  51. // quadword aligned.
  52. //
  53. // Applications CAN have multiple entries in a single process. You must insure that guidInternalInstance
  54. // is unique amoung all the entries.
  55. //
  56. // PERF_HEADER
  57. //
  58. // This structure is placed at the head of the central memory block.
  59. //
  60. typedef struct _PERF_HEADER
  61. {
  62. LONG lNumEntries; // # of entries in the central memory block
  63. DWORD dwPack; // Alignment DWORD to ensure quadword alignment.
  64. } PERF_HEADER, *PPERF_HEADER;
  65. // PERF_APPLICATION_INFO
  66. //
  67. // This structure is used to track instance specific information. So applications who add an
  68. // entry into the global perf information table will have to store a copy of this structure
  69. // that they get from the call to PERF_AddEntry.
  70. //
  71. typedef struct _PERF_APPLICATION_INFO
  72. {
  73. HANDLE hFileMap;
  74. PBYTE pbMemoryBlock;
  75. HANDLE hMutex;
  76. } PERF_APPLICATION_INFO, *PPERF_APPLICATION_INFO;
  77. // PERF_APPLICATION
  78. //
  79. // There is one of these structures for each entry in the performance library.
  80. //
  81. // A single process can have multiple entries like this.
  82. //
  83. // It tracks configuration information for an individual instance.
  84. //
  85. // It is valid only if the PERF_APPLICATION_VALID flag is set on the dwFlags member
  86. //
  87. typedef struct _PERF_APPLICATION
  88. {
  89. GUID guidApplicationInstance; // Instance GUID (App usage)
  90. GUID guidInternalInstance; // Per/interface instance instance GUID (MUST BE UNIQUE)
  91. GUID guidIID; // Interface ID for this instance (App usage - suggested IID of interface using this)
  92. DWORD dwProcessID; // Process ID
  93. DWORD dwFlags; // Flags PERF_APPLICATION_XXXXX
  94. DWORD dwMemoryBlockSize; // Size of the memory block
  95. DWORD dwPadding0; // Padding to ensure Quadword alignment
  96. } PERF_APPLICATION, *PPERF_APPLICATION;
  97. // PERF_APPLICATION_VALID
  98. //
  99. // This flag is set on an entry if the entry is in use.
  100. #define PERF_APPLICATION_VALID 0x00000001
  101. // PERF_APPLICATION_VOICE
  102. //
  103. // The entry contains voice related statistics
  104. #define PERF_APPLICATION_VOICE 0x00000002
  105. // PERF_APPLICATION_TRANSPORT
  106. //
  107. // The entry contains transport related statistics
  108. #define PERF_APPLICATION_TRANSPORT 0x00000004
  109. // PERF_APPLICATION_SERVER
  110. //
  111. // The entry contains "server" statistics.
  112. #define PERF_APPLICATION_SERVER 0x00000008
  113. // PERF_Initialize
  114. //
  115. // Initialize the global "instance" list memory block. Must be called once / process.
  116. //
  117. HRESULT PERF_Initialize( );
  118. HRESULT PERF_AddEntry( PPERF_APPLICATION pperfApplication, PPERF_APPLICATION_INFO pperfApplicationInfo );
  119. void PERF_RemoveEntry( GUID &guidInternalInstance, PPERF_APPLICATION_INFO pperfApplicationInfo );
  120. void PERF_DeInitialize();
  121. //
  122. // Callback Function for table dumping
  123. //
  124. typedef HRESULT (WINAPI *PFNDUMPPERFTABLE)(PVOID, PPERF_APPLICATION, PBYTE);
  125. void PERF_DumpTable( BOOL fGrabMutex, PVOID pvContext, PFNDUMPPERFTABLE pperfAppEntry );
  126. #endif