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.

148 lines
4.1 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "edc.h"
  4. #include "ncnetcfg.h"
  5. #include "netcfgn.h"
  6. #include "winstall.h"
  7. struct INSTALL_PROGRESS_DATA
  8. {
  9. CWizard* pWizard;
  10. HWND hwndProgress; // NULL if no progress window
  11. UINT nProgressDelta;
  12. };
  13. // type of PFN_EDC_CALLBACK
  14. VOID
  15. CALLBACK
  16. InstallCallback (
  17. IN EDC_CALLBACK_MESSAGE Message,
  18. IN ULONG_PTR MessageData,
  19. IN PVOID pvCallerData OPTIONAL)
  20. {
  21. TraceFileFunc(ttidGuiModeSetup);
  22. INSTALL_PROGRESS_DATA* pCallbackData;
  23. UpgradeData* pUpgradeData;
  24. pCallbackData = (INSTALL_PROGRESS_DATA*)pvCallerData;
  25. Assert (pCallbackData);
  26. if ( !pCallbackData ) {
  27. return;
  28. }
  29. Assert (pCallbackData->pWizard);
  30. if ( !pCallbackData->pWizard ) {
  31. return;
  32. }
  33. pUpgradeData = (UpgradeData*)pCallbackData->pWizard->GetPageData(IDD_Upgrade);
  34. Assert(pUpgradeData);
  35. if ( !pUpgradeData ) {
  36. return;
  37. }
  38. if (EDC_INDICATE_COUNT == Message)
  39. {
  40. // 0-nCurrentCap and (c_nMaxProgressRange - 10) through
  41. // c_nMaxProgressRange are spoken for. So the the delta is the
  42. // number of items to install divided into the range remaining.
  43. //
  44. UINT Count = (UINT)MessageData;
  45. pCallbackData->nProgressDelta =
  46. ((c_nMaxProgressRange - 10) - pUpgradeData->nCurrentCap) / Count;
  47. }
  48. else if (EDC_INDICATE_ENTRY == Message)
  49. {
  50. const EDC_ENTRY* pEntry = (const EDC_ENTRY*)MessageData;
  51. NETWORK_INSTALL_PARAMS nip = {0};
  52. nip.dwSetupFlags = NSF_PRIMARYINSTALL;
  53. if (pCallbackData->hwndProgress)
  54. {
  55. OnUpgradeUpdateProgressCap (
  56. pCallbackData->hwndProgress,
  57. pCallbackData->pWizard,
  58. pUpgradeData->nCurrentCap + pCallbackData->nProgressDelta);
  59. }
  60. (VOID) HrInstallComponentOboUser(
  61. pCallbackData->pWizard->PNetCfg(),
  62. &nip,
  63. *pEntry->pguidDevClass,
  64. pEntry->pszInfId,
  65. NULL);
  66. }
  67. }
  68. VOID
  69. InstallDefaultComponents (
  70. IN CWizard* pWizard,
  71. IN DWORD dwSetupFlags,
  72. IN HWND hwndProgress OPTIONAL)
  73. {
  74. TraceFileFunc(ttidGuiModeSetup);
  75. INSTALL_PROGRESS_DATA CallbackData = {0};
  76. CallbackData.pWizard = pWizard;
  77. CallbackData.hwndProgress = hwndProgress;
  78. EnumDefaultComponents (
  79. dwSetupFlags,
  80. InstallCallback,
  81. &CallbackData);
  82. }
  83. VOID
  84. InstallDefaultComponentsIfNeeded (
  85. IN CWizard* pWizard)
  86. {
  87. TraceFileFunc(ttidGuiModeSetup);
  88. HRESULT hr = S_OK;
  89. BOOL fNetworkingPresent = FALSE;
  90. // If at least one LAN capable protocol is installed then networking is installed
  91. //
  92. Assert(NULL != pWizard->PNetCfg());
  93. CIterNetCfgComponent nccIter(pWizard->PNetCfg(), &GUID_DEVCLASS_NETTRANS);
  94. INetCfgComponent* pncc;
  95. while (!fNetworkingPresent && SUCCEEDED(hr) &&
  96. (S_OK == (hr = nccIter.HrNext (&pncc))))
  97. {
  98. // Hack (Sort of) - Basically we want to install default networking if networking is
  99. // not already installed. Unfortunately Ndiswan can bind to ndisatm, so using the
  100. // "Can the protocol bind to an adapter?" is not sufficent. given that the users
  101. // impression of is networking installed, is really based on what they can visually
  102. // see in the UI. We'll (and this is the hack part), ignore hidden protocols when
  103. // considering if a protocol can bind to and adapter.
  104. DWORD dwCharacteristics;
  105. hr = pncc->GetCharacteristics(&dwCharacteristics);
  106. if (SUCCEEDED(hr) && !(dwCharacteristics & NCF_HIDDEN))
  107. {
  108. // Check if the protocol binds to "Lan" type adapter interfaces
  109. //
  110. hr = HrIsLanCapableProtocol(pncc);
  111. if (S_OK == hr)
  112. {
  113. fNetworkingPresent = TRUE;
  114. }
  115. }
  116. ReleaseObj(pncc);
  117. }
  118. if (!fNetworkingPresent)
  119. {
  120. InstallDefaultComponents(pWizard, EDC_DEFAULT, NULL);
  121. }
  122. }