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.

1756 lines
62 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. perfnntp.c
  7. This file implements the Extensible Performance Objects for
  8. the NNTP Server service.
  9. FILE HISTORY:
  10. KeithMo 07-Jun-1993 Created, based on RussBl's sample code.
  11. */
  12. #define INITGUID
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <winperf.h>
  18. #include <lm.h>
  19. #include <string.h>
  20. //#include <wcstr.h>
  21. #include <nntpctrs.h>
  22. #include <perfmsg.h>
  23. #include <nntps.h>
  24. #include <nntptype.h>
  25. #include <nntpapi.h>
  26. extern "C" {
  27. #include <perfutil.h>
  28. #include <nntpdata.h>
  29. }
  30. #include <ole2.h>
  31. #include "iadm.h"
  32. #define APP_NAME (TEXT("NntpCtrs"))
  33. #define MAX_SIZEOF_INSTANCE_NAME 128
  34. #define TOTAL_INSTANCE_NAME L"_Total"
  35. //
  36. // Private constants.
  37. //
  38. #if DBG
  39. #undef IF_DEBUG
  40. #define IF_DEBUG(flag) if ( NntpDebug & TCP_ ## flag )
  41. #undef DBG_CONTEXT
  42. #define DBG_CONTEXT NULL
  43. #define TCP_ENTRYPOINTS 0x00001000
  44. #define TCP_COLLECT 0X00002000
  45. #endif //DBG
  46. //
  47. // Private globals.
  48. //
  49. DWORD cOpens = 0; // Active "opens" reference count.
  50. BOOL fInitOK = FALSE; // TRUE if DLL initialized OK.
  51. IMSAdminBaseW * g_pAdminBase = NULL;
  52. #if DBG
  53. DWORD NntpDebug = 0; // Debug behaviour flags.
  54. #endif // DBG
  55. //
  56. // Private prototypes.
  57. //
  58. VOID
  59. CopyStatisticsData1(
  60. IN NNTP_STATISTICS_0 * pNntpStats,
  61. OUT NNTP_COUNTER_BLOCK1 * pCounterBlock
  62. );
  63. VOID
  64. CopyStatisticsData2(
  65. IN NNTP_STATISTICS_0 * pNntpStats,
  66. OUT NNTP_COUNTER_BLOCK2 * pCounterBlock
  67. );
  68. VOID
  69. Update_TotalStatisticsData1(
  70. IN NNTP_COUNTER_BLOCK1 * pCounterBlock,
  71. OUT NNTP_COUNTER_BLOCK1 * pTotal
  72. );
  73. VOID
  74. Update_TotalStatisticsData2(
  75. IN NNTP_COUNTER_BLOCK2 * pCounterBlock,
  76. OUT NNTP_COUNTER_BLOCK2 * pTotal
  77. );
  78. VOID
  79. UpdateNameAndHelpIndicies(
  80. IN DWORD dwFirstCounter,
  81. IN DWORD dwFirstHelp
  82. );
  83. HRESULT
  84. InitAdminBase();
  85. VOID
  86. UninitAdminBase();
  87. HRESULT
  88. OpenAdminBaseKey(
  89. OUT METADATA_HANDLE *phHandle
  90. );
  91. VOID
  92. CloseAdminBaseKey(
  93. IN METADATA_HANDLE hHandle
  94. );
  95. //
  96. // Public prototypes.
  97. //
  98. PM_OPEN_PROC OpenNntpPerformanceData;
  99. PM_COLLECT_PROC CollectNntpPerformanceData;
  100. PM_CLOSE_PROC CloseNntpPerformanceData;
  101. //
  102. // Public functions.
  103. //
  104. /*******************************************************************
  105. NAME: OpenNntpPerformanceData
  106. SYNOPSIS: Initializes the data structures used to communicate
  107. performance counters with the registry.
  108. ENTRY: lpDeviceNames - Poitner to object ID of each device
  109. to be opened.
  110. RETURNS: DWORD - Win32 status code.
  111. HISTORY:
  112. KeithMo 07-Jun-1993 Created.
  113. ********************************************************************/
  114. DWORD
  115. OpenNntpPerformanceData(
  116. LPWSTR lpDeviceNames
  117. )
  118. {
  119. DWORD err = NO_ERROR;
  120. HKEY hkey = NULL;
  121. DWORD size;
  122. DWORD type;
  123. DWORD dwFirstCounter;
  124. DWORD dwFirstHelp;
  125. //PERF_COUNTER_DEFINITION * pctr;
  126. //
  127. // Since SCREG is multi-threaded and will call this routine in
  128. // order to service remote performance queries, this library
  129. // must keep track of how many times it has been opened (i.e.
  130. // how many threads have accessed it). The registry routines will
  131. // limit access to the initialization routine to only one thread
  132. // at a time so synchronization (i.e. reentrancy) should not be
  133. // a problem.
  134. //
  135. if( !fInitOK ) {
  136. //
  137. // This is the *first* open.
  138. //
  139. //
  140. // Open the NNTP Server service's Performance key.
  141. //
  142. err = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
  143. NNTP_PERFORMANCE_KEY,
  144. 0,
  145. KEY_READ,
  146. &hkey );
  147. if( err == NO_ERROR )
  148. {
  149. //
  150. // Read the first counter DWORD.
  151. //
  152. size = sizeof(DWORD);
  153. err = RegQueryValueEx( hkey,
  154. "First Counter",
  155. NULL,
  156. &type,
  157. (LPBYTE)&dwFirstCounter,
  158. &size );
  159. }
  160. if( err == NO_ERROR )
  161. {
  162. //
  163. // Read the first help DWORD.
  164. //
  165. size = sizeof(DWORD);
  166. err = RegQueryValueEx( hkey,
  167. "First Help",
  168. NULL,
  169. &type,
  170. (LPBYTE)&dwFirstHelp,
  171. &size );
  172. }
  173. if ( err == NO_ERROR ) {
  174. //
  175. // Update the object & counter name & help indicies.
  176. //
  177. UpdateNameAndHelpIndicies( dwFirstCounter, dwFirstHelp );
  178. //
  179. // Remember that we initialized OK.
  180. //
  181. fInitOK = TRUE;
  182. }
  183. //
  184. // Close the registry if we managed to actually open it.
  185. //
  186. if( hkey != NULL )
  187. {
  188. RegCloseKey( hkey );
  189. hkey = NULL;
  190. }
  191. g_pAdminBase = NULL;
  192. }
  193. //
  194. // Bump open counter.
  195. //
  196. cOpens++;
  197. return NO_ERROR;
  198. } // OpenNntpPerformanceData
  199. /*******************************************************************
  200. NAME: CollectNntpPerformanceData
  201. SYNOPSIS: Initializes the data structures used to communicate
  202. ENTRY: lpValueName - The name of the value to retrieve.
  203. lppData - On entry contains a pointer to the buffer to
  204. receive the completed PerfDataBlock & subordinate
  205. structures. On exit, points to the first bytes
  206. *after* the data structures added by this routine.
  207. lpcbTotalBytes - On entry contains a pointer to the
  208. size (in BYTEs) of the buffer referenced by lppData.
  209. On exit, contains the number of BYTEs added by this
  210. routine.
  211. lpNumObjectTypes - Receives the number of objects added
  212. by this routine.
  213. RETURNS: DWORD - Win32 status code. MUST be either NO_ERROR
  214. or ERROR_MORE_DATA.
  215. HISTORY:
  216. KeithMo 07-Jun-1993 Created.
  217. ********************************************************************/
  218. DWORD CollectNntpPerformanceData(
  219. LPWSTR lpValueName,
  220. LPVOID * lppData,
  221. LPDWORD lpcbTotalBytes,
  222. LPDWORD lpNumObjectTypes
  223. )
  224. {
  225. PERF_INSTANCE_DEFINITION *pPerfInstanceDefinition;
  226. DWORD dwInstanceIndex = 0;
  227. DWORD dwInstanceCount = 0;
  228. DWORD dwCount = 0;
  229. DWORD i = 0;
  230. DWORD dwQueryType;
  231. ULONG cbRequired;
  232. //DWORD *pdwCounter;
  233. //LARGE_INTEGER *pliCounter;
  234. NNTP_COUNTER_BLOCK1 *pCounterBlock1;
  235. NNTP_COUNTER_BLOCK1 *pTotal1;
  236. NNTP_COUNTER_BLOCK2 *pCounterBlock2;
  237. NNTP_COUNTER_BLOCK2 *pTotal2;
  238. NNTP_DATA_DEFINITION_OBJECT1 *pNntpDataDefinitionObject1;
  239. NNTP_DATA_DEFINITION_OBJECT2 *pNntpDataDefinitionObject2;
  240. NNTP_STATISTICS_0 *pNntpStats;
  241. NET_API_STATUS neterr;
  242. HRESULT hresErr;
  243. DWORD dwRetCode = NO_ERROR;
  244. METADATA_HANDLE hObjHandle = 0;
  245. WCHAR wszKeyName[METADATA_MAX_NAME_LEN];
  246. //
  247. // No need to even try if we failed to open...
  248. //
  249. if( !fInitOK )
  250. {
  251. *lpcbTotalBytes = 0;
  252. *lpNumObjectTypes = 0;
  253. //
  254. // According to the Performance Counter design, this
  255. // is a successful exit. Go figure.
  256. //
  257. return NO_ERROR;
  258. }
  259. //
  260. // Determine the query type.
  261. //
  262. dwQueryType = GetQueryType( lpValueName );
  263. if( dwQueryType == QUERY_FOREIGN )
  264. {
  265. //
  266. // We don't do foreign queries.
  267. //
  268. *lpcbTotalBytes = 0;
  269. *lpNumObjectTypes = 0;
  270. return NO_ERROR;
  271. }
  272. if( dwQueryType == QUERY_ITEMS )
  273. {
  274. //
  275. // The registry is asking for a specific object. Let's
  276. // see if we're one of the chosen.
  277. //
  278. if( !IsNumberInUnicodeList(
  279. NntpDataDefinitionObject1.NntpObjectType.ObjectNameTitleIndex,
  280. lpValueName ) &&
  281. !IsNumberInUnicodeList(
  282. NntpDataDefinitionObject2.NntpObjectType.ObjectNameTitleIndex,
  283. lpValueName )
  284. )
  285. {
  286. *lpcbTotalBytes = 0;
  287. *lpNumObjectTypes = 0;
  288. return NO_ERROR;
  289. }
  290. }
  291. //
  292. // Enumerate and get total number of instances count.
  293. //
  294. hresErr = OpenAdminBaseKey(
  295. &hObjHandle
  296. );
  297. if( FAILED(hresErr) )
  298. {
  299. *lpcbTotalBytes = 0;
  300. *lpNumObjectTypes = 0;
  301. return NO_ERROR;
  302. }
  303. //
  304. // loop through instance keys and find out total number of instances
  305. //
  306. while( SUCCEEDED(hresErr = g_pAdminBase->EnumKeys( hObjHandle,
  307. NULL,
  308. wszKeyName,
  309. dwInstanceIndex))) {
  310. dwInstanceIndex++;
  311. if( _wtoi(wszKeyName) == 0 ) {
  312. continue;
  313. }
  314. dwInstanceCount++;
  315. }
  316. //
  317. // add 1 to dwInstanceCount for _Total instance
  318. //
  319. dwInstanceCount++;
  320. //
  321. // always return an "instance sized" buffer after the definition
  322. // blocks to prevent perfmon from reading bogus data. This is strictly
  323. // a hack to accomodate how PERFMON handles the "0" instance case.
  324. // By doing this, perfmon won't choke when there are no instances
  325. // and the counter object & counters will be displayed in the list
  326. // boxes, even though no instances will be listed.
  327. //
  328. pNntpDataDefinitionObject1 = (NNTP_DATA_DEFINITION_OBJECT1 *)*lppData;
  329. cbRequired = sizeof(NNTP_DATA_DEFINITION_OBJECT1) +
  330. (dwInstanceCount * (sizeof(PERF_INSTANCE_DEFINITION) +
  331. MAX_SIZEOF_INSTANCE_NAME +
  332. sizeof (NNTP_COUNTER_BLOCK1)));
  333. cbRequired += sizeof(NNTP_DATA_DEFINITION_OBJECT2) +
  334. (dwInstanceCount * (sizeof(PERF_INSTANCE_DEFINITION) +
  335. MAX_SIZEOF_INSTANCE_NAME +
  336. sizeof (NNTP_COUNTER_BLOCK2)));
  337. //
  338. // See if there's enough space.
  339. //
  340. if( *lpcbTotalBytes < cbRequired ) {
  341. //
  342. // Nope.
  343. //
  344. *lpcbTotalBytes = 0;
  345. *lpNumObjectTypes = 0;
  346. dwRetCode = ERROR_MORE_DATA;
  347. goto Exit;
  348. }
  349. //
  350. // Copy the (constant, initialized) Object Type and counter definitions
  351. // to the caller's data buffer
  352. //
  353. memmove( pNntpDataDefinitionObject1,
  354. &NntpDataDefinitionObject1,
  355. sizeof(NNTP_DATA_DEFINITION_OBJECT1) );
  356. //
  357. // Create data for return for each instance
  358. //
  359. pPerfInstanceDefinition = (PERF_INSTANCE_DEFINITION *)
  360. &pNntpDataDefinitionObject1[1];
  361. //
  362. // Set first block of Buffer for _Total
  363. //
  364. MonBuildInstanceDefinition(
  365. pPerfInstanceDefinition,
  366. (PVOID *)&pCounterBlock1,
  367. 0,
  368. 0,
  369. (DWORD)-1, // use name
  370. TOTAL_INSTANCE_NAME ); // pass in instance name
  371. pTotal1 = pCounterBlock1;
  372. memset( pTotal1, 0, sizeof(NNTP_COUNTER_BLOCK1 ));
  373. pTotal1->PerfCounterBlock.ByteLength = sizeof (NNTP_COUNTER_BLOCK1);
  374. pPerfInstanceDefinition =
  375. (PERF_INSTANCE_DEFINITION *)((LPBYTE)pCounterBlock1 +
  376. sizeof(NNTP_COUNTER_BLOCK1));
  377. //
  378. // Try to retrieve the data for each instance.
  379. //
  380. for( i = 0, dwCount = 1 ; (i < dwInstanceIndex) && dwCount < dwInstanceCount;
  381. i++ ) {
  382. hresErr = g_pAdminBase->EnumKeys( hObjHandle,
  383. NULL,
  384. wszKeyName,
  385. i);
  386. if (FAILED(hresErr)) {
  387. *lpcbTotalBytes = 0;
  388. *lpNumObjectTypes = 0;
  389. dwRetCode = NO_ERROR;
  390. goto Exit;
  391. }
  392. if (_wtoi(wszKeyName) == 0) {
  393. continue;
  394. }
  395. MonBuildInstanceDefinition(
  396. pPerfInstanceDefinition,
  397. (PVOID *)&pCounterBlock1,
  398. 0,
  399. 0,
  400. (DWORD)-1, // use name
  401. (LPWSTR)wszKeyName ); // pass in instance name
  402. //
  403. // query for statistics info
  404. //
  405. neterr = NntpQueryStatistics(
  406. NULL,
  407. _wtoi(wszKeyName), // instance id
  408. 0,
  409. (LPBYTE *)&pNntpStats );
  410. if( neterr != NERR_Success )
  411. {
  412. #if 0
  413. //
  414. // Error retrieving statistics.
  415. //
  416. ReportEvent (hEventLog, EVENTLOG_ERROR_TYPE,
  417. 0, W3_UNABLE_QUERY_W3SVC_DATA,
  418. (PSID)NULL, 0,
  419. sizeof(neterr), NULL,
  420. (PVOID)(&neterr));
  421. #endif
  422. *lpcbTotalBytes = 0;
  423. *lpNumObjectTypes = 0;
  424. dwRetCode = NO_ERROR;
  425. goto Exit;
  426. }
  427. //
  428. // Format the NNTP Server data.
  429. //
  430. CopyStatisticsData1( pNntpStats,
  431. pCounterBlock1 );
  432. //
  433. // update _total instance counters
  434. //
  435. Update_TotalStatisticsData1( pCounterBlock1,
  436. pTotal1 );
  437. pPerfInstanceDefinition =
  438. (PERF_INSTANCE_DEFINITION *)((LPBYTE)pCounterBlock1 +
  439. sizeof(NNTP_COUNTER_BLOCK1));
  440. dwCount++;
  441. //
  442. // Free the API buffer.
  443. //
  444. //MIDL_user_free( pNntpStats );
  445. NetApiBufferFree((LPBYTE)pNntpStats);
  446. }
  447. if (dwInstanceCount == 1) {
  448. //
  449. // zero fill one instance sized block of data if there's no data
  450. // instances
  451. //
  452. memset (pPerfInstanceDefinition, 0,
  453. (sizeof(PERF_INSTANCE_DEFINITION) +
  454. MAX_SIZEOF_INSTANCE_NAME +
  455. sizeof(NNTP_COUNTER_BLOCK1)));
  456. // adjust pointer to point to end of zeroed block
  457. pPerfInstanceDefinition += (sizeof(PERF_INSTANCE_DEFINITION) +
  458. MAX_SIZEOF_INSTANCE_NAME +
  459. sizeof(NNTP_COUNTER_BLOCK1));
  460. }
  461. pNntpDataDefinitionObject1->NntpObjectType.NumInstances = dwInstanceCount;
  462. pNntpDataDefinitionObject1->NntpObjectType.TotalByteLength =
  463. *lpcbTotalBytes = (DWORD)((PBYTE)pPerfInstanceDefinition -
  464. (PBYTE)pNntpDataDefinitionObject1);
  465. //
  466. // Fill in data for Object 2 - the "NNTP Svc Client Request" object
  467. //
  468. *lppData = (PVOID)(pPerfInstanceDefinition);
  469. pNntpDataDefinitionObject2 = (NNTP_DATA_DEFINITION_OBJECT2 *)*lppData;
  470. //
  471. // Copy the (constant, initialized) Object Type and counter definitions
  472. // to the caller's data buffer
  473. //
  474. memmove( pNntpDataDefinitionObject2,
  475. &NntpDataDefinitionObject2,
  476. sizeof(NNTP_DATA_DEFINITION_OBJECT2) );
  477. //
  478. // Create data for return for each instance
  479. //
  480. pPerfInstanceDefinition = (PERF_INSTANCE_DEFINITION *)
  481. &pNntpDataDefinitionObject2[1];
  482. //
  483. // Set first block of Buffer for _Total
  484. //
  485. MonBuildInstanceDefinition(
  486. pPerfInstanceDefinition,
  487. (PVOID *)&pCounterBlock2,
  488. 0,
  489. 0,
  490. (DWORD)-1, // use name
  491. TOTAL_INSTANCE_NAME ); // pass in instance name
  492. pTotal2 = pCounterBlock2;
  493. memset( pTotal2, 0, sizeof(NNTP_COUNTER_BLOCK2 ));
  494. pTotal2->PerfCounterBlock.ByteLength = sizeof (NNTP_COUNTER_BLOCK2);
  495. pPerfInstanceDefinition =
  496. (PERF_INSTANCE_DEFINITION *)((LPBYTE)pCounterBlock2 +
  497. sizeof(NNTP_COUNTER_BLOCK2));
  498. //
  499. // Try to retrieve the data for each instance.
  500. //
  501. for( i = 0, dwCount = 1 ; (i < dwInstanceIndex) && dwCount < dwInstanceCount;
  502. i++ ) {
  503. hresErr = g_pAdminBase->EnumKeys( hObjHandle,
  504. NULL,
  505. wszKeyName,
  506. i);
  507. if (FAILED(hresErr)) {
  508. *lpcbTotalBytes = 0;
  509. *lpNumObjectTypes = 0;
  510. dwRetCode = NO_ERROR;
  511. goto Exit;
  512. }
  513. if (_wtoi(wszKeyName) == 0) {
  514. continue;
  515. }
  516. MonBuildInstanceDefinition(
  517. pPerfInstanceDefinition,
  518. (PVOID *)&pCounterBlock2,
  519. 0,
  520. 0,
  521. (DWORD)-1, // use name
  522. (LPWSTR)wszKeyName ); // pass in instance name
  523. //
  524. // query for statistics info
  525. //
  526. neterr = NntpQueryStatistics(
  527. NULL,
  528. _wtoi(wszKeyName), // instance id
  529. 0,
  530. (LPBYTE *)&pNntpStats );
  531. if( neterr != NERR_Success )
  532. {
  533. #if 0
  534. //
  535. // Error retrieving statistics.
  536. //
  537. ReportEvent (hEventLog, EVENTLOG_ERROR_TYPE,
  538. 0, W3_UNABLE_QUERY_W3SVC_DATA,
  539. (PSID)NULL, 0,
  540. sizeof(neterr), NULL,
  541. (PVOID)(&neterr));
  542. #endif
  543. *lpcbTotalBytes = 0;
  544. *lpNumObjectTypes = 0;
  545. dwRetCode = NO_ERROR;
  546. goto Exit;
  547. }
  548. //
  549. // Format the NNTP Server data.
  550. //
  551. CopyStatisticsData2( pNntpStats,
  552. pCounterBlock2 );
  553. //
  554. // update _total instance counters
  555. //
  556. Update_TotalStatisticsData2( pCounterBlock2,
  557. pTotal2 );
  558. pPerfInstanceDefinition =
  559. (PERF_INSTANCE_DEFINITION *)((LPBYTE)pCounterBlock2 +
  560. sizeof(NNTP_COUNTER_BLOCK2));
  561. dwCount++;
  562. //
  563. // Free the API buffer.
  564. //
  565. //MIDL_user_free( pNntpStats );
  566. NetApiBufferFree((LPBYTE)pNntpStats);
  567. }
  568. if (dwInstanceCount == 1) {
  569. //
  570. // zero fill one instance sized block of data if there's no data
  571. // instances
  572. //
  573. memset (pPerfInstanceDefinition, 0,
  574. (sizeof(PERF_INSTANCE_DEFINITION) +
  575. MAX_SIZEOF_INSTANCE_NAME +
  576. sizeof(NNTP_COUNTER_BLOCK2)));
  577. // adjust pointer to point to end of zeroed block
  578. pPerfInstanceDefinition += (sizeof(PERF_INSTANCE_DEFINITION) +
  579. MAX_SIZEOF_INSTANCE_NAME +
  580. sizeof(NNTP_COUNTER_BLOCK2));
  581. }
  582. //
  583. // Update arguments for return.
  584. //
  585. *lppData = (PVOID)(pPerfInstanceDefinition);
  586. *lpNumObjectTypes = 2;
  587. pNntpDataDefinitionObject2->NntpObjectType.NumInstances = dwInstanceCount;
  588. pNntpDataDefinitionObject2->NntpObjectType.TotalByteLength =
  589. (DWORD)((PBYTE)pPerfInstanceDefinition -
  590. ((PBYTE)pNntpDataDefinitionObject1 + *lpcbTotalBytes));
  591. *lpcbTotalBytes = (DWORD)((PBYTE)pPerfInstanceDefinition -
  592. (PBYTE)pNntpDataDefinitionObject1);
  593. Exit:
  594. //
  595. // Free Metabase handle
  596. //
  597. CloseAdminBaseKey(hObjHandle);
  598. //
  599. // Success! Honest!!
  600. //
  601. return dwRetCode;
  602. } // CollectNntpPerformanceData
  603. /*******************************************************************
  604. NAME: CloseNntpPerformanceData
  605. SYNOPSIS: Terminates the performance counters.
  606. RETURNS: DWORD - Win32 status code.
  607. HISTORY:
  608. KeithMo 07-Jun-1993 Created.
  609. ********************************************************************/
  610. DWORD CloseNntpPerformanceData( VOID )
  611. {
  612. //
  613. // No real cleanup to do here.
  614. //
  615. if ((--cOpens) == 0) {
  616. // Done each time the perf data is collect instead of here
  617. // UninitAdminBase();
  618. }
  619. return NO_ERROR;
  620. } // CloseNntpPerformanceData
  621. VOID
  622. CopyStatisticsData1(
  623. IN NNTP_STATISTICS_0 * pNntpStats,
  624. OUT NNTP_COUNTER_BLOCK1 * pCounterBlock
  625. )
  626. {
  627. //
  628. // Format the NNTP Server data for Object1
  629. //
  630. pCounterBlock->PerfCounterBlock.ByteLength = sizeof (NNTP_COUNTER_BLOCK1);
  631. pCounterBlock->BytesSent = pNntpStats->TotalBytesSent.QuadPart;
  632. pCounterBlock->BytesReceived = pNntpStats->TotalBytesReceived.QuadPart;
  633. pCounterBlock->BytesTotal = pNntpStats->TotalBytesSent.QuadPart + pNntpStats->TotalBytesReceived.QuadPart;
  634. pCounterBlock->TotalConnections = pNntpStats->TotalConnections;
  635. pCounterBlock->TotalSSLConnections = pNntpStats->TotalSSLConnections;
  636. pCounterBlock->CurrentConnections = pNntpStats->CurrentConnections;
  637. pCounterBlock->MaxConnections = pNntpStats->MaxConnections;
  638. pCounterBlock->CurrentAnonymous = pNntpStats->CurrentAnonymousUsers;
  639. pCounterBlock->CurrentNonAnonymous = pNntpStats->CurrentNonAnonymousUsers;
  640. pCounterBlock->TotalAnonymous = pNntpStats->TotalAnonymousUsers;
  641. pCounterBlock->TotalNonAnonymous = pNntpStats->TotalNonAnonymousUsers;
  642. pCounterBlock->MaxAnonymous = pNntpStats->MaxAnonymousUsers;
  643. pCounterBlock->MaxNonAnonymous = pNntpStats->MaxNonAnonymousUsers;
  644. pCounterBlock->TotalOutboundConnects = pNntpStats->TotalOutboundConnects;
  645. pCounterBlock->OutboundConnectsFailed = pNntpStats->OutboundConnectsFailed;
  646. pCounterBlock->CurrentOutboundConnects = pNntpStats->CurrentOutboundConnects;
  647. pCounterBlock->OutboundLogonFailed = pNntpStats->OutboundLogonFailed;
  648. pCounterBlock->TotalPullFeeds = pNntpStats->TotalPullFeeds;
  649. pCounterBlock->TotalPushFeeds = pNntpStats->TotalPushFeeds;
  650. pCounterBlock->TotalPassiveFeeds = pNntpStats->TotalPassiveFeeds;
  651. pCounterBlock->ArticlesSent = pNntpStats->ArticlesSent;
  652. pCounterBlock->ArticlesReceived = pNntpStats->ArticlesReceived;
  653. pCounterBlock->ArticlesTotal = pNntpStats->ArticlesSent + pNntpStats->ArticlesReceived;
  654. pCounterBlock->ArticlesPosted = pNntpStats->ArticlesPosted;
  655. pCounterBlock->ArticleMapEntries = pNntpStats->ArticleMapEntries;
  656. pCounterBlock->HistoryMapEntries = pNntpStats->HistoryMapEntries;
  657. pCounterBlock->XoverEntries = pNntpStats->XoverEntries;
  658. pCounterBlock->ControlMessagesIn = pNntpStats->ControlMessagesIn;
  659. pCounterBlock->ControlMessagesFailed = pNntpStats->ControlMessagesFailed;
  660. pCounterBlock->ModeratedPostingsSent = pNntpStats->ModeratedPostingsSent;
  661. pCounterBlock->ModeratedPostingsFailed = pNntpStats->ModeratedPostingsFailed;
  662. pCounterBlock->SessionsFlowControlled = pNntpStats->SessionsFlowControlled;
  663. pCounterBlock->ArticlesExpired = pNntpStats->ArticlesExpired;
  664. pCounterBlock->ArticlesSentPerSec = pNntpStats->ArticlesSent;
  665. pCounterBlock->ArticlesReceivedPerSec = pNntpStats->ArticlesReceived;
  666. pCounterBlock->ArticlesPostedPerSec = pNntpStats->ArticlesPosted;
  667. pCounterBlock->ArticleMapEntriesPerSec = pNntpStats->ArticleMapEntries;
  668. pCounterBlock->HistoryMapEntriesPerSec = pNntpStats->HistoryMapEntries;
  669. pCounterBlock->XoverEntriesPerSec = pNntpStats->XoverEntries;
  670. pCounterBlock->ArticlesExpiredPerSec = pNntpStats->ArticlesExpired;
  671. } // CopyStatisticsData
  672. VOID
  673. CopyStatisticsData2(
  674. IN NNTP_STATISTICS_0 * pNntpStats,
  675. OUT NNTP_COUNTER_BLOCK2 * pCounterBlock
  676. )
  677. {
  678. //
  679. // Format the NNTP Server data for Object2
  680. //
  681. pCounterBlock->PerfCounterBlock.ByteLength = sizeof (NNTP_COUNTER_BLOCK2);
  682. pCounterBlock->ArticleCmds = pNntpStats->ArticleCommands;
  683. pCounterBlock->ArticleCmdsPerSec = pNntpStats->ArticleCommands;
  684. pCounterBlock->GroupCmds = pNntpStats->GroupCommands;
  685. pCounterBlock->GroupCmdsPerSec = pNntpStats->GroupCommands;
  686. pCounterBlock->HelpCmds = pNntpStats->HelpCommands;
  687. pCounterBlock->HelpCmdsPerSec = pNntpStats->HelpCommands;
  688. pCounterBlock->IHaveCmds = pNntpStats->IHaveCommands;
  689. pCounterBlock->IHaveCmdsPerSec = pNntpStats->IHaveCommands;
  690. pCounterBlock->LastCmds = pNntpStats->LastCommands;
  691. pCounterBlock->LastCmdsPerSec = pNntpStats->LastCommands;
  692. pCounterBlock->ListCmds = pNntpStats->ListCommands;
  693. pCounterBlock->ListCmdsPerSec = pNntpStats->ListCommands;
  694. pCounterBlock->NewgroupsCmds = pNntpStats->NewgroupsCommands;
  695. pCounterBlock->NewgroupsCmdsPerSec = pNntpStats->NewgroupsCommands;
  696. pCounterBlock->NewnewsCmds = pNntpStats->NewnewsCommands;
  697. pCounterBlock->NewnewsCmdsPerSec = pNntpStats->NewnewsCommands;
  698. pCounterBlock->NextCmds = pNntpStats->NextCommands;
  699. pCounterBlock->NextCmdsPerSec = pNntpStats->NextCommands;
  700. pCounterBlock->PostCmds = pNntpStats->PostCommands;
  701. pCounterBlock->PostCmdsPerSec = pNntpStats->PostCommands;
  702. pCounterBlock->QuitCmds = pNntpStats->QuitCommands;
  703. pCounterBlock->QuitCmdsPerSec = pNntpStats->QuitCommands;
  704. pCounterBlock->StatCmds = pNntpStats->StatCommands;
  705. pCounterBlock->StatCmdsPerSec = pNntpStats->StatCommands;
  706. pCounterBlock->LogonAttempts = pNntpStats->LogonAttempts;
  707. pCounterBlock->LogonFailures = pNntpStats->LogonFailures;
  708. pCounterBlock->LogonAttemptsPerSec = pNntpStats->LogonAttempts;
  709. pCounterBlock->LogonFailuresPerSec = pNntpStats->LogonFailures;
  710. pCounterBlock->CheckCmds = pNntpStats->CheckCommands;
  711. pCounterBlock->CheckCmdsPerSec = pNntpStats->CheckCommands;
  712. pCounterBlock->TakethisCmds = pNntpStats->TakethisCommands;
  713. pCounterBlock->TakethisCmdsPerSec = pNntpStats->TakethisCommands;
  714. pCounterBlock->ModeCmds = pNntpStats->ModeCommands;
  715. pCounterBlock->ModeCmdsPerSec = pNntpStats->ModeCommands;
  716. pCounterBlock->SearchCmds = pNntpStats->SearchCommands;
  717. pCounterBlock->SearchCmdsPerSec = pNntpStats->SearchCommands;
  718. pCounterBlock->XHdrCmds = pNntpStats->XHdrCommands;
  719. pCounterBlock->XHdrCmdsPerSec = pNntpStats->XHdrCommands;
  720. pCounterBlock->XOverCmds = pNntpStats->XOverCommands;
  721. pCounterBlock->XOverCmdsPerSec = pNntpStats->XOverCommands;
  722. pCounterBlock->XPatCmds = pNntpStats->XPatCommands;
  723. pCounterBlock->XPatCmdsPerSec = pNntpStats->XPatCommands;
  724. pCounterBlock->XReplicCmds = pNntpStats->XReplicCommands;
  725. pCounterBlock->XReplicCmdsPerSec = pNntpStats->XReplicCommands;
  726. } // CopyStatisticsData
  727. VOID
  728. Update_TotalStatisticsData1(
  729. IN NNTP_COUNTER_BLOCK1 * pCounterBlock,
  730. OUT NNTP_COUNTER_BLOCK1 * pTotal
  731. )
  732. {
  733. //
  734. // update _total instance counters for Object1
  735. //
  736. pTotal->BytesSent += pCounterBlock->BytesSent;
  737. pTotal->BytesReceived += pCounterBlock->BytesReceived;
  738. pTotal->BytesTotal += pCounterBlock->BytesSent + pCounterBlock->BytesReceived;
  739. pTotal->TotalConnections += pCounterBlock->TotalConnections;
  740. pTotal->TotalSSLConnections += pCounterBlock->TotalSSLConnections;
  741. pTotal->CurrentConnections += pCounterBlock->CurrentConnections;
  742. pTotal->MaxConnections += pCounterBlock->MaxConnections;
  743. pTotal->CurrentAnonymous += pCounterBlock->CurrentAnonymous;
  744. pTotal->CurrentNonAnonymous += pCounterBlock->CurrentNonAnonymous;
  745. pTotal->TotalAnonymous += pCounterBlock->TotalAnonymous;
  746. pTotal->TotalNonAnonymous += pCounterBlock->TotalNonAnonymous;
  747. pTotal->MaxAnonymous += pCounterBlock->MaxAnonymous;
  748. pTotal->MaxNonAnonymous += pCounterBlock->MaxNonAnonymous;
  749. pTotal->TotalOutboundConnects += pCounterBlock->TotalOutboundConnects;
  750. pTotal->OutboundConnectsFailed += pCounterBlock->OutboundConnectsFailed;
  751. pTotal->CurrentOutboundConnects += pCounterBlock->CurrentOutboundConnects;
  752. pTotal->OutboundLogonFailed += pCounterBlock->OutboundLogonFailed;
  753. pTotal->TotalPullFeeds += pCounterBlock->TotalPullFeeds;
  754. pTotal->TotalPushFeeds += pCounterBlock->TotalPushFeeds;
  755. pTotal->TotalPassiveFeeds += pCounterBlock->TotalPassiveFeeds;
  756. pTotal->ArticlesSent += pCounterBlock->ArticlesSent;
  757. pTotal->ArticlesReceived += pCounterBlock->ArticlesReceived;
  758. pTotal->ArticlesTotal += pCounterBlock->ArticlesTotal;
  759. pTotal->ArticlesPosted += pCounterBlock->ArticlesPosted;
  760. pTotal->ArticleMapEntries += pCounterBlock->ArticleMapEntries;
  761. pTotal->HistoryMapEntries += pCounterBlock->HistoryMapEntries;
  762. pTotal->XoverEntries += pCounterBlock->XoverEntries;
  763. pTotal->ControlMessagesIn += pCounterBlock->ControlMessagesIn;
  764. pTotal->ControlMessagesFailed += pCounterBlock->ControlMessagesFailed;
  765. pTotal->ModeratedPostingsSent += pCounterBlock->ModeratedPostingsSent;
  766. pTotal->ModeratedPostingsFailed += pCounterBlock->ModeratedPostingsFailed;
  767. pTotal->SessionsFlowControlled += pCounterBlock->SessionsFlowControlled;
  768. pTotal->ArticlesExpired += pCounterBlock->ArticlesExpired;
  769. pTotal->ArticlesSentPerSec += pCounterBlock->ArticlesSentPerSec;
  770. pTotal->ArticlesReceivedPerSec += pCounterBlock->ArticlesReceivedPerSec;
  771. pTotal->ArticlesPostedPerSec += pCounterBlock->ArticlesPostedPerSec;
  772. pTotal->ArticleMapEntriesPerSec += pCounterBlock->ArticleMapEntriesPerSec;
  773. pTotal->HistoryMapEntriesPerSec += pCounterBlock->HistoryMapEntriesPerSec;
  774. pTotal->XoverEntriesPerSec += pCounterBlock->XoverEntriesPerSec;
  775. pTotal->ArticlesExpiredPerSec += pCounterBlock->ArticlesExpiredPerSec;
  776. } // Update_TotalStatisticsData
  777. VOID
  778. Update_TotalStatisticsData2(
  779. IN NNTP_COUNTER_BLOCK2 * pCounterBlock,
  780. OUT NNTP_COUNTER_BLOCK2 * pTotal
  781. )
  782. {
  783. //
  784. // update _total instance counters for Object2
  785. //
  786. pTotal->ArticleCmds += pCounterBlock->ArticleCmds;
  787. pTotal->ArticleCmdsPerSec += pCounterBlock->ArticleCmdsPerSec;
  788. pTotal->GroupCmds += pCounterBlock->GroupCmds;
  789. pTotal->GroupCmdsPerSec += pCounterBlock->GroupCmdsPerSec;
  790. pTotal->HelpCmds += pCounterBlock->HelpCmds;
  791. pTotal->HelpCmdsPerSec += pCounterBlock->HelpCmdsPerSec;
  792. pTotal->IHaveCmds += pCounterBlock->IHaveCmds;
  793. pTotal->IHaveCmdsPerSec += pCounterBlock->IHaveCmdsPerSec;
  794. pTotal->LastCmds += pCounterBlock->LastCmds;
  795. pTotal->LastCmdsPerSec += pCounterBlock->LastCmdsPerSec;
  796. pTotal->ListCmds += pCounterBlock->ListCmds;
  797. pTotal->ListCmdsPerSec += pCounterBlock->ListCmdsPerSec;
  798. pTotal->NewgroupsCmds += pCounterBlock->NewgroupsCmds;
  799. pTotal->NewgroupsCmdsPerSec += pCounterBlock->NewgroupsCmdsPerSec;
  800. pTotal->NewnewsCmds += pCounterBlock->NewnewsCmds;
  801. pTotal->NewnewsCmdsPerSec += pCounterBlock->NewnewsCmdsPerSec;
  802. pTotal->NextCmds += pCounterBlock->NextCmds;
  803. pTotal->NextCmdsPerSec += pCounterBlock->NextCmdsPerSec;
  804. pTotal->PostCmds += pCounterBlock->PostCmds;
  805. pTotal->PostCmdsPerSec += pCounterBlock->PostCmdsPerSec;
  806. pTotal->QuitCmds += pCounterBlock->QuitCmds;
  807. pTotal->QuitCmdsPerSec += pCounterBlock->QuitCmdsPerSec;
  808. pTotal->StatCmds += pCounterBlock->StatCmds;
  809. pTotal->StatCmdsPerSec += pCounterBlock->StatCmdsPerSec;
  810. pTotal->LogonAttempts += pCounterBlock->LogonAttempts;
  811. pTotal->LogonFailures += pCounterBlock->LogonFailures;
  812. pTotal->LogonAttemptsPerSec += pCounterBlock->LogonAttemptsPerSec;
  813. pTotal->LogonFailuresPerSec += pCounterBlock->LogonFailuresPerSec;
  814. pTotal->CheckCmds += pCounterBlock->CheckCmds;
  815. pTotal->CheckCmdsPerSec += pCounterBlock->CheckCmdsPerSec;
  816. pTotal->TakethisCmds += pCounterBlock->TakethisCmds;
  817. pTotal->TakethisCmdsPerSec += pCounterBlock->TakethisCmdsPerSec;
  818. pTotal->ModeCmds += pCounterBlock->ModeCmds;
  819. pTotal->ModeCmdsPerSec += pCounterBlock->ModeCmdsPerSec;
  820. pTotal->SearchCmds += pCounterBlock->SearchCmds;
  821. pTotal->SearchCmdsPerSec += pCounterBlock->SearchCmdsPerSec;
  822. pTotal->XHdrCmds += pCounterBlock->XHdrCmds;
  823. pTotal->XHdrCmdsPerSec += pCounterBlock->XHdrCmdsPerSec;
  824. pTotal->XOverCmds += pCounterBlock->XOverCmds;
  825. pTotal->XOverCmdsPerSec += pCounterBlock->XOverCmdsPerSec;
  826. pTotal->XPatCmds += pCounterBlock->XPatCmds;
  827. pTotal->XPatCmdsPerSec += pCounterBlock->XPatCmdsPerSec;
  828. pTotal->XReplicCmds += pCounterBlock->XReplicCmds;
  829. pTotal->XReplicCmdsPerSec += pCounterBlock->XReplicCmdsPerSec;
  830. } // Update_TotalStatisticsData
  831. VOID
  832. UpdateNameAndHelpIndicies(
  833. IN DWORD dwFirstCounter,
  834. IN DWORD dwFirstHelp
  835. )
  836. {
  837. NNTP_COUNTER_BLOCK1 nntpc1;
  838. NNTP_COUNTER_BLOCK2 nntpc2;
  839. //
  840. // Update the object & counter name & help indicies for object1
  841. //
  842. NntpDataDefinitionObject1.NntpObjectType.ObjectNameTitleIndex
  843. += dwFirstCounter;
  844. NntpDataDefinitionObject1.NntpObjectType.ObjectHelpTitleIndex
  845. += dwFirstHelp;
  846. NntpDataDefinitionObject1.NntpBytesSent.CounterNameTitleIndex
  847. += dwFirstCounter;
  848. NntpDataDefinitionObject1.NntpBytesSent.CounterHelpTitleIndex
  849. += dwFirstHelp;
  850. NntpDataDefinitionObject1.NntpBytesSent.CounterOffset =
  851. (DWORD)((LPBYTE)&nntpc1.BytesSent - (LPBYTE)&nntpc1);
  852. NntpDataDefinitionObject1.NntpBytesReceived.CounterNameTitleIndex
  853. += dwFirstCounter;
  854. NntpDataDefinitionObject1.NntpBytesReceived.CounterHelpTitleIndex
  855. += dwFirstHelp;
  856. NntpDataDefinitionObject1.NntpBytesReceived.CounterOffset =
  857. (DWORD)((LPBYTE)&nntpc1.BytesReceived - (LPBYTE)&nntpc1);
  858. NntpDataDefinitionObject1.NntpBytesTotal.CounterNameTitleIndex
  859. += dwFirstCounter;
  860. NntpDataDefinitionObject1.NntpBytesTotal.CounterHelpTitleIndex
  861. += dwFirstHelp;
  862. NntpDataDefinitionObject1.NntpBytesTotal.CounterOffset =
  863. (DWORD)((LPBYTE)&nntpc1.BytesTotal - (LPBYTE)&nntpc1);
  864. NntpDataDefinitionObject1.NntpTotalConnections.CounterNameTitleIndex
  865. += dwFirstCounter;
  866. NntpDataDefinitionObject1.NntpTotalConnections.CounterHelpTitleIndex
  867. += dwFirstHelp;
  868. NntpDataDefinitionObject1.NntpTotalConnections.CounterOffset =
  869. (DWORD)((LPBYTE)&nntpc1.TotalConnections - (LPBYTE)&nntpc1);
  870. NntpDataDefinitionObject1.NntpTotalSSLConnections.CounterNameTitleIndex
  871. += dwFirstCounter;
  872. NntpDataDefinitionObject1.NntpTotalSSLConnections.CounterHelpTitleIndex
  873. += dwFirstHelp;
  874. NntpDataDefinitionObject1.NntpTotalSSLConnections.CounterOffset =
  875. (DWORD)((LPBYTE)&nntpc1.TotalSSLConnections - (LPBYTE)&nntpc1);
  876. NntpDataDefinitionObject1.NntpCurrentConnections.CounterNameTitleIndex
  877. += dwFirstCounter;
  878. NntpDataDefinitionObject1.NntpCurrentConnections.CounterHelpTitleIndex
  879. += dwFirstHelp;
  880. NntpDataDefinitionObject1.NntpCurrentConnections.CounterOffset =
  881. (DWORD)((LPBYTE)&nntpc1.CurrentConnections - (LPBYTE)&nntpc1);
  882. NntpDataDefinitionObject1.NntpMaxConnections.CounterNameTitleIndex
  883. += dwFirstCounter;
  884. NntpDataDefinitionObject1.NntpMaxConnections.CounterHelpTitleIndex
  885. += dwFirstHelp;
  886. NntpDataDefinitionObject1.NntpMaxConnections.CounterOffset =
  887. (DWORD)((LPBYTE)&nntpc1.MaxConnections - (LPBYTE)&nntpc1);
  888. NntpDataDefinitionObject1.NntpCurrentAnonymous.CounterNameTitleIndex
  889. += dwFirstCounter;
  890. NntpDataDefinitionObject1.NntpCurrentAnonymous.CounterHelpTitleIndex
  891. += dwFirstHelp;
  892. NntpDataDefinitionObject1.NntpCurrentAnonymous.CounterOffset =
  893. (DWORD)((LPBYTE)&nntpc1.CurrentAnonymous - (LPBYTE)&nntpc1);
  894. NntpDataDefinitionObject1.NntpCurrentNonAnonymous.CounterNameTitleIndex
  895. += dwFirstCounter;
  896. NntpDataDefinitionObject1.NntpCurrentNonAnonymous.CounterHelpTitleIndex
  897. += dwFirstHelp;
  898. NntpDataDefinitionObject1.NntpCurrentNonAnonymous.CounterOffset =
  899. (DWORD)((LPBYTE)&nntpc1.CurrentNonAnonymous - (LPBYTE)&nntpc1);
  900. NntpDataDefinitionObject1.NntpTotalAnonymous.CounterNameTitleIndex
  901. += dwFirstCounter;
  902. NntpDataDefinitionObject1.NntpTotalAnonymous.CounterHelpTitleIndex
  903. += dwFirstHelp;
  904. NntpDataDefinitionObject1.NntpTotalAnonymous.CounterOffset =
  905. (DWORD)((LPBYTE)&nntpc1.TotalAnonymous - (LPBYTE)&nntpc1);
  906. NntpDataDefinitionObject1.NntpTotalNonAnonymous.CounterNameTitleIndex
  907. += dwFirstCounter;
  908. NntpDataDefinitionObject1.NntpTotalNonAnonymous.CounterHelpTitleIndex
  909. += dwFirstHelp;
  910. NntpDataDefinitionObject1.NntpTotalNonAnonymous.CounterOffset =
  911. (DWORD)((LPBYTE)&nntpc1.TotalNonAnonymous - (LPBYTE)&nntpc1);
  912. NntpDataDefinitionObject1.NntpMaxAnonymous.CounterNameTitleIndex
  913. += dwFirstCounter;
  914. NntpDataDefinitionObject1.NntpMaxAnonymous.CounterHelpTitleIndex
  915. += dwFirstHelp;
  916. NntpDataDefinitionObject1.NntpMaxAnonymous.CounterOffset =
  917. (DWORD)((LPBYTE)&nntpc1.MaxAnonymous - (LPBYTE)&nntpc1);
  918. NntpDataDefinitionObject1.NntpMaxNonAnonymous.CounterNameTitleIndex
  919. += dwFirstCounter;
  920. NntpDataDefinitionObject1.NntpMaxNonAnonymous.CounterHelpTitleIndex
  921. += dwFirstHelp;
  922. NntpDataDefinitionObject1.NntpMaxNonAnonymous.CounterOffset =
  923. (DWORD)((LPBYTE)&nntpc1.MaxNonAnonymous - (LPBYTE)&nntpc1);
  924. NntpDataDefinitionObject1.NntpTotalOutboundConnects.CounterNameTitleIndex
  925. += dwFirstCounter;
  926. NntpDataDefinitionObject1.NntpTotalOutboundConnects.CounterHelpTitleIndex
  927. += dwFirstHelp;
  928. NntpDataDefinitionObject1.NntpTotalOutboundConnects.CounterOffset =
  929. (DWORD)((LPBYTE)&nntpc1.TotalOutboundConnects - (LPBYTE)&nntpc1);
  930. NntpDataDefinitionObject1.NntpOutboundConnectsFailed.CounterNameTitleIndex
  931. += dwFirstCounter;
  932. NntpDataDefinitionObject1.NntpOutboundConnectsFailed.CounterHelpTitleIndex
  933. += dwFirstHelp;
  934. NntpDataDefinitionObject1.NntpOutboundConnectsFailed.CounterOffset =
  935. (DWORD)((LPBYTE)&nntpc1.OutboundConnectsFailed - (LPBYTE)&nntpc1);
  936. NntpDataDefinitionObject1.NntpCurrentOutboundConnects.CounterNameTitleIndex
  937. += dwFirstCounter;
  938. NntpDataDefinitionObject1.NntpCurrentOutboundConnects.CounterHelpTitleIndex
  939. += dwFirstHelp;
  940. NntpDataDefinitionObject1.NntpCurrentOutboundConnects.CounterOffset =
  941. (DWORD)((LPBYTE)&nntpc1.CurrentOutboundConnects - (LPBYTE)&nntpc1);
  942. NntpDataDefinitionObject1.NntpOutboundLogonFailed.CounterNameTitleIndex
  943. += dwFirstCounter;
  944. NntpDataDefinitionObject1.NntpOutboundLogonFailed.CounterHelpTitleIndex
  945. += dwFirstHelp;
  946. NntpDataDefinitionObject1.NntpOutboundLogonFailed.CounterOffset =
  947. (DWORD)((LPBYTE)&nntpc1.OutboundLogonFailed - (LPBYTE)&nntpc1);
  948. NntpDataDefinitionObject1.NntpTotalPullFeeds.CounterNameTitleIndex
  949. += dwFirstCounter;
  950. NntpDataDefinitionObject1.NntpTotalPullFeeds.CounterHelpTitleIndex
  951. += dwFirstHelp;
  952. NntpDataDefinitionObject1.NntpTotalPullFeeds.CounterOffset =
  953. (DWORD)((LPBYTE)&nntpc1.TotalPullFeeds - (LPBYTE)&nntpc1);
  954. NntpDataDefinitionObject1.NntpTotalPushFeeds.CounterNameTitleIndex
  955. += dwFirstCounter;
  956. NntpDataDefinitionObject1.NntpTotalPushFeeds.CounterHelpTitleIndex
  957. += dwFirstHelp;
  958. NntpDataDefinitionObject1.NntpTotalPushFeeds.CounterOffset =
  959. (DWORD)((LPBYTE)&nntpc1.TotalPushFeeds - (LPBYTE)&nntpc1);
  960. NntpDataDefinitionObject1.NntpTotalPassiveFeeds.CounterNameTitleIndex
  961. += dwFirstCounter;
  962. NntpDataDefinitionObject1.NntpTotalPassiveFeeds.CounterHelpTitleIndex
  963. += dwFirstHelp;
  964. NntpDataDefinitionObject1.NntpTotalPassiveFeeds.CounterOffset =
  965. (DWORD)((LPBYTE)&nntpc1.TotalPassiveFeeds - (LPBYTE)&nntpc1);
  966. NntpDataDefinitionObject1.NntpArticlesSent.CounterNameTitleIndex
  967. += dwFirstCounter;
  968. NntpDataDefinitionObject1.NntpArticlesSent.CounterHelpTitleIndex
  969. += dwFirstHelp;
  970. NntpDataDefinitionObject1.NntpArticlesSent.CounterOffset =
  971. (DWORD)((LPBYTE)&nntpc1.ArticlesSent - (LPBYTE)&nntpc1);
  972. NntpDataDefinitionObject1.NntpArticlesReceived.CounterNameTitleIndex
  973. += dwFirstCounter;
  974. NntpDataDefinitionObject1.NntpArticlesReceived.CounterHelpTitleIndex
  975. += dwFirstHelp;
  976. NntpDataDefinitionObject1.NntpArticlesReceived.CounterOffset =
  977. (DWORD)((LPBYTE)&nntpc1.ArticlesReceived - (LPBYTE)&nntpc1);
  978. NntpDataDefinitionObject1.NntpArticlesTotal.CounterNameTitleIndex
  979. += dwFirstCounter;
  980. NntpDataDefinitionObject1.NntpArticlesTotal.CounterHelpTitleIndex
  981. += dwFirstHelp;
  982. NntpDataDefinitionObject1.NntpArticlesTotal.CounterOffset =
  983. (DWORD)((LPBYTE)&nntpc1.ArticlesTotal - (LPBYTE)&nntpc1);
  984. NntpDataDefinitionObject1.NntpArticlesPosted.CounterNameTitleIndex
  985. += dwFirstCounter;
  986. NntpDataDefinitionObject1.NntpArticlesPosted.CounterHelpTitleIndex
  987. += dwFirstHelp;
  988. NntpDataDefinitionObject1.NntpArticlesPosted.CounterOffset =
  989. (DWORD)((LPBYTE)&nntpc1.ArticlesPosted - (LPBYTE)&nntpc1);
  990. NntpDataDefinitionObject1.NntpArticleMapEntries.CounterNameTitleIndex
  991. += dwFirstCounter;
  992. NntpDataDefinitionObject1.NntpArticleMapEntries.CounterHelpTitleIndex
  993. += dwFirstHelp;
  994. NntpDataDefinitionObject1.NntpArticleMapEntries.CounterOffset =
  995. (DWORD)((LPBYTE)&nntpc1.ArticleMapEntries - (LPBYTE)&nntpc1);
  996. NntpDataDefinitionObject1.NntpHistoryMapEntries.CounterNameTitleIndex
  997. += dwFirstCounter;
  998. NntpDataDefinitionObject1.NntpHistoryMapEntries.CounterHelpTitleIndex
  999. += dwFirstHelp;
  1000. NntpDataDefinitionObject1.NntpHistoryMapEntries.CounterOffset =
  1001. (DWORD)((LPBYTE)&nntpc1.HistoryMapEntries - (LPBYTE)&nntpc1);
  1002. NntpDataDefinitionObject1.NntpXoverEntries.CounterNameTitleIndex
  1003. += dwFirstCounter;
  1004. NntpDataDefinitionObject1.NntpXoverEntries.CounterHelpTitleIndex
  1005. += dwFirstHelp;
  1006. NntpDataDefinitionObject1.NntpXoverEntries.CounterOffset =
  1007. (DWORD)((LPBYTE)&nntpc1.XoverEntries - (LPBYTE)&nntpc1);
  1008. NntpDataDefinitionObject1.NntpControlMessagesIn.CounterNameTitleIndex
  1009. += dwFirstCounter;
  1010. NntpDataDefinitionObject1.NntpControlMessagesIn.CounterHelpTitleIndex
  1011. += dwFirstHelp;
  1012. NntpDataDefinitionObject1.NntpControlMessagesIn.CounterOffset =
  1013. (DWORD)((LPBYTE)&nntpc1.ControlMessagesIn - (LPBYTE)&nntpc1);
  1014. NntpDataDefinitionObject1.NntpControlMessagesFailed.CounterNameTitleIndex
  1015. += dwFirstCounter;
  1016. NntpDataDefinitionObject1.NntpControlMessagesFailed.CounterHelpTitleIndex
  1017. += dwFirstHelp;
  1018. NntpDataDefinitionObject1.NntpControlMessagesFailed.CounterOffset =
  1019. (DWORD)((LPBYTE)&nntpc1.ControlMessagesFailed - (LPBYTE)&nntpc1);
  1020. NntpDataDefinitionObject1.NntpModeratedPostingsSent.CounterNameTitleIndex
  1021. += dwFirstCounter;
  1022. NntpDataDefinitionObject1.NntpModeratedPostingsSent.CounterHelpTitleIndex
  1023. += dwFirstHelp;
  1024. NntpDataDefinitionObject1.NntpModeratedPostingsSent.CounterOffset =
  1025. (DWORD)((LPBYTE)&nntpc1.ModeratedPostingsSent - (LPBYTE)&nntpc1);
  1026. NntpDataDefinitionObject1.NntpModeratedPostingsFailed.CounterNameTitleIndex
  1027. += dwFirstCounter;
  1028. NntpDataDefinitionObject1.NntpModeratedPostingsFailed.CounterHelpTitleIndex
  1029. += dwFirstHelp;
  1030. NntpDataDefinitionObject1.NntpModeratedPostingsFailed.CounterOffset =
  1031. (DWORD)((LPBYTE)&nntpc1.ModeratedPostingsFailed - (LPBYTE)&nntpc1);
  1032. NntpDataDefinitionObject1.NntpSessionsFlowControlled.CounterNameTitleIndex
  1033. += dwFirstCounter;
  1034. NntpDataDefinitionObject1.NntpSessionsFlowControlled.CounterHelpTitleIndex
  1035. += dwFirstHelp;
  1036. NntpDataDefinitionObject1.NntpSessionsFlowControlled.CounterOffset =
  1037. (DWORD)((LPBYTE)&nntpc1.SessionsFlowControlled - (LPBYTE)&nntpc1);
  1038. NntpDataDefinitionObject1.NntpArticlesExpired.CounterNameTitleIndex
  1039. += dwFirstCounter;
  1040. NntpDataDefinitionObject1.NntpArticlesExpired.CounterHelpTitleIndex
  1041. += dwFirstHelp;
  1042. NntpDataDefinitionObject1.NntpArticlesExpired.CounterOffset =
  1043. (DWORD)((LPBYTE)&nntpc1.ArticlesExpired - (LPBYTE)&nntpc1);
  1044. NntpDataDefinitionObject1.NntpArticlesSentPerSec.CounterNameTitleIndex
  1045. += dwFirstCounter;
  1046. NntpDataDefinitionObject1.NntpArticlesSentPerSec.CounterHelpTitleIndex
  1047. += dwFirstHelp;
  1048. NntpDataDefinitionObject1.NntpArticlesSentPerSec.CounterOffset =
  1049. (DWORD)((LPBYTE)&nntpc1.ArticlesSentPerSec - (LPBYTE)&nntpc1);
  1050. NntpDataDefinitionObject1.NntpArticlesReceivedPerSec.CounterNameTitleIndex
  1051. += dwFirstCounter;
  1052. NntpDataDefinitionObject1.NntpArticlesReceivedPerSec.CounterHelpTitleIndex
  1053. += dwFirstHelp;
  1054. NntpDataDefinitionObject1.NntpArticlesReceivedPerSec.CounterOffset =
  1055. (DWORD)((LPBYTE)&nntpc1.ArticlesReceivedPerSec - (LPBYTE)&nntpc1);
  1056. NntpDataDefinitionObject1.NntpArticlesPostedPerSec.CounterNameTitleIndex
  1057. += dwFirstCounter;
  1058. NntpDataDefinitionObject1.NntpArticlesPostedPerSec.CounterHelpTitleIndex
  1059. += dwFirstHelp;
  1060. NntpDataDefinitionObject1.NntpArticlesPostedPerSec.CounterOffset =
  1061. (DWORD)((LPBYTE)&nntpc1.ArticlesPostedPerSec - (LPBYTE)&nntpc1);
  1062. NntpDataDefinitionObject1.NntpArticleMapEntriesPerSec.CounterNameTitleIndex
  1063. += dwFirstCounter;
  1064. NntpDataDefinitionObject1.NntpArticleMapEntriesPerSec.CounterHelpTitleIndex
  1065. += dwFirstHelp;
  1066. NntpDataDefinitionObject1.NntpArticleMapEntriesPerSec.CounterOffset =
  1067. (DWORD)((LPBYTE)&nntpc1.ArticleMapEntriesPerSec - (LPBYTE)&nntpc1);
  1068. NntpDataDefinitionObject1.NntpHistoryMapEntriesPerSec.CounterNameTitleIndex
  1069. += dwFirstCounter;
  1070. NntpDataDefinitionObject1.NntpHistoryMapEntriesPerSec.CounterHelpTitleIndex
  1071. += dwFirstHelp;
  1072. NntpDataDefinitionObject1.NntpHistoryMapEntriesPerSec.CounterOffset =
  1073. (DWORD)((LPBYTE)&nntpc1.HistoryMapEntriesPerSec - (LPBYTE)&nntpc1);
  1074. NntpDataDefinitionObject1.NntpXoverEntriesPerSec.CounterNameTitleIndex
  1075. += dwFirstCounter;
  1076. NntpDataDefinitionObject1.NntpXoverEntriesPerSec.CounterHelpTitleIndex
  1077. += dwFirstHelp;
  1078. NntpDataDefinitionObject1.NntpXoverEntriesPerSec.CounterOffset =
  1079. (DWORD)((LPBYTE)&nntpc1.XoverEntriesPerSec - (LPBYTE)&nntpc1);
  1080. NntpDataDefinitionObject1.NntpArticlesExpiredPerSec.CounterNameTitleIndex
  1081. += dwFirstCounter;
  1082. NntpDataDefinitionObject1.NntpArticlesExpiredPerSec.CounterHelpTitleIndex
  1083. += dwFirstHelp;
  1084. NntpDataDefinitionObject1.NntpArticlesExpiredPerSec.CounterOffset =
  1085. (DWORD)((LPBYTE)&nntpc1.ArticlesExpiredPerSec - (LPBYTE)&nntpc1);
  1086. //
  1087. // Update the object & counter name & help indicies for object2
  1088. //
  1089. NntpDataDefinitionObject2.NntpObjectType.ObjectNameTitleIndex
  1090. += dwFirstCounter;
  1091. NntpDataDefinitionObject2.NntpObjectType.ObjectHelpTitleIndex
  1092. += dwFirstHelp;
  1093. NntpDataDefinitionObject2.NntpArticleCmds.CounterNameTitleIndex
  1094. += dwFirstCounter;
  1095. NntpDataDefinitionObject2.NntpArticleCmds.CounterHelpTitleIndex
  1096. += dwFirstHelp;
  1097. NntpDataDefinitionObject2.NntpArticleCmds.CounterOffset =
  1098. (DWORD)((LPBYTE)&nntpc2.ArticleCmds - (LPBYTE)&nntpc2);
  1099. NntpDataDefinitionObject2.NntpArticleCmdsPerSec.CounterNameTitleIndex
  1100. += dwFirstCounter;
  1101. NntpDataDefinitionObject2.NntpArticleCmdsPerSec.CounterHelpTitleIndex
  1102. += dwFirstHelp;
  1103. NntpDataDefinitionObject2.NntpArticleCmdsPerSec.CounterOffset =
  1104. (DWORD)((LPBYTE)&nntpc2.ArticleCmdsPerSec - (LPBYTE)&nntpc2);
  1105. NntpDataDefinitionObject2.NntpGroupCmds.CounterNameTitleIndex
  1106. += dwFirstCounter;
  1107. NntpDataDefinitionObject2.NntpGroupCmds.CounterHelpTitleIndex
  1108. += dwFirstHelp;
  1109. NntpDataDefinitionObject2.NntpGroupCmds.CounterOffset =
  1110. (DWORD)((LPBYTE)&nntpc2.GroupCmds - (LPBYTE)&nntpc2);
  1111. NntpDataDefinitionObject2.NntpGroupCmdsPerSec.CounterNameTitleIndex
  1112. += dwFirstCounter;
  1113. NntpDataDefinitionObject2.NntpGroupCmdsPerSec.CounterHelpTitleIndex
  1114. += dwFirstHelp;
  1115. NntpDataDefinitionObject2.NntpGroupCmdsPerSec.CounterOffset =
  1116. (DWORD)((LPBYTE)&nntpc2.GroupCmdsPerSec - (LPBYTE)&nntpc2);
  1117. NntpDataDefinitionObject2.NntpHelpCmds.CounterNameTitleIndex
  1118. += dwFirstCounter;
  1119. NntpDataDefinitionObject2.NntpHelpCmds.CounterHelpTitleIndex
  1120. += dwFirstHelp;
  1121. NntpDataDefinitionObject2.NntpHelpCmds.CounterOffset =
  1122. (DWORD)((LPBYTE)&nntpc2.HelpCmds - (LPBYTE)&nntpc2);
  1123. NntpDataDefinitionObject2.NntpHelpCmdsPerSec.CounterNameTitleIndex
  1124. += dwFirstCounter;
  1125. NntpDataDefinitionObject2.NntpHelpCmdsPerSec.CounterHelpTitleIndex
  1126. += dwFirstHelp;
  1127. NntpDataDefinitionObject2.NntpHelpCmdsPerSec.CounterOffset =
  1128. (DWORD)((LPBYTE)&nntpc2.HelpCmdsPerSec - (LPBYTE)&nntpc2);
  1129. NntpDataDefinitionObject2.NntpIHaveCmds.CounterNameTitleIndex
  1130. += dwFirstCounter;
  1131. NntpDataDefinitionObject2.NntpIHaveCmds.CounterHelpTitleIndex
  1132. += dwFirstHelp;
  1133. NntpDataDefinitionObject2.NntpIHaveCmds.CounterOffset =
  1134. (DWORD)((LPBYTE)&nntpc2.IHaveCmds - (LPBYTE)&nntpc2);
  1135. NntpDataDefinitionObject2.NntpIHaveCmdsPerSec.CounterNameTitleIndex
  1136. += dwFirstCounter;
  1137. NntpDataDefinitionObject2.NntpIHaveCmdsPerSec.CounterHelpTitleIndex
  1138. += dwFirstHelp;
  1139. NntpDataDefinitionObject2.NntpIHaveCmdsPerSec.CounterOffset =
  1140. (DWORD)((LPBYTE)&nntpc2.IHaveCmdsPerSec - (LPBYTE)&nntpc2);
  1141. NntpDataDefinitionObject2.NntpLastCmds.CounterNameTitleIndex
  1142. += dwFirstCounter;
  1143. NntpDataDefinitionObject2.NntpLastCmds.CounterHelpTitleIndex
  1144. += dwFirstHelp;
  1145. NntpDataDefinitionObject2.NntpLastCmds.CounterOffset =
  1146. (DWORD)((LPBYTE)&nntpc2.LastCmds - (LPBYTE)&nntpc2);
  1147. NntpDataDefinitionObject2.NntpLastCmdsPerSec.CounterNameTitleIndex
  1148. += dwFirstCounter;
  1149. NntpDataDefinitionObject2.NntpLastCmdsPerSec.CounterHelpTitleIndex
  1150. += dwFirstHelp;
  1151. NntpDataDefinitionObject2.NntpLastCmdsPerSec.CounterOffset =
  1152. (DWORD)((LPBYTE)&nntpc2.LastCmdsPerSec - (LPBYTE)&nntpc2);
  1153. NntpDataDefinitionObject2.NntpListCmds.CounterNameTitleIndex
  1154. += dwFirstCounter;
  1155. NntpDataDefinitionObject2.NntpListCmds.CounterHelpTitleIndex
  1156. += dwFirstHelp;
  1157. NntpDataDefinitionObject2.NntpListCmds.CounterOffset =
  1158. (DWORD)((LPBYTE)&nntpc2.ListCmds - (LPBYTE)&nntpc2);
  1159. NntpDataDefinitionObject2.NntpListCmdsPerSec.CounterNameTitleIndex
  1160. += dwFirstCounter;
  1161. NntpDataDefinitionObject2.NntpListCmdsPerSec.CounterHelpTitleIndex
  1162. += dwFirstHelp;
  1163. NntpDataDefinitionObject2.NntpListCmdsPerSec.CounterOffset =
  1164. (DWORD)((LPBYTE)&nntpc2.ListCmdsPerSec - (LPBYTE)&nntpc2);
  1165. NntpDataDefinitionObject2.NntpNewgroupsCmds.CounterNameTitleIndex
  1166. += dwFirstCounter;
  1167. NntpDataDefinitionObject2.NntpNewgroupsCmds.CounterHelpTitleIndex
  1168. += dwFirstHelp;
  1169. NntpDataDefinitionObject2.NntpNewgroupsCmds.CounterOffset =
  1170. (DWORD)((LPBYTE)&nntpc2.NewgroupsCmds - (LPBYTE)&nntpc2);
  1171. NntpDataDefinitionObject2.NntpNewgroupsCmdsPerSec.CounterNameTitleIndex
  1172. += dwFirstCounter;
  1173. NntpDataDefinitionObject2.NntpNewgroupsCmdsPerSec.CounterHelpTitleIndex
  1174. += dwFirstHelp;
  1175. NntpDataDefinitionObject2.NntpNewgroupsCmdsPerSec.CounterOffset =
  1176. (DWORD)((LPBYTE)&nntpc2.NewgroupsCmdsPerSec - (LPBYTE)&nntpc2);
  1177. NntpDataDefinitionObject2.NntpNewnewsCmds.CounterNameTitleIndex
  1178. += dwFirstCounter;
  1179. NntpDataDefinitionObject2.NntpNewnewsCmds.CounterHelpTitleIndex
  1180. += dwFirstHelp;
  1181. NntpDataDefinitionObject2.NntpNewnewsCmds.CounterOffset =
  1182. (DWORD)((LPBYTE)&nntpc2.NewnewsCmds - (LPBYTE)&nntpc2);
  1183. NntpDataDefinitionObject2.NntpNewnewsCmdsPerSec.CounterNameTitleIndex
  1184. += dwFirstCounter;
  1185. NntpDataDefinitionObject2.NntpNewnewsCmdsPerSec.CounterHelpTitleIndex
  1186. += dwFirstHelp;
  1187. NntpDataDefinitionObject2.NntpNewnewsCmdsPerSec.CounterOffset =
  1188. (DWORD)((LPBYTE)&nntpc2.NewnewsCmdsPerSec - (LPBYTE)&nntpc2);
  1189. NntpDataDefinitionObject2.NntpNextCmds.CounterNameTitleIndex
  1190. += dwFirstCounter;
  1191. NntpDataDefinitionObject2.NntpNextCmds.CounterHelpTitleIndex
  1192. += dwFirstHelp;
  1193. NntpDataDefinitionObject2.NntpNextCmds.CounterOffset =
  1194. (DWORD)((LPBYTE)&nntpc2.NextCmds - (LPBYTE)&nntpc2);
  1195. NntpDataDefinitionObject2.NntpNextCmdsPerSec.CounterNameTitleIndex
  1196. += dwFirstCounter;
  1197. NntpDataDefinitionObject2.NntpNextCmdsPerSec.CounterHelpTitleIndex
  1198. += dwFirstHelp;
  1199. NntpDataDefinitionObject2.NntpNextCmdsPerSec.CounterOffset =
  1200. (DWORD)((LPBYTE)&nntpc2.NextCmdsPerSec - (LPBYTE)&nntpc2);
  1201. NntpDataDefinitionObject2.NntpPostCmds.CounterNameTitleIndex
  1202. += dwFirstCounter;
  1203. NntpDataDefinitionObject2.NntpPostCmds.CounterHelpTitleIndex
  1204. += dwFirstHelp;
  1205. NntpDataDefinitionObject2.NntpPostCmds.CounterOffset =
  1206. (DWORD)((LPBYTE)&nntpc2.PostCmds - (LPBYTE)&nntpc2);
  1207. NntpDataDefinitionObject2.NntpPostCmdsPerSec.CounterNameTitleIndex
  1208. += dwFirstCounter;
  1209. NntpDataDefinitionObject2.NntpPostCmdsPerSec.CounterHelpTitleIndex
  1210. += dwFirstHelp;
  1211. NntpDataDefinitionObject2.NntpPostCmdsPerSec.CounterOffset =
  1212. (DWORD)((LPBYTE)&nntpc2.PostCmdsPerSec - (LPBYTE)&nntpc2);
  1213. NntpDataDefinitionObject2.NntpQuitCmds.CounterNameTitleIndex
  1214. += dwFirstCounter;
  1215. NntpDataDefinitionObject2.NntpQuitCmds.CounterHelpTitleIndex
  1216. += dwFirstHelp;
  1217. NntpDataDefinitionObject2.NntpQuitCmds.CounterOffset =
  1218. (DWORD)((LPBYTE)&nntpc2.QuitCmds - (LPBYTE)&nntpc2);
  1219. NntpDataDefinitionObject2.NntpQuitCmdsPerSec.CounterNameTitleIndex
  1220. += dwFirstCounter;
  1221. NntpDataDefinitionObject2.NntpQuitCmdsPerSec.CounterHelpTitleIndex
  1222. += dwFirstHelp;
  1223. NntpDataDefinitionObject2.NntpQuitCmdsPerSec.CounterOffset =
  1224. (DWORD)((LPBYTE)&nntpc2.QuitCmdsPerSec - (LPBYTE)&nntpc2);
  1225. NntpDataDefinitionObject2.NntpStatCmds.CounterNameTitleIndex
  1226. += dwFirstCounter;
  1227. NntpDataDefinitionObject2.NntpStatCmds.CounterHelpTitleIndex
  1228. += dwFirstHelp;
  1229. NntpDataDefinitionObject2.NntpStatCmds.CounterOffset =
  1230. (DWORD)((LPBYTE)&nntpc2.StatCmds - (LPBYTE)&nntpc2);
  1231. NntpDataDefinitionObject2.NntpStatCmdsPerSec.CounterNameTitleIndex
  1232. += dwFirstCounter;
  1233. NntpDataDefinitionObject2.NntpStatCmdsPerSec.CounterHelpTitleIndex
  1234. += dwFirstHelp;
  1235. NntpDataDefinitionObject2.NntpStatCmdsPerSec.CounterOffset =
  1236. (DWORD)((LPBYTE)&nntpc2.StatCmdsPerSec - (LPBYTE)&nntpc2);
  1237. NntpDataDefinitionObject2.NntpLogonAttempts.CounterNameTitleIndex
  1238. += dwFirstCounter;
  1239. NntpDataDefinitionObject2.NntpLogonAttempts.CounterHelpTitleIndex
  1240. += dwFirstHelp;
  1241. NntpDataDefinitionObject2.NntpLogonAttempts.CounterOffset =
  1242. (DWORD)((LPBYTE)&nntpc2.LogonAttempts - (LPBYTE)&nntpc2);
  1243. NntpDataDefinitionObject2.NntpLogonFailures.CounterNameTitleIndex
  1244. += dwFirstCounter;
  1245. NntpDataDefinitionObject2.NntpLogonFailures.CounterHelpTitleIndex
  1246. += dwFirstHelp;
  1247. NntpDataDefinitionObject2.NntpLogonFailures.CounterOffset =
  1248. (DWORD)((LPBYTE)&nntpc2.LogonFailures - (LPBYTE)&nntpc2);
  1249. NntpDataDefinitionObject2.NntpLogonAttemptsPerSec.CounterNameTitleIndex
  1250. += dwFirstCounter;
  1251. NntpDataDefinitionObject2.NntpLogonAttemptsPerSec.CounterHelpTitleIndex
  1252. += dwFirstHelp;
  1253. NntpDataDefinitionObject2.NntpLogonAttemptsPerSec.CounterOffset =
  1254. (DWORD)((LPBYTE)&nntpc2.LogonAttemptsPerSec - (LPBYTE)&nntpc2);
  1255. NntpDataDefinitionObject2.NntpLogonFailuresPerSec.CounterNameTitleIndex
  1256. += dwFirstCounter;
  1257. NntpDataDefinitionObject2.NntpLogonFailuresPerSec.CounterHelpTitleIndex
  1258. += dwFirstHelp;
  1259. NntpDataDefinitionObject2.NntpLogonFailuresPerSec.CounterOffset =
  1260. (DWORD)((LPBYTE)&nntpc2.LogonFailuresPerSec - (LPBYTE)&nntpc2);
  1261. NntpDataDefinitionObject2.NntpCheckCmds.CounterNameTitleIndex
  1262. += dwFirstCounter;
  1263. NntpDataDefinitionObject2.NntpCheckCmds.CounterHelpTitleIndex
  1264. += dwFirstHelp;
  1265. NntpDataDefinitionObject2.NntpCheckCmds.CounterOffset =
  1266. (DWORD)((LPBYTE)&nntpc2.CheckCmds - (LPBYTE)&nntpc2);
  1267. NntpDataDefinitionObject2.NntpCheckCmdsPerSec.CounterNameTitleIndex
  1268. += dwFirstCounter;
  1269. NntpDataDefinitionObject2.NntpCheckCmdsPerSec.CounterHelpTitleIndex
  1270. += dwFirstHelp;
  1271. NntpDataDefinitionObject2.NntpCheckCmdsPerSec.CounterOffset =
  1272. (DWORD)((LPBYTE)&nntpc2.CheckCmdsPerSec - (LPBYTE)&nntpc2);
  1273. NntpDataDefinitionObject2.NntpTakethisCmds.CounterNameTitleIndex
  1274. += dwFirstCounter;
  1275. NntpDataDefinitionObject2.NntpTakethisCmds.CounterHelpTitleIndex
  1276. += dwFirstHelp;
  1277. NntpDataDefinitionObject2.NntpTakethisCmds.CounterOffset =
  1278. (DWORD)((LPBYTE)&nntpc2.TakethisCmds - (LPBYTE)&nntpc2);
  1279. NntpDataDefinitionObject2.NntpTakethisCmdsPerSec.CounterNameTitleIndex
  1280. += dwFirstCounter;
  1281. NntpDataDefinitionObject2.NntpTakethisCmdsPerSec.CounterHelpTitleIndex
  1282. += dwFirstHelp;
  1283. NntpDataDefinitionObject2.NntpTakethisCmdsPerSec.CounterOffset =
  1284. (DWORD)((LPBYTE)&nntpc2.TakethisCmdsPerSec - (LPBYTE)&nntpc2);
  1285. NntpDataDefinitionObject2.NntpModeCmds.CounterNameTitleIndex
  1286. += dwFirstCounter;
  1287. NntpDataDefinitionObject2.NntpModeCmds.CounterHelpTitleIndex
  1288. += dwFirstHelp;
  1289. NntpDataDefinitionObject2.NntpModeCmds.CounterOffset =
  1290. (DWORD)((LPBYTE)&nntpc2.ModeCmds - (LPBYTE)&nntpc2);
  1291. NntpDataDefinitionObject2.NntpModeCmdsPerSec.CounterNameTitleIndex
  1292. += dwFirstCounter;
  1293. NntpDataDefinitionObject2.NntpModeCmdsPerSec.CounterHelpTitleIndex
  1294. += dwFirstHelp;
  1295. NntpDataDefinitionObject2.NntpModeCmdsPerSec.CounterOffset =
  1296. (DWORD)((LPBYTE)&nntpc2.ModeCmdsPerSec - (LPBYTE)&nntpc2);
  1297. NntpDataDefinitionObject2.NntpSearchCmds.CounterNameTitleIndex
  1298. += dwFirstCounter;
  1299. NntpDataDefinitionObject2.NntpSearchCmds.CounterHelpTitleIndex
  1300. += dwFirstHelp;
  1301. NntpDataDefinitionObject2.NntpSearchCmds.CounterOffset =
  1302. (DWORD)((LPBYTE)&nntpc2.SearchCmds - (LPBYTE)&nntpc2);
  1303. NntpDataDefinitionObject2.NntpSearchCmdsPerSec.CounterNameTitleIndex
  1304. += dwFirstCounter;
  1305. NntpDataDefinitionObject2.NntpSearchCmdsPerSec.CounterHelpTitleIndex
  1306. += dwFirstHelp;
  1307. NntpDataDefinitionObject2.NntpSearchCmdsPerSec.CounterOffset =
  1308. (DWORD)((LPBYTE)&nntpc2.SearchCmdsPerSec - (LPBYTE)&nntpc2);
  1309. NntpDataDefinitionObject2.NntpXHdrCmds.CounterNameTitleIndex
  1310. += dwFirstCounter;
  1311. NntpDataDefinitionObject2.NntpXHdrCmds.CounterHelpTitleIndex
  1312. += dwFirstHelp;
  1313. NntpDataDefinitionObject2.NntpXHdrCmds.CounterOffset =
  1314. (DWORD)((LPBYTE)&nntpc2.XHdrCmds - (LPBYTE)&nntpc2);
  1315. NntpDataDefinitionObject2.NntpXHdrCmdsPerSec.CounterNameTitleIndex
  1316. += dwFirstCounter;
  1317. NntpDataDefinitionObject2.NntpXHdrCmdsPerSec.CounterHelpTitleIndex
  1318. += dwFirstHelp;
  1319. NntpDataDefinitionObject2.NntpXHdrCmdsPerSec.CounterOffset =
  1320. (DWORD)((LPBYTE)&nntpc2.XHdrCmdsPerSec - (LPBYTE)&nntpc2);
  1321. NntpDataDefinitionObject2.NntpXOverCmds.CounterNameTitleIndex
  1322. += dwFirstCounter;
  1323. NntpDataDefinitionObject2.NntpXOverCmds.CounterHelpTitleIndex
  1324. += dwFirstHelp;
  1325. NntpDataDefinitionObject2.NntpXOverCmds.CounterOffset =
  1326. (DWORD)((LPBYTE)&nntpc2.XOverCmds - (LPBYTE)&nntpc2);
  1327. NntpDataDefinitionObject2.NntpXOverCmdsPerSec.CounterNameTitleIndex
  1328. += dwFirstCounter;
  1329. NntpDataDefinitionObject2.NntpXOverCmdsPerSec.CounterHelpTitleIndex
  1330. += dwFirstHelp;
  1331. NntpDataDefinitionObject2.NntpXOverCmdsPerSec.CounterOffset =
  1332. (DWORD)((LPBYTE)&nntpc2.XOverCmdsPerSec - (LPBYTE)&nntpc2);
  1333. NntpDataDefinitionObject2.NntpXPatCmds.CounterNameTitleIndex
  1334. += dwFirstCounter;
  1335. NntpDataDefinitionObject2.NntpXPatCmds.CounterHelpTitleIndex
  1336. += dwFirstHelp;
  1337. NntpDataDefinitionObject2.NntpXPatCmds.CounterOffset =
  1338. (DWORD)((LPBYTE)&nntpc2.XPatCmds - (LPBYTE)&nntpc2);
  1339. NntpDataDefinitionObject2.NntpXPatCmdsPerSec.CounterNameTitleIndex
  1340. += dwFirstCounter;
  1341. NntpDataDefinitionObject2.NntpXPatCmdsPerSec.CounterHelpTitleIndex
  1342. += dwFirstHelp;
  1343. NntpDataDefinitionObject2.NntpXPatCmdsPerSec.CounterOffset =
  1344. (DWORD)((LPBYTE)&nntpc2.XPatCmdsPerSec - (LPBYTE)&nntpc2);
  1345. NntpDataDefinitionObject2.NntpXReplicCmds.CounterNameTitleIndex
  1346. += dwFirstCounter;
  1347. NntpDataDefinitionObject2.NntpXReplicCmds.CounterHelpTitleIndex
  1348. += dwFirstHelp;
  1349. NntpDataDefinitionObject2.NntpXReplicCmds.CounterOffset =
  1350. (DWORD)((LPBYTE)&nntpc2.XReplicCmds - (LPBYTE)&nntpc2);
  1351. NntpDataDefinitionObject2.NntpXReplicCmdsPerSec.CounterNameTitleIndex
  1352. += dwFirstCounter;
  1353. NntpDataDefinitionObject2.NntpXReplicCmdsPerSec.CounterHelpTitleIndex
  1354. += dwFirstHelp;
  1355. NntpDataDefinitionObject2.NntpXReplicCmdsPerSec.CounterOffset =
  1356. (DWORD)((LPBYTE)&nntpc2.XReplicCmdsPerSec - (LPBYTE)&nntpc2);
  1357. }
  1358. HRESULT
  1359. InitAdminBase()
  1360. {
  1361. HRESULT hRes = S_OK;
  1362. hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  1363. if ( RPC_E_CHANGED_MODE == hRes )
  1364. hRes = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
  1365. if (SUCCEEDED(hRes) ) {
  1366. hRes = CoCreateInstance(
  1367. CLSID_MSAdminBase_W,
  1368. NULL,
  1369. CLSCTX_SERVER,
  1370. IID_IMSAdminBase_W,
  1371. (void**) &g_pAdminBase
  1372. );
  1373. }
  1374. else {
  1375. //CoUninitialize();
  1376. }
  1377. return hRes;
  1378. }
  1379. VOID
  1380. UninitAdminBase()
  1381. {
  1382. if (g_pAdminBase != NULL) {
  1383. g_pAdminBase->Release();
  1384. CoUninitialize();
  1385. g_pAdminBase = NULL;
  1386. }
  1387. }
  1388. HRESULT
  1389. OpenAdminBaseKey(
  1390. OUT METADATA_HANDLE *phHandle
  1391. )
  1392. {
  1393. HRESULT hRes = S_OK;
  1394. METADATA_HANDLE RootHandle;
  1395. if (g_pAdminBase == NULL) {
  1396. //
  1397. // Don't have a Metadata interface
  1398. // so try to get one.
  1399. //
  1400. hRes = InitAdminBase();
  1401. }
  1402. if (SUCCEEDED(hRes)) {
  1403. hRes = g_pAdminBase->OpenKey(
  1404. METADATA_MASTER_ROOT_HANDLE,
  1405. L"/LM/NNTPSVC/",
  1406. METADATA_PERMISSION_READ,
  1407. 100,
  1408. &RootHandle
  1409. );
  1410. if (FAILED(hRes)) {
  1411. if ((HRESULT_CODE(hRes) == RPC_S_SERVER_UNAVAILABLE) ||
  1412. ((HRESULT_CODE(hRes) >= RPC_S_NO_CALL_ACTIVE) &&
  1413. (HRESULT_CODE(hRes) <= RPC_S_CALL_FAILED_DNE))) {
  1414. //
  1415. // RPC error, try to recover connection
  1416. //
  1417. UninitAdminBase();
  1418. hRes = InitAdminBase();
  1419. if (SUCCEEDED(hRes)) {
  1420. hRes = g_pAdminBase->OpenKey(
  1421. METADATA_MASTER_ROOT_HANDLE,
  1422. L"/LM/NNTPSVC/",
  1423. METADATA_PERMISSION_READ,
  1424. 100,
  1425. &RootHandle
  1426. );
  1427. }
  1428. }
  1429. }
  1430. if (SUCCEEDED(hRes)) {
  1431. *phHandle = RootHandle;
  1432. }
  1433. }
  1434. return(hRes);
  1435. }
  1436. VOID
  1437. CloseAdminBaseKey(
  1438. IN METADATA_HANDLE hHandle
  1439. )
  1440. {
  1441. g_pAdminBase->CloseKey(hHandle);
  1442. UninitAdminBase();
  1443. g_pAdminBase = NULL;
  1444. }