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.

2371 lines
40 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. setupp.h
  5. Abstract:
  6. Private top-level header file for Windows NT Setup module.
  7. Author:
  8. Ted Miller (tedm) 11-Jan-1995
  9. Revision History:
  10. --*/
  11. //
  12. // System header files
  13. //
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <ntsam.h>
  18. #include <ntlsa.h>
  19. #include <ntdddisk.h>
  20. #include <ntapmsdk.h>
  21. #define OEMRESOURCE // setting this gets OBM_ constants in windows.h
  22. #include <windows.h>
  23. #include <winspool.h>
  24. #include <winsvcp.h>
  25. #include <ntdskreg.h>
  26. #include <ntddft.h>
  27. #include <ddeml.h>
  28. #include <commdlg.h>
  29. #include <commctrl.h>
  30. #include <setupapi.h>
  31. #include <spapip.h>
  32. #include <cfgmgr32.h>
  33. #include <objbase.h>
  34. #include <syssetup.h>
  35. #include <ntsetup.h>
  36. #include <userenv.h>
  37. #include <userenvp.h>
  38. #include <regstr.h>
  39. #include <setupbat.h>
  40. #include <shlobj.h>
  41. #include <shlwapi.h>
  42. #include <cryptui.h>
  43. #include <wincrypt.h>
  44. #include <dnsapi.h>
  45. #include <winnls.h>
  46. #include <encrypt.h>
  47. // For setting default power scheme
  48. #include <initguid.h>
  49. #include <poclass.h>
  50. #include <powrprofp.h>
  51. // For NetGetJoinInformation & NetApiBufferFree
  52. #include <lmjoin.h>
  53. #include <lmapibuf.h>
  54. // For EnableSR()
  55. #include <srrpcapi.h>
  56. #ifdef _WIN64
  57. #include <wow64reg.h>
  58. #endif
  59. //
  60. // CRT header files
  61. //
  62. #include <process.h>
  63. #include <wchar.h>
  64. #include <stddef.h>
  65. #include <stdlib.h>
  66. #include <stdio.h>
  67. #include <time.h>
  68. #include <limits.h>
  69. #ifdef UNICODE
  70. #define _UNICODE
  71. #endif
  72. #include <tchar.h>
  73. //
  74. // Private header files
  75. //
  76. #include "res.h"
  77. #include "msg.h"
  78. #include "helpids.h"
  79. #include "unattend.h"
  80. #include "sif.h"
  81. #include "watch.h"
  82. #include "userdiff.h"
  83. #include "setuplog.h"
  84. #include "pidgen.h"
  85. #include "mgdlllib.h"
  86. #include "dynupdt.h"
  87. #include <sfcapip.h>
  88. #include <sfcfiles.h>
  89. #include <excppkg.h>
  90. #include <mscat.h>
  91. #include <softpub.h>
  92. #if defined(_AMD64_)
  93. #include "amd64\spx86.h"
  94. #elif defined(_X86_)
  95. #include "i386\spx86.h"
  96. #endif
  97. //
  98. // Custom window messages.
  99. //
  100. #define WM_IAMVISIBLE (WM_APP + 0)
  101. #define WM_SIMULATENEXT (WM_APP + 1)
  102. #define WM_MY_PROGRESS (WM_APP + 2)
  103. #define WM_NEWBITMAP (WM_APP + 3)
  104. #define WM_MY_STATUS (WM_APP + 4)
  105. #define WMX_TERMINATE (WM_APP + 5)
  106. #define WMX_VALIDATE (WM_APP + 6)
  107. // Message used to end the main setup window.
  108. #define WM_EXIT_SETUPWINDOW (WM_APP + 7)
  109. // Billboard private messages
  110. #define WMX_SETPROGRESSTEXT (WM_APP + 8)
  111. #define WMX_BB_SETINFOTEXT (WM_APP + 9)
  112. #define WMX_BBPROGRESSGAUGE (WM_APP + 10)
  113. #define WMX_BBTEXT (WM_APP + 11)
  114. #define WMX_PROGRESSTICKS (WM_APP + 12)
  115. //
  116. // enum for use with WM_NEWBITMAP
  117. //
  118. typedef enum {
  119. SetupBmBackground,
  120. SetupBmLogo,
  121. SetupBmBanner // text, not a bitmap
  122. } SetupBm;
  123. //
  124. // Context for file queues in SysSetup
  125. //
  126. typedef struct _SYSSETUP_QUEUE_CONTEXT {
  127. PVOID DefaultContext;
  128. BOOL Skipped;
  129. } SYSSETUP_QUEUE_CONTEXT, *PSYSSETUP_QUEUE_CONTEXT;
  130. //
  131. // Context for migrating exception packages
  132. //
  133. typedef struct _EXCEPTION_MIGRATION_CONTEXT {
  134. PDWORD Count;
  135. HWND hWndProgress;
  136. BOOL AnyComponentFailed;
  137. } EXCEPTION_MIGRATION_CONTEXT, *PEXCEPTION_MIGRATION_CONTEXT;
  138. //
  139. // context for file registration in syssetup
  140. //
  141. typedef struct _REGISTRATION_CONTEXT {
  142. HWND hWndParent;
  143. HWND hWndProgress;
  144. } REGISTRATION_CONTEXT, *PREGISTRATION_CONTEXT;
  145. //
  146. // Constant for SETUPLDR. Use #ifdef since it has different names for
  147. // different architectures.
  148. //
  149. #ifdef _IA64_
  150. #define SETUPLDR L"SETUPLDR.EFI"
  151. #endif
  152. #ifdef _AMD64_
  153. #define SETUPLDR L"SETUPLDR"
  154. #endif
  155. //
  156. // Module handle for this module.
  157. //
  158. extern HANDLE MyModuleHandle;
  159. //
  160. // full path to this module
  161. //
  162. extern WCHAR MyModuleFileName[MAX_PATH];
  163. //
  164. // unattend answer table
  165. //
  166. extern UNATTENDANSWER UnattendAnswerTable[];
  167. #if DBG
  168. VOID
  169. AssertFail(
  170. IN PSTR FileName,
  171. IN UINT LineNumber,
  172. IN PSTR Condition
  173. );
  174. #define MYASSERT(x) if(!(x)) { AssertFail(__FILE__,__LINE__,#x); }
  175. #else
  176. #define MYASSERT(x)
  177. #endif
  178. //
  179. // Handle to heap so we can periodically validate it.
  180. //
  181. #if DBG
  182. extern HANDLE g_hSysSetupHeap;
  183. #define ASSERT_HEAP_IS_VALID() if (g_hSysSetupHeap) MYASSERT(RtlValidateHeap(g_hSysSetupHeap,0,NULL))
  184. #else
  185. #define ASSERT_HEAP_IS_VALID()
  186. #endif
  187. //
  188. // Product type being installed.
  189. //
  190. extern UINT ProductType;
  191. //
  192. // Boolean value indicating whether this installation
  193. // originated with winnt/winnt32.
  194. // And, original source path, saved away for us by winnt/winnt32.
  195. //
  196. extern BOOL WinntBased;
  197. extern PCWSTR OriginalSourcePath;
  198. //
  199. // Boolean value indicating whether this is a remote boot setup.
  200. //
  201. extern BOOL RemoteBootSetup;
  202. //
  203. // Mask indicating the "base" CopyStyle to use. Normally 0, this is set to
  204. // SP_COPY_SOURCE_SIS_MASTER during a remote boot setup to indicate that
  205. // the installation source and target reside on the same single-instance
  206. // storage volume.
  207. //
  208. extern ULONG BaseCopyStyle;
  209. //
  210. // Boolean value indicating whether we're upgrading.
  211. //
  212. extern BOOL Upgrade;
  213. extern BOOL Win31Upgrade;
  214. extern BOOL Win95Upgrade;
  215. extern BOOL UninstallEnabled;
  216. //
  217. // Boolean value indicating whether we're in Setup or in appwiz.
  218. //
  219. extern BOOL IsSetup;
  220. //
  221. // Boolean value indicating whether we're doing a subset of gui-mode setup.
  222. //
  223. extern BOOL MiniSetup;
  224. //
  225. // Boolean value indicating whether we're doing a subset of gui-mode setup.
  226. //
  227. extern BOOL OobeSetup;
  228. //
  229. // Boolean value indicating whether we're doing a subset of gui-mode setup
  230. // AND we did PnP re-enumeration.
  231. //
  232. extern BOOL PnPReEnumeration;
  233. //
  234. // Window handle of topmost setup window.
  235. //
  236. extern HWND SetupWindowHandle;
  237. extern HWND MainWindowHandle;
  238. extern HWND WizardHandle;
  239. extern HANDLE SetupWindowThreadHandle;
  240. //
  241. // Source path for installation.
  242. //
  243. extern WCHAR SourcePath[MAX_PATH];
  244. //
  245. // System setup inf.
  246. //
  247. extern HINF SyssetupInf;
  248. //
  249. // Flag indicating whether this is an unattended mode install/upgrade.
  250. //
  251. extern BOOL Unattended;
  252. //
  253. // We can get into unattended mode in several ways, so we also check whether
  254. // the "/unattend" switch was explicitly specified.
  255. //
  256. extern BOOL UnattendSwitch;
  257. //
  258. // Flag indicating whether we should run OOBE after Setup completes. Note
  259. // that if it is FALSE, OOBE may still be run, based on other criteria.
  260. //
  261. extern BOOL ForceRunOobe;
  262. //
  263. // Flag indicating whether we are in a special mode for OEM's to use on the
  264. // factory floor.
  265. //
  266. extern BOOL ReferenceMachine;
  267. //
  268. // Flag indicating whether a volume was extended or not using
  269. // ExtendOemPartition
  270. //
  271. extern BOOL PartitionExtended;
  272. //
  273. // Flag indicating if we're installing from a CD.
  274. //
  275. extern BOOL gInstallingFromCD;
  276. //
  277. // Cryptographically secure codesigning policies
  278. //
  279. extern DWORD PnpSeed;
  280. //
  281. // the original locale we started setup under.
  282. //
  283. extern LCID OriginalInstallLocale;
  284. //
  285. // Indicates whether we need to wait at the installation
  286. // end in unattended mode. Default is no wait.
  287. //
  288. extern BOOL UnattendWaitForReboot;
  289. //
  290. // If we are running unattended, the following mode indicates how answers
  291. // are used.
  292. //
  293. typedef enum _UNATTENDMODE {
  294. UAM_INVALID,
  295. UAM_GUIATTENDED,
  296. UAM_PROVIDEDEFAULT,
  297. UAM_DEFAULTHIDE,
  298. UAM_READONLY,
  299. UAM_FULLUNATTENDED,
  300. } UNATTENDMODE;
  301. extern UNATTENDMODE UnattendMode;
  302. //
  303. // Flags indicating whether any accessibility utilities are in use.
  304. //
  305. extern BOOL AccessibleSetup;
  306. extern BOOL Magnifier;
  307. extern BOOL ScreenReader;
  308. extern BOOL OnScreenKeyboard;
  309. //
  310. // String id of the string to be used for titles -- "Windows NT Setup"
  311. //
  312. extern UINT SetupTitleStringId;
  313. //
  314. // Platform name, like i386, ppc, alpha, mips
  315. //
  316. extern PCWSTR PlatformName;
  317. //
  318. // Maximum lengths for the various fields that form Pid 2.0
  319. //
  320. #define MAX_PID20_RPC 5
  321. #define MAX_PID20_SITE 3
  322. #define MAX_PID20_SERIAL_CHK 7
  323. #define MAX_PID20_RANDOM 5
  324. //
  325. // Maximum lengths for the pid 3.0 fields
  326. //
  327. #define MAX_PID30_EDIT 5
  328. #define MAX_PID30_RPC 5
  329. #define MAX_PID30_SITE 3
  330. extern WCHAR Pid30Text[5][MAX_PID30_EDIT+1];
  331. extern WCHAR Pid30Rpc[MAX_PID30_RPC+1];
  332. extern WCHAR Pid30Site[MAX_PID30_SITE+1];
  333. extern BYTE DigitalProductId[DIGITALPIDMAXLEN];
  334. //
  335. // Maximum product id length and the Product ID.
  336. //
  337. // 5 3 7 5 3 for the 3 dashes between the numbers.
  338. // MAX_PRODUCT_ID = MPC+SITE+SERIAL+RANDOM+3
  339. #define MAX_PRODUCT_ID MAX_PID20_RPC+MAX_PID20_SITE+MAX_PID20_SERIAL_CHK+MAX_PID20_RANDOM + 3
  340. extern WCHAR ProductId[MAX_PRODUCT_ID+1];
  341. extern WCHAR ProductId20FromProductId30[MAX_PRODUCT_ID+1];
  342. //
  343. // Maximum computer name length and the computer name.
  344. //
  345. extern WCHAR ComputerName[DNS_MAX_LABEL_LENGTH+1];
  346. extern WCHAR Win32ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
  347. extern BOOL IsNameTruncated;
  348. extern BOOL IsNameNonRfc;
  349. //
  350. // Copy disincentive name/organization strings.
  351. //
  352. #define MAX_NAMEORG_NAME 50
  353. #define MAX_NAMEORG_ORG 50
  354. extern WCHAR NameOrgName[MAX_NAMEORG_NAME+1];
  355. extern WCHAR NameOrgOrg[MAX_NAMEORG_ORG+1];
  356. //
  357. // User name and password
  358. //
  359. #define MAX_USERNAME 20
  360. #define MAX_PASSWORD 127
  361. extern WCHAR UserName[MAX_USERNAME+1];
  362. extern WCHAR UserPassword[MAX_PASSWORD+1];
  363. extern BOOL CreateUserAccount;
  364. //
  365. // Administrator password.
  366. extern WCHAR CurrentAdminPassword[MAX_PASSWORD+1];//
  367. extern WCHAR AdminPassword[MAX_PASSWORD+1];
  368. extern BOOL EncryptedAdminPasswordSet;
  369. extern BOOL DontChangeAdminPassword;
  370. #ifdef _X86_
  371. extern BOOL FlawedPentium;
  372. #endif
  373. //
  374. // This is a specification of optional directories
  375. // and/or optional user command to execute,
  376. // passed to us from text setup.
  377. //
  378. extern PWSTR OptionalDirSpec;
  379. extern PWSTR UserExecuteCmd;
  380. extern BOOL SkipMissingFiles;
  381. extern PWSTR IncludeCatalog;
  382. //
  383. // Custom, typical, laptop, minimal.
  384. //
  385. extern UINT SetupMode;
  386. //
  387. // boolean indicating if the eula was already shown during the winnt32 setup phase
  388. // this was passed to us from text setup. if the eula was shown, then the pid has
  389. // also been retreived from the user and validated
  390. extern BOOL EulaComplete;
  391. //
  392. // Flag indicating if the eula was already shown during the textmode setup phase
  393. // This will be the same as !Unattended unless UnattendMode = GuiAttended.
  394. //
  395. extern BOOL TextmodeEula;
  396. //
  397. // Global structure that contains information that will be used
  398. // by net setup and license setup. We pass a pointer to this structure when we
  399. // call NetSetupRequestWizardPages and LicenseSetupRequestWizardPages, then
  400. // fill it in before we call into the net setup wizard, or liccpa.
  401. //
  402. extern INTERNAL_SETUP_DATA InternalSetupData;
  403. //
  404. // Flags indicating whether the driver and non-driver signing policies came
  405. // from the answerfile. (If so, then those values are in effect throughout
  406. // GUI-mode setup and thereafter.)
  407. //
  408. extern BOOL AFDrvSignPolicySpecified;
  409. extern BOOL AFNonDrvSignPolicySpecified;
  410. //
  411. //
  412. // Did we log an error during SfcInitProt()?
  413. //
  414. extern BOOL SfcErrorOccurred;
  415. //
  416. // multi-sz list of files that is passed to SfcInitProt that the initial scan
  417. // will not replace. This is used for non-signed drivers that are specified
  418. // by F6 during textmode setup.
  419. //
  420. extern MULTISZ EnumPtrSfcIgnoreFiles;
  421. //
  422. // Parameters that are passed to the thread that drives the Finish dialog.
  423. //
  424. typedef struct _FINISH_THREAD_PARAMS {
  425. HWND hdlg;
  426. DWORD ThreadId;
  427. #ifdef _OCM
  428. PVOID OcManagerContext;
  429. #endif
  430. } FINISH_THREAD_PARAMS, *PFINISH_THREAD_PARAMS;
  431. DWORD
  432. FinishThread(
  433. PFINISH_THREAD_PARAMS Context
  434. );
  435. //
  436. // Miscellaneous stuff.
  437. //
  438. DWORD
  439. ApplySecurityToRepairInfo(
  440. );
  441. BOOL
  442. RestoreBootTimeout(
  443. VOID
  444. );
  445. VOID
  446. PrepareForNetSetup(
  447. VOID
  448. );
  449. VOID
  450. PrepareForNetUpgrade(
  451. VOID
  452. );
  453. VOID
  454. pSetInstallAttributes(
  455. VOID
  456. );
  457. DWORD
  458. TreeCopy(
  459. IN PCWSTR SourceDir,
  460. IN PCWSTR TargetDir
  461. );
  462. VOID
  463. DelSubNodes(
  464. IN PCWSTR Directory
  465. );
  466. VOID
  467. Delnode(
  468. IN PCWSTR Directory
  469. );
  470. BOOL
  471. InitializePidVariables(
  472. VOID
  473. );
  474. BOOL
  475. SetPid30Variables(
  476. PWSTR Buffer
  477. );
  478. BOOL
  479. ValidateCDRetailSite(
  480. IN PCWSTR PidString
  481. );
  482. BOOL
  483. ValidateSerialChk(
  484. IN PCWSTR PidString
  485. );
  486. BOOL
  487. ValidateOemRpc(
  488. IN PCWSTR PidString
  489. );
  490. BOOL
  491. ValidateOemSerialChk(
  492. IN PCWSTR PidString
  493. );
  494. BOOL
  495. ValidateOemRandom(
  496. IN PCWSTR PidString
  497. );
  498. BOOL
  499. ValidateAndSetPid30(
  500. VOID
  501. );
  502. BOOL
  503. CreateLicenseInfoKey(
  504. );
  505. BOOL
  506. InstallNetDDE(
  507. VOID
  508. );
  509. BOOL
  510. CopyOptionalDirectories(
  511. VOID
  512. );
  513. VOID
  514. SetUpProductTypeName(
  515. OUT PWSTR ProductTypeString,
  516. IN UINT BufferSizeChars
  517. );
  518. VOID
  519. RemoveHotfixData(
  520. VOID
  521. );
  522. void
  523. SetupCrashRecovery(
  524. VOID
  525. );
  526. BOOL
  527. SpSetupLoadParameter(
  528. IN PCWSTR Param,
  529. OUT PWSTR Answer,
  530. IN UINT AnswerBufLen
  531. );
  532. //
  533. // IsArc() is always true on non-x86 machines except AMD64 for which it is
  534. // always false. On x86, this determination has to be made at run time.
  535. //
  536. #if defined(_X86_)
  537. BOOL
  538. IsArc(
  539. VOID
  540. );
  541. #elif defined(_AMD64_)
  542. #define IsArc() FALSE
  543. #else
  544. #define IsArc() TRUE
  545. #endif
  546. //
  547. // IsEfi() is always true on IA64 machines. Therefore this determination can
  548. // be made at compile time. When x86 EFI machines are supported, the check
  549. // will need to be made at run time on x86.
  550. //
  551. // Note that EFI_NVRAM_ENABLED is defined in ia64\sources.
  552. //
  553. #if defined(EFI_NVRAM_ENABLED)
  554. #define IsEfi() TRUE
  555. #else
  556. #define IsEfi() FALSE
  557. #endif
  558. VOID
  559. DeleteLocalSource(
  560. VOID
  561. );
  562. BOOL
  563. ValidateAndChecksumFile(
  564. IN PCTSTR Filename,
  565. OUT PBOOLEAN IsNtImage,
  566. OUT PULONG Checksum,
  567. OUT PBOOLEAN Valid
  568. );
  569. HMODULE
  570. MyLoadLibraryWithSignatureCheck(
  571. IN PWSTR ModuleName
  572. );
  573. DWORD
  574. QueryHardDiskNumber(
  575. IN UCHAR DriveLetter
  576. );
  577. BOOL
  578. ExtendPartition(
  579. IN WCHAR DriveLetter,
  580. IN ULONG SizeMB OPTIONAL
  581. );
  582. DWORD
  583. RemoveStaleVolumes(
  584. VOID
  585. );
  586. BOOL
  587. DoFilesMatch(
  588. IN PCWSTR File1,
  589. IN PCWSTR File2
  590. );
  591. UINT
  592. MyGetDriveType(
  593. IN WCHAR Drive
  594. );
  595. BOOL
  596. GetPartitionInfo(
  597. IN WCHAR Drive,
  598. OUT PPARTITION_INFORMATION PartitionInfo
  599. );
  600. BOOL
  601. IsErrorLogEmpty (
  602. VOID
  603. );
  604. VOID
  605. BuildVolumeFreeSpaceList(
  606. OUT DWORD VolumeFreeSpaceMB[26]
  607. );
  608. BOOL
  609. SetUpVirtualMemory(
  610. VOID
  611. );
  612. BOOL
  613. RestoreVirtualMemoryInfo(
  614. VOID
  615. );
  616. BOOL
  617. CopySystemFiles(
  618. VOID
  619. );
  620. BOOL
  621. UpgradeSystemFiles(
  622. VOID
  623. );
  624. VOID
  625. MarkFilesReadOnly(
  626. VOID
  627. );
  628. VOID
  629. PumpMessageQueue(
  630. VOID
  631. );
  632. BOOL
  633. ConfigureMsDosSubsystem(
  634. VOID
  635. );
  636. BOOL
  637. PerfMergeCounterNames(
  638. VOID
  639. );
  640. DWORD
  641. pSetupInitRegionalSettings(
  642. IN HWND Window
  643. );
  644. VOID
  645. pSetupMarkHiddenFonts(
  646. VOID
  647. );
  648. VOID
  649. InstallServerNLSFiles(
  650. );
  651. PVOID
  652. InitSysSetupQueueCallbackEx(
  653. IN HWND OwnerWindow,
  654. IN HWND AlternateProgressWindow, OPTIONAL
  655. IN UINT ProgressMessage,
  656. IN DWORD Reserved1,
  657. IN PVOID Reserved2
  658. );
  659. PVOID
  660. InitSysSetupQueueCallback(
  661. IN HWND OwnerWindow
  662. );
  663. VOID
  664. TermSysSetupQueueCallback(
  665. IN PVOID SysSetupContext
  666. );
  667. UINT
  668. SysSetupQueueCallback(
  669. IN PVOID Context,
  670. IN UINT Notification,
  671. IN UINT_PTR Param1,
  672. IN UINT_PTR Param2
  673. );
  674. UINT
  675. RegistrationQueueCallback(
  676. IN PVOID Context,
  677. IN UINT Notification,
  678. IN UINT_PTR Param1,
  679. IN UINT_PTR Param2
  680. );
  681. VOID
  682. SaveRepairInfo(
  683. IN HWND hWnd,
  684. IN ULONG StartAtPercent,
  685. IN ULONG StopAtPercent
  686. );
  687. BOOLEAN
  688. IsLaptop(
  689. VOID
  690. );
  691. VOID
  692. InitializeUniqueness(
  693. IN OUT HWND *Billboard
  694. );
  695. #ifdef _X86_
  696. //
  697. // Code in i386\migwin95.c
  698. //
  699. BOOL
  700. PreWin9xMigration(
  701. VOID
  702. );
  703. BOOL
  704. MigrateWin95Settings(
  705. IN HWND hwndWizardParent,
  706. IN LPCWSTR UnattendFile
  707. );
  708. BOOL
  709. Win95MigrationFileRemoval(
  710. void
  711. );
  712. BOOL
  713. RemoveFiles_X86(
  714. IN HINF InfHandle
  715. );
  716. #endif // def _X86_
  717. BOOL
  718. RegisterActionItemListControl(
  719. IN BOOL Init
  720. );
  721. LONG
  722. WINAPI
  723. MyUnhandledExceptionFilter(
  724. IN struct _EXCEPTION_POINTERS *ExceptionInfo
  725. );
  726. #ifdef _OCM
  727. PVOID
  728. #else
  729. VOID
  730. #endif
  731. CommonInitialization(
  732. VOID
  733. );
  734. VOID
  735. InitializeExternalModules(
  736. BOOL DoSetupStuff,
  737. PVOID* pOcManagerContext
  738. );
  739. BOOL
  740. pSetupWaitForScmInitialization();
  741. VOID
  742. SetUpDataBlock(
  743. VOID
  744. );
  745. //
  746. // Wizard control.
  747. //
  748. VOID
  749. Wizard(
  750. #ifdef _OCM
  751. IN PVOID OcManagerContext
  752. #else
  753. VOID
  754. #endif
  755. );
  756. //
  757. // IMPORTANT: keep this in sync with WIZPAGE SetupWizardPages[WizPageMaximum]
  758. //
  759. typedef enum {
  760. WizPageWelcome,
  761. WizPageEula,
  762. WizPagePreparing,
  763. WizPagePreparingAsr,
  764. #ifdef PNP_DEBUG_UI
  765. WizPageInstalledHardware,
  766. #endif // PNP_DEBUG_UI
  767. WizPageRegionalSettings,
  768. WizPageNameOrg,
  769. WizPageProductIdCd,
  770. WizPageProductIdOem,
  771. WizPageProductIdSelect,
  772. WizPageComputerName,
  773. #ifdef DOLOCALUSER
  774. WizPageUserAccount,
  775. #endif
  776. #ifdef _X86_
  777. WizPagePentiumErrata,
  778. #endif // def _X86_
  779. WizPageSteps1,
  780. WizSetupPreNet,
  781. WizSetupPostNet,
  782. WizPageCopyFiles,
  783. WizPageAsrLast,
  784. WizPageLast,
  785. WizPageMaximum
  786. } WizPage;
  787. extern HPROPSHEETPAGE WizardPageHandles[WizPageMaximum];
  788. extern BOOL UiTest;
  789. VOID
  790. SetWizardButtons(
  791. IN HWND hdlgPage,
  792. IN WizPage PageNumber
  793. );
  794. VOID
  795. WizardBringUpHelp(
  796. IN HWND hdlg,
  797. IN WizPage PageNumber
  798. );
  799. VOID
  800. WizardKillHelp(
  801. IN HWND hdlg
  802. );
  803. //
  804. // Dialog procs.
  805. //
  806. INT_PTR
  807. CALLBACK
  808. WelcomeDlgProc(
  809. IN HWND hdlg,
  810. IN UINT msg,
  811. IN WPARAM wParam,
  812. IN LPARAM lParam
  813. );
  814. INT_PTR
  815. CALLBACK
  816. EulaDlgProc(
  817. IN HWND hdlg,
  818. IN UINT msg,
  819. IN WPARAM wParam,
  820. IN LPARAM lParam
  821. );
  822. INT_PTR
  823. CALLBACK
  824. StepsDlgProc(
  825. IN HWND hdlg,
  826. IN UINT msg,
  827. IN WPARAM wParam,
  828. IN LPARAM lParam
  829. );
  830. INT_PTR
  831. CALLBACK
  832. PreparingDlgProc(
  833. IN HWND hdlg,
  834. IN UINT msg,
  835. IN WPARAM wParam,
  836. IN LPARAM lParam
  837. );
  838. INT_PTR
  839. CALLBACK
  840. InstalledHardwareDlgProc(
  841. IN HWND hdlg,
  842. IN UINT msg,
  843. IN WPARAM wParam,
  844. IN LPARAM lParam
  845. );
  846. INT_PTR
  847. SetupModeDlgProc(
  848. IN HWND hdlg,
  849. IN UINT msg,
  850. IN WPARAM wParam,
  851. IN LPARAM lParam
  852. );
  853. INT_PTR
  854. CALLBACK
  855. RegionalSettingsDlgProc(
  856. IN HWND hdlg,
  857. IN UINT msg,
  858. IN WPARAM wParam,
  859. IN LPARAM lParam
  860. );
  861. INT_PTR
  862. CALLBACK
  863. NameOrgDlgProc(
  864. IN HWND hdlg,
  865. IN UINT msg,
  866. IN WPARAM wParam,
  867. IN LPARAM lParam
  868. );
  869. INT_PTR
  870. CALLBACK
  871. LicensingDlgProc(
  872. IN HWND hdlg,
  873. IN UINT msg,
  874. IN WPARAM wParam,
  875. IN LPARAM lParam
  876. );
  877. INT_PTR
  878. CALLBACK
  879. ComputerNameDlgProc(
  880. IN HWND hdlg,
  881. IN UINT msg,
  882. IN WPARAM wParam,
  883. IN LPARAM lParam
  884. );
  885. INT_PTR
  886. CALLBACK
  887. PidCDDlgProc(
  888. IN HWND hdlg,
  889. IN UINT msg,
  890. IN WPARAM wParam,
  891. IN LPARAM lParam
  892. );
  893. INT_PTR
  894. CALLBACK
  895. Pid30OemDlgProc(
  896. IN HWND hdlg,
  897. IN UINT msg,
  898. IN WPARAM wParam,
  899. IN LPARAM lParam
  900. );
  901. INT_PTR
  902. CALLBACK
  903. Pid30CDDlgProc(
  904. IN HWND hdlg,
  905. IN UINT msg,
  906. IN WPARAM wParam,
  907. IN LPARAM lParam
  908. );
  909. INT_PTR
  910. CALLBACK
  911. Pid30SelectDlgProc(
  912. IN HWND hdlg,
  913. IN UINT msg,
  914. IN WPARAM wParam,
  915. IN LPARAM lParam
  916. );
  917. INT_PTR
  918. CALLBACK
  919. PidOemDlgProc(
  920. IN HWND hdlg,
  921. IN UINT msg,
  922. IN WPARAM wParam,
  923. IN LPARAM lParam
  924. );
  925. #ifdef DOLOCALUSER
  926. INT_PTR
  927. CALLBACK
  928. UserAccountDlgProc(
  929. IN HWND hdlg,
  930. IN UINT msg,
  931. IN WPARAM wParam,
  932. IN LPARAM lParam
  933. );
  934. #endif
  935. INT_PTR
  936. CALLBACK
  937. OptionalComponentsPageDlgProc(
  938. IN HWND hwnd,
  939. IN UINT msg,
  940. IN WPARAM wParam,
  941. IN LPARAM lParam
  942. );
  943. INT_PTR
  944. CALLBACK
  945. RepairDiskDlgProc(
  946. IN HWND hdlg,
  947. IN UINT msg,
  948. IN WPARAM wParam,
  949. IN LPARAM lParam
  950. );
  951. INT_PTR
  952. CALLBACK
  953. CopyFilesDlgProc(
  954. IN HWND hdlg,
  955. IN UINT msg,
  956. IN WPARAM wParam,
  957. IN LPARAM lParam
  958. );
  959. INT_PTR
  960. CALLBACK
  961. LastPageDlgProc(
  962. IN HWND hdlg,
  963. IN UINT msg,
  964. IN WPARAM wParam,
  965. IN LPARAM lParam
  966. );
  967. INT_PTR
  968. DoneDlgProc(
  969. IN HWND hdlg,
  970. IN UINT msg,
  971. IN WPARAM wParam,
  972. IN LPARAM lParam
  973. );
  974. INT_PTR
  975. CALLBACK
  976. SetupPreNetDlgProc(
  977. IN HWND hdlg,
  978. IN UINT msg,
  979. IN WPARAM wParam,
  980. IN LPARAM lParam
  981. );
  982. INT_PTR
  983. CALLBACK
  984. SetupPostNetDlgProc(
  985. IN HWND hdlg,
  986. IN UINT msg,
  987. IN WPARAM wParam,
  988. IN LPARAM lParam
  989. );
  990. //
  991. // Billboard stuff.
  992. //
  993. HWND
  994. DisplayBillboard(
  995. IN HWND Owner,
  996. IN UINT MessageId,
  997. ...
  998. );
  999. VOID
  1000. KillBillboard(
  1001. IN HWND BillboardWindowHandle
  1002. );
  1003. //
  1004. // Message string routines
  1005. //
  1006. PWSTR
  1007. MyLoadString(
  1008. IN UINT StringId
  1009. );
  1010. PWSTR
  1011. FormatStringMessageV(
  1012. IN UINT FormatStringId,
  1013. IN va_list *ArgumentList
  1014. );
  1015. PWSTR
  1016. FormatStringMessage(
  1017. IN UINT FormatStringId,
  1018. ...
  1019. );
  1020. PWSTR
  1021. RetrieveAndFormatMessageV(
  1022. IN PCWSTR MessageString,
  1023. IN UINT MessageId, OPTIONAL
  1024. IN va_list *ArgumentList
  1025. );
  1026. PWSTR
  1027. RetrieveAndFormatMessage(
  1028. IN PCWSTR MessageString,
  1029. IN UINT MessageId, OPTIONAL
  1030. ...
  1031. );
  1032. int
  1033. MessageBoxFromMessageExV (
  1034. IN HWND Owner, OPTIONAL
  1035. IN LogSeverity Severity, OPTIONAL
  1036. IN PCWSTR MessageString,
  1037. IN UINT MessageId, OPTIONAL
  1038. IN PCWSTR Caption, OPTIONAL
  1039. IN UINT CaptionStringId, OPTIONAL
  1040. IN UINT Style,
  1041. IN va_list ArgumentList
  1042. );
  1043. int
  1044. MessageBoxFromMessageEx (
  1045. IN HWND Owner, OPTIONAL
  1046. IN LogSeverity Severity, OPTIONAL
  1047. IN PCWSTR MessageString,
  1048. IN UINT MessageId, OPTIONAL
  1049. IN PCWSTR Caption, OPTIONAL
  1050. IN UINT CaptionStringId, OPTIONAL
  1051. IN UINT Style,
  1052. ...
  1053. );
  1054. int
  1055. MessageBoxFromMessage(
  1056. IN HWND Owner, OPTIONAL
  1057. IN UINT MessageId,
  1058. IN PCWSTR Caption, OPTIONAL
  1059. IN UINT CaptionStringId, OPTIONAL
  1060. IN UINT Style,
  1061. ...
  1062. );
  1063. //
  1064. // Action-logging routines.
  1065. //
  1066. extern PCWSTR ActionLogFileName;
  1067. VOID
  1068. InitializeSetupLog(
  1069. IN PSETUPLOG_CONTEXT Context
  1070. );
  1071. VOID
  1072. TerminateSetupLog(
  1073. IN PSETUPLOG_CONTEXT Context
  1074. );
  1075. VOID
  1076. LogRepairInfo(
  1077. IN PCWSTR Source,
  1078. IN PCWSTR Target
  1079. );
  1080. VOID
  1081. FatalError(
  1082. IN UINT MessageId,
  1083. ...
  1084. );
  1085. BOOL
  1086. InitializeSetupActionLog(
  1087. BOOL WipeLogFile
  1088. );
  1089. VOID
  1090. TerminateSetupActionLog(
  1091. VOID
  1092. );
  1093. BOOL
  1094. LogItem(
  1095. IN LogSeverity Severity,
  1096. IN PCWSTR Description
  1097. );
  1098. BOOL
  1099. LogItem0(
  1100. IN LogSeverity Severity,
  1101. IN UINT MessageId,
  1102. ...
  1103. );
  1104. BOOL
  1105. LogItem1(
  1106. IN LogSeverity Severity,
  1107. IN UINT MajorMsgId,
  1108. IN UINT MinorMsgId,
  1109. ...
  1110. );
  1111. BOOL
  1112. LogItem2(
  1113. IN LogSeverity Severity,
  1114. IN UINT MajorMsgId,
  1115. IN PCWSTR MajorMsgParam,
  1116. IN UINT MinorMsgId,
  1117. ...
  1118. );
  1119. BOOL
  1120. LogItem3(
  1121. IN LogSeverity Severity,
  1122. IN UINT MajorMsgId,
  1123. IN PCWSTR MajorMsgParam1,
  1124. IN PCWSTR MajorMsgParam2,
  1125. IN UINT MinorMsgId,
  1126. ...
  1127. );
  1128. PCWSTR
  1129. FormatSetupMessageV (
  1130. IN UINT MessageId,
  1131. IN va_list ArgumentList
  1132. );
  1133. BOOL
  1134. LogItemV (
  1135. IN LogSeverity Severity,
  1136. IN va_list ArgumentList
  1137. );
  1138. LogItemN (
  1139. IN LogSeverity Severity,
  1140. ...
  1141. );
  1142. BOOL
  1143. ViewSetupActionLog(
  1144. IN HWND hOwnerWindow,
  1145. IN PCWSTR OptionalFileName OPTIONAL,
  1146. IN PCWSTR OptionalHeading OPTIONAL
  1147. );
  1148. //
  1149. // Constant strings used for logging in various places.
  1150. //
  1151. extern PCWSTR szFALSE;
  1152. extern PCWSTR szWaitForSingleObject;
  1153. extern PCWSTR szSetGroupOfValues;
  1154. extern PCWSTR szSetArrayToMultiSzValue;
  1155. extern PCWSTR szCreateProcess;
  1156. extern PCWSTR szRegOpenKeyEx;
  1157. extern PCWSTR szRegQueryValueEx;
  1158. extern PCWSTR szRegSetValueEx;
  1159. extern PCWSTR szDeleteFile;
  1160. extern PCWSTR szRemoveDirectory;
  1161. extern PCWSTR szOpenSCManager;
  1162. extern PCWSTR szCreateService;
  1163. extern PCWSTR szChangeServiceConfig;
  1164. extern PCWSTR szOpenService;
  1165. extern PCWSTR szStartService;
  1166. extern PCWSTR szSetupInstallFromInfSection;
  1167. //
  1168. // ARC routines.
  1169. //
  1170. PWSTR
  1171. ArcDevicePathToNtPath(
  1172. IN PCWSTR ArcPath
  1173. );
  1174. PWSTR
  1175. NtFullPathToDosPath(
  1176. IN PCWSTR NtPath
  1177. );
  1178. BOOL
  1179. ChangeBootTimeout(
  1180. IN UINT Timeout
  1181. );
  1182. BOOL
  1183. SetNvRamVariable(
  1184. IN PCWSTR VarName,
  1185. IN PCWSTR VarValue
  1186. );
  1187. PWSTR
  1188. NtPathToDosPath(
  1189. IN PCWSTR NtPath
  1190. );
  1191. //
  1192. // Progman/program group stuff
  1193. //
  1194. BOOL
  1195. CreateStartMenuItems(
  1196. IN HINF InfHandle
  1197. );
  1198. BOOL
  1199. UpgradeStartMenuItems(
  1200. IN HINF InfHandle
  1201. );
  1202. //
  1203. // Cryptography stuff
  1204. //
  1205. BOOL
  1206. InstallOrUpgradeCapi(
  1207. VOID
  1208. );
  1209. //
  1210. // Plug&Play initialization
  1211. //
  1212. HANDLE
  1213. SpawnPnPInitialization(
  1214. VOID
  1215. );
  1216. DWORD
  1217. PnPInitializationThread(
  1218. IN PVOID ThreadParam
  1219. );
  1220. //
  1221. // Printer/spooler routines
  1222. //
  1223. BOOL
  1224. MiscSpoolerInit(
  1225. VOID
  1226. );
  1227. BOOL
  1228. StartSpooler(
  1229. VOID
  1230. );
  1231. DWORD
  1232. UpgradePrinters(
  1233. VOID
  1234. );
  1235. //
  1236. // Name of spooler service.
  1237. //
  1238. extern PCWSTR szSpooler;
  1239. //
  1240. // Service control.
  1241. //
  1242. BOOL
  1243. MyCreateService(
  1244. IN PCWSTR ServiceName,
  1245. IN PCWSTR DisplayName, OPTIONAL
  1246. IN DWORD ServiceType,
  1247. IN DWORD StartType,
  1248. IN DWORD ErrorControl,
  1249. IN PCWSTR BinaryPathName,
  1250. IN PCWSTR LoadOrderGroup, OPTIONAL
  1251. IN PWCHAR DependencyList,
  1252. IN PCWSTR ServiceStartName, OPTIONAL
  1253. IN PCWSTR Password OPTIONAL
  1254. );
  1255. BOOL
  1256. MyChangeServiceConfig(
  1257. IN PCWSTR ServiceName,
  1258. IN DWORD ServiceType,
  1259. IN DWORD StartType,
  1260. IN DWORD ErrorControl,
  1261. IN PCWSTR BinaryPathName, OPTIONAL
  1262. IN PCWSTR LoadOrderGroup, OPTIONAL
  1263. IN PWCHAR DependencyList,
  1264. IN PCWSTR ServiceStartName, OPTIONAL
  1265. IN PCWSTR Password, OPTIONAL
  1266. IN PCWSTR DisplayName OPTIONAL
  1267. );
  1268. BOOL
  1269. MyChangeServiceStart(
  1270. IN PCWSTR ServiceName,
  1271. IN DWORD StartType
  1272. );
  1273. BOOL
  1274. UpdateServicesDependencies(
  1275. IN HINF InfHandle
  1276. );
  1277. //
  1278. // Registry manipulation
  1279. //
  1280. typedef struct _REGVALITEM {
  1281. PCWSTR Name;
  1282. PVOID Data;
  1283. DWORD Size;
  1284. DWORD Type;
  1285. } REGVALITEM, *PREGVALITEM;
  1286. //
  1287. // Names of frequently used keys/values
  1288. //
  1289. extern PCWSTR SessionManagerKeyName;
  1290. extern PCWSTR EnvironmentKeyName;
  1291. extern PCWSTR szBootExecute;
  1292. extern PCWSTR WinntSoftwareKeyName;
  1293. extern PCWSTR szRegisteredOwner;
  1294. extern PCWSTR szRegisteredOrganization;
  1295. UINT
  1296. SetGroupOfValues(
  1297. IN HKEY RootKey,
  1298. IN PCWSTR SubkeyName,
  1299. IN PREGVALITEM ValueList,
  1300. IN UINT ValueCount
  1301. );
  1302. BOOL
  1303. CreateWindowsNtSoftwareEntry(
  1304. IN BOOL FirstPass
  1305. );
  1306. BOOL
  1307. CreateInstallDateEntry(
  1308. );
  1309. BOOL
  1310. StoreNameOrgInRegistry(
  1311. PWSTR NameOrgName,
  1312. PWSTR NameOrgOrg
  1313. );
  1314. BOOL
  1315. SetUpEvaluationSKUStuff(
  1316. VOID
  1317. );
  1318. BOOL
  1319. SetEnabledProcessorCount(
  1320. VOID
  1321. );
  1322. BOOL
  1323. SetProductIdInRegistry(
  1324. VOID
  1325. );
  1326. DWORD
  1327. SetCurrentProductIdInRegistry(
  1328. VOID
  1329. );
  1330. VOID
  1331. DeleteCurrentProductIdInRegistry(
  1332. VOID
  1333. );
  1334. void LogPidValues();
  1335. BOOL
  1336. SetAutoAdminLogonInRegistry(
  1337. LPWSTR Username,
  1338. LPWSTR Password
  1339. );
  1340. BOOL
  1341. SetProfilesDirInRegistry(
  1342. LPWSTR ProfilesDir
  1343. );
  1344. BOOL
  1345. SetProductTypeInRegistry(
  1346. VOID
  1347. );
  1348. BOOL
  1349. SetEnvironmentVariableInRegistry(
  1350. IN PCWSTR Name,
  1351. IN PCWSTR Value,
  1352. IN BOOL SystemWide
  1353. );
  1354. BOOL
  1355. SaveHive(
  1356. IN HKEY RootKey,
  1357. IN PCWSTR Subkey,
  1358. IN PCWSTR Filename,
  1359. IN DWORD Format
  1360. );
  1361. BOOL
  1362. SaveAndReplaceSystemHives(
  1363. VOID
  1364. );
  1365. DWORD
  1366. FixupUserHives(
  1367. VOID
  1368. );
  1369. DWORD
  1370. QueryValueInHKLM (
  1371. IN PWCH KeyName OPTIONAL,
  1372. IN PWCH ValueName,
  1373. OUT PDWORD ValueType,
  1374. OUT PVOID *ValueData,
  1375. OUT PDWORD ValueDataLength
  1376. );
  1377. VOID
  1378. ConfigureSystemFileProtection(
  1379. VOID
  1380. );
  1381. VOID
  1382. RemoveRestartability (
  1383. HWND hProgress
  1384. );
  1385. BOOL
  1386. ResetSetupInProgress(
  1387. VOID
  1388. );
  1389. BOOL
  1390. RemoveRestartStuff(
  1391. VOID
  1392. );
  1393. BOOL
  1394. EnableEventlogPopup(
  1395. VOID
  1396. );
  1397. BOOL
  1398. MakeWowEntry(
  1399. VOID
  1400. );
  1401. BOOL
  1402. SetUpPath(
  1403. VOID
  1404. );
  1405. VOID
  1406. RestoreOldPathVariable(
  1407. VOID
  1408. );
  1409. BOOL
  1410. FixQuotaEntries(
  1411. VOID
  1412. );
  1413. BOOL
  1414. StampBuildNumber(
  1415. VOID
  1416. );
  1417. BOOL
  1418. SetProgramFilesDirInRegistry(
  1419. VOID
  1420. );
  1421. BOOL
  1422. RegisterOleControls(
  1423. IN HWND hwndParent,
  1424. IN PVOID InfHandle,
  1425. IN HWND hProgress,
  1426. IN ULONG StartAtPercent,
  1427. IN ULONG StopAtPercent,
  1428. IN PWSTR SectionName
  1429. );
  1430. VOID
  1431. InitializeCodeSigningPolicies(
  1432. IN BOOL ForGuiSetup
  1433. );
  1434. VOID
  1435. GetDllCacheFolder(
  1436. OUT LPWSTR CacheDir,
  1437. IN DWORD cbCacheDir
  1438. );
  1439. typedef enum _CODESIGNING_POLICY_TYPE {
  1440. PolicyTypeDriverSigning,
  1441. PolicyTypeNonDriverSigning
  1442. } CODESIGNING_POLICY_TYPE, *PCODESIGNING_POLICY_TYPE;
  1443. VOID
  1444. SetCodeSigningPolicy(
  1445. IN CODESIGNING_POLICY_TYPE PolicyType,
  1446. IN BYTE NewPolicy,
  1447. OUT PBYTE OldPolicy OPTIONAL
  1448. );
  1449. DWORD
  1450. GetSeed(
  1451. VOID
  1452. );
  1453. //
  1454. // Ini file routines.
  1455. //
  1456. BOOL
  1457. ReplaceIniKeyValue(
  1458. IN PCWSTR IniFile,
  1459. IN PCWSTR Section,
  1460. IN PCWSTR Key,
  1461. IN PCWSTR Value
  1462. );
  1463. BOOL
  1464. WinIniAlter1(
  1465. VOID
  1466. );
  1467. BOOL
  1468. SetDefaultWallpaper(
  1469. VOID
  1470. );
  1471. BOOL
  1472. SetShutdownVariables(
  1473. VOID
  1474. );
  1475. BOOL
  1476. SetLogonScreensaver(
  1477. VOID
  1478. );
  1479. BOOL
  1480. InstallOrUpgradeFonts(
  1481. VOID
  1482. );
  1483. //
  1484. // External app stuff.
  1485. //
  1486. BOOL
  1487. InvokeExternalApplication(
  1488. IN PCWSTR ApplicationName, OPTIONAL
  1489. IN PCWSTR CommandLine,
  1490. IN OUT PDWORD ExitCode OPTIONAL
  1491. );
  1492. BOOL
  1493. InvokeControlPanelApplet(
  1494. IN PCWSTR CplSpec,
  1495. IN PCWSTR AppletName, OPTIONAL
  1496. IN UINT AppletNameStringId,
  1497. IN PCWSTR CommandLine
  1498. );
  1499. //
  1500. // Security/account routines.
  1501. //
  1502. BOOL
  1503. SignalLsa(
  1504. VOID
  1505. );
  1506. BOOL
  1507. CreateSamEvent(
  1508. VOID
  1509. );
  1510. BOOL
  1511. WaitForSam(
  1512. VOID
  1513. );
  1514. BOOL
  1515. SetAccountsDomainSid(
  1516. IN DWORD Seed,
  1517. IN PCWSTR DomainName
  1518. );
  1519. BOOL
  1520. CreateLocalUserAccount(
  1521. IN PCWSTR UserName,
  1522. IN PCWSTR Password,
  1523. OUT PSID* UserSid OPTIONAL
  1524. );
  1525. NTSTATUS
  1526. CreateLocalAdminAccount(
  1527. IN PCWSTR UserName,
  1528. IN PCWSTR Password,
  1529. OUT PSID* UserSid OPTIONAL
  1530. );
  1531. BOOL
  1532. SetLocalUserPassword(
  1533. IN PCWSTR AccountName,
  1534. IN PCWSTR OldPassword,
  1535. IN PCWSTR NewPassword
  1536. );
  1537. BOOL
  1538. IsEncryptedAdminPasswordPresent( VOID );
  1539. BOOL
  1540. ProcessEncryptedAdminPassword( PCWSTR AdminAccountName );
  1541. BOOL
  1542. CreatePdcAccount(
  1543. IN PCWSTR MachineName
  1544. );
  1545. BOOL
  1546. AdjustPrivilege(
  1547. IN PCWSTR Privilege,
  1548. IN BOOL Enable
  1549. );
  1550. UINT
  1551. PlatformSpecificInit(
  1552. VOID
  1553. );
  1554. //
  1555. // Interface to new style parameter operations
  1556. //
  1557. BOOL
  1558. SpSetupProcessParameters(
  1559. IN OUT HWND *Billboard
  1560. );
  1561. extern WCHAR LegacySourcePath[MAX_PATH];
  1562. HWND
  1563. CreateSetupWindow(
  1564. VOID
  1565. );
  1566. //
  1567. // Preinstallation stuff
  1568. //
  1569. extern BOOL Preinstall;
  1570. extern BOOL AllowRollback;
  1571. extern BOOL OemSkipEula;
  1572. BOOL
  1573. InitializePreinstall(
  1574. VOID
  1575. );
  1576. BOOL
  1577. ExecutePreinstallCommands(
  1578. VOID
  1579. );
  1580. BOOL
  1581. DoInstallComponentInfs(
  1582. IN HWND hwndParent,
  1583. IN HWND hProgress, OPTIONAL
  1584. IN UINT ProgressMessage,
  1585. IN HINF InfHandle,
  1586. IN PCWSTR InfSection
  1587. );
  1588. BOOL
  1589. ProcessCompatibilityInfs(
  1590. IN HWND hwndParent,
  1591. IN HWND hProgress, OPTIONAL
  1592. IN UINT ProgressMessage
  1593. );
  1594. VOID
  1595. DoRunonce (
  1596. );
  1597. //
  1598. // Security Stuff
  1599. //
  1600. BOOL
  1601. SetupInstallSecurity(
  1602. IN HWND Window,
  1603. IN HWND ProgressWindow,
  1604. IN ULONG StartAtPercent,
  1605. IN ULONG StopAtPercent
  1606. );
  1607. VOID
  1608. CallSceGenerateTemplate( VOID );
  1609. VOID
  1610. CallSceConfigureServices( VOID );
  1611. extern HANDLE SceSetupRootSecurityThreadHandle;
  1612. extern BOOL bSceSetupRootSecurityComplete;
  1613. VOID
  1614. CallSceSetupRootSecurity( VOID );
  1615. PSID
  1616. GetAdminAccountSid(
  1617. );
  1618. VOID
  1619. GetAdminAccountName(
  1620. PWSTR AccountName
  1621. );
  1622. NTSTATUS
  1623. DisableLocalAdminAccount(
  1624. VOID
  1625. );
  1626. BOOL
  1627. SetupRunBaseWinOptions(
  1628. IN HWND Window,
  1629. IN HWND ProgressWindow
  1630. );
  1631. //
  1632. // PnP stuff.
  1633. //
  1634. BOOL
  1635. InstallPnpDevices(
  1636. IN HWND hwndParent,
  1637. IN HINF InfHandle,
  1638. IN HWND ProgressWindow,
  1639. IN ULONG StartAtPercent,
  1640. IN ULONG StopAtPercent
  1641. );
  1642. VOID
  1643. PnpStopServerSideInstall( VOID );
  1644. VOID
  1645. PnpUpdateHAL(
  1646. VOID
  1647. );
  1648. #ifdef _OCM
  1649. PVOID
  1650. FireUpOcManager(
  1651. VOID
  1652. );
  1653. VOID
  1654. KillOcManager(
  1655. PVOID OcManagerContext
  1656. );
  1657. #endif
  1658. //
  1659. // Boolean value indicating whether we found any new
  1660. // optional component infs.
  1661. //
  1662. extern BOOL AnyNewOCInfs;
  1663. //
  1664. // INF caching -- used during optional components processing.
  1665. // WARNING: NOT MULTI-THREAD SAFE!
  1666. //
  1667. HINF
  1668. InfCacheOpenInf(
  1669. IN PCWSTR FileName,
  1670. IN PCWSTR InfType OPTIONAL
  1671. );
  1672. HINF
  1673. InfCacheOpenLayoutInf(
  1674. IN HINF InfHandle
  1675. );
  1676. VOID
  1677. InfCacheEmpty(
  1678. IN BOOL CloseInfs
  1679. );
  1680. //
  1681. // Pnp stuff
  1682. //
  1683. BOOL
  1684. InstallPnpClassInstallers(
  1685. IN HWND hwndParent,
  1686. IN HINF InfHandle,
  1687. IN HSPFILEQ FileQ
  1688. );
  1689. //
  1690. // UI Stuff
  1691. //
  1692. VOID
  1693. SetFinishItemAttributes(
  1694. IN HWND hdlg,
  1695. IN int BitmapControl,
  1696. IN HANDLE hBitmap,
  1697. IN int TextControl,
  1698. IN LONG Weight
  1699. );
  1700. void
  1701. pSetupDebugPrint(
  1702. PWSTR FileName,
  1703. ULONG LineNumber,
  1704. PWSTR TagStr,
  1705. PWSTR FormatStr,
  1706. ...
  1707. );
  1708. #define SetupDebugPrint(_fmt_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,NULL,_fmt_)
  1709. #define SetupDebugPrint1(_fmt_,_arg1_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,NULL,_fmt_,_arg1_)
  1710. #define SetupDebugPrint2(_fmt_,_arg1_,_arg2_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,NULL,_fmt_,_arg1_,_arg2_)
  1711. #define SetupDebugPrint3(_fmt_,_arg1_,_arg2_,_arg3_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,NULL,_fmt_,_arg1_,_arg2_,_arg3_)
  1712. #define SetupDebugPrint4(_fmt_,_arg1_,_arg2_,_arg3_,_arg4_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,NULL,_fmt_,_arg1_,_arg2_,_arg3_,_arg4_)
  1713. #define SetupDebugPrint5(_fmt_,_arg1_,_arg2_,_arg3_,_arg4_,_arg5_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,NULL,_fmt_,_arg1_,_arg2_,_arg3_,_arg4_,_arg5_)
  1714. VOID
  1715. SaveInstallInfoIntoEventLog(
  1716. VOID
  1717. );
  1718. #ifdef _SETUP_PERF_
  1719. #define BEGIN_SECTION(_section_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,L"BEGIN_SECTION",_section_)
  1720. #define END_SECTION(_section_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,L"END_SECTION",_section_)
  1721. #define BEGIN_FUNCTION(_func_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,L"BEGIN_FUNCTION",_func_)
  1722. #define END_FUNCTION(_func_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,L"END_FUNCTION",_func_)
  1723. #define BEGIN_BLOCK(_block_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,L"BEGIN_BLOCK",_block_)
  1724. #define END_BLOCK(_block_) pSetupDebugPrint(TEXT(__FILE__),__LINE__,L"END_BLOCK",_block_)
  1725. #else // ! _PERF_
  1726. #define BEGIN_SECTION(_section_) ((void)0)
  1727. #define END_SECTION(_section_) ((void)0)
  1728. #endif // _PERF_
  1729. //
  1730. // Service Pack DLL Prototypes
  1731. //
  1732. #define SVCPACK_DLL_NAME TEXT("svcpack.dll")
  1733. #define SVCPACK_CALLBACK_NAME ("SvcPackCallbackRoutine")
  1734. #define CALL_SERVICE_PACK(_si_,_p1_,_p2_,_p3_) if (hModSvcPack && pSvcPackCallbackRoutine) pSvcPackCallbackRoutine(_si_,_p1_,_p2_,_p3_)
  1735. #define SVCPACK_PHASE_1 1
  1736. #define SVCPACK_PHASE_2 2
  1737. #define SVCPACK_PHASE_3 3
  1738. #define SVCPACK_PHASE_4 4
  1739. typedef DWORD
  1740. (WINAPI *PSVCPACKCALLBACKROUTINE)(
  1741. DWORD dwSetupPhase,
  1742. DWORD dwParam1,
  1743. DWORD dwParam2,
  1744. DWORD dwParam3
  1745. );
  1746. extern HMODULE hModSvcPack;
  1747. extern PSVCPACKCALLBACKROUTINE pSvcPackCallbackRoutine;
  1748. extern HINSTANCE hinstBB;
  1749. void PrepareBillBoard(HWND hwnd);
  1750. void TerminateBillBoard();
  1751. HWND GetBBhwnd();
  1752. void SetBBStep(int iStep);
  1753. VOID CenterWindowRelativeToWindow(HWND hwndtocenter, HWND hwndcenteron, BOOL bWizard);
  1754. BOOL BB_ShowProgressGaugeWnd(UINT nCmdShow);
  1755. LRESULT BB_ProgressGaugeMsg(UINT msg, WPARAM wparam, LPARAM lparam);
  1756. LRESULT ProgressGaugeMsgWrapper(UINT msg, WPARAM wparam, LPARAM lparam);
  1757. void BB_SetProgressText(LPCTSTR szText);
  1758. void BB_SetTimeEstimateText(LPTSTR szText);
  1759. void BB_SetInfoText(LPTSTR szText);
  1760. BOOL StartStopBB(BOOL bStart);
  1761. HWND
  1762. ShowHideWizardPage(
  1763. IN BOOL bShow
  1764. );
  1765. LRESULT
  1766. Billboard_Progress_Callback(
  1767. IN UINT Msg,
  1768. IN WPARAM wParam,
  1769. IN LPARAM lParam
  1770. );
  1771. VOID Billboard_Set_Progress_Text(LPCTSTR Text);
  1772. typedef struct _SETUPPHASE {
  1773. DWORD Time;
  1774. BOOL Win9xUpgradeOnly;
  1775. } SETUPPHASE;
  1776. void SetTimeEstimates();
  1777. DWORD CalcTimeRemaining(UINT Phase);
  1778. void SetRemainingTime(DWORD TimeInSeconds);
  1779. void UpdateTimeString(DWORD RemainungTimeMsecInThisPhase,
  1780. DWORD *PreviousRemainingTime);
  1781. extern UINT CurrentPhase;
  1782. extern ULONG RemainingTime;
  1783. extern SETUPPHASE SetupPhase[];
  1784. typedef enum {
  1785. Phase_Unknown = -1,
  1786. Phase_Initialize = 0,
  1787. Phase_InstallSecurity,
  1788. Phase_PrecompileInfs,
  1789. Phase_InstallEnumDevices1,
  1790. Phase_InstallLegacyDevices,
  1791. Phase_InstallEnumDevices2,
  1792. Phase_NetInstall,
  1793. Phase_OCInstall,
  1794. Phase_InstallComponentInfs,
  1795. Phase_Inf_Registration,
  1796. Phase_RunOnce_Registration,
  1797. Phase_SecurityTempates,
  1798. Phase_Win9xMigration,
  1799. Phase_SFC,
  1800. Phase_SaveRepair,
  1801. Phase_RemoveTempFiles,
  1802. Phase_Reboot // no entry for this, just to make sure we don't overrun.
  1803. } SetupPhases;
  1804. #include "SetupSxs.h"
  1805. #include "SxsApi.h"
  1806. typedef struct _SIDE_BY_SIDE
  1807. {
  1808. HINSTANCE Dll;
  1809. PSXS_BEGIN_ASSEMBLY_INSTALL BeginAssemblyInstall;
  1810. PSXS_END_ASSEMBLY_INSTALL EndAssemblyInstall;
  1811. PSXS_INSTALL_W InstallW;
  1812. PVOID Context;
  1813. } SIDE_BY_SIDE;
  1814. BOOL
  1815. SideBySidePopulateCopyQueue(
  1816. SIDE_BY_SIDE* Sxs,
  1817. HSPFILEQ FileQ, OPTIONAL
  1818. PCWSTR AssembliesRootSource OPTIONAL
  1819. );
  1820. BOOL
  1821. SideBySideFinish(
  1822. SIDE_BY_SIDE* Sxs,
  1823. BOOL fSuccess
  1824. );
  1825. BOOL
  1826. SideBySideCreateSyssetupContext(
  1827. VOID
  1828. );
  1829. VOID
  1830. SetUpProcessorNaming(
  1831. VOID
  1832. );
  1833. BOOL
  1834. SpSetProductTypeFromParameters(
  1835. VOID
  1836. );
  1837. //
  1838. // imported from setupapi
  1839. //
  1840. #define SIZECHARS(x) (sizeof((x))/sizeof(TCHAR))
  1841. #define CSTRLEN(x) ((sizeof((x))/sizeof(TCHAR)) - 1)
  1842. #define ARRAYSIZE(x) (sizeof((x))/sizeof((x)[0]))
  1843. #define MyFree pSetupFree
  1844. #define MyMalloc pSetupMalloc
  1845. #define MyRealloc pSetupRealloc
  1846. BOOL
  1847. FileExists(
  1848. IN PCTSTR FileName,
  1849. OUT PWIN32_FIND_DATA FindData OPTIONAL
  1850. );
  1851. BOOL
  1852. DriverNodeSupportsNT(
  1853. IN HDEVINFO DeviceInfoSet,
  1854. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  1855. );
  1856. VOID
  1857. ReplaceSlashWithHash(
  1858. IN PWSTR Str
  1859. );
  1860. HANDLE
  1861. UtilpGetDeviceHandle(
  1862. HDEVINFO DevInfo,
  1863. PSP_DEVINFO_DATA DevInfoData,
  1864. LPGUID ClassGuid,
  1865. DWORD DesiredAccess
  1866. );
  1867. typedef enum {
  1868. CDRetail,
  1869. CDOem,
  1870. CDSelect
  1871. } CDTYPE;
  1872. extern CDTYPE CdType;
  1873. extern DWORD GetProductFlavor();
  1874. BOOL IsSafeMode(
  1875. VOID
  1876. );
  1877. DWORD
  1878. SpUninstallCatalog(
  1879. IN HCATADMIN CatAdminHandle OPTIONAL,
  1880. IN PCWSTR CatFileName,
  1881. IN PCWSTR CatFilePath OPTIONAL,
  1882. IN PCWSTR AttributeName OPTIONAL,
  1883. IN PCWSTR AttributeValue OPTIONAL,
  1884. IN OUT PLIST_ENTRY InstalledCatalogsList OPTIONAL
  1885. );
  1886. extern GUID DriverVerifyGuid;
  1887. #ifdef PRERELEASE
  1888. extern INT g_TestHook;
  1889. # define TESTHOOK(n) if(g_TestHook==(n))RaiseException(EXCEPTION_NONCONTINUABLE_EXCEPTION,EXCEPTION_NONCONTINUABLE,0,NULL)
  1890. #else
  1891. # define TESTHOOK(n)
  1892. #endif
  1893. BOOL
  1894. RenameOnRestartOfGUIMode(
  1895. IN PCWSTR pPathName,
  1896. IN PCWSTR pPathNameNew
  1897. );
  1898. BOOL
  1899. DeleteOnRestartOfGUIMode(
  1900. IN PCWSTR pPathName
  1901. );
  1902. VOID
  1903. RemoveAllPendingOperationsOnRestartOfGUIMode(
  1904. VOID
  1905. );
  1906. typedef struct _STRING_LIST_ENTRY
  1907. {
  1908. LIST_ENTRY Entry;
  1909. PTSTR String;
  1910. }
  1911. STRING_LIST_ENTRY, *PSTRING_LIST_ENTRY;
  1912. void
  1913. FORCEINLINE
  1914. FreeStringEntry(
  1915. PLIST_ENTRY pEntry,
  1916. BOOL DeleteEntry
  1917. )
  1918. {
  1919. PSTRING_LIST_ENTRY pStringEntry = CONTAINING_RECORD(pEntry, STRING_LIST_ENTRY, Entry);
  1920. if(pStringEntry->String != NULL) {
  1921. MyFree(pStringEntry->String);
  1922. pStringEntry->String = NULL;
  1923. }
  1924. if(DeleteEntry) {
  1925. MyFree(pStringEntry);
  1926. }
  1927. }
  1928. typedef BOOL (CALLBACK* PFN_BUILD_FILE_LIST_CALLBACK)(IN PCTSTR Directory OPTIONAL, IN PCTSTR FilePath);
  1929. void
  1930. FORCEINLINE
  1931. FreeStringList(
  1932. PLIST_ENTRY pListHead
  1933. )
  1934. {
  1935. PLIST_ENTRY pEntry;
  1936. ASSERT(pListHead != NULL);
  1937. pEntry = pListHead->Flink;
  1938. while(pEntry != pListHead) {
  1939. PLIST_ENTRY Flink = pEntry->Flink;
  1940. FreeStringEntry(pEntry, TRUE);
  1941. pEntry = Flink;
  1942. }
  1943. InitializeListHead(pListHead);
  1944. }
  1945. DWORD
  1946. BuildFileListFromDir(
  1947. IN PCTSTR PathBase,
  1948. IN PCTSTR Directory OPTIONAL,
  1949. IN DWORD MustHaveAttrs OPTIONAL,
  1950. IN DWORD MustNotHaveAttrs OPTIONAL,
  1951. IN PFN_BUILD_FILE_LIST_CALLBACK Callback OPTIONAL,
  1952. OUT PLIST_ENTRY ListHead
  1953. );
  1954. PSTRING_LIST_ENTRY
  1955. SearchStringInList(
  1956. IN PLIST_ENTRY ListHead,
  1957. IN PCTSTR String,
  1958. BOOL CaseSensitive
  1959. );
  1960. DWORD
  1961. LookupCatalogAttribute(
  1962. IN PCWSTR CatalogName,
  1963. IN PCWSTR Directory OPTIONAL,
  1964. IN PCWSTR AttributeName OPTIONAL,
  1965. IN PCWSTR AttributeValue OPTIONAL,
  1966. PBOOL Found
  1967. );
  1968. BOOL
  1969. BuildPath (
  1970. OUT PTSTR PathBuffer,
  1971. IN DWORD PathBufferSize,
  1972. IN PCTSTR Path1,
  1973. IN PCTSTR Path2
  1974. );