ReactOS  0.4.14-dev-55-g2da92ac
usetup.c File Reference
#include <usetup.h>
#include <math.h>
#include <ntstrsafe.h>
#include "bootsup.h"
#include "chkdsk.h"
#include "cmdcons.h"
#include "devinst.h"
#include "format.h"
#include <debug.h>
Include dependency graph for usetup.c:

Go to the source code of this file.

Classes

struct  _COPYCONTEXT
 

Macros

#define NDEBUG
 
#define PARTITION_SIZE_INPUT_FIELD_LENGTH   9
 
#define PARTITION_MAXSIZE   (pow(10, (PARTITION_SIZE_INPUT_FIELD_LENGTH - 1)) - 1)
 

Typedefs

typedef struct _COPYCONTEXT COPYCONTEXT
 
typedef struct _COPYCONTEXTPCOPYCONTEXT
 

Functions

static VOID PrintString (char *fmt,...)
 
static VOID DrawBox (IN SHORT xLeft, IN SHORT yTop, IN SHORT Width, IN SHORT Height)
 
VOID PopupError (PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
 
static BOOL ConfirmQuit (PINPUT_RECORD Ir)
 
static VOID UpdateKBLayout (VOID)
 
static NTSTATUS NTAPI GetSettingDescription (IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
 
static NTSTATUS NTAPI GetNTOSInstallationName (IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
 
static PAGE_NUMBER LanguagePage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER SetupStartPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER WelcomePage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER LicensePage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER RepairIntroPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER UpgradeRepairPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER InstallIntroPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER DeviceSettingsPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER HandleGenericList (PGENERIC_LIST_UI ListUi, PAGE_NUMBER nextPage, PINPUT_RECORD Ir)
 
static PAGE_NUMBER ComputerSettingsPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER DisplaySettingsPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER KeyboardSettingsPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER LayoutSettingsPage (PINPUT_RECORD Ir)
 
static BOOL IsDiskSizeValid (PPARTENTRY PartEntry)
 
static PAGE_NUMBER SelectPartitionPage (PINPUT_RECORD Ir)
 
static VOID ShowPartitionSizeInputBox (SHORT Left, SHORT Top, SHORT Right, SHORT Bottom, ULONG MaxSize, PWSTR InputBuffer, PBOOLEAN Quit, PBOOLEAN Cancel)
 
static PAGE_NUMBER CreatePrimaryPartitionPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER CreateExtendedPartitionPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER CreateLogicalPartitionPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER ConfirmDeleteSystemPartitionPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER DeletePartitionPage (PINPUT_RECORD Ir)
 
static VOID ResetFileSystemList (VOID)
 
static PAGE_NUMBER SelectFileSystemPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER FormatPartitionPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER CheckFileSystemPage (PINPUT_RECORD Ir)
 
static BOOLEAN IsValidPath (IN PCWSTR InstallDir)
 
static PAGE_NUMBER InstallDirectoryPage (PINPUT_RECORD Ir)
 
static VOID __cdecl USetupErrorRoutine (IN PUSETUP_DATA pSetupData,...)
 
static PAGE_NUMBER PrepareCopyPage (PINPUT_RECORD Ir)
 
static VOID SetupUpdateMemoryInfo (IN PCOPYCONTEXT CopyContext, IN BOOLEAN First)
 
static UINT CALLBACK FileCopyCallback (PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
 
static PAGE_NUMBER FileCopyPage (PINPUT_RECORD Ir)
 
static VOID __cdecl RegistryStatus (IN REGISTRY_STATUS RegStatus,...)
 
static PAGE_NUMBER RegistryPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER BootLoaderPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER BootLoaderFloppyPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER BootLoaderHarddiskVbrPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER BootLoaderHarddiskMbrPage (PINPUT_RECORD Ir)
 
ProgressTimeOutStringHandler

Handles the generation (displaying) of the timeout countdown to the screen dynamically.

Parameters
BarA pointer to a progress bar.
AlwaysUpdateConstantly update the progress bar (boolean type).
BufferA pointer to a string buffer.
cchBufferSizeThe buffer's size in number of characters.
Returns
TRUE or FALSE on function termination.
static BOOLEAN NTAPI ProgressTimeOutStringHandler (IN PPROGRESSBAR Bar, IN BOOLEAN AlwaysUpdate, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
 
ProgressCountdown

Displays and draws a red-coloured progress bar with a countdown. When the timeout is reached, the flush page is displayed for reboot.

Parameters
IrA pointer to an input keyboard record.
TimeOutInitial countdown value in seconds.
Returns
Nothing.
static VOID ProgressCountdown (IN PINPUT_RECORD Ir, IN LONG TimeOut)
 
static PAGE_NUMBER QuitPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER SuccessPage (PINPUT_RECORD Ir)
 
static PAGE_NUMBER FlushPage (PINPUT_RECORD Ir)
 
NTSTATUS RunUSetup (VOID)
 
VOID NTAPI NtProcessStartup (PPEB Peb)
 

Variables

HANDLE ProcessHeap
 
BOOLEAN IsUnattendedSetup = FALSE
 
static USETUP_DATA USetupData
 
static PPARTENTRY InstallPartition = NULL
 
static PPARTENTRY SystemPartition = NULL
 
PCWSTR SelectedLanguageId
 
static WCHAR DefaultLanguage [20]
 
static WCHAR DefaultKBLayout [20]
 
static BOOLEAN RepairUpdateFlag = FALSE
 
static PPARTLIST PartitionList = NULL
 
static PPARTENTRY CurrentPartition = NULL
 
static PFILE_SYSTEM_LIST FileSystemList = NULL
 
static PPARTENTRY TempPartition = NULL
 
static FORMATMACHINESTATE FormatState = Start
 
static PNTOS_INSTALLATION CurrentInstallation = NULL
 
static PGENERIC_LIST NtOsInstallsList = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 38 of file usetup.c.

◆ PARTITION_MAXSIZE

#define PARTITION_MAXSIZE   (pow(10, (PARTITION_SIZE_INPUT_FIELD_LENGTH - 1)) - 1)

Definition at line 1807 of file usetup.c.

◆ PARTITION_SIZE_INPUT_FIELD_LENGTH

#define PARTITION_SIZE_INPUT_FIELD_LENGTH   9

Definition at line 1805 of file usetup.c.

Typedef Documentation

◆ COPYCONTEXT

◆ PCOPYCONTEXT

Function Documentation

◆ BootLoaderFloppyPage()

static PAGE_NUMBER BootLoaderFloppyPage ( PINPUT_RECORD  Ir)
static

Definition at line 4494 of file usetup.c.

4495 {
4496  NTSTATUS Status;
4497 
4499 
4500 // CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
4501 
4502  while (TRUE)
4503  {
4504  CONSOLE_ConInKey(Ir);
4505 
4506  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4507  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
4508  {
4509  if (ConfirmQuit(Ir))
4510  return QUIT_PAGE;
4511 
4512  break;
4513  }
4514  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4515  {
4516  Status = InstallFatBootcodeToFloppy(&USetupData.SourceRootPath,
4517  &USetupData.DestinationArcPath);
4518  if (!NT_SUCCESS(Status))
4519  {
4522 
4523  /* TODO: Print error message */
4524  return BOOT_LOADER_FLOPPY_PAGE;
4525  }
4526 
4527  return SUCCESS_PAGE;
4528  }
4529  }
4530 
4531  return BOOT_LOADER_FLOPPY_PAGE;
4532 }
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
LONG NTSTATUS
Definition: precomp.h:26
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
union _KEY_EVENT_RECORD::@3153 uChar
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
NTSTATUS InstallFatBootcodeToFloppy(IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
Definition: bootsup.c:2350
#define VK_F3
Definition: winuser.h:2232
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65

Referenced by RunUSetup().

◆ BootLoaderHarddiskMbrPage()

static PAGE_NUMBER BootLoaderHarddiskMbrPage ( PINPUT_RECORD  Ir)
static

Definition at line 4584 of file usetup.c.

4585 {
4586  NTSTATUS Status;
4587  WCHAR DestinationDevicePathBuffer[MAX_PATH];
4588 
4589  /* Step 1: Write the VBR */
4590  // FIXME! We must not use the partition type, but instead use the partition FileSystem!!
4591  Status = InstallVBRToPartition(&USetupData.SystemRootPath,
4592  &USetupData.SourceRootPath,
4593  &USetupData.DestinationArcPath,
4595  if (!NT_SUCCESS(Status))
4596  {
4599  return QUIT_PAGE;
4600  }
4601 
4602  /* Step 2: Write the MBR if the disk containing the system partition is not a super-floppy */
4604  {
4605  RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
4606  L"\\Device\\Harddisk%d\\Partition0",
4607  SystemPartition->DiskEntry->DiskNumber);
4608  Status = InstallMbrBootCodeToDisk(&USetupData.SystemRootPath,
4609  &USetupData.SourceRootPath,
4610  DestinationDevicePathBuffer);
4611  if (!NT_SUCCESS(Status))
4612  {
4613  DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n", Status);
4615  return QUIT_PAGE;
4616  }
4617  }
4618 
4619  return SUCCESS_PAGE;
4620 }
static USETUP_DATA USetupData
Definition: usetup.c:47
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS InstallVBRToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN UCHAR PartitionType)
Definition: bootsup.c:2307
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
UCHAR PartitionType
Definition: partlist.h:46
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
WCHAR FileSystem[MAX_PATH+1]
Definition: partlist.h:53
static PPARTENTRY SystemPartition
Definition: usetup.c:61
static const WCHAR L[]
Definition: oid.c:1250
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
NTSTATUS InstallMbrBootCodeToDisk(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PCWSTR DestinationDevicePathBuffer)
Definition: bootsup.c:877
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
Definition: partlist.c:679
#define DPRINT1
Definition: precomp.h:8

Referenced by RunUSetup().

◆ BootLoaderHarddiskVbrPage()

static PAGE_NUMBER BootLoaderHarddiskVbrPage ( PINPUT_RECORD  Ir)
static

Definition at line 4549 of file usetup.c.

4550 {
4551  NTSTATUS Status;
4552 
4553  // FIXME! We must not use the partition type, but instead use the partition FileSystem!!
4554  Status = InstallVBRToPartition(&USetupData.SystemRootPath,
4555  &USetupData.SourceRootPath,
4556  &USetupData.DestinationArcPath,
4558  if (!NT_SUCCESS(Status))
4559  {
4562  return QUIT_PAGE;
4563  }
4564 
4565  return SUCCESS_PAGE;
4566 }
static USETUP_DATA USetupData
Definition: usetup.c:47
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS InstallVBRToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN UCHAR PartitionType)
Definition: bootsup.c:2307
UCHAR PartitionType
Definition: partlist.h:46
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WCHAR FileSystem[MAX_PATH+1]
Definition: partlist.h:53
static PPARTENTRY SystemPartition
Definition: usetup.c:61
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:126

Referenced by RunUSetup().

◆ BootLoaderPage()

static PAGE_NUMBER BootLoaderPage ( PINPUT_RECORD  Ir)
static

Definition at line 4270 of file usetup.c.

4271 {
4273  BOOLEAN InstallOnFloppy;
4274  USHORT Line = 12;
4275  WCHAR PathBuffer[MAX_PATH];
4276 
4278 
4280 
4281  RtlFreeUnicodeString(&USetupData.SystemRootPath);
4282  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
4283  L"\\Device\\Harddisk%lu\\Partition%lu\\",
4284  SystemPartition->DiskEntry->DiskNumber,
4286  RtlCreateUnicodeString(&USetupData.SystemRootPath, PathBuffer);
4287  DPRINT1("SystemRootPath: %wZ\n", &USetupData.SystemRootPath);
4288 
4290 
4291  /* For unattended setup, skip MBR installation or install on floppy if needed */
4292  if (IsUnattendedSetup)
4293  {
4294  if ((USetupData.MBRInstallType == 0) ||
4295  (USetupData.MBRInstallType == 1))
4296  {
4297  goto Quit;
4298  }
4299  }
4300 
4301  /*
4302  * We may install an MBR or VBR, but before that, check whether
4303  * we need to actually install the VBR on floppy.
4304  */
4306  {
4307  DPRINT("Error: system partition invalid (unused)\n");
4308  InstallOnFloppy = TRUE;
4309  }
4310  else if (PartitionType == PARTITION_OS2BOOTMGR)
4311  {
4312  /* OS/2 boot manager partition */
4313  DPRINT("Found OS/2 boot manager partition\n");
4314  InstallOnFloppy = TRUE;
4315  }
4316  else if (PartitionType == PARTITION_LINUX)
4317  {
4318  /* Linux partition */
4319  DPRINT("Found Linux native partition (ext2/ext3/ReiserFS/BTRFS/etc)\n");
4320  InstallOnFloppy = FALSE;
4321  }
4322  else if (PartitionType == PARTITION_IFS)
4323  {
4324  /* NTFS partition */
4325  DPRINT("Found NTFS partition\n");
4326 
4327  // FIXME: Make it FALSE when we'll support NTFS installation!
4328  InstallOnFloppy = TRUE;
4329  }
4330  else if ((PartitionType == PARTITION_FAT_12) ||
4336  {
4337  DPRINT("Found FAT partition\n");
4338  InstallOnFloppy = FALSE;
4339  }
4340  else
4341  {
4342  /* Unknown partition */
4343  DPRINT("Unknown partition found\n");
4344  InstallOnFloppy = TRUE;
4345  }
4346 
4347  /* We should install on floppy */
4348  if (InstallOnFloppy)
4349  {
4350  USetupData.MBRInstallType = 1;
4351  goto Quit;
4352  }
4353 
4354  /* Is it an unattended install on hdd? */
4355  if (IsUnattendedSetup)
4356  {
4357  if ((USetupData.MBRInstallType == 2) ||
4358  (USetupData.MBRInstallType == 3))
4359  {
4360  goto Quit;
4361  }
4362  }
4363 
4365  CONSOLE_InvertTextXY(8, Line, 60, 1);
4366 
4367  while (TRUE)
4368  {
4369  CONSOLE_ConInKey(Ir);
4370 
4371  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4372  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
4373  {
4374  CONSOLE_NormalTextXY(8, Line, 60, 1);
4375 
4376  Line++;
4377  if (Line < 12)
4378  Line = 15;
4379 
4380  if (Line > 15)
4381  Line = 12;
4382 
4383  CONSOLE_InvertTextXY(8, Line, 60, 1);
4384  }
4385  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4386  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
4387  {
4388  CONSOLE_NormalTextXY(8, Line, 60, 1);
4389 
4390  Line--;
4391  if (Line < 12)
4392  Line = 15;
4393 
4394  if (Line > 15)
4395  Line = 12;
4396 
4397  CONSOLE_InvertTextXY(8, Line, 60, 1);
4398  }
4399  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4400  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_HOME)) /* HOME */
4401  {
4402  CONSOLE_NormalTextXY(8, Line, 60, 1);
4403 
4404  Line = 12;
4405 
4406  CONSOLE_InvertTextXY(8, Line, 60, 1);
4407  }
4408  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4409  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_END)) /* END */
4410  {
4411  CONSOLE_NormalTextXY(8, Line, 60, 1);
4412 
4413  Line = 15;
4414 
4415  CONSOLE_InvertTextXY(8, Line, 60, 1);
4416  }
4417  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4418  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
4419  {
4420  if (ConfirmQuit(Ir))
4421  return QUIT_PAGE;
4422 
4423  break;
4424  }
4425  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4426  {
4427  if (Line == 12)
4428  {
4429  /* Install on both MBR and VBR */
4430  USetupData.MBRInstallType = 2;
4431  break;
4432  }
4433  else if (Line == 13)
4434  {
4435  /* Install on VBR only */
4436  USetupData.MBRInstallType = 3;
4437  break;
4438  }
4439  else if (Line == 14)
4440  {
4441  /* Install on floppy */
4442  USetupData.MBRInstallType = 1;
4443  break;
4444  }
4445  else if (Line == 15)
4446  {
4447  /* Skip MBR installation */
4448  USetupData.MBRInstallType = 0;
4449  break;
4450  }
4451 
4452  return BOOT_LOADER_PAGE;
4453  }
4454  }
4455 
4456 Quit:
4457  switch (USetupData.MBRInstallType)
4458  {
4459  /* Skip MBR installation */
4460  case 0:
4461  return SUCCESS_PAGE;
4462 
4463  /* Install on floppy */
4464  case 1:
4465  return BOOT_LOADER_FLOPPY_PAGE;
4466 
4467  /* Install on both MBR and VBR */
4468  case 2:
4470 
4471  /* Install on VBR only */
4472  case 3:
4474  }
4475 
4476  return BOOT_LOADER_PAGE;
4477 }
#define PARTITION_FAT32
Definition: disk.h:95
ULONG PartitionNumber
Definition: partlist.h:48
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define VK_DOWN
Definition: winuser.h:2202
VOID CONSOLE_NormalTextXY(IN SHORT x, IN SHORT y, IN SHORT col, IN SHORT row)
Definition: consup.c:282
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
#define PARTITION_XINT13
Definition: disk.h:97
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
#define VK_HOME
Definition: winuser.h:2198
VOID CONSOLE_InvertTextXY(IN SHORT x, IN SHORT y, IN SHORT col, IN SHORT row)
Definition: consup.c:259
#define VK_UP
Definition: winuser.h:2200
#define PARTITION_HUGE
Definition: disk.h:92
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
#define PARTITION_IFS
Definition: disk.h:93
union _KEY_EVENT_RECORD::@3153 uChar
UCHAR PartitionType
Definition: partlist.h:46
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define PARTITION_FAT_16
Definition: disk.h:90
#define VK_F3
Definition: winuser.h:2232
static PPARTENTRY SystemPartition
Definition: usetup.c:61
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ncftp.h:79
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN IsUnattendedSetup
Definition: usetup.c:45
#define PARTITION_LINUX
Definition: partlist.c:36
#define DPRINT1
Definition: precomp.h:8
CHAR PartitionType
Definition: part_xbox.c:33
#define PARTITION_FAT_12
Definition: disk.h:87
#define STRING_PLEASEWAIT
Definition: mui.h:74
#define PARTITION_FAT32_XINT13
Definition: disk.h:96
#define VK_END
Definition: winuser.h:2197
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
BOOLEAN IsPartitioned
Definition: partlist.h:59
#define PARTITION_OS2BOOTMGR
Definition: disk.h:94

Referenced by RunUSetup().

◆ CheckFileSystemPage()

static PAGE_NUMBER CheckFileSystemPage ( PINPUT_RECORD  Ir)
static

Definition at line 3540 of file usetup.c.

3541 {
3542  NTSTATUS Status;
3543  PDISKENTRY DiskEntry;
3544  PPARTENTRY PartEntry;
3545  UNICODE_STRING PartitionRootPath;
3546  WCHAR PathBuffer[MAX_PATH];
3547  CHAR Buffer[MAX_PATH];
3548 
3549  if (PartitionList == NULL)
3550  {
3551  /* FIXME: show an error dialog */
3552  return QUIT_PAGE;
3553  }
3554 
3555  if (!GetNextUncheckedPartition(PartitionList, &DiskEntry, &PartEntry))
3556  {
3557  return INSTALL_DIRECTORY_PAGE;
3558  }
3559 
3560  ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
3561 
3563 
3565 
3566  DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystem: %S\n",
3567  PartEntry->PartitionType, (*PartEntry->FileSystem ? PartEntry->FileSystem : L"n/a"));
3568 
3569  /* HACK: Do not try to check a partition with an unknown filesystem */
3570  if (!*PartEntry->FileSystem)
3571  {
3572  PartEntry->NeedsCheck = FALSE;
3573  return CHECK_FILE_SYSTEM_PAGE;
3574  }
3575 
3576  /* Set PartitionRootPath */
3577  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
3578  L"\\Device\\Harddisk%lu\\Partition%lu",
3579  DiskEntry->DiskNumber,
3580  PartEntry->PartitionNumber);
3581  RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
3582  DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
3583 
3584  /* Check the partition */
3585  Status = ChkdskPartition(&PartitionRootPath, PartEntry->FileSystem);
3587  {
3588  /*
3589  * Partition checking is not supported with the current filesystem,
3590  * so disable FS checks on it.
3591  */
3592  PartEntry->NeedsCheck = FALSE;
3593 
3595  sizeof(Buffer),
3596  "Setup is currently unable to check a partition formatted in %S.\n"
3597  "\n"
3598  " \x07 Press ENTER to continue Setup.\n"
3599  " \x07 Press F3 to quit Setup.",
3600  PartEntry->FileSystem);
3601 
3605 
3606  while (TRUE)
3607  {
3608  CONSOLE_ConInKey(Ir);
3609 
3610  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x00 &&
3611  Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3) /* F3 */
3612  {
3613  if (ConfirmQuit(Ir))
3614  return QUIT_PAGE;
3615  else
3616  return CHECK_FILE_SYSTEM_PAGE;
3617  }
3618  else if (Ir->Event.KeyEvent.uChar.AsciiChar == VK_RETURN) /* ENTER */
3619  {
3620  return CHECK_FILE_SYSTEM_PAGE;
3621  }
3622  }
3623  }
3624  else if (!NT_SUCCESS(Status))
3625  {
3626  DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status);
3627  sprintf(Buffer, "ChkDsk detected some disk errors.\n(Status 0x%08lx).\n", Status);
3630  Ir, POPUP_WAIT_ENTER);
3631  }
3632 
3633  PartEntry->NeedsCheck = FALSE;
3634  return CHECK_FILE_SYSTEM_PAGE;
3635 }
ULONG PartitionNumber
Definition: partlist.h:48
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:124
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:305
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
VOID PopupError(PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
Definition: usetup.c:203
ULONG DiskNumber
Definition: partlist.h:104
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define VK_RETURN
Definition: winuser.h:2176
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS ChkdskPartition(IN PUNICODE_STRING DriveRoot, IN PCWSTR FileSystemName)
Definition: chkdsk.c:57
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN GetNextUncheckedPartition(IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
Definition: partlist.c:4263
Definition: bufpool.h:45
#define STRING_CHECKINGPART
Definition: mui.h:90
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
union _KEY_EVENT_RECORD::@3153 uChar
UCHAR PartitionType
Definition: partlist.h:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
WCHAR FileSystem[MAX_PATH+1]
Definition: partlist.h:53
static PPARTLIST PartitionList
Definition: usetup.c:73
#define VK_F3
Definition: winuser.h:2232
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
#define STRING_CONTINUE
Definition: mui.h:91
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
BOOLEAN NeedsCheck
Definition: partlist.h:70
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STRING_PLEASEWAIT
Definition: mui.h:74
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STRING_QUITCONTINUE
Definition: mui.h:92
BOOLEAN IsPartitioned
Definition: partlist.h:59

Referenced by RunUSetup().

◆ ComputerSettingsPage()

static PAGE_NUMBER ComputerSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1331 of file usetup.c.

1332 {
1333  GENERIC_LIST_UI ListUi;
1335 
1336  InitGenericListUi(&ListUi, USetupData.ComputerList, GetSettingDescription);
1337  DrawGenericList(&ListUi,
1338  2, 18,
1339  xScreen - 3,
1340  yScreen - 3);
1341 
1342  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1343 }
static USETUP_DATA USetupData
Definition: usetup.c:47
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
VOID InitGenericListUi(IN OUT PGENERIC_LIST_UI ListUi, IN PGENERIC_LIST List, IN PGET_ENTRY_DESCRIPTION GetEntryDescriptionProc)
Definition: genlist.c:37
static PAGE_NUMBER HandleGenericList(PGENERIC_LIST_UI ListUi, PAGE_NUMBER nextPage, PINPUT_RECORD Ir)
Definition: usetup.c:1265
VOID DrawGenericList(IN PGENERIC_LIST_UI ListUi, IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom)
Definition: genlist.c:326
SHORT yScreen
Definition: consup.c:40
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:438

Referenced by RunUSetup().

◆ ConfirmDeleteSystemPartitionPage()

static PAGE_NUMBER ConfirmDeleteSystemPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2489 of file usetup.c.

2490 {
2492 
2493  while (TRUE)
2494  {
2495  CONSOLE_ConInKey(Ir);
2496 
2497  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
2498  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
2499  {
2500  if (ConfirmQuit(Ir))
2501  return QUIT_PAGE;
2502 
2503  break;
2504  }
2505  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
2506  {
2507  return DELETE_PARTITION_PAGE;
2508  }
2509  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESC */
2510  {
2511  return SELECT_PARTITION_PAGE;
2512  }
2513  }
2514 
2516 }
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
#define VK_ESCAPE
Definition: winuser.h:2189
#define VK_RETURN
Definition: winuser.h:2176
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
union _KEY_EVENT_RECORD::@3153 uChar
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2232
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ ConfirmQuit()

static BOOL ConfirmQuit ( PINPUT_RECORD  Ir)
static

Definition at line 376 of file usetup.c.

377 {
378  BOOL Result = FALSE;
380 
381  while (TRUE)
382  {
383  CONSOLE_ConInKey(Ir);
384 
385  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
386  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
387  {
388  Result = TRUE;
389  break;
390  }
391  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
392  {
393  Result = FALSE;
394  break;
395  }
396  }
397 
398  return Result;
399 }
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:124
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
union _KEY_EVENT_RECORD::@3153 uChar
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2232
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by BootLoaderFloppyPage(), BootLoaderPage(), CheckFileSystemPage(), ConfirmDeleteSystemPartitionPage(), CreateExtendedPartitionPage(), CreateLogicalPartitionPage(), CreatePrimaryPartitionPage(), DeletePartitionPage(), DeviceSettingsPage(), FormatPartitionPage(), HandleGenericList(), InstallDirectoryPage(), InstallIntroPage(), LanguagePage(), SelectFileSystemPage(), SelectPartitionPage(), UpgradeRepairPage(), and WelcomePage().

◆ CreateExtendedPartitionPage()

static PAGE_NUMBER CreateExtendedPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2166 of file usetup.c.

2167 {
2168  PPARTENTRY PartEntry;
2169  PDISKENTRY DiskEntry;
2170  BOOLEAN Quit;
2171  BOOLEAN Cancel;
2172  WCHAR InputBuffer[50];
2173  ULONG MaxSize;
2174  ULONGLONG PartSize;
2175  ULONGLONG DiskSize;
2177  PCHAR Unit;
2178 
2179  if (PartitionList == NULL || CurrentPartition == NULL)
2180  {
2181  /* FIXME: show an error dialog */
2182  return QUIT_PAGE;
2183  }
2184 
2185  PartEntry = CurrentPartition;
2186  DiskEntry = CurrentPartition->DiskEntry;
2187 
2189 
2191 
2192  DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
2193 #if 0
2194  if (DiskSize >= 10 * GB) /* 10 GB */
2195  {
2196  DiskSize = DiskSize / GB;
2198  }
2199  else
2200 #endif
2201  {
2202  DiskSize = DiskSize / MB;
2203  if (DiskSize == 0)
2204  DiskSize = 1;
2205 
2207  }
2208 
2209  if (DiskEntry->DriverName.Length > 0)
2210  {
2211  CONSOLE_PrintTextXY(6, 10,
2213  DiskSize,
2214  Unit,
2215  DiskEntry->DiskNumber,
2216  DiskEntry->Port,
2217  DiskEntry->Bus,
2218  DiskEntry->Id,
2219  &DiskEntry->DriverName,
2220  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2221  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2222  "RAW");
2223  }
2224  else
2225  {
2226  CONSOLE_PrintTextXY(6, 10,
2228  DiskSize,
2229  Unit,
2230  DiskEntry->DiskNumber,
2231  DiskEntry->Port,
2232  DiskEntry->Bus,
2233  DiskEntry->Id,
2234  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2235  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2236  "RAW");
2237  }
2238 
2240 
2241 #if 0
2242  CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2243  CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
2244 #endif
2245 
2247 
2248  PartEntry = CurrentPartition;
2249  while (TRUE)
2250  {
2251  MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
2252 
2253  if (MaxSize > PARTITION_MAXSIZE)
2254  MaxSize = PARTITION_MAXSIZE;
2255 
2256  ShowPartitionSizeInputBox(12, 14, xScreen - 12, 17, /* left, top, right, bottom */
2257  MaxSize, InputBuffer, &Quit, &Cancel);
2258 
2259  if (Quit)
2260  {
2261  if (ConfirmQuit(Ir))
2262  return QUIT_PAGE;
2263 
2264  break;
2265  }
2266  else if (Cancel)
2267  {
2268  return SELECT_PARTITION_PAGE;
2269  }
2270  else
2271  {
2272  PartSize = _wcstoui64(InputBuffer, NULL, 10);
2273 
2274  if (PartSize < 1)
2275  {
2276  /* Too small */
2277  continue;
2278  }
2279 
2280  if (PartSize > MaxSize)
2281  {
2282  /* Too large */
2283  continue;
2284  }
2285 
2286  /* Convert to bytes */
2287  if (PartSize == MaxSize)
2288  {
2289  /* Use all of the unpartitioned disk space */
2290  SectorCount = PartEntry->SectorCount.QuadPart;
2291  }
2292  else
2293  {
2294  /* Calculate the sector count from the size in MB */
2295  SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
2296 
2297  /* But never get larger than the unpartitioned disk space */
2298  if (SectorCount > PartEntry->SectorCount.QuadPart)
2299  SectorCount = PartEntry->SectorCount.QuadPart;
2300  }
2301 
2302  DPRINT ("Partition size: %I64u bytes\n", PartSize);
2303 
2306  SectorCount);
2307 
2308  return SELECT_PARTITION_PAGE;
2309  }
2310  }
2311 
2313 }
signed char * PCHAR
Definition: retypes.h:7
#define STRING_HDDSIZE
Definition: mui.h:83
USHORT Id
Definition: partlist.h:108
#define TRUE
Definition: types.h:120
SHORT xScreen
Definition: consup.c:39
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:305
#define STRING_CREATEPARTITION
Definition: mui.h:84
Unit
Definition: gdiplusenums.h:25
USHORT Bus
Definition: partlist.h:107
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:599
ULONG DiskNumber
Definition: partlist.h:104
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
CHAR InputBuffer[80]
Definition: conmgr.c:33
_Check_return_ __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _wcstoui64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define STRING_GB
Definition: mui.h:135
#define MB
Definition: setuplib.h:53
static VOID ShowPartitionSizeInputBox(SHORT Left, SHORT Top, SHORT Right, SHORT Bottom, ULONG MaxSize, PWSTR InputBuffer, PBOOLEAN Quit, PBOOLEAN Cancel)
Definition: usetup.c:1810
PARTITION_STYLE DiskStyle
Definition: partlist.h:114
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define STRING_MB
Definition: mui.h:134
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
ULARGE_INTEGER SectorCount
Definition: partlist.h:90
void Cancel(int sigNum)
Definition: shell.c:481
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:88
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STRING_HDINFOPARTCREATE_2
Definition: mui.h:116
UNICODE_STRING DriverName
Definition: partlist.h:116
uint64_t ULONGLONG
Definition: typedefs.h:65
static PPARTLIST PartitionList
Definition: usetup.c:73
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
ULONG SectorCount
Definition: part_xbox.c:32
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
#define STRING_HDINFOPARTCREATE_1
Definition: mui.h:115
USHORT Port
Definition: partlist.h:106
#define PARTITION_MAXSIZE
Definition: usetup.c:1807
BOOLEAN CreateExtendedPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount)
Definition: partlist.c:3023
unsigned int ULONG
Definition: retypes.h:1
#define STRING_PLEASEWAIT
Definition: mui.h:74
#define GB
Definition: setuplib.h:54
#define STRING_CHOOSE_NEW_EXTENDED_PARTITION
Definition: mui.h:81

Referenced by RunUSetup().

◆ CreateLogicalPartitionPage()

static PAGE_NUMBER CreateLogicalPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2327 of file usetup.c.

2328 {
2329  PPARTENTRY PartEntry;
2330  PDISKENTRY DiskEntry;
2331  BOOLEAN Quit;
2332  BOOLEAN Cancel;
2333  WCHAR InputBuffer[50];
2334  ULONG MaxSize;
2335  ULONGLONG PartSize;
2336  ULONGLONG DiskSize;
2338  PCHAR Unit;
2339 
2340  if (PartitionList == NULL || CurrentPartition == NULL)
2341  {
2342  /* FIXME: show an error dialog */
2343  return QUIT_PAGE;
2344  }
2345 
2346  PartEntry = CurrentPartition;
2347  DiskEntry = CurrentPartition->DiskEntry;
2348 
2350 
2352 
2353  DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
2354 #if 0
2355  if (DiskSize >= 10 * GB) /* 10 GB */
2356  {
2357  DiskSize = DiskSize / GB;
2359  }
2360  else
2361 #endif
2362  {
2363  DiskSize = DiskSize / MB;
2364  if (DiskSize == 0)
2365  DiskSize = 1;
2366 
2368  }
2369 
2370  if (DiskEntry->DriverName.Length > 0)
2371  {
2372  CONSOLE_PrintTextXY(6, 10,
2374  DiskSize,
2375  Unit,
2376  DiskEntry->DiskNumber,
2377  DiskEntry->Port,
2378  DiskEntry->Bus,
2379  DiskEntry->Id,
2380  &DiskEntry->DriverName,
2381  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2382  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2383  "RAW");
2384  }
2385  else
2386  {
2387  CONSOLE_PrintTextXY(6, 10,
2389  DiskSize,
2390  Unit,
2391  DiskEntry->DiskNumber,
2392  DiskEntry->Port,
2393  DiskEntry->Bus,
2394  DiskEntry->Id,
2395  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2396  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2397  "RAW");
2398  }
2399 
2401 
2402 #if 0
2403  CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2404  CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
2405 #endif
2406 
2408 
2409  PartEntry = CurrentPartition;
2410  while (TRUE)
2411  {
2412  MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
2413 
2414  if (MaxSize > PARTITION_MAXSIZE)
2415  MaxSize = PARTITION_MAXSIZE;
2416 
2417  ShowPartitionSizeInputBox(12, 14, xScreen - 12, 17, /* left, top, right, bottom */
2418  MaxSize, InputBuffer, &Quit, &Cancel);
2419 
2420  if (Quit)
2421  {
2422  if (ConfirmQuit(Ir))
2423  return QUIT_PAGE;
2424 
2425  break;
2426  }
2427  else if (Cancel)
2428  {
2429  return SELECT_PARTITION_PAGE;
2430  }
2431  else
2432  {
2433  PartSize = _wcstoui64(InputBuffer, NULL, 10);
2434 
2435  if (PartSize < 1)
2436  {
2437  /* Too small */
2438  continue;
2439  }
2440 
2441  if (PartSize > MaxSize)
2442  {
2443  /* Too large */
2444  continue;
2445  }
2446 
2447  /* Convert to bytes */
2448  if (PartSize == MaxSize)
2449  {
2450  /* Use all of the unpartitioned disk space */
2451  SectorCount = PartEntry->SectorCount.QuadPart;
2452  }
2453  else
2454  {
2455  /* Calculate the sector count from the size in MB */
2456  SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
2457 
2458  /* But never get larger than the unpartitioned disk space */
2459  if (SectorCount > PartEntry->SectorCount.QuadPart)
2460  SectorCount = PartEntry->SectorCount.QuadPart;
2461  }
2462 
2463  DPRINT("Partition size: %I64u bytes\n", PartSize);
2464 
2467  SectorCount,
2468  FALSE);
2469 
2470  return SELECT_PARTITION_PAGE;
2471  }
2472  }
2473 
2475 }
signed char * PCHAR
Definition: retypes.h:7
#define STRING_HDDSIZE
Definition: mui.h:83
USHORT Id
Definition: partlist.h:108
#define TRUE
Definition: types.h:120
SHORT xScreen
Definition: consup.c:39
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:305
#define STRING_CREATEPARTITION
Definition: mui.h:84
Unit
Definition: gdiplusenums.h:25
#define STRING_CHOOSE_NEW_LOGICAL_PARTITION
Definition: mui.h:82
USHORT Bus
Definition: partlist.h:107
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:599
ULONG DiskNumber
Definition: partlist.h:104
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
CHAR InputBuffer[80]
Definition: conmgr.c:33
_Check_return_ __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _wcstoui64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define STRING_GB
Definition: mui.h:135
#define MB
Definition: setuplib.h:53
static VOID ShowPartitionSizeInputBox(SHORT Left, SHORT Top, SHORT Right, SHORT Bottom, ULONG MaxSize, PWSTR InputBuffer, PBOOLEAN Quit, PBOOLEAN Cancel)
Definition: usetup.c:1810
PARTITION_STYLE DiskStyle
Definition: partlist.h:114
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define STRING_MB
Definition: mui.h:134
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN CreateLogicalPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
Definition: partlist.c:3077
ULARGE_INTEGER SectorCount
Definition: partlist.h:90
void Cancel(int sigNum)
Definition: shell.c:481
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:88
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STRING_HDINFOPARTCREATE_2
Definition: mui.h:116
UNICODE_STRING DriverName
Definition: partlist.h:116
uint64_t ULONGLONG
Definition: typedefs.h:65
static PPARTLIST PartitionList
Definition: usetup.c:73
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
ULONG SectorCount
Definition: part_xbox.c:32
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
#define STRING_HDINFOPARTCREATE_1
Definition: mui.h:115
USHORT Port
Definition: partlist.h:106
#define PARTITION_MAXSIZE
Definition: usetup.c:1807
unsigned int ULONG
Definition: retypes.h:1
#define STRING_PLEASEWAIT
Definition: mui.h:74
#define GB
Definition: setuplib.h:54

Referenced by RunUSetup().

◆ CreatePrimaryPartitionPage()

static PAGE_NUMBER CreatePrimaryPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2004 of file usetup.c.

2005 {
2006  PPARTENTRY PartEntry;
2007  PDISKENTRY DiskEntry;
2008  BOOLEAN Quit;
2009  BOOLEAN Cancel;
2010  WCHAR InputBuffer[50];
2011  ULONG MaxSize;
2012  ULONGLONG PartSize;
2013  ULONGLONG DiskSize;
2015  PCHAR Unit;
2016 
2017  if (PartitionList == NULL || CurrentPartition == NULL)
2018  {
2019  /* FIXME: show an error dialog */
2020  return QUIT_PAGE;
2021  }
2022 
2023  PartEntry = CurrentPartition;
2024  DiskEntry = CurrentPartition->DiskEntry;
2025 
2027 
2029 
2030  DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
2031 #if 0
2032  if (DiskSize >= 10 * GB) /* 10 GB */
2033  {
2034  DiskSize = DiskSize / GB;
2036  }
2037  else
2038 #endif
2039  {
2040  DiskSize = DiskSize / MB;
2041  if (DiskSize == 0)
2042  DiskSize = 1;
2043 
2045  }
2046 
2047  if (DiskEntry->DriverName.Length > 0)
2048  {
2049  CONSOLE_PrintTextXY(6, 10,
2051  DiskSize,
2052  Unit,
2053  DiskEntry->DiskNumber,
2054  DiskEntry->Port,
2055  DiskEntry->Bus,
2056  DiskEntry->Id,
2057  &DiskEntry->DriverName,
2058  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2059  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2060  "RAW");
2061  }
2062  else
2063  {
2064  CONSOLE_PrintTextXY(6, 10,
2066  DiskSize,
2067  Unit,
2068  DiskEntry->DiskNumber,
2069  DiskEntry->Port,
2070  DiskEntry->Bus,
2071  DiskEntry->Id,
2072  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2073  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2074  "RAW");
2075  }
2076 
2078 
2079 #if 0
2080  CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2081  CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
2082 #endif
2083 
2085 
2086  PartEntry = CurrentPartition;
2087  while (TRUE)
2088  {
2089  MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
2090 
2091  if (MaxSize > PARTITION_MAXSIZE)
2092  MaxSize = PARTITION_MAXSIZE;
2093 
2094  ShowPartitionSizeInputBox(12, 14, xScreen - 12, 17, /* left, top, right, bottom */
2095  MaxSize, InputBuffer, &Quit, &Cancel);
2096 
2097  if (Quit)
2098  {
2099  if (ConfirmQuit(Ir))
2100  return QUIT_PAGE;
2101 
2102  break;
2103  }
2104  else if (Cancel)
2105  {
2106  return SELECT_PARTITION_PAGE;
2107  }
2108  else
2109  {
2110  PartSize = _wcstoui64(InputBuffer, NULL, 10);
2111 
2112  if (PartSize < 1)
2113  {
2114  /* Too small */
2115  continue;
2116  }
2117 
2118  if (PartSize > MaxSize)
2119  {
2120  /* Too large */
2121  continue;
2122  }
2123 
2124  /* Convert to bytes */
2125  if (PartSize == MaxSize)
2126  {
2127  /* Use all of the unpartitioned disk space */
2128  SectorCount = PartEntry->SectorCount.QuadPart;
2129  }
2130  else
2131  {
2132  /* Calculate the sector count from the size in MB */
2133  SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
2134 
2135  /* But never get larger than the unpartitioned disk space */
2136  if (SectorCount > PartEntry->SectorCount.QuadPart)
2137  SectorCount = PartEntry->SectorCount.QuadPart;
2138  }
2139 
2140  DPRINT ("Partition size: %I64u bytes\n", PartSize);
2141 
2144  SectorCount,
2145  FALSE);
2146 
2147  return SELECT_PARTITION_PAGE;
2148  }
2149  }
2150 
2152 }
signed char * PCHAR
Definition: retypes.h:7
#define STRING_HDDSIZE
Definition: mui.h:83
USHORT Id
Definition: partlist.h:108
#define TRUE
Definition: types.h:120
SHORT xScreen
Definition: consup.c:39
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:305
#define STRING_CREATEPARTITION
Definition: mui.h:84
Unit
Definition: gdiplusenums.h:25
USHORT Bus
Definition: partlist.h:107
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:599
ULONG DiskNumber
Definition: partlist.h:104
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
#define STRING_CHOOSENEWPARTITION
Definition: mui.h:80
CHAR InputBuffer[80]
Definition: conmgr.c:33
_Check_return_ __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _wcstoui64(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define STRING_GB
Definition: mui.h:135
#define MB
Definition: setuplib.h:53
static VOID ShowPartitionSizeInputBox(SHORT Left, SHORT Top, SHORT Right, SHORT Bottom, ULONG MaxSize, PWSTR InputBuffer, PBOOLEAN Quit, PBOOLEAN Cancel)
Definition: usetup.c:1810
PARTITION_STYLE DiskStyle
Definition: partlist.h:114
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define STRING_MB
Definition: mui.h:134
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
ULARGE_INTEGER SectorCount
Definition: partlist.h:90
void Cancel(int sigNum)
Definition: shell.c:481
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:88
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STRING_HDINFOPARTCREATE_2
Definition: mui.h:116
UNICODE_STRING DriverName
Definition: partlist.h:116
uint64_t ULONGLONG
Definition: typedefs.h:65
static PPARTLIST PartitionList
Definition: usetup.c:73
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
ULONG SectorCount
Definition: part_xbox.c:32
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
BOOLEAN CreatePrimaryPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
Definition: partlist.c:2959
#define STRING_HDINFOPARTCREATE_1
Definition: mui.h:115
USHORT Port
Definition: partlist.h:106
#define PARTITION_MAXSIZE
Definition: usetup.c:1807
unsigned int ULONG
Definition: retypes.h:1
#define STRING_PLEASEWAIT
Definition: mui.h:74
#define GB
Definition: setuplib.h:54

Referenced by RunUSetup().

◆ DeletePartitionPage()

static PAGE_NUMBER DeletePartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2530 of file usetup.c.

2531 {
2532  PPARTENTRY PartEntry;
2533  PDISKENTRY DiskEntry;
2534  ULONGLONG DiskSize;
2535  ULONGLONG PartSize;
2536  PCHAR Unit;
2537  CHAR PartTypeString[32];
2538 
2539  if (PartitionList == NULL || CurrentPartition == NULL)
2540  {
2541  /* FIXME: show an error dialog */
2542  return QUIT_PAGE;
2543  }
2544 
2545  PartEntry = CurrentPartition;
2546  DiskEntry = CurrentPartition->DiskEntry;
2547 
2549 
2550  /* Adjust partition type */
2552  PartTypeString,
2553  ARRAYSIZE(PartTypeString));
2554 
2555  PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
2556 #if 0
2557  if (PartSize >= 10 * GB) /* 10 GB */
2558  {
2559  PartSize = PartSize / GB;
2561  }
2562  else
2563 #endif
2564  if (PartSize >= 10 * MB) /* 10 MB */
2565  {
2566  PartSize = PartSize / MB;
2568  }
2569  else
2570  {
2571  PartSize = PartSize / KB;
2573  }
2574 
2575  if (*PartTypeString == '\0') // STRING_FORMATUNKNOWN ??
2576  {
2577  CONSOLE_PrintTextXY(6, 10,
2579  (PartEntry->DriveLetter == 0) ? '-' : (CHAR)PartEntry->DriveLetter,
2580  (PartEntry->DriveLetter == 0) ? '-' : ':',
2581  PartEntry->PartitionType,
2582  PartSize,
2583  Unit);
2584  }
2585  else
2586  {
2587  CONSOLE_PrintTextXY(6, 10,
2588  " %c%c %s %I64u %s",
2589  (PartEntry->DriveLetter == 0) ? '-' : (CHAR)PartEntry->DriveLetter,
2590  (PartEntry->DriveLetter == 0) ? '-' : ':',
2591  PartTypeString,
2592  PartSize,
2593  Unit);
2594  }
2595 
2596  DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
2597 #if 0
2598  if (DiskSize >= 10 * GB) /* 10 GB */
2599  {
2600  DiskSize = DiskSize / GB;
2602  }
2603  else
2604 #endif
2605  {
2606  DiskSize = DiskSize / MB;
2607  if (DiskSize == 0)
2608  DiskSize = 1;
2609 
2611  }
2612 
2613  if (DiskEntry->DriverName.Length > 0)
2614  {
2615  CONSOLE_PrintTextXY(6, 12,
2617  DiskSize,
2618  Unit,
2619  DiskEntry->DiskNumber,
2620  DiskEntry->Port,
2621  DiskEntry->Bus,
2622  DiskEntry->Id,
2623  &DiskEntry->DriverName,
2624  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2625  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2626  "RAW");
2627  }
2628  else
2629  {
2630  CONSOLE_PrintTextXY(6, 12,
2632  DiskSize,
2633  Unit,
2634  DiskEntry->DiskNumber,
2635  DiskEntry->Port,
2636  DiskEntry->Bus,
2637  DiskEntry->Id,
2638  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
2639  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
2640  "RAW");
2641  }
2642 
2643  while (TRUE)
2644  {
2645  CONSOLE_ConInKey(Ir);
2646 
2647  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
2648  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
2649  {
2650  if (ConfirmQuit(Ir))
2651  return QUIT_PAGE;
2652 
2653  break;
2654  }
2655  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESC */
2656  {
2657  return SELECT_PARTITION_PAGE;
2658  }
2659  else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'L') /* L */
2660  {
2663  &CurrentPartition);
2664  return SELECT_PARTITION_PAGE;
2665  }
2666  }
2667 
2668  return DELETE_PARTITION_PAGE;
2669 }
signed char * PCHAR
Definition: retypes.h:7
WCHAR DriveLetter
Definition: partlist.h:51
USHORT Id
Definition: partlist.h:108
#define TRUE
Definition: types.h:120
Unit
Definition: gdiplusenums.h:25
BOOLEAN DeletePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, OUT PPARTENTRY *FreeRegion OPTIONAL)
Definition: partlist.c:3220
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
USHORT Bus
Definition: partlist.h:107
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
char CHAR
Definition: xmlstorage.h:175
#define STRING_HDINFOPARTDELETE_2
Definition: mui.h:119
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:599
#define STRING_KB
Definition: mui.h:133
ULONG DiskNumber
Definition: partlist.h:104
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
#define VK_ESCAPE
Definition: winuser.h:2189
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
#define STRING_GB
Definition: mui.h:135
#define MB
Definition: setuplib.h:53
PARTITION_STYLE DiskStyle
Definition: partlist.h:114
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define STRING_HDINFOPARTDELETE_1
Definition: mui.h:118
#define STRING_MB
Definition: mui.h:134
smooth NULL
Definition: ftsmooth.c:416
ULARGE_INTEGER SectorCount
Definition: partlist.h:90
#define STRING_HDDINFOUNK2
Definition: mui.h:117
union _KEY_EVENT_RECORD::@3153 uChar
UCHAR PartitionType
Definition: partlist.h:46
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:88
UNICODE_STRING DriverName
Definition: partlist.h:116
uint64_t ULONGLONG
Definition: typedefs.h:65
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
static PPARTLIST PartitionList
Definition: usetup.c:73
#define VK_F3
Definition: winuser.h:2232
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
USHORT Port
Definition: partlist.h:106
VOID GetPartTypeStringFromPartitionType(IN UCHAR partitionType, OUT PCHAR strPartType, IN ULONG cchPartType)
Definition: drivepage.c:237
#define GB
Definition: setuplib.h:54
#define KB
Definition: setuplib.h:52
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ DeviceSettingsPage()

static PAGE_NUMBER DeviceSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1133 of file usetup.c.

1134 {
1135  static ULONG Line = 16;
1136 
1137  /* Initialize the computer settings list */
1138  if (USetupData.ComputerList == NULL)
1139  {
1140  USetupData.ComputerList = CreateComputerTypeList(USetupData.SetupInf);
1141  if (USetupData.ComputerList == NULL)
1142  {
1144  return QUIT_PAGE;
1145  }
1146  }
1147 
1148  /* Initialize the display settings list */
1149  if (USetupData.DisplayList == NULL)
1150  {
1151  USetupData.DisplayList = CreateDisplayDriverList(USetupData.SetupInf);
1152  if (USetupData.DisplayList == NULL)
1153  {
1155  return QUIT_PAGE;
1156  }
1157  }
1158 
1159  /* Initialize the keyboard settings list */
1160  if (USetupData.KeyboardList == NULL)
1161  {
1162  USetupData.KeyboardList = CreateKeyboardDriverList(USetupData.SetupInf);
1163  if (USetupData.KeyboardList == NULL)
1164  {
1166  return QUIT_PAGE;
1167  }
1168  }
1169 
1170  /* Initialize the keyboard layout list */
1171  if (USetupData.LayoutList == NULL)
1172  {
1174  if (USetupData.LayoutList == NULL)
1175  {
1176  /* FIXME: report error */
1178  return QUIT_PAGE;
1179  }
1180  }
1181 
1182  if (RepairUpdateFlag)
1183  return SELECT_PARTITION_PAGE;
1184 
1185  // if (IsUnattendedSetup)
1186  // return SELECT_PARTITION_PAGE;
1187 
1189 
1194 
1195  CONSOLE_InvertTextXY(24, Line, 48, 1);
1196 
1197  while (TRUE)
1198  {
1199  CONSOLE_ConInKey(Ir);
1200 
1201  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1202  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
1203  {
1204  CONSOLE_NormalTextXY(24, Line, 48, 1);
1205 
1206  if (Line == 14)
1207  Line = 16;
1208  else if (Line == 16)
1209  Line = 11;
1210  else
1211  Line++;
1212 
1213  CONSOLE_InvertTextXY(24, Line, 48, 1);
1214  }
1215  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1216  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
1217  {
1218  CONSOLE_NormalTextXY(24, Line, 48, 1);
1219 
1220  if (Line == 11)
1221  Line = 16;
1222  else if (Line == 16)
1223  Line = 14;
1224  else
1225  Line--;
1226 
1227  CONSOLE_InvertTextXY(24, Line, 48, 1);
1228  }
1229  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1230  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1231  {
1232  if (ConfirmQuit(Ir))
1233  return QUIT_PAGE;
1234 
1235  break;
1236  }
1237  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1238  {
1239  if (Line == 11)
1240  return COMPUTER_SETTINGS_PAGE;
1241  else if (Line == 12)
1242  return DISPLAY_SETTINGS_PAGE;
1243  else if (Line == 13)
1244  return KEYBOARD_SETTINGS_PAGE;
1245  else if (Line == 14)
1246  return LAYOUT_SETTINGS_PAGE;
1247  else if (Line == 16)
1248  return SELECT_PARTITION_PAGE;
1249  }
1250  }
1251 
1252  return DEVICE_SETTINGS_PAGE;
1253 }
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
#define VK_DOWN
Definition: winuser.h:2202
PGENERIC_LIST CreateKeyboardLayoutList(IN HINF InfFile, IN PCWSTR LanguageId, OUT PWSTR DefaultKBLayout)
Definition: settings.c:1210
VOID CONSOLE_NormalTextXY(IN SHORT x, IN SHORT y, IN SHORT col, IN SHORT row)
Definition: consup.c:282
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
VOID CONSOLE_InvertTextXY(IN SHORT x, IN SHORT y, IN SHORT col, IN SHORT row)
Definition: consup.c:259
#define VK_UP
Definition: winuser.h:2200
smooth NULL
Definition: ftsmooth.c:416
PGENERIC_LIST CreateDisplayDriverList(IN HINF InfFile)
Definition: settings.c:699
union _KEY_EVENT_RECORD::@3153 uChar
VOID DrawGenericListCurrentItem(IN PGENERIC_LIST List, IN PGET_ENTRY_DESCRIPTION GetEntryDescriptionProc, IN SHORT Left, IN SHORT Top)
Definition: genlist.c:353
PCWSTR SelectedLanguageId
Definition: usetup.c:66
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2232
Definition: ncftp.h:79
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
PGENERIC_LIST CreateComputerTypeList(IN HINF InfFile)
Definition: settings.c:515
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:70
unsigned int ULONG
Definition: retypes.h:1
PGENERIC_LIST CreateKeyboardDriverList(IN HINF InfFile)
Definition: settings.c:1073
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
static WCHAR DefaultKBLayout[20]
Definition: usetup.c:68
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:438

Referenced by RunUSetup().

◆ DisplaySettingsPage()

static PAGE_NUMBER DisplaySettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1357 of file usetup.c.

1358 {
1359  GENERIC_LIST_UI ListUi;
1361 
1362  InitGenericListUi(&ListUi, USetupData.DisplayList, GetSettingDescription);
1363  DrawGenericList(&ListUi,
1364  2, 18,
1365  xScreen - 3,
1366  yScreen - 3);
1367 
1368  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1369 }
static USETUP_DATA USetupData
Definition: usetup.c:47
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
VOID InitGenericListUi(IN OUT PGENERIC_LIST_UI ListUi, IN PGENERIC_LIST List, IN PGET_ENTRY_DESCRIPTION GetEntryDescriptionProc)
Definition: genlist.c:37
static PAGE_NUMBER HandleGenericList(PGENERIC_LIST_UI ListUi, PAGE_NUMBER nextPage, PINPUT_RECORD Ir)
Definition: usetup.c:1265
VOID DrawGenericList(IN PGENERIC_LIST_UI ListUi, IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom)
Definition: genlist.c:326
SHORT yScreen
Definition: consup.c:40
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:438

Referenced by RunUSetup().

◆ DrawBox()

static VOID DrawBox ( IN SHORT  xLeft,
IN SHORT  yTop,
IN SHORT  Width,
IN SHORT  Height 
)
static

Definition at line 113 of file usetup.c.

117 {
118  COORD coPos;
119  DWORD Written;
120 
121  /* Draw upper left corner */
122  coPos.X = xLeft;
123  coPos.Y = yTop;
125  0xDA, // '+',
126  1,
127  coPos,
128  &Written);
129 
130  /* Draw upper edge */
131  coPos.X = xLeft + 1;
132  coPos.Y = yTop;
134  0xC4, // '-',
135  Width - 2,
136  coPos,
137  &Written);
138 
139  /* Draw upper right corner */
140  coPos.X = xLeft + Width - 1;
141  coPos.Y = yTop;
143  0xBF, // '+',
144  1,
145  coPos,
146  &Written);
147 
148  /* Draw right edge, inner space and left edge */
149  for (coPos.Y = yTop + 1; coPos.Y < yTop + Height - 1; coPos.Y++)
150  {
151  coPos.X = xLeft;
153  0xB3, // '|',
154  1,
155  coPos,
156  &Written);
157 
158  coPos.X = xLeft + 1;
160  ' ',
161  Width - 2,
162  coPos,
163  &Written);
164 
165  coPos.X = xLeft + Width - 1;
167  0xB3, // '|',
168  1,
169  coPos,
170  &Written);
171  }
172 
173  /* Draw lower left corner */
174  coPos.X = xLeft;
175  coPos.Y = yTop + Height - 1;
177  0xC0, // '+',
178  1,
179  coPos,
180  &Written);
181 
182  /* Draw lower edge */
183  coPos.X = xLeft + 1;
184  coPos.Y = yTop + Height - 1;
186  0xC4, // '-',
187  Width - 2,
188  coPos,
189  &Written);
190 
191  /* Draw lower right corner */
192  coPos.X = xLeft + Width - 1;
193  coPos.Y = yTop + Height - 1;
195  0xD9, // '+',
196  1,
197  coPos,
198  &Written);
199 }
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
HANDLE StdOutput
Definition: consup.c:37
ULONG X
Definition: bl.h:1340
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1341

Referenced by PopupError(), and ShowPartitionSizeInputBox().

◆ FileCopyCallback()

static UINT CALLBACK FileCopyCallback ( PVOID  Context,
UINT  Notification,
UINT_PTR  Param1,
UINT_PTR  Param2 
)
static

Definition at line 3986 of file usetup.c.

3990 {
3991  PCOPYCONTEXT CopyContext = (PCOPYCONTEXT)Context;
3992  PFILEPATHS_W FilePathInfo;
3993  PCWSTR SrcFileName, DstFileName;
3994 
3995  switch (Notification)
3996  {
3998  {
3999  CopyContext->TotalOperations = (ULONG)Param2;
4000  CopyContext->CompletedOperations = 0;
4001  ProgressSetStepCount(CopyContext->ProgressBar,
4002  CopyContext->TotalOperations);
4003  SetupUpdateMemoryInfo(CopyContext, TRUE);
4004  break;
4005  }
4006 
4010  {
4011  FilePathInfo = (PFILEPATHS_W)Param1;
4012 
4013  if (Notification == SPFILENOTIFY_STARTDELETE)
4014  {
4015  /* Display delete message */
4016  ASSERT(Param2 == FILEOP_DELETE);
4017 
4018  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
4019  if (DstFileName) ++DstFileName;
4020  else DstFileName = FilePathInfo->Target;
4021 
4023  DstFileName);
4024  }
4025  else if (Notification == SPFILENOTIFY_STARTRENAME)
4026  {
4027  /* Display move/rename message */
4028  ASSERT(Param2 == FILEOP_RENAME);
4029 
4030  SrcFileName = wcsrchr(FilePathInfo->Source, L'\\');
4031  if (SrcFileName) ++SrcFileName;
4032  else SrcFileName = FilePathInfo->Source;
4033 
4034  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
4035  if (DstFileName) ++DstFileName;
4036  else DstFileName = FilePathInfo->Target;
4037 
4038  if (!wcsicmp(SrcFileName, DstFileName))
4039  Param2 = STRING_MOVING;
4040  else
4041  Param2 = STRING_RENAMING;
4042 
4044  SrcFileName, DstFileName);
4045  }
4046  else if (Notification == SPFILENOTIFY_STARTCOPY)
4047  {
4048  /* Display copy message */
4049  ASSERT(Param2 == FILEOP_COPY);
4050 
4051  /* NOTE: When extracting from CABs the Source is the CAB name */
4052  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
4053  if (DstFileName) ++DstFileName;
4054  else DstFileName = FilePathInfo->Target;
4055 
4057  DstFileName);
4058  }
4059 
4060  SetupUpdateMemoryInfo(CopyContext, FALSE);
4061  break;
4062  }
4063 
4065  {
4066  FilePathInfo = (PFILEPATHS_W)Param1;
4067 
4068  DPRINT1("An error happened while trying to copy file '%S' (error 0x%08lx), skipping it...\n",
4069  FilePathInfo->Target, FilePathInfo->Win32Error);
4070  return FILEOP_SKIP;
4071  }
4072 
4075  case SPFILENOTIFY_ENDCOPY:
4076  {
4077  CopyContext->CompletedOperations++;
4078 
4079  /* SYSREG checkpoint */
4080  if (CopyContext->TotalOperations >> 1 == CopyContext->CompletedOperations)
4081  DPRINT1("CHECKPOINT:HALF_COPIED\n");
4082 
4083  ProgressNextStep(CopyContext->ProgressBar);
4084  SetupUpdateMemoryInfo(CopyContext, FALSE);
4085  break;
4086  }
4087  }
4088 
4089  return FILEOP_DOIT;
4090 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define TRUE
Definition: types.h:120
#define FILEOP_RENAME
Definition: fileqsup.h:43
ULONG TotalOperations
Definition: reactos.c:980
#define SPFILENOTIFY_ENDCOPY
Definition: fileqsup.h:36
UINT Win32Error
Definition: fileqsup.h:62
VOID ProgressNextStep(IN PPROGRESSBAR Bar)
Definition: progress.c:361
#define SPFILENOTIFY_STARTRENAME
Definition: fileqsup.h:31
#define SPFILENOTIFY_ENDRENAME
Definition: fileqsup.h:32
#define STRING_COPYING
Definition: mui.h:97
#define SPFILENOTIFY_STARTSUBQUEUE
Definition: fileqsup.h:24
VOID ProgressSetStepCount(IN PPROGRESSBAR Bar, IN ULONG StepCount)
Definition: progress.c:347
#define FILEOP_COPY
Definition: fileqsup.h:42
#define SPFILENOTIFY_ENDDELETE
Definition: fileqsup.h:28
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define SPFILENOTIFY_STARTCOPY
Definition: fileqsup.h:35
#define SPFILENOTIFY_STARTDELETE
Definition: fileqsup.h:27
#define STRING_RENAMING
Definition: mui.h:96
#define FILEOP_DOIT
Definition: fileqsup.h:48
#define SPFILENOTIFY_COPYERROR
Definition: fileqsup.h:37
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STRING_MOVING
Definition: mui.h:95
ULONG CompletedOperations
Definition: reactos.c:981
static const WCHAR L[]
Definition: oid.c:1250
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
PCWSTR Source
Definition: fileqsup.h:61
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
#define wcsicmp
Definition: string.h:1152
static VOID SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext, IN BOOLEAN First)
Definition: usetup.c:3958
#define FILEOP_SKIP
Definition: fileqsup.h:49
PCWSTR Target
Definition: fileqsup.h:60
#define DPRINT1
Definition: precomp.h:8
struct _COPYCONTEXT * PCOPYCONTEXT
unsigned int ULONG
Definition: retypes.h:1
struct _FILEPATHS_W * PFILEPATHS_W
#define STRING_DELETING
Definition: mui.h:94
PPROGRESSBAR ProgressBar
Definition: usetup.c:3953
#define FILEOP_DELETE
Definition: fileqsup.h:44

Referenced by FileCopyPage().

◆ FileCopyPage()

static PAGE_NUMBER FileCopyPage ( PINPUT_RECORD  Ir)
static

Definition at line 4106 of file usetup.c.

4107 {
4108  COPYCONTEXT CopyContext;
4109  UINT MemBarWidth;
4110 
4112 
4113  /* Create context for the copy process */
4114  CopyContext.TotalOperations = 0;
4115  CopyContext.CompletedOperations = 0;
4116 
4117  /* Create the progress bar as well */
4118  CopyContext.ProgressBar = CreateProgressBar(13,
4119  26,
4120  xScreen - 13,
4121  yScreen - 20,
4122  10,
4123  24,
4124  TRUE,
4126 
4127  // fit memory bars to screen width, distribute them uniform
4128  MemBarWidth = (xScreen - 26) / 5;
4129  MemBarWidth -= MemBarWidth % 2; // make even
4130  /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
4131  /* Create the paged pool progress bar */
4132  CopyContext.MemoryBars[0] = CreateProgressBar(13,
4133  40,
4134  13 + MemBarWidth,
4135  43,
4136  13,
4137  44,
4138  FALSE,
4139  "Kernel Pool");
4140 
4141  /* Create the non paged pool progress bar */
4142  CopyContext.MemoryBars[1] = CreateProgressBar((xScreen / 2)- (MemBarWidth / 2),
4143  40,
4144  (xScreen / 2) + (MemBarWidth / 2),
4145  43,
4146  (xScreen / 2)- (MemBarWidth / 2),
4147  44,
4148  FALSE,
4149  "Kernel Cache");
4150 
4151  /* Create the global memory progress bar */
4152  CopyContext.MemoryBars[2] = CreateProgressBar(xScreen - 13 - MemBarWidth,
4153  40,
4154  xScreen - 13,
4155  43,
4156  xScreen - 13 - MemBarWidth,
4157  44,
4158  FALSE,
4159  "Free Memory");
4160 
4161  /* Do the file copying */
4162  DoFileCopy(&USetupData, FileCopyCallback, &CopyContext);
4163 
4164  /* If we get here, we're done, so cleanup the progress bar */
4165  DestroyProgressBar(CopyContext.ProgressBar);
4166  DestroyProgressBar(CopyContext.MemoryBars[0]);
4167  DestroyProgressBar(CopyContext.MemoryBars[1]);
4168  DestroyProgressBar(CopyContext.MemoryBars[2]);
4169 
4170  /* Create the $winnt$.inf file */
4172 
4173  /* Go display the next page */
4174  return REGISTRY_PAGE;
4175 }
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
ULONG TotalOperations
Definition: reactos.c:980
VOID DestroyProgressBar(IN OUT PPROGRESSBAR Bar)
Definition: progress.c:339
VOID InstallSetupInfFile(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:214
BOOLEAN DoFileCopy(IN OUT PUSETUP_DATA pSetupData, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: install.c:818
PPROGRESSBAR MemoryBars[4]
Definition: usetup.c:3954
ULONG CompletedOperations
Definition: reactos.c:981
static UINT CALLBACK FileCopyCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
Definition: usetup.c:3986
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
SHORT yScreen
Definition: consup.c:40
PPROGRESSBAR CreateProgressBar(IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN PCSTR DescriptionText OPTIONAL)
Definition: progress.c:317
unsigned int UINT
Definition: ndis.h:50
PPROGRESSBAR ProgressBar
Definition: usetup.c:3953
#define STRING_SETUPCOPYINGFILES
Definition: mui.h:98

Referenced by RunUSetup().

◆ FlushPage()

static PAGE_NUMBER FlushPage ( PINPUT_RECORD  Ir)
static

Definition at line 4900 of file usetup.c.

4901 {
4903  return REBOOT_PAGE;
4904 }
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149

Referenced by RunUSetup().

◆ FormatPartitionPage()

static PAGE_NUMBER FormatPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 3338 of file usetup.c.

3339 {
3340  NTSTATUS Status;
3341  PPARTENTRY PartEntry;
3342  PDISKENTRY DiskEntry;
3343  PFILE_SYSTEM_ITEM SelectedFileSystem;
3344  UNICODE_STRING PartitionRootPath;
3345  WCHAR PathBuffer[MAX_PATH];
3346  CHAR Buffer[MAX_PATH];
3347 
3348 #ifndef NDEBUG
3349  ULONG Line;
3350  ULONG i;
3352 #endif
3353 
3354  DPRINT("FormatPartitionPage()\n");
3355 
3357 
3358  if (PartitionList == NULL || TempPartition == NULL)
3359  {
3360  /* FIXME: show an error dialog */
3361  return QUIT_PAGE;
3362  }
3363 
3364  PartEntry = TempPartition;
3365  DiskEntry = TempPartition->DiskEntry;
3366 
3367  ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
3368 
3369  SelectedFileSystem = FileSystemList->Selected;
3370  ASSERT(SelectedFileSystem && SelectedFileSystem->FileSystem);
3371 
3372  while (TRUE)
3373  {
3374  if (!IsUnattendedSetup)
3375  CONSOLE_ConInKey(Ir);
3376 
3377  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3378  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
3379  {
3380  if (ConfirmQuit(Ir))
3381  {
3382  /* Reset the filesystem list */
3384  return QUIT_PAGE;
3385  }
3386 
3387  break;
3388  }
3389  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN || IsUnattendedSetup) /* ENTER */
3390  {
3392 
3393  if (!PreparePartitionForFormatting(PartEntry, SelectedFileSystem->FileSystem))
3394  {
3395  /* FIXME: show an error dialog */
3396 
3397  /* Reset the filesystem list */
3399 
3400  return QUIT_PAGE;
3401  }
3402 
3403 #ifndef NDEBUG
3404  CONSOLE_PrintTextXY(6, 12,
3405  "Cylinders: %I64u Tracks/Cyl: %lu Sectors/Trk: %lu Bytes/Sec: %lu %c",
3406  DiskEntry->Cylinders,
3407  DiskEntry->TracksPerCylinder,
3408  DiskEntry->SectorsPerTrack,
3409  DiskEntry->BytesPerSector,
3410  DiskEntry->Dirty ? '*' : ' ');
3411 
3412  Line = 13;
3413 
3414  for (i = 0; i < DiskEntry->LayoutBuffer->PartitionCount; i++)
3415  {
3416  PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[i];
3417 
3419  "%2u: %2lu %c %12I64u %12I64u %02x",
3420  i,
3421  PartitionInfo->PartitionNumber,
3422  PartitionInfo->BootIndicator ? 'A' : '-',
3423  PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector,
3424  PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector,
3425  PartitionInfo->PartitionType);
3426  Line++;
3427  }
3428 #endif
3429 
3430  /* Commit the partition changes to the disk */
3431  Status = WritePartitions(DiskEntry);
3432  if (!NT_SUCCESS(Status))
3433  {
3434  DPRINT1("WritePartitions(disk %lu) failed, Status 0x%08lx\n",
3435  DiskEntry->DiskNumber, Status);
3436 
3438 
3439  /* Reset the filesystem list */
3441 
3442  return QUIT_PAGE;
3443  }
3444 
3445  /* Set PartitionRootPath */
3446  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
3447  L"\\Device\\Harddisk%lu\\Partition%lu",
3448  DiskEntry->DiskNumber,
3449  PartEntry->PartitionNumber);
3450  RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
3451  DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
3452 
3453  /* Format the partition */
3454  Status = FormatPartition(&PartitionRootPath,
3455  SelectedFileSystem->FileSystem,
3456  SelectedFileSystem->QuickFormat);
3458  {
3459  sprintf(Buffer,
3460  "Setup is currently unable to format a partition in %S.\n"
3461  "\n"
3462  " \x07 Press ENTER to continue Setup.\n"
3463  " \x07 Press F3 to quit Setup.",
3464  SelectedFileSystem->FileSystem);
3465 
3469 
3470  while (TRUE)
3471  {
3472  CONSOLE_ConInKey(Ir);
3473 
3474  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x00 &&
3475  Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3) /* F3 */
3476  {
3477  if (ConfirmQuit(Ir))
3478  {
3479  /* Reset the filesystem list */
3481  return QUIT_PAGE;
3482  }
3483  else
3484  {
3485  return SELECT_FILE_SYSTEM_PAGE;
3486  }
3487  }
3488  else if (Ir->Event.KeyEvent.uChar.AsciiChar == VK_RETURN) /* ENTER */
3489  {
3490  return SELECT_FILE_SYSTEM_PAGE;
3491  }
3492  }
3493  }
3494  else if (!NT_SUCCESS(Status))
3495  {
3496  DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status);
3498 
3499  /* Reset the filesystem list */
3501 
3502  return QUIT_PAGE;
3503  }
3504 
3505 //
3506 // TODO: Here, call a partlist.c function that update the actual FS name
3507 // and the label fields of the volume.
3508 //
3509  PartEntry->FormatState = Formatted;
3510  // PartEntry->FileSystem = FileSystem;
3511  PartEntry->New = FALSE;
3512 
3513 #ifndef NDEBUG
3514  CONSOLE_SetStatusText(" Done. Press any key ...");
3515  CONSOLE_ConInKey(Ir);
3516 #endif
3517 
3518  return SELECT_FILE_SYSTEM_PAGE;
3519  }
3520  }
3521 
3522  return FORMAT_PARTITION_PAGE;
3523 }
NTSTATUS FormatPartition(IN PUNICODE_STRING DriveRoot, IN PCWSTR FileSystemName, IN BOOLEAN QuickFormat)
Definition: format.c:89
ULONG PartitionNumber
Definition: partlist.h:48
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:124
static VOID ResetFileSystemList(VOID)
Definition: usetup.c:2673
static PPARTENTRY TempPartition
Definition: usetup.c:82
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
char CHAR
Definition: xmlstorage.h:175
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:599
LONG NTSTATUS
Definition: precomp.h:26
PCWSTR FileSystem
Definition: fslist.h:34
VOID PopupError(PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
Definition: usetup.c:203
ULONG DiskNumber
Definition: partlist.h:104
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static PFILE_SYSTEM_LIST FileSystemList
Definition: usetup.c:79
#define POPUP_WAIT_ANY_KEY
Definition: usetup.h:125
#define VK_RETURN
Definition: winuser.h:2176
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FORMATSTATE FormatState
Definition: partlist.h:54
BOOLEAN Dirty
Definition: partlist.h:111
smooth NULL
Definition: ftsmooth.c:416
PARTITION_INFORMATION PartitionEntry[1]
Definition: ntdddisk.h:471
PFILE_SYSTEM_ITEM Selected
Definition: fslist.h:42
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
union _KEY_EVENT_RECORD::@3153 uChar
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:88
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
static PPARTLIST PartitionList
Definition: usetup.c:73
#define VK_F3
Definition: winuser.h:2232
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ncftp.h:79
static const WCHAR L[]
Definition: oid.c:1250
ULONG SectorsPerTrack
Definition: partlist.h:87
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
BOOLEAN QuickFormat
Definition: fslist.h:35
ULONGLONG Cylinders
Definition: partlist.h:85
BOOLEAN New
Definition: partlist.h:64
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
BOOLEAN IsUnattendedSetup
Definition: usetup.c:45
ULONG TracksPerCylinder
Definition: partlist.h:86
#define DPRINT1
Definition: precomp.h:8
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3792
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STRING_PLEASEWAIT
Definition: mui.h:74
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:118
BOOLEAN PreparePartitionForFormatting(IN struct _PARTENTRY *PartEntry, IN PCWSTR FileSystemName)
Definition: fsutil.c:536
struct Line Line
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STRING_QUITCONTINUE
Definition: mui.h:92
BOOLEAN IsPartitioned
Definition: partlist.h:59

Referenced by RunUSetup().

◆ GetNTOSInstallationName()

static NTSTATUS NTAPI GetNTOSInstallationName ( IN PGENERIC_LIST_ENTRY  Entry,
OUT PSTR  Buffer,
IN SIZE_T  cchBufferSize 
)
static

Definition at line 449 of file usetup.c.

453 {
455  PPARTENTRY PartEntry = NtOsInstall->PartEntry;
456 
457  if (PartEntry && PartEntry->DriveLetter)
458  {
459  /* We have retrieved a partition that is mounted */
461  "%C:%S \"%S\"",
462  PartEntry->DriveLetter,
463  NtOsInstall->PathComponent,
464  NtOsInstall->InstallationName);
465  }
466  else
467  {
468  /* We failed somewhere, just show the NT path */
470  "%wZ \"%S\"",
471  &NtOsInstall->SystemNtPath,
472  NtOsInstall->InstallationName);
473  }
474 }
WCHAR DriveLetter
Definition: partlist.h:51
IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
Definition: progress.h:34
PPARTENTRY PartEntry
Definition: osdetect.h:25
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
Definition: bufpool.h:45
WCHAR InstallationName[MAX_PATH]
Definition: osdetect.h:26
struct _NTOS_INSTALLATION * PNTOS_INSTALLATION
PCWSTR PathComponent
Definition: osdetect.h:22
base of all file and directory entries
Definition: entries.h:82
UNICODE_STRING SystemNtPath
Definition: osdetect.h:21

Referenced by UpgradeRepairPage().

◆ GetSettingDescription()

static NTSTATUS NTAPI GetSettingDescription ( IN PGENERIC_LIST_ENTRY  Entry,
OUT PSTR  Buffer,
IN SIZE_T  cchBufferSize 
)
static

Definition at line 438 of file usetup.c.

442 {
445 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
Definition: progress.h:34
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
Definition: bufpool.h:45
base of all file and directory entries
Definition: entries.h:82

Referenced by ComputerSettingsPage(), DeviceSettingsPage(), DisplaySettingsPage(), KeyboardSettingsPage(), LanguagePage(), and LayoutSettingsPage().

◆ HandleGenericList()

static PAGE_NUMBER HandleGenericList ( PGENERIC_LIST_UI  ListUi,
PAGE_NUMBER  nextPage,
PINPUT_RECORD  Ir 
)
static

Definition at line 1265 of file usetup.c.

1268 {
1269  while (TRUE)
1270  {
1271  CONSOLE_ConInKey(Ir);
1272 
1273  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1274  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
1275  {
1276  ScrollDownGenericList(ListUi);
1277  }
1278  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1279  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
1280  {
1281  ScrollUpGenericList(ListUi);
1282  }
1283  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1284  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
1285  {
1286  ScrollPageDownGenericList(ListUi);
1287  }
1288  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1289  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
1290  {
1291  ScrollPageUpGenericList(ListUi);
1292  }
1293  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1294  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1295  {
1296  if (ConfirmQuit(Ir))
1297  return QUIT_PAGE;
1298  else
1299  RedrawGenericList(ListUi);
1300  }
1301  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1302  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
1303  {
1304  RestoreGenericListUiState(ListUi);
1305  return nextPage; // Use some "prevPage;" instead?
1306  }
1307  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1308  {
1309  return nextPage;
1310  }
1311  else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
1312  {
1313  /* a-z */
1315  }
1316  }
1317 }
#define TRUE
Definition: types.h:120
VOID RestoreGenericListUiState(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:62
VOID RedrawGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:511
#define VK_DOWN
Definition: winuser.h:2202
#define VK_PRIOR
Definition: winuser.h:2195
#define VK_ESCAPE
Definition: winuser.h:2189
#define VK_NEXT
Definition: winuser.h:2196
WORD wVirtualKeyCode
Definition: wincon.h:227
VOID ScrollDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:376
union _INPUT_RECORD::@3154 Event
#define VK_UP
Definition: winuser.h:2200
VOID ScrollPageUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:454
VOID ScrollPageDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:432
union _KEY_EVENT_RECORD::@3153 uChar
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2232
VOID GenericListKeyPress(IN PGENERIC_LIST_UI ListUi, IN CHAR AsciiChar)
Definition: genlist.c:525
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
VOID ScrollUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:404
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by ComputerSettingsPage(), DisplaySettingsPage(), KeyboardSettingsPage(), and LayoutSettingsPage().

◆ InstallDirectoryPage()

static PAGE_NUMBER InstallDirectoryPage ( PINPUT_RECORD  Ir)
static

Definition at line 3695 of file usetup.c.

3696 {
3697  NTSTATUS Status;
3698  ULONG Length, Pos;
3699  WCHAR c;
3700  WCHAR InstallDir[MAX_PATH];
3701 
3702  /* We do not need the filesystem list anymore */
3704 
3705  if (PartitionList == NULL || InstallPartition == NULL)
3706  {
3707  /* FIXME: show an error dialog */
3708  return QUIT_PAGE;
3709  }
3710 
3711  // if (IsUnattendedSetup)
3712  if (RepairUpdateFlag)
3713  wcscpy(InstallDir, CurrentInstallation->PathComponent); // SystemNtPath
3714  else if (USetupData.InstallationDirectory[0])
3715  wcscpy(InstallDir, USetupData.InstallationDirectory);
3716  else
3717  wcscpy(InstallDir, L"\\ReactOS");
3718 
3719  /*
3720  * Check the validity of the predefined 'InstallDir'. If we are either
3721  * in unattended setup or in update/repair mode, and the installation path
3722  * is valid, just perform the installation. Otherwise (either in the case
3723  * of an invalid path, or we are in regular setup), display the UI and allow
3724  * the user to specify a new installation path.
3725  */
3726  if ((RepairUpdateFlag || IsUnattendedSetup) && IsValidPath(InstallDir))
3727  {
3729  if (!NT_SUCCESS(Status))
3730  {
3731  DPRINT1("InitDestinationPaths() failed. Status code: 0x%lx", Status);
3733  return QUIT_PAGE;
3734  }
3735 
3736  /*
3737  * Check whether the user attempts to install ReactOS within the
3738  * installation source directory, or in a subdirectory thereof.
3739  * If so, fail with an error.
3740  */
3741  if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
3742  {
3744  return INSTALL_DIRECTORY_PAGE;
3745  }
3746 
3747  return PREPARE_COPY_PAGE;
3748  }
3749 
3750  Length = wcslen(InstallDir);
3751  Pos = Length;
3752 
3754  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3755  CONSOLE_SetCursorXY(8 + Pos, 11);
3757 
3758  while (TRUE)
3759  {
3760  CONSOLE_ConInKey(Ir);
3761 
3762  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3763  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
3764  {
3766 
3767  if (ConfirmQuit(Ir))
3768  return QUIT_PAGE;
3769 
3771  break;
3772  }
3773  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3774  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DELETE)) /* DEL */
3775  {
3776  if (Pos < Length)
3777  {
3778  memmove(&InstallDir[Pos],
3779  &InstallDir[Pos + 1],
3780  (Length - Pos - 1) * sizeof(WCHAR));
3781  InstallDir[Length - 1] = UNICODE_NULL;
3782 
3783  Length--;
3784  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3785  CONSOLE_SetCursorXY(8 + Pos, 11);
3786  }
3787  }
3788  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3789  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_HOME)) /* HOME */
3790  {
3791  Pos = 0;
3792  CONSOLE_SetCursorXY(8 + Pos, 11);
3793  }
3794  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3795  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_END)) /* END */
3796  {
3797  Pos = Length;
3798  CONSOLE_SetCursorXY(8 + Pos, 11);
3799  }
3800  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3801  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_LEFT)) /* LEFT */
3802  {
3803  if (Pos > 0)
3804  {
3805  Pos--;
3806  CONSOLE_SetCursorXY(8 + Pos, 11);
3807  }
3808  }
3809  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3810  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)) /* RIGHT */
3811  {
3812  if (Pos < Length)
3813  {
3814  Pos++;
3815  CONSOLE_SetCursorXY(8 + Pos, 11);
3816  }
3817  }
3818  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
3819  {
3821 
3822  /*
3823  * Check for the validity of the installation directory and pop up
3824  * an error if it is not the case. Then the user can fix its input.
3825  */
3826  if (!IsValidPath(InstallDir))
3827  {
3829  return INSTALL_DIRECTORY_PAGE;
3830  }
3831 
3833  if (!NT_SUCCESS(Status))
3834  {
3835  DPRINT1("InitDestinationPaths() failed. Status code: 0x%lx", Status);
3837  return QUIT_PAGE;
3838  }
3839 
3840  /*
3841  * Check whether the user attempts to install ReactOS within the
3842  * installation source directory, or in a subdirectory thereof.
3843  * If so, fail with an error.
3844  */
3845  if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
3846  {
3848  return INSTALL_DIRECTORY_PAGE;
3849  }
3850 
3851  return PREPARE_COPY_PAGE;
3852  }
3853  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
3854  {
3855  if (Pos > 0)
3856  {
3857  if (Pos < Length)
3858  memmove(&InstallDir[Pos - 1],
3859  &InstallDir[Pos],
3860  (Length - Pos) * sizeof(WCHAR));
3861  InstallDir[Length - 1] = UNICODE_NULL;
3862 
3863  Pos--;
3864  Length--;
3865  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3866  CONSOLE_SetCursorXY(8 + Pos, 11);
3867  }
3868  }
3869  else if (isprint(Ir->Event.KeyEvent.uChar.AsciiChar))
3870  {
3871  if (Length < 50)
3872  {
3874  if (iswalpha(c) || iswdigit(c) || c == '.' || c == '\\' || c == '-' || c == '_')
3875  {
3876  if (Pos < Length)
3877  memmove(&InstallDir[Pos + 1],
3878  &InstallDir[Pos],
3879  (Length - Pos) * sizeof(WCHAR));
3880  InstallDir[Length + 1] = UNICODE_NULL;
3881  InstallDir[Pos] = c;
3882 
3883  Pos++;
3884  Length++;
3885  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3886  CONSOLE_SetCursorXY(8 + Pos, 11);
3887  }
3888  }
3889  }
3890  }
3891 
3892  return INSTALL_DIRECTORY_PAGE;
3893 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
static VOID ResetFileSystemList(VOID)
Definition: usetup.c:2673
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
#define iswdigit(_c)
Definition: ctype.h:667
LONG NTSTATUS
Definition: precomp.h:26
static PPARTENTRY InstallPartition
Definition: usetup.c:50
ush Pos
Definition: deflate.h:92
#define VK_LEFT
Definition: winuser.h:2199
#define iswalpha(_c)
Definition: ctype.h:664
VOID CONSOLE_SetInputTextXY(IN SHORT x, IN SHORT y, IN SHORT len, IN LPCWSTR Text)
Definition: consup.c:344
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
static BOOLEAN IsValidPath(IN PCWSTR InstallDir)
Definition: usetup.c:3639
#define VK_HOME
Definition: winuser.h:2198
#define UNICODE_NULL
VOID CONSOLE_SetCursorType(IN BOOL bInsert, IN BOOL bVisible)
Definition: consup.c:210
smooth NULL
Definition: ftsmooth.c:416
#define VK_DELETE
Definition: winuser.h:2208
union _KEY_EVENT_RECORD::@3153 uChar
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
const GLubyte * c
Definition: glext.h:8905
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static PPARTLIST PartitionList
Definition: usetup.c:73
#define VK_F3
Definition: winuser.h:2232
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
Status
Definition: gdiplustypes.h:24
#define VK_RIGHT
Definition: winuser.h:2201
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
PCWSTR PathComponent
Definition: osdetect.h:22
BOOLEAN IsUnattendedSetup
Definition: usetup.c:45
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define DPRINT1
Definition: precomp.h:8
#define isprint(c)
Definition: acclib.h:73
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:70
VOID CONSOLE_SetCursorXY(IN SHORT x, IN SHORT y)
Definition: consup.c:223
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS InitDestinationPaths(IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
Definition: setuplib.c:624
static PNTOS_INSTALLATION CurrentInstallation
Definition: usetup.c:87
#define VK_END
Definition: winuser.h:2197
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ InstallIntroPage()

static PAGE_NUMBER InstallIntroPage ( PINPUT_RECORD  Ir)
static

Definition at line 997 of file usetup.c.

998 {
999  if (RepairUpdateFlag)
1000  {
1001 #if 1 /* Old code that looks good */
1002 
1003  // return SELECT_PARTITION_PAGE;
1004  return DEVICE_SETTINGS_PAGE;
1005 
1006 #else /* Possible new code? */
1007 
1008  return DEVICE_SETTINGS_PAGE;
1009  // return SCSI_CONTROLLER_PAGE;
1010 
1011 #endif
1012  }
1013 
1014  if (IsUnattendedSetup)
1015  return SELECT_PARTITION_PAGE;
1016 
1018 
1019  while (TRUE)
1020  {
1021  CONSOLE_ConInKey(Ir);
1022 
1023  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1024  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1025  {
1026  if (ConfirmQuit(Ir))
1027  return QUIT_PAGE;
1028 
1029  break;
1030  }
1031  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1032  {
1033  return UPGRADE_REPAIR_PAGE;
1034  }
1035  }
1036 
1037  return INSTALL_INTRO_PAGE;
1038 }
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3154 Event
union _KEY_EVENT_RECORD::@3153 uChar
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2232
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
BOOLEAN IsUnattendedSetup
Definition: usetup.c:45
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:70
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ IsDiskSizeValid()

static BOOL IsDiskSizeValid ( PPARTENTRY  PartEntry)
static

Definition at line 1425 of file usetup.c.

1426 {
1427  ULONGLONG size;
1428 
1429  size = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
1430  size = (size + (512 * KB)) / MB; /* in MBytes */
1431 
1432  if (size < USetupData.RequiredPartitionDiskSpace)
1433  {
1434  /* Partition is too small so ask for another one */
1435  DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size, USetupData.RequiredPartitionDiskSpace);
1436  return FALSE;
1437  }
1438  else
1439  {
1440  return TRUE;
1441  }
1442 }
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
#define MB
Definition: setuplib.h:53
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
GLsizeiptr size
Definition: glext.h:5919
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
uint64_t ULONGLONG
Definition: typedefs.h:65
#define DPRINT1
Definition: precomp.h:8
#define KB
Definition: setuplib.h:52

Referenced by SelectPartitionPage().

◆ IsValidPath()

static BOOLEAN IsValidPath ( IN PCWSTR  InstallDir)
static

Definition at line 3639 of file usetup.c.

3641 {
3642  UINT i, Length;
3643 
3644  Length = wcslen(InstallDir);
3645 
3646  // TODO: Add check for 8.3 too.
3647 
3648  /* Path must be at least 2 characters long */
3649 // if (Length < 2)
3650 // return FALSE;
3651 
3652  /* Path must start with a backslash */
3653 // if (InstallDir[0] != L'\\')
3654 // return FALSE;
3655 
3656  /* Path must not end with a backslash */
3657  if (InstallDir[Length - 1] == L'\\')
3658  return FALSE;
3659 
3660  /* Path must not contain whitespace characters */
3661  for (i = 0; i < Length; i++)
3662  {
3663  if (iswspace(InstallDir[i]))
3664  return FALSE;
3665  }
3666 
3667  /* Path component must not end with a dot */
3668  for (i = 0; i < Length; i++)
3669  {
3670  if (InstallDir[i] == L'\\' && i > 0)
3671  {
3672  if (InstallDir[i - 1] == L'.')
3673  return FALSE;
3674  }
3675  }
3676 
3677  if (InstallDir[Length - 1] == L'.')
3678  return FALSE;
3679 
3680  return TRUE;
3681 }
#define TRUE
Definition: types.h:120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define iswspace(_c)
Definition: ctype.h:669
static const WCHAR L[]
Definition: oid.c:1250
unsigned int UINT
Definition: ndis.h:50
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by InstallDirectoryPage().

◆ KeyboardSettingsPage()

static PAGE_NUMBER KeyboardSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1383 of file usetup.c.

1384 {
1385  GENERIC_LIST_UI ListUi;
1387 
1388  InitGenericListUi(&ListUi, USetupData.KeyboardList, GetSettingDescription);
1389  DrawGenericList(&ListUi,
1390  2, 18,
1391  xScreen - 3,
1392  yScreen - 3);
1393 
1394  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1395 }
static USETUP_DATA USetupData
Definition: usetup.c:47
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
VOID InitGenericListUi(IN OUT PGENERIC_LIST_UI ListUi, IN PGENERIC_LIST List, IN PGET_ENTRY_DESCRIPTION GetEntryDescriptionProc)
Definition: genlist.c:37
static PAGE_NUMBER HandleGenericList(PGENERIC_LIST_UI ListUi, PAGE_NUMBER nextPage, PINPUT_RECORD Ir)
Definition: usetup.c:1265
VOID DrawGenericList(IN PGENERIC_LIST_UI ListUi, IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom)
Definition: genlist.c:326
SHORT yScreen
Definition: consup.c:40
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:438

Referenced by RunUSetup().

◆ LanguagePage()

static PAGE_NUMBER LanguagePage ( PINPUT_RECORD  Ir)
static

Definition at line 490 of file usetup.c.

491 {
492  GENERIC_LIST_UI ListUi;
493  PCWSTR NewLanguageId;
494  BOOL RefreshPage = FALSE;
495 
496  /* Initialize the computer settings list */
497  if (USetupData.LanguageList == NULL)
498  {
499  USetupData.LanguageList = CreateLanguageList(USetupData.SetupInf, DefaultLanguage);
500  if (USetupData.LanguageList == NULL)
501  {
502  PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE);
503  return WELCOME_PAGE;
504  }
505  }
506 
508  USetupData.LanguageId = 0;
509 
510  /* Load the font */
512  UpdateKBLayout();
513 
514  /*
515  * If there is no language or just a single one in the list,
516  * skip the language selection process altogether.
517  */
518  if (GetNumberOfListEntries(USetupData.LanguageList) <= 1)
519  {
520  USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
521  return WELCOME_PAGE;
522  }
523 
524  InitGenericListUi(&ListUi, USetupData.LanguageList, GetSettingDescription);
525  DrawGenericList(&ListUi,
526  2, 18,
527  xScreen - 3,
528  yScreen - 3);
529 
531 
533 
534  while (TRUE)
535  {
536  CONSOLE_ConInKey(Ir);
537 
538  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
539  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
540  {
541  ScrollDownGenericList(&ListUi);
542  RefreshPage = TRUE;
543  }
544  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
545  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
546  {
547  ScrollUpGenericList(&ListUi);
548  RefreshPage = TRUE;
549  }
550  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
551  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
552  {
553  ScrollPageDownGenericList(&ListUi);
554  RefreshPage = TRUE;
555  }
556  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
557  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
558  {
559  ScrollPageUpGenericList(&ListUi);
560  RefreshPage = TRUE;
561  }
562  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
563  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
564  {
565  if (ConfirmQuit(Ir))
566  return QUIT_PAGE;
567  else
568  RedrawGenericList(&ListUi);
569  }
570  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
571  {
572  ASSERT(GetNumberOfListEntries(USetupData.LanguageList) >= 1);
573 
576 
577  USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
578 
580  {
581  UpdateKBLayout();
582  }
583 
584  /* Load the font */
586 
587  return WELCOME_PAGE;
588  }
589  else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
590  {
591  /* a-z */
593  RefreshPage = TRUE;
594  }
595 
596  if (RefreshPage)
597  {
598  ASSERT(GetNumberOfListEntries(USetupData.LanguageList) >= 1);
599 
600  NewLanguageId =
602 
603  if (wcscmp(SelectedLanguageId, NewLanguageId))
604  {
605  /* Clear the language page */
607 
608  SelectedLanguageId = NewLanguageId;
609 
610  /* Load the font */
612 
613  /* Redraw language selection page in native language */
615  }
616 
617  RefreshPage = FALSE;
618  }
619  }
620 
621  return WELCOME_PAGE;
622 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
static USETUP_DATA USetupData
Definition: usetup.c:47
#define TRUE
Definition: types.h:120
ULONG GetNumberOfListEntries(IN PGENERIC_LIST List)
Definition: genlist.c:140
#define POPUP_WAIT_NONE
Definition: usetup.h:124
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
VOID PopupError(PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
Definition: usetup.c:203
VOID ScrollToPositionGenericList(IN PGENERIC_LIST_UI ListUi, IN ULONG uIndex)
Definition: genlist.c:476
PGENERIC_LIST CreateLanguageList(IN HINF InfFile, OUT PWSTR DefaultLanguage)
Definition: settings.c:1160
VOID RedrawGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:511
WORD LANGID
Definition: typedefs.h:79
#define VK_DOWN
Definition: winuser.h:2202
#define VK_PRIOR
Definition: winuser.h:2195
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
VOID InitGenericListUi(IN OUT PGENERIC_LIST_UI ListUi, IN PGENERIC_LIST List, IN PGET_ENTRY_DESCRIPTION GetEntryDescriptionProc)
Definition: genlist.c:37
#define VK_NEXT
Definition: winuser.h:2196
WORD wVirtualKeyCode
Definition: wincon.h:227
VOID ScrollDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:376
union _INPUT_RECORD::@3154 Event
static VOID UpdateKBLayout(VOID)
Definition: usetup.c:403
#define VK_UP
Definition: winuser.h:2200
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
VOID ScrollPageUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:454
VOID ScrollPageDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:432
smooth NULL
Definition: ftsmooth.c:416
union _KEY_EVENT_RECORD::@3153 uChar
VOID DrawGenericList(IN PGENERIC_LIST_UI ListUi, IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom)
Definition: genlist.c:326
VOID MUIClearPage(IN ULONG page)
Definition: mui.c:121
PCWSTR SelectedLanguageId
Definition: usetup.c:66
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2232
VOID GenericListKeyPress(IN PGENERIC_LIST_UI ListUi, IN CHAR AsciiChar)
Definition: genlist.c:525
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:376
ULONG GetDefaultLanguageIndex(VOID)
Definition: settings.c:1099
SHORT yScreen
Definition: consup.c:40
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct _GENENTRY * PGENENTRY
static WCHAR DefaultLanguage[20]
Definition: usetup.c:67
VOID ScrollUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:404
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
VOID SetConsoleCodePage(VOID)
Definition: mui.c:260
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:438

Referenced by RunUSetup().

◆ LayoutSettingsPage()

static PAGE_NUMBER LayoutSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1409 of file usetup.c.

1410 {
1411  GENERIC_LIST_UI ListUi;
1413 
1414  InitGenericListUi(&ListUi, USetupData.LayoutList, GetSettingDescription);
1415  DrawGenericList(&ListUi,
1416  2, 18,
1417  xScreen - 3,
1418  yScreen - 3);
1419 
1420  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1421 }
static USETUP_DATA USetupData
Definition: usetup.c:47
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
VOID InitGenericListUi(IN OUT PGENERIC_LIST_UI ListUi, IN PGENERIC_LIST List, IN PGET_ENTRY_DESCRIPTION GetEntryDescriptionProc)
Definition: genlist.c:37
static PAGE_NUMBER HandleGenericList(PGENERIC_LIST_UI ListUi, PAGE_NUMBER nextPage, PINPUT_RECORD Ir)
Definition: usetup.c:1265
VOID DrawGenericList(IN PGENERIC_LIST_UI ListUi, IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom)
Definition: genlist.c:326
SHORT yScreen
Definition: consup.c:40
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:438

Referenced by RunUSetup().

◆ LicensePage()

static PAGE_NUMBER LicensePage ( PINPUT_RECORD  Ir)
static

Definition at line 786 of file usetup.c.

787 {
789 
790  while (TRUE)
791  {
792  CONSOLE_ConInKey(Ir);
793 
794  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
795  {
796  return WELCOME_PAGE;
797  }
798  }
799 
800  return LICENSE_PAGE;
801 }
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _INPUT_RECORD::@3154 Event
union _KEY_EVENT_RECORD::@3153 uChar
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ NtProcessStartup()

VOID NTAPI NtProcessStartup ( PPEB  Peb)

Definition at line 5136 of file usetup.c.

5137 {
5138  NTSTATUS Status;
5140 
5142 
5144 
5146 
5147  Status = RunUSetup();
5148 
5149  if (NT_SUCCESS(Status))
5150  {
5151  /*
5152  * Avoid a bugcheck if RunUSetup() finishes too quickly by implementing
5153  * a protective waiting.
5154  * This wait is needed because, since we are started as SMSS.EXE,
5155  * the NT kernel explicitly waits 5 seconds for the initial process
5156  * SMSS.EXE to initialize (as a protective measure), and otherwise
5157  * bugchecks with the code SESSION5_INITIALIZATION_FAILED.
5158  */
5159  Time.QuadPart += 50000000;
5161  }
5162  else
5163  {
5164  /* The installer failed to start: raise a hard error (crash the system/BSOD) */
5166  0, 0, NULL, 0, NULL);
5167  }
5168 
5170 }
PPEB Peb
Definition: dllmain.c:27
NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:553
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS RunUSetup(VOID)
Definition: usetup.c:4911
NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlNormalizeProcessParams(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
smooth NULL
Definition: ftsmooth.c:416
HANDLE ProcessHeap
Definition: usetup.c:44
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
Definition: wait.c:879
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ProcessHeap
Definition: ntddk_ex.h:249
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1817
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:417
#define STATUS_SYSTEM_PROCESS_TERMINATED
Definition: ntstatus.h:656
static PLARGE_INTEGER Time
Definition: time.c:105
LONGLONG QuadPart
Definition: typedefs.h:112

◆ PopupError()

VOID PopupError ( PCCH  Text,
PCCH  Status,
PINPUT_RECORD  Ir,
ULONG  WaitEvent 
)

Definition at line 203 of file usetup.c.

207 {
208  SHORT yTop;
209  SHORT xLeft;
210  COORD coPos;
211  DWORD Written;
212  ULONG Length;
213  ULONG MaxLength;
214  ULONG Lines;
215  PCHAR p;
216  PCCH pnext;
217  BOOLEAN LastLine;
218  SHORT Width;
219  SHORT Height;
220 
221  /* Count text lines and longest line */
222  MaxLength = 0;
223  Lines = 0;
224  pnext = Text;
225 
226  while (TRUE)
227  {
228  p = strchr(pnext, '\n');
229 
230  if (p == NULL)
231  {
232  Length = strlen(pnext);
233  LastLine = TRUE;
234  }
235  else
236  {
237  Length = (ULONG)(p - pnext);
238  LastLine = FALSE;
239  }
240 
241  Lines++;
242 
243  if (Length > MaxLength)
244  MaxLength = Length;
245 
246  if (LastLine)
247  break;
248 
249  pnext = p + 1;
250  }
251 
252  /* Check length of status line */
253  if (Status != NULL)
254  {
255  Length = strlen(Status);
256 
257  if (Length > MaxLength)
258  MaxLength = Length;
259  }
260 
261  Width = MaxLength + 4;
262  Height = Lines + 2;
263 
264  if (Status != NULL)
265  Height += 2;
266 
267  yTop = (yScreen - Height) / 2;
268  xLeft = (xScreen - Width) / 2;
269 
270 
271  /* Set screen attributes */
272  coPos.X = xLeft;
273  for (coPos.Y = yTop; coPos.Y < yTop + Height; coPos.Y++)
274  {
277  Width,
278  coPos,
279  &Written);
280  }
281 
282  DrawBox(xLeft, yTop, Width, Height);
283 
284  /* Print message text */
285  coPos.Y = yTop + 1;
286  pnext = Text;
287  while (TRUE)
288  {
289  p = strchr(pnext, '\n');
290 
291  if (p == NULL)
292  {
293  Length = strlen(pnext);
294  LastLine = TRUE;
295  }
296  else
297  {
298  Length = (ULONG)(p - pnext);
299  LastLine = FALSE;
300  }
301 
302  if (Length != 0)
303  {
304  coPos.X = xLeft + 2;
306  pnext,
307  Length,
308  coPos,
309  &Written);
310  }
311 
312  if (LastLine)
313  break;
314 
315  coPos.Y++;
316  pnext = p + 1;
317  }
318 
319  /* Print separator line and status text */
320  if (Status != NULL)
321  {
322  coPos.Y = yTop + Height - 3;
323  coPos.X = xLeft;
325  0xC3, // '+',
326  1,
327  coPos,
328  &Written);
329 
330  coPos.X = xLeft + 1;
332  0xC4, // '-',
333  Width - 2,
334  coPos,
335  &Written);
336 
337  coPos.X = xLeft + Width - 1;
339  0xB4, // '+',
340  1,
341  coPos,
342  &Written);
343 
344  coPos.Y++;
345  coPos.X = xLeft + 2;
347  Status,
348  min(strlen(Status), (SIZE_T)Width - 4),
349  coPos,
350  &Written);
351  }
352 
353  if (WaitEvent == POPUP_WAIT_NONE)
354  return;
355 
356  while (TRUE)
357  {
358  CONSOLE_ConInKey(Ir);
359 
360  if (WaitEvent == POPUP_WAIT_ANY_KEY ||
361  Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)
362  {
363  return;
364  }
365  }
366 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:124
SHORT xScreen
Definition: consup.c:39
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:474
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define POPUP_WAIT_ANY_KEY
Definition: usetup.h:125
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
union _INPUT_RECORD::@3154 Event
short SHORT
Definition: pedump.c:59
HANDLE StdOutput
Definition: consup.c:37
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:356
ULONG X
Definition: bl.h:1340
CONST CHAR * PCCH
Definition: ntbasedef.h:399
union _KEY_EVENT_RECORD::@3153 uChar
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: bl.h:1338
SHORT yScreen
Definition: consup.c:40
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static VOID DrawBox(IN SHORT xLeft, IN SHORT yTop, IN SHORT Width, IN SHORT Height)
Definition: usetup.c:113
#define min(a, b)
Definition: monoChain.cc:55
#define BACKGROUND_WHITE
Definition: consup.h:31
#define FOREGROUND_RED
Definition: wincon.h:41
char * strchr(const char *String, int ch)
Definition: utclib.c:501
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
ULONG Y
Definition: bl.h:1341
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
char * Text
Definition: combotst.c:136

Referenced by CheckFileSystemPage(), FormatPartitionPage(), LanguagePage(), MUIClearPage(), MUIDisplayErrorV(), MUIDisplayPage(), MUIGetString(), SelectFileSystemPage(), and SelectPartitionPage().

◆ PrepareCopyPage()

static PAGE_NUMBER PrepareCopyPage ( PINPUT_RECORD  Ir)
static

Definition at line 3932 of file usetup.c.

3933 {
3934  // ERROR_NUMBER ErrorNumber;
3935  BOOLEAN Success;
3936 
3938 
3939  /* ErrorNumber = */ Success = PrepareFileCopy(&USetupData, NULL);
3940  if (/*ErrorNumber != ERROR_SUCCESS*/ !Success)
3941  {
3942  // MUIDisplayError(ErrorNumber, Ir, POPUP_WAIT_ENTER);
3943  return QUIT_PAGE;
3944  }
3945 
3946  return FILE_COPY_PAGE;
3947 }
static USETUP_DATA USetupData
Definition: usetup.c:47
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN PrepareFileCopy(IN OUT PUSETUP_DATA pSetupData, IN PFILE_COPY_STATUS_ROUTINE StatusRoutine OPTIONAL)
Definition: install.c:676

Referenced by RunUSetup().

◆ PrintString()

static VOID PrintString ( char fmt,
  ... 
)
static

Definition at line 94 of file usetup.c.

95 {
96  char buffer[512];
97  va_list ap;
100 
101  va_start(ap, fmt);
102  vsprintf(buffer, fmt, ap);
103  va_end(ap);
104 
109 }
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
GLuint buffer
Definition: glext.h:5915
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtDisplayString(PUNICODE_STRING String)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
Definition: dsound.c:943

Referenced by RunUSetup().

◆ ProgressCountdown()

static VOID ProgressCountdown ( IN PINPUT_RECORD  Ir,
IN LONG  TimeOut 
)
static

Definition at line 4694 of file usetup.c.

4697 {
4698  NTSTATUS Status;
4699  ULONG StartTime, BarWidth, TimerDiv;
4700  LONG TimeElapsed;
4701  LONG TimerValue, OldTimerValue;
4703  PPROGRESSBAR ProgressBar;
4704  BOOLEAN RefreshProgress = TRUE;
4705 
4706  /* Bail out if the timeout is already zero */
4707  if (TimeOut <= 0)
4708  return;
4709 
4710  /* Create the timeout progress bar and set it up */
4711  ProgressBar = CreateProgressBarEx(13,
4712  26,
4713  xScreen - 13,
4714  yScreen - 20,
4715  10,
4716  24,
4717  TRUE,
4719  0,
4720  NULL,
4723 
4724  BarWidth = max(1, ProgressBar->Width);
4725  TimerValue = TimeOut * BarWidth;
4726  ProgressSetStepCount(ProgressBar, TimerValue);
4727 
4729  CONSOLE_Flush();
4730 
4731  TimerDiv = 1000 / BarWidth;
4732  TimerDiv = max(1, TimerDiv);
4733  OldTimerValue = TimerValue;
4734  while (TRUE)
4735  {
4736  /* Decrease the timer */
4737 
4738  /*
4739  * Compute how much time the previous operations took.
4740  * This allows us in particular to take account for any time
4741  * elapsed if something slowed down.
4742  */
4743  TimeElapsed = NtGetTickCount() - StartTime;
4744  if (TimeElapsed >= TimerDiv)
4745  {
4746  /* Increase StartTime by steps of 1 / ProgressBar->Width seconds */
4747  TimeElapsed /= TimerDiv;
4748  StartTime += (TimerDiv * TimeElapsed);
4749 
4750  if (TimeElapsed <= TimerValue)
4751  TimerValue -= TimeElapsed;
4752  else
4753  TimerValue = 0;
4754 
4755  RefreshProgress = TRUE;
4756  }
4757 
4758  if (RefreshProgress)
4759  {
4760  ProgressSetStep(ProgressBar, OldTimerValue - TimerValue);
4761  RefreshProgress = FALSE;
4762  }
4763 
4764  /* Stop when the timer reaches zero */
4765  if (TimerValue <= 0)
4766  break;
4767 
4768  /* Check for user key presses */
4769 
4770  /*
4771  * If the timer is used, use a passive wait of maximum 1 second
4772  * while monitoring for incoming console input events, so that
4773  * we are still able to display the timing count.
4774  */
4775 
4776  /* Wait a maximum of 1 second for input events */
4777  TimeElapsed = NtGetTickCount() - StartTime;
4778  if (TimeElapsed < TimerDiv)
4779  {
4780  /* Convert the time to NT Format */
4781  Timeout.QuadPart = (TimerDiv - TimeElapsed) * -10000LL;
4783  }
4784  else
4785  {
4787  }
4788 
4789  /* Check whether the input event has been signaled, or a timeout happened */
4790  if (Status == STATUS_TIMEOUT)
4791  {
4792  continue;
4793  }
4794  if (Status != STATUS_WAIT_0)
4795  {
4796  /* An error happened, bail out */
4797  DPRINT1("NtWaitForSingleObject() failed, Status 0x%08lx\n", Status);
4798  break;
4799  }
4800 
4801  /* Check for an ENTER key press */
4802  while (CONSOLE_ConInKeyPeek(Ir))
4803  {
4804  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4805  {
4806  /* Found it, stop waiting */
4807  goto Exit;
4808  }
4809  }
4810  }
4811 
4812 Exit:
4813  /* Destroy the progress bar and quit */
4814  DestroyProgressBar(ProgressBar);
4815 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define LL
Definition: tui.h:85
SHORT xScreen
Definition: consup.c:39
#define STRING_REBOOTPROGRESSBAR
Definition: mui.h:137
PPROGRESSBAR CreateProgressBarEx(IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN SHORT ProgressColour, IN ULONG StepCount, IN PCSTR DescriptionText OPTIONAL, IN PCSTR ProgressFormatText OPTIONAL, IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
Definition: progress.c:272
LONG NTSTATUS
Definition: precomp.h:26
HANDLE StdInput
Definition: consup.c:36
VOID ProgressSetStep(IN PPROGRESSBAR Bar, IN ULONG Step)
Definition: progress.c:368
VOID DestroyProgressBar(IN OUT PPROGRESSBAR Bar)
Definition: progress.c:339
static LARGE_INTEGER StartTime
Definition: sys_arch.c:18
BOOL CONSOLE_Flush(VOID)
Definition: consup.c:171
#define NtGetTickCount
Definition: rtlp.h:146
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_WAIT_0
Definition: ntstatus.h:223
VOID ProgressSetStepCount(IN PPROGRESSBAR Bar, IN ULONG StepCount)
Definition: progress.c:347
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CONSOLE_ConInKeyPeek(OUT PINPUT_RECORD Buffer)
Definition: consup.c:81
SHORT Width
Definition: progress.h:48
static BOOLEAN NTAPI ProgressTimeOutStringHandler(IN PPROGRESSBAR Bar, IN BOOLEAN AlwaysUpdate, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:4647
static void Exit(void)
Definition: sock.c:1331
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
SHORT yScreen
Definition: consup.c:40
#define BACKGROUND_BLUE
Definition: wincon.h:43
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
#define FOREGROUND_RED
Definition: wincon.h:41
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by QuitPage(), and SuccessPage().

◆ ProgressTimeOutStringHandler()

static BOOLEAN NTAPI ProgressTimeOutStringHandler ( IN PPROGRESSBAR  Bar,
IN BOOLEAN  AlwaysUpdate,
OUT PSTR  Buffer,
IN SIZE_T  cchBufferSize 
)
static

Definition at line 4647 of file usetup.c.

4652 {
4653  ULONG OldProgress = Bar->Progress;
4654 
4655  if (Bar->StepCount == 0)
4656  {
4657  Bar->Progress = 0;
4658  }
4659  else
4660  {
4661  Bar->Progress = Bar->StepCount - Bar->CurrentStep;
4662  }
4663 
4664  /* Build the progress string if it has changed */
4665  if (Bar->ProgressFormatText &&
4666  (AlwaysUpdate || (Bar->Progress != OldProgress)))
4667  {
4669  Bar->ProgressFormatText, Bar->Progress / max(1, Bar->Width) + 1);
4670 
4671  return TRUE;
4672  }
4673 
4674  return FALSE;
4675 }
IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
Definition: progress.h:34
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
Definition: bufpool.h:45
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN AlwaysUpdate
Definition: progress.h:34

Referenced by ProgressCountdown().

◆ QuitPage()

static PAGE_NUMBER QuitPage ( PINPUT_RECORD  Ir)
static

Definition at line 4831 of file usetup.c.

4832 {
4834 
4835  /* Destroy the NTOS installations list */
4836  if (NtOsInstallsList != NULL)
4837  {
4840  }
4841 
4842  /* Destroy the partition list */
4843  if (PartitionList != NULL)
4844  {
4846  PartitionList = NULL;
4847  }
4848 
4849  /* Reset the formatter machine state */
4850  TempPartition = NULL;
4851  FormatState = Start;
4852 
4853  /* Destroy the filesystem list */
4855 
4857 
4858  /* Wait for maximum 15 seconds or an ENTER key before quitting */
4859  ProgressCountdown(Ir, 15);
4860  return FLUSH_PAGE;
4861 }
#define TRUE
Definition: types.h:120
static VOID ResetFileSystemList(VOID)
Definition: usetup.c:2673
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36
static PPARTENTRY TempPartition
Definition: usetup.c:82
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
#define STRING_REBOOTCOMPUTER2
Definition: mui.h:106
smooth NULL
Definition: ftsmooth.c:416
static PGENERIC_LIST NtOsInstallsList
Definition: usetup.c:88
static VOID ProgressCountdown(IN PINPUT_RECORD Ir, IN LONG TimeOut)
Definition: usetup.c:4694
static FORMATMACHINESTATE FormatState
Definition: usetup.c:83
Definition: partlist.h:33
static PPARTLIST PartitionList
Definition: usetup.c:73
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID DestroyPartitionList(IN PPARTLIST List)
Definition: partlist.c:2107
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481

Referenced by RunUSetup().

◆ RegistryPage()

static PAGE_NUMBER RegistryPage ( PINPUT_RECORD  Ir)
static

Definition at line 4224 of file usetup.c.

4225 {
4226  ULONG Error;
4227 
4229 
4232  PartitionList,
4235  RegistryStatus);
4236  if (Error != ERROR_SUCCESS)
4237  {
4238  MUIDisplayError(Error, Ir, PO