ReactOS  0.4.14-dev-833-g5f692ed
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 4499 of file usetup.c.

4500 {
4501  NTSTATUS Status;
4502 
4504 
4505 // CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
4506 
4507  while (TRUE)
4508  {
4509  CONSOLE_ConInKey(Ir);
4510 
4511  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4512  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
4513  {
4514  if (ConfirmQuit(Ir))
4515  return QUIT_PAGE;
4516 
4517  break;
4518  }
4519  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4520  {
4521  Status = InstallFatBootcodeToFloppy(&USetupData.SourceRootPath,
4522  &USetupData.DestinationArcPath);
4523  if (!NT_SUCCESS(Status))
4524  {
4527 
4528  /* TODO: Print error message */
4529  return BOOT_LOADER_FLOPPY_PAGE;
4530  }
4531 
4532  return SUCCESS_PAGE;
4533  }
4534  }
4535 
4536  return BOOT_LOADER_FLOPPY_PAGE;
4537 }
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
#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
union _KEY_EVENT_RECORD::@3172 uChar
union _INPUT_RECORD::@3173 Event
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70

Referenced by RunUSetup().

◆ BootLoaderHarddiskMbrPage()

static PAGE_NUMBER BootLoaderHarddiskMbrPage ( PINPUT_RECORD  Ir)
static

Definition at line 4589 of file usetup.c.

4590 {
4591  NTSTATUS Status;
4592  WCHAR DestinationDevicePathBuffer[MAX_PATH];
4593 
4594  /* Step 1: Write the VBR */
4595  // FIXME! We must not use the partition type, but instead use the partition FileSystem!!
4596  Status = InstallVBRToPartition(&USetupData.SystemRootPath,
4597  &USetupData.SourceRootPath,
4598  &USetupData.DestinationArcPath,
4600  if (!NT_SUCCESS(Status))
4601  {
4604  return QUIT_PAGE;
4605  }
4606 
4607  /* Step 2: Write the MBR if the disk containing the system partition is not a super-floppy */
4609  {
4610  RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
4611  L"\\Device\\Harddisk%d\\Partition0",
4612  SystemPartition->DiskEntry->DiskNumber);
4613  Status = InstallMbrBootCodeToDisk(&USetupData.SystemRootPath,
4614  &USetupData.SourceRootPath,
4615  DestinationDevicePathBuffer);
4616  if (!NT_SUCCESS(Status))
4617  {
4618  DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n", Status);
4620  return QUIT_PAGE;
4621  }
4622  }
4623 
4624  return SUCCESS_PAGE;
4625 }
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:680
#define DPRINT1
Definition: precomp.h:8

Referenced by RunUSetup().

◆ BootLoaderHarddiskVbrPage()

static PAGE_NUMBER BootLoaderHarddiskVbrPage ( PINPUT_RECORD  Ir)
static

Definition at line 4554 of file usetup.c.

4555 {
4556  NTSTATUS Status;
4557 
4558  // FIXME! We must not use the partition type, but instead use the partition FileSystem!!
4559  Status = InstallVBRToPartition(&USetupData.SystemRootPath,
4560  &USetupData.SourceRootPath,
4561  &USetupData.DestinationArcPath,
4563  if (!NT_SUCCESS(Status))
4564  {
4567  return QUIT_PAGE;
4568  }
4569 
4570  return SUCCESS_PAGE;
4571 }
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 4275 of file usetup.c.

4276 {
4278  BOOLEAN InstallOnFloppy;
4279  USHORT Line = 12;
4280  WCHAR PathBuffer[MAX_PATH];
4281 
4283 
4285 
4286  RtlFreeUnicodeString(&USetupData.SystemRootPath);
4287  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
4288  L"\\Device\\Harddisk%lu\\Partition%lu\\",
4289  SystemPartition->DiskEntry->DiskNumber,
4291  RtlCreateUnicodeString(&USetupData.SystemRootPath, PathBuffer);
4292  DPRINT1("SystemRootPath: %wZ\n", &USetupData.SystemRootPath);
4293 
4295 
4296  /* For unattended setup, skip MBR installation or install on floppy if needed */
4297  if (IsUnattendedSetup)
4298  {
4299  if ((USetupData.MBRInstallType == 0) ||
4300  (USetupData.MBRInstallType == 1))
4301  {
4302  goto Quit;
4303  }
4304  }
4305 
4306  /*
4307  * We may install an MBR or VBR, but before that, check whether
4308  * we need to actually install the VBR on floppy.
4309  */
4311  {
4312  DPRINT("Error: system partition invalid (unused)\n");
4313  InstallOnFloppy = TRUE;
4314  }
4315  else if (PartitionType == PARTITION_OS2BOOTMGR)
4316  {
4317  /* OS/2 boot manager partition */
4318  DPRINT("Found OS/2 boot manager partition\n");
4319  InstallOnFloppy = TRUE;
4320  }
4321  else if (PartitionType == PARTITION_LINUX)
4322  {
4323  /* Linux partition */
4324  DPRINT("Found Linux native partition (ext2/ext3/ReiserFS/BTRFS/etc)\n");
4325  InstallOnFloppy = FALSE;
4326  }
4327  else if (PartitionType == PARTITION_IFS)
4328  {
4329  /* NTFS partition */
4330  DPRINT("Found NTFS partition\n");
4331 
4332  // FIXME: Make it FALSE when we'll support NTFS installation!
4333  InstallOnFloppy = TRUE;
4334  }
4335  else if ((PartitionType == PARTITION_FAT_12) ||
4341  {
4342  DPRINT("Found FAT partition\n");
4343  InstallOnFloppy = FALSE;
4344  }
4345  else
4346  {
4347  /* Unknown partition */
4348  DPRINT("Unknown partition found\n");
4349  InstallOnFloppy = TRUE;
4350  }
4351 
4352  /* We should install on floppy */
4353  if (InstallOnFloppy)
4354  {
4355  USetupData.MBRInstallType = 1;
4356  goto Quit;
4357  }
4358 
4359  /* Is it an unattended install on hdd? */
4360  if (IsUnattendedSetup)
4361  {
4362  if ((USetupData.MBRInstallType == 2) ||
4363  (USetupData.MBRInstallType == 3))
4364  {
4365  goto Quit;
4366  }
4367  }
4368 
4370  CONSOLE_InvertTextXY(8, Line, 60, 1);
4371 
4372  while (TRUE)
4373  {
4374  CONSOLE_ConInKey(Ir);
4375 
4376  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4377  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
4378  {
4379  CONSOLE_NormalTextXY(8, Line, 60, 1);
4380 
4381  Line++;
4382  if (Line < 12)
4383  Line = 15;
4384 
4385  if (Line > 15)
4386  Line = 12;
4387 
4388  CONSOLE_InvertTextXY(8, Line, 60, 1);
4389  }
4390  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4391  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
4392  {
4393  CONSOLE_NormalTextXY(8, Line, 60, 1);
4394 
4395  Line--;
4396  if (Line < 12)
4397  Line = 15;
4398 
4399  if (Line > 15)
4400  Line = 12;
4401 
4402  CONSOLE_InvertTextXY(8, Line, 60, 1);
4403  }
4404  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4405  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_HOME)) /* HOME */
4406  {
4407  CONSOLE_NormalTextXY(8, Line, 60, 1);
4408 
4409  Line = 12;
4410 
4411  CONSOLE_InvertTextXY(8, Line, 60, 1);
4412  }
4413  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4414  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_END)) /* END */
4415  {
4416  CONSOLE_NormalTextXY(8, Line, 60, 1);
4417 
4418  Line = 15;
4419 
4420  CONSOLE_InvertTextXY(8, Line, 60, 1);
4421  }
4422  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4423  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
4424  {
4425  if (ConfirmQuit(Ir))
4426  return QUIT_PAGE;
4427 
4428  break;
4429  }
4430  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4431  {
4432  if (Line == 12)
4433  {
4434  /* Install on both MBR and VBR */
4435  USetupData.MBRInstallType = 2;
4436  break;
4437  }
4438  else if (Line == 13)
4439  {
4440  /* Install on VBR only */
4441  USetupData.MBRInstallType = 3;
4442  break;
4443  }
4444  else if (Line == 14)
4445  {
4446  /* Install on floppy */
4447  USetupData.MBRInstallType = 1;
4448  break;
4449  }
4450  else if (Line == 15)
4451  {
4452  /* Skip MBR installation */
4453  USetupData.MBRInstallType = 0;
4454  break;
4455  }
4456 
4457  return BOOT_LOADER_PAGE;
4458  }
4459  }
4460 
4461 Quit:
4462  switch (USetupData.MBRInstallType)
4463  {
4464  /* Skip MBR installation */
4465  case 0:
4466  return SUCCESS_PAGE;
4467 
4468  /* Install on floppy */
4469  case 1:
4470  return BOOT_LOADER_FLOPPY_PAGE;
4471 
4472  /* Install on both MBR and VBR */
4473  case 2:
4475 
4476  /* Install on VBR only */
4477  case 3:
4479  }
4480 
4481  return BOOT_LOADER_PAGE;
4482 }
#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
#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
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:480
union _KEY_EVENT_RECORD::@3172 uChar
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:32
#define PARTITION_FAT_12
Definition: disk.h:87
#define STRING_PLEASEWAIT
Definition: mui.h:111
#define PARTITION_FAT32_XINT13
Definition: disk.h:96
union _INPUT_RECORD::@3173 Event
#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 3545 of file usetup.c.

3546 {
3547  NTSTATUS Status;
3548  PDISKENTRY DiskEntry;
3549  PPARTENTRY PartEntry;
3550  UNICODE_STRING PartitionRootPath;
3551  WCHAR PathBuffer[MAX_PATH];
3552  CHAR Buffer[MAX_PATH];
3553 
3554  if (PartitionList == NULL)
3555  {
3556  /* FIXME: show an error dialog */
3557  return QUIT_PAGE;
3558  }
3559 
3560  if (!GetNextUncheckedPartition(PartitionList, &DiskEntry, &PartEntry))
3561  {
3562  return INSTALL_DIRECTORY_PAGE;
3563  }
3564 
3565  ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
3566 
3568 
3570 
3571  DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystem: %S\n",
3572  PartEntry->PartitionType, (*PartEntry->FileSystem ? PartEntry->FileSystem : L"n/a"));
3573 
3574  /* HACK: Do not try to check a partition with an unknown filesystem */
3575  if (!*PartEntry->FileSystem)
3576  {
3577  PartEntry->NeedsCheck = FALSE;
3578  return CHECK_FILE_SYSTEM_PAGE;
3579  }
3580 
3581  /* Set PartitionRootPath */
3582  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
3583  L"\\Device\\Harddisk%lu\\Partition%lu",
3584  DiskEntry->DiskNumber,
3585  PartEntry->PartitionNumber);
3586  RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
3587  DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
3588 
3589  /* Check the partition */
3590  Status = ChkdskPartition(&PartitionRootPath, PartEntry->FileSystem);
3592  {
3593  /*
3594  * Partition checking is not supported with the current filesystem,
3595  * so disable FS checks on it.
3596  */
3597  PartEntry->NeedsCheck = FALSE;
3598 
3600  sizeof(Buffer),
3601  "Setup is currently unable to check a partition formatted in %S.\n"
3602  "\n"
3603  " \x07 Press ENTER to continue Setup.\n"
3604  " \x07 Press F3 to quit Setup.",
3605  PartEntry->FileSystem);
3606 
3610 
3611  while (TRUE)
3612  {
3613  CONSOLE_ConInKey(Ir);
3614 
3615  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x00 &&
3616  Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3) /* F3 */
3617  {
3618  if (ConfirmQuit(Ir))
3619  return QUIT_PAGE;
3620  else
3621  return CHECK_FILE_SYSTEM_PAGE;
3622  }
3623  else if (Ir->Event.KeyEvent.uChar.AsciiChar == VK_RETURN) /* ENTER */
3624  {
3625  return CHECK_FILE_SYSTEM_PAGE;
3626  }
3627  }
3628  }
3629  else if (!NT_SUCCESS(Status))
3630  {
3631  DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status);
3632  sprintf(Buffer, "ChkDsk detected some disk errors.\n(Status 0x%08lx).\n", Status);
3635  Ir, POPUP_WAIT_ENTER);
3636  }
3637 
3638  PartEntry->NeedsCheck = FALSE;
3639  return CHECK_FILE_SYSTEM_PAGE;
3640 }
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
#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:127
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
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:480
#define STRING_CONTINUE
Definition: mui.h:128
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:126
BOOLEAN NeedsCheck
Definition: partlist.h:70
union _KEY_EVENT_RECORD::@3172 uChar
#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:111
union _INPUT_RECORD::@3173 Event
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STRING_QUITCONTINUE
Definition: mui.h:129
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
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
union _KEY_EVENT_RECORD::@3172 uChar
union _INPUT_RECORD::@3173 Event
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
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
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
union _KEY_EVENT_RECORD::@3172 uChar
union _INPUT_RECORD::@3173 Event
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:120
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:121
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:598
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:172
#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:171
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:153
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:31
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:480
#define STRING_HDINFOPARTCREATE_1
Definition: mui.h:152
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:3024
unsigned int ULONG
Definition: retypes.h:1
#define STRING_PLEASEWAIT
Definition: mui.h:111
#define GB
Definition: setuplib.h:54
#define STRING_CHOOSE_NEW_EXTENDED_PARTITION
Definition: mui.h:118

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:120
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:121
Unit
Definition: gdiplusenums.h:25
#define STRING_CHOOSE_NEW_LOGICAL_PARTITION
Definition: mui.h:119
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:598
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:172
#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:171
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:3078
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:153
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:31
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:480
#define STRING_HDINFOPARTCREATE_1
Definition: mui.h:152
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:111
#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:120
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:121
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:598
ULONG DiskNumber
Definition: partlist.h:104
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
#define STRING_CHOOSENEWPARTITION
Definition: mui.h:117
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:172
#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:171
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:153
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:31
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:480
BOOLEAN CreatePrimaryPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
Definition: partlist.c:2960
#define STRING_HDINFOPARTCREATE_1
Definition: mui.h:152
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:111
#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:3221
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:156
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:598
#define STRING_KB
Definition: mui.h:170
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
#define STRING_GB
Definition: mui.h:172
#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:155
#define STRING_MB
Definition: mui.h:171
smooth NULL
Definition: ftsmooth.c:416
ULARGE_INTEGER SectorCount
Definition: partlist.h:90
#define STRING_HDDINFOUNK2
Definition: mui.h:154
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
union _KEY_EVENT_RECORD::@3172 uChar
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
union _INPUT_RECORD::@3173 Event
#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
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
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
union _KEY_EVENT_RECORD::@3172 uChar
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:70
unsigned int ULONG
Definition: retypes.h:1
PGENERIC_LIST CreateKeyboardDriverList(IN HINF InfFile)
Definition: settings.c:1073
union _INPUT_RECORD::@3173 Event
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:531
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 3991 of file usetup.c.

3995 {
3996  PCOPYCONTEXT CopyContext = (PCOPYCONTEXT)Context;
3997  PFILEPATHS_W FilePathInfo;
3998  PCWSTR SrcFileName, DstFileName;
3999 
4000  switch (Notification)
4001  {
4003  {
4004  CopyContext->TotalOperations = (ULONG)Param2;
4005  CopyContext->CompletedOperations = 0;
4006  ProgressSetStepCount(CopyContext->ProgressBar,
4007  CopyContext->TotalOperations);
4008  SetupUpdateMemoryInfo(CopyContext, TRUE);
4009  break;
4010  }
4011 
4015  {
4016  FilePathInfo = (PFILEPATHS_W)Param1;
4017 
4018  if (Notification == SPFILENOTIFY_STARTDELETE)
4019  {
4020  /* Display delete message */
4021  ASSERT(Param2 == FILEOP_DELETE);
4022 
4023  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
4024  if (DstFileName) ++DstFileName;
4025  else DstFileName = FilePathInfo->Target;
4026 
4028  DstFileName);
4029  }
4030  else if (Notification == SPFILENOTIFY_STARTRENAME)
4031  {
4032  /* Display move/rename message */
4033  ASSERT(Param2 == FILEOP_RENAME);
4034 
4035  SrcFileName = wcsrchr(FilePathInfo->Source, L'\\');
4036  if (SrcFileName) ++SrcFileName;
4037  else SrcFileName = FilePathInfo->Source;
4038 
4039  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
4040  if (DstFileName) ++DstFileName;
4041  else DstFileName = FilePathInfo->Target;
4042 
4043  if (!wcsicmp(SrcFileName, DstFileName))
4044  Param2 = STRING_MOVING;
4045  else
4046  Param2 = STRING_RENAMING;
4047 
4049  SrcFileName, DstFileName);
4050  }
4051  else if (Notification == SPFILENOTIFY_STARTCOPY)
4052  {
4053  /* Display copy message */
4054  ASSERT(Param2 == FILEOP_COPY);
4055 
4056  /* NOTE: When extracting from CABs the Source is the CAB name */
4057  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
4058  if (DstFileName) ++DstFileName;
4059  else DstFileName = FilePathInfo->Target;
4060 
4062  DstFileName);
4063  }
4064 
4065  SetupUpdateMemoryInfo(CopyContext, FALSE);
4066  break;
4067  }
4068 
4070  {
4071  FilePathInfo = (PFILEPATHS_W)Param1;
4072 
4073  DPRINT1("An error happened while trying to copy file '%S' (error 0x%08lx), skipping it...\n",
4074  FilePathInfo->Target, FilePathInfo->Win32Error);
4075  return FILEOP_SKIP;
4076  }
4077 
4080  case SPFILENOTIFY_ENDCOPY:
4081  {
4082  CopyContext->CompletedOperations++;
4083 
4084  /* SYSREG checkpoint */
4085  if (CopyContext->TotalOperations >> 1 == CopyContext->CompletedOperations)
4086  DPRINT1("CHECKPOINT:HALF_COPIED\n");
4087 
4088  ProgressNextStep(CopyContext->ProgressBar);
4089  SetupUpdateMemoryInfo(CopyContext, FALSE);
4090  break;
4091  }
4092  }
4093 
4094  return FILEOP_DOIT;
4095 }
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:134
#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:133
#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:132
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:480
#define wcsicmp
Definition: string.h:1152
static VOID SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext, IN BOOLEAN First)
Definition: usetup.c:3963
#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:131
PPROGRESSBAR ProgressBar
Definition: usetup.c:3958
#define FILEOP_DELETE
Definition: fileqsup.h:44

Referenced by FileCopyPage().

◆ FileCopyPage()

static PAGE_NUMBER FileCopyPage ( PINPUT_RECORD  Ir)
static

Definition at line 4111 of file usetup.c.

4112 {
4113  COPYCONTEXT CopyContext;
4114  UINT MemBarWidth;
4115 
4117 
4118  /* Create context for the copy process */
4119  CopyContext.TotalOperations = 0;
4120  CopyContext.CompletedOperations = 0;
4121 
4122  /* Create the progress bar as well */
4123  CopyContext.ProgressBar = CreateProgressBar(13,
4124  26,
4125  xScreen - 13,
4126  yScreen - 20,
4127  10,
4128  24,
4129  TRUE,
4131 
4132  // fit memory bars to screen width, distribute them uniform
4133  MemBarWidth = (xScreen - 26) / 5;
4134  MemBarWidth -= MemBarWidth % 2; // make even
4135  /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
4136  /* Create the paged pool progress bar */
4137  CopyContext.MemoryBars[0] = CreateProgressBar(13,
4138  40,
4139  13 + MemBarWidth,
4140  43,
4141  13,
4142  44,
4143  FALSE,
4144  "Kernel Pool");
4145 
4146  /* Create the non paged pool progress bar */
4147  CopyContext.MemoryBars[1] = CreateProgressBar((xScreen / 2)- (MemBarWidth / 2),
4148  40,
4149  (xScreen / 2) + (MemBarWidth / 2),
4150  43,
4151  (xScreen / 2)- (MemBarWidth / 2),
4152  44,
4153  FALSE,
4154  "Kernel Cache");
4155 
4156  /* Create the global memory progress bar */
4157  CopyContext.MemoryBars[2] = CreateProgressBar(xScreen - 13 - MemBarWidth,
4158  40,
4159  xScreen - 13,
4160  43,
4161  xScreen - 13 - MemBarWidth,
4162  44,
4163  FALSE,
4164  "Free Memory");
4165 
4166  /* Do the file copying */
4167  DoFileCopy(&USetupData, FileCopyCallback, &CopyContext);
4168 
4169  /* If we get here, we're done, so cleanup the progress bar */
4170  DestroyProgressBar(CopyContext.ProgressBar);
4171  DestroyProgressBar(CopyContext.MemoryBars[0]);
4172  DestroyProgressBar(CopyContext.MemoryBars[1]);
4173  DestroyProgressBar(CopyContext.MemoryBars[2]);
4174 
4175  /* Create the $winnt$.inf file */
4177 
4178  /* Go display the next page */
4179  return REGISTRY_PAGE;
4180 }
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:3959
ULONG CompletedOperations
Definition: reactos.c:981
static UINT CALLBACK FileCopyCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
Definition: usetup.c:3991
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:3958
#define STRING_SETUPCOPYINGFILES
Definition: mui.h:135

Referenced by RunUSetup().

◆ FlushPage()

static PAGE_NUMBER FlushPage ( PINPUT_RECORD  Ir)
static

Definition at line 4905 of file usetup.c.

4906 {
4908  return REBOOT_PAGE;
4909 }
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  {
3391  /*
3392  * Remove the "Press ENTER to continue" message prompt when the ENTER
3393  * key is pressed as the user wants to begin the partition formatting.
3394  */
3397 
3398  if (!PreparePartitionForFormatting(PartEntry, SelectedFileSystem->FileSystem))
3399  {
3400  /* FIXME: show an error dialog */
3401 
3402  /* Reset the filesystem list */
3404 
3405  return QUIT_PAGE;
3406  }
3407 
3408 #ifndef NDEBUG
3409  CONSOLE_PrintTextXY(6, 12,
3410  "Cylinders: %I64u Tracks/Cyl: %lu Sectors/Trk: %lu Bytes/Sec: %lu %c",
3411  DiskEntry->Cylinders,
3412  DiskEntry->TracksPerCylinder,
3413  DiskEntry->SectorsPerTrack,
3414  DiskEntry->BytesPerSector,
3415  DiskEntry->Dirty ? '*' : ' ');
3416 
3417  Line = 13;
3418 
3419  for (i = 0; i < DiskEntry->LayoutBuffer->PartitionCount; i++)
3420  {
3421  PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[i];
3422 
3424  "%2u: %2lu %c %12I64u %12I64u %02x",
3425  i,
3426  PartitionInfo->PartitionNumber,
3427  PartitionInfo->BootIndicator ? 'A' : '-',
3428  PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector,
3429  PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector,
3430  PartitionInfo->PartitionType);
3431  Line++;
3432  }
3433 #endif
3434 
3435  /* Commit the partition changes to the disk */
3436  Status = WritePartitions(DiskEntry);
3437  if (!NT_SUCCESS(Status))
3438  {
3439  DPRINT1("WritePartitions(disk %lu) failed, Status 0x%08lx\n",
3440  DiskEntry->DiskNumber, Status);
3441 
3443 
3444  /* Reset the filesystem list */
3446 
3447  return QUIT_PAGE;
3448  }
3449 
3450  /* Set PartitionRootPath */
3451  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
3452  L"\\Device\\Harddisk%lu\\Partition%lu",
3453  DiskEntry->DiskNumber,
3454  PartEntry->PartitionNumber);
3455  RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
3456  DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
3457 
3458  /* Format the partition */
3459  Status = FormatPartition(&PartitionRootPath,
3460  SelectedFileSystem->FileSystem,
3461  SelectedFileSystem->QuickFormat);
3463  {
3464  sprintf(Buffer,
3465  "Setup is currently unable to format a partition in %S.\n"
3466  "\n"
3467  " \x07 Press ENTER to continue Setup.\n"
3468  " \x07 Press F3 to quit Setup.",
3469  SelectedFileSystem->FileSystem);
3470 
3474 
3475  while (TRUE)
3476  {
3477  CONSOLE_ConInKey(Ir);
3478 
3479  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x00 &&
3480  Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3) /* F3 */
3481  {
3482  if (ConfirmQuit(Ir))
3483  {
3484  /* Reset the filesystem list */
3486  return QUIT_PAGE;
3487  }
3488  else
3489  {
3490  return SELECT_FILE_SYSTEM_PAGE;
3491  }
3492  }
3493  else if (Ir->Event.KeyEvent.uChar.AsciiChar == VK_RETURN) /* ENTER */
3494  {
3495  return SELECT_FILE_SYSTEM_PAGE;
3496  }
3497  }
3498  }
3499  else if (!NT_SUCCESS(Status))
3500  {
3501  DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status);
3503 
3504  /* Reset the filesystem list */
3506 
3507  return QUIT_PAGE;
3508  }
3509 
3510 //
3511 // TODO: Here, call a partlist.c function that update the actual FS name
3512 // and the label fields of the volume.
3513 //
3514  PartEntry->FormatState = Formatted;
3515  // PartEntry->FileSystem = FileSystem;
3516  PartEntry->New = FALSE;
3517 
3518 #ifndef NDEBUG
3519  CONSOLE_SetStatusText(" Done. Press any key ...");
3520  CONSOLE_ConInKey(Ir);
3521 #endif
3522 
3523  return SELECT_FILE_SYSTEM_PAGE;
3524  }
3525  }
3526 
3527  return FORMAT_PARTITION_PAGE;
3528 }
NTSTATUS FormatPartition(IN PUNICODE_STRING DriveRoot, IN PCWSTR FileSystemName, IN BOOLEAN QuickFormat)
Definition: format.c:89
ULONG PartitionNumber
Definition: partlist.h:48
#define TEXT_TYPE_REGULAR
Definition: consup.h:39
#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:598
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
#define TEXT_ID_FORMAT_PROMPT
Definition: mui.h:108
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
#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:476
PFILE_SYSTEM_ITEM Selected
Definition: fslist.h:42
VOID MUIClearStyledText(IN ULONG Page, IN INT TextID, IN INT Flags)
Definition: mui.c:363
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
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:480
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
union _KEY_EVENT_RECORD::@3172 uChar
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:3793
#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:111
union _INPUT_RECORD::@3173 Event
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:129
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:2374
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
#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
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
union _KEY_EVENT_RECORD::@3172 uChar
VOID ScrollUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:404
union _INPUT_RECORD::@3173 Event
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 3700 of file usetup.c.

3701 {
3702  NTSTATUS Status;
3703  ULONG Length, Pos;
3704  WCHAR c;
3705  WCHAR InstallDir[MAX_PATH];
3706 
3707  /* We do not need the filesystem list anymore */
3709 
3710  if (PartitionList == NULL || InstallPartition == NULL)
3711  {
3712  /* FIXME: show an error dialog */
3713  return QUIT_PAGE;
3714  }
3715 
3716  // if (IsUnattendedSetup)
3717  if (RepairUpdateFlag)
3718  wcscpy(InstallDir, CurrentInstallation->PathComponent); // SystemNtPath
3719  else if (USetupData.InstallationDirectory[0])
3720  wcscpy(InstallDir, USetupData.InstallationDirectory);
3721  else
3722  wcscpy(InstallDir, L"\\ReactOS");
3723 
3724  /*
3725  * Check the validity of the predefined 'InstallDir'. If we are either
3726  * in unattended setup or in update/repair mode, and the installation path
3727  * is valid, just perform the installation. Otherwise (either in the case
3728  * of an invalid path, or we are in regular setup), display the UI and allow
3729  * the user to specify a new installation path.
3730  */
3731  if ((RepairUpdateFlag || IsUnattendedSetup) && IsValidPath(InstallDir))
3732  {
3734  if (!NT_SUCCESS(Status))
3735  {
3736  DPRINT1("InitDestinationPaths() failed. Status code: 0x%lx", Status);
3738  return QUIT_PAGE;
3739  }
3740 
3741  /*
3742  * Check whether the user attempts to install ReactOS within the
3743  * installation source directory, or in a subdirectory thereof.
3744  * If so, fail with an error.
3745  */
3746  if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
3747  {
3749  return INSTALL_DIRECTORY_PAGE;
3750  }
3751 
3752  return PREPARE_COPY_PAGE;
3753  }
3754 
3755  Length = wcslen(InstallDir);
3756  Pos = Length;
3757 
3759  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3760  CONSOLE_SetCursorXY(8 + Pos, 11);
3762 
3763  while (TRUE)
3764  {
3765  CONSOLE_ConInKey(Ir);
3766 
3767  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3768  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
3769  {
3771 
3772  if (ConfirmQuit(Ir))
3773  return QUIT_PAGE;
3774 
3776  break;
3777  }
3778  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3779  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DELETE)) /* DEL */
3780  {
3781  if (Pos < Length)
3782  {
3783  memmove(&InstallDir[Pos],
3784  &InstallDir[Pos + 1],
3785  (Length - Pos - 1) * sizeof(WCHAR));
3786  InstallDir[Length - 1] = UNICODE_NULL;
3787 
3788  Length--;
3789  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3790  CONSOLE_SetCursorXY(8 + Pos, 11);
3791  }
3792  }
3793  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3794  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_HOME)) /* HOME */
3795  {
3796  Pos = 0;
3797  CONSOLE_SetCursorXY(8 + Pos, 11);
3798  }
3799  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3800  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_END)) /* END */
3801  {
3802  Pos = Length;
3803  CONSOLE_SetCursorXY(8 + Pos, 11);
3804  }
3805  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3806  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_LEFT)) /* LEFT */
3807  {
3808  if (Pos > 0)
3809  {
3810  Pos--;
3811  CONSOLE_SetCursorXY(8 + Pos, 11);
3812  }
3813  }
3814  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3815  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)) /* RIGHT */
3816  {
3817  if (Pos < Length)
3818  {
3819  Pos++;
3820  CONSOLE_SetCursorXY(8 + Pos, 11);
3821  }
3822  }
3823  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
3824  {
3826 
3827  /*
3828  * Check for the validity of the installation directory and pop up
3829  * an error if it is not the case. Then the user can fix its input.
3830  */
3831  if (!IsValidPath(InstallDir))
3832  {
3834  return INSTALL_DIRECTORY_PAGE;
3835  }
3836 
3838  if (!NT_SUCCESS(Status))
3839  {
3840  DPRINT1("InitDestinationPaths() failed. Status code: 0x%lx", Status);
3842  return QUIT_PAGE;
3843  }
3844 
3845  /*
3846  * Check whether the user attempts to install ReactOS within the
3847  * installation source directory, or in a subdirectory thereof.
3848  * If so, fail with an error.
3849  */
3850  if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
3851  {
3853  return INSTALL_DIRECTORY_PAGE;
3854  }
3855 
3856  return PREPARE_COPY_PAGE;
3857  }
3858  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
3859  {
3860  if (Pos > 0)
3861  {
3862  if (Pos < Length)
3863  memmove(&InstallDir[Pos - 1],
3864  &InstallDir[Pos],
3865  (Length - Pos) * sizeof(WCHAR));
3866  InstallDir[Length - 1] = UNICODE_NULL;
3867 
3868  Pos--;
3869  Length--;
3870  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3871  CONSOLE_SetCursorXY(8 + Pos, 11);
3872  }
3873  }
3874  else if (isprint(Ir->Event.KeyEvent.uChar.AsciiChar))
3875  {
3876  if (Length < 50)
3877  {
3879  if (iswalpha(c) || iswdigit(c) || c == '.' || c == '\\' || c == '-' || c == '_')
3880  {
3881  if (Pos < Length)
3882  memmove(&InstallDir[Pos + 1],
3883  &InstallDir[Pos],
3884  (Length - Pos) * sizeof(WCHAR));
3885  InstallDir[Length + 1] = UNICODE_NULL;
3886  InstallDir[Pos] = c;
3887 
3888  Pos++;
3889  Length++;
3890  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3891  CONSOLE_SetCursorXY(8 + Pos, 11);
3892  }
3893  }
3894  }
3895  }
3896 
3897  return INSTALL_DIRECTORY_PAGE;
3898 }
#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:343
WORD wVirtualKeyCode
Definition: wincon.h:227
static BOOLEAN IsValidPath(IN PCWSTR InstallDir)
Definition: usetup.c:3644
#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
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
union _KEY_EVENT_RECORD::@3172 uChar
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
union _INPUT_RECORD::@3173 Event
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
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
union _KEY_EVENT_RECORD::@3172 uChar
BOOLEAN IsUnattendedSetup
Definition: usetup.c:45
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:70
union _INPUT_RECORD::@3173 Event
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 3644 of file usetup.c.

3646 {
3647  UINT i, Length;
3648 
3649  Length = wcslen(InstallDir);
3650 
3651  // TODO: Add check for 8.3 too.
3652 
3653  /* Path must be at least 2 characters long */
3654 // if (Length < 2)
3655 // return FALSE;
3656 
3657  /* Path must start with a backslash */
3658 // if (InstallDir[0] != L'\\')
3659 // return FALSE;
3660 
3661  /* Path must not end with a backslash */
3662  if (InstallDir[Length - 1] == L'\\')
3663  return FALSE;
3664 
3665  /* Path must not contain whitespace characters */
3666  for (i = 0; i < Length; i++)
3667  {
3668  if (iswspace(InstallDir[i]))
3669  return FALSE;
3670  }
3671 
3672  /* Path component must not end with a dot */
3673  for (i = 0; i < Length; i++)
3674  {
3675  if (InstallDir[i] == L'\\' && i > 0)
3676  {
3677  if (InstallDir[i - 1] == L'.')
3678  return FALSE;
3679  }
3680  }
3681 
3682  if (InstallDir[Length - 1] == L'.')
3683  return FALSE;
3684 
3685  return TRUE;
3686 }
#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
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
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)
union _KEY_EVENT_RECORD::@3172 uChar
struct _GENENTRY * PGENENTRY
static WCHAR DefaultLanguage[20]
Definition: usetup.c:67
VOID ScrollUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:404
union _INPUT_RECORD::@3173 Event
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:456
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
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
union _KEY_EVENT_RECORD::@3172 uChar
union _INPUT_RECORD::@3173 Event
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ NtProcessStartup()

VOID NTAPI NtProcessStartup ( PPEB  Peb)

Definition at line 5141 of file usetup.c.

5142 {
5143  NTSTATUS Status;
5145 
5147 
5149 
5151 
5152  Status = RunUSetup();
5153 
5154  if (NT_SUCCESS(Status))
5155  {
5156  /*
5157  * Avoid a bugcheck if RunUSetup() finishes too quickly by implementing
5158  * a protective waiting.
5159  * This wait is needed because, since we are started as SMSS.EXE,
5160  * the NT kernel explicitly waits 5 seconds for the initial process
5161  * SMSS.EXE to initialize (as a protective measure), and otherwise
5162  * bugchecks with the code SESSION5_INITIALIZATION_FAILED.
5163  */
5164  Time.QuadPart += 50000000;
5166  }
5167  else
5168  {
5169  /* The installer failed to start: raise a hard error (crash the system/BSOD) */
5171  0, 0, NULL, 0, NULL);
5172  }
5173 
5175 }
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:4916
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:1890
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:496
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FOREGROUND_RED
Definition: blue.h:63
#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:531
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:378
ULONG X
Definition: bl.h:1340
CONST CHAR * PCCH
Definition: ntbasedef.h:399
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
union _KEY_EVENT_RECORD::@3172 uChar
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
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
union _INPUT_RECORD::@3173 Event
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 3937 of file usetup.c.

3938 {
3939  // ERROR_NUMBER ErrorNumber;
3940  BOOLEAN Success;
3941 
3943 
3944  /* ErrorNumber = */ Success = PrepareFileCopy(&USetupData, NULL);
3945  if (/*ErrorNumber != ERROR_SUCCESS*/ !Success)
3946  {
3947  // MUIDisplayError(ErrorNumber, Ir, POPUP_WAIT_ENTER);
3948  return QUIT_PAGE;
3949  }
3950 
3951  return FILE_COPY_PAGE;
3952 }
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 4699 of file usetup.c.

4702 {
4703  NTSTATUS Status;
4704  ULONG StartTime, BarWidth, TimerDiv;
4705  LONG TimeElapsed;
4706  LONG TimerValue, OldTimerValue;
4708  PPROGRESSBAR ProgressBar;
4709  BOOLEAN RefreshProgress = TRUE;
4710 
4711  /* Bail out if the timeout is already zero */
4712  if (TimeOut <= 0)
4713  return;
4714 
4715  /* Create the timeout progress bar and set it up */
4716  ProgressBar = CreateProgressBarEx(13,
4717  26,
4718  xScreen - 13,
4719  yScreen - 20,
4720  10,
4721  24,
4722  TRUE,
4724  0,
4725  NULL,
4728 
4729  BarWidth = max(1, ProgressBar->Width);
4730  TimerValue = TimeOut * BarWidth;
4731  ProgressSetStepCount(ProgressBar, TimerValue);
4732 
4734  CONSOLE_Flush();
4735 
4736  TimerDiv = 1000 / BarWidth;
4737  TimerDiv = max(1, TimerDiv);
4738  OldTimerValue = TimerValue;
4739  while (TRUE)
4740  {
4741  /* Decrease the timer */
4742 
4743  /*
4744  * Compute how much time the previous operations took.
4745  * This allows us in particular to take account for any time
4746  * elapsed if something slowed down.
4747  */
4748  TimeElapsed = NtGetTickCount() - StartTime;
4749  if (TimeElapsed >= TimerDiv)
4750  {
4751  /* Increase StartTime by steps of 1 / ProgressBar->Width seconds */
4752  TimeElapsed /= TimerDiv;
4753  StartTime += (TimerDiv * TimeElapsed);
4754 
4755  if (TimeElapsed <= TimerValue)
4756  TimerValue -= TimeElapsed;
4757  else
4758  TimerValue = 0;
4759 
4760  RefreshProgress = TRUE;
4761  }
4762 
4763  if (RefreshProgress)
4764  {
4765  ProgressSetStep(ProgressBar, OldTimerValue - TimerValue);
4766  RefreshProgress = FALSE;
4767  }
4768 
4769  /* Stop when the timer reaches zero */
4770  if (TimerValue <= 0)
4771  break;
4772 
4773  /* Check for user key presses */
4774 
4775  /*
4776  * If the timer is used, use a passive wait of maximum 1 second
4777  * while monitoring for incoming console input events, so that
4778  * we are still able to display the timing count.
4779  */
4780 
4781  /* Wait a maximum of 1 second for input events */
4782  TimeElapsed = NtGetTickCount() - StartTime;
4783  if (TimeElapsed < TimerDiv)
4784  {
4785  /* Convert the time to NT Format */
4786  Timeout.QuadPart = (TimerDiv - TimeElapsed) * -10000LL;
4788  }
4789  else
4790  {
4792  }
4793 
4794  /* Check whether the input event has been signaled, or a timeout happened */
4795  if (Status == STATUS_TIMEOUT)
4796  {
4797  continue;
4798  }
4799  if (Status != STATUS_WAIT_0)
4800  {
4801  /* An error happened, bail out */
4802  DPRINT1("NtWaitForSingleObject() failed, Status 0x%08lx\n", Status);
4803  break;
4804  }
4805 
4806  /* Check for an ENTER key press */
4807  while (CONSOLE_ConInKeyPeek(Ir))
4808  {
4809  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4810  {
4811  /* Found it, stop waiting */
4812  goto Exit;
4813  }
4814  }
4815  }
4816 
4817 Exit:
4818  /* Destroy the progress bar and quit */
4819  DestroyProgressBar(ProgressBar);
4820 }
#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:174
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
#define FOREGROUND_RED
Definition: blue.h:63
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:4652
static void Exit(void)
Definition: sock.c:1331
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
SHORT yScreen
Definition: consup.c:40
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
#define DPRINT1
Definition: precomp.h:8
#define BACKGROUND_BLUE
Definition: blue.h:65
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 4652 of file usetup.c.

4657 {
4658  ULONG OldProgress = Bar->Progress;
4659 
4660  if (Bar->StepCount == 0)
4661  {
4662  Bar->Progress = 0;
4663  }
4664  else
4665  {
4666  Bar->Progress = Bar->StepCount - Bar->CurrentStep;
4667  }
4668 
4669  /* Build the progress string if it has changed */
4670  if (Bar->ProgressFormatText &&
4671  (AlwaysUpdate || (Bar->Progress != OldProgress)))
4672  {
4674  Bar->ProgressFormatText, Bar->Progress / max(1, Bar->Width) + 1);
4675 
4676  return TRUE;
4677  }
4678 
4679  return FALSE;
4680 }
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 4836 of file usetup.c.

4837 {
4839 
4840  /* Destroy the NTOS installations list */
4841  if (NtOsInstallsList != NULL)
4842  {
4845  }
4846 
4847  /* Destroy the partition list */
4848  if (PartitionList != NULL)
4849  {
4851  PartitionList = NULL;
4852  }
4853 
4854  /* Reset the formatter machine state */
4855  TempPartition = NULL;
4856  FormatState = Start;
4857 
4858  /* Destroy the filesystem list */
4860 
4862 
4863  /* Wait for maximum 15 seconds or an ENTER key before quitting */
4864  ProgressCountdown(Ir, 15);
4865  return FLUSH_PAGE;
4866 }
#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:143
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:4699
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:2108
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:480

Referenced by RunUSetup().

◆ RegistryPage()

static PAGE_NUMBER RegistryPage ( PINPUT_RECORD  Ir)
static

Definition at line 4229 of file usetup.c.

4230 {
4231  ULONG Error;
4232 
4234 
4235