[USETUP] Similarly to what was done for GenLists, factor out the UI code from the...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 15 May 2017 19:41:18 +0000 (19:41 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 26 May 2018 20:45:50 +0000 (22:45 +0200)
This will allow to reuse it for the 1st-stage GUI setup too, while using another UI representation.
Add also two partition iterator functions: GetNextPartition and GetPrevPartition.

svn path=/branches/setup_improvements/; revision=74554

base/setup/usetup/partlist.c
base/setup/usetup/partlist.h
base/setup/usetup/usetup.c

index 7d52208..31c657f 100644 (file)
@@ -1419,11 +1419,7 @@ AddDiskToList(
 
 
 PPARTLIST
-CreatePartitionList(
-    SHORT Left,
-    SHORT Top,
-    SHORT Right,
-    SHORT Bottom)
+CreatePartitionList(VOID)
 {
     PPARTLIST List;
     OBJECT_ATTRIBUTES ObjectAttributes;
@@ -1442,14 +1438,6 @@ CreatePartitionList(
     if (List == NULL)
         return NULL;
 
-    List->Left = Left;
-    List->Top = Top;
-    List->Right = Right;
-    List->Bottom = Bottom;
-
-    List->Line = 0;
-    List->Offset = 0;
-
     List->CurrentDisk = NULL;
     List->CurrentPartition = NULL;
 
@@ -1466,10 +1454,11 @@ CreatePartitionList(
 
     Status = NtQuerySystemInformation(SystemDeviceInformation,
                                       &Sdi,
-                                      sizeof(SYSTEM_DEVICE_INFORMATION),
+                                      sizeof(Sdi),
                                       &ReturnSize);
     if (!NT_SUCCESS(Status))
     {
+        DPRINT1("NtQuerySystemInformation() failed, Status 0x%08lx", Status);
         RtlFreeHeap(ProcessHeap, 0, List);
         return NULL;
     }
@@ -1593,23 +1582,47 @@ DestroyPartitionList(
 }
 
 
+VOID
+InitPartitionListUi(
+    IN OUT PPARTLIST_UI ListUi,
+    IN PPARTLIST List,
+    IN SHORT Left,
+    IN SHORT Top,
+    IN SHORT Right,
+    IN SHORT Bottom)
+{
+    ListUi->List = List;
+    // ListUi->FirstShown = NULL;
+    // ListUi->LastShown = NULL;
+
+    ListUi->Left = Left;
+    ListUi->Top = Top;
+    ListUi->Right = Right;
+    ListUi->Bottom = Bottom;
+
+    ListUi->Line = 0;
+    ListUi->Offset = 0;
+
+    // ListUi->Redraw = TRUE;
+}
+
 static
 VOID
 PrintEmptyLine(
-    IN PPARTLIST List)
+    IN PPARTLIST_UI ListUi)
 {
     COORD coPos;
     ULONG Written;
     USHORT Width;
     USHORT Height;
 
-    Width = List->Right - List->Left - 1;
-    Height = List->Bottom - List->Top - 2;
+    Width = ListUi->Right - ListUi->Left - 1;
+    Height = ListUi->Bottom - ListUi->Top - 2;
 
-    coPos.X = List->Left + 1;
-    coPos.Y = List->Top + 1 + List->Line;
+    coPos.X = ListUi->Left + 1;
+    coPos.Y = ListUi->Top + 1 + ListUi->Line;
 
-    if (List->Line >= 0 && List->Line <= Height)
+    if (ListUi->Line >= 0 && ListUi->Line <= Height)
     {
         FillConsoleOutputAttribute(StdOutput,
                                    FOREGROUND_WHITE | BACKGROUND_BLUE,
@@ -1624,17 +1637,18 @@ PrintEmptyLine(
                                     &Written);
     }
 
-    List->Line++;
+    ListUi->Line++;
 }
 
 
 static
 VOID
 PrintPartitionData(
-    IN PPARTLIST List,
+    IN PPARTLIST_UI ListUi,
     IN PDISKENTRY DiskEntry,
     IN PPARTENTRY PartEntry)
 {
+    PPARTLIST List = ListUi->List;
     CHAR LineBuffer[128];
     COORD coPos;
     ULONG Written;
@@ -1644,14 +1658,13 @@ PrintPartitionData(
     PCHAR Unit;
     UCHAR Attribute;
     CHAR PartTypeString[32];
-    PCHAR PartType;
-    PartType = PartTypeString;
+    PCHAR PartType = PartTypeString;
 
-    Width = List->Right - List->Left - 1;
-    Height = List->Bottom - List->Top - 2;
+    Width = ListUi->Right - ListUi->Left - 1;
+    Height = ListUi->Bottom - ListUi->Top - 2;
 
-    coPos.X = List->Left + 1;
-    coPos.Y = List->Top + 1 + List->Line;
+    coPos.X = ListUi->Left + 1;
+    coPos.Y = ListUi->Top + 1 + ListUi->Line;
 
     if (PartEntry->IsPartitioned == FALSE)
     {
@@ -1751,7 +1764,7 @@ PrintPartitionData(
                  FOREGROUND_BLUE | BACKGROUND_WHITE :
                  FOREGROUND_WHITE | BACKGROUND_BLUE;
 
-    if (List->Line >= 0 && List->Line <= Height)
+    if (ListUi->Line >= 0 && ListUi->Line <= Height)
     {
         FillConsoleOutputCharacterA(StdOutput,
                                     ' ',
@@ -1761,7 +1774,7 @@ PrintPartitionData(
     }
     coPos.X += 4;
     Width -= 8;
-    if (List->Line >= 0 && List->Line <= Height)
+    if (ListUi->Line >= 0 && ListUi->Line <= Height)
     {
         FillConsoleOutputAttribute(StdOutput,
                                    Attribute,
@@ -1771,7 +1784,7 @@ PrintPartitionData(
     }
     coPos.X++;
     Width -= 2;
-    if (List->Line >= 0 && List->Line <= Height)
+    if (ListUi->Line >= 0 && ListUi->Line <= Height)
     {
         WriteConsoleOutputCharacterA(StdOutput,
                                      LineBuffer,
@@ -1780,16 +1793,17 @@ PrintPartitionData(
                                      &Written);
     }
 
-    List->Line++;
+    ListUi->Line++;
 }
 
 
 static
 VOID
 PrintDiskData(
-    IN PPARTLIST List,
+    IN PPARTLIST_UI ListUi,
     IN PDISKENTRY DiskEntry)
 {
+    // PPARTLIST List = ListUi->List;
     PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
     PLIST_ENTRY PrimaryEntry, LogicalEntry;
     CHAR LineBuffer[128];
@@ -1800,11 +1814,11 @@ PrintDiskData(
     ULARGE_INTEGER DiskSize;
     PCHAR Unit;
 
-    Width = List->Right - List->Left - 1;
-    Height = List->Bottom - List->Top - 2;
+    Width = ListUi->Right - ListUi->Left - 1;
+    Height = ListUi->Bottom - ListUi->Top - 2;
 
-    coPos.X = List->Left + 1;
-    coPos.Y = List->Top + 1 + List->Line;
+    coPos.X = ListUi->Left + 1;
+    coPos.Y = ListUi->Top + 1 + ListUi->Line;
 
     DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
     if (DiskSize.QuadPart >= 10737418240) /* 10 GB */
@@ -1844,7 +1858,7 @@ PrintDiskData(
                 DiskEntry->Id);
     }
 
-    if (List->Line >= 0 && List->Line <= Height)
+    if (ListUi->Line >= 0 && ListUi->Line <= Height)
     {
         FillConsoleOutputAttribute(StdOutput,
                                    FOREGROUND_WHITE | BACKGROUND_BLUE,
@@ -1860,7 +1874,7 @@ PrintDiskData(
     }
 
     coPos.X++;
-    if (List->Line >= 0 && List->Line <= Height)
+    if (ListUi->Line >= 0 && ListUi->Line <= Height)
     {
         WriteConsoleOutputCharacterA(StdOutput,
                                      LineBuffer,
@@ -1869,10 +1883,10 @@ PrintDiskData(
                                      &Written);
     }
 
-    List->Line++;
+    ListUi->Line++;
 
     /* Print separator line */
-    PrintEmptyLine(List);
+    PrintEmptyLine(ListUi);
 
     /* Print partition lines */
     PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
@@ -1880,7 +1894,7 @@ PrintDiskData(
     {
         PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
 
-        PrintPartitionData(List,
+        PrintPartitionData(ListUi,
                            DiskEntry,
                            PrimaryPartEntry);
 
@@ -1891,7 +1905,7 @@ PrintDiskData(
             {
                 LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
 
-                PrintPartitionData(List,
+                PrintPartitionData(ListUi,
                                    DiskEntry,
                                    LogicalPartEntry);
 
@@ -1903,14 +1917,15 @@ PrintDiskData(
     }
 
     /* Print separator line */
-    PrintEmptyLine(List);
+    PrintEmptyLine(ListUi);
 }
 
 
 VOID
 DrawPartitionList(
-    IN PPARTLIST List)
+    IN PPARTLIST_UI ListUi)
 {
+    PPARTLIST List = ListUi->List;
     PLIST_ENTRY Entry, Entry2;
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry = NULL;
@@ -2001,37 +2016,37 @@ DrawPartitionList(
     }
 
     /* If it possible, make the disk name visible */
-    if (CurrentPartLine < List->Offset)
+    if (CurrentPartLine < ListUi->Offset)
     {
-        List->Offset = CurrentPartLine;
+        ListUi->Offset = CurrentPartLine;
     }
-    else if (CurrentPartLine - List->Offset > List->Bottom - List->Top - 2)
+    else if (CurrentPartLine - ListUi->Offset > ListUi->Bottom - ListUi->Top - 2)
     {
-        List->Offset = CurrentPartLine - (List->Bottom - List->Top - 2);
+        ListUi->Offset = CurrentPartLine - (ListUi->Bottom - ListUi->Top - 2);
     }
 
-    if (CurrentDiskLine < List->Offset && CurrentPartLine - CurrentDiskLine < List->Bottom - List->Top - 2)
+    if (CurrentDiskLine < ListUi->Offset && CurrentPartLine - CurrentDiskLine < ListUi->Bottom - ListUi->Top - 2)
     {
-        List->Offset = CurrentDiskLine;
+        ListUi->Offset = CurrentDiskLine;
     }
 
-    /* draw upper left corner */
-    coPos.X = List->Left;
-    coPos.Y = List->Top;
+    /* Draw upper left corner */
+    coPos.X = ListUi->Left;
+    coPos.Y = ListUi->Top;
     FillConsoleOutputCharacterA(StdOutput,
                                 0xDA, // '+',
                                 1,
                                 coPos,
                                 &Written);
 
-    /* draw upper edge */
-    coPos.X = List->Left + 1;
-    coPos.Y = List->Top;
-    if (List->Offset == 0)
+    /* Draw upper edge */
+    coPos.X = ListUi->Left + 1;
+    coPos.Y = ListUi->Top;
+    if (ListUi->Offset == 0)
     {
         FillConsoleOutputCharacterA(StdOutput,
                                     0xC4, // '-',
-                                    List->Right - List->Left - 1,
+                                    ListUi->Right - ListUi->Left - 1,
                                     coPos,
                                     &Written);
     }
@@ -2039,16 +2054,16 @@ DrawPartitionList(
     {
         FillConsoleOutputCharacterA(StdOutput,
                                     0xC4, // '-',
-                                    List->Right - List->Left - 5,
+                                    ListUi->Right - ListUi->Left - 5,
                                     coPos,
                                     &Written);
-        coPos.X = List->Right - 5;
+        coPos.X = ListUi->Right - 5;
         WriteConsoleOutputCharacterA(StdOutput,
                                      "(\x18)", // "(up)"
                                      3,
                                      coPos,
                                      &Written);
-        coPos.X = List->Right - 2;
+        coPos.X = ListUi->Right - 2;
         FillConsoleOutputCharacterA(StdOutput,
                                     0xC4, // '-',
                                     2,
@@ -2056,19 +2071,19 @@ DrawPartitionList(
                                     &Written);
     }
 
-    /* draw upper right corner */
-    coPos.X = List->Right;
-    coPos.Y = List->Top;
+    /* Draw upper right corner */
+    coPos.X = ListUi->Right;
+    coPos.Y = ListUi->Top;
     FillConsoleOutputCharacterA(StdOutput,
                                 0xBF, // '+',
                                 1,
                                 coPos,
                                 &Written);
 
-    /* draw left and right edge */
-    for (i = List->Top + 1; i < List->Bottom; i++)
+    /* Draw left and right edge */
+    for (i = ListUi->Top + 1; i < ListUi->Bottom; i++)
     {
-        coPos.X = List->Left;
+        coPos.X = ListUi->Left;
         coPos.Y = i;
         FillConsoleOutputCharacterA(StdOutput,
                                     0xB3, // '|',
@@ -2076,7 +2091,7 @@ DrawPartitionList(
                                     coPos,
                                     &Written);
 
-        coPos.X = List->Right;
+        coPos.X = ListUi->Right;
         FillConsoleOutputCharacterA(StdOutput,
                                     0xB3, //'|',
                                     1,
@@ -2084,23 +2099,23 @@ DrawPartitionList(
                                     &Written);
     }
 
-    /* draw lower left corner */
-    coPos.X = List->Left;
-    coPos.Y = List->Bottom;
+    /* Draw lower left corner */
+    coPos.X = ListUi->Left;
+    coPos.Y = ListUi->Bottom;
     FillConsoleOutputCharacterA(StdOutput,
                                 0xC0, // '+',
                                 1,
                                 coPos,
                                 &Written);
 
-    /* draw lower edge */
-    coPos.X = List->Left + 1;
-    coPos.Y = List->Bottom;
-    if (LastLine - List->Offset <= List->Bottom - List->Top - 2)
+    /* Draw lower edge */
+    coPos.X = ListUi->Left + 1;
+    coPos.Y = ListUi->Bottom;
+    if (LastLine - ListUi->Offset <= ListUi->Bottom - ListUi->Top - 2)
     {
         FillConsoleOutputCharacterA(StdOutput,
                                     0xC4, // '-',
-                                    List->Right - List->Left - 1,
+                                    ListUi->Right - ListUi->Left - 1,
                                     coPos,
                                     &Written);
     }
@@ -2108,16 +2123,16 @@ DrawPartitionList(
     {
         FillConsoleOutputCharacterA(StdOutput,
                                     0xC4, // '-',
-                                    List->Right - List->Left - 5,
+                                    ListUi->Right - ListUi->Left - 5,
                                     coPos,
                                     &Written);
-        coPos.X = List->Right - 5;
+        coPos.X = ListUi->Right - 5;
         WriteConsoleOutputCharacterA(StdOutput,
                                      "(\x19)", // "(down)"
                                      3,
                                      coPos,
                                      &Written);
-       coPos.X = List->Right - 2;
+       coPos.X = ListUi->Right - 2;
        FillConsoleOutputCharacterA(StdOutput,
                                    0xC4, // '-',
                                    2,
@@ -2125,9 +2140,9 @@ DrawPartitionList(
                                    &Written);
     }
 
-    /* draw lower right corner */
-    coPos.X = List->Right;
-    coPos.Y = List->Bottom;
+    /* Draw lower right corner */
+    coPos.X = ListUi->Right;
+    coPos.Y = ListUi->Bottom;
     FillConsoleOutputCharacterA(StdOutput,
                                 0xD9, // '+',
                                 1,
@@ -2135,7 +2150,7 @@ DrawPartitionList(
                                 &Written);
 
     /* print list entries */
-    List->Line = - List->Offset;
+    ListUi->Line = - ListUi->Offset;
 
     Entry = List->DiskListHead.Flink;
     while (Entry != &List->DiskListHead)
@@ -2143,8 +2158,7 @@ DrawPartitionList(
         DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
 
         /* Print disk entry */
-        PrintDiskData(List,
-                      DiskEntry);
+        PrintDiskData(ListUi, DiskEntry);
 
         Entry = Entry->Flink;
     }
@@ -2159,8 +2173,7 @@ SelectPartition(
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
-    PLIST_ENTRY Entry1;
-    PLIST_ENTRY Entry2;
+    PLIST_ENTRY Entry1, Entry2;
 
     /* Check for empty disks */
     if (IsListEmpty(&List->DiskListHead))
@@ -2181,10 +2194,9 @@ SelectPartition(
 
                 if (PartEntry->PartitionNumber == PartitionNumber)
                 {
-                     List->CurrentDisk = DiskEntry;
-                     List->CurrentPartition = PartEntry;
-                     DrawPartitionList(List);
-                     return TRUE;
+                    List->CurrentDisk = DiskEntry;
+                    List->CurrentPartition = PartEntry;
+                    return TRUE;
                 }
 
                 Entry2 = Entry2->Flink;
@@ -2200,8 +2212,8 @@ SelectPartition(
 }
 
 
-BOOL
-ScrollDownPartitionList(
+PPARTENTRY
+GetNextPartition(
     IN PPARTLIST List)
 {
     PLIST_ENTRY DiskListEntry;
@@ -2211,7 +2223,7 @@ ScrollDownPartitionList(
 
     /* Fail, if no disks are available */
     if (IsListEmpty(&List->DiskListHead))
-        return FALSE;
+        return NULL;
 
     /* Check for next usable entry on current disk */
     if (List->CurrentPartition != NULL)
@@ -2227,7 +2239,7 @@ ScrollDownPartitionList(
                 PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
 
                 List->CurrentPartition = PartEntry;
-                return TRUE;
+                return List->CurrentPartition;
             }
             else
             {
@@ -2237,7 +2249,7 @@ ScrollDownPartitionList(
                     PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
 
                     List->CurrentPartition = PartEntry;
-                    return TRUE;
+                    return List->CurrentPartition;
                 }
             }
         }
@@ -2255,7 +2267,7 @@ ScrollDownPartitionList(
                     PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
 
                     List->CurrentPartition = PartEntry;
-                    return TRUE;
+                    return List->CurrentPartition;
                 }
             }
             else
@@ -2267,7 +2279,7 @@ ScrollDownPartitionList(
                     PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
 
                     List->CurrentPartition = PartEntry;
-                    return TRUE;
+                    return List->CurrentPartition;
                 }
             }
         }
@@ -2286,18 +2298,17 @@ ScrollDownPartitionList(
 
             List->CurrentDisk = DiskEntry;
             List->CurrentPartition = PartEntry;
-            return TRUE;
+            return List->CurrentPartition;
         }
 
         DiskListEntry = DiskListEntry->Flink;
     }
 
-    return FALSE;
+    return NULL;
 }
 
-
-BOOL
-ScrollUpPartitionList(
+PPARTENTRY
+GetPrevPartition(
     IN PPARTLIST List)
 {
     PLIST_ENTRY DiskListEntry;
@@ -2307,7 +2318,7 @@ ScrollUpPartitionList(
 
     /* Fail, if no disks are available */
     if (IsListEmpty(&List->DiskListHead))
-        return FALSE;
+        return NULL;
 
     /* Check for previous usable entry on current disk */
     if (List->CurrentPartition != NULL)
@@ -2323,12 +2334,12 @@ ScrollUpPartitionList(
             }
             else
             {
-                /* Extended partition*/
+                /* Extended partition */
                 PartEntry = List->CurrentDisk->ExtendedPartition;
             }
 
             List->CurrentPartition = PartEntry;
-            return TRUE;
+            return List->CurrentPartition;
         }
         else
         {
@@ -2347,9 +2358,8 @@ ScrollUpPartitionList(
                 }
 
                 List->CurrentPartition = PartEntry;
-                return TRUE;
+                return List->CurrentPartition;
             }
-
         }
     }
 
@@ -2374,21 +2384,39 @@ ScrollUpPartitionList(
 
                     List->CurrentDisk = DiskEntry;
                     List->CurrentPartition = PartEntry;
-                    return TRUE;
+                    return List->CurrentPartition;
                 }
             }
             else
             {
                 List->CurrentDisk = DiskEntry;
                 List->CurrentPartition = PartEntry;
-                return TRUE;
+                return List->CurrentPartition;
             }
         }
 
         DiskListEntry = DiskListEntry->Blink;
     }
 
-    return FALSE;
+    return NULL;
+}
+
+
+
+VOID
+ScrollDownPartitionList(
+    IN PPARTLIST_UI ListUi)
+{
+    if (GetNextPartition(ListUi->List))
+        DrawPartitionList(ListUi);
+}
+
+VOID
+ScrollUpPartitionList(
+    IN PPARTLIST_UI ListUi)
+{
+    if (GetPrevPartition(ListUi->List))
+        DrawPartitionList(ListUi);
 }
 
 
index 35c83b3..e434959 100644 (file)
@@ -150,16 +150,9 @@ typedef struct _DISKENTRY
 
 typedef struct _PARTLIST
 {
-    /* UI stuff */
-    SHORT Left;
-    SHORT Top;
-    SHORT Right;
-    SHORT Bottom;
-
-    SHORT Line;
-    SHORT Offset;
-
     /*
+     * Disk & Partition iterators.
+     *
      * NOTE that when CurrentPartition != NULL, then CurrentPartition->DiskEntry
      * must be the same as CurrentDisk. We should however keep the two members
      * separated as we can have a current (selected) disk without any current
@@ -237,32 +230,24 @@ GetPartTypeStringFromPartitionType(
     IN ULONG cchPartType);
 
 PPARTLIST
-CreatePartitionList(
-    SHORT Left,
-    SHORT Top,
-    SHORT Right,
-    SHORT Bottom);
+CreatePartitionList(VOID);
 
 VOID
 DestroyPartitionList(
     IN PPARTLIST List);
 
-VOID
-DrawPartitionList(
-    IN PPARTLIST List);
-
 ULONG
 SelectPartition(
     IN PPARTLIST List,
     IN ULONG DiskNumber,
     IN ULONG PartitionNumber);
 
-BOOL
-ScrollDownPartitionList(
+PPARTENTRY
+GetNextPartition(
     IN PPARTLIST List);
 
-BOOL
-ScrollUpPartitionList(
+PPARTENTRY
+GetPrevPartition(
     IN PPARTLIST List);
 
 VOID
@@ -328,4 +313,47 @@ GetNextUncheckedPartition(
     OUT PDISKENTRY *pDiskEntry OPTIONAL,
     OUT PPARTENTRY *pPartEntry);
 
+
+
+
+
+typedef struct _PARTLIST_UI
+{
+    PPARTLIST List;
+
+    // PLIST_ENTRY FirstShown;
+    // PLIST_ENTRY LastShown;
+
+    SHORT Left;
+    SHORT Top;
+    SHORT Right;
+    SHORT Bottom;
+
+    SHORT Line;
+    SHORT Offset;
+
+    // BOOL Redraw;
+} PARTLIST_UI, *PPARTLIST_UI;
+
+VOID
+InitPartitionListUi(
+    IN OUT PPARTLIST_UI ListUi,
+    IN PPARTLIST List,
+    IN SHORT Left,
+    IN SHORT Top,
+    IN SHORT Right,
+    IN SHORT Bottom);
+
+VOID
+ScrollDownPartitionList(
+    IN PPARTLIST_UI ListUi);
+
+VOID
+ScrollUpPartitionList(
+    IN PPARTLIST_UI ListUi);
+
+VOID
+DrawPartitionList(
+    IN PPARTLIST_UI ListUi);
+
 /* EOF */
index 49f3af7..ff2e80b 100644 (file)
@@ -790,39 +790,16 @@ LanguagePage(PINPUT_RECORD Ir)
 static PAGE_NUMBER
 SetupStartPage(PINPUT_RECORD Ir)
 {
-    //SYSTEM_DEVICE_INFORMATION Sdi;
     NTSTATUS Status;
     WCHAR FileNameBuffer[MAX_PATH];
     INFCONTEXT Context;
     PWCHAR Value;
     UINT ErrorLine;
-    //ULONG ReturnSize;
     PGENERIC_LIST_ENTRY ListEntry;
     INT IntValue;
 
     CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
 
-#if 0
-    /* Check whether a harddisk is available */
-    Status = NtQuerySystemInformation(SystemDeviceInformation,
-                                      &Sdi,
-                                      sizeof(SYSTEM_DEVICE_INFORMATION),
-                                      &ReturnSize);
-
-    if (!NT_SUCCESS(Status))
-    {
-        CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status);
-        MUIDisplayError(ERROR_DRIVE_INFORMATION, Ir, POPUP_WAIT_ENTER);
-        return QUIT_PAGE;
-    }
-
-    if (Sdi.NumberOfDisks == 0)
-    {
-        MUIDisplayError(ERROR_NO_HDD, Ir, POPUP_WAIT_ENTER);
-        return QUIT_PAGE;
-    }
-#endif
-
     /* Get the source path and source root path */
     Status = GetSourcePaths(&SourcePath,
                             &SourceRootPath,
@@ -896,7 +873,7 @@ SetupStartPage(PINPUT_RECORD Ir)
 
     RequiredPartitionDiskSpace = (ULONG)IntValue;
 
-    /* Start PnP thread */
+    /* Start the PnP thread */
     if (hPnpThread != INVALID_HANDLE_VALUE)
     {
         NtResumeThread(hPnpThread, NULL);
@@ -907,8 +884,7 @@ SetupStartPage(PINPUT_RECORD Ir)
 
     if (IsUnattendedSetup)
     {
-        //TODO
-        //read options from inf
+        // TODO: Read options from inf
         ComputerList = CreateComputerTypeList(SetupInf);
         DisplayList = CreateDisplayDriverList(SetupInf);
         KeyboardList = CreateKeyboardDriverList(SetupInf);
@@ -993,7 +969,7 @@ IntroPage(PINPUT_RECORD Ir)
         {
             return REPAIR_INTRO_PAGE;
         }
-        else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'L') /* R */
+        else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'L') /* L */
         {
             return LICENSE_PAGE;
         }
@@ -1533,19 +1509,18 @@ IsDiskSizeValid(PPARTENTRY PartEntry)
 static PAGE_NUMBER
 SelectPartitionPage(PINPUT_RECORD Ir)
 {
+    PARTLIST_UI ListUi;
     ULONG Error;
 
     MUIDisplayPage(SELECT_PARTITION_PAGE);
 
     if (PartitionList == NULL)
     {
-        PartitionList = CreatePartitionList(2,
-                                            23,
-                                            xScreen - 3,
-                                            yScreen - 3);
+        PartitionList = CreatePartitionList();
         if (PartitionList == NULL)
         {
             /* FIXME: show an error dialog */
+            MUIDisplayError(ERROR_DRIVE_INFORMATION, Ir, POPUP_WAIT_ENTER);
             return QUIT_PAGE;
         }
         else if (IsListEmpty(&PartitionList->DiskListHead))
@@ -1555,7 +1530,12 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         }
     }
 
-    DrawPartitionList(PartitionList);
+    InitPartitionListUi(&ListUi, PartitionList,
+                        2,
+                        23,
+                        xScreen - 3,
+                        yScreen - 3);
+    DrawPartitionList(&ListUi);
 
     if (IsUnattendedSetup)
     {
@@ -1576,6 +1556,7 @@ SelectPartitionPage(PINPUT_RECORD Ir)
                                            TRUE);
                 }
 
+// FIXME?? Aren't we going to enter an infinite loop, if this test fails??
                 if (!IsDiskSizeValid(PartitionList->CurrentPartition))
                 {
                     MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY,
@@ -1590,6 +1571,9 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         }
         else
         {
+            DrawPartitionList(&ListUi);
+
+// FIXME?? Aren't we going to enter an infinite loop, if this test fails??
             if (!IsDiskSizeValid(PartitionList->CurrentPartition))
             {
                 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY,
@@ -1657,14 +1641,12 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
                  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN))  /* DOWN */
         {
-            if (ScrollDownPartitionList(PartitionList))
-                DrawPartitionList(PartitionList);
+            ScrollDownPartitionList(&ListUi);
         }
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
                  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP))  /* UP */
         {
-            if (ScrollUpPartitionList(PartitionList))
-                DrawPartitionList(PartitionList);
+            ScrollUpPartitionList(&ListUi);
         }
         else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN)  /* ENTER */
         {