Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

918 lines
27 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C O N F L I C T . C P P
  7. //
  8. // Contents: Code to handle and display software/hardware conflicts
  9. // during upgrade
  10. //
  11. // Notes:
  12. //
  13. // Author: kumarp 04/12/97 17:17:27
  14. //
  15. //----------------------------------------------------------------------------
  16. #include "pch.h"
  17. #pragma hdrstop
  18. #include "conflict.h"
  19. #include "infmap.h"
  20. #include "kkreg.h"
  21. #include "kkstl.h"
  22. #include "kkutils.h"
  23. #include "ncreg.h"
  24. #include "netreg.h"
  25. #include "nustrs.h"
  26. #include "nuutils.h"
  27. #include "oemupg.h"
  28. #include "ncsvc.h"
  29. // ----------------------------------------------------------------------
  30. // External string constants
  31. //
  32. extern const WCHAR c_szRegValServiceName[];
  33. extern const WCHAR c_szParameters[];
  34. // ----------------------------------------------------------------------
  35. // String constants
  36. //
  37. const WCHAR sz_DLC[] = L"DLC";
  38. const WCHAR sz_NBF[] = L"NBF";
  39. const WCHAR sz_SNAServerKey[] = L"SOFTWARE\\Microsoft\\Sna Server\\CurrentVersion";
  40. const WCHAR sz_SNAServerVersion[] = L"SNAVersion";
  41. // ----------------------------------------------------------------------
  42. TPtrList* g_pplNetComponents=NULL;
  43. // ----------------------------------------------------------------------
  44. //
  45. // Function: UpgradeConflictsFound
  46. //
  47. // Purpose: Find out if upgrade conflicts have been detected
  48. //
  49. // Arguments: None
  50. //
  51. // Returns: TRUE if found, FALSE otherwise
  52. //
  53. // Author: kumarp 17-December-97
  54. //
  55. // Notes:
  56. //
  57. BOOL UpgradeConflictsFound()
  58. {
  59. return (g_pplNetComponents && g_pplNetComponents->size());
  60. }
  61. // ----------------------------------------------------------------------
  62. //
  63. // Function: CNetComponent::CNetComponent
  64. //
  65. // Purpose: constructor for class CNetComponent
  66. //
  67. // Arguments:
  68. // pszPreNT5InfId [in] pre NT5 InfID (e.g. IEEPRO)
  69. // pszPreNT5Instance [in] pre NT5 instance name (e.g. IEEPRO2)
  70. // pszDescription [in] description
  71. // eType [in] type (software / hardware)
  72. //
  73. // Author: kumarp 17-December-97
  74. //
  75. // Notes:
  76. //
  77. CNetComponent::CNetComponent(PCWSTR pszPreNT5InfId,
  78. PCWSTR pszPreNT5Instance,
  79. PCWSTR pszDescription,
  80. EComponentType eType)
  81. : m_strPreNT5InfId(pszPreNT5InfId),
  82. m_strServiceName(pszPreNT5Instance),
  83. m_strDescription(pszDescription),
  84. m_eType(eType)
  85. {
  86. }
  87. // ----------------------------------------------------------------------
  88. //
  89. // Function: AddToComponentList
  90. //
  91. // Purpose: Construct and add a CNetComponent to the specified list
  92. //
  93. // Arguments:
  94. // pplComponents [in] pointer to list of
  95. // pszPreNT5InfId [in] pre NT5 InfID (e.g. IEEPRO)
  96. // pszPreNT5Instance [in] pre NT5 instance name (e.g. IEEPRO2)
  97. // pszDescription [in] description
  98. // eType [in] type (software / hardware)
  99. //
  100. // Returns: None
  101. //
  102. // Author: kumarp 17-December-97
  103. //
  104. // Notes:
  105. //
  106. void AddToComponentList(IN TPtrList* pplComponents,
  107. IN PCWSTR pszPreNT5InfId,
  108. IN PCWSTR pszPreNT5Instance,
  109. IN PCWSTR pszDescription,
  110. EComponentType eType)
  111. {
  112. AssertValidReadPtr(pplComponents);
  113. AssertValidReadPtr(pszPreNT5InfId);
  114. AssertValidReadPtr(pszPreNT5Instance);
  115. AssertValidReadPtr(pszDescription);
  116. if (pplComponents)
  117. {
  118. CNetComponent* pnc;
  119. pnc = new CNetComponent(pszPreNT5InfId, pszPreNT5Instance,
  120. pszDescription, eType);
  121. if (pnc)
  122. {
  123. pplComponents->push_back(pnc);
  124. }
  125. }
  126. #ifdef ENABLETRACE
  127. tstring strMessage;
  128. GetUnsupportedMessageBool((eType == CT_Hardware), pszPreNT5InfId,
  129. pszDescription, &strMessage);
  130. TraceTag(ttidNetUpgrade, "%S", strMessage.c_str());
  131. #endif
  132. }
  133. // ----------------------------------------------------------------------
  134. //
  135. // Function: AddToConflictsList
  136. //
  137. // Purpose: Construct and add a CNetComponent to the conflict list
  138. //
  139. // Arguments:
  140. // pszPreNT5InfId [in] pre NT5 InfID (e.g. IEEPRO)
  141. // pszPreNT5Instance [in] pre NT5 instance name (e.g. IEEPRO2)
  142. // pszDescription [in] description
  143. // eType [in] type (software / hardware)
  144. //
  145. // Returns: None
  146. //
  147. // Author: kumarp 17-December-97
  148. //
  149. // Notes:
  150. //
  151. void AddToConflictsList(IN PCWSTR pszPreNT5InfId,
  152. IN PCWSTR pszPreNT5Instance,
  153. IN PCWSTR pszDescription,
  154. EComponentType eType)
  155. {
  156. if (!g_pplNetComponents)
  157. {
  158. g_pplNetComponents = new TPtrList;
  159. }
  160. AddToComponentList(g_pplNetComponents, pszPreNT5InfId,
  161. pszPreNT5Instance, pszDescription, eType);
  162. }
  163. // ----------------------------------------------------------------------
  164. //
  165. // Function: HrGetAdapterParamsKeyFromInstance
  166. //
  167. // Purpose: Get handle of Parameters key using adapter instace key
  168. //
  169. // Arguments:
  170. // hkeyAdapterInstance [in] handle of
  171. // phkeyAdapterParams [out] pointer to handle of
  172. //
  173. // Returns: S_OK on success, otherwise an error code
  174. //
  175. // Author: kumarp 17-December-97
  176. //
  177. // Notes:
  178. //
  179. HRESULT HrGetAdapterParamsKeyFromInstance(IN HKEY hkeyAdapterInstance,
  180. OUT HKEY* phkeyAdapterParams)
  181. {
  182. DefineFunctionName("HrGetAdapterParamsKeyFromInstance");
  183. Assert(hkeyAdapterInstance);
  184. AssertValidWritePtr(phkeyAdapterParams);
  185. HRESULT hr=S_OK;
  186. tstring strServiceName;
  187. hr = HrRegQueryString(hkeyAdapterInstance, c_szRegValServiceName,
  188. &strServiceName);
  189. if (S_OK == hr)
  190. {
  191. hr = HrRegOpenServiceSubKey(strServiceName.c_str(), c_szParameters,
  192. KEY_READ, phkeyAdapterParams);
  193. }
  194. TraceError(__FUNCNAME__, hr);
  195. return hr;
  196. }
  197. // ----------------------------------------------------------------------
  198. //
  199. // Function: HrGenerateHardwareConflictList
  200. //
  201. // Purpose: Detect upgrade conflicts for h/w components
  202. //
  203. // Arguments: None
  204. //
  205. // Returns: S_OK on success, otherwise an error code
  206. //
  207. // Author: kumarp 17-December-97
  208. //
  209. // Notes:
  210. //
  211. HRESULT HrGenerateHardwareConflictList()
  212. {
  213. DefineFunctionName("HrGenerateHardwareConflictList");
  214. HKEY hkeyAdapters;
  215. HKEY hkeyAdapter;
  216. DWORD dwHidden;
  217. tstring strAdapterDescription;
  218. tstring strPreNT5InfId;
  219. tstring strServiceName;
  220. tstring strNT5InfId;
  221. tstring strAdapterType;
  222. BOOL fIsOemAdapter;
  223. BOOL fRealNetCard = FALSE;
  224. HRESULT hr=S_OK;
  225. hr = HrRegOpenKeyEx(HKEY_LOCAL_MACHINE, c_szRegKeyAdapterHome,
  226. KEY_READ, &hkeyAdapters);
  227. if (S_OK == hr)
  228. {
  229. WCHAR szBuf[MAX_PATH];
  230. FILETIME time;
  231. DWORD dwSize = celems(szBuf);
  232. DWORD dwRegIndex = 0;
  233. while(S_OK == (hr = HrRegEnumKeyEx(hkeyAdapters, dwRegIndex++, szBuf,
  234. &dwSize, NULL, NULL, &time)))
  235. {
  236. dwSize = celems(szBuf);
  237. Assert(*szBuf);
  238. hr = HrRegOpenKeyEx(hkeyAdapters, szBuf, KEY_READ, &hkeyAdapter);
  239. if (hr == S_OK)
  240. {
  241. hr = HrRegQueryDword(hkeyAdapter, c_szHidden, &dwHidden);
  242. // for REAL netcards, "Hidden" is absent or if present the value is 0
  243. if (S_OK == hr)
  244. {
  245. fRealNetCard = (dwHidden == 0);
  246. }
  247. else if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
  248. {
  249. fRealNetCard = TRUE;
  250. hr = S_OK;
  251. }
  252. if ((S_OK == hr) && fRealNetCard)
  253. {
  254. hr = HrGetPreNT5InfIdAndDesc(hkeyAdapter, &strPreNT5InfId,
  255. &strAdapterDescription, &
  256. strServiceName);
  257. if (S_OK == hr)
  258. {
  259. HKEY hkeyAdapterParams;
  260. hr = HrGetAdapterParamsKeyFromInstance(hkeyAdapter,
  261. &hkeyAdapterParams);
  262. if (S_OK == hr)
  263. {
  264. hr = HrMapPreNT5NetCardInfIdToNT5InfId(hkeyAdapterParams,
  265. strPreNT5InfId.c_str(),
  266. &strNT5InfId,
  267. &strAdapterType,
  268. &fIsOemAdapter,
  269. NULL);
  270. if (S_FALSE == hr)
  271. {
  272. AddToConflictsList(strPreNT5InfId.c_str(),
  273. strServiceName.c_str(),
  274. strAdapterDescription.c_str(),
  275. CT_Hardware);
  276. }
  277. }
  278. RegCloseKey(hkeyAdapterParams);
  279. }
  280. }
  281. RegCloseKey(hkeyAdapter);
  282. }
  283. }
  284. if ((HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr) ||
  285. (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr))
  286. {
  287. hr = S_OK;
  288. }
  289. RegCloseKey(hkeyAdapters);
  290. }
  291. TraceError(__FUNCNAME__, hr);
  292. return hr;
  293. }
  294. // ----------------------------------------------------------------------
  295. //
  296. // Function: ShouldIgnoreComponentForInstall
  297. //
  298. // Purpose: Determine if a components should be ignored when
  299. // we are checking to see for obsolesence
  300. //
  301. // Arguments:
  302. // pszComponentName [in] name of component
  303. //
  304. // Returns: TRUE on success, FALSE otherwise
  305. //
  306. // Author: deonb 22-September-2000
  307. //
  308. BOOL
  309. ShouldIgnoreComponentForInstall (
  310. IN PCWSTR pszComponentName)
  311. {
  312. BOOL fRet=FALSE;
  313. if (
  314. // We ignore NETBEUI since it's checked by DOSNET.INF already (NTBUG9: 181798)
  315. (lstrcmpiW(pszComponentName, sz_NBF) == 0) ||
  316. // We ignore DLC since it's checked by HrGenerateNT5ConflictList (NTBUG9: 187135)
  317. (lstrcmpiW(pszComponentName, sz_DLC) == 0)
  318. )
  319. {
  320. fRet = TRUE;
  321. }
  322. else
  323. {
  324. fRet = FALSE;
  325. }
  326. return fRet;
  327. }
  328. // ----------------------------------------------------------------------
  329. //
  330. // Function: HrGenerateSoftwareConflictListForProvider
  331. //
  332. // Purpose: Detect upgrade conflicts for s/w components of a provider
  333. //
  334. // Arguments:
  335. // pszSoftwareProvider [in] name of software provider (e.g. Microsoft)
  336. //
  337. // Returns: S_OK on success, otherwise an error code
  338. //
  339. // Author: kumarp 17-December-97
  340. //
  341. // Notes:
  342. //
  343. HRESULT HrGenerateSoftwareConflictListForProvider(IN PCWSTR pszSoftwareProvider)
  344. {
  345. DefineFunctionName("HrGenerateSoftwareConflictList");
  346. HRESULT hr=S_OK;
  347. HKEY hkeyProvider;
  348. HKEY hkeyProductCurrentVersion;
  349. tstring strProvider;
  350. strProvider = c_szRegKeySoftware;
  351. AppendToPath(&strProvider, pszSoftwareProvider);
  352. hr = HrRegOpenKeyEx(HKEY_LOCAL_MACHINE, strProvider.c_str(),
  353. KEY_READ, &hkeyProvider);
  354. if (S_OK == hr)
  355. {
  356. tstring strPreNT5InfId;
  357. tstring strNT5InfId;
  358. tstring strProductCurrentVersion;
  359. tstring strDescription;
  360. tstring strServiceName;
  361. tstring strSoftwareType;
  362. WCHAR szBuf[MAX_PATH];
  363. FILETIME time;
  364. DWORD dwSize = celems(szBuf);
  365. DWORD dwRegIndex = 0;
  366. BOOL fIsOemComponent;
  367. while(S_OK == (hr = HrRegEnumKeyEx(hkeyProvider, dwRegIndex++, szBuf,
  368. &dwSize, NULL, NULL, &time)))
  369. {
  370. dwSize = celems(szBuf);
  371. Assert(*szBuf);
  372. if (!ShouldIgnoreComponentForInstall(szBuf))
  373. {
  374. strProductCurrentVersion = szBuf;
  375. AppendToPath(&strProductCurrentVersion, c_szRegKeyCurrentVersion);
  376. // Look for Component\CurrentVersion
  377. hr = HrRegOpenKeyEx(hkeyProvider, strProductCurrentVersion.c_str(),
  378. KEY_READ, &hkeyProductCurrentVersion);
  379. if (hr == S_OK)
  380. {
  381. // Under Component\CurrentVersion, look for "SoftwareType" value
  382. hr = HrRegQueryString(hkeyProductCurrentVersion,
  383. c_szRegValSoftwareType,
  384. &strSoftwareType);
  385. if (!lstrcmpiW(strSoftwareType.c_str(), c_szSoftwareTypeDriver))
  386. {
  387. // ignore components of type "driver"
  388. hr = S_OK;
  389. }
  390. else
  391. {
  392. hr = HrGetPreNT5InfIdAndDesc(hkeyProductCurrentVersion,
  393. &strPreNT5InfId, &strDescription,
  394. &strServiceName);
  395. if (S_OK == hr)
  396. {
  397. hr = HrMapPreNT5NetComponentInfIDToNT5InfID(
  398. strPreNT5InfId.c_str(), &strNT5InfId,
  399. &fIsOemComponent, NULL, NULL);
  400. if (S_FALSE == hr)
  401. {
  402. AddToConflictsList(strPreNT5InfId.c_str(),
  403. strServiceName.c_str(),
  404. strDescription.c_str(),
  405. CT_Software);
  406. }
  407. }
  408. RegCloseKey(hkeyProductCurrentVersion);
  409. }
  410. }
  411. }
  412. }
  413. if (HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr)
  414. {
  415. hr = S_OK;
  416. }
  417. RegCloseKey(hkeyProvider);
  418. }
  419. TraceError(__FUNCNAME__, hr);
  420. return hr;
  421. }
  422. // ----------------------------------------------------------------------
  423. //
  424. // Function: HrGenerateSoftwareConflictList
  425. //
  426. // Purpose: Detect upgrade conflicts for s/w components of all providers
  427. //
  428. // Arguments: None
  429. //
  430. // Returns: S_OK on success, otherwise an error code
  431. //
  432. // Author: kumarp 17-December-97
  433. //
  434. // Notes:
  435. //
  436. HRESULT HrGenerateSoftwareConflictList()
  437. {
  438. DefineFunctionName("HrGenerateSoftwareConflictList");
  439. HRESULT hr=S_OK;
  440. HKEY hkeySoftware;
  441. hr = HrRegOpenKeyEx(HKEY_LOCAL_MACHINE, c_szRegKeySoftware,
  442. KEY_READ, &hkeySoftware);
  443. if (S_OK == hr)
  444. {
  445. WCHAR szBuf[MAX_PATH];
  446. FILETIME time;
  447. DWORD dwSize = celems(szBuf);
  448. DWORD dwRegIndex = 0;
  449. while(S_OK == (hr = HrRegEnumKeyEx(hkeySoftware, dwRegIndex++, szBuf,
  450. &dwSize, NULL, NULL, &time)))
  451. {
  452. dwSize = celems(szBuf);
  453. Assert(*szBuf);
  454. hr = HrGenerateSoftwareConflictListForProvider(szBuf);
  455. }
  456. if (HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr)
  457. {
  458. hr = S_OK;
  459. }
  460. RegCloseKey(hkeySoftware);
  461. }
  462. TraceError(__FUNCNAME__, hr);
  463. return hr;
  464. }
  465. // ----------------------------------------------------------------------
  466. //
  467. // Function: HrGenerateNT5ConflictList
  468. //
  469. // Purpose: Detect upgrade conflicts from Windows 2000
  470. //
  471. // Arguments: None
  472. //
  473. // Returns: S_OK on success, otherwise an error code
  474. //
  475. // Author: deonb 20-September 2000
  476. //
  477. // Notes:
  478. //
  479. HRESULT HrGenerateNT5ConflictList()
  480. {
  481. HRESULT hr = S_OK;
  482. tstring strDescription;
  483. BOOL fInstalled;
  484. if ( ShouldRemoveDLC(&strDescription, &fInstalled) )
  485. {
  486. // Add to conflict list only if DLC is installed, otherwise user will see
  487. // a warning message even if it is uninstalled.
  488. //
  489. if ( fInstalled )
  490. {
  491. if (strDescription.empty())
  492. {
  493. // Couldn't find a description from previous O/S. Oh well - just use "DLC".
  494. AddToConflictsList(sz_DLC, sz_DLC, sz_DLC, CT_Software);
  495. }
  496. else
  497. {
  498. AddToConflictsList(sz_DLC, sz_DLC, strDescription.c_str(), CT_Software);
  499. }
  500. }
  501. }
  502. return hr;
  503. }
  504. // ----------------------------------------------------------------------
  505. //
  506. // Function: ShouldRemoveDLC
  507. //
  508. // Purpose: Determine if DLC should be removed during the upgrade irrespective of whether
  509. // it is currently installed or not.
  510. //
  511. // Arguments:
  512. // strDLCDesc [out] pointer to DLC Description string.
  513. // pfInstalled [out] pointer to a boolean indicating if DLC is currently installed.
  514. // Valid for X86 only.
  515. //
  516. // Returns: TRUE if DLC should be removed.
  517. //
  518. // Author: asinha 3/27/2001
  519. //
  520. // Notes:
  521. //
  522. BOOL ShouldRemoveDLC (tstring *strDLCDesc,
  523. BOOL *pfInstalled)
  524. {
  525. HRESULT hr;
  526. BOOL fDlcRemove = FALSE;
  527. if ( pfInstalled )
  528. {
  529. *pfInstalled = FALSE;
  530. }
  531. // Check if DLC is installed (only for x86 - for IA64 we don't care (NTBUG9:186001) )
  532. #ifdef _X86_
  533. CServiceManager sm;
  534. CService srv;
  535. if ( pfInstalled )
  536. {
  537. hr = sm.HrOpenService(&srv, sz_DLC);
  538. if (SUCCEEDED(hr)) // DLC Service is installed
  539. {
  540. *pfInstalled = TRUE;
  541. LPQUERY_SERVICE_CONFIG pConfig;
  542. HRESULT hr = srv.HrQueryServiceConfig (&pConfig);
  543. if (S_OK == hr)
  544. {
  545. if ( strDLCDesc )
  546. {
  547. *strDLCDesc = pConfig->lpDisplayName;
  548. }
  549. MemFree (pConfig);
  550. }
  551. srv.Close();
  552. }
  553. else
  554. {
  555. *pfInstalled = FALSE;
  556. }
  557. }
  558. fDlcRemove = TRUE;
  559. OSVERSIONINFO osvi;
  560. ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
  561. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  562. // If SNA Server is installed (on NT5) - this is ok
  563. if (GetVersionEx(&osvi)) // Can't use VerifyVersionInfo - we have to run on NT4.
  564. {
  565. if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
  566. (osvi.dwMajorVersion == 5) &&
  567. (osvi.dwMinorVersion == 0) )
  568. {
  569. // If SNA Server is installed - we still allow this
  570. hr = sm.HrOpenService(&srv, L"SnaServr");
  571. if (SUCCEEDED(hr)) // Service is installed
  572. {
  573. srv.Close();
  574. // Only if SNA version is 5.0 or more.
  575. HKEY hkeySnaServer;
  576. hr = HrRegOpenKeyEx(HKEY_LOCAL_MACHINE, sz_SNAServerKey, KEY_READ, &hkeySnaServer);
  577. if (S_OK == hr)
  578. {
  579. tstring tstr;
  580. hr = HrRegQueryString(hkeySnaServer, sz_SNAServerVersion, &tstr);
  581. if (S_OK == hr)
  582. {
  583. int nSnaVersion = _wtoi(tstr.c_str());
  584. if (nSnaVersion >= 5)
  585. {
  586. fDlcRemove = FALSE;
  587. }
  588. }
  589. RegCloseKey(hkeySnaServer);
  590. }
  591. }
  592. }
  593. // Never complain about DLC if upgrading from Whistler+
  594. if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
  595. ( ( (osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1) ) ||
  596. (osvi.dwMajorVersion >= 6) ) )
  597. {
  598. fDlcRemove = FALSE;
  599. }
  600. }
  601. #endif
  602. return fDlcRemove;
  603. }
  604. // ----------------------------------------------------------------------
  605. //
  606. // Function: HrGenerateConflictList
  607. //
  608. // Purpose: Generate upgrade conflict list for s/w and h/w components
  609. //
  610. // Arguments: None
  611. //
  612. // Returns: S_OK on success, otherwise an error code
  613. //
  614. // Author: kumarp 17-December-97
  615. //
  616. // Notes:
  617. //
  618. HRESULT HrGenerateConflictList(OUT UINT* pcNumConflicts)
  619. {
  620. DefineFunctionName("HrGenerateConflictList");
  621. HRESULT hr=S_OK;
  622. (void) HrGenerateHardwareConflictList();
  623. (void) HrGenerateSoftwareConflictList();
  624. (void) HrGenerateNT5ConflictList();
  625. if (g_pplNetComponents && g_pplNetComponents->size())
  626. {
  627. *pcNumConflicts = g_pplNetComponents->size();
  628. }
  629. else
  630. {
  631. *pcNumConflicts = 0;
  632. }
  633. TraceError(__FUNCNAME__, hr);
  634. return hr;
  635. }
  636. // ----------------------------------------------------------------------
  637. //
  638. // Function: UninitConflictList
  639. //
  640. // Purpose: Uninitialize and destroy global lists holding upgrade conflicts
  641. //
  642. // Arguments: None
  643. //
  644. // Returns: None
  645. //
  646. // Author: kumarp 17-December-97
  647. //
  648. // Notes:
  649. //
  650. void UninitConflictList()
  651. {
  652. if (g_pplNetComponents)
  653. {
  654. CNetComponent* pnc;
  655. TPtrListIter pos;
  656. for (pos = g_pplNetComponents->begin();
  657. pos != g_pplNetComponents->end(); pos++)
  658. {
  659. pnc = (CNetComponent*) *pos;
  660. delete pnc;
  661. }
  662. g_pplNetComponents->erase(g_pplNetComponents->begin(),
  663. g_pplNetComponents->end());
  664. delete g_pplNetComponents;
  665. g_pplNetComponents = NULL;
  666. }
  667. }
  668. // ----------------------------------------------------------------------
  669. //
  670. // Function: HrResolveConflictsFromList
  671. //
  672. // Purpose: Use the specified netmap.inf file to find out if any
  673. // of the components currently detected as unsupported can
  674. // be mapped. If such components are found, then delete them
  675. // from pplComponents if fDeleteResolvedItemsFromList is TRUE
  676. //
  677. // Arguments:
  678. // fDeleteResolvedItemsFromList [in] flag (see above)
  679. // pplComponents [in] pointer to list of unsupported components
  680. // hinfNetMap [in] handle of netmap.inf file
  681. // pdwNumConflictsResolved [out] number of components mapped using the
  682. // specified netmap.inf
  683. //
  684. // Returns: S_OK on success, otherwise an error code
  685. //
  686. // Author: kumarp 17-December-97
  687. //
  688. // Notes:
  689. //
  690. HRESULT HrResolveConflictsFromList(IN BOOL fDeleteResolvedItemsFromList,
  691. IN TPtrList* pplComponents,
  692. IN HINF hinfNetMap,
  693. OUT DWORD* pdwNumConflictsResolved,
  694. OUT BOOL* pfHasUpgradeHelpInfo)
  695. {
  696. DefineFunctionName("HrResolveConflictsFromList");
  697. Assert(hinfNetMap);
  698. AssertValidWritePtr(pdwNumConflictsResolved);
  699. HRESULT hr=S_OK;
  700. *pdwNumConflictsResolved = 0;
  701. if (pplComponents && (pplComponents->size() > 0))
  702. {
  703. TPtrListIter pos;
  704. TPtrListIter tpos;
  705. tstring strPreNT5InfId;
  706. CNetComponent* pnc;
  707. HKEY hkeyAdapterParams;
  708. BOOL fIsOemComponent;
  709. tstring strNT5InfId;
  710. pos = pplComponents->begin();
  711. while(pos != pplComponents->end())
  712. {
  713. pnc = (CNetComponent*) *pos;
  714. strNT5InfId = c_szEmpty;
  715. if (pnc->m_eType == CT_Hardware)
  716. {
  717. hr = HrRegOpenServiceSubKey(pnc->m_strServiceName.c_str(), c_szParameters,
  718. KEY_READ, &hkeyAdapterParams);
  719. if (S_OK == hr)
  720. {
  721. fIsOemComponent = FALSE;
  722. hr = HrMapPreNT5NetCardInfIdInInf(hinfNetMap, hkeyAdapterParams,
  723. pnc->m_strPreNT5InfId.c_str(),
  724. &strNT5InfId,
  725. NULL, &fIsOemComponent);
  726. RegCloseKey(hkeyAdapterParams);
  727. }
  728. }
  729. else
  730. {
  731. hr = HrMapPreNT5NetComponentInfIDInInf(hinfNetMap,
  732. pnc->m_strPreNT5InfId.c_str(),
  733. &strNT5InfId,
  734. NULL,
  735. &fIsOemComponent);
  736. if ((S_FALSE == hr) && !strNT5InfId.empty())
  737. {
  738. *pfHasUpgradeHelpInfo = TRUE;
  739. }
  740. }
  741. tpos = pos;
  742. pos++;
  743. // if we found a map, remove the entry
  744. if (S_OK == hr)
  745. {
  746. (*pdwNumConflictsResolved)++;
  747. if (fDeleteResolvedItemsFromList)
  748. {
  749. delete pnc;
  750. pplComponents->erase(tpos);
  751. }
  752. }
  753. }
  754. }
  755. else
  756. {
  757. hr = S_FALSE;
  758. }
  759. TraceErrorOptional(__FUNCNAME__, hr, (S_FALSE == hr));
  760. return hr;
  761. }
  762. // ----------------------------------------------------------------------
  763. //
  764. // Function: HrUpdateConflictList
  765. //
  766. // Purpose: Use the specified netmap.inf file to find out if any
  767. // of the components currently detected as unsupported can
  768. // be mapped. If such components are found, then delete them
  769. // from pplComponents if fDeleteResolvedItemsFromList is TRUE
  770. //
  771. // Arguments:
  772. // fDeleteResolvedItemsFromList [in] flag (see above)
  773. // hinfNetMap [in] handle of netmap.inf file
  774. // pdwNumConflictsResolved [out] number of components mapped using the
  775. // specified netmap.inf
  776. // Returns: S_OK on success, otherwise an error code
  777. //
  778. // Author: kumarp 17-December-97
  779. //
  780. // Notes:
  781. //
  782. HRESULT HrUpdateConflictList(IN BOOL fDeleteResolvedItemsFromList,
  783. IN HINF hinfNetMap,
  784. OUT DWORD* pdwNumConflictsResolved,
  785. OUT BOOL* pfHasUpgradeHelpInfo)
  786. {
  787. DefineFunctionName("HrUpdateConflictList");
  788. HRESULT hr=S_OK;
  789. hr = HrResolveConflictsFromList(fDeleteResolvedItemsFromList,
  790. g_pplNetComponents, hinfNetMap,
  791. pdwNumConflictsResolved,
  792. pfHasUpgradeHelpInfo);
  793. TraceErrorOptional(__FUNCNAME__, hr, (S_FALSE == hr));
  794. return hr;
  795. }
  796. HRESULT HrGetConflictsList(OUT TPtrList** ppplNetComponents)
  797. {
  798. HRESULT hr=S_FALSE;
  799. if (g_pplNetComponents)
  800. {
  801. hr = S_OK;
  802. *ppplNetComponents = g_pplNetComponents;
  803. }
  804. return hr;
  805. }