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.

1669 lines
54 KiB

  1. #include "setupp.h"
  2. #pragma hdrstop
  3. #ifdef _OCM
  4. #include <ocmanage.h>
  5. #include <ocmgrlib.h>
  6. #endif
  7. extern BOOLEAN
  8. AsrIsEnabled( VOID );
  9. typedef struct _WIZPAGE {
  10. UINT ButtonState;
  11. UINT Spare;
  12. PROPSHEETPAGE Page;
  13. } WIZPAGE, *PWIZPAGE;
  14. BOOL UiTest;
  15. //
  16. // "Page" that is actually a signal to fetch the net pages
  17. // and insert them there.
  18. //
  19. #define WizPagePlaceholderNet (WizPageMaximum+1)
  20. #define WizPagePlaceholderLic (WizPageMaximum+2)
  21. BOOL NetWizard;
  22. #ifdef _OCM
  23. #define WizPageOcManager (WizPageMaximum+3)
  24. #define WizPageOcManagerSetup (WizPageMaximum+4)
  25. #define WizPageOcManagerEarly (WizPageMaximum+5)
  26. #define WizPageOcManagerPrenet (WizPageMaximum+6)
  27. #define WizPageOcManagerPostnet (WizPageMaximum+7)
  28. #define WizPageOcManagerLate (WizPageMaximum+8)
  29. #endif
  30. #define MAX_LICWIZ_PAGES MAX_NETWIZ_PAGES
  31. #define LICENSESETUPPAGEREQUESTPROCNAME "LicenseSetupRequestWizardPages"
  32. //
  33. // These MUST be in the same order as the items in the WizPage enum!!!
  34. //
  35. WIZPAGE SetupWizardPages[WizPageMaximum] = {
  36. //
  37. // Welcome page
  38. //
  39. {
  40. PSWIZB_NEXT,
  41. 0,
  42. { sizeof(PROPSHEETPAGE), // size of struct
  43. PSP_HIDEHEADER, // full-size page, no header
  44. NULL, // hinst (filled in at run time)
  45. MAKEINTRESOURCE(IDD_WELCOME), // dlg template
  46. NULL, // icon
  47. NULL, // title
  48. WelcomeDlgProc, // dlg proc
  49. 0, // lparam
  50. NULL, // callback
  51. NULL // ref count
  52. }},
  53. //
  54. // EULA page
  55. //
  56. {
  57. PSWIZB_NEXT | PSWIZB_BACK,
  58. 0,
  59. { sizeof(PROPSHEETPAGE), // size of struct
  60. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  61. NULL, // hinst (filled in at run time)
  62. MAKEINTRESOURCE(IDD_EULA), // dlg template
  63. NULL, // icon
  64. NULL, // title
  65. EulaDlgProc, // dlg proc
  66. 0, // lparam
  67. NULL, // callback
  68. NULL, // ref count
  69. (LPCWSTR)IDS_EULA, // title
  70. (LPCWSTR)IDS_EULA_SUB, // subtitle
  71. }},
  72. //
  73. // Preparing Directory page
  74. //
  75. {
  76. PSWIZB_NEXT | PSWIZB_BACK,
  77. 0,
  78. { sizeof(PROPSHEETPAGE), // size of struct
  79. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  80. NULL, // hinst (filled in at run time)
  81. MAKEINTRESOURCE(IDD_PREPARING), // dlg template
  82. NULL, // icon
  83. NULL, // title
  84. PreparingDlgProc, // dlg proc
  85. 0, // lparam
  86. NULL, // callback
  87. NULL, // ref count
  88. (LPCWSTR)IDS_PREPARING_INSTALL, // title
  89. (LPCWSTR)IDS_PREPARING_INSTALL_SUB, // subtitle
  90. }},
  91. //
  92. // Preparing ASR page
  93. //
  94. {
  95. PSWIZB_NEXT | PSWIZB_BACK,
  96. 0,
  97. { sizeof(PROPSHEETPAGE), // size of struct
  98. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE, NULL, // hinst (filled in at run time)
  99. MAKEINTRESOURCE(IDD_PREPARING_ASR), // dlg template
  100. NULL, // icon
  101. NULL, // title
  102. PreparingDlgProc, // dlg proc
  103. 0, // lparam
  104. NULL, // callback
  105. NULL, // ref count
  106. (LPCWSTR)IDS_ASR, // title
  107. (LPCWSTR)IDS_ASR_SUB, // subtitle
  108. }},
  109. //
  110. // International settings (locale, kbd layout) page
  111. //
  112. {
  113. PSWIZB_NEXT | PSWIZB_BACK,
  114. 0,
  115. { sizeof(PROPSHEETPAGE), // size of struct
  116. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  117. NULL, // hInst (filled in at run time)
  118. MAKEINTRESOURCE(IDD_REGIONAL_SETTINGS), // dlg template
  119. NULL, // icon
  120. NULL, // title
  121. RegionalSettingsDlgProc, // dlg proc
  122. 0, // lparam
  123. NULL, // callback
  124. NULL, // ref count
  125. (LPCWSTR)IDS_REGIONAL_SETTINGS,
  126. (LPCWSTR)IDS_REGIONAL_SETTINGS_SUB
  127. }},
  128. //
  129. // Name/organization page
  130. //
  131. {
  132. PSWIZB_NEXT | PSWIZB_BACK,
  133. 0,
  134. { sizeof(PROPSHEETPAGE), // size of struct
  135. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  136. NULL, // hinst (filled in at run time)
  137. MAKEINTRESOURCE(IDD_NAMEORG), // dlg template
  138. NULL, // icon
  139. NULL, // title
  140. NameOrgDlgProc, // dlg proc
  141. 0, // lparam
  142. NULL, // callback
  143. NULL, // ref count
  144. (LPCWSTR)IDS_NAMEORG, // title
  145. (LPCWSTR)IDS_NAMEORG_SUB // subtitle
  146. }},
  147. //
  148. // Product id page for CD
  149. //
  150. {
  151. PSWIZB_NEXT | PSWIZB_BACK,
  152. 0,
  153. { sizeof(PROPSHEETPAGE), // size of struct
  154. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  155. NULL, // hinst (filled in at run time)
  156. MAKEINTRESOURCE(IDD_PID_CD), // dlg template
  157. NULL, // icon
  158. NULL, // title
  159. Pid30CDDlgProc, // dlg proc
  160. 0, // lparam
  161. NULL, // callback
  162. NULL, // ref count
  163. (LPCWSTR)IDS_PID, // title
  164. (LPCWSTR)IDS_PID_SUB // subtitle
  165. }},
  166. //
  167. // Product id page for OEM
  168. //
  169. {
  170. PSWIZB_NEXT | PSWIZB_BACK,
  171. 0,
  172. { sizeof(PROPSHEETPAGE), // size of struct
  173. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  174. NULL, // hinst (filled in at run time)
  175. MAKEINTRESOURCE(IDD_PID_OEM), // dlg template
  176. NULL, // icon
  177. NULL, // title
  178. Pid30OemDlgProc, // dlg proc
  179. 0, // lparam
  180. NULL, // callback
  181. NULL, // ref count
  182. (LPCWSTR)IDS_OEM, // title
  183. (LPCWSTR)IDS_OEM_SUB // subtitle
  184. }},
  185. //
  186. // Product id page for Select media
  187. //
  188. {
  189. PSWIZB_NEXT | PSWIZB_BACK,
  190. 0,
  191. { sizeof(PROPSHEETPAGE), // size of struct
  192. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  193. NULL, // hinst (filled in at run time)
  194. MAKEINTRESOURCE(IDD_PID_SELECT), // dlg template
  195. NULL, // icon
  196. NULL, // title
  197. Pid30SelectDlgProc, // dlg proc
  198. 0, // lparam
  199. NULL, // callback
  200. NULL, // ref count
  201. (LPCWSTR)IDS_SELECT, // title
  202. (LPCWSTR)IDS_SELECT_SUB // subtitle
  203. }},
  204. //
  205. // Computer name page
  206. //
  207. {
  208. PSWIZB_NEXT | PSWIZB_BACK,
  209. 0,
  210. { sizeof(PROPSHEETPAGE), // size of struct
  211. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  212. NULL, // hinst (filled in at run time)
  213. MAKEINTRESOURCE(IDD_COMPUTERNAME), // dlg template
  214. NULL, // icon
  215. NULL, // title
  216. ComputerNameDlgProc, // dlg proc
  217. 0, // lparam
  218. NULL, // callback
  219. NULL, // ref count
  220. (LPCWSTR)IDS_COMPUTERNAME, // title
  221. (LPCWSTR)IDS_COMPUTERNAME_SUB // subtitle
  222. }},
  223. #ifdef DOLOCALUSER
  224. //
  225. // Local user account page
  226. //
  227. {
  228. PSWIZB_NEXT | PSWIZB_BACK,
  229. 0,
  230. { sizeof(PROPSHEETPAGE), // size of struct
  231. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  232. NULL, // hinst (filled in at run time)
  233. MAKEINTRESOURCE(IDD_USERACCOUNT), // dlg template
  234. NULL, // icon
  235. NULL, // title
  236. UserAccountDlgProc, // dlg proc
  237. 0, // lparam
  238. NULL, // callback
  239. NULL, // ref count
  240. (LPCWSTR)IDS_USERNAME, // title
  241. (LPCWSTR)IDS_USERNAME_SUB // subtitle
  242. }},
  243. #endif
  244. #ifdef _X86_
  245. //
  246. // Pentium errata page (x86 only)
  247. //
  248. {
  249. PSWIZB_NEXT | PSWIZB_BACK,
  250. 0,
  251. { sizeof(PROPSHEETPAGE), // size of struct
  252. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  253. NULL, // hinst (filled in at run time)
  254. MAKEINTRESOURCE(IDD_PENTIUM), // dlg template
  255. NULL, // icon
  256. NULL, // title
  257. PentiumDlgProc, // dlg proc
  258. 0, // lparam
  259. NULL, // callback
  260. NULL, // ref count
  261. (LPCWSTR)IDS_FPERRATA, // title
  262. (LPCWSTR)IDS_FPERRATA_SUB // subtitle
  263. }},
  264. #endif // def _X86_
  265. //
  266. // Intermediate steps page
  267. //
  268. {
  269. PSWIZB_NEXT | PSWIZB_BACK,
  270. 0,
  271. { sizeof(PROPSHEETPAGE), // size of struct
  272. PSP_USEHEADERTITLE,
  273. NULL, // hinst (filled in at run time)
  274. MAKEINTRESOURCE(IDD_STEPS1), // dlg template
  275. NULL, // icon
  276. NULL, // title
  277. StepsDlgProc, // dlg proc
  278. 0, // lparam
  279. NULL, // callback
  280. NULL, // ref count
  281. (LPCWSTR)IDS_WINNT_SETUP // title
  282. }},
  283. {
  284. 0,
  285. 0,
  286. { sizeof(PROPSHEETPAGE), // size of struct
  287. PSP_USEHEADERTITLE,
  288. NULL, // hinst (filled in at run time)
  289. MAKEINTRESOURCE(IDD_STEPS1), // dlg template
  290. NULL, // icon
  291. NULL, // title
  292. SetupPreNetDlgProc, // dlg proc
  293. 0, // lparam
  294. NULL, // callback
  295. NULL, // ref count
  296. (LPCWSTR)IDS_WINNT_SETUP // title
  297. }},
  298. {
  299. 0,
  300. 0,
  301. { sizeof(PROPSHEETPAGE), // size of struct
  302. PSP_USEHEADERTITLE,
  303. NULL, // hinst (filled in at run time)
  304. MAKEINTRESOURCE(IDD_STEPS1), // dlg template
  305. NULL, // icon
  306. NULL, // title
  307. SetupPostNetDlgProc, // dlg proc
  308. 0, // lparam
  309. NULL, // callback
  310. NULL, // ref count
  311. (LPCWSTR)IDS_WINNT_SETUP // title
  312. }},
  313. //
  314. // Copying files page
  315. //
  316. {
  317. PSWIZB_NEXT | PSWIZB_BACK,
  318. 0,
  319. { sizeof(PROPSHEETPAGE), // size of struct
  320. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  321. NULL, // hinst (filled in at run time)
  322. MAKEINTRESOURCE(IDD_COPYFILES3), // dlg template
  323. NULL, // icon
  324. NULL, // title
  325. CopyFilesDlgProc, // dlg proc
  326. 0, // lparam
  327. NULL, // callback
  328. NULL, // ref count
  329. (LPCWSTR)IDS_COPYFILES, // title
  330. (LPCWSTR)IDS_COPYFILES_SUB2, // subtitle
  331. }},
  332. //
  333. // Last ASR page.
  334. //
  335. {
  336. PSWIZB_FINISH,
  337. 0,
  338. { sizeof(PROPSHEETPAGE), // size of struct
  339. PSP_HIDEHEADER, // full-size page, no header
  340. NULL, // hinst (filled in at run time)
  341. MAKEINTRESOURCE(IDD_LAST_ASR_PAGE), // dlg template
  342. NULL, // icon
  343. NULL, // title
  344. LastPageDlgProc, // dlg proc
  345. 0, // lparam
  346. NULL, // callback
  347. NULL, // ref count
  348. (LPCWSTR)IDS_WINNT_SETUP // title
  349. }},
  350. //
  351. // Last page.
  352. //
  353. {
  354. PSWIZB_FINISH,
  355. 0,
  356. { sizeof(PROPSHEETPAGE), // size of struct
  357. PSP_HIDEHEADER, // full-size page, no header
  358. NULL, // hinst (filled in at run time)
  359. MAKEINTRESOURCE(IDD_LAST_WIZARD_PAGE), // dlg template
  360. NULL, // icon
  361. NULL, // title
  362. LastPageDlgProc, // dlg proc
  363. 0, // lparam
  364. NULL, // callback
  365. NULL, // ref count
  366. (LPCWSTR)IDS_WINNT_SETUP // title
  367. }}
  368. };
  369. UINT InitialWizardPages[] = { WizPageWelcome,
  370. WizPageEula,
  371. WizPagePreparing,
  372. WizPageRegionalSettings,
  373. WizPageNameOrg,
  374. WizPageProductIdCd,
  375. WizPageProductIdOem,
  376. WizPageProductIdSelect,
  377. WizPagePlaceholderLic,
  378. WizPageComputerName,
  379. #ifdef _OCM
  380. WizPageOcManager,
  381. WizPageOcManagerEarly,
  382. #endif
  383. #ifdef DOLOCALUSER
  384. WizPageUserAccount,
  385. #endif
  386. #ifdef _X86_
  387. WizPagePentiumErrata,
  388. #endif
  389. WizPageSteps1,
  390. #ifdef _OCM
  391. WizPageOcManagerPrenet,
  392. #endif
  393. WizSetupPreNet,
  394. WizPagePlaceholderNet,
  395. WizSetupPostNet,
  396. #ifdef _OCM
  397. WizPageOcManagerPostnet,
  398. WizPageOcManagerLate,
  399. WizPageOcManagerSetup,
  400. #endif
  401. WizPageCopyFiles,
  402. WizPageLast
  403. };
  404. UINT AsrWizardPages[] = { WizPagePreparingAsr,
  405. #ifdef _OCM
  406. WizPageOcManager,
  407. WizPageOcManagerEarly,
  408. WizPageOcManagerPrenet,
  409. #endif
  410. WizSetupPreNet,
  411. WizPagePlaceholderNet,
  412. WizSetupPostNet,
  413. #ifdef _OCM
  414. WizPageOcManagerPostnet,
  415. WizPageOcManagerLate,
  416. WizPageOcManagerSetup,
  417. #endif
  418. WizPageAsrLast
  419. };
  420. UINT UpgradeWizardPages[] = { WizPageWelcome,
  421. WizPageEula,
  422. WizPagePreparing,
  423. WizPageRegionalSettings,
  424. WizPageProductIdCd,
  425. WizPageProductIdOem,
  426. WizPageProductIdSelect,
  427. WizPagePlaceholderLic,
  428. #ifdef _OCM
  429. WizPageOcManager,
  430. WizPageOcManagerEarly,
  431. #endif
  432. #ifdef _X86_
  433. WizPagePentiumErrata,
  434. #endif
  435. WizPageSteps1,
  436. #ifdef _OCM
  437. WizPageOcManagerPrenet,
  438. #endif
  439. WizSetupPreNet,
  440. WizPagePlaceholderNet,
  441. WizSetupPostNet,
  442. #ifdef _OCM
  443. WizPageOcManagerPostnet,
  444. WizPageOcManagerLate,
  445. WizPageOcManagerSetup,
  446. #endif
  447. WizPageCopyFiles,
  448. WizPageLast
  449. };
  450. UINT UiTestWizardPages[] = { WizPageWelcome,
  451. WizPageEula,
  452. WizPagePreparing,
  453. WizPageRegionalSettings,
  454. WizPageNameOrg,
  455. WizPageProductIdCd,
  456. WizPageProductIdOem,
  457. WizPageProductIdSelect,
  458. WizPageComputerName,
  459. #ifdef DOLOCALUSER
  460. WizPageUserAccount,
  461. #endif
  462. #ifdef _X86_
  463. WizPagePentiumErrata,
  464. #endif // def _X86_
  465. WizPageSteps1,
  466. WizPageCopyFiles,
  467. WizPageLast
  468. };
  469. UINT MiniSetupWizardPages[] = {
  470. WizPageWelcome,
  471. WizPageEula,
  472. WizPagePreparing,
  473. WizPageRegionalSettings,
  474. WizPageNameOrg,
  475. WizPageProductIdCd,
  476. WizPageProductIdOem,
  477. WizPageProductIdSelect,
  478. WizPagePlaceholderLic,
  479. WizPageComputerName,
  480. #ifdef _OCM
  481. WizPageOcManager,
  482. WizPageOcManagerEarly,
  483. #endif
  484. WizPageSteps1,
  485. #ifdef _OCM
  486. WizPageOcManagerPrenet,
  487. #endif
  488. WizPagePlaceholderNet,
  489. #ifdef _OCM
  490. WizPageOcManagerPostnet,
  491. WizPageOcManagerLate,
  492. WizPageOcManagerSetup,
  493. #endif
  494. WizPageCopyFiles,
  495. WizPageLast
  496. };
  497. #define TIME_INITIALIZE 120
  498. #define TIME_INSTALLSECURITY 30
  499. #define TIME_PRECOMPILEINFS 90 // calc something with #infs and throughput
  500. #define TIME_INSTALLDEVICES 330 // How can we calc a better number?
  501. // Also Pre compile INFs is part of Device Install page
  502. #define TIME_INSTALLENUMDEVICES1 120
  503. #define TIME_INSTALLLEGACYDEVICES 30
  504. #define TIME_INSTALLENUMDEVICES2 60
  505. #define TIME_NETINSTALL 150 // need better number
  506. #define TIME_OCINSTALL 420 // need better number
  507. #define TIME_INSTALLCOMPONENTINFS 240 // need better number
  508. #define TIME_INF_REGISTRATION 300 // need better number
  509. #define TIME_RUNONCE_REGISTRATION 120 // need better number
  510. #define TIME_SECURITYTEMPLATE 150 // need better number
  511. #define TIME_WIN9XMIGRATION 120 // Need better number
  512. #define TIME_SFC 420
  513. #define TIME_SAVEREPAIR 30
  514. #define TIME_REMOVETEMOFILES 30
  515. #define TIME_ALL 2190
  516. //
  517. // The entries in this array need to correcpond to the enum SetupPhases in setuppp.h
  518. SETUPPHASE SetupPhase[] = {
  519. { TIME_INITIALIZE, FALSE }, // Initialize
  520. { TIME_INSTALLSECURITY, FALSE }, // InstallSecurity
  521. { TIME_PRECOMPILEINFS, FALSE }, // PrecompileInfs
  522. { TIME_INSTALLENUMDEVICES1, FALSE }, // InstallDevices
  523. { TIME_INSTALLLEGACYDEVICES, FALSE },
  524. { TIME_INSTALLENUMDEVICES2, FALSE },
  525. { TIME_NETINSTALL, FALSE }, // NetInstall
  526. { TIME_OCINSTALL, FALSE }, // OCInstall
  527. { TIME_INSTALLCOMPONENTINFS, FALSE},
  528. { TIME_INF_REGISTRATION, FALSE},
  529. { TIME_RUNONCE_REGISTRATION, FALSE }, // Registration
  530. { TIME_SECURITYTEMPLATE, FALSE }, // SecurityTempates
  531. { TIME_WIN9XMIGRATION, TRUE }, // Win9xMigration
  532. { TIME_SFC, FALSE }, // SFC
  533. { TIME_SAVEREPAIR, FALSE }, // SaveRepair
  534. { TIME_REMOVETEMOFILES, FALSE } // RemoveTempFiles
  535. };
  536. UINT CurrentPhase = Phase_Unknown;
  537. ULONG RemainingTime = 0;
  538. #ifdef _OCM
  539. BOOL
  540. pOcManagerPages(
  541. IN PSETUP_REQUEST_PAGES Page,
  542. OUT HPROPSHEETPAGE *WizardPageHandles,
  543. IN OUT UINT *PageCount
  544. );
  545. #endif
  546. BOOL
  547. GetNetworkWizardPages(
  548. OUT HPROPSHEETPAGE *PageHandles,
  549. IN OUT PUINT PageCount
  550. )
  551. /*++
  552. Routine Description:
  553. This routine asks net setup for its wizard pages and passes it
  554. a pointer to a global structure to be used later to pass info
  555. back and forth between base and net setups. Net setup must not
  556. attempt to use any fields in there yet because they are not
  557. filled in yet.
  558. Arguments:
  559. PropSheetHandles - receives network setup wizard page handles.
  560. PageCount - on input, supplies number of slots in PropSheetHandles
  561. array. On output, receives number of handles actually placed
  562. in the array.
  563. Return Value:
  564. If the netsetup wizard dll could not be loaded, returns FALSE.
  565. Otherwise returns TRUE if no error, or does not return if error.
  566. --*/
  567. {
  568. NETSETUPPAGEREQUESTPROC PageRequestProc;
  569. HMODULE NetSetupModule;
  570. DWORD d;
  571. BOOL b;
  572. b = FALSE;
  573. d = NO_ERROR;
  574. NetSetupModule = LoadLibrary(L"NETSHELL");
  575. if(!NetSetupModule) {
  576. //
  577. // If the network wizard isn't around, then the legacy network inf
  578. // had better be.
  579. //
  580. WCHAR x[MAX_PATH];
  581. if(!GetSystemDirectory(x, MAX_PATH)){
  582. d = GetLastError();
  583. goto c0;
  584. }
  585. if(pSetupConcatenatePaths(x,L"NTLANMAN.INF",MAX_PATH,NULL)){
  586. if(FileExists(x,NULL)) {
  587. return(FALSE);
  588. }
  589. }
  590. d = ERROR_FILE_NOT_FOUND;
  591. goto c0;
  592. }
  593. PageRequestProc = (NETSETUPPAGEREQUESTPROC)GetProcAddress(
  594. NetSetupModule,
  595. NETSETUPPAGEREQUESTPROCNAME
  596. );
  597. if(!PageRequestProc) {
  598. d = GetLastError();
  599. goto c0;
  600. }
  601. //
  602. // Net setup needs product type really early.
  603. //
  604. SetProductTypeInRegistry();
  605. //
  606. // Call net setup to get its pages.
  607. //
  608. InternalSetupData.dwSizeOf = sizeof(INTERNAL_SETUP_DATA);
  609. b = PageRequestProc(PageHandles,PageCount,&InternalSetupData);
  610. //
  611. // If we get here, d is NO_ERROR. If b is FALSE this NO_ERROR will be
  612. // a special case to mean "the network wizard request failed."
  613. // In other error cases, d will have a non-0 value.
  614. //
  615. c0:
  616. if(!b) {
  617. //
  618. // This is fatal, something is really wrong.
  619. //
  620. FatalError(MSG_LOG_NETWIZPAGE,d,0,0);
  621. }
  622. return(TRUE);
  623. }
  624. BOOL
  625. GetLicenseWizardPages(
  626. OUT HPROPSHEETPAGE *PageHandles,
  627. IN OUT PUINT PageCount
  628. )
  629. /*++
  630. Routine Description:
  631. This routine asks liccpa setup for its wizard pages and passes it
  632. a pointer to a global structure to be used later to pass info
  633. back and forth between base and liccpa setups. Liccpa setup must not
  634. attempt to use any fields in there yet because they are not
  635. filled in yet.
  636. Arguments:
  637. PropSheetHandles - receives liccpa setup wizard page handles.
  638. PageCount - on input, supplies number of slots in PropSheetHandles
  639. array. On output, receives number of handles actually placed
  640. in the array.
  641. Return Value:
  642. If the liccpa dll could not be loaded, returns FALSE.
  643. Otherwise returns TRUE if no error, or does not return if error.
  644. --*/
  645. {
  646. NETSETUPPAGEREQUESTPROC PageRequestProc;
  647. HMODULE LicenseSetupModule;
  648. DWORD d;
  649. BOOL b;
  650. b = FALSE;
  651. d = NO_ERROR;
  652. LicenseSetupModule = LoadLibrary(L"LICCPA.CPL");
  653. if(!LicenseSetupModule) {
  654. //
  655. // If the license wizard isn't around, then this is a fatal error
  656. //
  657. d = ERROR_FILE_NOT_FOUND;
  658. goto c0;
  659. }
  660. PageRequestProc = (NETSETUPPAGEREQUESTPROC)GetProcAddress(
  661. LicenseSetupModule,
  662. LICENSESETUPPAGEREQUESTPROCNAME
  663. );
  664. if(!PageRequestProc) {
  665. d = GetLastError();
  666. goto c0;
  667. }
  668. // //
  669. // // Net setup needs product type really early.
  670. // //
  671. // SetProductTypeInRegistry();
  672. //
  673. // Call liccpa setup to get its pages.
  674. //
  675. InternalSetupData.dwSizeOf = sizeof(INTERNAL_SETUP_DATA);
  676. b = PageRequestProc(PageHandles,PageCount,&InternalSetupData);
  677. //
  678. // If we get here, d is NO_ERROR. If b is FALSE this NO_ERROR will be
  679. // a special case to mean "the license wizard request failed."
  680. // In other error cases, d will have a non-0 value.
  681. //
  682. c0:
  683. if(!b) {
  684. //
  685. // This is fatal, something is really wrong.
  686. //
  687. FatalError(MSG_LOG_LICWIZPAGE,d,0,0);
  688. }
  689. return(TRUE);
  690. }
  691. VOID
  692. SetWizardButtons(
  693. IN HWND hdlgPage,
  694. IN WizPage PageNumber
  695. )
  696. {
  697. //
  698. // Dirty hack to hide cancel and help buttons.
  699. // We don't have any help buttons but some of the other
  700. // components whose pages are included here might; we want to make
  701. // sure that for us, the help button stays removed!
  702. //
  703. EnableWindow(GetDlgItem(GetParent(hdlgPage),IDCANCEL),FALSE);
  704. ShowWindow(GetDlgItem(GetParent(hdlgPage),IDCANCEL),SW_HIDE);
  705. EnableWindow(GetDlgItem(GetParent(hdlgPage),IDHELP),FALSE);
  706. ShowWindow(GetDlgItem(GetParent(hdlgPage),IDHELP),SW_HIDE);
  707. PropSheet_SetWizButtons(GetParent(hdlgPage),SetupWizardPages[PageNumber].ButtonState);
  708. SetWindowLongPtr(hdlgPage,DWLP_MSGRESULT,0);
  709. }
  710. VOID
  711. WizardBringUpHelp(
  712. IN HWND hdlg,
  713. IN WizPage PageNumber
  714. )
  715. {
  716. #if 0
  717. BOOL b;
  718. b = WinHelp(
  719. hdlg,
  720. L"setupnt.hlp",
  721. HELP_CONTEXT,
  722. SetupWizardPages[PageNumber].HelpContextId
  723. );
  724. if(!b) {
  725. MessageBoxFromMessage(
  726. hdlg,
  727. MSG_CANT_INVOKE_WINHELP,
  728. NULL,
  729. IDS_ERROR,
  730. MB_ICONSTOP | MB_OK
  731. );
  732. }
  733. #else
  734. UNREFERENCED_PARAMETER(hdlg);
  735. UNREFERENCED_PARAMETER(PageNumber);
  736. #endif
  737. }
  738. VOID
  739. WizardKillHelp(
  740. IN HWND hdlg
  741. )
  742. {
  743. #if 0
  744. WinHelp(hdlg,NULL,HELP_QUIT,0);
  745. #else
  746. UNREFERENCED_PARAMETER(hdlg);
  747. #endif
  748. }
  749. WNDPROC OldWizDlgProc;
  750. INT_PTR
  751. NewWizDlgProc(
  752. IN HWND hdlg,
  753. IN UINT msg,
  754. IN WPARAM wParam,
  755. IN LPARAM lParam
  756. )
  757. {
  758. static RECT rect;
  759. static BOOL Visible = TRUE;
  760. BOOL b = FALSE;
  761. //
  762. // Eat WM_SYSCOMMAND where wParam is SC_CLOSE.
  763. // Pass all other messages on.
  764. //
  765. if((msg != WM_SYSCOMMAND) || ((wParam & 0xfff0) != SC_CLOSE))
  766. {
  767. switch (msg)
  768. {
  769. // Set the progress text
  770. // Indicates what setup is doing.
  771. case WMX_SETPROGRESSTEXT:
  772. BB_SetProgressText((PCTSTR)lParam);
  773. b = TRUE;
  774. break;
  775. case WMX_BB_SETINFOTEXT:
  776. BB_SetInfoText((PTSTR)lParam);
  777. b = TRUE;
  778. break;
  779. // Enabled, disable, show, hide the progress gauge on the billboard
  780. // wParam should be SW_SHOW or SW_HIDE
  781. case WMX_BBPROGRESSGAUGE:
  782. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,BB_ShowProgressGaugeWnd((UINT)wParam));
  783. b= TRUE;
  784. break;
  785. // Start, stop the billboard text.
  786. // This start, stops the billboard text and shows, hides the wizard pages
  787. case WMX_BBTEXT:
  788. if (hinstBB)
  789. {
  790. if (wParam != 0)
  791. {
  792. if (Visible)
  793. {
  794. // Get the current position of the wizard
  795. // We restore this position when we need to show it.
  796. GetWindowRect(hdlg, &rect);
  797. SetWindowPos(hdlg,
  798. GetBBhwnd(),
  799. 0,0,0,0,
  800. SWP_NOZORDER);
  801. SetActiveWindow(GetBBhwnd());
  802. Visible = FALSE;
  803. }
  804. }
  805. else
  806. {
  807. if (!Visible)
  808. {
  809. SetWindowPos(hdlg,
  810. HWND_TOP,
  811. rect.left,
  812. rect.top,
  813. rect.right-rect.left,
  814. rect.bottom-rect.top,
  815. SWP_SHOWWINDOW);
  816. }
  817. Visible = TRUE;
  818. }
  819. if (!StartStopBB((wParam != 0)))
  820. {
  821. if (!Visible)
  822. {
  823. SetWindowPos(hdlg,
  824. HWND_TOP,
  825. rect.left,
  826. rect.top,
  827. rect.right-rect.left,
  828. rect.bottom-rect.top,
  829. SWP_SHOWWINDOW);
  830. }
  831. Visible = TRUE;
  832. }
  833. }
  834. else
  835. {
  836. if (!Visible)
  837. {
  838. SetWindowPos(hdlg,
  839. HWND_TOP,
  840. rect.left,
  841. rect.top,
  842. rect.right-rect.left,
  843. rect.bottom-rect.top,
  844. SWP_SHOWWINDOW);
  845. }
  846. Visible = TRUE;
  847. }
  848. return TRUE;
  849. /*
  850. case WMX_BBTEXT:
  851. if (hinstBB)
  852. {
  853. if (wParam != 0)
  854. {
  855. ShowWindow (hdlg, SW_HIDE);
  856. }
  857. else
  858. {
  859. ShowWindow (hdlg, SW_SHOW);
  860. }
  861. if (!StartStopBB((wParam != 0)))
  862. {
  863. ShowWindow (hdlg, SW_SHOW);
  864. }
  865. }
  866. else
  867. {
  868. ShowWindow (hdlg, SW_SHOW);
  869. }
  870. b = TRUE;
  871. break;
  872. */
  873. default:
  874. b = (BOOL)CallWindowProc(OldWizDlgProc,hdlg,msg,wParam,lParam);
  875. break;
  876. }
  877. }
  878. return b;
  879. }
  880. #ifdef _OCM
  881. //
  882. // Bogus global variable necessary because there's no way to get
  883. // a value through to the PropSheetCallback.
  884. //
  885. PVOID _CBx;
  886. #endif
  887. int
  888. CALLBACK
  889. WizardCallback(
  890. IN HWND hdlg,
  891. IN UINT code,
  892. IN LPARAM lParam
  893. )
  894. {
  895. DLGTEMPLATE *DlgTemplate;
  896. HMENU menu;
  897. UNREFERENCED_PARAMETER(hdlg);
  898. //
  899. // Get rid of context sensitive help control on title bar
  900. //
  901. if(code == PSCB_PRECREATE) {
  902. DlgTemplate = (DLGTEMPLATE *)lParam;
  903. DlgTemplate->style &= ~DS_CONTEXTHELP;
  904. } else {
  905. if(code == PSCB_INITIALIZED) {
  906. //
  907. // Get rid of close item on system menu.
  908. // Also need to process WM_SYSCOMMAND to eliminate use
  909. // of Alt+F4.
  910. //
  911. if(menu = GetSystemMenu(hdlg,FALSE)) {
  912. EnableMenuItem(menu,SC_CLOSE,MF_BYCOMMAND|MF_GRAYED);
  913. }
  914. OldWizDlgProc = (WNDPROC)SetWindowLongPtr(hdlg,DWLP_DLGPROC,(LONG_PTR)NewWizDlgProc);
  915. #ifdef _OCM
  916. // inform ocm components of the wizard dialog handle
  917. if (_CBx)
  918. OcRememberWizardDialogHandle(_CBx,hdlg);
  919. #endif
  920. }
  921. }
  922. return(0);
  923. }
  924. VOID
  925. Wizard(
  926. #ifdef _OCM
  927. IN PVOID OcManagerContext
  928. #else
  929. VOID
  930. #endif
  931. )
  932. {
  933. PROPSHEETHEADER psh;
  934. PUINT PageList;
  935. UINT PagesInSet;
  936. UINT i;
  937. UINT PageOrdinal;
  938. UINT PageCount;
  939. UINT NetPageCount;
  940. UINT LicPageCount;
  941. #ifdef _OCM
  942. HPROPSHEETPAGE WizardPageHandles[MAXPROPPAGES];
  943. #else
  944. HPROPSHEETPAGE WizardPageHandles[WizPageMaximum+MAX_NETWIZ_PAGES+MAX_LICWIZ_PAGES];
  945. #endif
  946. BOOL b;
  947. INT_PTR Status;
  948. HDC hdc;
  949. #ifdef _OCM
  950. PSETUP_REQUEST_PAGES PagesFromOcManager[WizPagesTypeMax];
  951. OC_PAGE_CONTROLS OcPageControls,OcDetailsControls;
  952. SETUP_PAGE_CONTROLS OcSetupPageControls;
  953. #endif
  954. //
  955. // Determine which set of pages to use and how many there are in the set.
  956. //
  957. if(UiTest) {
  958. PageList = UiTestWizardPages;
  959. PagesInSet = sizeof(UiTestWizardPages)/sizeof(UiTestWizardPages[0]);
  960. } else {
  961. if(Upgrade) {
  962. PageList = UpgradeWizardPages;
  963. PagesInSet = sizeof(UpgradeWizardPages)/sizeof(UpgradeWizardPages[0]);
  964. } else {
  965. if( MiniSetup ) {
  966. PageList = MiniSetupWizardPages;
  967. PagesInSet = sizeof(MiniSetupWizardPages)/sizeof(MiniSetupWizardPages[0]);
  968. }
  969. else {
  970. if( AsrIsEnabled() ) {
  971. PageList = AsrWizardPages;
  972. PagesInSet = sizeof(AsrWizardPages)/sizeof(AsrWizardPages[0]);
  973. } else {
  974. PageList = InitialWizardPages;
  975. PagesInSet = sizeof(InitialWizardPages)/sizeof(InitialWizardPages[0]);
  976. }
  977. }
  978. }
  979. }
  980. #ifdef _OCM
  981. // for callbacks
  982. _CBx = OcManagerContext;
  983. // Get pages from OC Manager components.
  984. if(OcManagerContext) {
  985. Status = OcGetWizardPages(OcManagerContext,PagesFromOcManager);
  986. if(Status != NO_ERROR) {
  987. FatalError(MSG_LOG_WIZPAGES,0,0);
  988. }
  989. } else {
  990. ZeroMemory(PagesFromOcManager,sizeof(PagesFromOcManager));
  991. }
  992. #endif
  993. //
  994. // Create each page. Some of the pages are placeholders for external pages,
  995. // which are handled specially.
  996. //
  997. b = TRUE;
  998. PageCount = 0;
  999. for(i=0; b && (i<PagesInSet); i++) {
  1000. switch(PageOrdinal = PageList[i]) {
  1001. case WizPagePlaceholderNet:
  1002. //
  1003. // Fetch network pages.
  1004. //
  1005. MYASSERT(MAX_NETWIZ_PAGES <= MAXPROPPAGES);
  1006. NetPageCount = MAX_NETWIZ_PAGES;
  1007. if(GetNetworkWizardPages(&WizardPageHandles[PageCount],&NetPageCount)) {
  1008. PageCount += NetPageCount;
  1009. NetWizard = TRUE;
  1010. }
  1011. break;
  1012. case WizPagePlaceholderLic:
  1013. if( (ProductType != PRODUCT_WORKSTATION) ) {
  1014. //
  1015. // Fetch license pages.
  1016. //
  1017. MYASSERT(MAX_LICWIZ_PAGES <= MAXPROPPAGES);
  1018. LicPageCount = MAX_LICWIZ_PAGES;
  1019. if(GetLicenseWizardPages(&WizardPageHandles[PageCount],&LicPageCount)) {
  1020. PageCount += LicPageCount;
  1021. }
  1022. }
  1023. break;
  1024. case WizPagePreparing:
  1025. //
  1026. // We let the PnP engine run out of process
  1027. // and asynchronously for a MiniSetup case.
  1028. //
  1029. //
  1030. // If we're doing a mini Setup, then we ONLY do
  1031. // the preparing page if the user has asked us to
  1032. // do pnp enumeration.
  1033. //
  1034. if( MiniSetup && (PnPReEnumeration == FALSE)) {
  1035. break;
  1036. }
  1037. goto dodefault;
  1038. break;
  1039. case WizPageCopyFiles:
  1040. #ifdef _X86_
  1041. if (Win95Upgrade) {
  1042. SetupWizardPages[PageOrdinal].Page.pszTemplate = MAKEINTRESOURCE(IDD_COPYFILES4);
  1043. }
  1044. #endif
  1045. #ifdef _OCM
  1046. MYASSERT(OcManagerContext);
  1047. SetupWizardPages[PageOrdinal].Page.lParam = (LPARAM) OcManagerContext;
  1048. #endif
  1049. goto dodefault;
  1050. break;
  1051. #ifdef _OCM
  1052. case WizPageWelcome:
  1053. //
  1054. // If there's a welcome page from an OC Manager component
  1055. // then use it. Otherwise use the standard setup one.
  1056. //
  1057. if(!pOcManagerPages(PagesFromOcManager[WizPagesWelcome],WizardPageHandles,&PageCount)) {
  1058. goto dodefault;
  1059. }
  1060. break;
  1061. case WizPageLast:
  1062. //
  1063. // If there's a final page from an OC Manager component
  1064. // then use it. Otherwise use the standard setup one.
  1065. //
  1066. if(!pOcManagerPages(PagesFromOcManager[WizPagesFinal],WizardPageHandles,&PageCount)) {
  1067. goto dodefault;
  1068. }
  1069. break;
  1070. case WizPageOcManagerEarly:
  1071. pOcManagerPages(PagesFromOcManager[WizPagesEarly],WizardPageHandles,&PageCount);
  1072. break;
  1073. case WizPageOcManagerPrenet:
  1074. pOcManagerPages(PagesFromOcManager[WizPagesPrenet],WizardPageHandles,&PageCount);
  1075. break;
  1076. case WizPageOcManagerPostnet:
  1077. pOcManagerPages(PagesFromOcManager[WizPagesPostnet],WizardPageHandles,&PageCount);
  1078. break;
  1079. case WizPageOcManagerLate:
  1080. pOcManagerPages(PagesFromOcManager[WizPagesLate],WizardPageHandles,&PageCount);
  1081. break;
  1082. case WizPageOcManager:
  1083. if(OcManagerContext && OcSubComponentsPresent(OcManagerContext)) {
  1084. OcPageControls.TemplateModule = MyModuleHandle;
  1085. OcPageControls.TemplateResource = MAKEINTRESOURCE(IDD_OCM_WIZARD_PAGE);
  1086. OcPageControls.ListBox = IDC_LISTBOX;
  1087. OcPageControls.TipText = IDT_TIP;
  1088. OcPageControls.DetailsButton = IDB_DETAILS;
  1089. OcPageControls.ResetButton = 0; // unused
  1090. OcPageControls.InstalledCountText = 0; // unused
  1091. OcPageControls.SpaceNeededText = IDT_SPACE_NEEDED_NUM;
  1092. OcPageControls.SpaceAvailableText = IDT_SPACE_AVAIL_NUM;
  1093. OcPageControls.InstructionsText = IDT_INSTRUCTIONS;
  1094. OcPageControls.HeaderText = IDS_OCPAGE_HEADER;
  1095. OcPageControls.SubheaderText = IDS_OCPAGE_SUBHEAD;
  1096. OcPageControls.ComponentHeaderText = IDT_COMP_TITLE;
  1097. OcDetailsControls = OcPageControls;
  1098. OcDetailsControls.TemplateResource = MAKEINTRESOURCE(IDD_OCM_DETAILS);
  1099. WizardPageHandles[PageCount] = OcCreateOcPage(
  1100. OcManagerContext,
  1101. &OcPageControls,
  1102. &OcDetailsControls
  1103. );
  1104. if(WizardPageHandles[PageCount]) {
  1105. PageCount++;
  1106. } else {
  1107. b = FALSE;
  1108. }
  1109. }
  1110. break;
  1111. case WizPageOcManagerSetup:
  1112. if(OcManagerContext) {
  1113. OcSetupPageControls.TemplateModule = MyModuleHandle;
  1114. OcSetupPageControls.TemplateResource = MAKEINTRESOURCE(IDD_OCM_PROGRESS_PAGE);
  1115. OcSetupPageControls.ProgressBar = IDC_PROGRESS;
  1116. OcSetupPageControls.ProgressLabel = IDT_THERM_LABEL;
  1117. OcSetupPageControls.ProgressText = IDT_TIP;
  1118. OcSetupPageControls.AnimationControl = IDA_EXTERNAL_PROGRAM;
  1119. OcSetupPageControls.AnimationResource = IDA_FILECOPY;
  1120. OcSetupPageControls.ForceExternalProgressIndicator = FALSE;
  1121. OcSetupPageControls.AllowCancel = FALSE;
  1122. OcSetupPageControls.HeaderText = IDS_PROGPAGE_HEADER;
  1123. OcSetupPageControls.SubheaderText = IDS_PROGPAGE_SUBHEAD;
  1124. if(WizardPageHandles[PageCount] = OcCreateSetupPage(OcManagerContext,&OcSetupPageControls)) {
  1125. PageCount++;
  1126. } else {
  1127. b = FALSE;
  1128. }
  1129. }
  1130. break;
  1131. #endif
  1132. case WizPageComputerName:
  1133. if( GetProductFlavor() == 4)
  1134. {
  1135. // If Personal use a different template
  1136. SetupWizardPages[PageOrdinal].Page.pszTemplate = MAKEINTRESOURCE(IDD_COMPUTERNAME2);
  1137. }
  1138. goto dodefault;
  1139. break;
  1140. default:
  1141. dodefault:
  1142. {
  1143. UINT uiStrID;
  1144. SetupWizardPages[PageOrdinal].Page.hInstance = MyModuleHandle;
  1145. SetupWizardPages[PageOrdinal].Page.pszTitle = (PWSTR)UIntToPtr( SetupTitleStringId );
  1146. SetupWizardPages[PageOrdinal].Page.dwFlags |= PSP_USETITLE;
  1147. //
  1148. // Convert resource ids to actual strings for header title and subtitle,
  1149. // if required for this page.
  1150. //
  1151. if(SetupWizardPages[PageOrdinal].Page.dwFlags & PSP_USEHEADERTITLE) {
  1152. uiStrID = (UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderTitle);
  1153. if ((PageOrdinal == WizPageComputerName) &&
  1154. (GetProductFlavor() == 4))
  1155. {
  1156. uiStrID = IDS_COMPUTERNAME2;
  1157. }
  1158. SetupWizardPages[PageOrdinal].Page.pszHeaderTitle = MyLoadString(uiStrID
  1159. //(UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderTitle)
  1160. );
  1161. if(!SetupWizardPages[PageOrdinal].Page.pszHeaderTitle) {
  1162. SetupWizardPages[PageOrdinal].Page.dwFlags &= ~PSP_USEHEADERTITLE;
  1163. }
  1164. }
  1165. if(SetupWizardPages[PageOrdinal].Page.dwFlags & PSP_USEHEADERSUBTITLE) {
  1166. uiStrID = (UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle);
  1167. if ((PageOrdinal == WizPageComputerName) &&
  1168. (GetProductFlavor() == 4))
  1169. {
  1170. uiStrID = IDS_COMPUTERNAME2_SUB;
  1171. }
  1172. SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle = MyLoadString(uiStrID
  1173. //(UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle)
  1174. );
  1175. if(!SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle) {
  1176. SetupWizardPages[PageOrdinal].Page.dwFlags &= ~PSP_USEHEADERSUBTITLE;
  1177. }
  1178. }
  1179. WizardPageHandles[PageCount] = CreatePropertySheetPage(
  1180. &SetupWizardPages[PageOrdinal].Page
  1181. );
  1182. if(WizardPageHandles[PageCount]) {
  1183. PageCount++;
  1184. } else {
  1185. b = FALSE;
  1186. }
  1187. }
  1188. break;
  1189. }
  1190. }
  1191. if(b) {
  1192. psh.dwSize = sizeof(PROPSHEETHEADER);
  1193. psh.dwFlags = PSH_WIZARD | PSH_USECALLBACK | PSH_WIZARD97 |
  1194. PSH_HEADER;
  1195. // in order to have the watermark sized correctly for all languages,
  1196. // we must draw the bitmap ourselves rather than letting wiz97
  1197. // take care of it for us.
  1198. //PSH_WATERMARK | PSH_HEADER;
  1199. psh.hwndParent = MainWindowHandle;
  1200. psh.hInstance = MyModuleHandle;
  1201. psh.pszCaption = NULL;
  1202. psh.nPages = PageCount;
  1203. psh.nStartPage = 0;
  1204. psh.phpage = WizardPageHandles;
  1205. psh.pfnCallback = WizardCallback;
  1206. //psh.pszbmWatermark = MAKEINTRESOURCE(IDB_BITMAP1);
  1207. psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
  1208. Status = PropertySheet(&psh);
  1209. if (Status == -1) {
  1210. FatalError(MSG_LOG_WIZPAGES,0,0);
  1211. }
  1212. } else {
  1213. FatalError(MSG_LOG_WIZPAGES,0,0);
  1214. }
  1215. for (i = 0; i < WizPagesTypeMax ; i++) {
  1216. MyFree(PagesFromOcManager[i]);
  1217. }
  1218. return;
  1219. }
  1220. #ifdef _OCM
  1221. BOOL
  1222. pOcManagerPages(
  1223. IN PSETUP_REQUEST_PAGES Page,
  1224. OUT HPROPSHEETPAGE *WizardPageHandles,
  1225. IN OUT UINT *PageCount
  1226. )
  1227. {
  1228. BOOL b;
  1229. if(Page && Page->MaxPages) {
  1230. MYASSERT(WizardPageHandles && PageCount);
  1231. CopyMemory(
  1232. &WizardPageHandles[*PageCount],
  1233. Page->Pages,
  1234. Page->MaxPages * sizeof(HPROPSHEETPAGE)
  1235. );
  1236. *PageCount += Page->MaxPages;
  1237. b = TRUE;
  1238. } else {
  1239. b = FALSE;
  1240. }
  1241. return(b);
  1242. }
  1243. #endif
  1244. VOID
  1245. WizardUiTest(
  1246. VOID
  1247. )
  1248. {
  1249. UiTest = TRUE;
  1250. SyssetupInf = SetupOpenInfFile(L"syssetup.inf",NULL,INF_STYLE_WIN4,NULL);
  1251. MYASSERT(ARRAYSIZE(SourcePath) >= ARRAYSIZE(L"D:\\$WIN_NT$.LS"));
  1252. lstrcpy(SourcePath,L"D:\\$WIN_NT$.LS");
  1253. #ifdef _OCM
  1254. {
  1255. PVOID OcManagerContext = FireUpOcManager();
  1256. MYASSERT(OcManagerContext);
  1257. Wizard(OcManagerContext);
  1258. KillOcManager(OcManagerContext);
  1259. }
  1260. #else
  1261. Wizard();
  1262. #endif
  1263. SetupCloseInfFile(SyssetupInf);
  1264. }
  1265. DWORD GetPhase_InitializeEstimate ()
  1266. {
  1267. return TIME_INITIALIZE;
  1268. }
  1269. DWORD GetPhase_InstallSecurityEstimate ()
  1270. {
  1271. return TIME_INSTALLSECURITY;
  1272. }
  1273. DWORD GetPhase_PrecompileInfsEstimate ()
  1274. {
  1275. return TIME_PRECOMPILEINFS;
  1276. }
  1277. DWORD GetPhase_InstallDevicesEstimate ()
  1278. {
  1279. return TIME_INSTALLDEVICES;
  1280. }
  1281. DWORD GetPhase_InstallEnumDevices1Estimate ()
  1282. {
  1283. return TIME_INSTALLENUMDEVICES1;
  1284. }
  1285. DWORD GetPhase_InstallLegacyDevicesEstimate ()
  1286. {
  1287. return TIME_INSTALLLEGACYDEVICES;
  1288. }
  1289. DWORD GetPhase_InstallEnumDevices2Estimate ()
  1290. {
  1291. return TIME_INSTALLENUMDEVICES2;
  1292. }
  1293. DWORD GetPhase_NetInstallEstimate ()
  1294. {
  1295. return TIME_NETINSTALL;
  1296. }
  1297. DWORD GetPhase_OCInstallEstimate ()
  1298. {
  1299. return TIME_OCINSTALL;
  1300. }
  1301. DWORD GetPhase_InstallComponentInfsEstimate ()
  1302. {
  1303. return TIME_INSTALLCOMPONENTINFS;
  1304. }
  1305. DWORD GetPhase_Inf_RegistrationEstimate ()
  1306. {
  1307. return TIME_INF_REGISTRATION;
  1308. }
  1309. DWORD GetPhase_RunOnce_RegistrationEstimate ()
  1310. {
  1311. return TIME_RUNONCE_REGISTRATION;
  1312. }
  1313. DWORD GetPhase_SecurityTempatesEstimate ()
  1314. {
  1315. return TIME_SECURITYTEMPLATE;
  1316. }
  1317. LPTSTR WinRegisteries[] = { TEXT("system.dat"),
  1318. TEXT("User.dat"),
  1319. TEXT("classes.dat"),
  1320. TEXT("")};
  1321. DWORD GetPhase_Win9xMigrationEstimate ()
  1322. {
  1323. // Get the size of the registery,
  1324. // system.dat, user.dat and classes.dat(only exiss on Millennium)
  1325. // If the size if above 3MB, do the following
  1326. // Substract 3MB, devide by 9000 (that should give use the through put), and add 100 seconds
  1327. DWORD dwTime = TIME_WIN9XMIGRATION;
  1328. DWORD dwSize = 0;
  1329. TCHAR szRegPath[MAX_PATH];
  1330. TCHAR szRegName[MAX_PATH];
  1331. LPTSTR pRegName = NULL;
  1332. UINT index = 0;
  1333. HANDLE hFind;
  1334. WIN32_FIND_DATA FindData;
  1335. SetupDebugPrint(L"SETUP: Calculating registery size");
  1336. if (GetWindowsDirectory(szRegPath, MAX_PATH - ARRAYSIZE(L"Setup\\DefHives")))
  1337. {
  1338. pSetupConcatenatePaths (szRegPath, L"Setup\\DefHives", MAX_PATH, NULL);
  1339. while (*WinRegisteries[index])
  1340. {
  1341. lstrcpy(szRegName, szRegPath);
  1342. if(pSetupConcatenatePaths ( szRegName, WinRegisteries[index], MAX_PATH, NULL)){
  1343. hFind = FindFirstFile(szRegName, &FindData);
  1344. if (hFind != INVALID_HANDLE_VALUE)
  1345. {
  1346. SetupDebugPrint2(L"SETUP: %s size is: %2ld",
  1347. szRegName,
  1348. FindData.nFileSizeLow
  1349. );
  1350. // Don't worry about the nFileSizeHigh,
  1351. // if that is used the registery is over 4GB
  1352. dwSize += FindData.nFileSizeLow;
  1353. FindClose(hFind);
  1354. }
  1355. }
  1356. index++;
  1357. }
  1358. // Anything below 3.000.000 byte is already in the base time
  1359. if (dwSize > 3000000)
  1360. {
  1361. dwSize -= 3000000;
  1362. // Estimated that for about 9000 bytes we need 1 second.
  1363. dwTime += (dwSize/9000);
  1364. }
  1365. SetupDebugPrint1(L"SETUP: Calculated time for Win9x migration = %1ld seconds", dwTime);
  1366. }
  1367. return dwTime;
  1368. }
  1369. DWORD GetPhase_SFCEstimate ()
  1370. {
  1371. return TIME_SFC;
  1372. }
  1373. DWORD GetPhase_SaveRepairEstimate ()
  1374. {
  1375. return TIME_SAVEREPAIR;
  1376. }
  1377. DWORD GetPhase_RemoveTempFilesEstimate ()
  1378. {
  1379. return TIME_REMOVETEMOFILES;
  1380. }
  1381. void SetTimeEstimates()
  1382. {
  1383. SetupPhase[Phase_Initialize].Time = GetPhase_InitializeEstimate();
  1384. SetupPhase[Phase_InstallSecurity].Time = GetPhase_InstallSecurityEstimate();
  1385. SetupPhase[Phase_PrecompileInfs].Time = GetPhase_PrecompileInfsEstimate();
  1386. SetupPhase[Phase_InstallEnumDevices1].Time = GetPhase_InstallEnumDevices1Estimate();
  1387. SetupPhase[Phase_InstallLegacyDevices].Time = GetPhase_InstallLegacyDevicesEstimate();
  1388. SetupPhase[Phase_InstallEnumDevices2].Time = GetPhase_InstallEnumDevices2Estimate();
  1389. SetupPhase[Phase_OCInstall].Time = GetPhase_OCInstallEstimate();
  1390. SetupPhase[Phase_InstallComponentInfs].Time = GetPhase_InstallComponentInfsEstimate();
  1391. SetupPhase[Phase_Inf_Registration].Time = GetPhase_Inf_RegistrationEstimate();
  1392. SetupPhase[Phase_RunOnce_Registration].Time = GetPhase_RunOnce_RegistrationEstimate();
  1393. SetupPhase[Phase_SecurityTempates].Time = GetPhase_SecurityTempatesEstimate();
  1394. SetupPhase[Phase_Win9xMigration].Time = GetPhase_Win9xMigrationEstimate();
  1395. SetupPhase[Phase_SFC].Time = GetPhase_SFCEstimate();
  1396. SetupPhase[Phase_SaveRepair].Time = GetPhase_SaveRepairEstimate();
  1397. SetupPhase[Phase_RemoveTempFiles].Time = GetPhase_RemoveTempFilesEstimate();
  1398. }
  1399. // Returns the time remaining starting with the current "Phase"
  1400. DWORD CalcTimeRemaining(UINT Phase)
  1401. {
  1402. UINT i;
  1403. DWORD Time = 0;
  1404. CurrentPhase = Phase;
  1405. for (i = Phase; i < Phase_Reboot; i++)
  1406. {
  1407. // Is this a phase we always run or only when upgrading Win9x?
  1408. if (!SetupPhase[i].Win9xUpgradeOnly)
  1409. {
  1410. Time += SetupPhase[i].Time;
  1411. }
  1412. else if (Win95Upgrade)
  1413. {
  1414. Time += SetupPhase[i].Time;
  1415. }
  1416. }
  1417. return Time;
  1418. }
  1419. void SetRemainingTime(DWORD TimeInSeconds)
  1420. {
  1421. DWORD Minutes;
  1422. TCHAR MinuteString[MAX_PATH];
  1423. TCHAR TimeLeft[MAX_PATH];
  1424. int i;
  1425. Minutes = ((TimeInSeconds)/60) +1;
  1426. if (Minutes > 1)
  1427. {
  1428. if(!LoadString(MyModuleHandle, IDS_TIMEESTIMATE_MINUTES, MinuteString, ARRAYSIZE(MinuteString)))
  1429. {
  1430. lstrcpy(MinuteString, TEXT("Installation will complete in %d minutes or less."));
  1431. }
  1432. TimeLeft[0] = 0;
  1433. i = _sntprintf(TimeLeft, ARRAYSIZE(TimeLeft), MinuteString, Minutes);
  1434. TimeLeft[ARRAYSIZE(TimeLeft) - 1] = 0;
  1435. if( (i < 0) || (i == ARRAYSIZE(TimeLeft))) {
  1436. SetupDebugPrint(L"SETUP: SetRemainingTime: TimeLeft message truncated due to small buffer size");
  1437. }
  1438. }
  1439. else
  1440. {
  1441. if(!LoadString(MyModuleHandle,IDS_TIMEESTIMATE_LESSTHENONEMINUTE,TimeLeft, MAX_PATH))
  1442. {
  1443. lstrcpy(TimeLeft,TEXT("Installation will complete in less then 1 minute."));
  1444. }
  1445. }
  1446. BB_SetTimeEstimateText(TimeLeft);
  1447. }