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.

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