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.

2405 lines
47 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <commctrl.h>
  6. #include <commdlg.h>
  7. #include <winioctl.h>
  8. #include <setupbat.h>
  9. #include <setupapi.h>
  10. #include <winnls.h>
  11. #include <shlwapi.h>
  12. #include <winspool.h>
  13. #include <wininet.h>
  14. #include <tchar.h>
  15. #include <malloc.h>
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <winnt32p.h>
  19. #include <pidgen.h>
  20. #include <locale.h>
  21. #include <ntverp.h>
  22. #include <patchapi.h>
  23. #include <cfgmgr32.h>
  24. #include <regstr.h>
  25. #include <imagehlp.h>
  26. #include "resource.h"
  27. #include "util.h"
  28. #include "hwdb.h"
  29. #include "wsdu.h"
  30. #include "dynupdt.h"
  31. #include "diamond.h"
  32. //
  33. // moved to precomp.h
  34. //
  35. //#include "msg.h"
  36. #include "helpids.h"
  37. #include "comp.h"
  38. #include "compliance.h"
  39. #include "mgdlllib.h"
  40. #ifdef PRERELEASE
  41. #define TRY
  42. #define EXCEPT(e) goto __skip;
  43. #define _exception_code() 0
  44. #define END_EXCEPT __skip:;
  45. #else
  46. #define TRY __try
  47. #define EXCEPT(e) __except (e)
  48. #define END_EXCEPT
  49. #endif
  50. #define SIZEOFARRAY(a) (sizeof (a) / sizeof (a[0]))
  51. #define HideWindow(_hwnd) SetWindowLong((_hwnd),GWL_STYLE,GetWindowLong((_hwnd),GWL_STYLE)&~WS_VISIBLE)
  52. #define UnHideWindow(_hwnd) SetWindowLong((_hwnd),GWL_STYLE,GetWindowLong((_hwnd),GWL_STYLE)|WS_VISIBLE)
  53. #define UNATTENDED(btn) if((UnattendedOperation) && (!CancelPending)) PostMessage(hdlg,WMX_UNATTENDED,btn,0)
  54. #define CHECKUPGRADEONLY() if(CheckUpgradeOnly) return( FALSE )
  55. #define CHECKUPGRADEONLY_Q() if(CheckUpgradeOnlyQ) return( FALSE )
  56. #define SetDialogFocus(_hwnd, _hwndchild) SendMessage(_hwnd, WM_NEXTDLGCTL, (WPARAM)_hwndchild, MAKELPARAM(TRUE, 0))
  57. #define MAKEULONGLONG(low,high) ((ULONGLONG)(((DWORD)(low)) | ((ULONGLONG)((DWORD)(high))) << 32))
  58. #define HIULONG(_val_) ((ULONG)(_val_>>32))
  59. #define LOULONG(_val_) ((ULONG)_val_)
  60. #define TYPICAL() (dwSetupFlags & UPG_FLAG_TYPICAL)
  61. extern HINSTANCE hInst;
  62. extern UINT AppTitleStringId;
  63. extern DWORD TlsIndex;
  64. extern HINSTANCE hinstBB;
  65. extern HWND WizardHandle;
  66. extern BOOL g_DeleteRunOnceFlag;
  67. HWND GetBBhwnd();
  68. HWND GetBBMainHwnd();
  69. #define S_WINNT32_WARNING TEXT("Winnt32RunOnceWarning")
  70. // #define RUN_SYSPARSE 1
  71. //
  72. // Flag indicating whether we are initiating an MSI-Install.
  73. //
  74. extern BOOL RunFromMSI;
  75. //
  76. // Flag indicating whether we are initiating an Typical install
  77. //
  78. extern DWORD dwSetupFlags;
  79. //
  80. // Flag indicating whether we are initiating an upgrade.
  81. //
  82. extern BOOL Upgrade;
  83. //
  84. // Flag to say if we need to write the AcpiHAL value to the winnt.sif file
  85. //
  86. extern BOOL WriteAcpiHalValue;
  87. //
  88. // What should we write as the value for the AcpiHalValue
  89. //
  90. extern BOOL AcpiHalValue;
  91. //
  92. // Flag indicating whether we're installing/upgrading to NT Server
  93. //
  94. extern BOOL Server;
  95. //
  96. // Flag to indicate if we are running BVT's
  97. //
  98. extern BOOL RunningBVTs;
  99. //
  100. // When running BVT's, what baudrate should we set the debugger to?
  101. //
  102. extern LONG lDebugBaudRate;
  103. //
  104. // When running BVT's, what comport should we set the debugger to?
  105. //
  106. extern LONG lDebugComPort;
  107. //
  108. // When running BVT's, should we copy the symbols locally?
  109. //
  110. extern BOOL CopySymbols;
  111. //
  112. // Flag to indicate if we are running ASR tests
  113. //
  114. extern DWORD AsrQuickTest;
  115. //
  116. // Product type and flavor for upgrade modules
  117. //
  118. extern PRODUCTTYPE UpgradeProductType;
  119. extern UINT ProductFlavor;
  120. //
  121. // fat to ntfs conversion flag
  122. //
  123. extern BOOL ForceNTFSConversion;
  124. extern BOOL NTFSConversionChanged;
  125. //
  126. // 16 bit environment boot (Win9x upgrade only)
  127. //
  128. typedef enum {
  129. BOOT16_AUTOMATIC,
  130. BOOT16_YES,
  131. BOOT16_NO
  132. } BOOT16_OPTIONS;
  133. extern UINT g_Boot16;
  134. //
  135. // Global flag indicating whether the entire overall program operation
  136. // was successful. Also a flag indicating whether to shut down automatically
  137. // when the wizard is done in the non-unattended case.
  138. //
  139. extern BOOL GlobalResult;
  140. extern BOOL AutomaticallyShutDown;
  141. //
  142. // Global OS version info.
  143. //
  144. extern OSVERSIONINFO OsVersion;
  145. extern DWORD OsVersionNumber;
  146. #define BUILDNUM() (OsVersion.dwBuildNumber)
  147. #ifdef UNICODE
  148. #define ISNT() (TRUE)
  149. #define ISOSR2() (FALSE)
  150. #else
  151. #define ISNT() (FALSE)
  152. #define ISOSR2() (LOWORD(OsVersion.dwBuildNumber) > 1080)
  153. #endif
  154. extern WINNT32_PLUGIN_INIT_INFORMATION_BLOCK info;
  155. //
  156. // Flags indicating how we were run and whether to create
  157. // a local source.
  158. //
  159. extern BOOL RunFromCD;
  160. extern BOOL MakeLocalSource;
  161. extern BOOL UserSpecifiedMakeLocalSource;
  162. extern BOOL NoLs;
  163. extern TCHAR UserSpecifiedLocalSourceDrive;
  164. extern LONG SourceInstallType; // uses InstallType enum
  165. extern DWORD MLSDiskID;
  166. //
  167. // Used for win9xupg reporting (reportonly mode)
  168. //
  169. extern UINT UpgRequiredMb;
  170. extern UINT UpgAvailableMb;
  171. //
  172. // advanced install options
  173. //
  174. extern BOOL ChoosePartition;
  175. extern BOOL UseSignatures;
  176. extern TCHAR InstallDir[MAX_PATH];
  177. extern TCHAR HeadlessSelection[MAX_PATH];
  178. extern ULONG HeadlessBaudRate;
  179. #ifdef PRERELEASE
  180. extern BOOL AppendDebugDataToBoot;
  181. #endif
  182. //
  183. // SMS support
  184. //
  185. extern PSTR LastMessage;
  186. #if defined(REMOTE_BOOT)
  187. //
  188. // Flag indicating whether we're running on a remote boot client.
  189. //
  190. extern BOOL RemoteBoot;
  191. //
  192. // Path to the machine directory for a remote boot client.
  193. //
  194. extern TCHAR MachineDirectory[MAX_PATH];
  195. #endif // defined(REMOTE_BOOT)
  196. //
  197. // Flags indicating which Accessibility utilities to use
  198. //
  199. extern BOOL AccessibleMagnifier;
  200. extern BOOL AccessibleKeyboard;
  201. extern BOOL AccessibleVoice;
  202. extern BOOL AccessibleReader;
  203. //
  204. // Build number we're upgrading from
  205. //
  206. extern DWORD BuildNumber;
  207. #define NT351 1057
  208. #define NT40 1381
  209. #define NT50B1 1671
  210. #define NT50B3 2031
  211. #define NT50 2195
  212. #define NT51B2 2462
  213. //
  214. // Are any of the Accesssibility utilities enabled?
  215. //
  216. extern BOOL AccessibleSetup;
  217. //
  218. // Flags and values relating to unattended operation.
  219. //
  220. extern BOOL UnattendedOperation;
  221. extern BOOL UnattendSwitchSpecified;
  222. extern PTSTR UnattendedScriptFile;
  223. extern UINT UnattendedShutdownTimeout;
  224. extern UINT UnattendedCountdown;
  225. extern BOOL BatchMode;
  226. //
  227. // Name of unattended script file to be used for Accessible Setup
  228. //
  229. extern TCHAR AccessibleScriptFile[MAX_PATH];
  230. //
  231. // Name of inf file and handles to dosnet.inf and txtsetup.sif.
  232. //
  233. extern TCHAR InfName[MAX_PATH];
  234. extern PVOID MainInf;
  235. extern TCHAR FullInfName[MAX_PATH];
  236. extern PVOID TxtsetupSif;
  237. extern PVOID NtcompatInf;
  238. BOOL
  239. GetMainInfValue (
  240. IN PCTSTR Section,
  241. IN PCTSTR Key,
  242. IN DWORD FieldNumber,
  243. OUT PTSTR Buffer,
  244. IN DWORD BufChars
  245. );
  246. //
  247. // Language options stuff
  248. //
  249. extern BOOL IntlInfProcessed;
  250. extern DWORD PrimaryLocale;
  251. // Global used in WriteParamsFile and AddExternalParams
  252. extern TCHAR ActualParamFile[MAX_PATH];
  253. BOOL InitLangControl(HWND hdlg, BOOL bFarEast);
  254. BOOL IsFarEastLanguage(DWORD LangIdx);
  255. BOOL SelectFarEastLangGroup(BOOL bSelect);
  256. void BB_SetProgressText(LPTSTR szText);
  257. void BB_SetTimeEstimateText(LPTSTR szText);
  258. void BB_SetInfoText(LPTSTR szText);
  259. extern
  260. BOOL
  261. ReadIntlInf(
  262. IN HWND hdlg
  263. );
  264. extern
  265. VOID
  266. SaveLanguageDirs(
  267. );
  268. extern
  269. BOOL
  270. SaveLanguageParams(
  271. IN LPCTSTR FileName
  272. );
  273. extern
  274. VOID
  275. FreeLanguageData(
  276. );
  277. VOID
  278. CleanUpOldLocalSources(
  279. IN HWND hdlg
  280. );
  281. BOOL
  282. InspectFilesystems(
  283. IN HWND hdlg
  284. );
  285. BOOL
  286. LoadInfWorker(
  287. IN HWND hdlg,
  288. IN LPCTSTR FilenamePart,
  289. OUT PVOID *InfHandle,
  290. IN BOOL Winnt32File
  291. );
  292. BOOL
  293. FindLocalSourceAndCheckSpace(
  294. IN HWND hdlg,
  295. IN BOOL QuickTest,
  296. IN LONGLONG AdditionalPadding
  297. );
  298. BOOL
  299. EnoughMemory(
  300. IN HWND hdlg,
  301. IN BOOL QuickTest
  302. );
  303. //
  304. // Optional directory stuff.
  305. //
  306. #define MAX_OPTIONALDIRS 20
  307. extern UINT OptionalDirectoryCount;
  308. extern TCHAR OptionalDirectories[MAX_OPTIONALDIRS][MAX_PATH];
  309. extern UINT OptionalDirectoryFlags[MAX_OPTIONALDIRS];
  310. #define OPTDIR_TEMPONLY 0x00000001
  311. #define OPTDIR_OEMSYS 0x00000002
  312. #define OPTDIR_OVERLAY 0x00000004
  313. #define OPTDIR_ADDSRCARCH 0x00000008
  314. #define OPTDIR_ABSOLUTE 0x00000010
  315. #define OPTDIR_DEBUGGEREXT 0x00000020 // speficies that this optional dir is to be copied to %windir%\system32\pri (for debugger extensions)
  316. // OPTDIR_PLATFORM_INDEP becomes DIR_IS_PLATFORM_INDEPEND and FILE_IN_PLATFORM_INDEPEND_DIR
  317. #define OPTDIR_PLATFORM_INDEP 0x00000040
  318. #define OPTDIR_IN_LOCAL_BOOT 0x00000080
  319. #define OPTDIR_SUPPORT_DYNAMIC_UPDATE 0x00000100
  320. #define OPTDIR_USE_TAIL_FOLDER_NAME 0x00000200
  321. #define OPTDIR_PLATFORM_SPECIFIC_FIRST 0x00000400
  322. #define OPTDIR_DOESNT_SUPPORT_PRIVATES 0x00000800
  323. #define OPTDIR_SIDE_BY_SIDE 0x00001000
  324. //
  325. // Source paths and count of paths.
  326. //
  327. extern TCHAR SourcePaths[MAX_SOURCE_COUNT][MAX_PATH];
  328. extern TCHAR NativeSourcePaths[MAX_SOURCE_COUNT][MAX_PATH];
  329. extern UINT SourceCount;
  330. extern TCHAR *UserSpecifiedOEMShare;
  331. //
  332. // Local source information.
  333. //
  334. #define DEFAULT_INSTALL_DIR TEXT("\\WINDOWS")
  335. #define INTERNAL_WINNT32_DIR TEXT("winnt32")
  336. #define LOCAL_SOURCE_DIR_A "$WIN_NT$.~LS"
  337. #define LOCAL_SOURCE_DIR_W L"$WIN_NT$.~LS"
  338. #define TEXTMODE_INF_A "TXTSETUP.SIF"
  339. #define TEXTMODE_INF_W L"TXTSETUP.SIF"
  340. #define NTCOMPAT_INF_A "COMPDATA\\NTCOMPAT.INF"
  341. #define NTCOMPAT_INF_W L"COMPDATA\\NTCOMPAT.INF"
  342. #define DRVINDEX_INF_A "DRVINDEX.INF"
  343. #define DRVINDEX_INF_W L"DRVINDEX.INF"
  344. #define SETUPP_INI_A "SETUPP.INI"
  345. #define SETUPP_INI_W L"SETUPP.INI"
  346. #define PID_SECTION_A "Pid"
  347. #define PID_SECTION_W L"Pid"
  348. #define PID_KEY_A "Pid"
  349. #define PID_KEY_W L"Pid"
  350. #define OEM_INSTALL_RPC_A "OEM"
  351. #define OEM_INSTALL_RPC_W L"OEM"
  352. #define SELECT_INSTALL_RPC_A "270"
  353. #define SELECT_INSTALL_RPC_W L"270"
  354. #define MSDN_INSTALL_RPC_A "335"
  355. #define MSDN_INSTALL_RPC_W L"335"
  356. #define MSDN_PID30_A "MD97J-QC7R7-TQJGD-3V2WM-W7PVM"
  357. #define MSDN_PID30_W L"MD97J-QC7R7-TQJGD-3V2WM-W7PVM"
  358. #define INF_FILE_HEADER "[Version]\r\nSignature = \"$Windows NT$\"\r\n\r\n"
  359. #ifdef UNICODE
  360. #define LOCAL_SOURCE_DIR LOCAL_SOURCE_DIR_W
  361. #define TEXTMODE_INF TEXTMODE_INF_W
  362. #define NTCOMPAT_INF NTCOMPAT_INF_W
  363. #define DRVINDEX_INF DRVINDEX_INF_W
  364. #define SETUPP_INI SETUPP_INI_W
  365. #define PID_SECTION PID_SECTION_W
  366. #define PID_KEY PID_KEY_W
  367. #define OEM_INSTALL_RPC OEM_INSTALL_RPC_W
  368. #define SELECT_INSTALL_RPC SELECT_INSTALL_RPC_W
  369. #define MSDN_INSTALL_RPC MSDN_INSTALL_RPC_W
  370. #define MSDN_PID30 MSDN_PID30_W
  371. #else
  372. #define LOCAL_SOURCE_DIR LOCAL_SOURCE_DIR_A
  373. #define TEXTMODE_INF TEXTMODE_INF_A
  374. #define NTCOMPAT_INF NTCOMPAT_INF_A
  375. #define DRVINDEX_INF DRVINDEX_INF_A
  376. #define SETUPP_INI SETUPP_INI_A
  377. #define PID_SECTION PID_SECTION_A
  378. #define PID_KEY PID_KEY_A
  379. #define OEM_INSTALL_RPC OEM_INSTALL_RPC_A
  380. #define SELECT_INSTALL_RPC SELECT_INSTALL_RPC_A
  381. #define MSDN_INSTALL_RPC MSDN_INSTALL_RPC_A
  382. #define MSDN_PID30 MSDN_PID30_A
  383. #endif
  384. #ifdef _X86_
  385. #define LOCAL_BOOT_DIR_A "$WIN_NT$.~BT"
  386. #define LOCAL_BOOT_DIR_W L"$WIN_NT$.~BT"
  387. #define AUX_BS_NAME_A "$LDR$"
  388. #define AUX_BS_NAME_W L"$LDR$"
  389. #define FLOPPY_COUNT 4
  390. //
  391. // Local BACKUP information, on NEC98.
  392. //
  393. #define LOCAL_BACKUP_DIR_A "$WIN_NT$.~BU"
  394. #define LOCAL_BACKUP_DIR_W L"$WIN_NT$.~BU"
  395. #ifdef UNICODE
  396. #define LOCAL_BOOT_DIR LOCAL_BOOT_DIR_W
  397. #define AUX_BS_NAME AUX_BS_NAME_W
  398. #define LOCAL_BACKUP_DIR LOCAL_BACKUP_DIR_W
  399. #else
  400. #define LOCAL_BOOT_DIR LOCAL_BOOT_DIR_A
  401. #define AUX_BS_NAME AUX_BS_NAME_A
  402. #define LOCAL_BACKUP_DIR LOCAL_BACKUP_DIR_A
  403. #endif
  404. extern TCHAR LocalBackupDirectory[MAX_PATH];
  405. extern TCHAR FirstFloppyDriveLetter;
  406. #endif
  407. extern DWORD LocalSourceDriveOffset;
  408. extern TCHAR LocalSourceDrive;
  409. extern TCHAR LocalSourceDirectory[MAX_PATH];
  410. extern TCHAR LocalSourceWithPlatform[MAX_PATH];
  411. extern TCHAR LocalBootDirectory[MAX_PATH];
  412. extern BOOL BlockOnNotEnoughSpace;
  413. extern LONGLONG LocalSourceSpaceRequired;
  414. extern LONGLONG WinDirSpaceFor9x;
  415. extern BOOL UpginfsUpdated;
  416. extern BOOL Win95upgInfUpdated;
  417. //
  418. // wizard stuff
  419. //
  420. // wizard page size
  421. #define WIZ_PAGE_SIZE_X 317
  422. #define WIZ_PAGE_SIZE_Y 179
  423. #define BBSTEP_NONE 0
  424. #define BBSTEP_COLLECTING_INFORMATION 1
  425. #define BBSTEP_DYNAMIC_UPDATE 2
  426. #define BBSTEP_PREPARING 3
  427. typedef struct _PAGE_COMMON_DATA {
  428. DLGPROC DialogProcedure;
  429. UINT BillboardStep;
  430. //
  431. // State to initialize buttons to.
  432. //
  433. DWORD Buttons;
  434. UINT Flags;
  435. } PAGE_COMMON_DATA, *PPAGE_COMMON_DATA;
  436. typedef struct _PAGE_CREATE_DATA {
  437. //
  438. // If these are specified, then a range of pages may come
  439. // from somewhere else. Otherwise, it's one page whose
  440. // resource id is given below.
  441. //
  442. LPPROPSHEETPAGE *ExternalPages;
  443. PUINT ExternalPageCount;
  444. UINT Template;
  445. PAGE_COMMON_DATA CommonData;
  446. } PAGE_CREATE_DATA, *PPAGE_CREATE_DATA;
  447. typedef struct _PAGE_RUNTIME_DATA {
  448. PAGE_COMMON_DATA CommonData;
  449. //
  450. // Per-page (private) data
  451. //
  452. DWORD PerPageData;
  453. } PAGE_RUNTIME_DATA, *PPAGE_RUNTIME_DATA;
  454. typedef struct _BITMAP_DATA {
  455. CONST BITMAPINFOHEADER *BitmapInfoHeader;
  456. PVOID BitmapBits;
  457. HPALETTE Palette;
  458. UINT PaletteColorCount;
  459. BOOL Adjusted;
  460. } BITMAP_DATA, *PBITMAP_DATA;
  461. #define WIZPAGE_FULL_PAGE_WATERMARK 0x00000001
  462. #define WIZPAGE_SEPARATOR_CREATED 0x00000002
  463. #define WIZPAGE_NEW_HEADER 0x00000004
  464. //
  465. // compatibility data
  466. //
  467. typedef struct _COMPATIBILITY_DATA {
  468. //
  469. // general
  470. //
  471. LIST_ENTRY ListEntry;
  472. //
  473. // what type of entry
  474. //
  475. TCHAR Type;
  476. //
  477. // service-driver data
  478. //
  479. LPCTSTR ServiceName;
  480. //
  481. // registry data
  482. //
  483. LPCTSTR RegKey;
  484. LPCTSTR RegValue;
  485. LPCTSTR RegValueExpect;
  486. //
  487. // file data
  488. //
  489. LPCTSTR FileName;
  490. LPCTSTR FileVer;
  491. //
  492. // common
  493. //
  494. LPCTSTR Description;
  495. LPCTSTR HtmlName;
  496. LPCTSTR TextName;
  497. LPTSTR RegKeyName;
  498. LPTSTR RegValName;
  499. LPVOID RegValData;
  500. DWORD RegValDataSize;
  501. LPVOID SaveValue;
  502. DWORD Flags;
  503. LPCTSTR InfName;
  504. LPCTSTR InfSection;
  505. HMODULE hModDll;
  506. PCOMPAIBILITYHAVEDISK CompHaveDisk;
  507. } COMPATIBILITY_DATA, *PCOMPATIBILITY_DATA;
  508. extern LIST_ENTRY CompatibilityData;
  509. extern DWORD CompatibilityCount;
  510. extern DWORD IncompatibilityStopsInstallation;
  511. extern BOOL AnyNt5CompatDlls;
  512. BOOL
  513. AnyBlockingCompatibilityItems (
  514. VOID
  515. );
  516. //
  517. // Plug and Play device migration routines.
  518. // (linked into winnt.dll from pnpsif.lib)
  519. //
  520. BOOL
  521. MigrateDeviceInstanceData(
  522. OUT LPTSTR *Buffer
  523. );
  524. BOOL
  525. MigrateClassKeys(
  526. OUT LPTSTR *Buffer
  527. );
  528. BOOL
  529. MigrateHashValues(
  530. OUT LPTSTR *Buffer
  531. );
  532. //
  533. // Array of drive letters for all system partitions.
  534. // Note that on x86 there will always be exactly one.
  535. // The list is 0-terminated.
  536. //
  537. extern TCHAR SystemPartitionDriveLetters[27];
  538. extern TCHAR SystemPartitionDriveLetter;
  539. #ifdef UNICODE
  540. extern UINT SystemPartitionCount;
  541. extern PWSTR* SystemPartitionNtNames;
  542. extern PWSTR SystemPartitionNtName;
  543. extern PWSTR SystemPartitionVolumeGuid;
  544. #else
  545. extern PCSTR g_LocalSourcePath;
  546. #endif
  547. //
  548. // UDF stuff
  549. //
  550. extern LPCTSTR UniquenessId;
  551. extern LPCTSTR UniquenessDatabaseFile;
  552. //
  553. // Preinstall stuff
  554. //
  555. extern BOOL OemPreinstall;
  556. #ifdef _X86_
  557. typedef struct _OEM_BOOT_FILE {
  558. struct _OEM_BOOT_FILE *Next;
  559. LPCTSTR Filename;
  560. } OEM_BOOT_FILE, *POEM_BOOT_FILE;
  561. extern POEM_BOOT_FILE OemBootFiles;
  562. #endif
  563. extern TCHAR ForcedSystemPartition;
  564. //
  565. // Miscellaneous other command line parameters.
  566. //
  567. extern LPCTSTR CmdToExecuteAtEndOfGui;
  568. extern BOOL AutoSkipMissingFiles;
  569. extern BOOL HideWinDir;
  570. extern TCHAR ProductId[64];
  571. //
  572. // Flag indicating that the user cancelled.
  573. // Flag indicating that a succssessful abort should be performed.
  574. // Handle for mutex used to guarantee that only one error dialog
  575. // is on the screen at once.
  576. //
  577. extern BOOL Cancelled;
  578. extern BOOL CancelPending;
  579. extern BOOL Aborted;
  580. extern HANDLE UiMutex;
  581. //
  582. // This indicates that well give the user some detailed data-throughput
  583. // info.
  584. //
  585. extern BOOL DetailedCopyProgress;
  586. extern ULONGLONG TotalDataCopied;
  587. //
  588. // Upgrade Options variables. Used to pass a multistring of
  589. // upgrade command line options to the plugin DLLs.
  590. //
  591. extern LPTSTR UpgradeOptions;
  592. extern DWORD UpgradeOptionsLength;
  593. extern DWORD UpgradeOptionsSize;
  594. BOOL
  595. AppendUpgradeOption (
  596. IN PCTSTR String
  597. );
  598. #ifdef _X86_
  599. //
  600. // Win9x upgrade report status
  601. //
  602. extern UINT g_UpgradeReportMode;
  603. #endif
  604. //
  605. // Compliance variables
  606. //
  607. extern BOOL NoCompliance;
  608. extern BOOL NoBuildCheck;
  609. // UpgradeOnly is true is the media is CCP media and only valid
  610. // to upgrade a system. eula.c will use this to ensure that an
  611. // FPP pid is not used with CCP media and vice-versa
  612. extern BOOL UpgradeOnly;
  613. extern BOOL SkipLocaleCheck;
  614. extern BOOL SkipVirusScannerCheck;
  615. extern BOOL UseBIOSToBoot;
  616. //
  617. // TargetNativeLangID : this is native language ID of running system
  618. //
  619. extern LANGID TargetNativeLangID;
  620. //
  621. // SourceNativeLangID : this is native language ID of new NT you want to install
  622. //
  623. extern LANGID SourceNativeLangID;
  624. //
  625. // IsLanguageMatched : if source and target language are matched (or compatible)
  626. //
  627. // 1. if SourceNativeLangID == TargetNativeLangID
  628. //
  629. // 2. if SourceNativeLangID's alternative ID == TargetNativeLangID
  630. //
  631. extern BOOL IsLanguageMatched;
  632. BOOL
  633. InitLanguageDetection(
  634. LPCTSTR SourcePath,
  635. LPCTSTR InfFile
  636. );
  637. //
  638. // Routines from Setupapi.dll
  639. //
  640. extern
  641. BOOL
  642. (*SetupapiCabinetRoutine)(
  643. IN LPCTSTR CabinetFile,
  644. IN DWORD Flags,
  645. IN PSP_FILE_CALLBACK MsgHandler,
  646. IN PVOID Context
  647. );
  648. extern
  649. DWORD
  650. (*SetupapiDecompressOrCopyFile)(
  651. IN PCTSTR SourceFileName,
  652. OUT PCTSTR TargetFileName,
  653. OUT PUINT CompressionType OPTIONAL
  654. );
  655. extern
  656. HINF
  657. (*SetupapiOpenInfFile)(
  658. IN LPCTSTR FileName,
  659. IN LPCTSTR InfClass, OPTIONAL
  660. IN DWORD InfStyle,
  661. OUT PUINT ErrorLine OPTIONAL
  662. );
  663. extern
  664. VOID
  665. (*SetupapiCloseInfFile)(
  666. IN HINF InfHandle
  667. );
  668. extern
  669. BOOL
  670. (*SetupapiFindFirstLine)(
  671. IN HINF InfHandle,
  672. IN PCTSTR Section,
  673. IN PCTSTR Key, OPTIONAL
  674. OUT PINFCONTEXT Context
  675. );
  676. extern
  677. BOOL
  678. (*SetupapiFindNextLine)(
  679. PINFCONTEXT ContextIn,
  680. PINFCONTEXT ContextOut
  681. );
  682. extern
  683. BOOL
  684. (*SetupapiFindNextMatchLine)(
  685. PINFCONTEXT ContextIn,
  686. PCTSTR Key,
  687. PINFCONTEXT ContextOut
  688. );
  689. extern
  690. LONG
  691. (*SetupapiGetLineCount)(
  692. IN HINF InfHandle,
  693. IN LPCTSTR Section
  694. );
  695. extern
  696. DWORD
  697. (*SetupapiGetFieldCount)(
  698. IN PINFCONTEXT Context
  699. );
  700. extern
  701. BOOL
  702. (*SetupapiGetStringField)(
  703. IN PINFCONTEXT Context,
  704. DWORD FieldIndex,
  705. PTSTR ReturnBuffer,
  706. DWORD ReturnBufferSize,
  707. PDWORD RequiredSize
  708. );
  709. extern
  710. BOOL
  711. (*SetupapiGetLineByIndex)(
  712. IN HINF InfHandle,
  713. IN LPCTSTR Section,
  714. IN DWORD Index,
  715. OUT PINFCONTEXT Context
  716. );
  717. extern
  718. HSPFILEQ
  719. (*SetupapiOpenFileQueue) (
  720. VOID
  721. );
  722. extern
  723. BOOL
  724. (*SetupapiCloseFileQueue) (
  725. IN HSPFILEQ QueueHandle
  726. );
  727. extern
  728. BOOL
  729. (*SetupapiQueueCopy) (
  730. IN HSPFILEQ QueueHandle,
  731. IN PCTSTR SourceRootPath, OPTIONAL
  732. IN PCTSTR SourcePath, OPTIONAL
  733. IN PCTSTR SourceFilename,
  734. IN PCTSTR SourceDescription, OPTIONAL
  735. IN PCTSTR SourceTagfile, OPTIONAL
  736. IN PCTSTR TargetDirectory,
  737. IN PCTSTR TargetFilename, OPTIONAL
  738. IN DWORD CopyStyle
  739. );
  740. extern
  741. BOOL
  742. (*SetupapiCommitFileQueue) (
  743. IN HWND Owner, OPTIONAL
  744. IN HSPFILEQ QueueHandle,
  745. IN PSP_FILE_CALLBACK_W MsgHandler,
  746. IN PVOID Context
  747. );
  748. extern
  749. UINT
  750. (*SetupapiDefaultQueueCallback) (
  751. IN PVOID Context,
  752. IN UINT Notification,
  753. IN UINT_PTR Param1,
  754. IN UINT_PTR Param2
  755. );
  756. extern
  757. PVOID
  758. (*SetupapiInitDefaultQueueCallback) (
  759. HWND OwnerWindow
  760. );
  761. extern
  762. VOID
  763. (*SetupapiTermDefaultQueueCallback) (
  764. PVOID Context
  765. );
  766. //
  767. // Custom window messages. Define so they don't overlap with
  768. // any being used by plug-in dll's.
  769. //
  770. #define WMX_EDITCONTROLSTATE (WMX_PLUGIN_FIRST-1)
  771. #define WMX_INSPECTRESULT (WMX_PLUGIN_FIRST-2)
  772. //#define WMX_SETPROGRESSTEXT (WMX_PLUGIN_FIRST-3)
  773. #define WMX_ERRORMESSAGEUP (WMX_PLUGIN_FIRST-4)
  774. #define WMX_I_AM_VISIBLE (WMX_PLUGIN_FIRST-5)
  775. #define WMX_COPYPROGRESS (WMX_PLUGIN_FIRST-6)
  776. #define WMX_I_AM_DONE (WMX_PLUGIN_FIRST-7)
  777. #define WMX_FINISHBUTTON (WMX_PLUGIN_FIRST-8)
  778. #define WMX_UNATTENDED (WMX_PLUGIN_FIRST-9)
  779. #define WMX_NEXTBUTTON (WMX_PLUGIN_FIRST-10)
  780. #define WMX_BACKBUTTON (WMX_PLUGIN_FIRST-11)
  781. #define WMX_VALIDATE (WMX_PLUGIN_FIRST-12)
  782. #define WMX_SETUPUPDATE_PREPARING (WMX_PLUGIN_FIRST-13)
  783. #define WMX_SETUPUPDATE_DOWNLOADING (WMX_PLUGIN_FIRST-14)
  784. #define WMX_SETUPUPDATE_PROCESSING (WMX_PLUGIN_FIRST-15)
  785. #define WMX_SETUPUPDATE_DONE (WMX_PLUGIN_FIRST-16)
  786. #define WMX_SETUPUPDATE_CANCEL (WMX_PLUGIN_FIRST-17)
  787. #define WMX_SETUPUPDATE_INIT_RETRY (WMX_PLUGIN_FIRST-18)
  788. #define WMX_SETUPUPDATE_THREAD_DONE (WMX_PLUGIN_FIRST-19)
  789. #ifdef RUN_SYSPARSE
  790. #define WMX_SYSPARSE_DONE (WMX_PLUGIN_FIRST-20)
  791. #endif
  792. #define WMX_DYNAMIC_UPDATE_COMPLETE (WMX_PLUGIN_FIRST-21)
  793. //
  794. // Helper macro for uppercasing
  795. //
  796. #define TOUPPER(x) (TCHAR)CharUpper((LPTSTR)x)
  797. //
  798. // Routine that does everything by starting the wizard.
  799. //
  800. VOID
  801. Wizard(
  802. VOID
  803. );
  804. //
  805. // Routine that builds a cmdcons installation.
  806. //
  807. VOID
  808. DoBuildCmdcons(
  809. VOID
  810. );
  811. VOID
  812. FixUpWizardTitle(
  813. IN HWND Wizard
  814. );
  815. //
  816. // Cleanup routine and globals used by the cleanup stuff.
  817. //
  818. DWORD
  819. StartCleanup(
  820. IN PVOID ThreadParameter
  821. );
  822. #ifdef _X86_
  823. BOOL
  824. RestoreBootSector(
  825. VOID
  826. );
  827. BOOL
  828. RestoreBootIni(
  829. VOID
  830. );
  831. BOOL
  832. SaveRestoreBootFiles_NEC98(
  833. IN UCHAR Flag
  834. );
  835. #define NEC98SAVEBOOTFILES 0
  836. #define NEC98RESTOREBOOTFILES 1
  837. BOOL
  838. IsDriveAssignNEC98(
  839. VOID
  840. );
  841. //
  842. // Check ATA Drive
  843. //
  844. BOOLEAN
  845. CheckATACardonNT4(
  846. HANDLE hDisk
  847. );
  848. //
  849. // Check formatted drive type
  850. //
  851. BOOLEAN
  852. IsValidDrive(
  853. TCHAR Drive
  854. );
  855. #endif //_X86_
  856. BOOL
  857. RestoreNvRam(
  858. VOID
  859. );
  860. //
  861. // Thread that inspects sources, loads infs, builds the copy list,
  862. // checks disk space, etc. And some worker routines.
  863. //
  864. DWORD
  865. InspectAndLoadThread(
  866. IN PVOID ThreadParam
  867. );
  868. BOOL
  869. InspectSources(
  870. IN HWND ParentWnd
  871. );
  872. BOOL
  873. BuildCopyListWorker(
  874. IN HWND hdlg
  875. );
  876. BOOL
  877. FindLocalSourceAndCheckSpaceWorker(
  878. IN HWND hdlg,
  879. IN BOOL QuickTest,
  880. IN LONGLONG AdditionalPadding
  881. );
  882. UINT
  883. GetTotalFileCount(
  884. VOID
  885. );
  886. DWORD
  887. StartCopyingThread(
  888. IN PVOID ThreadParameter
  889. );
  890. VOID
  891. CancelledMakeSureCopyThreadsAreDead(
  892. VOID
  893. );
  894. DWORD
  895. DoPostCopyingStuff(
  896. IN PVOID ThreadParam
  897. );
  898. //
  899. // File copy error routine and outcomes.
  900. //
  901. UINT
  902. FileCopyError(
  903. IN HWND ParentWindow,
  904. IN LPCTSTR SourceFilename,
  905. IN LPCTSTR TargetFilename,
  906. IN UINT Win32Error,
  907. IN BOOL MasterList
  908. );
  909. #define COPYERR_SKIP 1
  910. #define COPYERR_EXIT 2
  911. #define COPYERR_RETRY 3
  912. //
  913. // Routine to add an optional directory to the list of dirs
  914. // we copy.
  915. //
  916. BOOL
  917. RememberOptionalDir(
  918. IN LPCTSTR Directory,
  919. IN UINT Flags
  920. );
  921. //
  922. // Resource utility routines.
  923. //
  924. PCTSTR
  925. GetStringResource (
  926. IN UINT Id // ID or pointer to string name
  927. );
  928. VOID
  929. FreeStringResource (
  930. IN PCTSTR String
  931. );
  932. VOID
  933. SaveMessageForSMS(
  934. IN DWORD MessageId,
  935. ...
  936. );
  937. VOID
  938. SaveTextForSMS(
  939. IN PCTSTR Buffer
  940. );
  941. int
  942. MessageBoxFromMessage(
  943. IN HWND Window,
  944. IN DWORD MessageId,
  945. IN BOOL SystemMessage,
  946. IN DWORD CaptionStringId,
  947. IN UINT Style,
  948. ...
  949. );
  950. int
  951. MessageBoxFromMessageV(
  952. IN HWND Window,
  953. IN DWORD MessageId,
  954. IN BOOL SystemMessage,
  955. IN DWORD CaptionStringId,
  956. IN UINT Style,
  957. IN va_list *Args
  958. );
  959. int
  960. MessageBoxFromMessageWithSystem(
  961. IN HWND Window,
  962. IN DWORD MessageId,
  963. IN DWORD CaptionStringId,
  964. IN UINT Style,
  965. IN HMODULE hMod
  966. );
  967. int
  968. MessageBoxFromMessageAndSystemError(
  969. IN HWND Window,
  970. IN DWORD MessageId,
  971. IN DWORD SystemMessageId,
  972. IN DWORD CaptionStringId,
  973. IN UINT Style,
  974. ...
  975. );
  976. HBITMAP
  977. LoadResourceBitmap(
  978. IN HINSTANCE hInst,
  979. IN LPCTSTR Id,
  980. OUT HPALETTE *Palette
  981. );
  982. BOOL
  983. GetBitmapDataAndPalette(
  984. IN HINSTANCE hInst,
  985. IN LPCTSTR Id,
  986. OUT HPALETTE *Palette,
  987. OUT PUINT ColorCount,
  988. OUT CONST BITMAPINFOHEADER **BitmapData
  989. );
  990. UINT
  991. GetYPositionOfDialogItem(
  992. IN LPCTSTR Dialog,
  993. IN UINT ControlId
  994. );
  995. //
  996. // Security routines.
  997. //
  998. BOOL
  999. IsUserAdmin(
  1000. VOID
  1001. );
  1002. BOOL
  1003. DoesUserHavePrivilege(
  1004. PTSTR PrivilegeName
  1005. );
  1006. BOOL
  1007. EnablePrivilege(
  1008. IN PTSTR PrivilegeName,
  1009. IN BOOL Enable
  1010. );
  1011. //
  1012. // Inf routines.
  1013. //
  1014. DWORD
  1015. LoadInfFile(
  1016. IN LPCTSTR Filename,
  1017. IN BOOL OemCodepage,
  1018. OUT PVOID *InfHandle
  1019. );
  1020. VOID
  1021. UnloadInfFile(
  1022. IN PVOID InfHandle
  1023. );
  1024. LONG
  1025. InfGetSectionLineCount(
  1026. IN PVOID INFHandle,
  1027. IN PTSTR SectionName
  1028. );
  1029. LPCTSTR
  1030. InfGetFieldByIndex(
  1031. IN PVOID INFHandle,
  1032. IN LPCTSTR SectionName,
  1033. IN unsigned LineIndex,
  1034. IN unsigned ValueIndex
  1035. );
  1036. LPCTSTR
  1037. InfGetFieldByKey(
  1038. IN PVOID INFHandle,
  1039. IN LPCTSTR SectionName,
  1040. IN LPCTSTR Key,
  1041. IN unsigned ValueIndex
  1042. );
  1043. BOOL
  1044. InfDoesLineExistInSection(
  1045. IN PVOID INFHandle,
  1046. IN LPCTSTR SectionName,
  1047. IN LPCTSTR Key
  1048. );
  1049. BOOL
  1050. InfDoesEntryExistInSection (
  1051. IN PVOID INFHandle,
  1052. IN LPCTSTR SectionName,
  1053. IN LPCTSTR Entry
  1054. );
  1055. LPCTSTR
  1056. InfGetLineKeyName(
  1057. IN PVOID INFHandle,
  1058. IN LPCTSTR SectionName,
  1059. IN unsigned LineIndex
  1060. );
  1061. typedef struct {
  1062. // Caller members (read-only)
  1063. PCTSTR FieldZeroData;
  1064. unsigned LineIndex;
  1065. // Internal members
  1066. PVOID InfHandle;
  1067. PCTSTR SectionName;
  1068. } INF_ENUM, *PINF_ENUM;
  1069. BOOL
  1070. EnumFirstInfLine (
  1071. OUT PINF_ENUM InfEnum,
  1072. IN PVOID InfHandle,
  1073. IN PCTSTR InfSection
  1074. );
  1075. BOOL
  1076. EnumNextInfLine (
  1077. IN OUT PINF_ENUM InfEnum
  1078. );
  1079. VOID
  1080. AbortInfLineEnum (
  1081. IN PINF_ENUM InfEnum // ZEROED
  1082. );
  1083. //
  1084. // Routines to manipulate parameters files like unattend.txt,
  1085. // the param file we pass to text mode setup, etc.
  1086. //
  1087. BOOL
  1088. WriteParametersFile(
  1089. IN HWND ParentWindow
  1090. );
  1091. BOOL
  1092. AddExternalParams(
  1093. IN HWND ParentWindow
  1094. );
  1095. //
  1096. // Miscellaenous utility routines.
  1097. //
  1098. LPTSTR *
  1099. CommandLineToArgv(
  1100. OUT int *NumArgs
  1101. );
  1102. VOID
  1103. MyWinHelp(
  1104. IN HWND Window,
  1105. IN UINT Command,
  1106. IN ULONG_PTR Data
  1107. );
  1108. VOID
  1109. ConcatenatePaths(
  1110. IN OUT PTSTR Path1,
  1111. IN LPCTSTR Path2,
  1112. IN DWORD BufferSizeChars
  1113. );
  1114. LPTSTR
  1115. DupString(
  1116. IN LPCTSTR String
  1117. );
  1118. UINT
  1119. MyGetDriveType(
  1120. IN TCHAR Drive
  1121. );
  1122. #ifdef UNICODE
  1123. UINT
  1124. MyGetDriveType2 (
  1125. IN PCWSTR NtDeviceName
  1126. );
  1127. BOOL
  1128. MyGetDiskFreeSpace (
  1129. IN PCWSTR NtVolumeName,
  1130. IN PDWORD SectorsPerCluster,
  1131. IN PDWORD BytesPerSector,
  1132. IN PDWORD NumberOfFreeClusters,
  1133. IN PDWORD TotalNumberOfClusters
  1134. );
  1135. #endif
  1136. BOOL
  1137. GetPartitionInfo(
  1138. IN TCHAR Drive,
  1139. OUT PPARTITION_INFORMATION PartitionInfo
  1140. );
  1141. BOOL
  1142. IsDriveNTFT(
  1143. IN TCHAR Drive,
  1144. IN PCTSTR NtVolumeName
  1145. );
  1146. BOOL
  1147. IsDriveVeritas(
  1148. IN TCHAR Drive,
  1149. IN PCTSTR NtVolumeName
  1150. );
  1151. #ifdef UNICODE
  1152. BOOL
  1153. IsSoftPartition(
  1154. IN TCHAR Drive,
  1155. IN PCTSTR NtVolumeName
  1156. );
  1157. #else
  1158. #define IsSoftPartition(d,n) (FALSE)
  1159. #endif
  1160. BOOL
  1161. IsDriveNTFS(
  1162. IN TCHAR Drive
  1163. );
  1164. BOOL
  1165. IsMachineSupported(
  1166. OUT PCOMPATIBILITY_ENTRY CompEntry
  1167. );
  1168. BOOL
  1169. GetAndSaveNTFTInfo(
  1170. IN HWND ParentWindow
  1171. );
  1172. VOID
  1173. ForceStickyDriveLetters(
  1174. );
  1175. DWORD
  1176. MapFileForRead(
  1177. IN LPCTSTR FileName,
  1178. OUT PDWORD FileSize,
  1179. OUT PHANDLE FileHandle,
  1180. OUT PHANDLE MappingHandle,
  1181. OUT PVOID *BaseAddress
  1182. );
  1183. DWORD
  1184. UnmapFile(
  1185. IN HANDLE MappingHandle,
  1186. IN PVOID BaseAddress
  1187. );
  1188. VOID
  1189. GenerateCompressedName(
  1190. IN LPCTSTR Filename,
  1191. OUT LPTSTR CompressedName
  1192. );
  1193. DWORD
  1194. CreateMultiLevelDirectory(
  1195. IN LPCTSTR Directory
  1196. );
  1197. VOID
  1198. MyDelnode(
  1199. IN LPCTSTR Directory
  1200. );
  1201. BOOL
  1202. ForceFileNoCompress(
  1203. IN LPCTSTR Filename
  1204. );
  1205. BOOL
  1206. IsCurrentOsServer(
  1207. void
  1208. );
  1209. BOOL
  1210. IsCurrentAdvancedServer(
  1211. void
  1212. );
  1213. BOOL
  1214. IsNTFSConversionRecommended(
  1215. void
  1216. );
  1217. BOOL
  1218. ForceBootFilesUncompressed(
  1219. IN HWND ParentWindow,
  1220. IN BOOL TellUserAboutError
  1221. );
  1222. BOOLEAN
  1223. AdjustPrivilege(
  1224. PCTSTR Privilege
  1225. );
  1226. BOOL
  1227. GetUserPrintableFileSizeString(
  1228. IN DWORDLONG Size,
  1229. OUT LPTSTR Buffer,
  1230. IN DWORD BufferSize
  1231. );
  1232. BOOL
  1233. FileExists(
  1234. IN PCTSTR FileName,
  1235. OUT PWIN32_FIND_DATA FindData OPTIONAL
  1236. );
  1237. BOOL
  1238. DoesDirectoryExist (
  1239. IN PCTSTR DirSpec
  1240. );
  1241. BOOL
  1242. InDriverCacheInf(
  1243. IN PVOID InfHandle,
  1244. IN PCTSTR FileName,
  1245. OUT PTSTR DriverCabName, OPTIONAL
  1246. IN DWORD BufferChars OPTIONAL
  1247. );
  1248. BOOL
  1249. BuildSystemPartitionPathToFile (
  1250. IN PCTSTR FileName,
  1251. OUT PTSTR Path,
  1252. IN DWORD BufferSizeChars
  1253. );
  1254. BOOL
  1255. FindPathToInstallationFileEx (
  1256. IN PCTSTR FileName,
  1257. OUT PTSTR PathToFile,
  1258. IN DWORD PathToFileBufferSize,
  1259. OUT PBOOL Compressed OPTIONAL
  1260. );
  1261. #define FindPathToInstallationFile(n,p,s) FindPathToInstallationFileEx(n,p,s,NULL)
  1262. BOOL
  1263. FindPathToWinnt32File (
  1264. IN PCTSTR FileRelativePath,
  1265. OUT PTSTR PathToFile,
  1266. IN DWORD PathToFileBufferSize
  1267. );
  1268. BOOL
  1269. GetFileVersion (
  1270. IN PCTSTR FilePath,
  1271. OUT PTSTR FileVersion
  1272. );
  1273. //
  1274. // #define to use MyPrivateProfileString to get around virus checkers monitoring operations to C
  1275. // drive that cause us to fail WritePrivateProfileString
  1276. // The problem is that usually these s/w examine the files we touch and in somecases open it
  1277. // with exclusive access. We just need to wait for them to be done.
  1278. //
  1279. BOOL
  1280. MyWritePrivateProfileString(
  1281. LPCTSTR lpAppName, // pointer to section name
  1282. LPCTSTR lpKeyName, // pointer to key name
  1283. LPCTSTR lpString, // pointer to string to add
  1284. LPCTSTR lpFileName // pointer to initialization filename
  1285. );
  1286. #ifdef UNICODE
  1287. #define WritePrivateProfileStringW(w,x,y,z) MyWritePrivateProfileString(w,x,y,z)
  1288. #else
  1289. #define WritePrivateProfileStringA(w,x,y,z) MyWritePrivateProfileString(w,x,y,z)
  1290. #endif
  1291. //
  1292. // Routines having to do with advanced program options
  1293. //
  1294. VOID
  1295. InitVariousOptions(
  1296. VOID
  1297. );
  1298. VOID
  1299. DoOptions(
  1300. IN HWND Parent
  1301. );
  1302. VOID
  1303. DoLanguage(
  1304. IN HWND Parent
  1305. );
  1306. VOID
  1307. DoAccessibility(
  1308. IN HWND Parent
  1309. );
  1310. BOOL
  1311. BrowseForDosnetInf(
  1312. IN HWND hdlg,
  1313. IN LPCTSTR InitialPath,
  1314. OUT TCHAR NewPath[MAX_PATH]
  1315. );
  1316. BOOL
  1317. IsValid8Dot3(
  1318. IN LPCTSTR Path
  1319. );
  1320. //
  1321. // Routines having to do with eula and pid
  1322. //
  1323. #define MAX_PID30_EDIT 5
  1324. extern LPTSTR g_EncryptedPID;
  1325. extern BOOL g_bDeferPIDValidation;
  1326. extern BOOL EulaComplete;
  1327. typedef enum InstallType
  1328. {
  1329. SelectInstall,
  1330. OEMInstall,
  1331. RetailInstall
  1332. };
  1333. VOID
  1334. GetSourceInstallType(
  1335. OUT OPTIONAL PDWORD InstallVariation
  1336. );
  1337. BOOL
  1338. SetPid30(
  1339. HWND hdlg,
  1340. LONG ExpectedPidType,
  1341. LPTSTR pProductId
  1342. );
  1343. #ifdef UNICODE
  1344. PCHAR
  1345. FindRealHalName(
  1346. TCHAR *pHalFileName
  1347. );
  1348. #endif
  1349. //
  1350. // Debugging and logging
  1351. //
  1352. typedef enum {
  1353. Winnt32LogSevereError,
  1354. Winnt32LogError,
  1355. Winnt32LogWarning,
  1356. Winnt32LogInformation,
  1357. Winnt32LogDetailedInformation,
  1358. Winnt32LogMax
  1359. #define WINNT32_HARDWARE_LOG 0x40000000
  1360. } Winnt32DebugLevel;
  1361. extern Winnt32DebugLevel DebugLevel;
  1362. BOOL
  1363. StartDebugLog(
  1364. IN LPCTSTR DebugFileLog,
  1365. IN Winnt32DebugLevel Level
  1366. );
  1367. VOID
  1368. CloseDebugLog(
  1369. VOID
  1370. );
  1371. BOOL
  1372. DebugLog(
  1373. IN Winnt32DebugLevel Level,
  1374. IN LPCTSTR Text, OPTIONAL
  1375. IN UINT MessageId,
  1376. ...
  1377. );
  1378. BOOL
  1379. DebugLog2(
  1380. IN Winnt32DebugLevel Level,
  1381. IN LPCTSTR Text, OPTIONAL
  1382. IN UINT MessageId,
  1383. IN va_list ArgList
  1384. );
  1385. BOOL
  1386. DynUpdtDebugLog(
  1387. IN Winnt32DebugLevel Level,
  1388. IN LPCTSTR Text,
  1389. IN UINT MessageId,
  1390. ...
  1391. );
  1392. BOOL
  1393. ConcatenateFile(
  1394. IN HANDLE hOpenFile,
  1395. IN LPTSTR FileName
  1396. );
  1397. VOID
  1398. GatherOtherLogFiles(
  1399. VOID
  1400. );
  1401. //
  1402. // Memory allocation.
  1403. //
  1404. #define MALLOC(s) malloc(s)
  1405. #define FREE(b) free(b)
  1406. #define REALLOC(b,s) realloc((b),(s))
  1407. //
  1408. // Floppy-related stuff.
  1409. //
  1410. extern BOOL MakeBootMedia;
  1411. extern BOOL Floppyless;
  1412. //
  1413. // boot loader timeout value, in string form
  1414. //
  1415. extern TCHAR Timeout[32];
  1416. #ifdef _X86_
  1417. UINT
  1418. FloppyGetTotalFileCount(
  1419. VOID
  1420. );
  1421. DWORD
  1422. FloppyWorkerThread(
  1423. IN PVOID ThreadParameter
  1424. );
  1425. //
  1426. // Routine to lay NT boot code, munge boot.ini, create aux boot sector, etc.
  1427. //
  1428. BOOL
  1429. DoX86BootStuff(
  1430. IN HWND ParentWindow
  1431. );
  1432. BOOL
  1433. PatchTextIntoBootCode(
  1434. VOID
  1435. );
  1436. VOID
  1437. MigrateBootIniData();
  1438. //
  1439. // Drive information abstraction
  1440. //
  1441. typedef struct _WINNT32_DRIVE_INFORMATION {
  1442. DWORD CylinderCount;
  1443. DWORD HeadCount;
  1444. DWORD SectorsPerTrack;
  1445. ULONGLONG SectorCount;
  1446. WORD BytesPerSector;
  1447. } WINNT32_DRIVE_INFORMATION, *PWINNT32_DRIVE_INFORMATION;
  1448. //
  1449. // Routine to get drive form-factor/type.
  1450. //
  1451. MEDIA_TYPE
  1452. GetMediaType(
  1453. IN TCHAR Drive,
  1454. IN PWINNT32_DRIVE_INFORMATION DriveInfo OPTIONAL
  1455. );
  1456. //
  1457. // Disk sector I/O routines
  1458. //
  1459. BOOL
  1460. ReadDiskSectors(
  1461. IN TCHAR Drive,
  1462. IN UINT StartSector,
  1463. IN UINT SectorCount,
  1464. IN UINT SectorSize,
  1465. OUT LPBYTE Buffer
  1466. );
  1467. BOOL
  1468. WriteDiskSectors(
  1469. IN TCHAR Drive,
  1470. IN UINT StartSector,
  1471. IN UINT SectorCount,
  1472. IN UINT SectorSize,
  1473. IN LPBYTE Buffer
  1474. );
  1475. BOOL
  1476. MarkPartitionActive(
  1477. IN TCHAR DriveLetter
  1478. );
  1479. //
  1480. // Enum for filesystems we recognize
  1481. //
  1482. typedef enum {
  1483. Winnt32FsUnknown,
  1484. Winnt32FsFat,
  1485. Winnt32FsFat32,
  1486. Winnt32FsNtfs
  1487. } WINNT32_SYSPART_FILESYSTEM;
  1488. //
  1489. // Hardcoded constant for sector size, and sizes
  1490. // of bootcode areas for various filesystems.
  1491. //
  1492. #define WINNT32_SECTOR_SIZE 512
  1493. #define WINNT32_FAT_BOOT_SECTOR_COUNT 1
  1494. #define WINNT32_NTFS_BOOT_SECTOR_COUNT 16
  1495. #define WINNT32_MAX_BOOT_SIZE (16*WINNT32_SECTOR_SIZE)
  1496. BOOL
  1497. PatchBootCode(
  1498. IN WINNT32_SYSPART_FILESYSTEM FileSystem,
  1499. IN TCHAR Drive,
  1500. IN OUT PUCHAR BootCode,
  1501. IN DWORD BootCodeSize
  1502. );
  1503. #endif //_X86_
  1504. //
  1505. // ARC/NV-RAM stuff
  1506. //
  1507. #if defined _IA64_
  1508. #define SETUPLDR_FILENAME L"SETUPLDR.EFI"
  1509. #elif defined _X86_
  1510. #define SETUPLDR_FILENAME L"arcsetup.exe"
  1511. #else
  1512. #define SETUPLDR_FILENAME L"SETUPLDR"
  1513. #endif
  1514. BOOL
  1515. SetUpNvRam(
  1516. IN HWND ParentWindow
  1517. );
  1518. DWORD
  1519. DriveLetterToArcPath(
  1520. IN WCHAR DriveLetter,
  1521. OUT LPWSTR *ArcPath
  1522. );
  1523. //
  1524. // Implement a terminalserver-safe GetWindowsDirectory()
  1525. //
  1526. UINT
  1527. MyGetWindowsDirectory(
  1528. LPTSTR MyBuffer,
  1529. UINT Size
  1530. );
  1531. //
  1532. // Upgrade stuff
  1533. //
  1534. typedef struct _UPGRADE_SUPPORT {
  1535. TCHAR DllPath[MAX_PATH];
  1536. HINSTANCE DllModuleHandle;
  1537. UINT AfterWelcomePageCount;
  1538. LPPROPSHEETPAGE Pages1;
  1539. UINT AfterOptionsPageCount;
  1540. LPPROPSHEETPAGE Pages2;
  1541. UINT BeforeCopyPageCount;
  1542. LPPROPSHEETPAGE Pages3;
  1543. PWINNT32_PLUGIN_INIT_ROUTINE InitializeRoutine;
  1544. PWINNT32_PLUGIN_GETPAGES_ROUTINE GetPagesRoutine;
  1545. PWINNT32_PLUGIN_WRITEPARAMS_ROUTINE WriteParamsRoutine;
  1546. PWINNT32_PLUGIN_CLEANUP_ROUTINE CleanupRoutine;
  1547. PWINNT32_PLUGIN_OPTIONAL_DIRS_ROUTINE OptionalDirsRoutine;
  1548. } UPGRADE_SUPPORT, *PUPGRADE_SUPPORT;
  1549. extern UPGRADE_SUPPORT UpgradeSupport;
  1550. //
  1551. // Only check to see if we can upgrade or not.
  1552. //
  1553. extern BOOL CheckUpgradeOnly;
  1554. extern BOOL CheckUpgradeOnlyQ;
  1555. extern BOOL UpgradeAdvisorMode;
  1556. BOOL
  1557. InitializeArcStuff(
  1558. IN HWND Parent
  1559. );
  1560. BOOL
  1561. ArcInitializeArcStuff(
  1562. IN HWND Parent
  1563. );
  1564. //
  1565. // Test to see if we're on an ARC based machine
  1566. #ifdef UNICODE
  1567. #if defined(_X86_)
  1568. BOOL
  1569. IsArc(
  1570. VOID
  1571. );
  1572. #else
  1573. #define IsArc() TRUE
  1574. #endif
  1575. #if defined(EFI_NVRAM_ENABLED)
  1576. BOOL
  1577. IsEfi(
  1578. VOID
  1579. );
  1580. #else
  1581. #define IsEfi() FALSE
  1582. #endif
  1583. VOID
  1584. MigrateBootVarData(
  1585. VOID
  1586. );
  1587. #else
  1588. #define IsArc() (FALSE)
  1589. #define MigrateBootVarData()
  1590. #endif
  1591. //
  1592. // Build the command console.
  1593. //
  1594. extern BOOL BuildCmdcons;
  1595. #ifdef RUN_SYSPARSE
  1596. //
  1597. // NoSysparse. Set to true if we don't want to run sysparse.exe
  1598. // This hack should be removed before RTM.
  1599. //
  1600. extern BOOL NoSysparse;
  1601. extern PROCESS_INFORMATION piSysparse;
  1602. #endif
  1603. //
  1604. // Internal/undoc'ed stuff
  1605. //
  1606. extern UINT NumberOfLicensedProcessors;
  1607. extern BOOL IgnoreExceptionPackages;
  1608. //
  1609. // Where to get missing files.
  1610. //
  1611. extern TCHAR AlternateSourcePath[MAX_PATH];
  1612. VOID
  1613. InternalProcessCmdLineArg(
  1614. IN LPCTSTR Arg
  1615. );
  1616. //
  1617. // Get Harddisk BPS
  1618. //
  1619. ULONG
  1620. GetHDBps(
  1621. HANDLE hDisk
  1622. );
  1623. #define INIT_OBJA(Obja,UnicodeString,UnicodeText) \
  1624. \
  1625. RtlInitUnicodeString((UnicodeString),(UnicodeText)); \
  1626. \
  1627. InitializeObjectAttributes( \
  1628. (Obja), \
  1629. (UnicodeString), \
  1630. OBJ_CASE_INSENSITIVE, \
  1631. NULL, \
  1632. NULL \
  1633. )
  1634. #ifdef _X86_
  1635. //
  1636. // PC-98 stuff
  1637. //
  1638. VOID
  1639. SetAutomaticBootselector(
  1640. VOID
  1641. );
  1642. VOID
  1643. SetAutomaticBootselectorNT(
  1644. VOID
  1645. );
  1646. VOID
  1647. SetAutomaticBootselector95(
  1648. VOID
  1649. );
  1650. #define ALIGN(p,val) \
  1651. \
  1652. (PVOID)((((ULONG)(p) + (val) - 1)) & (~((val) - 1)))
  1653. //
  1654. // read/write disk sectors
  1655. //
  1656. NTSTATUS
  1657. SpReadWriteDiskSectors(
  1658. IN HANDLE Handle,
  1659. IN ULONG SectorNumber,
  1660. IN ULONG SectorCount,
  1661. IN ULONG BytesPerSector,
  1662. IN OUT PVOID AlignedBuffer,
  1663. IN BOOL Write
  1664. );
  1665. #define NEC_WRITESEC TRUE
  1666. #define NEC_READSEC FALSE
  1667. //
  1668. // Get WindowsNT System Position
  1669. //
  1670. UCHAR
  1671. GetSystemPosition(
  1672. PHANDLE phDisk,
  1673. PDISK_GEOMETRY SystemMediaInfo
  1674. );
  1675. BOOL
  1676. IsNEC98(
  1677. VOID
  1678. );
  1679. LONG
  1680. CalcHiddenSector(
  1681. IN TCHAR SystemPartitionDriveLetter,
  1682. IN SHORT Bps
  1683. );
  1684. #endif
  1685. //
  1686. // Registry migration stuff
  1687. //
  1688. //
  1689. // Context structure used for generating inf files (infgen.c)
  1690. //
  1691. #define INFLINEBUFLEN 512
  1692. typedef struct _INFFILEGEN {
  1693. TCHAR FileName[MAX_PATH];
  1694. HANDLE FileHandle;
  1695. BOOL SawBogusOp;
  1696. TCHAR LineBuf[INFLINEBUFLEN];
  1697. unsigned LineBufUsed;
  1698. } INFFILEGEN, *PINFFILEGEN;
  1699. DWORD
  1700. InfStart(
  1701. IN LPCTSTR InfName,
  1702. IN LPCTSTR Directory,
  1703. OUT PINFFILEGEN *Context
  1704. );
  1705. DWORD
  1706. InfEnd(
  1707. IN OUT PINFFILEGEN *Context
  1708. );
  1709. DWORD
  1710. InfCreateSection(
  1711. IN LPCTSTR SectionName,
  1712. IN OUT PINFFILEGEN *Context
  1713. );
  1714. DWORD
  1715. InfRecordAddReg(
  1716. IN OUT PINFFILEGEN Context,
  1717. IN HKEY Key,
  1718. IN LPCTSTR Subkey,
  1719. IN LPCTSTR Value, OPTIONAL
  1720. IN DWORD DataType,
  1721. IN PVOID Data,
  1722. IN DWORD DataLength,
  1723. IN BOOL SetNoClobberFlag
  1724. );
  1725. ULONG
  1726. DumpRegKeyToInf(
  1727. IN PINFFILEGEN InfContext,
  1728. IN HKEY PredefinedKey,
  1729. IN LPCTSTR FullKeyPath,
  1730. IN BOOL DumpIfEmpty,
  1731. IN BOOL DumpSubKeys,
  1732. IN BOOL SetNoClobberFlag,
  1733. IN BOOL DumpNonVolatileKey
  1734. );
  1735. DWORD
  1736. WriteText(
  1737. IN HANDLE FileHandle,
  1738. IN UINT MessageId,
  1739. ...
  1740. );
  1741. //
  1742. // Unsupported driver migration stuff
  1743. //
  1744. //
  1745. // Structure used to build a list of files associated to and usupported
  1746. // driver that was detected on the NT system to be upgraded.
  1747. //
  1748. typedef struct _UNSUPORTED_PNP_HARDWARE_ID {
  1749. //
  1750. // Pointer to the next element in the list
  1751. //
  1752. struct _UNSUPORTED_PNP_HARDWARE_ID *Next;
  1753. //
  1754. // String that represents the hardware id of a PNP device.
  1755. //
  1756. LPTSTR Id;
  1757. //
  1758. // Service for the device
  1759. //
  1760. LPTSTR Service;
  1761. //
  1762. // GUID for this device, if any
  1763. //
  1764. LPTSTR ClassGuid;
  1765. } UNSUPORTED_PNP_HARDWARE_ID, *PUNSUPORTED_PNP_HARDWARE_ID;
  1766. typedef struct _UNSUPORTED_DRIVER_FILE_INFO {
  1767. //
  1768. // Pointer to the next element in the list
  1769. //
  1770. struct _UNSUPORTED_DRIVER_FILE_INFO *Next;
  1771. //
  1772. // Pointer to the file name
  1773. //
  1774. LPTSTR FileName;
  1775. //
  1776. // Pointer to the path relative to %SystemRoot% where the file
  1777. // should be installed.
  1778. //
  1779. LPTSTR TargetDirectory;
  1780. } UNSUPORTED_DRIVER_FILE_INFO, *PUNSUPORTED_DRIVER_FILE_INFO;
  1781. typedef struct _UNSUPORTED_DRIVER_REGKEY_INFO {
  1782. //
  1783. // Pointer to the next element in the list
  1784. //
  1785. struct _UNSUPORTED_DRIVER_REGKEY_INFO *Next;
  1786. //
  1787. // A predefined key
  1788. //
  1789. HKEY PredefinedKey;
  1790. //
  1791. // Path to the key to be migrated, relative to a predefined key.
  1792. //
  1793. LPTSTR KeyPath;
  1794. //
  1795. // Undicates whether or not volatile keys should be migrated
  1796. //
  1797. BOOL MigrateVolatileKeys;
  1798. } UNSUPORTED_DRIVER_REGKEY_INFO, *PUNSUPORTED_DRIVER_REGKEY_INFO;
  1799. typedef struct _UNSUPORTED_DRIVER_INFO {
  1800. //
  1801. // Pointer to the next element in the list
  1802. //
  1803. struct _UNSUPORTED_DRIVER_INFO *Next;
  1804. //
  1805. // A string that identifies the driver to be migrated (such as aic78xx)
  1806. //
  1807. LPTSTR DriverId;
  1808. //
  1809. // Points to the list of files associated to the unsupported driver
  1810. //
  1811. PUNSUPORTED_DRIVER_REGKEY_INFO KeyList;
  1812. //
  1813. // Points to the list of keys associated to the unsupported driver
  1814. //
  1815. PUNSUPORTED_DRIVER_FILE_INFO FileList;
  1816. //
  1817. // Points to the list of hardware ids associated to the unsupported driver
  1818. //
  1819. PUNSUPORTED_PNP_HARDWARE_ID HardwareIdsList;
  1820. } UNSUPORTED_DRIVER_INFO, *PUNSUPORTED_DRIVER_INFO;
  1821. //
  1822. // Unsupported driver list
  1823. // This list contains the information about the unsupported drivers that needs
  1824. // to be migrated on a clean install or upgrade.
  1825. //
  1826. // extern PUNSUPORTED_DRIVER_INFO UnsupportedDriverList;
  1827. BOOL
  1828. BuildUnsupportedDriverList(
  1829. IN PVOID TxtsetupSifHandle,
  1830. OUT PUNSUPORTED_DRIVER_INFO* DriverList
  1831. );
  1832. BOOL
  1833. SaveUnsupportedDriverInfo(
  1834. IN HWND ParentWindow,
  1835. IN LPTSTR FileName,
  1836. IN PUNSUPORTED_DRIVER_INFO DriverList
  1837. );
  1838. BOOL
  1839. AddUnsupportedFilesToCopyList(
  1840. IN HWND ParentWindow,
  1841. IN PUNSUPORTED_DRIVER_INFO DriverList
  1842. );
  1843. BOOL
  1844. MigrateUnsupportedNTDrivers(
  1845. IN HWND ParentWindow,
  1846. IN PVOID TxtsetupSifHandle
  1847. );
  1848. // Error codes and Function to check schema version for NT5 DC Upgrades
  1849. #define DSCHECK_ERR_SUCCESS 0
  1850. #define DSCHECK_ERR_FILE_NOT_FOUND 1
  1851. #define DSCHECK_ERR_FILE_COPY 2
  1852. #define DSCHECK_ERR_VERSION_MISMATCH 3
  1853. #define DSCHECK_ERR_CREATE_DIRECTORY 4
  1854. BOOL
  1855. ISDC(
  1856. VOID
  1857. );
  1858. BOOL
  1859. IsNT5DC();
  1860. int
  1861. CheckSchemaVersionForNT5DCs(
  1862. IN HWND ParentWnd
  1863. );
  1864. //
  1865. // Diagnostic/debug functions in debug.c
  1866. //
  1867. //
  1868. // Allow assertion checking to be turned on independently
  1869. // of DBG, like by specifying C_DEFINES=-DASSERTS_ON=1 in sources file.
  1870. //
  1871. #ifndef ASSERTS_ON
  1872. #if DBG
  1873. #define ASSERTS_ON 1
  1874. #else
  1875. #define ASSERTS_ON 0
  1876. #endif
  1877. #endif
  1878. #if ASSERTS_ON
  1879. #ifndef MYASSERT
  1880. #define MYASSERT(x) if(!(x)) { AssertFail(__FILE__,__LINE__,#x); }
  1881. VOID
  1882. AssertFail(
  1883. IN PSTR FileName,
  1884. IN UINT LineNumber,
  1885. IN PSTR Condition
  1886. );
  1887. #endif
  1888. #else
  1889. #define MYASSERT(x)
  1890. #endif
  1891. #ifdef _X86_
  1892. VOID
  1893. ProtectAllModules (
  1894. VOID
  1895. );
  1896. #endif
  1897. BOOL
  1898. WriteHeadlessParameters(
  1899. IN LPCTSTR FileName
  1900. );
  1901. //
  1902. // Setup Log prototypes in setupapi.dll
  1903. //
  1904. typedef BOOL(WINAPI * SETUPOPENLOG)(BOOL Erase);
  1905. typedef BOOL(WINAPI * SETUPLOGERROR)(PCTSTR MessageString, LogSeverity Severity);
  1906. typedef VOID(WINAPI * SETUPCLOSELOG)(VOID);
  1907. //
  1908. // Default throughput (5 KB/msec)
  1909. //
  1910. #define DEFAULT_IO_THROUGHPUT (5 * 1024)
  1911. extern DWORD dwThroughPutSrcToDest;
  1912. extern DWORD dwThroughPutHDToHD;
  1913. void CalcThroughput();
  1914. // Should allow 1K for strings for localization
  1915. #define MAX_STRING 1024
  1916. BOOL
  1917. SaveAdvancedOptions (
  1918. IN PCTSTR AnswerFile
  1919. );
  1920. BOOL
  1921. SaveLanguageOptions (
  1922. IN PCTSTR AnswerFile
  1923. );
  1924. BOOL
  1925. SaveAccessibilityOptions (
  1926. IN PCTSTR AnswerFile
  1927. );
  1928. BOOL
  1929. LoadAdvancedOptions (
  1930. IN PCTSTR AnswerFile
  1931. );
  1932. BOOL
  1933. LoadLanguageOptions (
  1934. IN PCTSTR AnswerFile
  1935. );
  1936. BOOL
  1937. LoadAccessibilityOptions (
  1938. IN PCTSTR AnswerFile
  1939. );
  1940. BOOL
  1941. AddCopydirIfExists(
  1942. IN LPTSTR pszPathToCopy,
  1943. IN UINT Flags
  1944. );
  1945. BOOL
  1946. IsNetConnectivityAvailable (
  1947. VOID
  1948. );
  1949. BOOL
  1950. ValidatePidEx(LPTSTR PID, BOOL *pbStepup, BOOL *bSelect);
  1951. #ifdef PRERELEASE
  1952. #define TEST_EXCEPTION 1
  1953. #endif
  1954. #define SETUP_FAULTH_APPNAME "drw\\faulth.dll"
  1955. //#define SETUP_URL "officewatson"
  1956. #define SETUP_URL "watson.microsoft.com"
  1957. #define S_WINNT32LOGFILE TEXT("WINNT32.LOG")
  1958. #define S_DEFAULT_NT_COMPAT_FILENAME TEXT("UPGRADE.TXT")
  1959. #ifdef TEST_EXCEPTION
  1960. void DoException( DWORD dwSetupArea);
  1961. #endif