ReactOS  0.4.13-dev-259-g5ca9c9c
usetup.c File Reference
#include <usetup.h>
#include <math.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 NTSTATUS BuildInstallPaths (IN PCWSTR InstallDir, IN PPARTENTRY PartEntry)
 
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 WCHAR DestinationDriveLetter
 
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 37 of file usetup.c.

◆ PARTITION_MAXSIZE

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

Definition at line 1803 of file usetup.c.

◆ PARTITION_SIZE_INPUT_FIELD_LENGTH

#define PARTITION_SIZE_INPUT_FIELD_LENGTH   9

Definition at line 1801 of file usetup.c.

Typedef Documentation

◆ COPYCONTEXT

◆ PCOPYCONTEXT

Function Documentation

◆ BootLoaderFloppyPage()

static PAGE_NUMBER BootLoaderFloppyPage ( PINPUT_RECORD  Ir)
static

Definition at line 4340 of file usetup.c.

4341 {
4342  NTSTATUS Status;
4343 
4345 
4346 // CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
4347 
4348  while (TRUE)
4349  {
4350  CONSOLE_ConInKey(Ir);
4351 
4352  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4353  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
4354  {
4355  if (ConfirmQuit(Ir))
4356  return QUIT_PAGE;
4357 
4358  break;
4359  }
4360  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4361  {
4362  Status = InstallFatBootcodeToFloppy(&USetupData.SourceRootPath,
4363  &USetupData.DestinationArcPath);
4364  if (!NT_SUCCESS(Status))
4365  {
4368 
4369  /* TODO: Print error message */
4370  return BOOT_LOADER_FLOPPY_PAGE;
4371  }
4372 
4373  return SUCCESS_PAGE;
4374  }
4375  }
4376 
4377  return BOOT_LOADER_FLOPPY_PAGE;
4378 }
static USETUP_DATA USetupData
Definition: usetup.c:46
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
LONG NTSTATUS
Definition: precomp.h:26
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3145 Event
#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:2211
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
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:125
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65

Referenced by RunUSetup().

◆ BootLoaderHarddiskMbrPage()

static PAGE_NUMBER BootLoaderHarddiskMbrPage ( PINPUT_RECORD  Ir)
static

Definition at line 4430 of file usetup.c.

4431 {
4432  NTSTATUS Status;
4433  WCHAR DestinationDevicePathBuffer[MAX_PATH];
4434 
4435  /* Step 1: Write the VBR */
4436  // FIXME! We must not use the partition type, but instead use the partition FileSystem!!
4437  Status = InstallVBRToPartition(&USetupData.SystemRootPath,
4438  &USetupData.SourceRootPath,
4439  &USetupData.DestinationArcPath,
4441  if (!NT_SUCCESS(Status))
4442  {
4445  return QUIT_PAGE;
4446  }
4447 
4448  /* Step 2: Write the MBR if the disk containing the system partition is not a super-floppy */
4450  {
4451  RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
4452  L"\\Device\\Harddisk%d\\Partition0",
4453  PartitionList->SystemPartition->DiskEntry->DiskNumber);
4454  Status = InstallMbrBootCodeToDisk(&USetupData.SystemRootPath,
4455  &USetupData.SourceRootPath,
4456  DestinationDevicePathBuffer);
4457  if (!NT_SUCCESS(Status))
4458  {
4459  DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n", Status);
4461  return QUIT_PAGE;
4462  }
4463  }
4464 
4465  return SUCCESS_PAGE;
4466 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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
PPARTENTRY SystemPartition
Definition: partlist.h:153
static __inline NTSTATUS RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1064
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:54
static PPARTLIST PartitionList
Definition: usetup.c:65
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:125
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
Definition: partlist.c:679
#define DPRINT1
Definition: precomp.h:8

Referenced by RunUSetup().

◆ BootLoaderHarddiskVbrPage()

static PAGE_NUMBER BootLoaderHarddiskVbrPage ( PINPUT_RECORD  Ir)
static

Definition at line 4395 of file usetup.c.

4396 {
4397  NTSTATUS Status;
4398 
4399  // FIXME! We must not use the partition type, but instead use the partition FileSystem!!
4400  Status = InstallVBRToPartition(&USetupData.SystemRootPath,
4401  &USetupData.SourceRootPath,
4402  &USetupData.DestinationArcPath,
4404  if (!NT_SUCCESS(Status))
4405  {
4408  return QUIT_PAGE;
4409  }
4410 
4411  return SUCCESS_PAGE;
4412 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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
PPARTENTRY SystemPartition
Definition: partlist.h:153
UCHAR PartitionType
Definition: partlist.h:46
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WCHAR FileSystem[MAX_PATH+1]
Definition: partlist.h:54
static PPARTLIST PartitionList
Definition: usetup.c:65
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:125

Referenced by RunUSetup().

◆ BootLoaderPage()

static PAGE_NUMBER BootLoaderPage ( PINPUT_RECORD  Ir)
static

Definition at line 4116 of file usetup.c.

4117 {
4119  BOOLEAN InstallOnFloppy;
4120  USHORT Line = 12;
4121  WCHAR PathBuffer[MAX_PATH];
4122 
4124 
4126 
4127  RtlFreeUnicodeString(&USetupData.SystemRootPath);
4128  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
4129  L"\\Device\\Harddisk%lu\\Partition%lu\\",
4130  PartitionList->SystemPartition->DiskEntry->DiskNumber,
4132  RtlCreateUnicodeString(&USetupData.SystemRootPath, PathBuffer);
4133  DPRINT1("SystemRootPath: %wZ\n", &USetupData.SystemRootPath);
4134 
4136 
4137  /* For unattended setup, skip MBR installation or install on floppy if needed */
4138  if (IsUnattendedSetup)
4139  {
4140  if ((USetupData.MBRInstallType == 0) ||
4141  (USetupData.MBRInstallType == 1))
4142  {
4143  goto Quit;
4144  }
4145  }
4146 
4147  /*
4148  * We may install an MBR or VBR, but before that, check whether
4149  * we need to actually install the VBR on floppy.
4150  */
4152  {
4153  DPRINT("Error: system partition invalid (unused)\n");
4154  InstallOnFloppy = TRUE;
4155  }
4156  else if (PartitionType == PARTITION_OS2BOOTMGR)
4157  {
4158  /* OS/2 boot manager partition */
4159  DPRINT("Found OS/2 boot manager partition\n");
4160  InstallOnFloppy = TRUE;
4161  }
4162  else if (PartitionType == PARTITION_LINUX)
4163  {
4164  /* Linux partition */
4165  DPRINT("Found Linux native partition (ext2/ext3/ReiserFS/BTRFS/etc)\n");
4166  InstallOnFloppy = FALSE;
4167  }
4168  else if (PartitionType == PARTITION_IFS)
4169  {
4170  /* NTFS partition */
4171  DPRINT("Found NTFS partition\n");
4172 
4173  // FIXME: Make it FALSE when we'll support NTFS installation!
4174  InstallOnFloppy = TRUE;
4175  }
4176  else if ((PartitionType == PARTITION_FAT_12) ||
4182  {
4183  DPRINT("Found FAT partition\n");
4184  InstallOnFloppy = FALSE;
4185  }
4186  else
4187  {
4188  /* Unknown partition */
4189  DPRINT("Unknown partition found\n");
4190  InstallOnFloppy = TRUE;
4191  }
4192 
4193  /* We should install on floppy */
4194  if (InstallOnFloppy)
4195  {
4196  USetupData.MBRInstallType = 1;
4197  goto Quit;
4198  }
4199 
4200  /* Is it an unattended install on hdd? */
4201  if (IsUnattendedSetup)
4202  {
4203  if ((USetupData.MBRInstallType == 2) ||
4204  (USetupData.MBRInstallType == 3))
4205  {
4206  goto Quit;
4207  }
4208  }
4209 
4211  CONSOLE_InvertTextXY(8, Line, 60, 1);
4212 
4213  while (TRUE)
4214  {
4215  CONSOLE_ConInKey(Ir);
4216 
4217  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4218  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
4219  {
4220  CONSOLE_NormalTextXY(8, Line, 60, 1);
4221 
4222  Line++;
4223  if (Line < 12)
4224  Line = 15;
4225 
4226  if (Line > 15)
4227  Line = 12;
4228 
4229  CONSOLE_InvertTextXY(8, Line, 60, 1);
4230  }
4231  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4232  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
4233  {
4234  CONSOLE_NormalTextXY(8, Line, 60, 1);
4235 
4236  Line--;
4237  if (Line < 12)
4238  Line = 15;
4239 
4240  if (Line > 15)
4241  Line = 12;
4242 
4243  CONSOLE_InvertTextXY(8, Line, 60, 1);
4244  }
4245  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4246  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_HOME)) /* HOME */
4247  {
4248  CONSOLE_NormalTextXY(8, Line, 60, 1);
4249 
4250  Line = 12;
4251 
4252  CONSOLE_InvertTextXY(8, Line, 60, 1);
4253  }
4254  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4255  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_END)) /* END */
4256  {
4257  CONSOLE_NormalTextXY(8, Line, 60, 1);
4258 
4259  Line = 15;
4260 
4261  CONSOLE_InvertTextXY(8, Line, 60, 1);
4262  }
4263  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
4264  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
4265  {
4266  if (ConfirmQuit(Ir))
4267  return QUIT_PAGE;
4268 
4269  break;
4270  }
4271  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4272  {
4273  if (Line == 12)
4274  {
4275  /* Install on both MBR and VBR */
4276  USetupData.MBRInstallType = 2;
4277  break;
4278  }
4279  else if (Line == 13)
4280  {
4281  /* Install on VBR only */
4282  USetupData.MBRInstallType = 3;
4283  break;
4284  }
4285  else if (Line == 14)
4286  {
4287  /* Install on floppy */
4288  USetupData.MBRInstallType = 1;
4289  break;
4290  }
4291  else if (Line == 15)
4292  {
4293  /* Skip MBR installation */
4294  USetupData.MBRInstallType = 0;
4295  break;
4296  }
4297 
4298  return BOOT_LOADER_PAGE;
4299  }
4300  }
4301 
4302 Quit:
4303  switch (USetupData.MBRInstallType)
4304  {
4305  /* Skip MBR installation */
4306  case 0:
4307  return SUCCESS_PAGE;
4308 
4309  /* Install on floppy */
4310  case 1:
4311  return BOOT_LOADER_FLOPPY_PAGE;
4312 
4313  /* Install on both MBR and VBR */
4314  case 2:
4316 
4317  /* Install on VBR only */
4318  case 3:
4320  }
4321 
4322  return BOOT_LOADER_PAGE;
4323 }
#define PARTITION_FAT32
Definition: disk.h:95
ULONG PartitionNumber
Definition: partlist.h:49
static USETUP_DATA USetupData
Definition: usetup.c:46
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define VK_DOWN
Definition: winuser.h:2181
VOID CONSOLE_NormalTextXY(IN SHORT x, IN SHORT y, IN SHORT col, IN SHORT row)
Definition: consup.c:282
PPARTENTRY SystemPartition
Definition: partlist.h:153
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:2177
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:2179
#define PARTITION_HUGE
Definition: disk.h:92
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
#define PARTITION_IFS
Definition: disk.h:93
static __inline NTSTATUS RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1064
union _INPUT_RECORD::@3145 Event
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
static PPARTLIST PartitionList
Definition: usetup.c:65
#define VK_F3
Definition: winuser.h:2211
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:368
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN IsUnattendedSetup
Definition: usetup.c:44
#define PARTITION_LINUX
Definition: partlist.c:36
#define DPRINT1
Definition: precomp.h:8
CHAR PartitionType
Definition: part_xbox.c:33
#define PARTITION_FAT_12
Definition: disk.h:87
#define STRING_PLEASEWAIT
Definition: mui.h:74
#define PARTITION_FAT32_XINT13
Definition: disk.h:96
#define VK_END
Definition: winuser.h:2176
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
BOOLEAN IsPartitioned
Definition: partlist.h:60
#define PARTITION_OS2BOOTMGR
Definition: disk.h:94

Referenced by RunUSetup().

◆ BuildInstallPaths()

static NTSTATUS BuildInstallPaths ( IN PCWSTR  InstallDir,
IN PPARTENTRY  PartEntry 
)
static

Definition at line 3455 of file usetup.c.

3458 {
3459  NTSTATUS Status;
3460 
3461  Status = InitDestinationPaths(&USetupData, InstallDir, PartEntry);
3462 
3463  if (!NT_SUCCESS(Status))
3464  {
3465  DPRINT1("InitDestinationPaths() failed with status 0x%08lx\n", Status);
3466  return Status;
3467  }
3468 
3469  /* Initialize DestinationDriveLetter */
3470  DestinationDriveLetter = PartEntry->DriveLetter;
3471 
3472  return STATUS_SUCCESS;
3473 }
static USETUP_DATA USetupData
Definition: usetup.c:46
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static WCHAR DestinationDriveLetter
Definition: usetup.c:53
#define DPRINT1
Definition: precomp.h:8
return STATUS_SUCCESS
Definition: btrfs.c:2745
NTSTATUS InitDestinationPaths(IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
Definition: setuplib.c:624

Referenced by InstallDirectoryPage().

◆ CheckFileSystemPage()

static PAGE_NUMBER CheckFileSystemPage ( PINPUT_RECORD  Ir)
static

Definition at line 3352 of file usetup.c.

3353 {
3354  NTSTATUS Status;
3355  PDISKENTRY DiskEntry;
3356  PPARTENTRY PartEntry;
3357  UNICODE_STRING PartitionRootPath;
3358  WCHAR PathBuffer[MAX_PATH];
3359  CHAR Buffer[MAX_PATH];
3360 
3361  if (PartitionList == NULL)
3362  {
3363  /* FIXME: show an error dialog */
3364  return QUIT_PAGE;
3365  }
3366 
3367  if (!GetNextUncheckedPartition(PartitionList, &DiskEntry, &PartEntry))
3368  {
3369  return INSTALL_DIRECTORY_PAGE;
3370  }
3371 
3372  ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
3373 
3375 
3377 
3378  DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystem: %S\n",
3379  PartEntry->PartitionType, (*PartEntry->FileSystem ? PartEntry->FileSystem : L"n/a"));
3380 
3381  /* HACK: Do not try to check a partition with an unknown filesystem */
3382  if (!*PartEntry->FileSystem)
3383  {
3384  PartEntry->NeedsCheck = FALSE;
3385  return CHECK_FILE_SYSTEM_PAGE;
3386  }
3387 
3388  /* Set PartitionRootPath */
3389  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
3390  L"\\Device\\Harddisk%lu\\Partition%lu",
3391  DiskEntry->DiskNumber,
3392  PartEntry->PartitionNumber);
3393  RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
3394  DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
3395 
3396  /* Check the partition */
3397  Status = ChkdskPartition(&PartitionRootPath, PartEntry->FileSystem);
3399  {
3400  /*
3401  * Partition checking is not supported with the current filesystem,
3402  * so disable FS checks on it.
3403  */
3404  PartEntry->NeedsCheck = FALSE;
3405 
3406  sprintf(Buffer,
3407  "Setup is currently unable to check a partition formatted in %S.\n"
3408  "\n"
3409  " \x07 Press ENTER to continue Setup.\n"
3410  " \x07 Press F3 to quit Setup.",
3411  PartEntry->FileSystem);
3412 
3416 
3417  while (TRUE)
3418  {
3419  CONSOLE_ConInKey(Ir);
3420 
3421  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x00 &&
3422  Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3) /* F3 */
3423  {
3424  if (ConfirmQuit(Ir))
3425  return QUIT_PAGE;
3426  else
3427  return CHECK_FILE_SYSTEM_PAGE;
3428  }
3429  else if (Ir->Event.KeyEvent.uChar.AsciiChar == VK_RETURN) /* ENTER */
3430  {
3431  return CHECK_FILE_SYSTEM_PAGE;
3432  }
3433  }
3434  }
3435  else if (!NT_SUCCESS(Status))
3436  {
3437  DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status);
3438  // sprintf(Buffer, "Setup failed to verify the selected partition.\n"
3439  sprintf(Buffer, "ChkDsk detected some disk errors.\n"
3440  "(Status 0x%08lx).\n", Status);
3442  // MUIGetString(STRING_REBOOTCOMPUTER),
3444  Ir, POPUP_WAIT_ENTER);
3445 
3446  // return QUIT_PAGE;
3447  }
3448 
3449  PartEntry->NeedsCheck = FALSE;
3450  return CHECK_FILE_SYSTEM_PAGE;
3451 }
ULONG PartitionNumber
Definition: partlist.h:49
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:123
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:305
union _KEY_EVENT_RECORD::@3144 uChar
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:195
ULONG DiskNumber
Definition: partlist.h:105
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define VK_RETURN
Definition: winuser.h:2155
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:4136
Definition: bufpool.h:45
#define STRING_CHECKINGPART
Definition: mui.h:90
static __inline NTSTATUS RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1064
union _INPUT_RECORD::@3145 Event
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:54
static PPARTLIST PartitionList
Definition: usetup.c:65
#define VK_F3
Definition: winuser.h:2211
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
#define STRING_CONTINUE
Definition: mui.h:91
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:125
BOOLEAN NeedsCheck
Definition: partlist.h:71
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STRING_PLEASEWAIT
Definition: mui.h:74
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STRING_QUITCONTINUE
Definition: mui.h:92
BOOLEAN IsPartitioned
Definition: partlist.h:60

Referenced by RunUSetup().

◆ ComputerSettingsPage()

static PAGE_NUMBER ComputerSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1323 of file usetup.c.

1324 {
1325  GENERIC_LIST_UI ListUi;
1327 
1328  InitGenericListUi(&ListUi, USetupData.ComputerList, GetSettingDescription);
1329  DrawGenericList(&ListUi,
1330  2, 18,
1331  xScreen - 3,
1332  yScreen - 3);
1333 
1334  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1335 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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:1257
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:430

Referenced by RunUSetup().

◆ ConfirmDeleteSystemPartitionPage()

static PAGE_NUMBER ConfirmDeleteSystemPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2485 of file usetup.c.

2486 {
2488 
2489  while (TRUE)
2490  {
2491  CONSOLE_ConInKey(Ir);
2492 
2493  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
2494  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
2495  {
2496  if (ConfirmQuit(Ir))
2497  return QUIT_PAGE;
2498 
2499  break;
2500  }
2501  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
2502  {
2503  return DELETE_PARTITION_PAGE;
2504  }
2505  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESC */
2506  {
2507  return SELECT_PARTITION_PAGE;
2508  }
2509  }
2510 
2512 }
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
#define VK_ESCAPE
Definition: winuser.h:2168
#define VK_RETURN
Definition: winuser.h:2155
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3145 Event
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2211
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
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 368 of file usetup.c.

369 {
370  BOOL Result = FALSE;
372 
373  while (TRUE)
374  {
375  CONSOLE_ConInKey(Ir);
376 
377  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
378  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
379  {
380  Result = TRUE;
381  break;
382  }
383  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
384  {
385  Result = FALSE;
386  break;
387  }
388  }
389 
390  return Result;
391 }
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:123
union _KEY_EVENT_RECORD::@3144 uChar
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
union _INPUT_RECORD::@3145 Event
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2211
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

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

◆ CreateExtendedPartitionPage()

static PAGE_NUMBER CreateExtendedPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2162 of file usetup.c.

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

Referenced by RunUSetup().

◆ CreateLogicalPartitionPage()

static PAGE_NUMBER CreateLogicalPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2323 of file usetup.c.

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

Referenced by RunUSetup().

◆ CreatePrimaryPartitionPage()

static PAGE_NUMBER CreatePrimaryPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2000 of file usetup.c.

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

Referenced by RunUSetup().

◆ DeletePartitionPage()

static PAGE_NUMBER DeletePartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 2526 of file usetup.c.

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

Referenced by RunUSetup().

◆ DeviceSettingsPage()

static PAGE_NUMBER DeviceSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1125 of file usetup.c.

1126 {
1127  static ULONG Line = 16;
1128 
1129  /* Initialize the computer settings list */
1130  if (USetupData.ComputerList == NULL)
1131  {
1132  USetupData.ComputerList = CreateComputerTypeList(USetupData.SetupInf);
1133  if (USetupData.ComputerList == NULL)
1134  {
1136  return QUIT_PAGE;
1137  }
1138  }
1139 
1140  /* Initialize the display settings list */
1141  if (USetupData.DisplayList == NULL)
1142  {
1143  USetupData.DisplayList = CreateDisplayDriverList(USetupData.SetupInf);
1144  if (USetupData.DisplayList == NULL)
1145  {
1147  return QUIT_PAGE;
1148  }
1149  }
1150 
1151  /* Initialize the keyboard settings list */
1152  if (USetupData.KeyboardList == NULL)
1153  {
1154  USetupData.KeyboardList = CreateKeyboardDriverList(USetupData.SetupInf);
1155  if (USetupData.KeyboardList == NULL)
1156  {
1158  return QUIT_PAGE;
1159  }
1160  }
1161 
1162  /* Initialize the keyboard layout list */
1163  if (USetupData.LayoutList == NULL)
1164  {
1166  if (USetupData.LayoutList == NULL)
1167  {
1168  /* FIXME: report error */
1170  return QUIT_PAGE;
1171  }
1172  }
1173 
1174  if (RepairUpdateFlag)
1175  return SELECT_PARTITION_PAGE;
1176 
1177  // if (IsUnattendedSetup)
1178  // return SELECT_PARTITION_PAGE;
1179 
1181 
1186 
1187  CONSOLE_InvertTextXY(24, Line, 48, 1);
1188 
1189  while (TRUE)
1190  {
1191  CONSOLE_ConInKey(Ir);
1192 
1193  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1194  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
1195  {
1196  CONSOLE_NormalTextXY(24, Line, 48, 1);
1197 
1198  if (Line == 14)
1199  Line = 16;
1200  else if (Line == 16)
1201  Line = 11;
1202  else
1203  Line++;
1204 
1205  CONSOLE_InvertTextXY(24, Line, 48, 1);
1206  }
1207  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1208  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
1209  {
1210  CONSOLE_NormalTextXY(24, Line, 48, 1);
1211 
1212  if (Line == 11)
1213  Line = 16;
1214  else if (Line == 16)
1215  Line = 14;
1216  else
1217  Line--;
1218 
1219  CONSOLE_InvertTextXY(24, Line, 48, 1);
1220  }
1221  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1222  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1223  {
1224  if (ConfirmQuit(Ir))
1225  return QUIT_PAGE;
1226 
1227  break;
1228  }
1229  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1230  {
1231  if (Line == 11)
1232  return COMPUTER_SETTINGS_PAGE;
1233  else if (Line == 12)
1234  return DISPLAY_SETTINGS_PAGE;
1235  else if (Line == 13)
1236  return KEYBOARD_SETTINGS_PAGE;
1237  else if (Line == 14)
1238  return LAYOUT_SETTINGS_PAGE;
1239  else if (Line == 16)
1240  return SELECT_PARTITION_PAGE;
1241  }
1242  }
1243 
1244  return DEVICE_SETTINGS_PAGE;
1245 }
static USETUP_DATA USetupData
Definition: usetup.c:46
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
#define VK_DOWN
Definition: winuser.h:2181
PGENERIC_LIST CreateKeyboardLayoutList(IN HINF InfFile, IN PCWSTR LanguageId, OUT PWSTR DefaultKBLayout)
Definition: settings.c:1184
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:2179
smooth NULL
Definition: ftsmooth.c:416
union _INPUT_RECORD::@3145 Event
PGENERIC_LIST CreateDisplayDriverList(IN HINF InfFile)
Definition: settings.c:673
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:58
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2211
Definition: ncftp.h:79
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
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:437
#define POPUP_WAIT_ENTER
Definition: usetup.h:125
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:62
unsigned int ULONG
Definition: retypes.h:1
PGENERIC_LIST CreateKeyboardDriverList(IN HINF InfFile)
Definition: settings.c:1047
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
static WCHAR DefaultKBLayout[20]
Definition: usetup.c:60
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:430

Referenced by RunUSetup().

◆ DisplaySettingsPage()

static PAGE_NUMBER DisplaySettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1349 of file usetup.c.

1350 {
1351  GENERIC_LIST_UI ListUi;
1353 
1354  InitGenericListUi(&ListUi, USetupData.DisplayList, GetSettingDescription);
1355  DrawGenericList(&ListUi,
1356  2, 18,
1357  xScreen - 3,
1358  yScreen - 3);
1359 
1360  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1361 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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:1257
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:430

Referenced by RunUSetup().

◆ DrawBox()

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

Definition at line 105 of file usetup.c.

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

Referenced by PopupError(), and ShowPartitionSizeInputBox().

◆ FileCopyCallback()

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

Definition at line 3832 of file usetup.c.

3836 {
3837  PCOPYCONTEXT CopyContext = (PCOPYCONTEXT)Context;
3838  PFILEPATHS_W FilePathInfo;
3839  PCWSTR SrcFileName, DstFileName;
3840 
3841  switch (Notification)
3842  {
3844  {
3845  CopyContext->TotalOperations = (ULONG)Param2;
3846  CopyContext->CompletedOperations = 0;
3847  ProgressSetStepCount(CopyContext->ProgressBar,
3848  CopyContext->TotalOperations);
3849  SetupUpdateMemoryInfo(CopyContext, TRUE);
3850  break;
3851  }
3852 
3856  {
3857  FilePathInfo = (PFILEPATHS_W)Param1;
3858 
3859  if (Notification == SPFILENOTIFY_STARTDELETE)
3860  {
3861  /* Display delete message */
3862  ASSERT(Param2 == FILEOP_DELETE);
3863 
3864  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
3865  if (DstFileName) ++DstFileName;
3866  else DstFileName = FilePathInfo->Target;
3867 
3869  DstFileName);
3870  }
3871  else if (Notification == SPFILENOTIFY_STARTRENAME)
3872  {
3873  /* Display move/rename message */
3874  ASSERT(Param2 == FILEOP_RENAME);
3875 
3876  SrcFileName = wcsrchr(FilePathInfo->Source, L'\\');
3877  if (SrcFileName) ++SrcFileName;
3878  else SrcFileName = FilePathInfo->Source;
3879 
3880  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
3881  if (DstFileName) ++DstFileName;
3882  else DstFileName = FilePathInfo->Target;
3883 
3884  if (!wcsicmp(SrcFileName, DstFileName))
3885  Param2 = STRING_MOVING;
3886  else
3887  Param2 = STRING_RENAMING;
3888 
3890  SrcFileName, DstFileName);
3891  }
3892  else if (Notification == SPFILENOTIFY_STARTCOPY)
3893  {
3894  /* Display copy message */
3895  ASSERT(Param2 == FILEOP_COPY);
3896 
3897  /* NOTE: When extracting from CABs the Source is the CAB name */
3898  DstFileName = wcsrchr(FilePathInfo->Target, L'\\');
3899  if (DstFileName) ++DstFileName;
3900  else DstFileName = FilePathInfo->Target;
3901 
3903  DstFileName);
3904  }
3905 
3906  SetupUpdateMemoryInfo(CopyContext, FALSE);
3907  break;
3908  }
3909 
3911  {
3912  FilePathInfo = (PFILEPATHS_W)Param1;
3913 
3914  DPRINT1("An error happened while trying to copy file '%S' (error 0x%08lx), skipping it...\n",
3915  FilePathInfo->Target, FilePathInfo->Win32Error);
3916  return FILEOP_SKIP;
3917  }
3918 
3921  case SPFILENOTIFY_ENDCOPY:
3922  {
3923  CopyContext->CompletedOperations++;
3924 
3925  /* SYSREG checkpoint */
3926  if (CopyContext->TotalOperations >> 1 == CopyContext->CompletedOperations)
3927  DPRINT1("CHECKPOINT:HALF_COPIED\n");
3928 
3929  ProgressNextStep(CopyContext->ProgressBar);
3930  SetupUpdateMemoryInfo(CopyContext, FALSE);
3931  break;
3932  }
3933  }
3934 
3935  return FILEOP_DOIT;
3936 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define TRUE
Definition: types.h:120
#define FILEOP_RENAME
Definition: fileqsup.h:43
ULONG TotalOperations
Definition: reactos.c:980
#define SPFILENOTIFY_ENDCOPY
Definition: fileqsup.h:36
UINT Win32Error
Definition: fileqsup.h:62
VOID ProgressNextStep(IN PPROGRESSBAR Bar)
Definition: progress.c:361
#define SPFILENOTIFY_STARTRENAME
Definition: fileqsup.h:31
#define SPFILENOTIFY_ENDRENAME
Definition: fileqsup.h:32
#define STRING_COPYING
Definition: mui.h:97
#define SPFILENOTIFY_STARTSUBQUEUE
Definition: fileqsup.h:24
VOID ProgressSetStepCount(IN PPROGRESSBAR Bar, IN ULONG StepCount)
Definition: progress.c:347
#define FILEOP_COPY
Definition: fileqsup.h:42
#define SPFILENOTIFY_ENDDELETE
Definition: fileqsup.h:28
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define SPFILENOTIFY_STARTCOPY
Definition: fileqsup.h:35
#define SPFILENOTIFY_STARTDELETE
Definition: fileqsup.h:27
#define STRING_RENAMING
Definition: mui.h:96
#define FILEOP_DOIT
Definition: fileqsup.h:48
#define SPFILENOTIFY_COPYERROR
Definition: fileqsup.h:37
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STRING_MOVING
Definition: mui.h:95
ULONG CompletedOperations
Definition: reactos.c:981
static const WCHAR L[]
Definition: oid.c:1250
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
PCWSTR Source
Definition: fileqsup.h:61
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
#define wcsicmp
Definition: string.h:1152
static VOID SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext, IN BOOLEAN First)
Definition: usetup.c:3804
#define FILEOP_SKIP
Definition: fileqsup.h:49
PCWSTR Target
Definition: fileqsup.h:60
#define DPRINT1
Definition: precomp.h:8
struct _COPYCONTEXT * PCOPYCONTEXT
unsigned int ULONG
Definition: retypes.h:1
struct _FILEPATHS_W * PFILEPATHS_W
#define STRING_DELETING
Definition: mui.h:94
PPROGRESSBAR ProgressBar
Definition: usetup.c:3799
#define FILEOP_DELETE
Definition: fileqsup.h:44

Referenced by FileCopyPage().

◆ FileCopyPage()

static PAGE_NUMBER FileCopyPage ( PINPUT_RECORD  Ir)
static

Definition at line 3952 of file usetup.c.

3953 {
3954  COPYCONTEXT CopyContext;
3955  UINT MemBarWidth;
3956 
3958 
3959  /* Create context for the copy process */
3960  CopyContext.TotalOperations = 0;
3961  CopyContext.CompletedOperations = 0;
3962 
3963  /* Create the progress bar as well */
3964  CopyContext.ProgressBar = CreateProgressBar(13,
3965  26,
3966  xScreen - 13,
3967  yScreen - 20,
3968  10,
3969  24,
3970  TRUE,
3972 
3973  // fit memory bars to screen width, distribute them uniform
3974  MemBarWidth = (xScreen - 26) / 5;
3975  MemBarWidth -= MemBarWidth % 2; // make even
3976  /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3977  /* Create the paged pool progress bar */
3978  CopyContext.MemoryBars[0] = CreateProgressBar(13,
3979  40,
3980  13 + MemBarWidth,
3981  43,
3982  13,
3983  44,
3984  FALSE,
3985  "Kernel Pool");
3986 
3987  /* Create the non paged pool progress bar */
3988  CopyContext.MemoryBars[1] = CreateProgressBar((xScreen / 2)- (MemBarWidth / 2),
3989  40,
3990  (xScreen / 2) + (MemBarWidth / 2),
3991  43,
3992  (xScreen / 2)- (MemBarWidth / 2),
3993  44,
3994  FALSE,
3995  "Kernel Cache");
3996 
3997  /* Create the global memory progress bar */
3998  CopyContext.MemoryBars[2] = CreateProgressBar(xScreen - 13 - MemBarWidth,
3999  40,
4000  xScreen - 13,
4001  43,
4002  xScreen - 13 - MemBarWidth,
4003  44,
4004  FALSE,
4005  "Free Memory");
4006 
4007  /* Do the file copying */
4008  DoFileCopy(&USetupData, FileCopyCallback, &CopyContext);
4009 
4010  /* If we get here, we're done, so cleanup the progress bar */
4011  DestroyProgressBar(CopyContext.ProgressBar);
4012  DestroyProgressBar(CopyContext.MemoryBars[0]);
4013  DestroyProgressBar(CopyContext.MemoryBars[1]);
4014  DestroyProgressBar(CopyContext.MemoryBars[2]);
4015 
4016  /* Create the $winnt$.inf file */
4018 
4019  /* Go display the next page */
4020  return REGISTRY_PAGE;
4021 }
static USETUP_DATA USetupData
Definition: usetup.c:46
#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:3800
ULONG CompletedOperations
Definition: reactos.c:981
static UINT CALLBACK FileCopyCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
Definition: usetup.c:3832
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:3799
#define STRING_SETUPCOPYINGFILES
Definition: mui.h:98

Referenced by RunUSetup().

◆ FlushPage()

static PAGE_NUMBER FlushPage ( PINPUT_RECORD  Ir)
static

Definition at line 4746 of file usetup.c.

4747 {
4749  return REBOOT_PAGE;
4750 }
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149

Referenced by RunUSetup().

◆ FormatPartitionPage()

static PAGE_NUMBER FormatPartitionPage ( PINPUT_RECORD  Ir)
static

Definition at line 3150 of file usetup.c.

3151 {
3152  NTSTATUS Status;
3153  PPARTENTRY PartEntry;
3154  PDISKENTRY DiskEntry;
3155  PFILE_SYSTEM_ITEM SelectedFileSystem;
3156  UNICODE_STRING PartitionRootPath;
3157  WCHAR PathBuffer[MAX_PATH];
3158  CHAR Buffer[MAX_PATH];
3159 
3160 #ifndef NDEBUG
3161  ULONG Line;
3162  ULONG i;
3164 #endif
3165 
3166  DPRINT("FormatPartitionPage()\n");
3167 
3169 
3170  if (PartitionList == NULL || TempPartition == NULL)
3171  {
3172  /* FIXME: show an error dialog */
3173  return QUIT_PAGE;
3174  }
3175 
3176  PartEntry = TempPartition;
3177  DiskEntry = TempPartition->DiskEntry;
3178 
3179  ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
3180 
3181  SelectedFileSystem = FileSystemList->Selected;
3182  ASSERT(SelectedFileSystem && SelectedFileSystem->FileSystem);
3183 
3184  while (TRUE)
3185  {
3186  if (!IsUnattendedSetup)
3187  CONSOLE_ConInKey(Ir);
3188 
3189  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3190  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
3191  {
3192  if (ConfirmQuit(Ir))
3193  {
3194  /* Reset the filesystem list */
3196  return QUIT_PAGE;
3197  }
3198 
3199  break;
3200  }
3201  else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN || IsUnattendedSetup) /* ENTER */
3202  {
3204 
3205  if (!PreparePartitionForFormatting(PartEntry, SelectedFileSystem->FileSystem))
3206  {
3207  /* FIXME: show an error dialog */
3208 
3209  /* Reset the filesystem list */
3211 
3212  return QUIT_PAGE;
3213  }
3214 
3215 #ifndef NDEBUG
3216  CONSOLE_PrintTextXY(6, 12,
3217  "Cylinders: %I64u Tracks/Cyl: %lu Sectors/Trk: %lu Bytes/Sec: %lu %c",
3218  DiskEntry->Cylinders,
3219  DiskEntry->TracksPerCylinder,
3220  DiskEntry->SectorsPerTrack,
3221  DiskEntry->BytesPerSector,
3222  DiskEntry->Dirty ? '*' : ' ');
3223 
3224  Line = 13;
3225 
3226  for (i = 0; i < DiskEntry->LayoutBuffer->PartitionCount; i++)
3227  {
3228  PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[i];
3229 
3231  "%2u: %2lu %c %12I64u %12I64u %02x",
3232  i,
3233  PartitionInfo->PartitionNumber,
3234  PartitionInfo->BootIndicator ? 'A' : '-',
3235  PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector,
3236  PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector,
3237  PartitionInfo->PartitionType);
3238  Line++;
3239  }
3240 #endif
3241 
3242  /* Commit the partition changes to the disk */
3243  Status = WritePartitions(DiskEntry);
3244  if (!NT_SUCCESS(Status))
3245  {
3246  DPRINT1("WritePartitions(disk %lu) failed, Status 0x%08lx\n",
3247  DiskEntry->DiskNumber, Status);
3248 
3250 
3251  /* Reset the filesystem list */
3253 
3254  return QUIT_PAGE;
3255  }
3256 
3257  /* Set PartitionRootPath */
3258  RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
3259  L"\\Device\\Harddisk%lu\\Partition%lu",
3260  DiskEntry->DiskNumber,
3261  PartEntry->PartitionNumber);
3262  RtlInitUnicodeString(&PartitionRootPath, PathBuffer);
3263  DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath);
3264 
3265  /* Format the partition */
3266  Status = FormatPartition(&PartitionRootPath,
3267  SelectedFileSystem->FileSystem,
3268  SelectedFileSystem->QuickFormat);
3270  {
3271  sprintf(Buffer,
3272  "Setup is currently unable to format a partition in %S.\n"
3273  "\n"
3274  " \x07 Press ENTER to continue Setup.\n"
3275  " \x07 Press F3 to quit Setup.",
3276  SelectedFileSystem->FileSystem);
3277 
3281 
3282  while (TRUE)
3283  {
3284  CONSOLE_ConInKey(Ir);
3285 
3286  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x00 &&
3287  Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3) /* F3 */
3288  {
3289  if (ConfirmQuit(Ir))
3290  {
3291  /* Reset the filesystem list */
3293  return QUIT_PAGE;
3294  }
3295  else
3296  {
3297  return SELECT_FILE_SYSTEM_PAGE;
3298  }
3299  }
3300  else if (Ir->Event.KeyEvent.uChar.AsciiChar == VK_RETURN) /* ENTER */
3301  {
3302  return SELECT_FILE_SYSTEM_PAGE;
3303  }
3304  }
3305  }
3306  else if (!NT_SUCCESS(Status))
3307  {
3308  DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status);
3310 
3311  /* Reset the filesystem list */
3313 
3314  return QUIT_PAGE;
3315  }
3316 
3317 //
3318 // TODO: Here, call a partlist.c function that update the actual FS name
3319 // and the label fields of the volume.
3320 //
3321  PartEntry->FormatState = Formatted;
3322  // PartEntry->FileSystem = FileSystem;
3323  PartEntry->New = FALSE;
3324 
3325 #ifndef NDEBUG
3326  CONSOLE_SetStatusText(" Done. Press any key ...");
3327  CONSOLE_ConInKey(Ir);
3328 #endif
3329 
3330  return SELECT_FILE_SYSTEM_PAGE;
3331  }
3332  }
3333 
3334  return FORMAT_PARTITION_PAGE;
3335 }
NTSTATUS FormatPartition(IN PUNICODE_STRING DriveRoot, IN PCWSTR FileSystemName, IN BOOLEAN QuickFormat)
Definition: format.c:89
ULONG PartitionNumber
Definition: partlist.h:49
#define TRUE
Definition: types.h:120
#define POPUP_WAIT_NONE
Definition: usetup.h:123
static VOID ResetFileSystemList(VOID)
Definition: usetup.c:2669
static PPARTENTRY TempPartition
Definition: usetup.c:74
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
char CHAR
Definition: xmlstorage.h:175
VOID __cdecl CONSOLE_PrintTextXY(IN SHORT x, IN SHORT y, IN LPCSTR fmt,...)
Definition: consup.c:599
LONG NTSTATUS
Definition: precomp.h:26
PCWSTR FileSystem
Definition: fslist.h:34
VOID PopupError(PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
Definition: usetup.c:195
ULONG DiskNumber
Definition: partlist.h:105
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static PFILE_SYSTEM_LIST FileSystemList
Definition: usetup.c:71
#define POPUP_WAIT_ANY_KEY
Definition: usetup.h:124
#define VK_RETURN
Definition: winuser.h:2155
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:55
BOOLEAN Dirty
Definition: partlist.h:112
smooth NULL
Definition: ftsmooth.c:416
PARTITION_INFORMATION PartitionEntry[1]
Definition: ntdddisk.h:467
PFILE_SYSTEM_ITEM Selected
Definition: fslist.h:42
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
static __inline NTSTATUS RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1064
union _INPUT_RECORD::@3145 Event
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
ULONG BytesPerSector
Definition: partlist.h:89
__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:65
#define VK_F3
Definition: winuser.h:2211
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ncftp.h:79
static const WCHAR L[]
Definition: oid.c:1250
ULONG SectorsPerTrack
Definition: partlist.h:88
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID __cdecl MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent,...)
Definition: mui.c:216
VOID __cdecl CONSOLE_SetStatusText(IN LPCSTR fmt,...)
Definition: consup.c:481
BOOLEAN QuickFormat
Definition: fslist.h:35
ULONGLONG Cylinders
Definition: partlist.h:86
BOOLEAN New
Definition: partlist.h:65
Status
Definition: gdiplustypes.h:24
#define POPUP_WAIT_ENTER
Definition: usetup.h:125
BOOLEAN IsUnattendedSetup
Definition: usetup.c:44
ULONG TracksPerCylinder
Definition: partlist.h:87
#define DPRINT1
Definition: precomp.h:8
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3665
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STRING_PLEASEWAIT
Definition: mui.h:74
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:119
BOOLEAN PreparePartitionForFormatting(IN struct _PARTENTRY *PartEntry, IN PCWSTR FileSystemName)
Definition: fsutil.c:536
struct Line Line
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
#define STRING_QUITCONTINUE
Definition: mui.h:92
BOOLEAN IsPartitioned
Definition: partlist.h:60

Referenced by RunUSetup().

◆ GetNTOSInstallationName()

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

Definition at line 441 of file usetup.c.

445 {
447  PPARTENTRY PartEntry = NtOsInstall->PartEntry;
448 
449  if (PartEntry && PartEntry->DriveLetter)
450  {
451  /* We have retrieved a partition that is mounted */
453  "%C:%S \"%S\"",
454  PartEntry->DriveLetter,
455  NtOsInstall->PathComponent,
456  NtOsInstall->InstallationName);
457  }
458  else
459  {
460  /* We failed somewhere, just show the NT path */
462  "%wZ \"%S\"",
463  &NtOsInstall->SystemNtPath,
464  NtOsInstall->InstallationName);
465  }
466 }
WCHAR DriveLetter
Definition: partlist.h:52
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
static __inline NTSTATUS RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1043
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 430 of file usetup.c.

434 {
437 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
Definition: progress.h:34
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
static __inline NTSTATUS RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1043
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 1257 of file usetup.c.

1260 {
1261  while (TRUE)
1262  {
1263  CONSOLE_ConInKey(Ir);
1264 
1265  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1266  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
1267  {
1268  ScrollDownGenericList(ListUi);
1269  }
1270  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1271  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
1272  {
1273  ScrollUpGenericList(ListUi);
1274  }
1275  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1276  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
1277  {
1278  ScrollPageDownGenericList(ListUi);
1279  }
1280  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1281  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
1282  {
1283  ScrollPageUpGenericList(ListUi);
1284  }
1285  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1286  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1287  {
1288  if (ConfirmQuit(Ir))
1289  return QUIT_PAGE;
1290  else
1291  RedrawGenericList(ListUi);
1292  }
1293  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1294  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
1295  {
1296  RestoreGenericListUiState(ListUi);
1297  return nextPage; // Use some "prevPage;" instead?
1298  }
1299  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1300  {
1301  return nextPage;
1302  }
1303  else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
1304  {
1305  /* a-z */
1307  }
1308  }
1309 }
#define TRUE
Definition: types.h:120
union _KEY_EVENT_RECORD::@3144 uChar
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:2181
#define VK_PRIOR
Definition: winuser.h:2174
#define VK_ESCAPE
Definition: winuser.h:2168
#define VK_NEXT
Definition: winuser.h:2175
WORD wVirtualKeyCode
Definition: wincon.h:227
VOID ScrollDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:376
#define VK_UP
Definition: winuser.h:2179
VOID ScrollPageUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:454
VOID ScrollPageDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:432
union _INPUT_RECORD::@3145 Event
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2211
VOID GenericListKeyPress(IN PGENERIC_LIST_UI ListUi, IN CHAR AsciiChar)
Definition: genlist.c:525
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
VOID ScrollUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:404
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

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

◆ InstallDirectoryPage()

static PAGE_NUMBER InstallDirectoryPage ( PINPUT_RECORD  Ir)
static

Definition at line 3533 of file usetup.c.

3534 {
3535  NTSTATUS Status;
3536  ULONG Length, Pos;
3537  WCHAR c;
3538  WCHAR InstallDir[MAX_PATH];
3539 
3540  /* We do not need the filesystem list anymore */
3542 
3543  if (PartitionList == NULL || InstallPartition == NULL)
3544  {
3545  /* FIXME: show an error dialog */
3546  return QUIT_PAGE;
3547  }
3548 
3549  // if (IsUnattendedSetup)
3550  if (RepairUpdateFlag)
3551  wcscpy(InstallDir, CurrentInstallation->PathComponent); // SystemNtPath
3552  else if (USetupData.InstallationDirectory[0])
3553  wcscpy(InstallDir, USetupData.InstallationDirectory);
3554  else
3555  wcscpy(InstallDir, L"\\ReactOS");
3556 
3557  /*
3558  * Check the validity of the predefined 'InstallDir'. If we are either
3559  * in unattended setup or in update/repair mode, and the installation path
3560  * is valid, just perform the installation. Otherwise (either in the case
3561  * of an invalid path, or we are in regular setup), display the UI and allow
3562  * the user to specify a new installation path.
3563  */
3564  if ((RepairUpdateFlag || IsUnattendedSetup) && IsValidPath(InstallDir))
3565  {
3566  Status = BuildInstallPaths(InstallDir, InstallPartition);
3567  if (!NT_SUCCESS(Status))
3568  {
3569  DPRINT1("BuildInstallPaths() failed. Status code: 0x%lx", Status);
3570  PopupError("Failed to build the installation paths for the ReactOS installation directory!",
3572  Ir, POPUP_WAIT_ENTER);
3573  return QUIT_PAGE;
3574  }
3575 
3576  /*
3577  * Check whether the user attempts to install ReactOS within the
3578  * installation source directory, or in a subdirectory thereof.
3579  * If so, fail with an error.
3580  */
3581  if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
3582  {
3583  PopupError("You cannot install ReactOS within the installation source directory!",
3585  Ir, POPUP_WAIT_ENTER);
3586  return INSTALL_DIRECTORY_PAGE;
3587  }
3588 
3589  return PREPARE_COPY_PAGE;
3590  }
3591 
3592  Length = wcslen(InstallDir);
3593  Pos = Length;
3594 
3596  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3597  CONSOLE_SetCursorXY(8 + Pos, 11);
3599 
3600  while (TRUE)
3601  {
3602  CONSOLE_ConInKey(Ir);
3603 
3604  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3605  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
3606  {
3608 
3609  if (ConfirmQuit(Ir))
3610  return QUIT_PAGE;
3611 
3613  break;
3614  }
3615  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3616  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DELETE)) /* DEL */
3617  {
3618  if (Pos < Length)
3619  {
3620  memmove(&InstallDir[Pos],
3621  &InstallDir[Pos + 1],
3622  (Length - Pos - 1) * sizeof(WCHAR));
3623  InstallDir[Length - 1] = UNICODE_NULL;
3624 
3625  Length--;
3626  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3627  CONSOLE_SetCursorXY(8 + Pos, 11);
3628  }
3629  }
3630  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3631  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_HOME)) /* HOME */
3632  {
3633  Pos = 0;
3634  CONSOLE_SetCursorXY(8 + Pos, 11);
3635  }
3636  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3637  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_END)) /* END */
3638  {
3639  Pos = Length;
3640  CONSOLE_SetCursorXY(8 + Pos, 11);
3641  }
3642  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3643  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_LEFT)) /* LEFT */
3644  {
3645  if (Pos > 0)
3646  {
3647  Pos--;
3648  CONSOLE_SetCursorXY(8 + Pos, 11);
3649  }
3650  }
3651  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
3652  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)) /* RIGHT */
3653  {
3654  if (Pos < Length)
3655  {
3656  Pos++;
3657  CONSOLE_SetCursorXY(8 + Pos, 11);
3658  }
3659  }
3660  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
3661  {
3663 
3664  /*
3665  * Check for the validity of the installation directory and pop up
3666  * an error if it is not the case. Then the user can fix its input.
3667  */
3668  if (!IsValidPath(InstallDir))
3669  {
3671  return INSTALL_DIRECTORY_PAGE;
3672  }
3673 
3674  Status = BuildInstallPaths(InstallDir, InstallPartition);
3675  if (!NT_SUCCESS(Status))
3676  {
3677  DPRINT1("BuildInstallPaths() failed. Status code: 0x%lx", Status);
3678  PopupError("Failed to build the installation paths for the ReactOS installation directory!",
3680  Ir, POPUP_WAIT_ENTER);
3681  return QUIT_PAGE;
3682  }
3683 
3684  /*
3685  * Check whether the user attempts to install ReactOS within the
3686  * installation source directory, or in a subdirectory thereof.
3687  * If so, fail with an error.
3688  */
3689  if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
3690  {
3691  PopupError("You cannot install ReactOS within the installation source directory!",
3693  Ir, POPUP_WAIT_ENTER);
3694  return INSTALL_DIRECTORY_PAGE;
3695  }
3696 
3697  return PREPARE_COPY_PAGE;
3698  }
3699  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
3700  {
3701  if (Pos > 0)
3702  {
3703  if (Pos < Length)
3704  memmove(&InstallDir[Pos - 1],
3705  &InstallDir[Pos],
3706  (Length - Pos) * sizeof(WCHAR));
3707  InstallDir[Length - 1] = UNICODE_NULL;
3708 
3709  Pos--;
3710  Length--;
3711  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3712  CONSOLE_SetCursorXY(8 + Pos, 11);
3713  }
3714  }
3715  else if (isprint(Ir->Event.KeyEvent.uChar.AsciiChar))
3716  {
3717  if (Length < 50)
3718  {
3720  if (iswalpha(c) || iswdigit(c) || c == '.' || c == '\\' || c == '-' || c == '_')
3721  {
3722  if (Pos < Length)
3723  memmove(&InstallDir[Pos + 1],
3724  &InstallDir[Pos],
3725  (Length - Pos) * sizeof(WCHAR));
3726  InstallDir[Length + 1] = UNICODE_NULL;
3727  InstallDir[Pos] = c;
3728 
3729  Pos++;
3730  Length++;
3731  CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
3732  CONSOLE_SetCursorXY(8 + Pos, 11);
3733  }
3734  }
3735  }
3736  }
3737 
3738  return INSTALL_DIRECTORY_PAGE;
3739 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static USETUP_DATA USetupData
Definition: usetup.c:46
#define TRUE
Definition: types.h:120
static VOID ResetFileSystemList(VOID)
Definition: usetup.c:2669
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
#define iswdigit(_c)
Definition: ctype.h:667
LONG NTSTATUS
Definition: precomp.h:26
static PPARTENTRY InstallPartition
Definition: usetup.c:49
ush Pos
Definition: deflate.h:92
VOID PopupError(PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
Definition: usetup.c:195
#define VK_LEFT
Definition: winuser.h:2178
#define iswalpha(_c)
Definition: ctype.h:664
VOID CONSOLE_SetInputTextXY(IN SHORT x, IN SHORT y, IN SHORT len, IN LPCWSTR Text)
Definition: consup.c:344
WORD wVirtualKeyCode
Definition: wincon.h:227
static BOOLEAN IsValidPath(IN PCWSTR InstallDir)
Definition: usetup.c:3477
#define VK_HOME
Definition: winuser.h:2177
#define UNICODE_NULL
VOID CONSOLE_SetCursorType(IN BOOL bInsert, IN BOOL bVisible)
Definition: consup.c:210
smooth NULL
Definition: ftsmooth.c:416
static NTSTATUS BuildInstallPaths(IN PCWSTR InstallDir, IN PPARTENTRY PartEntry)
Definition: usetup.c:3455
union _INPUT_RECORD::@3145 Event
#define VK_DELETE
Definition: winuser.h:2187
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:65
#define VK_F3
Definition: winuser.h:2211
_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:368
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
#define STRING_CONTINUE
Definition: mui.h:91
Status
Definition: gdiplustypes.h:24
#define VK_RIGHT
Definition: winuser.h:2180
#define POPUP_WAIT_ENTER
Definition: usetup.h:125
PCWSTR PathComponent
Definition: osdetect.h:22
BOOLEAN IsUnattendedSetup
Definition: usetup.c:44
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:62
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
static PNTOS_INSTALLATION CurrentInstallation
Definition: usetup.c:79
#define VK_END
Definition: winuser.h:2176
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 989 of file usetup.c.

990 {
991  if (RepairUpdateFlag)
992  {
993 #if 1 /* Old code that looks good */
994 
995  // return SELECT_PARTITION_PAGE;
996  return DEVICE_SETTINGS_PAGE;
997 
998 #else /* Possible new code? */
999 
1000  return DEVICE_SETTINGS_PAGE;
1001  // return SCSI_CONTROLLER_PAGE;
1002 
1003 #endif
1004  }
1005 
1006  if (IsUnattendedSetup)
1007  return SELECT_PARTITION_PAGE;
1008 
1010 
1011  while (TRUE)
1012  {
1013  CONSOLE_ConInKey(Ir);
1014 
1015  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1016  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1017  {
1018  if (ConfirmQuit(Ir))
1019  return QUIT_PAGE;
1020 
1021  break;
1022  }
1023  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1024  {
1025  return UPGRADE_REPAIR_PAGE;
1026  }
1027  }
1028 
1029  return INSTALL_INTRO_PAGE;
1030 }
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
WORD wVirtualKeyCode
Definition: wincon.h:227
union _INPUT_RECORD::@3145 Event
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2211
static BOOL ConfirmQuit(PINPUT_RECORD Ir)
Definition: usetup.c:368
BOOLEAN IsUnattendedSetup
Definition: usetup.c:44
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:62
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ IsDiskSizeValid()

static BOOL IsDiskSizeValid ( PPARTENTRY  PartEntry)
static

Definition at line 1417 of file usetup.c.

1418 {
1419  ULONGLONG size;
1420 
1421  size = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
1422  size = (size + (512 * KB)) / MB; /* in MBytes */
1423 
1424  if (size < USetupData.RequiredPartitionDiskSpace)
1425  {
1426  /* Partition is too small so ask for another one */
1427  DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size, USetupData.RequiredPartitionDiskSpace);
1428  return FALSE;
1429  }
1430  else
1431  {
1432  return TRUE;
1433  }
1434 }
static USETUP_DATA USetupData
Definition: usetup.c:46
#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 3477 of file usetup.c.

3479 {
3480  UINT i, Length;
3481 
3482  Length = wcslen(InstallDir);
3483 
3484  // TODO: Add check for 8.3 too.
3485 
3486  /* Path must be at least 2 characters long */
3487 // if (Length < 2)
3488 // return FALSE;
3489 
3490  /* Path must start with a backslash */
3491 // if (InstallDir[0] != L'\\')
3492 // return FALSE;
3493 
3494  /* Path must not end with a backslash */
3495  if (InstallDir[Length - 1] == L'\\')
3496  return FALSE;
3497 
3498  /* Path must not contain whitespace characters */
3499  for (i = 0; i < Length; i++)
3500  {
3501  if (iswspace(InstallDir[i]))
3502  return FALSE;
3503  }
3504 
3505  /* Path component must not end with a dot */
3506  for (i = 0; i < Length; i++)
3507  {
3508  if (InstallDir[i] == L'\\' && i > 0)
3509  {
3510  if (InstallDir[i - 1] == L'.')
3511  return FALSE;
3512  }
3513  }
3514 
3515  if (InstallDir[Length - 1] == L'.')
3516  return FALSE;
3517 
3518  return TRUE;
3519 }
#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 1375 of file usetup.c.

1376 {
1377  GENERIC_LIST_UI ListUi;
1379 
1380  InitGenericListUi(&ListUi, USetupData.KeyboardList, GetSettingDescription);
1381  DrawGenericList(&ListUi,
1382  2, 18,
1383  xScreen - 3,
1384  yScreen - 3);
1385 
1386  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1387 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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:1257
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:430

Referenced by RunUSetup().

◆ LanguagePage()

static PAGE_NUMBER LanguagePage ( PINPUT_RECORD  Ir)
static

Definition at line 482 of file usetup.c.

483 {
484  GENERIC_LIST_UI ListUi;
485  PCWSTR NewLanguageId;
486  BOOL RefreshPage = FALSE;
487 
488  /* Initialize the computer settings list */
489  if (USetupData.LanguageList == NULL)
490  {
491  USetupData.LanguageList = CreateLanguageList(USetupData.SetupInf, DefaultLanguage);
492  if (USetupData.LanguageList == NULL)
493  {
494  PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE);
495  return WELCOME_PAGE;
496  }
497  }
498 
500  USetupData.LanguageId = 0;
501 
502  /* Load the font */
504  UpdateKBLayout();
505 
506  /*
507  * If there is no language or just a single one in the list,
508  * skip the language selection process altogether.
509  */
510  if (GetNumberOfListEntries(USetupData.LanguageList) <= 1)
511  {
512  USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
513  return WELCOME_PAGE;
514  }
515 
516  InitGenericListUi(&ListUi, USetupData.LanguageList, GetSettingDescription);
517  DrawGenericList(&ListUi,
518  2, 18,
519  xScreen - 3,
520  yScreen - 3);
521 
523 
525 
526  while (TRUE)
527  {
528  CONSOLE_ConInKey(Ir);
529 
530  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
531  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
532  {
533  ScrollDownGenericList(&ListUi);
534  RefreshPage = TRUE;
535  }
536  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
537  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
538  {
539  ScrollUpGenericList(&ListUi);
540  RefreshPage = TRUE;
541  }
542  if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
543  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
544  {
545  ScrollPageDownGenericList(&ListUi);
546  RefreshPage = TRUE;
547  }
548  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
549  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
550  {
551  ScrollPageUpGenericList(&ListUi);
552  RefreshPage = TRUE;
553  }
554  else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
555  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
556  {
557  if (ConfirmQuit(Ir))
558  return QUIT_PAGE;
559  else
560  RedrawGenericList(&ListUi);
561  }
562  else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
563  {
564  ASSERT(GetNumberOfListEntries(USetupData.LanguageList) >= 1);
565 
568 
569  USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
570 
572  {
573  UpdateKBLayout();
574  }
575 
576  /* Load the font */
578 
579  return WELCOME_PAGE;
580  }
581  else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
582  {
583  /* a-z */
585  RefreshPage = TRUE;
586  }
587 
588  if (RefreshPage)
589  {
590  ASSERT(GetNumberOfListEntries(USetupData.LanguageList) >= 1);
591 
592  NewLanguageId =
594 
595  if (wcscmp(SelectedLanguageId, NewLanguageId))
596  {
597  /* Clear the language page */
599 
600  SelectedLanguageId = NewLanguageId;
601 
602  /* Load the font */
604 
605  /* Redraw language selection page in native language */
607  }
608 
609  RefreshPage = FALSE;
610  }
611  }
612 
613  return WELCOME_PAGE;
614 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
static USETUP_DATA USetupData
Definition: usetup.c:46
#define TRUE
Definition: types.h:120
ULONG GetNumberOfListEntries(IN PGENERIC_LIST List)
Definition: genlist.c:140
#define POPUP_WAIT_NONE
Definition: usetup.h:123
SHORT xScreen
Definition: consup.c:39
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
VOID PopupError(PCCH Text, PCCH Status, PINPUT_RECORD Ir, ULONG WaitEvent)
Definition: usetup.c:195
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:1134
VOID RedrawGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:511
WORD LANGID
Definition: typedefs.h:79
#define VK_DOWN
Definition: winuser.h:2181
#define VK_PRIOR
Definition: winuser.h:2174
_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:2175
WORD wVirtualKeyCode
Definition: wincon.h:227
VOID ScrollDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:376
static VOID UpdateKBLayout(VOID)
Definition: usetup.c:395
#define VK_UP
Definition: winuser.h:2179
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
VOID ScrollPageUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:454
VOID ScrollPageDownGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:432
smooth NULL
Definition: ftsmooth.c:416
union _INPUT_RECORD::@3145 Event
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:58
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
#define VK_F3
Definition: winuser.h:2211
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:368
ULONG GetDefaultLanguageIndex(VOID)
Definition: settings.c:1073
SHORT yScreen
Definition: consup.c:40
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct _GENENTRY * PGENENTRY
static WCHAR DefaultLanguage[20]
Definition: usetup.c:59
VOID ScrollUpGenericList(IN PGENERIC_LIST_UI ListUi)
Definition: genlist.c:404
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62
VOID SetConsoleCodePage(VOID)
Definition: mui.c:260
static NTSTATUS NTAPI GetSettingDescription(IN PGENERIC_LIST_ENTRY Entry, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:430

Referenced by RunUSetup().

◆ LayoutSettingsPage()

static PAGE_NUMBER LayoutSettingsPage ( PINPUT_RECORD  Ir)
static

Definition at line 1401 of file usetup.c.

1402 {
1403  GENERIC_LIST_UI ListUi;
1405 
1406  InitGenericListUi(&ListUi, USetupData.LayoutList, GetSettingDescription);
1407  DrawGenericList(&ListUi,
1408  2, 18,
1409  xScreen - 3,
1410  yScreen - 3);
1411 
1412  return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
1413 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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:1257
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:430

Referenced by RunUSetup().

◆ LicensePage()

static PAGE_NUMBER LicensePage ( PINPUT_RECORD  Ir)
static

Definition at line 778 of file usetup.c.

779 {
781 
782  while (TRUE)
783  {
784  CONSOLE_ConInKey(Ir);
785 
786  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
787  {
788  return WELCOME_PAGE;
789  }
790  }
791 
792  return LICENSE_PAGE;
793 }
#define TRUE
Definition: types.h:120
VOID MUIDisplayPage(IN ULONG page)
Definition: mui.c:149
union _KEY_EVENT_RECORD::@3144 uChar
union _INPUT_RECORD::@3145 Event
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
VOID CONSOLE_ConInKey(OUT PINPUT_RECORD Buffer)
Definition: consup.c:62

Referenced by RunUSetup().

◆ NtProcessStartup()

VOID NTAPI NtProcessStartup ( PPEB  Peb)

Definition at line 4979 of file usetup.c.

4980 {
4981  NTSTATUS Status;
4983 
4985 
4987 
4989 
4990  Status = RunUSetup();
4991 
4992  if (NT_SUCCESS(Status))
4993  {
4994  /*
4995  * Avoid a bugcheck if RunUSetup() finishes too quickly by implementing
4996  * a protective waiting.
4997  * This wait is needed because, since we are started as SMSS.EXE,
4998  * the NT kernel explicitly waits 5 seconds for the initial process
4999  * SMSS.EXE to initialize (as a protective measure), and otherwise
5000  * bugchecks with the code SESSION5_INITIALIZATION_FAILED.
5001  */
5002  Time.QuadPart += 50000000;
5004  }
5005  else
5006  {
5007  /* The installer failed to start: raise a hard error (crash the system/BSOD) */
5009  0, 0, NULL, 0, NULL);
5010  }
5011 
5013 }
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:4757
NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlNormalizeProcessParams(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
smooth NULL
Definition: ftsmooth.c:416
HANDLE ProcessHeap
Definition: usetup.c:43
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:1851
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 195 of file usetup.c.

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

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

◆ PrepareCopyPage()

static PAGE_NUMBER PrepareCopyPage ( PINPUT_RECORD  Ir)
static

Definition at line 3778 of file usetup.c.

3779 {
3780  // ERROR_NUMBER ErrorNumber;
3781  BOOLEAN Success;
3782 
3784 
3785  /* ErrorNumber = */ Success = PrepareFileCopy(&USetupData, NULL);
3786  if (/*ErrorNumber != ERROR_SUCCESS*/ !Success)
3787  {
3788  // MUIDisplayError(ErrorNumber, Ir, POPUP_WAIT_ENTER);
3789  return QUIT_PAGE;
3790  }
3791 
3792  return FILE_COPY_PAGE;
3793 }
static USETUP_DATA USetupData
Definition: usetup.c:46
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 86 of file usetup.c.

87 {
88  char buffer[512];
89  va_list ap;
92 
93  va_start(ap, fmt);
94  vsprintf(buffer, fmt, ap);
95  va_end(ap);
96 
101 }
#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 4540 of file usetup.c.

4543 {
4544  NTSTATUS Status;
4545  ULONG StartTime, BarWidth, TimerDiv;
4546  LONG TimeElapsed;
4547  LONG TimerValue, OldTimerValue;
4549  PPROGRESSBAR ProgressBar;
4550  BOOLEAN RefreshProgress = TRUE;
4551 
4552  /* Bail out if the timeout is already zero */
4553  if (TimeOut <= 0)
4554  return;
4555 
4556  /* Create the timeout progress bar and set it up */
4557  ProgressBar = CreateProgressBarEx(13,
4558  26,
4559  xScreen - 13,
4560  yScreen - 20,
4561  10,
4562  24,
4563  TRUE,
4565  0,
4566  NULL,
4569 
4570  BarWidth = max(1, ProgressBar->Width);
4571  TimerValue = TimeOut * BarWidth;
4572  ProgressSetStepCount(ProgressBar, TimerValue);
4573 
4575  CONSOLE_Flush();
4576 
4577  TimerDiv = 1000 / BarWidth;
4578  TimerDiv = max(1, TimerDiv);
4579  OldTimerValue = TimerValue;
4580  while (TRUE)
4581  {
4582  /* Decrease the timer */
4583 
4584  /*
4585  * Compute how much time the previous operations took.
4586  * This allows us in particular to take account for any time
4587  * elapsed if something slowed down.
4588  */
4589  TimeElapsed = NtGetTickCount() - StartTime;
4590  if (TimeElapsed >= TimerDiv)
4591  {
4592  /* Increase StartTime by steps of 1 / ProgressBar->Width seconds */
4593  TimeElapsed /= TimerDiv;
4594  StartTime += (TimerDiv * TimeElapsed);
4595 
4596  if (TimeElapsed <= TimerValue)
4597  TimerValue -= TimeElapsed;
4598  else
4599  TimerValue = 0;
4600 
4601  RefreshProgress = TRUE;
4602  }
4603 
4604  if (RefreshProgress)
4605  {
4606  ProgressSetStep(ProgressBar, OldTimerValue - TimerValue);
4607  RefreshProgress = FALSE;
4608  }
4609 
4610  /* Stop when the timer reaches zero */
4611  if (TimerValue <= 0)
4612  break;
4613 
4614  /* Check for user key presses */
4615 
4616  /*
4617  * If the timer is used, use a passive wait of maximum 1 second
4618  * while monitoring for incoming console input events, so that
4619  * we are still able to display the timing count.
4620  */
4621 
4622  /* Wait a maximum of 1 second for input events */
4623  TimeElapsed = NtGetTickCount() - StartTime;
4624  if (TimeElapsed < TimerDiv)
4625  {
4626  /* Convert the time to NT Format */
4627  Timeout.QuadPart = (TimerDiv - TimeElapsed) * -10000LL;
4629  }
4630  else
4631  {
4633  }
4634 
4635  /* Check whether the input event has been signaled, or a timeout happened */
4636  if (Status == STATUS_TIMEOUT)
4637  {
4638  continue;
4639  }
4640  if (Status != STATUS_WAIT_0)
4641  {
4642  /* An error happened, bail out */
4643  DPRINT1("NtWaitForSingleObject() failed, Status 0x%08lx\n", Status);
4644  break;
4645  }
4646 
4647  /* Check for an ENTER key press */
4648  while (CONSOLE_ConInKeyPeek(Ir))
4649  {
4650  if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
4651  {
4652  /* Found it, stop waiting */
4653  goto Exit;
4654  }
4655  }
4656  }
4657 
4658 Exit:
4659  /* Destroy the progress bar and quit */
4660  DestroyProgressBar(ProgressBar);
4661 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define LL
Definition: tui.h:72
SHORT xScreen
Definition: consup.c:39
#define STRING_REBOOTPROGRESSBAR
Definition: mui.h:137
PPROGRESSBAR CreateProgressBarEx(IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN SHORT ProgressColour, IN ULONG StepCount, IN PCSTR DescriptionText OPTIONAL, IN PCSTR ProgressFormatText OPTIONAL, IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
Definition: progress.c:272
LONG NTSTATUS
Definition: precomp.h:26
HANDLE StdInput
Definition: consup.c:36
VOID ProgressSetStep(IN PPROGRESSBAR Bar, IN ULONG Step)
Definition: progress.c:368
VOID DestroyProgressBar(IN OUT PPROGRESSBAR Bar)
Definition: progress.c:339
static LARGE_INTEGER StartTime
Definition: sys_arch.c:18
BOOL CONSOLE_Flush(VOID)
Definition: consup.c:171
#define NtGetTickCount
Definition: rtlp.h:146
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_WAIT_0
Definition: ntstatus.h:223
VOID ProgressSetStepCount(IN PPROGRESSBAR Bar, IN ULONG StepCount)
Definition: progress.c:347
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CONSOLE_ConInKeyPeek(OUT PINPUT_RECORD Buffer)
Definition: consup.c:81
SHORT Width
Definition: progress.h:48
static BOOLEAN NTAPI ProgressTimeOutStringHandler(IN PPROGRESSBAR Bar, IN BOOLEAN AlwaysUpdate, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: usetup.c:4493
static void Exit(void)
Definition: sock.c:1331
LPSTR MUIGetString(ULONG Number)
Definition: mui.c:230
SHORT yScreen
Definition: consup.c:40
#define BACKGROUND_BLUE
Definition: wincon.h:43
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
#define FOREGROUND_RED
Definition: wincon.h:41
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by QuitPage(), and SuccessPage().

◆ ProgressTimeOutStringHandler()

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

Definition at line 4493 of file usetup.c.

4498 {
4499  ULONG OldProgress = Bar->Progress;
4500 
4501  if (Bar->StepCount == 0)
4502  {
4503  Bar->Progress = 0;
4504  }
4505  else
4506  {
4507  Bar->Progress = Bar->StepCount - Bar->CurrentStep;
4508  }
4509 
4510  /* Build the progress string if it has changed */
4511  if (Bar->ProgressFormatText &&
4512  (AlwaysUpdate || (Bar->Progress != OldProgress)))
4513  {
4515  Bar->ProgressFormatText, Bar->Progress / max(1, Bar->Width) + 1);
4516 
4517  return TRUE;
4518  }
4519 
4520  return FALSE;
4521 }
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
static __inline NTSTATUS RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1043
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 4677 of file usetup.c.

4678 {
4680 
4681  /* Destroy the NTOS installations list */
4682  if (NtOsInstallsList != NULL)
4683  {
4686  }
4687 
4688  /* Destroy the partition list */
4689  if (PartitionList != NULL)
4690  {
4692  PartitionList = NULL;
4693  }
4694 
4695  /* Reset the formatter machine state */
4696  TempPartition = N