Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

perfutil.h File Reference

Go to the source code of this file.

Defines

#define DWORD_MULTIPLE(x)   (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
#define ALIGN_ON_DWORD(x)   ((VOID *)( ((DWORD) x & 0x00000003) ? ( ((DWORD) x & 0xFFFFFFFC) + 4 ) : ( (DWORD) x ) ))
#define QUERY_GLOBAL   1
#define QUERY_ITEMS   2
#define QUERY_FOREIGN   3
#define QUERY_COSTLY   4
#define QUERY_NOCOUNTERS   0x0001
#define QUERY_USER   0x0002
#define QUERY_CS   0x0004
#define ALLOC(size)   HeapAlloc (GetProcessHeap(), 0, size)
#define ALLOCZERO(size)   HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, size)
#define REALLOC(pointer, newsize)   HeapReAlloc (GetProcessHeap(), 0, pointer, newsize)
#define FREE(pointer)   HeapFree (GetProcessHeap(), 0, pointer)

Functions

HANDLE MonOpenEventLog ()
VOID MonCloseEventLog ()
DWORD GetQueryType (IN LPWSTR)
DWORD IsNumberInUnicodeList (LPWSTR)

Variables

WCHAR GLOBAL_STRING []
WCHAR FOREIGN_STRING []
WCHAR COSTLY_STRING []
WCHAR NULL_STRING []


Define Documentation

#define ALIGN_ON_DWORD  )     ((VOID *)( ((DWORD) x & 0x00000003) ? ( ((DWORD) x & 0xFFFFFFFC) + 4 ) : ( (DWORD) x ) ))
 

Definition at line 29 of file perfutil.h.

#define ALLOC size   )     HeapAlloc (GetProcessHeap(), 0, size)
 

Definition at line 62 of file perfutil.h.

Referenced by FillInstances().

#define ALLOCZERO size   )     HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, size)
 

Definition at line 63 of file perfutil.h.

#define DWORD_MULTIPLE  )     (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
 

Definition at line 25 of file perfutil.h.

#define FREE pointer   )     HeapFree (GetProcessHeap(), 0, pointer)
 

Definition at line 66 of file perfutil.h.

Referenced by CleanUpInstances(), CloseUserPerformanceData(), and FillInstances().

#define QUERY_COSTLY   4
 

Definition at line 39 of file perfutil.h.

Referenced by GetQueryType().

#define QUERY_CS   0x0004
 

Definition at line 59 of file perfutil.h.

Referenced by GlobalCollect(), and IsNumberInUnicodeList().

#define QUERY_FOREIGN   3
 

Definition at line 38 of file perfutil.h.

Referenced by CollectUserPerformanceData(), and GetQueryType().

#define QUERY_GLOBAL   1
 

Definition at line 36 of file perfutil.h.

Referenced by GetQueryType().

#define QUERY_ITEMS   2
 

Definition at line 37 of file perfutil.h.

Referenced by CollectUserPerformanceData(), and GetQueryType().

#define QUERY_NOCOUNTERS   0x0001
 

Definition at line 57 of file perfutil.h.

Referenced by CollectUserPerformanceData(), and GlobalCollect().

#define QUERY_USER   0x0002
 

Definition at line 58 of file perfutil.h.

Referenced by GlobalCollect(), and IsNumberInUnicodeList().

#define REALLOC pointer,
newsize   )     HeapReAlloc (GetProcessHeap(), 0, pointer, newsize)
 

Definition at line 64 of file perfutil.h.


Function Documentation

DWORD GetQueryType IN  LPWSTR  ) 
 

Definition at line 151 of file perfutil.c.

References BOOL, COSTLY_STRING, DWORD, FALSE, FOREIGN_STRING, GLOBAL_STRING, QUERY_COSTLY, QUERY_FOREIGN, QUERY_GLOBAL, QUERY_ITEMS, and TRUE.

Referenced by CollectUserPerformanceData().

00154 : 00155 Returns the type of query described in the lpValue string so that 00156 the appropriate processing method may be used 00157 00158 Arguments 00159 IN lpValue 00160 string passed to PerfRegQuery Value for processing 00161 00162 Return Value 00163 00164 QUERY_GLOBAL if lpValue == 0 (null pointer) 00165 lpValue == pointer to Null string 00166 lpValue == pointer to "Global" string 00167 QUERY_FOREIGN 00168 if lpValue == pointer to "Foreign" string 00169 QUERY_COSTLY 00170 if lpValue == pointer to "Costly" string 00171 otherwise: 00172 00173 QUERY_ITEMS 00174 00175 --*/ 00176 00177 { 00178 WCHAR *pwcArgChar, *pwcTypeChar; 00179 BOOL bFound; 00180 if (lpValue == 0) { 00181 return QUERY_GLOBAL; 00182 } 00183 else if (*lpValue == 0) { 00184 return QUERY_GLOBAL; 00185 } 00186 00187 // check for "Global" request 00188 pwcArgChar = lpValue; 00189 pwcTypeChar = GLOBAL_STRING; 00190 bFound = TRUE; // assume found until contradicted 00191 00192 // check to the length of the shortest string 00193 while ((*pwcArgChar != 0) && (*pwcTypeChar != 0)) { 00194 if (*pwcArgChar++ != *pwcTypeChar++) { 00195 bFound = FALSE; // no match 00196 break; // bail out now 00197 } 00198 } 00199 if (bFound) return QUERY_GLOBAL; 00200 00201 // check for "Foreign" request 00202 pwcArgChar = lpValue; 00203 pwcTypeChar = FOREIGN_STRING; 00204 bFound = TRUE; // assume found until contradicted 00205 00206 // check to the length of the shortest string 00207 while ((*pwcArgChar != 0) && (*pwcTypeChar != 0)) { 00208 if (*pwcArgChar++ != *pwcTypeChar++) { 00209 bFound = FALSE; // no match 00210 break; // bail out now 00211 } 00212 } 00213 if (bFound) return QUERY_FOREIGN; 00214 00215 // check for "Costly" request 00216 pwcArgChar = lpValue; 00217 pwcTypeChar = COSTLY_STRING; 00218 bFound = TRUE; // assume found until contradicted 00219 00220 // check to the length of the shortest string 00221 while ((*pwcArgChar != 0) && (*pwcTypeChar != 0)) { 00222 if (*pwcArgChar++ != *pwcTypeChar++) { 00223 bFound = FALSE; // no match 00224 break; // bail out now 00225 } 00226 } 00227 if (bFound) return QUERY_COSTLY; 00228 00229 // if not Global and not Foreign and not Costly, 00230 // then it must be an item list 00231 00232 return QUERY_ITEMS; 00233 }

DWORD IsNumberInUnicodeList LPWSTR   ) 
 

Referenced by CollectUserPerformanceData().

VOID MonCloseEventLog  ) 
 

Definition at line 131 of file perfutil.c.

References dwLogUsers, hEventLog, LOG_DEBUG, NULL, REPORT_INFORMATION, and VOID().

Referenced by CloseUserPerformanceData().

00133 : 00134 Closes the handle to the event logger if this is the last caller 00135 00136 Arguments: None 00137 00138 Return Value: None 00139 00140 --*/ 00141 { 00142 if (hEventLog != NULL) { 00143 dwLogUsers--; // decrement usage 00144 if (dwLogUsers <= 0) { // and if we're the last, then close up log 00145 REPORT_INFORMATION (UTIL_CLOSING_LOG, LOG_DEBUG); 00146 DeregisterEventSource (hEventLog); 00147 } 00148 } 00149 }

HANDLE MonOpenEventLog  ) 
 

Definition at line 65 of file perfutil.c.

References APP_NAME, dwLogUsers, DWORD, hEventLog, LOG_DEBUG, MESSAGE_LEVEL, MESSAGE_LEVEL_DEFAULT, NULL, and REPORT_INFORMATION.

Referenced by OpenUserPerformanceData().

00067 : 00068 00069 Reads the level of event logging from the registry and opens the 00070 channel to the event logger for subsequent event log entries. 00071 00072 Arguments: 00073 None 00074 00075 Return Value: 00076 Handle to the event log for reporting events. 00077 NULL if open not successful. 00078 --*/ 00079 { 00080 HKEY hAppKey; 00081 TCHAR LogLevelKeyName[] = "SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\PerfLib"; 00082 TCHAR LogLevelValueName[] = "EventLogLevel"; 00083 LONG lStatus; 00084 DWORD dwLogLevel; 00085 DWORD dwValueType; 00086 DWORD dwValueSize; 00087 00088 // if global value of the logging level not initialized or is disabled, 00089 // check the registry to see if it should be updated. 00090 00091 if (!MESSAGE_LEVEL) { 00092 lStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE, 00093 LogLevelKeyName, 00094 0, 00095 KEY_READ, 00096 &hAppKey); 00097 dwValueSize = sizeof (dwLogLevel); 00098 if (lStatus == ERROR_SUCCESS) { 00099 lStatus = RegQueryValueEx (hAppKey, 00100 LogLevelValueName, 00101 (LPDWORD)NULL, 00102 &dwValueType, 00103 (LPBYTE)&dwLogLevel, 00104 &dwValueSize); 00105 if (lStatus == ERROR_SUCCESS) { 00106 MESSAGE_LEVEL = dwLogLevel; 00107 } 00108 else { 00109 MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT; 00110 } 00111 RegCloseKey (hAppKey); 00112 } 00113 else { 00114 MESSAGE_LEVEL = MESSAGE_LEVEL_DEFAULT; 00115 } 00116 } 00117 if (hEventLog == NULL) { 00118 hEventLog = RegisterEventSource ( 00119 (LPTSTR)NULL, // Use Local Machine 00120 APP_NAME); // event log app name to find in registry 00121 if (hEventLog != NULL) { 00122 REPORT_INFORMATION (UTIL_LOG_OPEN, LOG_DEBUG); 00123 } 00124 } 00125 if (hEventLog != NULL) { 00126 dwLogUsers++; // increment count of perfctr log users 00127 } 00128 return (hEventLog); 00129 }


Variable Documentation

WCHAR COSTLY_STRING[]
 

Definition at line 33 of file perfutil.h.

Referenced by GetQueryType().

WCHAR FOREIGN_STRING[]
 

Definition at line 32 of file perfutil.h.

Referenced by GetQueryType().

WCHAR GLOBAL_STRING[]
 

Definition at line 31 of file perfutil.h.

Referenced by GetQueryType().

WCHAR NULL_STRING[]
 

Definition at line 34 of file perfutil.h.


Generated on Sat May 15 19:45:02 2004 for test by doxygen 1.3.7