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.

1542 lines
42 KiB

  1. /*++
  2. Copyright (C) 1999 Microsoft Corporation
  3. --*/
  4. #include "precomp.h"
  5. #include "strdefs.h"
  6. DWORD
  7. WinsDumpServer(IN LPCWSTR pwszServerIp,
  8. IN LPCWSTR pwszNetBiosName,
  9. IN handle_t hBind,
  10. IN WINSINTF_BIND_DATA_T BindData
  11. )
  12. {
  13. DWORD Status = NO_ERROR;
  14. HKEY hServer = NULL,
  15. hWins = NULL,
  16. hParameter = NULL,
  17. hDefault = NULL,
  18. hDefaultPull = NULL,
  19. hDefaultPush = NULL,
  20. hPartner = NULL,
  21. hCheck = NULL,
  22. hPullPart = NULL,
  23. hPushPart = NULL;
  24. DWORD dwType = 0,
  25. dwSize = 1024*sizeof(WCHAR),
  26. dwData = 0;
  27. LPWSTR pwszData = NULL,
  28. pTemp = NULL;
  29. WCHAR wcData[1024] = {L'\0'};
  30. BOOL fBackDir = TRUE;
  31. Status = RegConnectRegistry(pwszNetBiosName,
  32. HKEY_LOCAL_MACHINE,
  33. &hServer);
  34. if( Status isnot NO_ERROR )
  35. {
  36. goto RETURN;
  37. }
  38. Status = RegOpenKeyEx(hServer,
  39. PARAMETER,
  40. 0,
  41. KEY_READ,//KEY_ALL_ACCESS,
  42. &hParameter);
  43. if( Status isnot NO_ERROR )
  44. goto RETURN;
  45. Status = RegOpenKeyEx(hServer,
  46. PARTNERROOT,
  47. 0,
  48. KEY_READ, //KEY_ALL_ACCESS,
  49. &hPartner);
  50. if( Status isnot NO_ERROR )
  51. goto RETURN;
  52. Status = RegOpenKeyEx(hServer,
  53. PULLROOT,
  54. 0,
  55. KEY_READ, //KEY_ALL_ACCESS,
  56. &hPullPart);
  57. if( Status isnot NO_ERROR )
  58. goto RETURN;
  59. Status = RegOpenKeyEx(hServer,
  60. PUSHROOT,
  61. 0,
  62. KEY_READ, //KEY_ALL_ACCESS,
  63. &hPushPart);
  64. if( Status isnot NO_ERROR )
  65. goto RETURN;
  66. Status = RegOpenKeyEx(hServer,
  67. DEFAULTPULL,
  68. 0,
  69. KEY_READ, //KEY_ALL_ACCESS,
  70. &hDefaultPull);
  71. if( Status isnot NO_ERROR )
  72. goto RETURN;
  73. Status = RegOpenKeyEx(hServer,
  74. DEFAULTPUSH,
  75. 0,
  76. KEY_READ, //KEY_ALL_ACCESS,
  77. &hDefaultPush);
  78. if( Status isnot NO_ERROR )
  79. goto RETURN;
  80. //Set Backuppath, Display only when Backup path is set.
  81. Status = NO_ERROR;
  82. Status = RegQueryValueEx(hParameter,
  83. WINSCNF_BACKUP_DIR_PATH_NM,
  84. NULL,
  85. &dwType,
  86. NULL,
  87. &dwSize);
  88. if( Status is NO_ERROR and
  89. dwSize >= sizeof(WCHAR) )
  90. {
  91. pwszData = WinsAllocateMemory(dwSize);
  92. if( pwszData is NULL )
  93. {
  94. Status = ERROR_NOT_ENOUGH_MEMORY;
  95. goto RETURN;
  96. }
  97. Status = NO_ERROR;
  98. Status = RegQueryValueEx(hParameter,
  99. WINSCNF_BACKUP_DIR_PATH_NM,
  100. NULL,
  101. &dwType,
  102. (LPBYTE)pwszData,
  103. &dwSize);
  104. if( Status isnot NO_ERROR )
  105. {
  106. if( pwszData )
  107. {
  108. WinsFreeMemory(pwszData);
  109. pwszData = NULL;
  110. }
  111. goto RETURN;
  112. }
  113. if( wcscmp(pwszData, L" ") is 0 or
  114. wcslen(pwszData) < 1 )
  115. {
  116. fBackDir = FALSE;
  117. }
  118. if( !ExpandEnvironmentStrings(pwszData, wcData, 1023) )
  119. {
  120. if( pwszData )
  121. {
  122. WinsFreeMemory(pwszData);
  123. pwszData = NULL;
  124. }
  125. Status = GetLastError();
  126. goto RETURN;
  127. }
  128. }
  129. else if( Status is ERROR_FILE_NOT_FOUND ||
  130. dwSize < sizeof(WCHAR) )
  131. {
  132. fBackDir = FALSE;
  133. }
  134. else if( Status isnot NO_ERROR )
  135. {
  136. goto RETURN;
  137. }
  138. else
  139. {
  140. fBackDir = FALSE;
  141. }
  142. dwSize = sizeof(DWORD);
  143. Status = NO_ERROR;
  144. Status = RegQueryValueEx(hParameter,
  145. WINSCNF_DO_BACKUP_ON_TERM_NM,
  146. NULL,
  147. &dwType,
  148. (LPBYTE)&dwData,
  149. &dwSize);
  150. if( Status isnot NO_ERROR )
  151. goto RETURN;
  152. if( dwData > 0 )
  153. dwData = 1;
  154. if( fBackDir )
  155. {
  156. DisplayMessage(g_hModule,
  157. DMP_SRVR_SET_BACKUPPATH,
  158. pwszServerIp,
  159. wcData,
  160. dwData);
  161. }
  162. else
  163. {
  164. DisplayMessage(g_hModule,
  165. DMP_SRVR_SET_BACKUPTERM,
  166. pwszServerIp,
  167. dwData);
  168. }
  169. memset(wcData, 0x00, 1024*sizeof(WCHAR));
  170. //Set Name record
  171. {
  172. WINSINTF_RESULTS_T Results = {0};
  173. WINSINTF_RESULTS_NEW_T ResultsN = {0};
  174. BOOL fNew = TRUE;
  175. ResultsN.WinsStat.NoOfPnrs = 0;
  176. ResultsN.WinsStat.pRplPnrs = NULL;
  177. ResultsN.NoOfWorkerThds = 1;
  178. Status = WinsStatusNew(g_hBind,
  179. WINSINTF_E_CONFIG,
  180. &ResultsN);
  181. if( Status is RPC_S_PROCNUM_OUT_OF_RANGE )
  182. {
  183. //Try old API
  184. Results.WinsStat.NoOfPnrs = 0;
  185. Results.WinsStat.pRplPnrs = 0;
  186. Status = WinsStatus(g_hBind, WINSINTF_E_CONFIG, &Results);
  187. fNew = FALSE;
  188. }
  189. if( Status is NO_ERROR )
  190. {
  191. if( fNew )
  192. {
  193. DisplayMessage(g_hModule,
  194. DMP_SRVR_SET_NAMERECORD,
  195. pwszServerIp,
  196. ResultsN.RefreshInterval,
  197. ResultsN.TombstoneInterval,
  198. ResultsN.TombstoneTimeout,
  199. ResultsN.VerifyInterval);
  200. }
  201. else
  202. {
  203. DisplayMessage(g_hModule,
  204. DMP_SRVR_SET_NAMERECORD,
  205. pwszServerIp,
  206. Results.RefreshInterval,
  207. Results.TombstoneInterval,
  208. Results.TombstoneTimeout,
  209. Results.VerifyInterval);
  210. }
  211. }
  212. else
  213. {
  214. DisplayMessage(g_hModule,
  215. DMP_SRVR_SET_NAMERECORD,
  216. pwszServerIp,
  217. NAMERECORD_REFRESH_DEFAULT,
  218. NAMERECORD_EXINTVL_DEFAULT,
  219. NAMERECORD_EXTMOUT_DEFAULT,
  220. NAMERECORD_VERIFY_DEFAULT);
  221. }
  222. }
  223. //Set Periodic DB Checking
  224. {
  225. DWORD dwMaxRec = 30000,
  226. dwUseRpl = 0,
  227. dwTimeIntvl = 24,
  228. dwState = 0,
  229. dwStart = 2*60*60;
  230. LPWSTR pwcTemp = NULL;
  231. Status = NO_ERROR;
  232. Status = RegOpenKeyEx(hServer,
  233. CCROOT,
  234. 0,
  235. KEY_READ, //KEY_ALL_ACCESS,
  236. &hCheck);
  237. if( Status is NO_ERROR )
  238. {
  239. dwState = 1;
  240. dwData = 0;
  241. dwSize = sizeof(DWORD);
  242. Status = RegQueryValueEx(hCheck,
  243. WINSCNF_CC_MAX_RECS_AAT_NM,
  244. NULL,
  245. &dwType,
  246. (LPBYTE)&dwData,
  247. &dwSize);
  248. if( Status is NO_ERROR )
  249. dwMaxRec = dwData;
  250. dwData = 0;
  251. Status = RegQueryValueEx(hCheck,
  252. WINSCNF_CC_USE_RPL_PNRS_NM,
  253. NULL,
  254. &dwType,
  255. (LPBYTE)&dwData,
  256. &dwSize);
  257. if( Status is NO_ERROR )
  258. dwUseRpl = dwData;
  259. if( dwUseRpl > 1 )
  260. dwUseRpl = 1;
  261. dwData = 0;
  262. Status = RegQueryValueEx(hCheck,
  263. WINSCNF_CC_INTVL_NM,
  264. NULL,
  265. &dwType,
  266. (LPBYTE)&dwData,
  267. &dwSize);
  268. if( Status is NO_ERROR )
  269. {
  270. dwTimeIntvl = dwData/(60*60);
  271. }
  272. dwSize = 1024*sizeof(WCHAR);
  273. Status = RegQueryValueEx(hCheck,
  274. WINSCNF_SP_TIME_NM,
  275. NULL,
  276. &dwType,
  277. (LPBYTE)&wcData,
  278. &dwSize);
  279. if( Status is NO_ERROR )
  280. {
  281. WCHAR wcHr[3] = {L'\0'},
  282. wcMt[3] = {L'\0'},
  283. wcSc[3] = {L'\0'};
  284. wcsncpy(wcHr, wcData, 2);
  285. wcsncpy(wcMt, wcData+3, 2);
  286. wcsncpy(wcSc, wcData+6, 2);
  287. dwStart = wcstoul(wcHr, NULL, 10)*60*60 +
  288. wcstoul(wcMt, NULL, 10)*60 +
  289. wcstoul(wcSc, NULL, 10);
  290. }
  291. }
  292. DisplayMessage(g_hModule,
  293. DMP_SRVR_SET_PERIODICDBCHECKING,
  294. pwszServerIp,
  295. dwState,
  296. dwMaxRec,
  297. dwUseRpl,
  298. dwTimeIntvl,
  299. dwStart);
  300. if( hCheck )
  301. {
  302. RegCloseKey(hCheck);
  303. hCheck = NULL;
  304. }
  305. }
  306. //Set replicate flag
  307. dwSize = sizeof(DWORD);
  308. dwData = 0;
  309. Status = NO_ERROR;
  310. Status = RegQueryValueEx(hParameter,
  311. WINSCNF_RPL_ONLY_W_CNF_PNRS_NM,
  312. NULL,
  313. &dwType,
  314. (LPBYTE)&dwData,
  315. &dwSize);
  316. if( Status isnot NO_ERROR )
  317. {
  318. dwData = 0;
  319. }
  320. if( dwData > 1 )
  321. dwData = 1;
  322. DisplayMessage(g_hModule,
  323. DMP_SRVR_SET_REPLICATEFLAG,
  324. pwszServerIp,
  325. dwData);
  326. //Set Migrate flag
  327. dwSize = sizeof(DWORD);
  328. dwData = 0;
  329. Status = NO_ERROR;
  330. Status = RegQueryValueEx(hParameter,
  331. WINSCNF_MIGRATION_ON_NM,
  332. NULL,
  333. &dwType,
  334. (LPBYTE)&dwData,
  335. &dwSize);
  336. if( Status isnot NO_ERROR )
  337. {
  338. dwData = 0;
  339. }
  340. if( dwData > 1 )
  341. dwData = 1;
  342. DisplayMessage(g_hModule,
  343. DMP_SRVR_SET_MIGRATEFLAG,
  344. pwszServerIp,
  345. dwData);
  346. //Set PullParam
  347. {
  348. DWORD dwState = 0,
  349. dwStartUp = 0,
  350. dwStart = 0,
  351. dwRepIntvl = 0,
  352. dwRetry = 0;
  353. Status = NO_ERROR;
  354. dwSize = sizeof(DWORD);
  355. Status = RegQueryValueEx(hDefaultPull,
  356. WINSCNF_RPL_INTERVAL_NM,
  357. NULL,
  358. &dwType,
  359. (LPBYTE)&dwData,
  360. &dwSize);
  361. if( Status is NO_ERROR )
  362. dwRepIntvl = dwData;
  363. dwSize = 1024*sizeof(WCHAR);
  364. Status = RegQueryValueEx(hDefaultPull,
  365. WINSCNF_SP_TIME_NM,
  366. NULL,
  367. &dwType,
  368. (LPBYTE)wcData,
  369. &dwSize);
  370. if( Status is NO_ERROR )
  371. {
  372. WCHAR wcHr[3] = {L'\0'},
  373. wcMt[3] = {L'\0'},
  374. wcSc[3] = {L'\0'};
  375. wcsncpy(wcHr, wcData, 2);
  376. wcsncpy(wcMt, wcData+3, 2);
  377. wcsncpy(wcSc, wcData+6, 2);
  378. dwStart = wcstoul(wcHr, NULL, 10)*60*60 +
  379. wcstoul(wcMt, NULL, 10)*60 +
  380. wcstoul(wcSc, NULL, 10);
  381. }
  382. dwSize = sizeof(DWORD);
  383. dwData = 0;
  384. Status = RegQueryValueEx(hPullPart,
  385. PERSISTENCE,
  386. NULL,
  387. &dwType,
  388. (LPBYTE)&dwData,
  389. &dwSize);
  390. if( Status is NO_ERROR )
  391. {
  392. dwState = dwData;
  393. }
  394. if( dwState > 1 )
  395. dwState = 1;
  396. dwData = 0;
  397. dwSize = sizeof(DWORD);
  398. Status = RegQueryValueEx(hPullPart,
  399. WINSCNF_RETRY_COUNT_NM,
  400. NULL,
  401. &dwType,
  402. (LPBYTE)&dwData,
  403. &dwSize);
  404. if(Status is NO_ERROR )
  405. {
  406. dwRetry = dwData;
  407. }
  408. dwData = 0;
  409. dwSize = sizeof(DWORD);
  410. Status = RegQueryValueEx(hPullPart,
  411. WINSCNF_INIT_TIME_RPL_NM,
  412. NULL,
  413. &dwType,
  414. (LPBYTE)&dwData,
  415. &dwSize);
  416. if( Status is NO_ERROR )
  417. {
  418. dwStartUp = dwData;
  419. }
  420. if( dwStartUp > 1 )
  421. dwStartUp = 1;
  422. DisplayMessage(g_hModule,
  423. DMP_SRVR_SET_PULLPARAM,
  424. pwszServerIp,
  425. dwState,
  426. dwStartUp,
  427. dwStart,
  428. dwRepIntvl,
  429. dwRetry);
  430. }
  431. //Set PushParam
  432. {
  433. DWORD dwState = 0,
  434. dwAddChng = 0,
  435. dwStartUp = 0,
  436. dwUpdate = 0;
  437. dwData = 0;
  438. dwSize = sizeof(DWORD);
  439. Status = NO_ERROR;
  440. Status = RegQueryValueEx(hDefaultPush,
  441. WINSCNF_UPDATE_COUNT_NM,
  442. NULL,
  443. &dwType,
  444. (LPBYTE)&dwData,
  445. &dwSize);
  446. if( Status is NO_ERROR )
  447. dwUpdate = dwData;
  448. dwData = 0;
  449. dwSize = sizeof(DWORD);
  450. Status = RegQueryValueEx(hPushPart,
  451. WINSCNF_INIT_TIME_RPL_NM,
  452. NULL,
  453. &dwType,
  454. (LPBYTE)&dwData,
  455. &dwSize);
  456. if( Status is NO_ERROR )
  457. dwStartUp = dwData;
  458. if( dwStartUp > 1 )
  459. dwStartUp = 1;
  460. dwSize = sizeof(DWORD);
  461. dwData = 0;
  462. Status = RegQueryValueEx(hPushPart,
  463. PERSISTENCE,
  464. NULL,
  465. &dwType,
  466. (LPBYTE)&dwData,
  467. &dwSize);
  468. if( Status is NO_ERROR )
  469. {
  470. dwState = dwData;
  471. }
  472. if( dwState > 1 )
  473. dwState = 1;
  474. dwData = 0;
  475. dwSize = sizeof(DWORD);
  476. Status = RegQueryValueEx(hPushPart,
  477. WINSCNF_ADDCHG_TRIGGER_NM,
  478. NULL,
  479. &dwType,
  480. (LPBYTE)&dwData,
  481. &dwSize);
  482. if( Status is NO_ERROR )
  483. dwAddChng = dwData;
  484. if( dwAddChng > 1 )
  485. {
  486. dwAddChng = 1;
  487. }
  488. DisplayMessage(g_hModule,
  489. DMP_SRVR_SET_PUSHPARAM,
  490. pwszServerIp,
  491. dwState,
  492. dwStartUp,
  493. dwAddChng,
  494. dwUpdate);
  495. }
  496. //Add PNG Server List
  497. while( TRUE )
  498. {
  499. LPBYTE pbData = NULL;
  500. DWORD dwCount = 0,
  501. dw = 0;
  502. Status = NO_ERROR;
  503. Status = RegQueryValueEx(hPartner,
  504. WinsOemToUnicode(WINSCNF_PERSONA_NON_GRATA_NM, NULL),
  505. NULL,
  506. &dwType,
  507. pbData,
  508. &dwSize);
  509. if( Status isnot NO_ERROR )
  510. break;
  511. if( dwSize < 7 )
  512. break;
  513. pbData = WinsAllocateMemory(dwSize);
  514. if( pbData is NULL )
  515. break;
  516. Status = RegQueryValueEx(hPartner,
  517. WinsOemToUnicode(WINSCNF_PERSONA_NON_GRATA_NM, NULL),
  518. NULL,
  519. &dwType,
  520. pbData,
  521. &dwSize);
  522. if( Status isnot NO_ERROR )
  523. {
  524. WinsFreeMemory(pbData);
  525. pbData = NULL;
  526. break;
  527. }
  528. pTemp = (LPWSTR)pbData;
  529. for( dw=0; dw<dwSize/sizeof(WCHAR); dw++ )
  530. {
  531. if( pTemp[dw] is L'\0' and
  532. pTemp[dw+1] isnot L'\0' )
  533. {
  534. pTemp[dw] = L',';
  535. }
  536. }
  537. DisplayMessage(g_hModule,
  538. DMP_SRVR_SET_PGMODE,
  539. pwszServerIp,
  540. PERSMODE_NON_GRATA);
  541. DisplayMessage(g_hModule,
  542. DMP_SRVR_ADD_PNGSERVER,
  543. pwszServerIp,
  544. pTemp);
  545. WinsFreeMemory(pbData);
  546. pbData = NULL;
  547. break;
  548. }
  549. //Add PG Server List
  550. while( TRUE )
  551. {
  552. LPBYTE pbData = NULL;
  553. DWORD dwCount = 0,
  554. dw = 0;
  555. Status = NO_ERROR;
  556. Status = RegQueryValueEx(hPartner,
  557. WinsOemToUnicode(WINSCNF_PERSONA_GRATA_NM, NULL),
  558. NULL,
  559. &dwType,
  560. pbData,
  561. &dwSize);
  562. if( Status isnot NO_ERROR )
  563. break;
  564. if( dwSize < 7 )
  565. break;
  566. pbData = WinsAllocateMemory(dwSize);
  567. if( pbData is NULL )
  568. break;
  569. Status = RegQueryValueEx(hPartner,
  570. WinsOemToUnicode(WINSCNF_PERSONA_GRATA_NM, NULL),
  571. NULL,
  572. &dwType,
  573. pbData,
  574. &dwSize);
  575. if( Status isnot NO_ERROR )
  576. {
  577. WinsFreeMemory(pbData);
  578. pbData = NULL;
  579. break;
  580. }
  581. pTemp = (LPWSTR)pbData;
  582. for( dw=0; dw<dwSize/sizeof(WCHAR); dw++ )
  583. {
  584. if( pTemp[dw] is L'\0' and
  585. pTemp[dw+1] isnot L'\0' )
  586. {
  587. pTemp[dw] = L',';
  588. }
  589. }
  590. DisplayMessage(g_hModule,
  591. DMP_SRVR_SET_PGMODE,
  592. pwszServerIp,
  593. PERSMODE_GRATA);
  594. DisplayMessage(g_hModule,
  595. DMP_SRVR_ADD_PGSERVER,
  596. pwszServerIp,
  597. pTemp);
  598. WinsFreeMemory(pbData);
  599. pbData = NULL;
  600. break;
  601. }
  602. //Set the PGMode
  603. {
  604. DWORD dwPGMode = PERSMODE_NON_GRATA;
  605. Status = NO_ERROR;
  606. dwSize = sizeof(DWORD);
  607. Status = RegQueryValueEx(hPartner,
  608. WinsOemToUnicode(WINSCNF_PERSONA_MODE_NM, NULL),
  609. NULL,
  610. &dwType,
  611. (LPVOID)&dwPGMode,
  612. &dwSize);
  613. if (dwPGMode != PERSMODE_GRATA)
  614. DisplayMessage(g_hModule,
  615. DMP_SRVR_SET_PGMODE,
  616. pwszServerIp,
  617. dwPGMode);
  618. }
  619. //Set AutoPartner config
  620. {
  621. DWORD dwState = 0,
  622. dwInterval = 0,
  623. dwTTL = 2;
  624. dwData = 0;
  625. dwSize = sizeof(DWORD);
  626. Status = NO_ERROR;
  627. Status = RegQueryValueEx(hParameter,
  628. WINSCNF_USE_SELF_FND_PNRS_NM,
  629. NULL,
  630. &dwType,
  631. (LPBYTE)&dwData,
  632. &dwSize);
  633. if( Status is NO_ERROR )
  634. {
  635. dwState = dwData;
  636. }
  637. if( dwState > 1 )
  638. dwState = 0;
  639. dwData = 0;
  640. dwSize = sizeof(DWORD);
  641. Status = RegQueryValueEx(hParameter,
  642. WINSCNF_MCAST_TTL_NM,
  643. NULL,
  644. &dwType,
  645. (LPBYTE)&dwData,
  646. &dwSize);
  647. if( Status is NO_ERROR )
  648. dwTTL = dwData;
  649. dwData = 0;
  650. dwSize = sizeof(DWORD);
  651. Status = RegQueryValueEx(hParameter,
  652. WINSCNF_MCAST_INTVL_NM,
  653. NULL,
  654. &dwType,
  655. (LPBYTE)&dwData,
  656. &dwSize);
  657. if( Status is NO_ERROR )
  658. dwInterval = dwData;
  659. DisplayMessage(g_hModule,
  660. DMP_SRVR_SET_AUTOPARTNERCONFIG,
  661. pwszServerIp,
  662. dwState,
  663. dwInterval,
  664. dwTTL);
  665. }
  666. Status = NO_ERROR;
  667. //Set Burst Handling parameters
  668. {
  669. DWORD dwState = 0;
  670. dwType = REG_DWORD;
  671. dwSize = sizeof(DWORD);
  672. Status = RegQueryValueEx(hParameter,
  673. WINSCNF_BURST_HANDLING_NM,
  674. NULL,
  675. &dwType,
  676. (LPBYTE)&dwState,
  677. &dwSize);
  678. if( Status is NO_ERROR )
  679. {
  680. dwSize = sizeof(DWORD);
  681. Status = RegQueryValueEx(hParameter,
  682. WINSCNF_BURST_QUE_SIZE_NM,
  683. NULL,
  684. &dwType,
  685. (LPBYTE)&dwData,
  686. &dwSize);
  687. if( Status isnot NO_ERROR )
  688. {
  689. DisplayMessage(g_hModule,
  690. DMP_SRVR_SET_BURSTPARAM,
  691. pwszServerIp,
  692. dwState);
  693. }
  694. else
  695. {
  696. DisplayMessage(g_hModule,
  697. DMP_SRVR_SET_BURSTPARAM_ALL,
  698. pwszServerIp,
  699. dwState,
  700. dwData);
  701. }
  702. }
  703. else
  704. {
  705. DisplayMessage(g_hModule,
  706. DMP_SRVR_SET_BURSTPARAM,
  707. pwszServerIp,
  708. dwState);
  709. }
  710. }
  711. Status = NO_ERROR;
  712. //Set Log Parameter
  713. {
  714. DWORD dwLog = 0;
  715. dwType = REG_DWORD;
  716. dwSize = sizeof(DWORD);
  717. dwData = 0;
  718. Status = RegQueryValueEx(hParameter,
  719. WINSCNF_LOG_FLAG_NM,
  720. NULL,
  721. &dwType,
  722. (LPBYTE)&dwLog,
  723. &dwSize);
  724. dwSize = sizeof(DWORD);
  725. dwType = REG_DWORD;
  726. Status = RegQueryValueEx(hParameter,
  727. WINSCNF_LOG_DETAILED_EVTS_NM,
  728. NULL,
  729. &dwType,
  730. (LPBYTE)&dwData,
  731. &dwSize);
  732. DisplayMessage(g_hModule,
  733. DMP_SRVR_SET_LOGPARAM,
  734. pwszServerIp,
  735. dwLog,
  736. dwData);
  737. }
  738. Status = NO_ERROR;
  739. //Start Version count
  740. {
  741. DWORD dwHigh = 0;
  742. dwData = 0;
  743. dwType = REG_DWORD;
  744. dwSize = sizeof(DWORD);
  745. Status = RegQueryValueEx(hParameter,
  746. WINSCNF_INIT_VERSNO_VAL_HW_NM,
  747. NULL,
  748. &dwType,
  749. (LPBYTE)&dwHigh,
  750. &dwSize);
  751. if( Status isnot NO_ERROR )
  752. dwHigh = 0;
  753. dwType = REG_DWORD;
  754. dwSize = sizeof(DWORD);
  755. Status = RegQueryValueEx(hParameter,
  756. WINSCNF_INIT_VERSNO_VAL_LW_NM,
  757. NULL,
  758. &dwType,
  759. (LPBYTE)&dwData,
  760. &dwSize);
  761. if( Status isnot NO_ERROR )
  762. dwData = 0;
  763. DisplayMessage(g_hModule,
  764. DMP_SRVR_SET_STARTVERSION,
  765. pwszServerIp,
  766. dwHigh,
  767. dwData);
  768. }
  769. Status = NO_ERROR;
  770. //For all partners, set PullPersistentConnections
  771. {
  772. DWORD i, dwSubKey = 0;
  773. HKEY hKey = NULL;
  774. WCHAR wcIp[MAX_IP_STRING_LEN+1] = {L'\0'};
  775. DWORD dwBuffer = MAX_IP_STRING_LEN+1;
  776. Status = NO_ERROR;
  777. while( TRUE )
  778. {
  779. Status = RegQueryInfoKey(hPullPart,
  780. NULL,
  781. NULL,
  782. NULL,
  783. &dwSubKey,
  784. NULL,
  785. NULL,
  786. NULL,
  787. NULL,
  788. NULL,
  789. NULL,
  790. NULL);
  791. if( Status isnot NO_ERROR )
  792. break;
  793. if ( dwSubKey is 0 )
  794. break;
  795. for( i=0; i<dwSubKey; i++ )
  796. {
  797. DWORD dwState = 0,
  798. dwIntvl = 0,
  799. dwStart = 0;
  800. dwBuffer = MAX_IP_STRING_LEN+1;
  801. dwSize = sizeof(DWORD);
  802. dwData = 0;
  803. Status = RegEnumKeyEx(hPullPart,
  804. i,
  805. wcIp,
  806. &dwBuffer,
  807. NULL,
  808. NULL,
  809. NULL,
  810. NULL);
  811. if( Status isnot NO_ERROR )
  812. continue;
  813. DisplayMessage(g_hModule,
  814. DMP_SRVR_ADD_PARTNER,
  815. pwszServerIp,
  816. wcIp,
  817. 0);
  818. Status = RegOpenKeyEx(hPullPart,
  819. wcIp,
  820. 0,
  821. KEY_READ, //KEY_ALL_ACCESS,
  822. &hKey);
  823. if( Status isnot NO_ERROR )
  824. continue;
  825. Status = RegQueryValueEx(hKey,
  826. PERSISTENCE,
  827. NULL,
  828. &dwType,
  829. (LPBYTE)&dwData,
  830. &dwSize);
  831. if( Status isnot NO_ERROR )
  832. {
  833. Status = RegQueryValueEx(hPullPart,
  834. PERSISTENCE,
  835. NULL,
  836. &dwType,
  837. (LPBYTE)&dwData,
  838. &dwSize);
  839. }
  840. if( Status is NO_ERROR )
  841. {
  842. dwState = dwData;
  843. if( dwState > 1 )
  844. dwState = 1;
  845. }
  846. dwData = 0;
  847. dwSize = sizeof(DWORD);
  848. Status = RegQueryValueEx(hKey,
  849. WINSCNF_RPL_INTERVAL_NM,
  850. NULL,
  851. &dwType,
  852. (LPBYTE)&dwData,
  853. &dwSize);
  854. if( Status isnot NO_ERROR )
  855. {
  856. Status = RegQueryValueEx(hDefaultPull,
  857. WINSCNF_RPL_INTERVAL_NM,
  858. NULL,
  859. &dwType,
  860. (LPBYTE)&dwData,
  861. &dwSize);
  862. }
  863. if( Status is NO_ERROR )
  864. {
  865. dwIntvl = dwData;
  866. }
  867. dwSize = 1024*sizeof(WCHAR);
  868. Status = RegQueryValueEx(hKey,
  869. WINSCNF_SP_TIME_NM,
  870. NULL,
  871. &dwType,
  872. (LPBYTE)wcData,
  873. &dwSize);
  874. if( Status isnot NO_ERROR )
  875. {
  876. dwSize = 1024*sizeof(WCHAR);
  877. Status = RegQueryValueEx(hDefaultPull,
  878. WINSCNF_SP_TIME_NM,
  879. NULL,
  880. &dwType,
  881. (LPBYTE)wcData,
  882. &dwSize);
  883. }
  884. if( Status is NO_ERROR )
  885. {
  886. WCHAR wcHr[3] = {L'\0'},
  887. wcMt[3] = {L'\0'},
  888. wcSc[3] = {L'\0'};
  889. wcsncpy(wcHr, wcData, 2);
  890. wcsncpy(wcMt, wcData+3, 2);
  891. wcsncpy(wcSc, wcData+6, 2);
  892. dwStart = wcstoul(wcHr, NULL, 10)*60*60 +
  893. wcstoul(wcMt, NULL, 10)*60 +
  894. wcstoul(wcSc, NULL, 10);
  895. }
  896. DisplayMessage(g_hModule,
  897. DMP_SRVR_SET_PULLPERSISTENTCONNECTION,
  898. pwszServerIp,
  899. dwState,
  900. wcIp,
  901. dwStart,
  902. dwIntvl);
  903. RegCloseKey(hKey);
  904. hKey = NULL;
  905. }
  906. break;
  907. }
  908. }
  909. //Set PushPersistentConnection
  910. {
  911. DWORD i, dwSubKey = 0;
  912. HKEY hKey = NULL;
  913. WCHAR wcIp[MAX_IP_STRING_LEN+1] = {L'\0'};
  914. DWORD dwBuffer = MAX_IP_STRING_LEN+1;
  915. Status = NO_ERROR;
  916. while( TRUE )
  917. {
  918. Status = RegQueryInfoKey(hPushPart,
  919. NULL,
  920. NULL,
  921. NULL,
  922. &dwSubKey,
  923. NULL,
  924. NULL,
  925. NULL,
  926. NULL,
  927. NULL,
  928. NULL,
  929. NULL);
  930. if( Status isnot NO_ERROR )
  931. break;
  932. if ( dwSubKey is 0 )
  933. break;
  934. for( i=0; i<dwSubKey; i++ )
  935. {
  936. DWORD dwState = 0,
  937. dwUpdate = 0;
  938. dwBuffer = MAX_IP_STRING_LEN+1;
  939. dwSize = sizeof(DWORD);
  940. dwData = 0;
  941. Status = RegEnumKeyEx(hPushPart,
  942. i,
  943. wcIp,
  944. &dwBuffer,
  945. NULL,
  946. NULL,
  947. NULL,
  948. NULL);
  949. if( Status isnot NO_ERROR )
  950. continue;
  951. DisplayMessage(g_hModule,
  952. DMP_SRVR_ADD_PARTNER,
  953. pwszServerIp,
  954. wcIp,
  955. 1);
  956. Status = RegOpenKeyEx(hPushPart,
  957. wcIp,
  958. 0,
  959. KEY_READ, //KEY_ALL_ACCESS,
  960. &hKey);
  961. if( Status isnot NO_ERROR )
  962. continue;
  963. Status = RegQueryValueEx(hKey,
  964. PERSISTENCE,
  965. NULL,
  966. &dwType,
  967. (LPBYTE)&dwData,
  968. &dwSize);
  969. if( Status isnot NO_ERROR )
  970. {
  971. Status = RegQueryValueEx(hPushPart,
  972. PERSISTENCE,
  973. NULL,
  974. &dwType,
  975. (LPBYTE)&dwData,
  976. &dwSize);
  977. }
  978. if( Status is NO_ERROR )
  979. {
  980. dwState = dwData;
  981. if( dwState > 1 )
  982. dwState = 1;
  983. }
  984. dwData = 0;
  985. dwSize = sizeof(DWORD);
  986. Status = RegQueryValueEx(hKey,
  987. WINSCNF_UPDATE_COUNT_NM,
  988. NULL,
  989. &dwType,
  990. (LPBYTE)&dwData,
  991. &dwSize);
  992. if( Status isnot NO_ERROR )
  993. {
  994. Status = RegQueryValueEx(hDefaultPush,
  995. WINSCNF_UPDATE_COUNT_NM,
  996. NULL,
  997. &dwType,
  998. (LPBYTE)&dwData,
  999. &dwSize);
  1000. }
  1001. if( Status is NO_ERROR )
  1002. {
  1003. dwUpdate = dwData;
  1004. }
  1005. DisplayMessage(g_hModule,
  1006. DMP_SRVR_SET_PUSHPERSISTENTCONNECTION,
  1007. pwszServerIp,
  1008. dwState,
  1009. wcIp,
  1010. dwUpdate);
  1011. RegCloseKey(hKey);
  1012. hKey = NULL;
  1013. }
  1014. break;
  1015. }
  1016. if( Status is 2 )
  1017. Status = NO_ERROR;
  1018. }
  1019. RETURN:
  1020. if( pwszData )
  1021. {
  1022. WinsFreeMemory(pwszData);
  1023. pwszData = NULL;
  1024. }
  1025. if( hPushPart )
  1026. {
  1027. RegCloseKey(hPushPart);
  1028. hPushPart = NULL;
  1029. }
  1030. if( hPullPart )
  1031. {
  1032. RegCloseKey(hPullPart);
  1033. hPullPart = NULL;
  1034. }
  1035. if( hPartner )
  1036. {
  1037. RegCloseKey(hPartner);
  1038. hPartner = NULL;
  1039. }
  1040. if( hCheck )
  1041. {
  1042. RegCloseKey(hCheck);
  1043. hCheck = NULL;
  1044. }
  1045. if( hDefault )
  1046. {
  1047. RegCloseKey(hDefault);
  1048. hDefault = NULL;
  1049. }
  1050. if( hParameter )
  1051. {
  1052. RegCloseKey(hParameter);
  1053. hParameter = NULL;
  1054. }
  1055. if( hWins )
  1056. {
  1057. RegCloseKey(hWins);
  1058. hWins = NULL;
  1059. }
  1060. if( hServer )
  1061. {
  1062. RegCloseKey(hServer);
  1063. hServer = NULL;
  1064. }
  1065. return Status;
  1066. }
  1067. DWORD
  1068. WINAPI
  1069. WinsDump(
  1070. IN LPCWSTR pwszRouter,
  1071. IN OUT LPWSTR *ppwcArguments,
  1072. IN DWORD dwArgCount,
  1073. IN LPCVOID pvData
  1074. )
  1075. {
  1076. DWORD Status = NO_ERROR;
  1077. WCHAR wcServerIp[MAX_IP_STRING_LEN+1] = {L'\0'};
  1078. CHAR cServerIp[MAX_IP_STRING_LEN+1] = {'\0'};
  1079. LPWSTR pwcServerName = NULL;
  1080. WCHAR wcNetBios[MAX_COMPUTER_NAME_LEN+1] = {L'\0'};
  1081. struct hostent * lpHostEnt = NULL;
  1082. handle_t hServer = NULL;
  1083. WINSINTF_BIND_DATA_T BindData={0};
  1084. LPWSTR pwszComputerName = NULL;
  1085. LPSTR pszComputerName = NULL,
  1086. pTemp = NULL,
  1087. pTemp1 = NULL;
  1088. DWORD dwComputerNameLen = 0,
  1089. dwTempLen = 0,
  1090. nLen = 0, i = 0;
  1091. BYTE pbAdd[4] = {0x00};
  1092. char szAdd[4] = {'\0'};
  1093. DWORD Access = 0;
  1094. wcNetBios[0] = L'\\';
  1095. wcNetBios[1] = L'\\';
  1096. if( !GetComputerNameEx(ComputerNameDnsFullyQualified,
  1097. NULL,
  1098. &dwComputerNameLen) )
  1099. {
  1100. pwszComputerName = WinsAllocateMemory((dwComputerNameLen+1)*sizeof(WCHAR));
  1101. if(pwszComputerName is NULL)
  1102. {
  1103. return FALSE;
  1104. }
  1105. dwComputerNameLen++;
  1106. if( !GetComputerNameEx(ComputerNameDnsFullyQualified,
  1107. pwszComputerName,
  1108. &dwComputerNameLen) )
  1109. {
  1110. WinsFreeMemory(pwszComputerName);
  1111. pwszComputerName = NULL;
  1112. return GetLastError();
  1113. }
  1114. }
  1115. else
  1116. {
  1117. return GetLastError();
  1118. }
  1119. //Now process the Computer name and convert it to ANSI because
  1120. //gethostbyname requires ANSI character string.
  1121. //pszComputerName = WinsUnicodeToOem(pwszComputerName, NULL);
  1122. pszComputerName = WinsUnicodeToAnsi(pwszComputerName, NULL);
  1123. if( pszComputerName is NULL )
  1124. return ERROR_NOT_ENOUGH_MEMORY;
  1125. //Now get the server IP Address
  1126. lpHostEnt = gethostbyname(pszComputerName);
  1127. //Not a valid server name
  1128. if( lpHostEnt is NULL )
  1129. {
  1130. DisplayMessage(g_hModule, EMSG_WINS_INVALID_COMPUTERNAME);
  1131. if( pszComputerName )
  1132. {
  1133. WinsFreeMemory(pszComputerName);
  1134. pszComputerName = NULL;
  1135. }
  1136. return WSAGetLastError();
  1137. }
  1138. //Get the IP Address from the returned struct...
  1139. memcpy(pbAdd, lpHostEnt->h_addr_list[0], 4);
  1140. nLen = 0;
  1141. for( i=0; i<4; i++)
  1142. {
  1143. _itoa((int)pbAdd[i], szAdd, 10);
  1144. memcpy(cServerIp+nLen, szAdd, strlen(szAdd));
  1145. nLen += strlen(szAdd);
  1146. *(cServerIp+nLen) = '.';
  1147. nLen++;
  1148. }
  1149. *(cServerIp+nLen-1) = '\0';
  1150. {
  1151. LPWSTR pwstrServerIp;
  1152. pwstrServerIp = WinsAnsiToUnicode(cServerIp, NULL);
  1153. if (pwstrServerIp == NULL)
  1154. return ERROR_NOT_ENOUGH_MEMORY;
  1155. wcscpy(wcServerIp, pwstrServerIp);
  1156. wcscpy(wcNetBios+2, wcServerIp);
  1157. WinsFreeMemory(pwstrServerIp);
  1158. }
  1159. if(pTemp1)
  1160. {
  1161. WinsFreeMemory(pTemp1);
  1162. pTemp1 = NULL;
  1163. }
  1164. pwcServerName = WinsAllocateMemory((strlen(lpHostEnt->h_name) + 1)*sizeof(WCHAR));
  1165. if( pwcServerName is NULL )
  1166. {
  1167. if( pszComputerName )
  1168. {
  1169. WinsFreeMemory(pszComputerName);
  1170. pszComputerName = NULL;
  1171. }
  1172. if( pwszComputerName )
  1173. {
  1174. WinsFreeMemory(pwszComputerName);
  1175. pwszComputerName = NULL;
  1176. }
  1177. return ERROR_NOT_ENOUGH_MEMORY;
  1178. }
  1179. if( pszComputerName )
  1180. {
  1181. WinsFreeMemory(pszComputerName);
  1182. pszComputerName = NULL;
  1183. }
  1184. if( pwszComputerName )
  1185. {
  1186. WinsFreeMemory(pwszComputerName);
  1187. pwszComputerName = NULL;
  1188. }
  1189. wcscpy(pwcServerName, WinsOemToUnicode(lpHostEnt->h_name, NULL));
  1190. //Bind the server
  1191. BindData.fTcpIp = TRUE;
  1192. BindData.pServerAdd = (LPBYTE)wcServerIp;
  1193. BindData.pPipeName = (LPBYTE)pwcServerName;
  1194. hServer = WinsBind(&BindData);
  1195. if (hServer is NULL)
  1196. {
  1197. DisplayMessage(g_hModule,
  1198. EMSG_WINS_BIND_FAILED,
  1199. pwcServerName);
  1200. WinsFreeMemory(pwcServerName);
  1201. pwcServerName = NULL;
  1202. return ERROR_INVALID_PARAMETER;
  1203. }
  1204. //find out what type of access do we have
  1205. Access = WINS_NO_ACCESS;
  1206. Status = WinsCheckAccess(hServer, &Access);
  1207. if (WINSINTF_SUCCESS == Status)
  1208. {
  1209. DisplayMessage(g_hModule,
  1210. MSG_WINS_ACCESS,
  1211. (Access ? (Access == WINS_CONTROL_ACCESS ? wszReadwrite : wszRead)
  1212. : wszNo),
  1213. pwcServerName);
  1214. if( Access is WINS_NO_ACCESS )
  1215. {
  1216. WinsUnbind(&BindData, hServer);
  1217. hServer = NULL;
  1218. }
  1219. }
  1220. else
  1221. {
  1222. DisplayErrorMessage(EMSG_WINS_GETSTATUS_FAILED,
  1223. Status);
  1224. WinsFreeMemory(pwcServerName);
  1225. pwcServerName = NULL;
  1226. return Status;
  1227. }
  1228. //Now dump the configuration information for this server.
  1229. Status = WinsDumpServer(wcServerIp,
  1230. wcNetBios,
  1231. hServer,
  1232. BindData);
  1233. DisplayMessage(g_hModule,
  1234. WINS_FORMAT_LINE);
  1235. WinsFreeMemory(pwcServerName);
  1236. pwcServerName = NULL;
  1237. return Status;
  1238. }