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.

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