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.

1446 lines
30 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. spmisc.h
  5. Abstract:
  6. Miscellaneous stuff for text setup.
  7. Author:
  8. Ted Miller (tedm) 29-July-1993
  9. Revision History:
  10. --*/
  11. #include <crypt.h>
  12. #ifndef _SPSETUP_DEFN_
  13. #define _SPSETUP_DEFN_
  14. extern PWSTR SetupSourceDevicePath;
  15. extern PWSTR DirectoryOnSetupSource;
  16. extern PVOID SifHandle;
  17. extern BOOLEAN Win9xRollback;
  18. ULONG
  19. SpStartSetup(
  20. VOID
  21. );
  22. VOID
  23. SpGetWinntParams(
  24. OUT PWSTR *DevicePath,
  25. OUT PWSTR *DirectoryOnDevice
  26. );
  27. extern WCHAR TemporaryBuffer[16384];
  28. //
  29. // TRUE if setup should run in the step-up upgrade mode.
  30. // In this mode, setup is not allowed to do clean install,
  31. // and is not allowed to upgrade workstation to server.
  32. //
  33. // We also track an evaluation time for the evaluation SKU.
  34. //
  35. extern BOOLEAN StepUpMode;
  36. extern ULONG EvaluationTime;
  37. extern ULONG RestrictCpu;
  38. extern ULONG SuiteType;
  39. __inline
  40. BOOLEAN
  41. SpIsProductSuite(
  42. DWORD SuiteToCheck
  43. )
  44. {
  45. return (SuiteType & SuiteToCheck) ? TRUE : FALSE;
  46. }
  47. //
  48. // Non-0 if gui setup is supposed to be restartable.
  49. // This causes us to do special stuff with hives in spconfig.c.
  50. //
  51. extern BOOLEAN RestartableGuiSetup;
  52. //
  53. // TRUE if user chose Repair Winnt
  54. //
  55. extern BOOLEAN RepairWinnt;
  56. //
  57. // TRUE if user chose Custom Setup.
  58. //
  59. extern BOOLEAN CustomSetup;
  60. //
  61. // TRUE if floppyless boot
  62. //
  63. extern BOOLEAN IsFloppylessBoot;
  64. //
  65. // TRUE is textmode is to pick a partition
  66. //
  67. extern BOOLEAN AutoPartitionPicker;
  68. //
  69. // Preferred installation dir
  70. //
  71. extern PWSTR PreferredInstallDir;
  72. //
  73. // ARC pathname of the device from which we were started.
  74. //
  75. extern PWSTR ArcBootDevicePath;
  76. //
  77. // Gets set to TRUE if the user elects to convert or format to ntfs.
  78. // And a flag indicating whether we are doing a dirty sleazy hack
  79. // for oem preinstall.
  80. //
  81. extern BOOLEAN ConvertNtVolumeToNtfs;
  82. extern BOOLEAN ExtendingOemPartition;
  83. //
  84. // TRUE if upgrading NT to NT
  85. //
  86. typedef enum _ENUMUPRADETYPE {
  87. DontUpgrade = 0,
  88. UpgradeFull,
  89. UpgradeInstallFresh
  90. } ENUMUPGRADETYPE;
  91. extern ENUMUPGRADETYPE NTUpgrade;
  92. extern ENUMUPGRADETYPE IsNTUpgrade;
  93. extern ULONG OldMinorVersion,OldMajorVersion;
  94. //
  95. // TRUE if upgrading Workstation to Standard Server, or upgrading
  96. // existing Standard Server
  97. //
  98. extern BOOLEAN StandardServerUpgrade;
  99. typedef enum _ENUMNONNTUPRADETYPE {
  100. NoWinUpgrade = 0,
  101. UpgradeWin31,
  102. UpgradeWin95
  103. } ENUMNONNTUPRADETYPE;
  104. //
  105. // Non-zero if upgrading win31 or win95 to NT.
  106. //
  107. extern ENUMNONNTUPRADETYPE WinUpgradeType;
  108. //
  109. // Macros to simplify use of enum type
  110. //
  111. #define ANY_TYPE_OF_UPGRADE (NTUpgrade || WinUpgradeType)
  112. #define WIN9X_OR_NT_UPGRADE (NTUpgrade == UpgradeFull || WinUpgradeType == UpgradeWin95)
  113. //
  114. // TRUE if this setup was started with winnt.exe.
  115. // Also a flag indicating whether the local source was not created and we
  116. // should get files from the CD instead.
  117. //
  118. extern BOOLEAN WinntSetup;
  119. extern BOOLEAN WinntFromCd;
  120. #ifdef _X86_
  121. //
  122. // TRUE if this setup was started with winnt95.exe.
  123. //
  124. extern BOOLEAN Winnt95Setup;
  125. #endif
  126. //
  127. // TRUE if any of the accessibility options was selected
  128. //
  129. extern BOOLEAN AccessibleSetup;
  130. //
  131. // If this is an unattended setup, this value will be a TRUE
  132. //
  133. extern BOOLEAN UnattendedOperation;
  134. //
  135. // If there is an Unattended GUI section, this value will be TRUE
  136. //
  137. extern BOOLEAN UnattendedGuiOperation;
  138. //
  139. // This value is strictly a pointer to the WINNT.SIF file in the
  140. // case that Unattended operation occurs in either the textmode
  141. // or GUI Mode case. It has been kept to avoid changing large
  142. // sections of code.
  143. //
  144. extern PVOID UnattendedSifHandle;
  145. //
  146. // This value is a non-null pointer to the WINNT.SIF file. It is
  147. // initialized when the driver is started. Any parameter which is
  148. // to be passed to GUI mode is added to the WINNT.SIF file by
  149. // referencing this parameter.
  150. //
  151. extern PVOID WinntSifHandle;
  152. extern BOOLEAN SkipMissingFiles;
  153. extern BOOLEAN HideWinDir;
  154. //
  155. // this value is a non-null pointer to the drvindex.inf file. It is
  156. // initialized on startup. The list of files that are present in our
  157. // driver cab file are indexed in this inf, so we can quickly look if a
  158. // file is present in the cab
  159. //
  160. extern PVOID DriverInfHandle;
  161. //
  162. // This structure will keep track of all the cabs
  163. // that we'll be installing from.
  164. //
  165. typedef struct _CABDATA {
  166. struct _CABDATA *Next;
  167. PWSTR CabName;
  168. HANDLE CabHandle;
  169. PWSTR CabSectionName;
  170. PVOID CabInfHandle;
  171. } CABDATA;
  172. extern CABDATA *CabData;
  173. //
  174. // handle to delta.inf, used for private testing
  175. //
  176. extern PVOID PrivateInfHandle;
  177. #ifdef _X86_
  178. //
  179. // WINNT95 may turn this flag on, it is off by default for everything
  180. // else.
  181. //
  182. extern BOOLEAN MigrateOption;
  183. #endif
  184. //
  185. // This is a handle to txtsetup.oem, used on pre-install mode.
  186. //
  187. extern PVOID PreinstallOemSifHandle;
  188. //
  189. // On unattended mode, indicates whether OEM files
  190. // that have same name as Microsoft files released
  191. // with the product should be overwritten.
  192. //
  193. extern BOOLEAN UnattendedOverwriteOem;
  194. //
  195. // On unattended mode, indicates that this is is
  196. // an OEM pre-installation
  197. //
  198. extern BOOLEAN PreInstall;
  199. //
  200. // On pre-install mode, points to the directory that contains the files
  201. // that need to be copied during textmode setup
  202. //
  203. extern PWSTR PreinstallOemSourcePath;
  204. //
  205. // Flags that indicate the type of mice detected in the machine.
  206. // Note that more than one type of mice may be present.
  207. //
  208. extern BOOLEAN UsbMouseDetected;
  209. extern BOOLEAN PS2MouseDetected;
  210. extern BOOLEAN SerMouseDetected;
  211. //
  212. // Flags that indicate the type of keyboard detected in the machine.
  213. // Note that more than one type of keyborad may be present.
  214. //
  215. extern BOOLEAN UsbKeyboardDetected;
  216. extern BOOLEAN StdKeyboardDetected;
  217. //
  218. // This flag identifies "dockable" machines (portables)
  219. // so that we can disble dynamic volumes on them
  220. //
  221. extern BOOLEAN DockableMachine;
  222. //
  223. // Variable used during the repair process, that indicates that the
  224. // system has no CD-ROM drive.
  225. // This is a hack that we did for World Bank so that they can repair
  226. // the hives even if they don't have a CD-ROM drive.
  227. //
  228. extern BOOLEAN RepairNoCDROMDrive;
  229. //
  230. // RemoteBootSetup is true when Source and target paths are through the redirector
  231. // with possibly no system partition.
  232. //
  233. // RemoteInstallSetup is true when we are doing a remote install.
  234. //
  235. // RemoteSysPrepSetup is true when we are doing a remote install of a sys prep image.
  236. //
  237. // RemoteSysPrepVolumeIsNtfs is true when the sysprep image we're copying down
  238. // represents an ntfs volume.
  239. //
  240. extern BOOLEAN RemoteBootSetup;
  241. extern BOOLEAN RemoteInstallSetup;
  242. extern BOOLEAN RemoteSysPrepSetup;
  243. extern BOOLEAN RemoteSysPrepVolumeIsNtfs;
  244. //
  245. // setupldr may pass us the administrator password in a remote install
  246. // if the user is prompted for the password.
  247. //
  248. extern PWSTR NetBootAdministratorPassword;
  249. extern BOOLEAN NoLs;
  250. //
  251. // Source and target paths are through the redirector with possibly no
  252. // system partition,
  253. //
  254. extern BOOLEAN RemoteBootSetup;
  255. //
  256. // Filename of local source directory.
  257. //
  258. extern PWSTR LocalSourceDirectory;
  259. //
  260. // Platform-specific extension, used when creating names of sections
  261. // in sif/inf files.
  262. //
  263. extern PWSTR PlatformExtension;
  264. //
  265. // TRUE if this is advanced server we're setting up.
  266. //
  267. extern BOOLEAN AdvancedServer;
  268. //
  269. // Windows NT Version.
  270. //
  271. extern ULONG WinntMajorVer;
  272. extern ULONG WinntMinorVer;
  273. //
  274. // Representation of the boot device path in the nt namespace.
  275. //
  276. extern PWSTR NtBootDevicePath;
  277. extern PWSTR DirectoryOnBootDevice;
  278. //
  279. // Setup parameters passed to us by setupldr.
  280. //
  281. extern SETUP_LOADER_BLOCK_SCALARS SetupParameters;
  282. //
  283. // System information gathered by the user-mode part of text setup
  284. // and passed to us in IOCTL_SETUP_START
  285. //
  286. extern SYSTEM_BASIC_INFORMATION SystemBasicInfo;
  287. //
  288. // Flags indicating whether or not keyboard and video have been initialized
  289. //
  290. extern BOOLEAN VideoInitialized, KeyboardInitialized, KbdLayoutInitialized;
  291. //
  292. // ARC disk/signature information structure.
  293. // A list of these is created during phase0 initialization.
  294. //
  295. typedef struct _DISK_SIGNATURE_INFORMATION {
  296. struct _DISK_SIGNATURE_INFORMATION *Next;
  297. ULONG Signature;
  298. PWSTR ArcPath;
  299. ULONG CheckSum;
  300. BOOLEAN ValidPartitionTable;
  301. BOOLEAN xInt13;
  302. } DISK_SIGNATURE_INFORMATION, *PDISK_SIGNATURE_INFORMATION;
  303. extern PDISK_SIGNATURE_INFORMATION DiskSignatureInformation;
  304. //
  305. // Flag indicating whether or not pcmcia driver has been initialized
  306. //
  307. extern BOOLEAN PcmciaLoaded;
  308. //
  309. // Flag indicating whether or not atapi driver has been initialized
  310. //
  311. extern BOOLEAN AtapiLoaded;
  312. //
  313. // Array with the PIDs of all NT greater than 4.x found in the machine (PID 2.0)
  314. // The values in this array will be saved under Setup\PID key in the registry,
  315. // and will be used during GUI setup
  316. //
  317. extern PWSTR* Pid20Array;
  318. //
  319. // Product Id read from setup.ini
  320. //
  321. extern PWSTR PidString;
  322. //
  323. // Object types.
  324. //
  325. extern POBJECT_TYPE *IoFileObjectType;
  326. extern POBJECT_TYPE *IoDeviceObjectType;
  327. //
  328. // Gauge used to report progress of autochk and autofmt
  329. //
  330. extern PVOID UserModeGauge;
  331. //
  332. // This variable is used when displaying the progress bar
  333. // during autochk and autofmt. It indicates the disk that
  334. // is being autochecked or formatted.
  335. //
  336. extern ULONG CurrentDiskIndex;
  337. //
  338. // Process structure for usetup.exe
  339. //
  340. extern PEPROCESS UsetupProcess;
  341. //
  342. // Setup fatal error codes.
  343. //
  344. // If you add anything here, you must also update ntos\nls\bugcodes.txt.
  345. //
  346. #define SETUP_BUGCHECK_BAD_OEM_FONT 0
  347. #define SETUP_BUGCHECK_BOOTPATH 4
  348. #define SETUP_BUGCHECK_PARTITION 5
  349. #define SETUP_BUGCHECK_BOOTMSGS 6
  350. //
  351. // The following error codes are no longer used, because we have friendlier
  352. // error messages for them.
  353. //
  354. // #define SETUP_BUGCHECK_VIDEO 1
  355. // #define SETUP_BUGCHECK_MEMORY 2
  356. // #define SETUP_BUGCHECK_KEYBOARD 3
  357. //
  358. // Video-specific bugcheck subcodes.
  359. //
  360. #define VIDEOBUG_OPEN 0
  361. #define VIDEOBUG_GETNUMMODES 1
  362. #define VIDEOBUG_GETMODES 2
  363. #define VIDEOBUG_BADMODE 3
  364. #define VIDEOBUG_SETMODE 4
  365. #define VIDEOBUG_MAP 5
  366. #define VIDEOBUG_SETFONT 6
  367. //
  368. // Partition sanity check bugcheck subcodes.
  369. //
  370. #define PARTITIONBUG_A 0
  371. #define PARTITIONBUG_B 1
  372. //
  373. // Use the following enum to access line draw characters in
  374. // the LineChars array.
  375. //
  376. typedef enum {
  377. LineCharDoubleUpperLeft = 0,
  378. LineCharDoubleUpperRight,
  379. LineCharDoubleLowerLeft,
  380. LineCharDoubleLowerRight,
  381. LineCharDoubleHorizontal,
  382. LineCharDoubleVertical,
  383. LineCharSingleUpperLeft,
  384. LineCharSingleUpperRight,
  385. LineCharSingleLowerLeft,
  386. LineCharSingleLowerRight,
  387. LineCharSingleHorizontal,
  388. LineCharSingleVertical,
  389. LineCharDoubleVerticalToSingleHorizontalRight,
  390. LineCharDoubleVerticalToSingleHorizontalLeft,
  391. LineCharMax
  392. } LineCharIndex;
  393. extern WCHAR LineChars[LineCharMax];
  394. //
  395. // Remember whether or not we write out an ntbootdd.sys
  396. //
  397. typedef struct _HARDWAREIDLIST {
  398. struct _HARDWAREIDLIST *Next;
  399. PWSTR HardwareID;
  400. } HARDWAREIDLIST;
  401. extern HARDWAREIDLIST *HardwareIDList;
  402. extern BOOLEAN ForceBIOSBoot;
  403. //
  404. // Structure used to track a gauge.
  405. //
  406. typedef struct _GAS_GAUGE {
  407. //
  408. // upper left corner of outside of gauge.
  409. //
  410. ULONG GaugeX,GaugeY;
  411. //
  412. // Total width of gauge.
  413. //
  414. ULONG GaugeW;
  415. //
  416. // upper left corner of thermometer box.
  417. //
  418. ULONG ThermX,ThermY;
  419. //
  420. // Width of thermometer box.
  421. //
  422. ULONG ThermW;
  423. //
  424. // Total items reperesented by 100%
  425. //
  426. ULONG ItemCount;
  427. //
  428. // Items elapsed.
  429. //
  430. ULONG ItemsElapsed;
  431. //
  432. // Current percentage represented by ItemsElapsed.
  433. //
  434. ULONG CurrentPercentage;
  435. //
  436. // Caption text.
  437. //
  438. PWCHAR Caption;
  439. //
  440. // Absolute string
  441. //
  442. PWCHAR ProgressFmtStr;
  443. ULONG ProgressFmtWidth;
  444. //
  445. // Flags controlling what value to print
  446. //
  447. ULONG Flags;
  448. //
  449. // Color for the gauge bar
  450. //
  451. UCHAR Attribute;
  452. //
  453. // Buffer used for drawing.
  454. //
  455. PWCHAR Buffer;
  456. } GAS_GAUGE, *PGAS_GAUGE;
  457. //
  458. // Indicates whether autochk or autofmt are running
  459. //
  460. extern BOOLEAN AutochkRunning;
  461. extern BOOLEAN AutofrmtRunning;
  462. //
  463. // Various textmode setup progress events
  464. //
  465. typedef enum {
  466. CallbackEvent,
  467. InitializationEvent,
  468. PartitioningEvent,
  469. FileCopyEvent,
  470. BackupEvent,
  471. UninstallEvent,
  472. SavingSettingsEvent,
  473. SetupCompletedEvent
  474. } TM_SETUP_MAJOR_EVENT;
  475. typedef enum {
  476. CallbackInitialize,
  477. CallbackDeInitialize,
  478. InitializationStartEvent,
  479. InitializationEndEvent,
  480. PartitioningStartEvent,
  481. ScanDisksEvent,
  482. ScanDiskEvent,
  483. CreatePartitionEvent,
  484. DeletePartitionEvent,
  485. FormatPartitionEvent,
  486. ValidatePartitionEvent,
  487. PartitioningEventEnd,
  488. FileCopyStartEvent,
  489. OneFileCopyEvent,
  490. FileCopyEndEvent,
  491. SavingSettingsStartEvent,
  492. InitializeHiveEvent,
  493. SaveHiveEvent,
  494. HiveProcessingEndEvent,
  495. SavingSettingsEndEvent,
  496. ShutdownEvent,
  497. UninstallStartEvent,
  498. UninstallUpdateEvent,
  499. UninstallEndEvent,
  500. BackupStartEvent,
  501. BackupEndEvent,
  502. OneFileBackedUpEvent
  503. } TM_SETUP_MINOR_EVENT;
  504. typedef VOID (*TM_SETUP_PROGRESS_CALLBACK) (
  505. IN TM_SETUP_MAJOR_EVENT MajorEvent,
  506. IN TM_SETUP_MINOR_EVENT MinorEvent,
  507. IN PVOID Context,
  508. IN PVOID EventData
  509. );
  510. typedef struct _TM_PROGRESS_SUBSCRIBER {
  511. TM_SETUP_PROGRESS_CALLBACK Callback;
  512. PVOID Context;
  513. } TM_PROGRESS_SUBSCRIBER, *PTM_PROGRESS_SUBSCRIBER;
  514. NTSTATUS
  515. RegisterSetupProgressCallback(
  516. IN TM_SETUP_PROGRESS_CALLBACK CallBack,
  517. IN PVOID Context
  518. );
  519. NTSTATUS
  520. DeregisterSetupProgressCallback(
  521. IN TM_SETUP_PROGRESS_CALLBACK CallBack,
  522. IN PVOID Context
  523. );
  524. VOID
  525. SendSetupProgressEvent(
  526. IN TM_SETUP_MAJOR_EVENT MajorEvent,
  527. IN TM_SETUP_MINOR_EVENT MinorEvent,
  528. IN PVOID EventData
  529. );
  530. //
  531. // Enumerate the possible returns values from SpEnumFiles()
  532. //
  533. typedef enum {
  534. NormalReturn, // if the whole process completes uninterrupted
  535. EnumFileError, // if an error occurs while enumerating files
  536. CallbackReturn // if the callback returns FALSE, causing termination
  537. } ENUMFILESRESULT;
  538. typedef BOOLEAN (*ENUMFILESPROC) (
  539. IN PCWSTR,
  540. IN PFILE_BOTH_DIR_INFORMATION,
  541. OUT PULONG,
  542. IN PVOID
  543. );
  544. ENUMFILESRESULT
  545. SpEnumFiles(
  546. IN PCWSTR DirName,
  547. IN ENUMFILESPROC EnumFilesProc,
  548. OUT PULONG ReturnData,
  549. IN PVOID Pointer
  550. );
  551. ENUMFILESRESULT
  552. SpEnumFilesRecursive (
  553. IN PWSTR DirName,
  554. IN ENUMFILESPROC EnumFilesProc,
  555. OUT PULONG ReturnData,
  556. IN PVOID Pointer OPTIONAL
  557. );
  558. ENUMFILESRESULT
  559. SpEnumFilesRecursiveLimited (
  560. IN PWSTR DirName,
  561. IN ENUMFILESPROC EnumFilesProc,
  562. IN ULONG MaxDepth,
  563. IN ULONG CurrentDepth,
  564. OUT PULONG ReturnData,
  565. IN PVOID p1 OPTIONAL
  566. );
  567. ENUMFILESRESULT
  568. SpEnumFilesRecursiveDel (
  569. IN PWSTR DirName,
  570. IN ENUMFILESPROC EnumFilesProc,
  571. OUT PULONG ReturnData,
  572. IN PVOID p1 OPTIONAL
  573. );
  574. #define SecToNano(_sec) (LONGLONG)((_sec) * 1000 * 1000 * 10)
  575. //
  576. // This macro filters in-page exceptions, which occur if there is
  577. // an I/O error while the memory manager is paging in parts of a
  578. // memory-mapped file. Access to such data should be guarded with SEH!
  579. //
  580. #define IN_PAGE_ERROR \
  581. \
  582. ((GetExceptionCode() == STATUS_IN_PAGE_ERROR) \
  583. ? EXCEPTION_EXECUTE_HANDLER \
  584. : EXCEPTION_CONTINUE_SEARCH)
  585. //
  586. // Helper macro to make object attribute initialization a little cleaner.
  587. //
  588. #define INIT_OBJA(Obja,UnicodeString,UnicodeText) \
  589. \
  590. RtlInitUnicodeString((UnicodeString),(UnicodeText)); \
  591. \
  592. InitializeObjectAttributes( \
  593. (Obja), \
  594. (UnicodeString), \
  595. OBJ_CASE_INSENSITIVE, \
  596. NULL, \
  597. NULL \
  598. )
  599. //
  600. // Macro to align a buffer.
  601. //
  602. #define ALIGN(p,val) \
  603. \
  604. (PVOID)((((ULONG_PTR)(p) + (val) - 1)) & (~((ULONG_PTR)((val) - 1))))
  605. //
  606. // Macro to determine the number of elements in a statically
  607. // initialized array.
  608. //
  609. #define ELEMENT_COUNT(x) (sizeof(x)/sizeof(x[0]))
  610. //
  611. // Marcos to pull potentially unaligned values from memory.
  612. //
  613. #define U_USHORT(p) (*(USHORT UNALIGNED *)(p))
  614. #define U_ULONG(p) (*(ULONG UNALIGNED *)(p))
  615. #define U_ULONGLONG(p) (*(ULONGLONG UNALIGNED *)(p))
  616. typedef struct _SP_MIG_DRIVER_ENTRY {
  617. LIST_ENTRY ListEntry;
  618. PWSTR BaseDllName;
  619. } SP_MIG_DRIVER_ENTRY, *PSP_MIG_DRIVER_ENTRY;
  620. extern LIST_ENTRY MigratedDriversList;
  621. BOOL
  622. SpRememberMigratedDrivers (
  623. OUT PLIST_ENTRY List,
  624. IN PDETECTED_DEVICE SetupldrList
  625. );
  626. //
  627. // Setup media types. Setup can be started from one media
  628. // (ie, floppy) and copy files from another (ie, cd-rom).
  629. //
  630. typedef enum {
  631. SetupBootMedia,
  632. SetupSourceMedia
  633. } SetupMediaType;
  634. //
  635. // Upgrade-specific routines.
  636. //
  637. VOID
  638. SpPrepareFontsForUpgrade(
  639. IN PCWSTR SystemDirectory
  640. );
  641. //
  642. // User-mode services.
  643. //
  644. NTSTATUS
  645. SpExecuteImage(
  646. IN PWSTR ImagePath,
  647. OUT PULONG ReturnStatus, OPTIONAL
  648. IN ULONG ArgumentCount,
  649. ... // argv[0] is generated automatically
  650. );
  651. NTSTATUS
  652. SpLoadUnloadKey(
  653. IN HANDLE TargetKeyRootDirectory, OPTIONAL
  654. IN HANDLE SourceFileRootDirectory, OPTIONAL
  655. IN PWSTR TargetKeyName,
  656. IN PWSTR SourceFileName OPTIONAL
  657. );
  658. NTSTATUS
  659. SpDeleteKey(
  660. IN HANDLE KeyRootDirectory, OPTIONAL
  661. IN PWSTR Key
  662. );
  663. NTSTATUS
  664. SpQueryDirectoryObject(
  665. IN HANDLE DirectoryHandle,
  666. IN BOOLEAN RestartScan,
  667. IN OUT PULONG Context
  668. );
  669. NTSTATUS
  670. SpFlushVirtualMemory(
  671. IN PVOID BaseAddress,
  672. IN ULONG RangeLength
  673. );
  674. VOID
  675. SpShutdownSystem(
  676. VOID
  677. );
  678. NTSTATUS
  679. SpLoadKbdLayoutDll(
  680. IN PWSTR Directory,
  681. IN PWSTR DllName,
  682. OUT PVOID *TableAddress
  683. );
  684. NTSTATUS
  685. SpVerifyFileAccess(
  686. IN PWSTR FileName,
  687. IN ACCESS_MASK DesiredAccess
  688. );
  689. NTSTATUS
  690. SpSetDefaultFileSecurity(
  691. IN PWSTR FileName
  692. );
  693. NTSTATUS
  694. SpCreatePageFile(
  695. IN PWSTR FileName,
  696. IN ULONG MinSize,
  697. IN ULONG MaxSize
  698. );
  699. NTSTATUS
  700. SpGetFullPathName(
  701. IN OUT PWSTR FileName
  702. );
  703. NTSTATUS
  704. SpDecryptPassword(
  705. PENCRYPTED_NT_OWF_PASSWORD PasswordData,
  706. ULONG PasswordDataLength,
  707. ULONG Rid,
  708. PNT_OWF_PASSWORD NtOwfPassword
  709. );
  710. //
  711. // Registry Hives. We pass around the keys to the hives
  712. // in an array. Use the following enum values to access
  713. // the hive members
  714. //
  715. typedef enum {
  716. SetupHiveSystem,
  717. SetupHiveSoftware,
  718. SetupHiveDefault,
  719. SetupHiveUserdiff,
  720. SetupHiveMax
  721. } SetupHive;
  722. //
  723. // Function to set up registry.
  724. //
  725. VOID
  726. SpInitializeRegistry(
  727. IN PVOID SifHandle,
  728. IN PDISK_REGION TargetRegion,
  729. IN PWSTR SystemRoot,
  730. IN PWSTR SetupSourceDevicePath,
  731. IN PWSTR DirectoryOnSourceDevice,
  732. IN PWSTR SpecialDevicePath OPTIONAL,
  733. IN PDISK_REGION SystemPartitionRegion
  734. );
  735. NTSTATUS
  736. SpThirdPartyRegistry(
  737. IN PVOID hKeyControlSetServices
  738. );
  739. //
  740. // Function to examine a target registry
  741. //
  742. typedef enum {
  743. UpgradeNotInProgress = 0,
  744. UpgradeInProgress,
  745. UpgradeMaxValue
  746. } UPG_PROGRESS_TYPE;
  747. NTSTATUS
  748. SpDetermineProduct(
  749. IN PDISK_REGION TargetRegion,
  750. IN PWSTR SystemRoot,
  751. OUT PNT_PRODUCT_TYPE ProductType,
  752. OUT ULONG *MajorVersion,
  753. OUT ULONG *MinorVersion,
  754. OUT ULONG *BuildNumber, OPTIONAL
  755. OUT ULONG *ProductSuiteMask,
  756. OUT UPG_PROGRESS_TYPE *UpgradeProgressValue,
  757. OUT PWSTR *UniqueIdFromReg, OPTIONAL
  758. OUT PWSTR *Pid, OPTIONAL
  759. OUT PBOOLEAN pIsEvalVariation OPTIONAL,
  760. OUT PLCID LangId,
  761. OUT ULONG *ServicePack OPTIONAL
  762. );
  763. NTSTATUS
  764. SpSetUpgradeStatus(
  765. IN PDISK_REGION TargetRegion,
  766. IN PWSTR SystemRoot,
  767. IN UPG_PROGRESS_TYPE UpgradeProgressValue
  768. );
  769. //
  770. // Utility functions.
  771. //
  772. BOOLEAN
  773. SpGetTargetPath(
  774. IN PVOID SifHandle,
  775. IN PDISK_REGION Region,
  776. IN PWSTR DefaultPath,
  777. OUT PWSTR *TargetPath
  778. );
  779. VOID
  780. SpDeleteExistingTargetDir(
  781. IN PDISK_REGION Region,
  782. IN PWSTR NtDir,
  783. IN BOOLEAN GaugeNeeded,
  784. IN DWORD MsgId
  785. );
  786. VOID
  787. SpDone(
  788. IN ULONG MsgId,
  789. IN BOOLEAN Successful,
  790. IN BOOLEAN Wait
  791. );
  792. VOID
  793. SpFatalSifError(
  794. IN PVOID SifHandle,
  795. IN PWSTR Section,
  796. IN PWSTR Key, OPTIONAL
  797. IN ULONG Line,
  798. IN ULONG ValueNumber
  799. );
  800. VOID
  801. SpNonFatalSifError(
  802. IN PVOID SifHandle,
  803. IN PWSTR Section,
  804. IN PWSTR Key, OPTIONAL
  805. IN ULONG Line,
  806. IN ULONG ValueNumber,
  807. IN PWSTR FileName
  808. );
  809. VOID
  810. SpFatalKbdError(
  811. IN ULONG MessageId,
  812. ...
  813. );
  814. VOID
  815. SpFatalError(
  816. IN ULONG MessageId,
  817. ...
  818. );
  819. PWSTR
  820. SpMakePlatformSpecificSectionName(
  821. IN PWSTR SectionName
  822. );
  823. VOID
  824. SpConfirmExit(
  825. VOID
  826. );
  827. PWSTR
  828. SpDupStringW(
  829. IN PCWSTR String
  830. );
  831. PSTR
  832. SpDupString(
  833. IN PCSTR String
  834. );
  835. #define \
  836. SpDupStringA SpDupString
  837. PWSTR
  838. SpToUnicode(
  839. IN PUCHAR OemString
  840. );
  841. PUCHAR
  842. SpToOem(
  843. IN PWSTR UnicodeString
  844. );
  845. VOID
  846. SpGetSourceMediaInfo(
  847. IN PVOID SifHandle,
  848. IN PWSTR MediaShortName,
  849. OUT PWSTR *Description, OPTIONAL
  850. OUT PWSTR *Tagfile, OPTIONAL
  851. OUT PWSTR *Directory OPTIONAL
  852. );
  853. VOID
  854. SpConcatenatePaths(
  855. IN OUT LPWSTR Path1,
  856. IN LPCWSTR Path2
  857. );
  858. VOID
  859. SpFetchDiskSpaceRequirements(
  860. IN PVOID SifHandle,
  861. IN ULONG BytesPerCluster,
  862. OUT PULONG FreeKBRequired, OPTIONAL
  863. OUT PULONG FreeKBRequiredSysPart OPTIONAL
  864. );
  865. VOID
  866. SpFetchTempDiskSpaceRequirements(
  867. IN PVOID SifHandle,
  868. IN ULONG BytesPerCluster,
  869. OUT PULONG LocalSourceKBRequired, OPTIONAL
  870. OUT PULONG BootKBRequired OPTIONAL
  871. );
  872. VOID
  873. SpFetchUpgradeDiskSpaceReq(
  874. IN PVOID SifHandle,
  875. OUT PULONG FreeKBRequired, OPTIONAL
  876. OUT PULONG FreeKBRequiredSysPart OPTIONAL
  877. );
  878. PWCHAR
  879. SpRetreiveMessageText(
  880. IN PVOID ImageBase, OPTIONAL
  881. IN ULONG MessageId,
  882. IN OUT PWCHAR MessageText, OPTIONAL
  883. IN ULONG MessageTextBufferSize OPTIONAL
  884. );
  885. NTSTATUS
  886. SpRtlFormatMessage(
  887. IN PWSTR MessageFormat,
  888. IN ULONG MaximumWidth OPTIONAL,
  889. IN BOOLEAN IgnoreInserts,
  890. IN BOOLEAN ArgumentsAreAnsi,
  891. IN BOOLEAN ArgumentsAreAnArray,
  892. IN va_list *Arguments,
  893. OUT PWSTR Buffer,
  894. IN ULONG Length,
  895. OUT PULONG ReturnLength OPTIONAL
  896. );
  897. VOID
  898. SpInitializeDriverInf(
  899. IN HANDLE MasterSifHandle,
  900. IN PWSTR SetupSourceDevicePath,
  901. IN PWSTR DirectoryOnSourceDevice
  902. );
  903. VOID
  904. SpOpenDriverCab(
  905. IN HANDLE MasterSifHandle,
  906. IN PWSTR SetupSourceDevicePath,
  907. IN PWSTR DirectoryOnSourceDevice,
  908. OUT PWSTR *Directory OPTIONAL
  909. );
  910. //
  911. // Disk region name translations
  912. //
  913. typedef enum _ENUMARCPATHTYPE {
  914. PrimaryArcPath = 0,
  915. SecondaryArcPath
  916. } ENUMARCPATHTYPE;
  917. VOID
  918. SpNtNameFromRegion(
  919. IN PDISK_REGION Region,
  920. OUT PWSTR NtPath,
  921. IN ULONG BufferSizeBytes,
  922. IN PartitionOrdinalType OrdinalType
  923. );
  924. BOOLEAN
  925. SpNtNameFromDosPath (
  926. IN PCWSTR DosPath,
  927. OUT PWSTR NtPath,
  928. IN UINT NtPathSizeInBytes,
  929. IN PartitionOrdinalType OrdinalType
  930. );
  931. VOID
  932. SpArcNameFromRegion(
  933. IN PDISK_REGION Region,
  934. OUT PWSTR ArcPath,
  935. IN ULONG BufferSizeBytes,
  936. IN PartitionOrdinalType OrdinalType,
  937. IN ENUMARCPATHTYPE ArcPathType
  938. );
  939. PDISK_REGION
  940. SpRegionFromArcOrDosName(
  941. IN PWSTR Name,
  942. IN PartitionOrdinalType OrdinalType,
  943. IN PDISK_REGION PreviousMatch
  944. );
  945. PDISK_REGION
  946. SpRegionFromNtName(
  947. IN PWSTR NtName,
  948. IN PartitionOrdinalType OrdinalType
  949. );
  950. PDISK_REGION
  951. SpRegionFromDosName(
  952. IN PCWSTR DosName
  953. );
  954. PDISK_REGION
  955. SpRegionFromArcName(
  956. IN PWSTR ArcName,
  957. IN PartitionOrdinalType OrdinalType,
  958. IN PDISK_REGION PreviousMatch
  959. );
  960. //
  961. // Help routine.
  962. //
  963. #define SPHELP_HELPTEXT 0x00000000
  964. #define SPHELP_LICENSETEXT 0x00000001
  965. VOID
  966. SpHelp(
  967. IN ULONG MessageId, OPTIONAL
  968. IN PCWSTR FileText, OPTIONAL
  969. IN ULONG Flags
  970. );
  971. //
  972. //
  973. //
  974. BOOLEAN
  975. SpPromptForDisk(
  976. IN PWSTR DiskDescription,
  977. IN OUT PWSTR DiskDevicePath,
  978. IN PWSTR DiskTagFile,
  979. IN BOOLEAN IgnoreDiskInDrive,
  980. IN BOOLEAN AllowEscape,
  981. IN BOOLEAN WarnMultiplePrompts,
  982. OUT PBOOLEAN pRedrawFlag
  983. );
  984. BOOLEAN
  985. SpPromptForSetupMedia(
  986. IN PVOID SifHandle,
  987. IN PWSTR MediaShortname,
  988. IN PWSTR DiskDevicePath
  989. );
  990. ULONG
  991. SpFindStringInTable(
  992. IN PWSTR *StringTable,
  993. IN PWSTR StringToFind
  994. );
  995. PWSTR
  996. SpGenerateCompressedName(
  997. IN PWSTR Filename
  998. );
  999. BOOLEAN
  1000. SpNonCriticalError(
  1001. IN PVOID SifHandle,
  1002. IN ULONG MsgId,
  1003. IN PWSTR p1,
  1004. IN PWSTR p2
  1005. );
  1006. BOOLEAN
  1007. SpNonCriticalErrorWithContinue(
  1008. IN ULONG MsgId,
  1009. IN PWSTR p1,
  1010. IN PWSTR p2
  1011. );
  1012. VOID
  1013. SpNonCriticalErrorNoRetry(
  1014. IN ULONG MsgId,
  1015. IN PWSTR p1,
  1016. IN PWSTR p2
  1017. );
  1018. VOID
  1019. SpPrepareForPrinterUpgrade(
  1020. IN PVOID SifHandle,
  1021. IN PDISK_REGION NtRegion,
  1022. IN PWSTR Sysroot
  1023. );
  1024. NTSTATUS
  1025. SpOpenSetValueAndClose(
  1026. IN HANDLE hKeyRoot,
  1027. IN PWSTR SubKeyName, OPTIONAL
  1028. IN PWSTR ValueName,
  1029. IN ULONG ValueType,
  1030. IN PVOID Value,
  1031. IN ULONG ValueSize
  1032. );
  1033. NTSTATUS
  1034. SpDeleteValueKey(
  1035. IN HANDLE hKeyRoot,
  1036. IN PWSTR KeyName,
  1037. IN PWSTR ValueName
  1038. );
  1039. NTSTATUS
  1040. SpGetValueKey(
  1041. IN HANDLE hKeyRoot,
  1042. IN PWSTR KeyName,
  1043. IN PWSTR ValueName,
  1044. IN ULONG BufferLength,
  1045. OUT PUCHAR Buffer,
  1046. OUT PULONG ResultLength
  1047. );
  1048. BOOLEAN
  1049. SpIsRegionBeyondCylinder1024(
  1050. IN PDISK_REGION Region
  1051. );
  1052. PWSTR
  1053. SpDetermineSystemPartitionDirectory(
  1054. IN PDISK_REGION SystemPartitionRegion,
  1055. IN PWSTR OriginalSystemPartitionDirectory OPTIONAL
  1056. );
  1057. VOID
  1058. SpFindSizeOfFilesInOsWinnt(
  1059. IN PVOID MasterSifHandle,
  1060. IN PDISK_REGION SystemPartition,
  1061. IN PULONG TotalSize
  1062. );
  1063. VOID
  1064. SpRunAutochkOnNtAndSystemPartitions(
  1065. IN HANDLE MasterSifHandle,
  1066. IN PDISK_REGION WinntPartitionRegion,
  1067. IN PDISK_REGION SystemPartitionRegion,
  1068. IN PWSTR SetupSourceDevicePath,
  1069. IN PWSTR DirectoryOnSourceDevice,
  1070. IN PWSTR TargetPath
  1071. );
  1072. NTSTATUS
  1073. SpRunAutoFormat(
  1074. IN HANDLE MasterSifHandle,
  1075. IN PWSTR RegionDescription,
  1076. IN PDISK_REGION PartitionRegion,
  1077. IN ULONG FilesystemType,
  1078. IN BOOLEAN QuickFormat,
  1079. IN DWORD ClusterSize,
  1080. IN PWSTR SetupSourceDevicePath,
  1081. IN PWSTR DirectoryOnSourceDevice
  1082. );
  1083. #ifdef _X86_
  1084. BOOL
  1085. SpUseBIOSToBoot(
  1086. IN PDISK_REGION NtPartitionRegion,
  1087. IN PWSTR NtPartitionDevicePath,
  1088. IN PVOID SifHandle
  1089. );
  1090. #endif
  1091. //
  1092. // Utilities used for partitioning/formatting
  1093. //
  1094. USHORT
  1095. ComputeSecPerCluster(
  1096. IN ULONG NumSectors,
  1097. IN BOOLEAN SmallFat
  1098. );
  1099. NTSTATUS
  1100. SpLockUnlockVolume(
  1101. IN HANDLE Handle,
  1102. IN BOOLEAN LockVolume
  1103. );
  1104. NTSTATUS
  1105. SpDismountVolume(
  1106. IN HANDLE Handle
  1107. );
  1108. //
  1109. // Miscellaneous other stuff
  1110. //
  1111. BOOLEAN
  1112. SpReadSKUStuff(
  1113. VOID
  1114. );
  1115. VOID
  1116. SpSetDirtyShutdownFlag(
  1117. IN PDISK_REGION TargetRegion,
  1118. IN PWSTR SystemRoot
  1119. );
  1120. BOOLEAN
  1121. SpPatchBootMessages(
  1122. VOID
  1123. );
  1124. ULONG
  1125. SpGetHeaderTextId(
  1126. VOID
  1127. );
  1128. NTSTATUS
  1129. SpGetVersionFromStr(
  1130. IN PWSTR VersionStr,
  1131. OUT PDWORD Version, // major * 100 + minor
  1132. OUT PDWORD BuildNumber
  1133. );
  1134. NTSTATUS
  1135. SpQueryCanonicalName(
  1136. IN PWSTR Name,
  1137. IN ULONG MaxDepth,
  1138. OUT PWSTR CanonicalName,
  1139. IN ULONG SizeOfBufferInBytes
  1140. );
  1141. void
  1142. SpDisableCrashRecoveryForGuiMode(
  1143. IN PDISK_REGION TargetRegion,
  1144. IN PWSTR SystemRoot
  1145. );
  1146. //
  1147. // mountmanger mount point iteration routine(s)
  1148. //
  1149. typedef BOOLEAN (* SPMOUNTMGR_ITERATION_CALLBACK)(
  1150. IN PVOID Context,
  1151. IN PMOUNTMGR_MOUNT_POINTS MountPoints,
  1152. IN PMOUNTMGR_MOUNT_POINT MountPoint);
  1153. NTSTATUS
  1154. SpIterateMountMgrMountPoints(
  1155. IN PVOID Context,
  1156. IN SPMOUNTMGR_ITERATION_CALLBACK Callback
  1157. );
  1158. //
  1159. // Registry iteration abstractions
  1160. //
  1161. typedef struct _SPREGISTERYKEY_ITERATION_CALLBACK_DATA {
  1162. KEY_INFORMATION_CLASS InformationType;
  1163. PVOID Information;
  1164. HANDLE ParentKeyHandle;
  1165. } SP_REGISTRYKEY_ITERATION_CALLBACK_DATA, *PSP_REGISTRYKEY_ITERATION_CALLBACK_DATA;
  1166. //
  1167. // registry iteration call back
  1168. //
  1169. typedef BOOLEAN (* SP_REGISTRYKEY_ITERATION_CALLBACK)(
  1170. IN PVOID Context,
  1171. IN PSP_REGISTRYKEY_ITERATION_CALLBACK_DATA Data,
  1172. OUT NTSTATUS *StatusCode
  1173. );
  1174. NTSTATUS
  1175. SpIterateRegistryKeyForKeys(
  1176. IN HANDLE RootKeyHandle,
  1177. IN PWSTR KeyToIterate,
  1178. IN SP_REGISTRYKEY_ITERATION_CALLBACK Callback,
  1179. IN PVOID Context
  1180. );
  1181. #define MAX_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
  1182. #define MAX_COPY_SIZE(a) (MAX_ARRAY_SIZE(a) - 1)
  1183. #define MAX_APPEND_SIZE_W(a) (MAX_COPY_SIZE(a) - wcslen(a))
  1184. #define MAX_APPEND_SIZE MAX_APPEND_SIZE_W
  1185. #ifdef PRERELEASE
  1186. extern INT g_TestHook;
  1187. # define TESTHOOK(n) if(g_TestHook==(n))SpBugCheck(SETUP_BUGCHECK_BOOTMSGS,0,0,0)
  1188. #else
  1189. # define TESTHOOK(n)
  1190. #endif
  1191. //
  1192. // On x86, we want to clear the previous OS entry in boot.ini if
  1193. // we reformat C:
  1194. //
  1195. #ifdef _X86_
  1196. extern UCHAR OldSystemLine[MAX_PATH];
  1197. extern BOOLEAN DiscardOldSystemLine;
  1198. #endif
  1199. #endif // ndef _SPSETUP_DEFN_