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.

1598 lines
72 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. dnsperf.c
  5. Abstract:
  6. This file implements the Extensible Objects for the DNS object type
  7. Created:
  8. Jing Chen 1998
  9. Revision History
  10. --*/
  11. //
  12. // Include Files
  13. //
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <windows.h>
  18. #include <rpc.h>
  19. #include <wchar.h>
  20. #include <winperf.h>
  21. #include "perfutil.h"
  22. #include "datadns.h"
  23. #include "dnsperf.h"
  24. #include "perfconfig.h"
  25. #include "dnslibp.h" // security routine
  26. #define SERVICE_NAME "DNS"
  27. //
  28. // DNS counter data structures
  29. //
  30. DWORD dwOpenCount = 0; // count of "Open" threads
  31. BOOL bInitOK = FALSE; // true = DLL initialized OK
  32. HANDLE hDnsSharedMemory = NULL; // Handle of Dns Shared Memory
  33. PDWORD pCounterBlock = NULL;
  34. extern DNS_DATA_DEFINITION DnsDataDefinition;
  35. //
  36. // Function Prototypes
  37. //
  38. // these are used to insure that the data collection functions
  39. // accessed by Perflib will have the correct calling format.
  40. //
  41. PM_OPEN_PROC OpenDnsPerformanceData;
  42. PM_COLLECT_PROC CollectDnsPerformanceData;
  43. PM_CLOSE_PROC CloseDnsPerformanceData;
  44. DWORD
  45. OpenDnsPerformanceData(
  46. IN LPWSTR lpDeviceNames
  47. )
  48. /*++
  49. Routine Description:
  50. This routine will open and map the memory used by the DNS to
  51. pass performance data in. This routine also initializes the data
  52. structures used to pass data back to the registry
  53. Arguments:
  54. Pointer to object ID of each device to be opened (DNS), which
  55. seems to be totally unused, just as it was in the sample code
  56. from which this is stolen.
  57. Return Value:
  58. None.
  59. --*/
  60. {
  61. LONG status;
  62. HKEY hKeyDriverPerf = NULL;
  63. DWORD size;
  64. DWORD type;
  65. DWORD dwFirstCounter;
  66. DWORD dwFirstHelp;
  67. //
  68. // Since SCREG is multi-threaded and will call this routine in
  69. // order to service remote performance queries, this library
  70. // must keep track of how many times it has been opened (i.e.
  71. // how many threads have accessed it). the registry routines will
  72. // limit access to the initialization routine to only one thread
  73. // at a time so synchronization (i.e. reentrancy) should not be
  74. // a problem
  75. //
  76. // DNS_FIX0: possible MT issues in dnsperf
  77. // - thread counter is not protected, needs Interlocked instruction
  78. // - contrary to above, reentrancy is not protected as we do
  79. // file mapping first
  80. // - file mapping not cleaned up on failure
  81. // - registry handle not cleaned up on failure
  82. //
  83. if ( !dwOpenCount )
  84. {
  85. // open shared memory used by device driver to pass performance values
  86. hDnsSharedMemory = OpenFileMapping(
  87. FILE_MAP_READ,
  88. FALSE,
  89. DNS_PERF_COUNTER_BLOCK );
  90. pCounterBlock = NULL; // initialize pointer to memory
  91. if ( hDnsSharedMemory == NULL )
  92. {
  93. //
  94. // create security on perfmon mapped file
  95. //
  96. // security will be AuthenticatedUsers get to read
  97. // note, using array syntax, to make it easier to tweak
  98. // if want other ACLs later
  99. //
  100. SID_IDENTIFIER_AUTHORITY ntAuthority = SECURITY_NT_AUTHORITY;
  101. SECURITY_ATTRIBUTES secAttr;
  102. PSECURITY_ATTRIBUTES psecAttr = NULL;
  103. PSECURITY_DESCRIPTOR psd = NULL;
  104. DWORD maskArray[ 3 ] = { 0 };
  105. PSID sidArray[ 3 ] = { 0 }; // NULL terminated!
  106. INT i;
  107. maskArray[ 0 ] = GENERIC_READ;
  108. status = RtlAllocateAndInitializeSid(
  109. &ntAuthority,
  110. 1,
  111. SECURITY_AUTHENTICATED_USER_RID,
  112. 0, 0, 0, 0, 0, 0, 0,
  113. &sidArray[ 0 ] );
  114. if ( status != ERROR_SUCCESS )
  115. {
  116. maskArray[ 1 ] = GENERIC_ALL;
  117. status = RtlAllocateAndInitializeSid(
  118. &ntAuthority,
  119. 1,
  120. SECURITY_LOCAL_SYSTEM_RID,
  121. 0, 0, 0, 0, 0, 0, 0,
  122. &sidArray[ 1 ] );
  123. }
  124. if ( status != ERROR_SUCCESS )
  125. {
  126. DNS_PRINT((
  127. "ERROR <%lu>: Cannot create Authenticated Users SID\n",
  128. status ));
  129. }
  130. else
  131. {
  132. status = Dns_CreateSecurityDescriptor(
  133. &psd,
  134. 2, // number of ACEs
  135. sidArray,
  136. maskArray );
  137. if ( status == ERROR_SUCCESS )
  138. {
  139. secAttr.lpSecurityDescriptor = psd;
  140. secAttr.bInheritHandle = FALSE;
  141. secAttr.nLength = sizeof( SECURITY_ATTRIBUTES );
  142. psecAttr = &secAttr;
  143. }
  144. ELSE
  145. {
  146. DNSDBG( ANY, (
  147. "ERROR: <%d> failed SD create for perfmon memory!\n",
  148. status ));
  149. }
  150. }
  151. hDnsSharedMemory = CreateFileMapping(
  152. (HANDLE) (-1),
  153. psecAttr,
  154. PAGE_READWRITE,
  155. 0,
  156. 4096,
  157. DNS_PERF_COUNTER_BLOCK );
  158. for ( i = 0; sidArray[ i ]; ++i )
  159. {
  160. RtlFreeSid( sidArray[ i ] );
  161. }
  162. if ( psd )
  163. {
  164. Dns_Free( psd );
  165. }
  166. }
  167. // log error if unsuccessful
  168. if ( hDnsSharedMemory == NULL )
  169. {
  170. // this is fatal, if we can't get data then there's no
  171. // point in continuing.
  172. status = GetLastError(); // return error
  173. goto OpenFailed;
  174. }
  175. else
  176. {
  177. // if opened ok, then map pointer to memory
  178. pCounterBlock = (PDWORD) MapViewOfFile(
  179. hDnsSharedMemory,
  180. FILE_MAP_READ,
  181. 0,
  182. 0,
  183. 0);
  184. if (pCounterBlock == NULL)
  185. {
  186. // this is fatal, if we can't get data then there's no
  187. // point in continuing.
  188. status = GetLastError(); // return error
  189. goto OpenFailed;
  190. }
  191. }
  192. // get counter and help index base values from registry
  193. // Open key to registry entry
  194. // read First Counter and First Help values
  195. // update static data strucutures by adding base to
  196. // offset value in structure.
  197. status = RegOpenKeyEx(
  198. HKEY_LOCAL_MACHINE,
  199. "SYSTEM\\CurrentControlSet\\Services\\" SERVICE_NAME "\\Performance",
  200. 0L,
  201. KEY_READ,
  202. &hKeyDriverPerf);
  203. if (status != ERROR_SUCCESS)
  204. {
  205. LPTSTR apsz[2];
  206. // this is fatal, if we can't get the base values of the
  207. // counter or help names, then the names won't be available
  208. // to the requesting application so there's not much
  209. // point in continuing.
  210. apsz[0] = (LPTSTR) (LONG_PTR) status;
  211. apsz[1] = "SYSTEM\\CurrentControlSet\\Services\\" SERVICE_NAME "\\Performance";
  212. goto OpenFailed;
  213. }
  214. size = sizeof (DWORD);
  215. status = RegQueryValueEx(
  216. hKeyDriverPerf,
  217. "First Counter",
  218. 0L,
  219. &type,
  220. (LPBYTE)&dwFirstCounter,
  221. &size);
  222. if (status != ERROR_SUCCESS) {
  223. LPTSTR apsz[2];
  224. // this is fatal, if we can't get the base values of the
  225. // counter or help names, then the names won't be available
  226. // to the requesting application so there's not much
  227. // point in continuing.
  228. apsz[0] = (LPTSTR) (LONG_PTR) status;
  229. apsz[1] = "First Counter";
  230. goto OpenFailed;
  231. }
  232. size = sizeof (DWORD);
  233. status = RegQueryValueEx(
  234. hKeyDriverPerf,
  235. "First Help",
  236. 0L,
  237. &type,
  238. (LPBYTE)&dwFirstHelp,
  239. &size);
  240. if (status != ERROR_SUCCESS)
  241. {
  242. LPTSTR apsz[2];
  243. // this is fatal, if we can't get the base values of the
  244. // counter or help names, then the names won't be available
  245. // to the requesting application so there's not much
  246. // point in continuing.
  247. apsz[0] = (LPTSTR) (LONG_PTR) status;
  248. apsz[1] = "First Help";
  249. goto OpenFailed;
  250. }
  251. //
  252. // NOTE: the initialization program could also retrieve
  253. // LastCounter and LastHelp if they wanted to do
  254. // bounds checking on the new number. e.g.
  255. //
  256. // counter->CounterNameTitleIndex += dwFirstCounter;
  257. // if (counter->CounterNameTitleIndex > dwLastCounter) {
  258. // LogErrorToEventLog (INDEX_OUT_OF_BOUNDS);
  259. // }
  260. DnsDataDefinition.DnsObjectType.ObjectNameTitleIndex += dwFirstCounter;
  261. DnsDataDefinition.DnsObjectType.ObjectHelpTitleIndex += dwFirstHelp;
  262. DnsDataDefinition.TotalQueryReceived.CounterNameTitleIndex += dwFirstCounter;
  263. DnsDataDefinition.TotalQueryReceived.CounterHelpTitleIndex += dwFirstHelp;
  264. DnsDataDefinition.TotalQueryReceived_s.CounterNameTitleIndex += dwFirstCounter;
  265. DnsDataDefinition.TotalQueryReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  266. DnsDataDefinition.UdpQueryReceived.CounterNameTitleIndex += dwFirstCounter;
  267. DnsDataDefinition.UdpQueryReceived.CounterHelpTitleIndex += dwFirstHelp;
  268. DnsDataDefinition.UdpQueryReceived_s.CounterNameTitleIndex += dwFirstCounter;
  269. DnsDataDefinition.UdpQueryReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  270. DnsDataDefinition.TcpQueryReceived.CounterNameTitleIndex += dwFirstCounter;
  271. DnsDataDefinition.TcpQueryReceived.CounterHelpTitleIndex += dwFirstHelp;
  272. DnsDataDefinition.TcpQueryReceived_s.CounterNameTitleIndex += dwFirstCounter;
  273. DnsDataDefinition.TcpQueryReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  274. DnsDataDefinition.TotalResponseSent.CounterNameTitleIndex += dwFirstCounter;
  275. DnsDataDefinition.TotalResponseSent.CounterHelpTitleIndex += dwFirstHelp;
  276. DnsDataDefinition.TotalResponseSent_s.CounterNameTitleIndex += dwFirstCounter;
  277. DnsDataDefinition.TotalResponseSent_s.CounterHelpTitleIndex += dwFirstHelp;
  278. DnsDataDefinition.UdpResponseSent.CounterNameTitleIndex += dwFirstCounter;
  279. DnsDataDefinition.UdpResponseSent.CounterHelpTitleIndex += dwFirstHelp;
  280. DnsDataDefinition.UdpResponseSent_s.CounterNameTitleIndex += dwFirstCounter;
  281. DnsDataDefinition.UdpResponseSent_s.CounterHelpTitleIndex += dwFirstHelp;
  282. DnsDataDefinition.TcpResponseSent.CounterNameTitleIndex += dwFirstCounter;
  283. DnsDataDefinition.TcpResponseSent.CounterHelpTitleIndex += dwFirstHelp;
  284. DnsDataDefinition.TcpResponseSent_s.CounterNameTitleIndex += dwFirstCounter;
  285. DnsDataDefinition.TcpResponseSent_s.CounterHelpTitleIndex += dwFirstHelp;
  286. DnsDataDefinition.RecursiveQueries.CounterNameTitleIndex += dwFirstCounter;
  287. DnsDataDefinition.RecursiveQueries.CounterHelpTitleIndex += dwFirstHelp;
  288. DnsDataDefinition.RecursiveQueries_s.CounterNameTitleIndex += dwFirstCounter;
  289. DnsDataDefinition.RecursiveQueries_s.CounterHelpTitleIndex += dwFirstHelp;
  290. DnsDataDefinition.RecursiveTimeOut.CounterNameTitleIndex += dwFirstCounter;
  291. DnsDataDefinition.RecursiveTimeOut.CounterHelpTitleIndex += dwFirstHelp;
  292. DnsDataDefinition.RecursiveTimeOut_s.CounterNameTitleIndex += dwFirstCounter;
  293. DnsDataDefinition.RecursiveTimeOut_s.CounterHelpTitleIndex += dwFirstHelp;
  294. DnsDataDefinition.RecursiveQueryFailure.CounterNameTitleIndex += dwFirstCounter;
  295. DnsDataDefinition.RecursiveQueryFailure.CounterHelpTitleIndex += dwFirstHelp;
  296. DnsDataDefinition.RecursiveQueryFailure_s.CounterNameTitleIndex += dwFirstCounter;
  297. DnsDataDefinition.RecursiveQueryFailure_s.CounterHelpTitleIndex += dwFirstHelp;
  298. DnsDataDefinition.NotifySent.CounterNameTitleIndex += dwFirstCounter;
  299. DnsDataDefinition.NotifySent.CounterHelpTitleIndex += dwFirstHelp;
  300. DnsDataDefinition.ZoneTransferRequestReceived.CounterNameTitleIndex += dwFirstCounter;
  301. DnsDataDefinition.ZoneTransferRequestReceived.CounterHelpTitleIndex += dwFirstHelp;
  302. DnsDataDefinition.ZoneTransferSuccess.CounterNameTitleIndex += dwFirstCounter;
  303. DnsDataDefinition.ZoneTransferSuccess.CounterHelpTitleIndex += dwFirstHelp;
  304. DnsDataDefinition.ZoneTransferFailure.CounterNameTitleIndex += dwFirstCounter;
  305. DnsDataDefinition.ZoneTransferFailure.CounterHelpTitleIndex += dwFirstHelp;
  306. DnsDataDefinition.AxfrRequestReceived.CounterNameTitleIndex += dwFirstCounter;
  307. DnsDataDefinition.AxfrRequestReceived.CounterHelpTitleIndex += dwFirstHelp;
  308. DnsDataDefinition.AxfrSuccessSent.CounterNameTitleIndex += dwFirstCounter;
  309. DnsDataDefinition.AxfrSuccessSent.CounterHelpTitleIndex += dwFirstHelp;
  310. DnsDataDefinition.IxfrRequestReceived.CounterNameTitleIndex += dwFirstCounter;
  311. DnsDataDefinition.IxfrRequestReceived.CounterHelpTitleIndex += dwFirstHelp;
  312. DnsDataDefinition.IxfrSuccessSent.CounterNameTitleIndex += dwFirstCounter;
  313. DnsDataDefinition.IxfrSuccessSent.CounterHelpTitleIndex += dwFirstHelp;
  314. DnsDataDefinition.NotifyReceived.CounterNameTitleIndex += dwFirstCounter;
  315. DnsDataDefinition.NotifyReceived.CounterHelpTitleIndex += dwFirstHelp;
  316. DnsDataDefinition.ZoneTransferSoaRequestSent.CounterNameTitleIndex += dwFirstCounter;
  317. DnsDataDefinition.ZoneTransferSoaRequestSent.CounterHelpTitleIndex += dwFirstHelp;
  318. DnsDataDefinition.AxfrRequestSent.CounterNameTitleIndex += dwFirstCounter;
  319. DnsDataDefinition.AxfrRequestSent.CounterHelpTitleIndex += dwFirstHelp;
  320. DnsDataDefinition.AxfrResponseReceived.CounterNameTitleIndex += dwFirstCounter;
  321. DnsDataDefinition.AxfrResponseReceived.CounterHelpTitleIndex += dwFirstHelp;
  322. DnsDataDefinition.AxfrSuccessReceived.CounterNameTitleIndex += dwFirstCounter;
  323. DnsDataDefinition.AxfrSuccessReceived.CounterHelpTitleIndex += dwFirstHelp;
  324. DnsDataDefinition.IxfrRequestSent.CounterNameTitleIndex += dwFirstCounter;
  325. DnsDataDefinition.IxfrRequestSent.CounterHelpTitleIndex += dwFirstHelp;
  326. DnsDataDefinition.IxfrResponseReceived.CounterNameTitleIndex += dwFirstCounter;
  327. DnsDataDefinition.IxfrResponseReceived.CounterHelpTitleIndex += dwFirstHelp;
  328. DnsDataDefinition.IxfrSuccessReceived.CounterNameTitleIndex += dwFirstCounter;
  329. DnsDataDefinition.IxfrSuccessReceived.CounterHelpTitleIndex += dwFirstHelp;
  330. DnsDataDefinition.IxfrUdpSuccessReceived.CounterNameTitleIndex += dwFirstCounter;
  331. DnsDataDefinition.IxfrUdpSuccessReceived.CounterHelpTitleIndex += dwFirstHelp;
  332. DnsDataDefinition.IxfrTcpSuccessReceived.CounterNameTitleIndex += dwFirstCounter;
  333. DnsDataDefinition.IxfrTcpSuccessReceived.CounterHelpTitleIndex += dwFirstHelp;
  334. DnsDataDefinition.WinsLookupReceived.CounterNameTitleIndex += dwFirstCounter;
  335. DnsDataDefinition.WinsLookupReceived.CounterHelpTitleIndex += dwFirstHelp;
  336. DnsDataDefinition.WinsLookupReceived_s.CounterNameTitleIndex += dwFirstCounter;
  337. DnsDataDefinition.WinsLookupReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  338. DnsDataDefinition.WinsResponseSent.CounterNameTitleIndex += dwFirstCounter;
  339. DnsDataDefinition.WinsResponseSent.CounterHelpTitleIndex += dwFirstHelp;
  340. DnsDataDefinition.WinsResponseSent_s.CounterNameTitleIndex += dwFirstCounter;
  341. DnsDataDefinition.WinsResponseSent_s.CounterHelpTitleIndex += dwFirstHelp;
  342. DnsDataDefinition.WinsReverseLookupReceived.CounterNameTitleIndex += dwFirstCounter;
  343. DnsDataDefinition.WinsReverseLookupReceived.CounterHelpTitleIndex += dwFirstHelp;
  344. DnsDataDefinition.WinsReverseLookupReceived_s.CounterNameTitleIndex += dwFirstCounter;
  345. DnsDataDefinition.WinsReverseLookupReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  346. DnsDataDefinition.WinsReverseResponseSent.CounterNameTitleIndex += dwFirstCounter;
  347. DnsDataDefinition.WinsReverseResponseSent.CounterHelpTitleIndex += dwFirstHelp;
  348. DnsDataDefinition.WinsReverseResponseSent_s.CounterNameTitleIndex += dwFirstCounter;
  349. DnsDataDefinition.WinsReverseResponseSent_s.CounterHelpTitleIndex += dwFirstHelp;
  350. DnsDataDefinition.DynamicUpdateReceived.CounterNameTitleIndex += dwFirstCounter;
  351. DnsDataDefinition.DynamicUpdateReceived.CounterHelpTitleIndex += dwFirstHelp;
  352. DnsDataDefinition.DynamicUpdateReceived_s.CounterNameTitleIndex += dwFirstCounter;
  353. DnsDataDefinition.DynamicUpdateReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  354. DnsDataDefinition.DynamicUpdateNoOp.CounterNameTitleIndex += dwFirstCounter;
  355. DnsDataDefinition.DynamicUpdateNoOp.CounterHelpTitleIndex += dwFirstHelp;
  356. DnsDataDefinition.DynamicUpdateNoOp_s.CounterNameTitleIndex += dwFirstCounter;
  357. DnsDataDefinition.DynamicUpdateNoOp_s.CounterHelpTitleIndex += dwFirstHelp;
  358. DnsDataDefinition.DynamicUpdateWriteToDB.CounterNameTitleIndex += dwFirstCounter;
  359. DnsDataDefinition.DynamicUpdateWriteToDB.CounterHelpTitleIndex += dwFirstHelp;
  360. DnsDataDefinition.DynamicUpdateWriteToDB_s.CounterNameTitleIndex += dwFirstCounter;
  361. DnsDataDefinition.DynamicUpdateWriteToDB_s.CounterHelpTitleIndex += dwFirstHelp;
  362. DnsDataDefinition.DynamicUpdateRejected.CounterNameTitleIndex += dwFirstCounter;
  363. DnsDataDefinition.DynamicUpdateRejected.CounterHelpTitleIndex += dwFirstHelp;
  364. DnsDataDefinition.DynamicUpdateTimeOut.CounterNameTitleIndex += dwFirstCounter;
  365. DnsDataDefinition.DynamicUpdateTimeOut.CounterHelpTitleIndex += dwFirstHelp;
  366. DnsDataDefinition.DynamicUpdateQueued.CounterNameTitleIndex += dwFirstCounter;
  367. DnsDataDefinition.DynamicUpdateQueued.CounterHelpTitleIndex += dwFirstHelp;
  368. DnsDataDefinition.SecureUpdateReceived.CounterNameTitleIndex += dwFirstCounter;
  369. DnsDataDefinition.SecureUpdateReceived.CounterHelpTitleIndex += dwFirstHelp;
  370. DnsDataDefinition.SecureUpdateReceived_s.CounterNameTitleIndex += dwFirstCounter;
  371. DnsDataDefinition.SecureUpdateReceived_s.CounterHelpTitleIndex += dwFirstHelp;
  372. DnsDataDefinition.SecureUpdateFailure.CounterNameTitleIndex += dwFirstCounter;
  373. DnsDataDefinition.SecureUpdateFailure.CounterHelpTitleIndex += dwFirstHelp;
  374. DnsDataDefinition.DatabaseNodeMemory.CounterNameTitleIndex += dwFirstCounter;
  375. DnsDataDefinition.DatabaseNodeMemory.CounterHelpTitleIndex += dwFirstHelp;
  376. DnsDataDefinition.RecordFlowMemory.CounterNameTitleIndex += dwFirstCounter;
  377. DnsDataDefinition.RecordFlowMemory.CounterHelpTitleIndex += dwFirstHelp;
  378. DnsDataDefinition.CachingMemory.CounterNameTitleIndex += dwFirstCounter;
  379. DnsDataDefinition.CachingMemory.CounterHelpTitleIndex += dwFirstHelp;
  380. DnsDataDefinition.UdpMessageMemory.CounterNameTitleIndex += dwFirstCounter;
  381. DnsDataDefinition.UdpMessageMemory.CounterHelpTitleIndex += dwFirstHelp;
  382. DnsDataDefinition.TcpMessageMemory.CounterNameTitleIndex += dwFirstCounter;
  383. DnsDataDefinition.TcpMessageMemory.CounterHelpTitleIndex += dwFirstHelp;
  384. DnsDataDefinition.NbstatMemory.CounterNameTitleIndex += dwFirstCounter;
  385. DnsDataDefinition.NbstatMemory.CounterHelpTitleIndex += dwFirstHelp;
  386. RegCloseKey( hKeyDriverPerf ); // close key to registry
  387. bInitOK = TRUE; // ok to use this function
  388. }
  389. dwOpenCount++; // increment OPEN counter
  390. return( ERROR_SUCCESS ); // for successful exit
  391. OpenFailed:
  392. //
  393. // close handles if open fails
  394. //
  395. if ( hKeyDriverPerf )
  396. {
  397. RegCloseKey( hKeyDriverPerf );
  398. }
  399. if ( pCounterBlock )
  400. {
  401. UnmapViewOfFile( pCounterBlock );
  402. pCounterBlock = NULL;
  403. }
  404. if ( hDnsSharedMemory )
  405. {
  406. CloseHandle( hDnsSharedMemory );
  407. hDnsSharedMemory = NULL;
  408. }
  409. return status;
  410. }
  411. DWORD
  412. CollectDnsPerformanceData(
  413. IN LPWSTR lpValueName,
  414. IN OUT LPVOID * lppData,
  415. IN OUT LPDWORD lpcbTotalBytes,
  416. IN OUT LPDWORD lpNumObjectTypes
  417. )
  418. /*++
  419. Routine Description:
  420. This routine will return the data for the DNS counters.
  421. Arguments:
  422. IN LPWSTR lpValueName
  423. pointer to a wide character string passed by registry.
  424. IN OUT LPVOID *lppData
  425. IN: pointer to the address of the buffer to receive the completed
  426. PerfDataBlock and subordinate structures. This routine will
  427. append its data to the buffer starting at the point referenced
  428. by *lppData.
  429. OUT: points to the first byte after the data structure added by this
  430. routine. This routine updated the value at lppdata after appending
  431. its data.
  432. IN OUT LPDWORD lpcbTotalBytes
  433. IN: the address of the DWORD that tells the size in bytes of the
  434. buffer referenced by the lppData argument
  435. OUT: the number of bytes added by this routine is writted to the
  436. DWORD pointed to by this argument
  437. IN OUT LPDWORD NumObjectTypes
  438. IN: the address of the DWORD to receive the number of objects added
  439. by this routine
  440. OUT: the number of objects added by this routine is writted to the
  441. DWORD pointed to by this argument
  442. Return Value:
  443. ERROR_MORE_DATA if buffer passed is too small to hold data
  444. any error conditions encountered are reported to the event log if
  445. event logging is enabled.
  446. ERROR_SUCCESS if success or any other error. Errors, however are
  447. also reported to the event log.
  448. --*/
  449. {
  450. // Variables for reformating the data
  451. ULONG SpaceNeeded;
  452. PDWORD pdwCounter;
  453. PERF_COUNTER_BLOCK *pPerfCounterBlock;
  454. DNS_DATA_DEFINITION *pDnsDataDefinition;
  455. DWORD dwQueryType; // for error logging
  456. //
  457. // before doing anything else, see if Open went OK
  458. //
  459. if (!bInitOK)
  460. {
  461. // unable to continue because open failed.
  462. *lpcbTotalBytes = (DWORD) 0;
  463. *lpNumObjectTypes = (DWORD) 0;
  464. return ERROR_SUCCESS; // yes, this is a successful exit
  465. }
  466. // see if this is a foreign (i.e. non-NT) computer data request
  467. //
  468. dwQueryType = GetQueryType (lpValueName);
  469. if ( dwQueryType == QUERY_FOREIGN )
  470. {
  471. // this routine does not service requests for data from
  472. // Non-NT computers
  473. *lpcbTotalBytes = (DWORD) 0;
  474. *lpNumObjectTypes = (DWORD) 0;
  475. return ERROR_SUCCESS;
  476. }
  477. if (dwQueryType == QUERY_ITEMS)
  478. {
  479. if ( ! IsNumberInUnicodeList(
  480. DnsDataDefinition.DnsObjectType.ObjectNameTitleIndex,
  481. lpValueName ) )
  482. {
  483. // request received for data object not provided by this routine
  484. *lpcbTotalBytes = (DWORD) 0;
  485. *lpNumObjectTypes = (DWORD) 0;
  486. return ERROR_SUCCESS;
  487. }
  488. }
  489. //
  490. // Get the data.
  491. //
  492. pDnsDataDefinition = (DNS_DATA_DEFINITION *) *lppData;
  493. SpaceNeeded = sizeof(DNS_DATA_DEFINITION) + SIZE_OF_DNS_PERFORMANCE_DATA;
  494. if ( *lpcbTotalBytes < SpaceNeeded )
  495. {
  496. *lpcbTotalBytes = (DWORD) 0;
  497. *lpNumObjectTypes = (DWORD) 0;
  498. return ERROR_MORE_DATA;
  499. }
  500. //
  501. // Copy the (constant, initialized) Object Type and counter definitions
  502. // to the caller's data buffer
  503. //
  504. memmove(pDnsDataDefinition,
  505. &DnsDataDefinition,
  506. sizeof(DNS_DATA_DEFINITION));
  507. // Format and collect DNS data from shared memory
  508. // The counter block is to immediately follow the data definition,
  509. // so obtain a pointer to that space
  510. pPerfCounterBlock = (PERF_COUNTER_BLOCK *) &pDnsDataDefinition[1];
  511. // The byte length is of the counter block header and all following data
  512. pPerfCounterBlock->ByteLength = SIZE_OF_DNS_PERFORMANCE_DATA;
  513. // Compute a pointer to the buffer immediately following the counter
  514. // block header
  515. pdwCounter = (PDWORD) (&pPerfCounterBlock[1]);
  516. // copy the counter data from shared memory block into the counter block
  517. memcpy(pdwCounter,
  518. &pCounterBlock[1],
  519. SIZE_OF_DNS_PERFORMANCE_DATA - sizeof(PERF_COUNTER_BLOCK));
  520. // Tell caller where the next available byte is
  521. *lppData = (PVOID) ((PBYTE)pdwCounter + SIZE_OF_DNS_PERFORMANCE_DATA - sizeof(PERF_COUNTER_BLOCK));
  522. // update arguments before return
  523. *lpNumObjectTypes = 1;
  524. *lpcbTotalBytes = (DWORD) ((PBYTE)*lppData - (PBYTE)pDnsDataDefinition);
  525. return ERROR_SUCCESS;
  526. }
  527. DWORD
  528. CloseDnsPerformanceData(
  529. VOID
  530. )
  531. /*++
  532. Routine Description:
  533. This routine closes the open handles to DNS device performance counters
  534. Arguments:
  535. None.
  536. Return Value:
  537. ERROR_SUCCESS
  538. --*/
  539. {
  540. //
  541. // cleanup when close last thread
  542. //
  543. // DNS_FIX0: MT issues in dnsperf cleanup
  544. // no real protection on thread count (need interlock)
  545. // but also close can be going on concurrently with another
  546. // thread attempting to reopen (unlikely but possible)
  547. //
  548. // perhaps two flag approach would work, with all new threads
  549. // failing (not passing through but skipping open altogether)
  550. // until pCounterBlock was NULL again
  551. //
  552. if ( !(--dwOpenCount) )
  553. {
  554. // clear bInitOk, as otherwise collect function
  555. // will attempt to reference into pCounterBlock
  556. bInitOK = FALSE;
  557. if ( pCounterBlock )
  558. {
  559. UnmapViewOfFile( pCounterBlock );
  560. pCounterBlock = NULL;
  561. }
  562. if ( hDnsSharedMemory )
  563. {
  564. CloseHandle( hDnsSharedMemory );
  565. hDnsSharedMemory = NULL;
  566. }
  567. }
  568. return ERROR_SUCCESS;
  569. }
  570. //
  571. // Data for this whole thing to work on
  572. //
  573. DNS_DATA_DEFINITION DnsDataDefinition =
  574. {
  575. // DNS obj for PerfMon:
  576. { sizeof(DNS_DATA_DEFINITION) + SIZE_OF_DNS_PERFORMANCE_DATA, // TotLen
  577. sizeof(DNS_DATA_DEFINITION), // DefinitionLength
  578. sizeof(PERF_OBJECT_TYPE), // HeaderLength
  579. DNSOBJ, // ObjectNameTitleIndex
  580. 0, // ObjectNameTitle
  581. DNSOBJ, // ObjectHelpTitleIndex
  582. 0, // ObjectHelpTitle
  583. PERF_DETAIL_NOVICE, // DetailLevel
  584. (sizeof(DNS_DATA_DEFINITION)-sizeof(PERF_OBJECT_TYPE))/
  585. sizeof(PERF_COUNTER_DEFINITION), // NumCounters
  586. 0, // DefaultCounter
  587. -1, // NumInstances
  588. 0 // CodePage (0=Unicode)
  589. },
  590. // total query received
  591. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  592. TOTALQUERYRECEIVED, // CounterNameTitleIndex
  593. 0, // CounterNameTitle
  594. TOTALQUERYRECEIVED, // CounterHelpTitleIndex
  595. 0, // CounterHelpTitle
  596. 0, // DefaultScale
  597. PERF_DETAIL_NOVICE, // DetailLevel
  598. PERF_COUNTER_RAWCOUNT, // CounterType
  599. sizeof(DWORD), // CounterSize
  600. TOTALQUERYRECEIVED_OFFSET // CounterOffset
  601. },
  602. // total qurey received/sec
  603. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  604. TOTALQUERYRECEIVED_S, // CounterNameTitleIndex
  605. 0, // CounterNameTitle
  606. TOTALQUERYRECEIVED_S, // CounterHelpTitleIndex
  607. 0, // CounterHelpTitle
  608. 0, // DefaultScale
  609. PERF_DETAIL_NOVICE, // DetailLevel
  610. PERF_COUNTER_COUNTER, // CounterType
  611. sizeof(DWORD), // CounterSize
  612. TOTALQUERYRECEIVED_OFFSET // CounterOffset
  613. },
  614. // UDP query received
  615. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  616. UDPQUERYRECEIVED, // CounterNameTitleIndex
  617. 0, // CounterNameTitle
  618. UDPQUERYRECEIVED, // CounterHelpTitleIndex
  619. 0, // CounterHelpTitle
  620. 0, // DefaultScale
  621. PERF_DETAIL_NOVICE, // DetailLevel
  622. PERF_COUNTER_RAWCOUNT, // CounterType
  623. sizeof(DWORD), // CounterSize
  624. UDPQUERYRECEIVED_OFFSET // CounterOffset
  625. },
  626. // UDP query received/sec
  627. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  628. UDPQUERYRECEIVED_S, // CounterNameTitleIndex
  629. 0, // CounterNameTitle
  630. UDPQUERYRECEIVED_S, // CounterHelpTitleIndex
  631. 0, // CounterHelpTitle
  632. 0, // DefaultScale
  633. PERF_DETAIL_NOVICE, // DetailLevel
  634. PERF_COUNTER_COUNTER, // CounterType
  635. sizeof(DWORD), // CounterSize
  636. UDPQUERYRECEIVED_OFFSET // CounterOffset
  637. },
  638. // TCP query received
  639. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  640. TCPQUERYRECEIVED, // CounterNameTitleIndex
  641. 0, // CounterNameTitle
  642. TCPQUERYRECEIVED, // CounterHelpTitleIndex
  643. 0, // CounterHelpTitle
  644. 0, // DefaultScale
  645. PERF_DETAIL_NOVICE, // DetailLevel
  646. PERF_COUNTER_RAWCOUNT, // CounterType
  647. sizeof(DWORD), // CounterSize
  648. TCPQUERYRECEIVED_OFFSET // CounterOffset
  649. },
  650. // TCP query received/sec
  651. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  652. TCPQUERYRECEIVED_S, // CounterNameTitleIndex
  653. 0, // CounterNameTitle
  654. TCPQUERYRECEIVED_S, // CounterHelpTitleIndex
  655. 0, // CounterHelpTitle
  656. 0, // DefaultScale
  657. PERF_DETAIL_NOVICE, // DetailLevel
  658. PERF_COUNTER_COUNTER, // CounterType
  659. sizeof(DWORD), // CounterSize
  660. TCPQUERYRECEIVED_OFFSET // CounterOffset
  661. },
  662. // total response sent
  663. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  664. TOTALRESPONSESENT, // CounterNameTitleIndex
  665. 0, // CounterNameTitle
  666. TOTALRESPONSESENT, // CounterHelpTitleIndex
  667. 0, // CounterHelpTitle
  668. 0, // DefaultScale
  669. PERF_DETAIL_NOVICE, // DetailLevel
  670. PERF_COUNTER_RAWCOUNT, // CounterType
  671. sizeof(DWORD), // CounterSize
  672. TOTALRESPONSESENT_OFFSET // CounterOffset
  673. },
  674. // total response sent/sec
  675. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  676. TOTALRESPONSESENT_S, // CounterNameTitleIndex
  677. 0, // CounterNameTitle
  678. TOTALRESPONSESENT_S, // CounterHelpTitleIndex
  679. 0, // CounterHelpTitle
  680. 0, // DefaultScale
  681. PERF_DETAIL_NOVICE, // DetailLevel
  682. PERF_COUNTER_COUNTER, // CounterType
  683. sizeof(DWORD), // CounterSize
  684. TOTALRESPONSESENT_OFFSET // CounterOffset
  685. },
  686. // UDP response sent
  687. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  688. UDPRESPONSESENT, // CounterNameTitleIndex
  689. 0, // CounterNameTitle
  690. UDPRESPONSESENT, // CounterHelpTitleIndex
  691. 0, // CounterHelpTitle
  692. 0, // DefaultScale
  693. PERF_DETAIL_NOVICE, // DetailLevel
  694. PERF_COUNTER_RAWCOUNT, // CounterType
  695. sizeof(DWORD), // CounterSize
  696. UDPRESPONSESENT_OFFSET // CounterOffset
  697. },
  698. // UDP response sent/sec
  699. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  700. UDPRESPONSESENT_S, // CounterNameTitleIndex
  701. 0, // CounterNameTitle
  702. UDPRESPONSESENT_S, // CounterHelpTitleIndex
  703. 0, // CounterHelpTitle
  704. 0, // DefaultScale
  705. PERF_DETAIL_NOVICE, // DetailLevel
  706. PERF_COUNTER_COUNTER, // CounterType
  707. sizeof(DWORD), // CounterSize
  708. UDPRESPONSESENT_OFFSET // CounterOffset
  709. },
  710. // TCP response sent
  711. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  712. TCPRESPONSESENT, // CounterNameTitleIndex
  713. 0, // CounterNameTitle
  714. TCPRESPONSESENT, // CounterHelpTitleIndex
  715. 0, // CounterHelpTitle
  716. 0, // DefaultScale
  717. PERF_DETAIL_NOVICE, // DetailLevel
  718. PERF_COUNTER_RAWCOUNT, // CounterType
  719. sizeof(DWORD), // CounterSize
  720. TCPRESPONSESENT_OFFSET // CounterOffset
  721. },
  722. // TCP response sent/sec
  723. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  724. TCPRESPONSESENT_S, // CounterNameTitleIndex
  725. 0, // CounterNameTitle
  726. TCPRESPONSESENT_S, // CounterHelpTitleIndex
  727. 0, // CounterHelpTitle
  728. 0, // DefaultScale
  729. PERF_DETAIL_NOVICE, // DetailLevel
  730. PERF_COUNTER_COUNTER, // CounterType
  731. sizeof(DWORD), // CounterSize
  732. TCPRESPONSESENT_OFFSET // CounterOffset
  733. },
  734. // recursive query received
  735. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  736. RECURSIVEQUERIES, // CounterNameTitleIndex
  737. 0, // CounterNameTitle
  738. RECURSIVEQUERIES, // CounterHelpTitleIndex
  739. 0, // CounterHelpTitle
  740. 0, // DefaultScale
  741. PERF_DETAIL_NOVICE, // DetailLevel
  742. PERF_COUNTER_RAWCOUNT, // CounterType
  743. sizeof(DWORD), // CounterSize
  744. RECURSIVEQUERIES_OFFSET // CounterOffset
  745. },
  746. // recursive query received/s
  747. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  748. RECURSIVEQUERIES_S, // CounterNameTitleIndex
  749. 0, // CounterNameTitle
  750. RECURSIVEQUERIES_S, // CounterHelpTitleIndex
  751. 0, // CounterHelpTitle
  752. 0, // DefaultScale
  753. PERF_DETAIL_NOVICE, // DetailLevel
  754. PERF_COUNTER_COUNTER, // CounterType
  755. sizeof(DWORD), // CounterSize
  756. RECURSIVEQUERIES_OFFSET // CounterOffset
  757. },
  758. // recursive query timeout
  759. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  760. RECURSIVETIMEOUT, // CounterNameTitleIndex
  761. 0, // CounterNameTitle
  762. RECURSIVETIMEOUT, // CounterHelpTitleIndex
  763. 0, // CounterHelpTitle
  764. 0, // DefaultScale
  765. PERF_DETAIL_NOVICE, // DetailLevel
  766. PERF_COUNTER_RAWCOUNT, // CounterType
  767. sizeof(DWORD), // CounterSize
  768. RECURSIVETIMEOUT_OFFSET // CounterOffset
  769. },
  770. // recursive query timeout/s
  771. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  772. RECURSIVETIMEOUT_S, // CounterNameTitleIndex
  773. 0, // CounterNameTitle
  774. RECURSIVETIMEOUT_S, // CounterHelpTitleIndex
  775. 0, // CounterHelpTitle
  776. 0, // DefaultScale
  777. PERF_DETAIL_NOVICE, // DetailLevel
  778. PERF_COUNTER_COUNTER, // CounterType
  779. sizeof(DWORD), // CounterSize
  780. RECURSIVETIMEOUT_OFFSET // CounterOffset
  781. },
  782. // recursive query failure
  783. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  784. RECURSIVEQUERYFAILURE, // CounterNameTitleIndex
  785. 0, // CounterNameTitle
  786. RECURSIVEQUERYFAILURE, // CounterHelpTitleIndex
  787. 0, // CounterHelpTitle
  788. 0, // DefaultScale
  789. PERF_DETAIL_NOVICE, // DetailLevel
  790. PERF_COUNTER_RAWCOUNT, // CounterType
  791. sizeof(DWORD), // CounterSize
  792. RECURSIVEQUERYFAILURE_OFFSET // CounterOffset
  793. },
  794. // recursive query failure/s
  795. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  796. RECURSIVEQUERYFAILURE_S, // CounterNameTitleIndex
  797. 0, // CounterNameTitle
  798. RECURSIVEQUERYFAILURE_S, // CounterHelpTitleIndex
  799. 0, // CounterHelpTitle
  800. 0, // DefaultScale
  801. PERF_DETAIL_NOVICE, // DetailLevel
  802. PERF_COUNTER_COUNTER, // CounterType
  803. sizeof(DWORD), // CounterSize
  804. RECURSIVEQUERYFAILURE_OFFSET // CounterOffset
  805. },
  806. // notify sent
  807. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  808. NOTIFYSENT, // CounterNameTitleIndex
  809. 0, // CounterNameTitle
  810. NOTIFYSENT, // CounterHelpTitleIndex
  811. 0, // CounterHelpTitle
  812. 0, // DefaultScale
  813. PERF_DETAIL_NOVICE, // DetailLevel
  814. PERF_COUNTER_RAWCOUNT, // CounterType
  815. sizeof(DWORD), // CounterSize
  816. NOTIFYSENT_OFFSET // CounterOffset
  817. },
  818. // zone transfer request received
  819. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  820. ZONETRANSFERREQUESTRECEIVED, // CounterNameTitleIndex
  821. 0, // CounterNameTitle
  822. ZONETRANSFERREQUESTRECEIVED, // CounterHelpTitleIndex
  823. 0, // CounterHelpTitle
  824. 0, // DefaultScale
  825. PERF_DETAIL_NOVICE, // DetailLevel
  826. PERF_COUNTER_RAWCOUNT, // CounterType
  827. sizeof(DWORD), // CounterSize
  828. ZONETRANSFERREQUESTRECEIVED_OFFSET // CounterOffset
  829. },
  830. // zone transfer success
  831. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  832. ZONETRANSFERSUCCESS, // CounterNameTitleIndex
  833. 0, // CounterNameTitle
  834. ZONETRANSFERSUCCESS, // CounterHelpTitleIndex
  835. 0, // CounterHelpTitle
  836. 0, // DefaultScale
  837. PERF_DETAIL_NOVICE, // DetailLevel
  838. PERF_COUNTER_RAWCOUNT, // CounterType
  839. sizeof(DWORD), // CounterSize
  840. ZONETRANSFERSUCCESS_OFFSET // CounterOffset
  841. },
  842. // zone transfer failure
  843. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  844. ZONETRANSFERFAILURE, // CounterNameTitleIndex
  845. 0, // CounterNameTitle
  846. ZONETRANSFERFAILURE, // CounterHelpTitleIndex
  847. 0, // CounterHelpTitle
  848. 0, // DefaultScale
  849. PERF_DETAIL_NOVICE, // DetailLevel
  850. PERF_COUNTER_RAWCOUNT, // CounterType
  851. sizeof(DWORD), // CounterSize
  852. ZONETRANSFERFAILURE_OFFSET // CounterOffset
  853. },
  854. // AXFR request received
  855. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  856. AXFRREQUESTRECEIVED, // CounterNameTitleIndex
  857. 0, // CounterNameTitle
  858. AXFRREQUESTRECEIVED, // CounterHelpTitleIndex
  859. 0, // CounterHelpTitle
  860. 0, // DefaultScale
  861. PERF_DETAIL_NOVICE, // DetailLevel
  862. PERF_COUNTER_RAWCOUNT, // CounterType
  863. sizeof(DWORD), // CounterSize
  864. AXFRREQUESTRECEIVED_OFFSET // CounterOffset
  865. },
  866. // AXFR success sent
  867. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  868. AXFRSUCCESSSENT, // CounterNameTitleIndex
  869. 0, // CounterNameTitle
  870. AXFRSUCCESSSENT, // CounterHelpTitleIndex
  871. 0, // CounterHelpTitle
  872. 0, // DefaultScale
  873. PERF_DETAIL_NOVICE, // DetailLevel
  874. PERF_COUNTER_RAWCOUNT, // CounterType
  875. sizeof(DWORD), // CounterSize
  876. AXFRSUCCESSSENT_OFFSET // CounterOffset
  877. },
  878. // IXFR request received
  879. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  880. IXFRREQUESTRECEIVED, // CounterNameTitleIndex
  881. 0, // CounterNameTitle
  882. IXFRREQUESTRECEIVED, // CounterHelpTitleIndex
  883. 0, // CounterHelpTitle
  884. 0, // DefaultScale
  885. PERF_DETAIL_NOVICE, // DetailLevel
  886. PERF_COUNTER_RAWCOUNT, // CounterType
  887. sizeof(DWORD), // CounterSize
  888. IXFRREQUESTRECEIVED_OFFSET // CounterOffset
  889. },
  890. // IXFR success sent
  891. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  892. IXFRSUCCESSSENT, // CounterNameTitleIndex
  893. 0, // CounterNameTitle
  894. IXFRSUCCESSSENT, // CounterHelpTitleIndex
  895. 0, // CounterHelpTitle
  896. 0, // DefaultScale
  897. PERF_DETAIL_NOVICE, // DetailLevel
  898. PERF_COUNTER_RAWCOUNT, // CounterType
  899. sizeof(DWORD), // CounterSize
  900. IXFRSUCCESSSENT_OFFSET // CounterOffset
  901. },
  902. // notify received
  903. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  904. NOTIFYRECEIVED, // CounterNameTitleIndex
  905. 0, // CounterNameTitle
  906. NOTIFYRECEIVED, // CounterHelpTitleIndex
  907. 0, // CounterHelpTitle
  908. 0, // DefaultScale
  909. PERF_DETAIL_NOVICE, // DetailLevel
  910. PERF_COUNTER_RAWCOUNT, // CounterType
  911. sizeof(DWORD), // CounterSize
  912. NOTIFYRECEIVED_OFFSET // CounterOffset
  913. },
  914. // zone transfer SOA request sent
  915. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  916. ZONETRANSFERSOAREQUESTSENT, // CounterNameTitleIndex
  917. 0, // CounterNameTitle
  918. ZONETRANSFERSOAREQUESTSENT, // CounterHelpTitleIndex
  919. 0, // CounterHelpTitle
  920. 0, // DefaultScale
  921. PERF_DETAIL_NOVICE, // DetailLevel
  922. PERF_COUNTER_RAWCOUNT, // CounterType
  923. sizeof(DWORD), // CounterSize
  924. ZONETRANSFERSOAREQUESTSENT_OFFSET // CounterOffset
  925. },
  926. // AXFR request sent
  927. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  928. AXFRREQUESTSENT, // CounterNameTitleIndex
  929. 0, // CounterNameTitle
  930. AXFRREQUESTSENT, // CounterHelpTitleIndex
  931. 0, // CounterHelpTitle
  932. 0, // DefaultScale
  933. PERF_DETAIL_NOVICE, // DetailLevel
  934. PERF_COUNTER_RAWCOUNT, // CounterType
  935. sizeof(DWORD), // CounterSize
  936. AXFRREQUESTSENT_OFFSET // CounterOffset
  937. },
  938. // AXFR response received
  939. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  940. AXFRRESPONSERECEIVED, // CounterNameTitleIndex
  941. 0, // CounterNameTitle
  942. AXFRRESPONSERECEIVED, // CounterHelpTitleIndex
  943. 0, // CounterHelpTitle
  944. 0, // DefaultScale
  945. PERF_DETAIL_NOVICE, // DetailLevel
  946. PERF_COUNTER_RAWCOUNT, // CounterType
  947. sizeof(DWORD), // CounterSize
  948. AXFRRESPONSERECEIVED_OFFSET // CounterOffset
  949. },
  950. // AXFR success received
  951. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  952. AXFRSUCCESSRECEIVED, // CounterNameTitleIndex
  953. 0, // CounterNameTitle
  954. AXFRSUCCESSRECEIVED, // CounterHelpTitleIndex
  955. 0, // CounterHelpTitle
  956. 0, // DefaultScale
  957. PERF_DETAIL_NOVICE, // DetailLevel
  958. PERF_COUNTER_RAWCOUNT, // CounterType
  959. sizeof(DWORD), // CounterSize
  960. AXFRSUCCESSRECEIVED_OFFSET // CounterOffset
  961. },
  962. // IXFR request sent
  963. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  964. IXFRREQUESTSENT, // CounterNameTitleIndex
  965. 0, // CounterNameTitle
  966. IXFRREQUESTSENT, // CounterHelpTitleIndex
  967. 0, // CounterHelpTitle
  968. 0, // DefaultScale
  969. PERF_DETAIL_NOVICE, // DetailLevel
  970. PERF_COUNTER_RAWCOUNT, // CounterType
  971. sizeof(DWORD), // CounterSize
  972. IXFRREQUESTSENT_OFFSET // CounterOffset
  973. },
  974. // IXFR response received
  975. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  976. IXFRRESPONSERECEIVED, // CounterNameTitleIndex
  977. 0, // CounterNameTitle
  978. IXFRRESPONSERECEIVED, // CounterHelpTitleIndex
  979. 0, // CounterHelpTitle
  980. 0, // DefaultScale
  981. PERF_DETAIL_NOVICE, // DetailLevel
  982. PERF_COUNTER_RAWCOUNT, // CounterType
  983. sizeof(DWORD), // CounterSize
  984. IXFRRESPONSERECEIVED_OFFSET // CounterOffset
  985. },
  986. // IXFR succes received
  987. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  988. IXFRSUCCESSRECEIVED, // CounterNameTitleIndex
  989. 0, // CounterNameTitle
  990. IXFRSUCCESSRECEIVED, // CounterHelpTitleIndex
  991. 0, // CounterHelpTitle
  992. 0, // DefaultScale
  993. PERF_DETAIL_NOVICE, // DetailLevel
  994. PERF_COUNTER_RAWCOUNT, // CounterType
  995. sizeof(DWORD), // CounterSize
  996. IXFRSUCCESSRECEIVED_OFFSET // CounterOffset
  997. },
  998. // IXFR UDP success received
  999. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1000. IXFRUDPSUCCESSRECEIVED, // CounterNameTitleIndex
  1001. 0, // CounterNameTitle
  1002. IXFRUDPSUCCESSRECEIVED, // CounterHelpTitleIndex
  1003. 0, // CounterHelpTitle
  1004. 0, // DefaultScale
  1005. PERF_DETAIL_NOVICE, // DetailLevel
  1006. PERF_COUNTER_RAWCOUNT, // CounterType
  1007. sizeof(DWORD), // CounterSize
  1008. IXFRUDPSUCCESSRECEIVED_OFFSET // CounterOffset
  1009. },
  1010. // IXFR TCP success received
  1011. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1012. IXFRTCPSUCCESSRECEIVED, // CounterNameTitleIndex
  1013. 0, // CounterNameTitle
  1014. IXFRTCPSUCCESSRECEIVED, // CounterHelpTitleIndex
  1015. 0, // CounterHelpTitle
  1016. 0, // DefaultScale
  1017. PERF_DETAIL_NOVICE, // DetailLevel
  1018. PERF_COUNTER_RAWCOUNT, // CounterType
  1019. sizeof(DWORD), // CounterSize
  1020. IXFRTCPSUCCESSRECEIVED_OFFSET // CounterOffset
  1021. },
  1022. // WINS lookup request received
  1023. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1024. WINSLOOKUPRECEIVED, // CounterNameTitleIndex
  1025. 0, // CounterNameTitle
  1026. WINSLOOKUPRECEIVED, // CounterHelpTitleIndex
  1027. 0, // CounterHelpTitle
  1028. 0, // DefaultScale
  1029. PERF_DETAIL_NOVICE, // DetailLevel
  1030. PERF_COUNTER_RAWCOUNT, // CounterType
  1031. sizeof(DWORD), // CounterSize
  1032. WINSLOOKUPRECEIVED_OFFSET // CounterOffset
  1033. },
  1034. // WINS lookup request received/sec
  1035. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1036. WINSLOOKUPRECEIVED_S, // CounterNameTitleIndex
  1037. 0, // CounterNameTitle
  1038. WINSLOOKUPRECEIVED_S, // CounterHelpTitleIndex
  1039. 0, // CounterHelpTitle
  1040. 0, // DefaultScale
  1041. PERF_DETAIL_NOVICE, // DetailLevel
  1042. PERF_COUNTER_COUNTER, // CounterType
  1043. sizeof(DWORD), // CounterSize
  1044. WINSLOOKUPRECEIVED_OFFSET // CounterOffset
  1045. },
  1046. // WINS response sent
  1047. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1048. WINSRESPONSESENT, // CounterNameTitleIndex
  1049. 0, // CounterNameTitle
  1050. WINSRESPONSESENT, // CounterHelpTitleIndex
  1051. 0, // CounterHelpTitle
  1052. 0, // DefaultScale
  1053. PERF_DETAIL_NOVICE, // DetailLevel
  1054. PERF_COUNTER_RAWCOUNT, // CounterType
  1055. sizeof(DWORD), // CounterSize
  1056. WINSRESPONSESENT_OFFSET // CounterOffset
  1057. },
  1058. // WINS response sent/sec
  1059. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1060. WINSRESPONSESENT_S, // CounterNameTitleIndex
  1061. 0, // CounterNameTitle
  1062. WINSRESPONSESENT_S, // CounterHelpTitleIndex
  1063. 0, // CounterHelpTitle
  1064. 0, // DefaultScale
  1065. PERF_DETAIL_NOVICE, // DetailLevel
  1066. PERF_COUNTER_COUNTER, // CounterType
  1067. sizeof(DWORD), // CounterSize
  1068. WINSRESPONSESENT_OFFSET // CounterOffset
  1069. },
  1070. // WINS reverse lookup received
  1071. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1072. WINSREVERSELOOKUPRECEIVED, // CounterNameTitleIndex
  1073. 0, // CounterNameTitle
  1074. WINSREVERSELOOKUPRECEIVED, // CounterHelpTitleIndex
  1075. 0, // CounterHelpTitle
  1076. 0, // DefaultScale
  1077. PERF_DETAIL_NOVICE, // DetailLevel
  1078. PERF_COUNTER_RAWCOUNT, // CounterType
  1079. sizeof(DWORD), // CounterSize
  1080. WINSREVERSELOOKUPRECEIVED_OFFSET // CounterOffset
  1081. },
  1082. // WINS reverse lookup received/sec
  1083. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1084. WINSREVERSELOOKUPRECEIVED_S, // CounterNameTitleIndex
  1085. 0, // CounterNameTitle
  1086. WINSREVERSELOOKUPRECEIVED_S, // CounterHelpTitleIndex
  1087. 0, // CounterHelpTitle
  1088. 0, // DefaultScale
  1089. PERF_DETAIL_NOVICE, // DetailLevel
  1090. PERF_COUNTER_RAWCOUNT, // CounterType
  1091. sizeof(DWORD), // CounterSize
  1092. WINSREVERSELOOKUPRECEIVED_OFFSET // CounterOffset
  1093. },
  1094. // WINS reverse response sent
  1095. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1096. WINSREVERSERESPONSESENT, // CounterNameTitleIndex
  1097. 0, // CounterNameTitle
  1098. WINSREVERSERESPONSESENT, // CounterHelpTitleIndex
  1099. 0, // CounterHelpTitle
  1100. 0, // DefaultScale
  1101. PERF_DETAIL_NOVICE, // DetailLevel
  1102. PERF_COUNTER_RAWCOUNT, // CounterType
  1103. sizeof(DWORD), // CounterSize
  1104. WINSREVERSERESPONSESENT_OFFSET // CounterOffset
  1105. },
  1106. // WINS reverse response sent/sec
  1107. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1108. WINSREVERSERESPONSESENT_S, // CounterNameTitleIndex
  1109. 0, // CounterNameTitle
  1110. WINSREVERSERESPONSESENT_S, // CounterHelpTitleIndex
  1111. 0, // CounterHelpTitle
  1112. 0, // DefaultScale
  1113. PERF_DETAIL_NOVICE, // DetailLevel
  1114. PERF_COUNTER_COUNTER, // CounterType
  1115. sizeof(DWORD), // CounterSize
  1116. WINSREVERSERESPONSESENT_OFFSET // CounterOffset
  1117. },
  1118. // dynamic update received
  1119. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1120. DYNAMICUPDATERECEIVED, // CounterNameTitleIndex
  1121. 0, // CounterNameTitle
  1122. DYNAMICUPDATERECEIVED, // CounterHelpTitleIndex
  1123. 0, // CounterHelpTitle
  1124. 0, // DefaultScale
  1125. PERF_DETAIL_NOVICE, // DetailLevel
  1126. PERF_COUNTER_RAWCOUNT, // CounterType
  1127. sizeof(DWORD), // CounterSize
  1128. DYNAMICUPDATERECEIVED_OFFSET // CounterOffset
  1129. },
  1130. // dynamic update received/sec
  1131. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1132. DYNAMICUPDATERECEIVED_S, // CounterNameTitleIndex
  1133. 0, // CounterNameTitle
  1134. DYNAMICUPDATERECEIVED_S, // CounterHelpTitleIndex
  1135. 0, // CounterHelpTitle
  1136. 0, // DefaultScale
  1137. PERF_DETAIL_NOVICE, // DetailLevel
  1138. PERF_COUNTER_COUNTER, // CounterType
  1139. sizeof(DWORD), // CounterSize
  1140. DYNAMICUPDATERECEIVED_OFFSET // CounterOffset
  1141. },
  1142. // dynamic update NoOperation & Empty
  1143. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1144. DYNAMICUPDATENOOP, // CounterNameTitleIndex
  1145. 0, // CounterNameTitle
  1146. DYNAMICUPDATENOOP, // CounterHelpTitleIndex
  1147. 0, // CounterHelpTitle
  1148. 0, // DefaultScale
  1149. PERF_DETAIL_NOVICE, // DetailLevel
  1150. PERF_COUNTER_RAWCOUNT, // CounterType
  1151. sizeof(DWORD), // CounterSize
  1152. DYNAMICUPDATENOOP_OFFSET // CounterOffset
  1153. },
  1154. // dynamic update NoOperation & Empty/sec
  1155. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1156. DYNAMICUPDATENOOP_S, // CounterNameTitleIndex
  1157. 0, // CounterNameTitle
  1158. DYNAMICUPDATENOOP_S, // CounterHelpTitleIndex
  1159. 0, // CounterHelpTitle
  1160. 0, // DefaultScale
  1161. PERF_DETAIL_NOVICE, // DetailLevel
  1162. PERF_COUNTER_COUNTER, // CounterType
  1163. sizeof(DWORD), // CounterSize
  1164. DYNAMICUPDATENOOP_OFFSET // CounterOffset
  1165. },
  1166. // dynamic update write to database (completed)
  1167. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1168. DYNAMICUPDATEWRITETODB, // CounterNameTitleIndex
  1169. 0, // CounterNameTitle
  1170. DYNAMICUPDATEWRITETODB, // CounterHelpTitleIndex
  1171. 0, // CounterHelpTitle
  1172. 0, // DefaultScale
  1173. PERF_DETAIL_NOVICE, // DetailLevel
  1174. PERF_COUNTER_RAWCOUNT, // CounterType
  1175. sizeof(DWORD), // CounterSize
  1176. DYNAMICUPDATEWRITETODB_OFFSET // CounterOffset
  1177. },
  1178. // dynamic update write to database (completed)/sec
  1179. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1180. DYNAMICUPDATEWRITETODB_S, // CounterNameTitleIndex
  1181. 0, // CounterNameTitle
  1182. DYNAMICUPDATEWRITETODB_S, // CounterHelpTitleIndex
  1183. 0, // CounterHelpTitle
  1184. 0, // DefaultScale
  1185. PERF_DETAIL_NOVICE, // DetailLevel
  1186. PERF_COUNTER_COUNTER, // CounterType
  1187. sizeof(DWORD), // CounterSize
  1188. DYNAMICUPDATEWRITETODB_OFFSET // CounterOffset
  1189. },
  1190. // dynamic update rejected
  1191. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1192. DYNAMICUPDATEREJECTED, // CounterNameTitleIndex
  1193. 0, // CounterNameTitle
  1194. DYNAMICUPDATEREJECTED, // CounterHelpTitleIndex
  1195. 0, // CounterHelpTitle
  1196. 0, // DefaultScale
  1197. PERF_DETAIL_NOVICE, // DetailLevel
  1198. PERF_COUNTER_RAWCOUNT, // CounterType
  1199. sizeof(DWORD), // CounterSize
  1200. DYNAMICUPDATEREJECTED_OFFSET // CounterOffset
  1201. },
  1202. // dynamic update timeout
  1203. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1204. DYNAMICUPDATETIMEOUT, // CounterNameTitleIndex
  1205. 0, // CounterNameTitle
  1206. DYNAMICUPDATETIMEOUT, // CounterHelpTitleIndex
  1207. 0, // CounterHelpTitle
  1208. 0, // DefaultScale
  1209. PERF_DETAIL_NOVICE, // DetailLevel
  1210. PERF_COUNTER_RAWCOUNT, // CounterType
  1211. sizeof(DWORD), // CounterSize
  1212. DYNAMICUPDATETIMEOUT_OFFSET // CounterOffset
  1213. },
  1214. // dynamic update queued
  1215. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1216. DYNAMICUPDATEQUEUED, // CounterNameTitleIndex
  1217. 0, // CounterNameTitle
  1218. DYNAMICUPDATEQUEUED, // CounterHelpTitleIndex
  1219. 0, // CounterHelpTitle
  1220. 0, // DefaultScale
  1221. PERF_DETAIL_NOVICE, // DetailLevel
  1222. PERF_COUNTER_RAWCOUNT, // CounterType
  1223. sizeof(DWORD), // CounterSize
  1224. DYNAMICUPDATEQUEUED_OFFSET // CounterOffset
  1225. },
  1226. // secure update received
  1227. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1228. SECUREUPDATERECEIVED, // CounterNameTitleIndex
  1229. 0, // CounterNameTitle
  1230. SECUREUPDATERECEIVED, // CounterHelpTitleIndex
  1231. 0, // CounterHelpTitle
  1232. 0, // DefaultScale
  1233. PERF_DETAIL_NOVICE, // DetailLevel
  1234. PERF_COUNTER_RAWCOUNT, // CounterType
  1235. sizeof(DWORD), // CounterSize
  1236. SECUREUPDATERECEIVED_OFFSET // CounterOffset
  1237. },
  1238. // secure update received/sec
  1239. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1240. SECUREUPDATERECEIVED_S, // CounterNameTitleIndex
  1241. 0, // CounterNameTitle
  1242. SECUREUPDATERECEIVED_S, // CounterHelpTitleIndex
  1243. 0, // CounterHelpTitle
  1244. 0, // DefaultScale
  1245. PERF_DETAIL_NOVICE, // DetailLevel
  1246. PERF_COUNTER_COUNTER, // CounterType
  1247. sizeof(DWORD), // CounterSize
  1248. SECUREUPDATERECEIVED_OFFSET // CounterOffset
  1249. },
  1250. // secure update failure
  1251. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1252. SECUREUPDATEFAILURE, // CounterNameTitleIndex
  1253. 0, // CounterNameTitle
  1254. SECUREUPDATEFAILURE, // CounterHelpTitleIndex
  1255. 0, // CounterHelpTitle
  1256. 0, // DefaultScale
  1257. PERF_DETAIL_NOVICE, // DetailLevel
  1258. PERF_COUNTER_RAWCOUNT, // CounterType
  1259. sizeof(DWORD), // CounterSize
  1260. SECUREUPDATEFAILURE_OFFSET // CounterOffset
  1261. },
  1262. // database node memory
  1263. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1264. DATABASENODEMEMORY, // CounterNameTitleIndex
  1265. 0, // CounterNameTitle
  1266. DATABASENODEMEMORY, // CounterHelpTitleIndex
  1267. 0, // CounterHelpTitle
  1268. 0, // DefaultScale
  1269. PERF_DETAIL_NOVICE, // DetailLevel
  1270. PERF_COUNTER_RAWCOUNT, // CounterType
  1271. sizeof(DWORD), // CounterSize
  1272. DATABASENODEMEMORY_OFFSET // CounterOffset
  1273. },
  1274. // record flow memory
  1275. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1276. RECORDFLOWMEMORY, // CounterNameTitleIndex
  1277. 0, // CounterNameTitle
  1278. RECORDFLOWMEMORY, // CounterHelpTitleIndex
  1279. 0, // CounterHelpTitle
  1280. 0, // DefaultScale
  1281. PERF_DETAIL_NOVICE, // DetailLevel
  1282. PERF_COUNTER_RAWCOUNT, // CounterType
  1283. sizeof(DWORD), // CounterSize
  1284. RECORDFLOWMEMORY_OFFSET // CounterOffset
  1285. },
  1286. // caching memory
  1287. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1288. CACHINGMEMORY, // CounterNameTitleIndex
  1289. 0, // CounterNameTitle
  1290. CACHINGMEMORY, // CounterHelpTitleIndex
  1291. 0, // CounterHelpTitle
  1292. 0, // DefaultScale
  1293. PERF_DETAIL_NOVICE, // DetailLevel
  1294. PERF_COUNTER_RAWCOUNT, // CounterType
  1295. sizeof(DWORD), // CounterSize
  1296. CACHINGMEMORY_OFFSET // CounterOffset
  1297. },
  1298. // UDP message memory
  1299. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1300. UDPMESSAGEMEMORY, // CounterNameTitleIndex
  1301. 0, // CounterNameTitle
  1302. UDPMESSAGEMEMORY, // CounterHelpTitleIndex
  1303. 0, // CounterHelpTitle
  1304. 0, // DefaultScale
  1305. PERF_DETAIL_NOVICE, // DetailLevel
  1306. PERF_COUNTER_RAWCOUNT, // CounterType
  1307. sizeof(DWORD), // CounterSize
  1308. UDPMESSAGEMEMORY_OFFSET // CounterOffset
  1309. },
  1310. // TCP message memory
  1311. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1312. TCPMESSAGEMEMORY, // CounterNameTitleIndex
  1313. 0, // CounterNameTitle
  1314. TCPMESSAGEMEMORY, // CounterHelpTitleIndex
  1315. 0, // CounterHelpTitle
  1316. 0, // DefaultScale
  1317. PERF_DETAIL_NOVICE, // DetailLevel
  1318. PERF_COUNTER_RAWCOUNT, // CounterType
  1319. sizeof(DWORD), // CounterSize
  1320. TCPMESSAGEMEMORY_OFFSET // CounterOffset
  1321. },
  1322. // Nbstat memory
  1323. { sizeof(PERF_COUNTER_DEFINITION), // ByteLength
  1324. NBSTATMEMORY, // CounterNameTitleIndex
  1325. 0, // CounterNameTitle
  1326. NBSTATMEMORY, // CounterHelpTitleIndex
  1327. 0, // CounterHelpTitle
  1328. 0, // DefaultScale
  1329. PERF_DETAIL_NOVICE, // DetailLevel
  1330. PERF_COUNTER_RAWCOUNT, // CounterType
  1331. sizeof(DWORD), // CounterSize
  1332. NBSTATMEMORY_OFFSET // CounterOffset
  1333. },
  1334. };
  1335. int APIENTRY _CRT_INIT(
  1336. HANDLE hInstance,
  1337. DWORD ulReasonBeingCalled,
  1338. LPVOID lpReserved);
  1339. int __stdcall LibMain(
  1340. HANDLE hInstance,
  1341. DWORD ulReasonBeingCalled,
  1342. LPVOID lpReserved)
  1343. {
  1344. return (_CRT_INIT(hInstance, ulReasonBeingCalled,lpReserved));
  1345. }
  1346. //
  1347. // End dnsperf.c
  1348. //