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.

321 lines
8.5 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "ncreg.h"
  4. #include "ncsvc.h"
  5. #include "nslog.h"
  6. #include "wizard.h"
  7. // Setup Wizard Global - Only used during setup.
  8. extern CWizard * g_pSetupWizard;
  9. BOOL FSetupRequestWizardPages(HPROPSHEETPAGE* pahpsp,
  10. UINT* pcPages,
  11. PINTERNAL_SETUP_DATA psp);
  12. BOOL FSetupFreeWizardPages();
  13. BOOL FNetSetupPrepareSysPrep();
  14. #if !defined(WIN64) && !defined(_WIN64)
  15. BOOL FDoIcsUpgradeIfNecessary();
  16. #endif // !defined(WIN64) && !defined(_WIN64)
  17. //+---------------------------------------------------------------------------
  18. //
  19. // Function: DoInitialCleanup
  20. //
  21. // Purpose: Called from syssetup before any device is installed.
  22. //
  23. // Arguments:
  24. // hwnd [in] parent window
  25. // pisd [in] setup data
  26. //
  27. // Returns: TRUE or FALSE
  28. //
  29. // Author: kumarp 3 Dec 1997
  30. //
  31. // Notes: This must have the signature of NETSETUPINSTALLSOFTWAREPROC
  32. // defined in syssetup.h
  33. //
  34. // DoInitialCleanup is called from syssetup during installs before
  35. // any device is installed.
  36. // If you want something to happen before any PnP / wizard
  37. // stuff happens, this function is the best place to put that code.
  38. //
  39. //
  40. BOOL
  41. WINAPI
  42. DoInitialCleanup (
  43. HWND hwnd,
  44. PINTERNAL_SETUP_DATA pisd)
  45. {
  46. TraceFileFunc(ttidGuiModeSetup);
  47. Assert(pisd);
  48. #if DBG
  49. RtlValidateProcessHeaps ();
  50. #endif
  51. NetSetupLogStatusV (LogSevInformation,
  52. SzLoadIds (IDS_SETUP_MODE_STATUS),
  53. pisd->SetupMode,
  54. pisd->ProductType,
  55. pisd->OperationFlags);
  56. if (pisd->OperationFlags & SETUPOPER_NTUPGRADE)
  57. {
  58. extern HRESULT HrEnableServicesDisabledDuringUpgrade();
  59. // Delete the old NT4 legacy network key. Valid items will be
  60. // rewritten on each device install.
  61. //
  62. extern const WCHAR c_szRegKeyNt4Adapters[];
  63. (VOID) HrRegDeleteKeyTree (HKEY_LOCAL_MACHINE, c_szRegKeyNt4Adapters);
  64. }
  65. extern HRESULT HrRunAnswerFileCleanSection(IN PCWSTR pszAnswerFileName);
  66. extern HRESULT HrProcessInfToRunBeforeInstall(IN HWND hwndParent,
  67. IN PCWSTR szAnswerFileName);
  68. extern HRESULT HrNetSetupCopyOemInfs(IN PCWSTR szAnswerFileName);
  69. // Run the [Clean] section in the answerfile
  70. //
  71. if (pisd->OperationFlags & SETUPOPER_BATCH)
  72. {
  73. AssertValidReadPtr(pisd->UnattendFile);
  74. // We cannot abort upgrade in GUI setup, so we need to continue
  75. // even if an error occurs in any of the following functions
  76. (VOID) HrRunAnswerFileCleanSection(pisd->UnattendFile);
  77. (VOID) HrProcessInfToRunBeforeInstall(hwnd, pisd->UnattendFile);
  78. // Copy OEM net INF files using SetupCopyOemInf, if any
  79. // we want to ignore any error here
  80. (VOID) HrNetSetupCopyOemInfs(pisd->UnattendFile);
  81. }
  82. #if DBG
  83. RtlValidateProcessHeaps ();
  84. #endif
  85. return TRUE;
  86. }
  87. //+---------------------------------------------------------------------------
  88. //
  89. // Function: NetSetupInstallSoftware
  90. //
  91. // Purpose: Exported entrypoint to install network software.
  92. //
  93. // Arguments:
  94. // hwnd [in] parent window
  95. // pisd [in] setup data
  96. //
  97. // Returns: TRUE or FALSE
  98. //
  99. // Author: scottbri 5 Jul 1997
  100. //
  101. // Notes: This must have the signature of NETSETUPINSTALLSOFTWAREPROC
  102. // defined in syssetup.h
  103. //
  104. EXTERN_C
  105. BOOL
  106. WINAPI
  107. NetSetupInstallSoftware(
  108. HWND hwnd,
  109. PINTERNAL_SETUP_DATA pisd )
  110. {
  111. TraceFileFunc(ttidGuiModeSetup);
  112. #if DBG
  113. RtlValidateProcessHeaps ();
  114. #endif
  115. return FALSE;
  116. }
  117. //+---------------------------------------------------------------------------
  118. //
  119. // Function: NetSetupRequestWizardPages
  120. //
  121. // Purpose: Exported request for wizard pages
  122. //
  123. // Arguments:
  124. // pahpsp [out] property pages provided by us
  125. // pcPages [out] number of pages provided
  126. // psp [in] setup data
  127. //
  128. // Returns:
  129. //
  130. // Author: scottbri 5 Jul 1997
  131. //
  132. // Notes: This must have the signature of NETSETUPPAGEREQUESTPROCNAME
  133. // defined in syssetup.h
  134. //
  135. EXTERN_C
  136. BOOL
  137. WINAPI
  138. NetSetupRequestWizardPages(
  139. HPROPSHEETPAGE* pahpsp,
  140. UINT* pcPages,
  141. PINTERNAL_SETUP_DATA psp)
  142. {
  143. TraceFileFunc(ttidGuiModeSetup);
  144. #if DBG
  145. RtlValidateProcessHeaps ();
  146. #endif
  147. return FSetupRequestWizardPages(pahpsp, pcPages, psp);
  148. }
  149. //+---------------------------------------------------------------------------
  150. //
  151. // Function: NetSetupFinishInstall
  152. //
  153. // Purpose: Exported function to finish network installation
  154. //
  155. // Arguments:
  156. // hwnd [in] parent window
  157. // pisd [in] setup data
  158. //
  159. // Returns: TRUE or FALSE
  160. //
  161. // Author: scottbri 5 Jul 1997
  162. //
  163. // Notes: This must have the signature of NETSETUPFINISHINSTALLPROCNAME
  164. // defined in syssetup.h
  165. //
  166. EXTERN_C
  167. BOOL
  168. WINAPI
  169. NetSetupFinishInstall(
  170. HWND hwnd,
  171. PINTERNAL_SETUP_DATA pisd )
  172. {
  173. TraceFileFunc(ttidGuiModeSetup);
  174. #if DBG
  175. RtlValidateProcessHeaps ();
  176. #endif
  177. #if !defined(WIN64) && !defined(_WIN64)
  178. // do the ICS Upgrade from Win9x/Win2K if necessary
  179. // we are doing ICS upgrade here, because
  180. // 1. we need to wait until HNetCfg.dll components have been registered.
  181. // 2. we need to wait until Win9x Dial-Up connections have been migrated.
  182. FDoIcsUpgradeIfNecessary();
  183. #endif // !defined(WIN64) && !defined(_WIN64)
  184. return FSetupFreeWizardPages();
  185. }
  186. //+---------------------------------------------------------------------------
  187. //
  188. // Function: NetSetupAddRasConnection
  189. //
  190. // Purpose: Create a new RAS connection.
  191. //
  192. // Arguments:
  193. // hwnd []
  194. // ppConn []
  195. //
  196. // Returns: S_OK, S_FALSE if cancelled or reentered, or an error code.
  197. //
  198. // Author: scottbri 3 Nov 1997
  199. //
  200. // Notes:
  201. //
  202. EXTERN_C
  203. HRESULT
  204. WINAPI
  205. NetSetupAddRasConnection (
  206. HWND hwnd,
  207. INetConnection** ppConn)
  208. {
  209. TraceFileFunc(ttidGuiModeSetup);
  210. Assert (FImplies(hwnd, IsWindow(hwnd)));
  211. Assert (ppConn);
  212. // Initialize the output parameter.
  213. //
  214. *ppConn = NULL;
  215. HRESULT hr = S_FALSE;
  216. HANDLE hMutex = NULL;
  217. // If the PostInstall wizard flag the wizard has already been launched
  218. //
  219. hMutex = CreateMutex(NULL, TRUE, SzLoadIds(IDS_WIZARD_CAPTION));
  220. if ((NULL == hMutex) || (ERROR_ALREADY_EXISTS == GetLastError()))
  221. {
  222. // if the mutex already exists try to find the connection window
  223. //
  224. if (ERROR_ALREADY_EXISTS == GetLastError())
  225. {
  226. // Try to get the window handle and set to for ground
  227. HWND hwndWizard = FindWindow(NULL, SzLoadIds(IDS_WIZARD_CAPTION));
  228. if (IsWindow(hwndWizard))
  229. {
  230. SetForegroundWindow(hwndWizard);
  231. }
  232. }
  233. }
  234. else
  235. {
  236. #ifdef DBG
  237. if (FIsDebugFlagSet (dfidBreakOnWizard))
  238. {
  239. ShellExecute(NULL, L"open", L"cmd.exe", NULL, NULL, SW_SHOW);
  240. AssertSz(FALSE, "THIS IS NOT A BUG! The debug flag "
  241. "\"BreakOnWizard\" has been set. Set your breakpoints now.");
  242. }
  243. #endif // DBG
  244. hr = HrRunWizard(hwnd, FALSE, ppConn, FALSE);
  245. }
  246. if (hMutex)
  247. {
  248. ReleaseMutex(hMutex);
  249. CloseHandle(hMutex);
  250. }
  251. TraceHr(ttidError, FAL, hr, (S_FALSE == hr),
  252. "NetSetupAddRasConnection");
  253. return hr;
  254. }
  255. //+---------------------------------------------------------------------------
  256. //
  257. // Function: NetSetupPrepareSysPrep
  258. //
  259. // Purpose: Exported entrypoint to prepare work items related to SysPrep
  260. //
  261. // Arguments:
  262. // None
  263. //
  264. // Returns: TRUE or FALSE
  265. //
  266. // Author: FrankLi 22 April 2000
  267. //
  268. // Notes: This causes NetConfig to save network component per adapter
  269. // registry settings to an internal persistent format. Initially,
  270. // a CWInfFile object is used to save the settings in memory.
  271. // Finally, the content of the CWInfFile object will be saved as
  272. // file in %systemroot%\system32\$ncsp$.inf (NetConfigSysPrep)
  273. //
  274. EXTERN_C
  275. BOOL
  276. WINAPI
  277. NetSetupPrepareSysPrep()
  278. {
  279. TraceFileFunc(ttidGuiModeSetup);
  280. return FNetSetupPrepareSysPrep();
  281. }