#define NDEBUG
#include <debug.h>
+
/* GLOBALS ******************************************************************/
HANDLE ProcessHeap;
WCHAR DefaultKBLayout[20];
BOOLEAN RepairUpdateFlag = FALSE;
HANDLE hPnpThread = INVALID_HANDLE_VALUE;
+PPARTLIST PartitionList = NULL;
/* LOCALS *******************************************************************/
-static PPARTLIST PartitionList = NULL;
-
static PFILE_SYSTEM_LIST FileSystemList = NULL;
static UNICODE_STRING InstallPath;
static PGENERIC_LIST LayoutList = NULL;
static PGENERIC_LIST LanguageList = NULL;
+static LANGID LanguageId = 0;
+
+static ULONG RequiredPartitionDiskSpace = ~0;
+
/* FUNCTIONS ****************************************************************/
static VOID
static VOID
-DrawBox(
- IN SHORT xLeft,
- IN SHORT yTop,
- IN SHORT Width,
- IN SHORT Height)
+DrawBox(IN SHORT xLeft,
+ IN SHORT yTop,
+ IN SHORT Width,
+ IN SHORT Height)
{
COORD coPos;
DWORD Written;
/* draw upper left corner */
coPos.X = xLeft;
coPos.Y = yTop;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xDA, // '+',
- 1,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xDA, // '+',
+ 1,
+ coPos,
+ &Written);
/* draw upper edge */
coPos.X = xLeft + 1;
coPos.Y = yTop;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xC4, // '-',
- Width - 2,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xC4, // '-',
+ Width - 2,
+ coPos,
+ &Written);
/* draw upper right corner */
coPos.X = xLeft + Width - 1;
coPos.Y = yTop;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xBF, // '+',
- 1,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xBF, // '+',
+ 1,
+ coPos,
+ &Written);
/* Draw right edge, inner space and left edge */
for (coPos.Y = yTop + 1; coPos.Y < yTop + Height - 1; coPos.Y++)
{
coPos.X = xLeft;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xB3, // '|',
- 1,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xB3, // '|',
+ 1,
+ coPos,
+ &Written);
coPos.X = xLeft + 1;
- FillConsoleOutputCharacterA(
- StdOutput,
- ' ',
- Width - 2,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ ' ',
+ Width - 2,
+ coPos,
+ &Written);
coPos.X = xLeft + Width - 1;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xB3, // '|',
- 1,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xB3, // '|',
+ 1,
+ coPos,
+ &Written);
}
/* draw lower left corner */
coPos.X = xLeft;
coPos.Y = yTop + Height - 1;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xC0, // '+',
- 1,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xC0, // '+',
+ 1,
+ coPos,
+ &Written);
/* draw lower edge */
coPos.X = xLeft + 1;
coPos.Y = yTop + Height - 1;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xC4, // '-',
- Width - 2,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xC4, // '-',
+ Width - 2,
+ coPos,
+ &Written);
/* draw lower right corner */
coPos.X = xLeft + Width - 1;
coPos.Y = yTop + Height - 1;
- FillConsoleOutputCharacterA(
- StdOutput,
- 0xD9, // '+',
- 1,
- coPos,
- &Written);
+ FillConsoleOutputCharacterA(StdOutput,
+ 0xD9, // '+',
+ 1,
+ coPos,
+ &Written);
}
+
VOID
PopupError(PCCH Text,
- PCCH Status,
- PINPUT_RECORD Ir,
- ULONG WaitEvent)
+ PCCH Status,
+ PINPUT_RECORD Ir,
+ ULONG WaitEvent)
{
SHORT yTop;
SHORT xLeft;
BOOL Result = FALSE;
MUIDisplayError(ERROR_NOT_INSTALLED, NULL, POPUP_WAIT_NONE);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
UnattendInf = SetupOpenInfFileW(UnattendInfPath,
NULL,
INF_STYLE_WIN4,
+ LanguageId,
&ErrorLine);
if (UnattendInf == INVALID_HANDLE_VALUE)
}
}
- /* search for LocaleID in the 'Unattend' section*/
- if (SetupFindFirstLineW (UnattendInf, L"Unattend", L"LocaleID", &Context)){
- if (INF_GetData (&Context, NULL, &Value)){
- LONG Id = wcstol(Value, NULL, 16);
- swprintf(LocaleID,L"%08lx", Id);
- }
+ /* search for LocaleID in the 'Unattend' section*/
+ if (SetupFindFirstLineW (UnattendInf, L"Unattend", L"LocaleID", &Context))
+ {
+ if (INF_GetData (&Context, NULL, &Value))
+ {
+ LONG Id = wcstol(Value, NULL, 16);
+ swprintf(LocaleID,L"%08lx", Id);
+ }
}
- SetupCloseInfFile(UnattendInf);
-
+ SetupCloseInfFile(UnattendInf);
+
DPRINT("Running unattended setup\n");
}
+
VOID
UpdateKBLayout(VOID)
{
}
}
+
static PAGE_NUMBER
LanguagePage(PINPUT_RECORD Ir)
{
MUIDisplayPage(LANGUAGE_PAGE);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
MUIDisplayPage(LANGUAGE_PAGE);
#endif
- ScrollUpGenericList (LanguageList);
+ ScrollUpGenericList(LanguageList);
}
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
{
- ScrollPageDownGenericList (LanguageList);
+ ScrollPageDownGenericList(LanguageList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
{
- ScrollPageUpGenericList (LanguageList);
+ ScrollPageUpGenericList(LanguageList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
SelectedLanguageId = (PWCHAR)GetListEntryUserData(GetCurrentListEntry(LanguageList));
+ LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
+
if (wcscmp(SelectedLanguageId, DefaultLanguage))
{
UpdateKBLayout();
UINT ErrorLine;
ULONG ReturnSize;
PGENERIC_LIST_ENTRY ListEntry;
+ INT IntValue;
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
/* Check whether a harddisk is available */
- Status = NtQuerySystemInformation (SystemDeviceInformation,
- &Sdi,
- sizeof(SYSTEM_DEVICE_INFORMATION),
- &ReturnSize);
+ Status = NtQuerySystemInformation(SystemDeviceInformation,
+ &Sdi,
+ sizeof(SYSTEM_DEVICE_INFORMATION),
+ &ReturnSize);
- if (!NT_SUCCESS (Status))
+ if (!NT_SUCCESS(Status))
{
CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status);
MUIDisplayError(ERROR_DRIVE_INFORMATION, Ir, POPUP_WAIT_ENTER);
SetupInf = SetupOpenInfFileW(FileNameBuffer,
NULL,
INF_STYLE_WIN4,
+ LanguageId,
&ErrorLine);
if (SetupInf == INVALID_HANDLE_VALUE)
}
/* Open 'Version' section */
- if (!SetupFindFirstLineW (SetupInf, L"Version", L"Signature", &Context))
+ if (!SetupFindFirstLineW(SetupInf, L"Version", L"Signature", &Context))
{
MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
/* Get pointer 'Signature' key */
- if (!INF_GetData (&Context, NULL, &Value))
+ if (!INF_GetData(&Context, NULL, &Value))
{
MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
return QUIT_PAGE;
}
+ /* Open 'DiskSpaceRequirements' section */
+ if (!SetupFindFirstLineW(SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context))
+ {
+ MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
+
+ /* Get the 'FreeSysPartDiskSpace' value */
+ if (!SetupGetIntField(&Context, 1, &IntValue))
+ {
+ MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
+
+ RequiredPartitionDiskSpace = (ULONG)IntValue;
+
/* Start PnP thread */
if (hPnpThread != INVALID_HANDLE_VALUE)
{
KeyboardList = CreateKeyboardDriverList(SetupInf);
LayoutList = CreateKeyboardLayoutList(SetupInf, DefaultKBLayout);
LanguageList = CreateLanguageList(SetupInf, DefaultLanguage);
-
- /* new part */
-
- wcscpy(SelectedLanguageId,LocaleID);
-
-
- /* first we hack LanguageList */
- ListEntry = GetFirstListEntry(LanguageList);
-
- while (ListEntry != NULL)
- {
- if (!wcscmp(LocaleID, GetListEntryUserData(ListEntry)))
- {
- DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry));
- SetCurrentListEntry(LanguageList, ListEntry);
- break;
- }
-
- ListEntry = GetNextListEntry(ListEntry);
- }
- /* now LayoutList */
- ListEntry = GetFirstListEntry(LayoutList);
-
- while (ListEntry != NULL)
- {
- if (!wcscmp(LocaleID, GetListEntryUserData(ListEntry)))
- {
- DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry));
- SetCurrentListEntry(LayoutList, ListEntry);
- break;
- }
-
- ListEntry = GetNextListEntry(ListEntry);
- }
- SetConsoleCodePage();
-
- return INSTALL_INTRO_PAGE;
+
+ /* new part */
+ wcscpy(SelectedLanguageId,LocaleID);
+
+ /* first we hack LanguageList */
+ ListEntry = GetFirstListEntry(LanguageList);
+
+ while (ListEntry != NULL)
+ {
+ if (!wcsicmp(LocaleID, GetListEntryUserData(ListEntry)))
+ {
+ DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry));
+ SetCurrentListEntry(LanguageList, ListEntry);
+ break;
+ }
+
+ ListEntry = GetNextListEntry(ListEntry);
+ }
+
+ /* now LayoutList */
+ ListEntry = GetFirstListEntry(LayoutList);
+
+ while (ListEntry != NULL)
+ {
+ if (!wcsicmp(LocaleID, GetListEntryUserData(ListEntry)))
+ {
+ DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry));
+ SetCurrentListEntry(LayoutList, ListEntry);
+ break;
+ }
+
+ ListEntry = GetNextListEntry(ListEntry);
+ }
+
+ SetConsoleCodePage();
+
+ return INSTALL_INTRO_PAGE;
}
return LANGUAGE_PAGE;
return INTRO_PAGE;
}
+
/*
* License Page
* RETURNS
return LICENSE_PAGE;
}
+
static PAGE_NUMBER
RepairIntroPage(PINPUT_RECORD Ir)
{
return SELECT_PARTITION_PAGE;
}
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
SetStatusText(" ENTER = Continue F3 = Quit");
- while(TRUE)
+ while (TRUE)
{
ConInKey(Ir);
return SELECT_PARTITION_PAGE;
}
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
SaveGenericListState(ComputerList);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
- ScrollDownGenericList (ComputerList);
+ ScrollDownGenericList(ComputerList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
- ScrollUpGenericList (ComputerList);
+ ScrollUpGenericList(ComputerList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
SaveGenericListState(DisplayList);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
- ScrollDownGenericList (DisplayList);
+ ScrollDownGenericList(DisplayList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
- ScrollUpGenericList (DisplayList);
+ ScrollUpGenericList(DisplayList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
SaveGenericListState(KeyboardList);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
- ScrollDownGenericList (KeyboardList);
+ ScrollDownGenericList(KeyboardList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
- ScrollUpGenericList (KeyboardList);
+ ScrollUpGenericList(KeyboardList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
SaveGenericListState(LayoutList);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
- ScrollDownGenericList (LayoutList);
+ ScrollDownGenericList(LayoutList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
- ScrollUpGenericList (LayoutList);
+ ScrollUpGenericList(LayoutList);
}
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
{
- ScrollPageDownGenericList (LayoutList);
+ ScrollPageDownGenericList(LayoutList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
{
- ScrollPageUpGenericList (LayoutList);
+ ScrollPageUpGenericList(LayoutList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
{
/* a-z */
- GenericListKeyPress (LayoutList , Ir->Event.KeyEvent.uChar.AsciiChar);
+ GenericListKeyPress(LayoutList , Ir->Event.KeyEvent.uChar.AsciiChar);
}
}
}
+static BOOL
+IsDiskSizeValid(PPARTENTRY PartEntry)
+{
+ ULONGLONG m1, m2;
+
+ /* check for unpartitioned space */
+ m1 = PartEntry->UnpartitionedLength;
+ m1 = (m1 + (1 << 19)) >> 20; /* in MBytes (rounded) */
+
+ if( m1 > RequiredPartitionDiskSpace)
+ {
+ return TRUE;
+ }
+
+ /* check for partitioned space */
+ m2 = PartEntry->PartInfo[0].PartitionLength.QuadPart;
+ m2 = (m2 + (1 << 19)) >> 20; /* in MBytes (rounded) */
+ if (m2 < RequiredPartitionDiskSpace)
+ {
+ /* partition is too small so ask for another partion */
+ DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1, m2, RequiredPartitionDiskSpace);
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
+
+
static PAGE_NUMBER
SelectPartitionPage(PINPUT_RECORD Ir)
{
if (PartitionList == NULL)
{
- PartitionList = CreatePartitionList (2,
- 19,
- xScreen - 3,
- yScreen - 3);
-
+ PartitionList = CreatePartitionList(2,
+ 19,
+ xScreen - 3,
+ yScreen - 3);
if (PartitionList == NULL)
{
/* FIXME: show an error dialog */
}
}
- CheckActiveBootPartition (PartitionList);
+ CheckActiveBootPartition(PartitionList);
- DrawPartitionList (PartitionList);
+ DrawPartitionList(PartitionList);
/* Warn about partitions created by Linux Fdisk */
if (WarnLinuxPartitions == TRUE &&
{
if (AutoPartition)
{
- PPARTENTRY PartEntry = PartEntry = PartitionList->CurrentPartition;
+ PPARTENTRY PartEntry = PartitionList->CurrentPartition;
ULONG MaxSize = (PartEntry->UnpartitionedLength + (1 << 19)) >> 20; /* in MBytes (rounded) */
+ if(!IsDiskSizeValid(PartitionList->CurrentPartition))
+ {
+ MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE, Ir, POPUP_WAIT_ANY_KEY);
+ return SELECT_PARTITION_PAGE; /* let the user select another partition */
+ }
CreateNewPartition(PartitionList,
MaxSize,
TRUE);
- return (SELECT_FILE_SYSTEM_PAGE);
+ return SELECT_FILE_SYSTEM_PAGE;
}
}
else
{
- return(SELECT_FILE_SYSTEM_PAGE);
+ if(!IsDiskSizeValid(PartitionList->CurrentPartition))
+ {
+ MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE, Ir, POPUP_WAIT_ANY_KEY);
+ return SELECT_PARTITION_PAGE; /* let the user select another partition */
+ }
+
+ return SELECT_FILE_SYSTEM_PAGE;
}
}
- while(TRUE)
+ while (TRUE)
{
/* Update status text */
if (PartitionList->CurrentPartition == NULL ||
{
if (ConfirmQuit(Ir) == TRUE)
{
- DestroyPartitionList (PartitionList);
+ DestroyPartitionList(PartitionList);
PartitionList = NULL;
return QUIT_PAGE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
- ScrollDownPartitionList (PartitionList);
+ ScrollDownPartitionList(PartitionList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
- ScrollUpPartitionList (PartitionList);
+ ScrollUpPartitionList(PartitionList);
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
{
+ if(!IsDiskSizeValid(PartitionList->CurrentPartition))
+ {
+ MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE, Ir, POPUP_WAIT_ANY_KEY);
+ return SELECT_PARTITION_PAGE; /* let the user select another partition */
+ }
if (PartitionList->CurrentPartition == NULL ||
PartitionList->CurrentPartition->Unpartitioned == TRUE)
{
- CreateNewPartition (PartitionList,
- 0ULL,
- TRUE);
+ CreateNewPartition(PartitionList,
+ 0ULL,
+ TRUE);
}
return SELECT_FILE_SYSTEM_PAGE;
static VOID
DrawInputField(ULONG FieldLength,
- SHORT Left,
- SHORT Top,
- PCHAR FieldContent)
+ SHORT Left,
+ SHORT Top,
+ PCHAR FieldContent)
{
CHAR buf[100];
COORD coPos;
buf[FieldLength - strlen(FieldContent)] = 0;
strcat(buf, FieldContent);
- WriteConsoleOutputCharacterA (StdOutput,
- buf,
- strlen (buf),
- coPos,
- &Written);
+ WriteConsoleOutputCharacterA(StdOutput,
+ buf,
+ strlen(buf),
+ coPos,
+ &Written);
}
static VOID
ShowPartitionSizeInputBox(SHORT Left,
- SHORT Top,
- SHORT Right,
- SHORT Bottom,
- ULONG MaxSize,
- PCHAR InputBuffer,
- PBOOLEAN Quit,
- PBOOLEAN Cancel)
+ SHORT Top,
+ SHORT Right,
+ SHORT Bottom,
+ ULONG MaxSize,
+ PCHAR InputBuffer,
+ PBOOLEAN Quit,
+ PBOOLEAN Cancel)
{
INPUT_RECORD Ir;
COORD coPos;
/* Print message */
coPos.X = Left + 2;
coPos.Y = Top + 2;
- strcpy (Buffer, MUIGetString(STRING_PARTITIONSIZE));
- iLeft = coPos.X + strlen (Buffer) + 1;
+ strcpy(Buffer, MUIGetString(STRING_PARTITIONSIZE));
+ iLeft = coPos.X + strlen(Buffer) + 1;
iTop = coPos.Y;
WriteConsoleOutputCharacterA(StdOutput,
coPos,
&Written);
- sprintf (Buffer, MUIGetString(STRING_MAXSIZE), MaxSize);
+ sprintf(Buffer, MUIGetString(STRING_MAXSIZE), MaxSize);
coPos.X = iLeft + PARTITION_SIZE_INPUT_FIELD_LENGTH + 1;
coPos.Y = iTop;
WriteConsoleOutputCharacterA(StdOutput,
sprintf(Buffer, "%lu", MaxSize);
Index = strlen(Buffer);
- DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
- iLeft,
- iTop,
- Buffer);
+ DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
+ iLeft,
+ iTop,
+ Buffer);
while (TRUE)
{
Index--;
Buffer[Index] = 0;
- DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
- iLeft,
- iTop,
- Buffer);
+ DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
+ iLeft,
+ iTop,
+ Buffer);
}
else if ((Ir.Event.KeyEvent.uChar.AsciiChar != 0x00) &&
(Index < PARTITION_SIZE_INPUT_FIELD_LENGTH))
Index++;
Buffer[Index] = 0;
- DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
- iLeft,
- iTop,
- Buffer);
+ DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
+ iLeft,
+ iTop,
+ Buffer);
}
}
}
- strcpy (InputBuffer, Buffer);
+ strcpy(InputBuffer, Buffer);
}
static PAGE_NUMBER
-CreatePartitionPage (PINPUT_RECORD Ir)
+CreatePartitionPage(PINPUT_RECORD Ir)
{
PDISKENTRY DiskEntry;
PPARTENTRY PartEntry;
if (DiskEntry->DriverName.Length > 0)
{
CONSOLE_PrintTextXY(6, 10,
- MUIGetString(STRING_HDINFOPARTCREATE),
- DiskSize,
- Unit,
- DiskEntry->DiskNumber,
- DiskEntry->Port,
- DiskEntry->Bus,
- DiskEntry->Id,
- &DiskEntry->DriverName);
+ MUIGetString(STRING_HDINFOPARTCREATE),
+ DiskSize,
+ Unit,
+ DiskEntry->DiskNumber,
+ DiskEntry->Port,
+ DiskEntry->Bus,
+ DiskEntry->Id,
+ &DiskEntry->DriverName);
}
else
{
CONSOLE_PrintTextXY(6, 10,
- MUIGetString(STRING_HDDINFOUNK1),
- DiskSize,
- Unit,
- DiskEntry->DiskNumber,
- DiskEntry->Port,
- DiskEntry->Bus,
- DiskEntry->Id);
+ MUIGetString(STRING_HDDINFOUNK1),
+ DiskSize,
+ Unit,
+ DiskEntry->DiskNumber,
+ DiskEntry->Port,
+ DiskEntry->Bus,
+ DiskEntry->Id);
}
CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE));
#if 0
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
- PartitionList->CurrentPartition->UnpartitionedLength / (1024*1024));
+ PartitionList->CurrentPartition->UnpartitionedLength / (1024*1024));
#endif
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
if (MaxSize > PARTITION_MAXSIZE) MaxSize = PARTITION_MAXSIZE;
- ShowPartitionSizeInputBox (12, 14, xScreen - 12, 17, /* left, top, right, bottom */
- MaxSize, InputBuffer, &Quit, &Cancel);
+ ShowPartitionSizeInputBox(12, 14, xScreen - 12, 17, /* left, top, right, bottom */
+ MaxSize, InputBuffer, &Quit, &Cancel);
if (Quit == TRUE)
{
DPRINT ("Partition size: %I64u bytes\n", PartSize);
- CreateNewPartition (PartitionList,
- PartSize,
- FALSE);
+ CreateNewPartition(PartitionList,
+ PartSize,
+ FALSE);
return SELECT_PARTITION_PAGE;
}
static PAGE_NUMBER
-DeletePartitionPage (PINPUT_RECORD Ir)
+DeletePartitionPage(PINPUT_RECORD Ir)
{
PDISKENTRY DiskEntry;
PPARTENTRY PartEntry;
if (PartType == NULL)
{
CONSOLE_PrintTextXY(6, 10,
- MUIGetString(STRING_HDDINFOUNK2),
- (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
- (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
- PartEntry->PartInfo[PartNumber].PartitionType,
- PartSize,
- Unit);
+ MUIGetString(STRING_HDDINFOUNK2),
+ (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
+ (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
+ PartEntry->PartInfo[PartNumber].PartitionType,
+ PartSize,
+ Unit);
}
else
{
CONSOLE_PrintTextXY(6, 10,
- " %c%c %s %I64u %s",
- (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
- (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
- PartType,
- PartSize,
- Unit);
+ " %c%c %s %I64u %s",
+ (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
+ (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
+ PartType,
+ PartSize,
+ Unit);
}
#if 0
if (DiskEntry->DriverName.Length > 0)
{
CONSOLE_PrintTextXY(6, 12,
- MUIGetString(STRING_HDINFOPARTDELETE),
- DiskSize,
- Unit,
- DiskEntry->DiskNumber,
- DiskEntry->Port,
- DiskEntry->Bus,
- DiskEntry->Id,
- &DiskEntry->DriverName);
+ MUIGetString(STRING_HDINFOPARTDELETE),
+ DiskSize,
+ Unit,
+ DiskEntry->DiskNumber,
+ DiskEntry->Port,
+ DiskEntry->Bus,
+ DiskEntry->Id,
+ &DiskEntry->DriverName);
}
else
{
CONSOLE_PrintTextXY(6, 12,
- MUIGetString(STRING_HDDINFOUNK3),
- DiskSize,
- Unit,
- DiskEntry->DiskNumber,
- DiskEntry->Port,
- DiskEntry->Bus,
- DiskEntry->Id);
+ MUIGetString(STRING_HDDINFOUNK3),
+ DiskSize,
+ Unit,
+ DiskEntry->DiskNumber,
+ DiskEntry->Port,
+ DiskEntry->Bus,
+ DiskEntry->Id);
}
while (TRUE)
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
- if (ConfirmQuit (Ir) == TRUE)
+ if (ConfirmQuit(Ir) == TRUE)
{
return QUIT_PAGE;
}
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'D') /* D */
{
- DeleteCurrentPartition (PartitionList);
+ DeleteCurrentPartition(PartitionList);
return SELECT_PARTITION_PAGE;
}
static PAGE_NUMBER
-SelectFileSystemPage (PINPUT_RECORD Ir)
+SelectFileSystemPage(PINPUT_RECORD Ir)
{
PDISKENTRY DiskEntry;
PPARTENTRY PartEntry;
if (PartType == NULL)
{
CONSOLE_PrintTextXY(8, 10,
- MUIGetString(STRING_HDDINFOUNK4),
- (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
- (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
- PartEntry->PartInfo[PartNumber].PartitionType,
- PartSize,
- PartUnit);
+ MUIGetString(STRING_HDDINFOUNK4),
+ (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
+ (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
+ PartEntry->PartInfo[PartNumber].PartitionType,
+ PartSize,
+ PartUnit);
}
else
{
CONSOLE_PrintTextXY(8, 10,
- "%c%c %s %I64u %s",
+ "%c%c %s %I64u %s",
(PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
(PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
PartType,
if (FileSystemList == NULL)
{
- FileSystemList = CreateFileSystemList (6, 26, PartEntry->New, L"FAT");
+ FileSystemList = CreateFileSystemList(6, 26, PartEntry->New, L"FAT");
if (FileSystemList == NULL)
{
/* FIXME: show an error dialog */
/* FIXME: Add file systems to list */
}
- DrawFileSystemList (FileSystemList);
+ DrawFileSystemList(FileSystemList);
if (RepairUpdateFlag)
{
return FORMAT_PARTITION_PAGE;
}
- return(CHECK_FILE_SYSTEM_PAGE);
+ return CHECK_FILE_SYSTEM_PAGE;
}
while (TRUE)
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
- if (ConfirmQuit (Ir) == TRUE)
+ if (ConfirmQuit(Ir) == TRUE)
{
return QUIT_PAGE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
- ScrollDownFileSystemList (FileSystemList);
+ ScrollDownFileSystemList(FileSystemList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
- ScrollUpFileSystemList (FileSystemList);
+ ScrollUpFileSystemList(FileSystemList);
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
{
static ULONG
-FormatPartitionPage (PINPUT_RECORD Ir)
+FormatPartitionPage(PINPUT_RECORD Ir)
{
WCHAR PathBuffer[MAX_PATH];
PDISKENTRY DiskEntry;
PartEntry = PartitionList->CurrentPartition;
PartNum = PartitionList->CurrentPartitionNumber;
- while(TRUE)
+ while (TRUE)
{
if (!IsUnattendedSetup)
{
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
- if (ConfirmQuit (Ir) == TRUE)
+ if (ConfirmQuit(Ir) == TRUE)
{
return QUIT_PAGE;
}
{
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
- if (PartEntry->PartInfo[PartNum].PartitionType == PARTITION_ENTRY_UNUSED)
+ if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
{
- if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
+ if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (4200LL * 1024LL))
+ {
+ /* FAT12 CHS partition (disk is smaller than 4.1MB) */
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT_12;
+ }
+ else if (PartEntry->PartInfo[PartNum].StartingOffset.QuadPart < (1024LL * 255LL * 63LL * 512LL))
{
- if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (4200LL * 1024LL))
+ /* Partition starts below the 8.4GB boundary ==> CHS partition */
+
+ if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (32LL * 1024LL * 1024LL))
{
- /* FAT12 CHS partition (disk is smaller than 4.1MB) */
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT_12;
+ /* FAT16 CHS partition (partiton size < 32MB) */
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT_16;
}
- else if (PartEntry->PartInfo[PartNum].StartingOffset.QuadPart < (1024LL * 255LL * 63LL * 512LL))
+ else if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
{
- /* Partition starts below the 8.4GB boundary ==> CHS partition */
-
- if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (32LL * 1024LL * 1024LL))
- {
- /* FAT16 CHS partition (partiton size < 32MB) */
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT_16;
- }
- else if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
- {
- /* FAT16 CHS partition (partition size < 512MB) */
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_HUGE;
- }
- else
- {
- /* FAT32 CHS partition (partition size >= 512MB) */
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT32;
- }
+ /* FAT16 CHS partition (partition size < 512MB) */
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_HUGE;
}
else
{
- /* Partition starts above the 8.4GB boundary ==> LBA partition */
-
- if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
- {
- /* FAT16 LBA partition (partition size < 512MB) */
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_XINT13;
- }
- else
- {
- /* FAT32 LBA partition (partition size >= 512MB) */
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT32_XINT13;
- }
+ /* FAT32 CHS partition (partition size >= 512MB) */
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT32;
+ }
+ }
+ else
+ {
+ /* Partition starts above the 8.4GB boundary ==> LBA partition */
+
+ if (PartEntry->PartInfo[PartNum].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
+ {
+ /* FAT16 LBA partition (partition size < 512MB) */
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_XINT13;
+ }
+ else
+ {
+ /* FAT32 LBA partition (partition size >= 512MB) */
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT32_XINT13;
}
}
- else if (wcscmp(FileSystemList->Selected->FileSystem, L"EXT2") == 0)
- PartEntry->PartInfo[PartNum].PartitionType = PARTITION_EXT2;
- else if (!FileSystemList->Selected->FormatFunc)
- return QUIT_PAGE;
}
+ else if (wcscmp(FileSystemList->Selected->FileSystem, L"EXT2") == 0)
+ PartEntry->PartInfo[PartNum].PartitionType = PARTITION_EXT2;
+ else if (!FileSystemList->Selected->FormatFunc)
+ return QUIT_PAGE;
- CheckActiveBootPartition (PartitionList);
+ CheckActiveBootPartition(PartitionList);
#ifndef NDEBUG
CONSOLE_PrintTextXY(6, 12,
- "Disk: %I64u Cylinder: %I64u Track: %I64u",
- DiskEntry->DiskSize,
- DiskEntry->CylinderSize,
- DiskEntry->TrackSize);
+ "Disk: %I64u Cylinder: %I64u Track: %I64u",
+ DiskEntry->DiskSize,
+ DiskEntry->CylinderSize,
+ DiskEntry->TrackSize);
Line = 13;
DiskEntry = PartitionList->CurrentDisk;
for (i = 0; i < 4; i++)
{
CONSOLE_PrintTextXY(6, Line,
- "%2u: %2u %c %12I64u %12I64u %2u %c",
- i,
- PartEntry->PartInfo[i].PartitionNumber,
- PartEntry->PartInfo[i].BootIndicator ? 'A' : '-',
- PartEntry->PartInfo[i].StartingOffset.QuadPart,
- PartEntry->PartInfo[i].PartitionLength.QuadPart,
- PartEntry->PartInfo[i].PartitionType,
- PartEntry->PartInfo[i].RewritePartition ? '*' : ' ');
+ "%2u: %2u %c %12I64u %12I64u %2u %c",
+ i,
+ PartEntry->PartInfo[i].PartitionNumber,
+ PartEntry->PartInfo[i].BootIndicator ? 'A' : '-',
+ PartEntry->PartInfo[i].StartingOffset.QuadPart,
+ PartEntry->PartInfo[i].PartitionLength.QuadPart,
+ PartEntry->PartInfo[i].PartitionType,
+ PartEntry->PartInfo[i].RewritePartition ? '*' : ' ');
Line++;
}
PartEntry = PartitionList->CurrentPartition;
#endif
- if (WritePartitionsToDisk (PartitionList) == FALSE)
+ if (WritePartitionsToDisk(PartitionList) == FALSE)
{
- DPRINT ("WritePartitionsToDisk() failed\n");
+ DPRINT("WritePartitionsToDisk() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
/* Set DestinationRootPath */
- RtlFreeUnicodeString (&DestinationRootPath);
- swprintf (PathBuffer,
- L"\\Device\\Harddisk%lu\\Partition%lu",
- PartitionList->CurrentDisk->DiskNumber,
- PartitionList->CurrentPartition->PartInfo[PartNum].PartitionNumber);
- RtlCreateUnicodeString (&DestinationRootPath,
- PathBuffer);
- DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath);
+ RtlFreeUnicodeString(&DestinationRootPath);
+ swprintf(PathBuffer,
+ L"\\Device\\Harddisk%lu\\Partition%lu",
+ PartitionList->CurrentDisk->DiskNumber,
+ PartitionList->CurrentPartition->PartInfo[PartNum].PartitionNumber);
+ RtlCreateUnicodeString(&DestinationRootPath,
+ PathBuffer);
+ DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath);
/* Set SystemRootPath */
- RtlFreeUnicodeString (&SystemRootPath);
- swprintf (PathBuffer,
- L"\\Device\\Harddisk%lu\\Partition%lu",
- PartitionList->ActiveBootDisk->DiskNumber,
- PartitionList->ActiveBootPartition->
- PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionNumber);
- RtlCreateUnicodeString (&SystemRootPath,
- PathBuffer);
- DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath);
+ RtlFreeUnicodeString(&SystemRootPath);
+ swprintf(PathBuffer,
+ L"\\Device\\Harddisk%lu\\Partition%lu",
+ PartitionList->ActiveBootDisk->DiskNumber,
+ PartitionList->ActiveBootPartition->
+ PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionNumber);
+ RtlCreateUnicodeString(&SystemRootPath,
+ PathBuffer);
+ DPRINT("SystemRootPath: %wZ\n", &SystemRootPath);
if (FileSystemList->Selected->FormatFunc)
{
- Status = FormatPartition(&DestinationRootPath, FileSystemList->Selected);
+ Status = FormatPartition(&DestinationRootPath,
+ FileSystemList->Selected);
if (!NT_SUCCESS(Status))
{
DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status);
CheckActiveBootPartition(PartitionList);
}
- /* Install MBR if necessary */
- if (DiskEntry->NoMbr &&
- DiskEntry->BiosDiskNumber == 0)
- {
- wcscpy(PathBuffer, SourceRootPath.Buffer);
- wcscat(PathBuffer, L"\\loader\\dosmbr.bin");
-
- DPRINT("Install MBR bootcode: %S ==> %S\n",
- PathBuffer, DestinationRootPath.Buffer);
-
- /* Install MBR bootcode */
- Status = InstallMbrBootCodeToDisk(PathBuffer, DestinationRootPath.Buffer);
- if (!NT_SUCCESS (Status))
- {
- DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
- Status);
- return FALSE;
- }
-
- DiskEntry->NoMbr = FALSE;
- }
-
if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
{
/* FIXME: Install boot code. This is a hack! */
wcscat(PathBuffer, L"\\loader\\fat32.bin");
DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
- DestinationRootPath.Buffer);
- Status = InstallFat32BootCodeToDisk(PathBuffer,
- DestinationRootPath.Buffer);
+ DestinationRootPath.Buffer);
+ Status = InstallFat32BootCodeToDisk(PathBuffer,
+ DestinationRootPath.Buffer);
if (!NT_SUCCESS(Status))
{
DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status);
wcscat(PathBuffer, L"\\loader\\fat.bin");
DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer,
- DestinationRootPath.Buffer);
- Status = InstallFat16BootCodeToDisk(PathBuffer,
- DestinationRootPath.Buffer);
+ DestinationRootPath.Buffer);
+ Status = InstallFat16BootCodeToDisk(PathBuffer,
+ DestinationRootPath.Buffer);
if (!NT_SUCCESS(Status))
{
DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status);
wcscat(PathBuffer, L"\\loader\\ext2.bin");
DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer,
- DestinationRootPath.Buffer);
- Status = InstallFat32BootCodeToDisk(PathBuffer,
- DestinationRootPath.Buffer);
+ DestinationRootPath.Buffer);
+ Status = InstallFat32BootCodeToDisk(PathBuffer,
+ DestinationRootPath.Buffer);
if (!NT_SUCCESS(Status))
{
DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status);
MUIGetString(STRING_QUITCONTINUE),
NULL, POPUP_WAIT_NONE);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
static PAGE_NUMBER
-InstallDirectoryPage1(PWCHAR InstallDir, PDISKENTRY DiskEntry, PPARTENTRY PartEntry, UCHAR PartNum)
+InstallDirectoryPage1(PWCHAR InstallDir,
+ PDISKENTRY DiskEntry,
+ PPARTENTRY PartEntry,
+ UCHAR PartNum)
{
WCHAR PathBuffer[MAX_PATH];
wcscat(PathBuffer, InstallDir);
RtlCreateUnicodeString(&DestinationArcPath, PathBuffer);
- return(PREPARE_COPY_PAGE);
+ return PREPARE_COPY_PAGE;
}
PartEntry = PartitionList->CurrentPartition;
/* Search for 'DefaultPath' in the 'SetupData' section */
- if (!SetupFindFirstLineW (SetupInf, L"SetupData", L"DefaultPath", &Context))
+ if (!SetupFindFirstLineW(SetupInf, L"SetupData", L"DefaultPath", &Context))
{
MUIDisplayError(ERROR_FIND_SETUPDATA, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
/* Read the 'DefaultPath' data */
- if (INF_GetData (&Context, NULL, &DefaultPath))
+ if (INF_GetData(&Context, NULL, &DefaultPath))
{
wcscpy(InstallDir, DefaultPath);
}
if (IsUnattendedSetup)
{
- return(InstallDirectoryPage1 (InstallDir, DiskEntry, PartEntry, PartitionList->CurrentPartitionNumber));
+ return InstallDirectoryPage1(InstallDir,
+ DiskEntry,
+ PartEntry,
+ PartitionList->CurrentPartitionNumber);
}
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) == TRUE)
- return(QUIT_PAGE);
+ return QUIT_PAGE;
break;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
- return (InstallDirectoryPage1 (InstallDir, DiskEntry, PartEntry, PartitionList->CurrentPartitionNumber));
+ return InstallDirectoryPage1(InstallDir,
+ DiskEntry,
+ PartEntry,
+ PartitionList->CurrentPartitionNumber);
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
{
}
}
- return(INSTALL_DIRECTORY_PAGE);
+ return INSTALL_DIRECTORY_PAGE;
}
+
static BOOLEAN
AddSectionToCopyQueueCab(HINF InfFile,
- PWCHAR SectionName,
- PWCHAR SourceCabinet,
- PCUNICODE_STRING DestinationPath,
- PINPUT_RECORD Ir)
+ PWCHAR SectionName,
+ PWCHAR SourceCabinet,
+ PCUNICODE_STRING DestinationPath,
+ PINPUT_RECORD Ir)
{
INFCONTEXT FilesContext;
INFCONTEXT DirContext;
PWCHAR TargetFileName;
/* Search for the SectionName section */
- if (!SetupFindFirstLineW (InfFile, SectionName, NULL, &FilesContext))
+ if (!SetupFindFirstLineW(InfFile, SectionName, NULL, &FilesContext))
{
char Buffer[128];
sprintf(Buffer, MUIGetString(STRING_TXTSETUPFAILED), SectionName);
PopupError(Buffer, MUIGetString(STRING_REBOOTCOMPUTER), Ir, POPUP_WAIT_ENTER);
- return(FALSE);
+ return FALSE;
}
/*
do
{
/* Get source file name and target directory id */
- if (!INF_GetData (&FilesContext, &FileKeyName, &FileKeyValue))
+ if (!INF_GetData(&FilesContext, &FileKeyName, &FileKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
}
/* Get optional target file name */
- if (!INF_GetDataField (&FilesContext, 2, &TargetFileName))
+ if (!INF_GetDataField(&FilesContext, 2, &TargetFileName))
TargetFileName = NULL;
- DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
+ DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
/* Lookup target directory */
- if (!SetupFindFirstLineW (InfFile, L"Directories", FileKeyValue, &DirContext))
+ if (!SetupFindFirstLineW(InfFile, L"Directories", FileKeyValue, &DirContext))
{
/* FIXME: Handle error! */
DPRINT1("SetupFindFirstLine() failed\n");
break;
}
- if (!INF_GetData (&DirContext, NULL, &DirKeyValue))
+ if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
}
if (!SetupQueueCopy(SetupFileQueue,
- SourceCabinet,
- SourceRootPath.Buffer,
- SourceRootDir.Buffer,
- FileKeyName,
- DirKeyValue,
- TargetFileName))
+ SourceCabinet,
+ SourceRootPath.Buffer,
+ SourceRootDir.Buffer,
+ FileKeyName,
+ DirKeyValue,
+ TargetFileName))
{
/* FIXME: Handle error! */
DPRINT1("SetupQueueCopy() failed\n");
return TRUE;
}
+
static BOOLEAN
AddSectionToCopyQueue(HINF InfFile,
- PWCHAR SectionName,
- PWCHAR SourceCabinet,
- PCUNICODE_STRING DestinationPath,
- PINPUT_RECORD Ir)
+ PWCHAR SectionName,
+ PWCHAR SourceCabinet,
+ PCUNICODE_STRING DestinationPath,
+ PINPUT_RECORD Ir)
{
INFCONTEXT FilesContext;
INFCONTEXT DirContext;
PWCHAR FileKeyValue;
PWCHAR DirKeyValue;
PWCHAR TargetFileName;
+ WCHAR CompleteOrigFileName[512];
if (SourceCabinet)
return AddSectionToCopyQueueCab(InfFile, L"SourceFiles", SourceCabinet, DestinationPath, Ir);
/* Search for the SectionName section */
- if (!SetupFindFirstLineW (InfFile, SectionName, NULL, &FilesContext))
+ if (!SetupFindFirstLineW(InfFile, SectionName, NULL, &FilesContext))
{
char Buffer[128];
sprintf(Buffer, MUIGetString(STRING_TXTSETUPFAILED), SectionName);
}
/*
- * Enumerate the files in the section
- * and add them to the file queue.
- */
+ * Enumerate the files in the section
+ * and add them to the file queue.
+ */
do
{
/* Get source file name and target directory id */
- if (!INF_GetData (&FilesContext, &FileKeyName, &FileKeyValue))
+ if (!INF_GetData(&FilesContext, &FileKeyName, &FileKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
}
/* Get target directory id */
- if (!INF_GetDataField (&FilesContext, 13, &FileKeyValue))
+ if (!INF_GetDataField(&FilesContext, 13, &FileKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
}
/* Get optional target file name */
- if (!INF_GetDataField (&FilesContext, 11, &TargetFileName))
+ if (!INF_GetDataField(&FilesContext, 11, &TargetFileName))
TargetFileName = NULL;
else if (!*TargetFileName)
TargetFileName = NULL;
- DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
+ DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
/* Lookup target directory */
- if (!SetupFindFirstLineW (InfFile, L"Directories", FileKeyValue, &DirContext))
+ if (!SetupFindFirstLineW(InfFile, L"Directories", FileKeyValue, &DirContext))
{
/* FIXME: Handle error! */
DPRINT1("SetupFindFirstLine() failed\n");
break;
}
- if (!INF_GetData (&DirContext, NULL, &DirKeyValue))
+ if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
break;
}
+ wcscpy(CompleteOrigFileName, SourceRootDir.Buffer);
+ wcscat(CompleteOrigFileName, L"\\");
+ wcscat(CompleteOrigFileName, DirKeyValue);
+
if (!SetupQueueCopy(SetupFileQueue,
SourceCabinet,
SourceRootPath.Buffer,
- SourceRootDir.Buffer,
+ CompleteOrigFileName,
FileKeyName,
DirKeyValue,
TargetFileName))
return TRUE;
}
+
static BOOLEAN
PrepareCopyPageInfFile(HINF InfFile,
- PWCHAR SourceCabinet,
- PINPUT_RECORD Ir)
+ PWCHAR SourceCabinet,
+ PINPUT_RECORD Ir)
{
WCHAR PathBuffer[MAX_PATH];
INFCONTEXT DirContext;
/* Enumerate the directory values and create the subdirectories */
do
{
- if (!INF_GetData (&DirContext, NULL, &KeyValue))
+ if (!INF_GetData(&DirContext, NULL, &KeyValue))
{
DPRINT1("break\n");
break;
return TRUE;
}
+
static PAGE_NUMBER
PrepareCopyPage(PINPUT_RECORD Ir)
{
}
/* Search for the 'Cabinets' section */
- if (!SetupFindFirstLineW (SetupInf, L"Cabinets", NULL, &CabinetsContext))
+ if (!SetupFindFirstLineW(SetupInf, L"Cabinets", NULL, &CabinetsContext))
{
return FILE_COPY_PAGE;
}
/*
- * Enumerate the directory values in the 'Cabinets'
- * section and parse their inf files.
- */
+ * Enumerate the directory values in the 'Cabinets'
+ * section and parse their inf files.
+ */
do
{
- if (!INF_GetData (&CabinetsContext, NULL, &KeyValue))
+ if (!INF_GetData(&CabinetsContext, NULL, &KeyValue))
break;
wcscpy(PathBuffer, SourcePath.Buffer);
InfFileSize,
(const CHAR*) NULL,
INF_STYLE_WIN4,
+ LanguageId,
&ErrorLine);
if (InfHandle == INVALID_HANDLE_VALUE)
return QUIT_PAGE;
}
#endif
- } while (SetupFindNextLine (&CabinetsContext, &CabinetsContext));
+ } while (SetupFindNextLine(&CabinetsContext, &CabinetsContext));
return FILE_COPY_PAGE;
}
+
VOID
NTAPI
SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext,
- IN BOOLEAN First)
+ IN BOOLEAN First)
{
SYSTEM_PERFORMANCE_INFORMATION PerfInfo;
ProgressSetStep(CopyContext->MemoryBars[2], PerfInfo.AvailablePages);
}
-static UINT CALLBACK
+
+static UINT
+CALLBACK
FileCopyCallback(PVOID Context,
- UINT Notification,
- UINT_PTR Param1,
- UINT_PTR Param2)
+ UINT Notification,
+ UINT_PTR Param1,
+ UINT_PTR Param2)
{
PCOPYCONTEXT CopyContext;
case SPFILENOTIFY_STARTCOPY:
/* Display copy message */
- CONSOLE_SetStatusTextAutoFitX (45 , MUIGetString(STRING_COPYING), (PWSTR)Param1);
+ CONSOLE_SetStatusText(MUIGetString(STRING_COPYING), (PWSTR)Param1);
SetupUpdateMemoryInfo(CopyContext, FALSE);
break;
return 0;
}
+
static
PAGE_NUMBER
FileCopyPage(PINPUT_RECORD Ir)
/* Create the paged pool progress bar */
CopyContext.MemoryBars[0] = CreateProgressBar(13,
40,
- 13 + mem_bar_width,
+ 13 + mem_bar_width,
43,
- 13,
+ 13,
44,
FALSE,
"Kernel Pool");
/* Create the non paged pool progress bar */
CopyContext.MemoryBars[1] = CreateProgressBar((xScreen / 2)- (mem_bar_width / 2),
40,
- (xScreen / 2) + (mem_bar_width / 2),
+ (xScreen / 2) + (mem_bar_width / 2),
43,
(xScreen / 2)- (mem_bar_width / 2),
44,
/* Create the global memory progress bar */
CopyContext.MemoryBars[2] = CreateProgressBar(xScreen - 13 - mem_bar_width,
40,
- xScreen - 13,
+ xScreen - 13,
43,
- xScreen - 13 - mem_bar_width,
+ xScreen - 13 - mem_bar_width,
44,
FALSE,
"Free Memory");
return REGISTRY_PAGE;
}
+
static PAGE_NUMBER
RegistryPage(PINPUT_RECORD Ir)
{
DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
+ if (Action == NULL)
+ break; // Hackfix
+
if (!_wcsicmp (Action, L"AddReg"))
{
Delete = FALSE;
CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE), File);
- if (!ImportRegistryFile(File, Section, Delete))
+ if (!ImportRegistryFile(File, Section, LanguageId, Delete))
{
DPRINT("Importing %S failed\n", File);
MUIDisplayError(ERROR_IMPORT_HIVE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
- } while (SetupFindNextLine (&InfContext, &InfContext));
+ } while (SetupFindNextLine(&InfContext, &InfContext));
/* Update display registry settings */
CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE));
return QUIT_PAGE;
}
- if (!IsUnattendedSetup){
-
- /* Update keyboard layout settings */
- CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE));
- if (!ProcessKeyboardLayoutRegistry(LayoutList))
- {
- MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);
- return QUIT_PAGE;
- }
+ if (!IsUnattendedSetup)
+ {
+ /* Update keyboard layout settings */
+ CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE));
+ if (!ProcessKeyboardLayoutRegistry(LayoutList))
+ {
+ MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
}
+
/* Add codepage information to registry */
CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE));
if (!AddCodePage())
/* Unattended install on hdd? */
if (IsUnattendedSetup && UnattendMBRInstallType == 2)
{
- return BOOT_LOADER_HARDDISK_PAGE;
+ return BOOT_LOADER_HARDDISK_MBR_PAGE;
}
MUIDisplayPage(BOOT_LOADER_PAGE);
CONSOLE_InvertTextXY(8, Line, 60, 1);
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
CONSOLE_NormalTextXY(8, Line, 60, 1);
Line++;
- if (Line<12) Line=14;
- if (Line>14) Line=12;
+ if (Line<12)
+ Line=15;
+
+ if (Line>15)
+ Line=12;
CONSOLE_InvertTextXY(8, Line, 60, 1);
}
CONSOLE_NormalTextXY(8, Line, 60, 1);
Line--;
- if (Line<12) Line=14;
- if (Line>14) Line=12;
+ if (Line<12)
+ Line=15;
+
+ if (Line>15)
+ Line=12;
CONSOLE_InvertTextXY(8, Line, 60, 1);
}
{
if (Line == 12)
{
- return BOOT_LOADER_HARDDISK_PAGE;
+ return BOOT_LOADER_HARDDISK_MBR_PAGE;
}
else if (Line == 13)
{
- return BOOT_LOADER_FLOPPY_PAGE;
+ return BOOT_LOADER_HARDDISK_VBR_PAGE;
}
else if (Line == 14)
+ {
+ return BOOT_LOADER_FLOPPY_PAGE;
+ }
+ else if (Line == 15)
{
return SUCCESS_PAGE;
}
// SetStatusText(" Please wait...");
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
return BOOT_LOADER_FLOPPY_PAGE;
}
+static PAGE_NUMBER
+BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir)
+{
+ UCHAR PartitionType;
+ NTSTATUS Status;
+
+ PartitionType = PartitionList->ActiveBootPartition->
+ PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionType;
+
+ Status = InstallVBRToPartition(&SystemRootPath,
+ &SourceRootPath,
+ &DestinationArcPath,
+ PartitionType);
+ if (!NT_SUCCESS(Status))
+ {
+ MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
+
+ return SUCCESS_PAGE;
+}
static PAGE_NUMBER
-BootLoaderHarddiskPage(PINPUT_RECORD Ir)
+BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir)
{
UCHAR PartitionType;
NTSTATUS Status;
+ WCHAR DestinationDevicePathBuffer[MAX_PATH];
+ WCHAR SourceMbrPathBuffer[MAX_PATH];
+ /* Step 1: Write the VBR */
PartitionType = PartitionList->ActiveBootPartition->
PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionType;
- if ((PartitionType == PARTITION_FAT_12) ||
- (PartitionType == PARTITION_FAT_16) ||
- (PartitionType == PARTITION_HUGE) ||
- (PartitionType == PARTITION_XINT13) ||
- (PartitionType == PARTITION_FAT32) ||
- (PartitionType == PARTITION_FAT32_XINT13))
- {
- Status = InstallFatBootcodeToPartition(&SystemRootPath,
- &SourceRootPath,
- &DestinationArcPath,
- PartitionType);
- if (!NT_SUCCESS(Status))
- {
- MUIDisplayError(ERROR_INSTALL_BOOTCODE, Ir, POPUP_WAIT_ENTER);
- return QUIT_PAGE;
- }
- return SUCCESS_PAGE;
- }
- else
+ Status = InstallVBRToPartition(&SystemRootPath,
+ &SourceRootPath,
+ &DestinationArcPath,
+ PartitionType);
+ if (!NT_SUCCESS(Status))
{
MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
- return BOOT_LOADER_HARDDISK_PAGE;
+ /* Step 2: Write the MBR */
+ swprintf(DestinationDevicePathBuffer,
+ L"\\Device\\Harddisk%d\\Partition0",
+ PartitionList->ActiveBootDisk->DiskNumber);
+
+ wcscpy(SourceMbrPathBuffer, SourceRootPath.Buffer);
+ wcscat(SourceMbrPathBuffer, L"\\loader\\dosmbr.bin");
+
+ DPRINT("Install MBR bootcode: %S ==> %S\n",
+ SourceMbrPathBuffer, DestinationDevicePathBuffer);
+
+ Status = InstallMbrBootCodeToDisk(SourceMbrPathBuffer,
+ DestinationDevicePathBuffer);
+ if (!NT_SUCCESS (Status))
+ {
+ DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
+ Status);
+ MUIDisplayError(ERROR_INSTALL_BOOTCODE, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
+
+ return SUCCESS_PAGE;
}
CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2));
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
return FLUSH_PAGE;
}
- while(TRUE)
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
NtQuerySystemTime(&Time);
- Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, PnpEventThread, &SetupInf, &hPnpThread, NULL);
+ Status = RtlCreateUserThread(NtCurrentProcess(),
+ NULL,
+ TRUE,
+ 0,
+ 0,
+ 0,
+ PnpEventThread,
+ &SetupInf,
+ &hPnpThread,
+ NULL);
if (!NT_SUCCESS(Status))
hPnpThread = INVALID_HANDLE_VALUE;
Page = BootLoaderFloppyPage(&Ir);
break;
- case BOOT_LOADER_HARDDISK_PAGE:
- Page = BootLoaderHarddiskPage(&Ir);
+ case BOOT_LOADER_HARDDISK_MBR_PAGE:
+ Page = BootLoaderHarddiskMbrPage(&Ir);
+ break;
+
+ case BOOT_LOADER_HARDDISK_VBR_PAGE:
+ Page = BootLoaderHarddiskVbrPage(&Ir);
break;
/* Repair pages */
RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessHeap = Peb->ProcessHeap;
- INF_SetHeap(ProcessHeap);
+ InfSetHeap(ProcessHeap);
RunUSetup();
}
#endif /* __REACTOS__ */