[USETUP]
[reactos.git] / reactos / base / setup / usetup / interface / usetup.c
index 26ece1e..38f4d1a 100644 (file)
@@ -12,9 +12,9 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 /*
  * COPYRIGHT:       See COPYING in the top level directory
@@ -31,6 +31,7 @@
 #define NDEBUG
 #include <debug.h>
 
+
 /* GLOBALS ******************************************************************/
 
 HANDLE ProcessHeap;
@@ -45,15 +46,15 @@ LONG UnattendFormatPartition = 0;
 LONG AutoPartition = 0;
 WCHAR UnattendInstallationDirectory[MAX_PATH];
 PWCHAR SelectedLanguageId;
+WCHAR LocaleID[9];
 WCHAR DefaultLanguage[20];
 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;
@@ -78,6 +79,10 @@ static PGENERIC_LIST KeyboardList = NULL;
 static PGENERIC_LIST LayoutList = NULL;
 static PGENERIC_LIST LanguageList = NULL;
 
+static LANGID LanguageId = 0;
+
+static ULONG RequiredPartitionDiskSpace = ~0;
+
 /* FUNCTIONS ****************************************************************/
 
 static VOID
@@ -100,11 +105,10 @@ PrintString(char* fmt,...)
 
 
 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;
@@ -112,97 +116,89 @@ DrawBox(
     /* 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;
@@ -377,7 +373,7 @@ ConfirmQuit(PINPUT_RECORD Ir)
     BOOL Result = FALSE;
     MUIDisplayError(ERROR_NOT_INSTALLED, NULL, POPUP_WAIT_NONE);
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -421,6 +417,7 @@ CheckUnattendedSetup(VOID)
     UnattendInf = SetupOpenInfFileW(UnattendInfPath,
                                     NULL,
                                     INF_STYLE_WIN4,
+                                    LanguageId,
                                     &ErrorLine);
 
     if (UnattendInf == INVALID_HANDLE_VALUE)
@@ -555,11 +552,22 @@ CheckUnattendedSetup(VOID)
         }
     }
 
+    /* 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);
 
     DPRINT("Running unattended setup\n");
 }
 
+
 VOID
 UpdateKBLayout(VOID)
 {
@@ -571,6 +579,11 @@ UpdateKBLayout(VOID)
     if (LayoutList == NULL)
     {
         LayoutList = CreateKeyboardLayoutList(SetupInf, DefaultKBLayout);
+        if (LayoutList == NULL)
+        {
+            /* FIXME: Handle error! */
+            return;
+        }
     }
 
     ListEntry = GetFirstListEntry(LayoutList);
@@ -591,6 +604,7 @@ UpdateKBLayout(VOID)
     }
 }
 
+
 static PAGE_NUMBER
 LanguagePage(PINPUT_RECORD Ir)
 {
@@ -616,7 +630,7 @@ LanguagePage(PINPUT_RECORD Ir)
 
     MUIDisplayPage(LANGUAGE_PAGE);
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -642,17 +656,17 @@ LanguagePage(PINPUT_RECORD 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 */
@@ -664,6 +678,8 @@ LanguagePage(PINPUT_RECORD Ir)
         {
             SelectedLanguageId = (PWCHAR)GetListEntryUserData(GetCurrentListEntry(LanguageList));
 
+            LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
+
             if (wcscmp(SelectedLanguageId, DefaultLanguage))
             {
                 UpdateKBLayout();
@@ -700,17 +716,19 @@ SetupStartPage(PINPUT_RECORD Ir)
     PWCHAR Value;
     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);
@@ -750,6 +768,7 @@ SetupStartPage(PINPUT_RECORD Ir)
     SetupInf = SetupOpenInfFileW(FileNameBuffer,
                                  NULL,
                                  INF_STYLE_WIN4,
+                                 LanguageId,
                                  &ErrorLine);
 
     if (SetupInf == INVALID_HANDLE_VALUE)
@@ -759,14 +778,14 @@ SetupStartPage(PINPUT_RECORD Ir)
     }
 
     /* 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;
@@ -779,6 +798,22 @@ SetupStartPage(PINPUT_RECORD Ir)
         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)
     {
@@ -798,6 +833,41 @@ SetupStartPage(PINPUT_RECORD Ir)
         LayoutList = CreateKeyboardLayoutList(SetupInf, DefaultKBLayout);
         LanguageList = CreateLanguageList(SetupInf, DefaultLanguage);
 
+        /* 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;
     }
 
@@ -847,6 +917,7 @@ IntroPage(PINPUT_RECORD Ir)
     return INTRO_PAGE;
 }
 
+
 /*
  * License Page
  * RETURNS
@@ -871,6 +942,7 @@ LicensePage(PINPUT_RECORD Ir)
     return LICENSE_PAGE;
 }
 
+
 static PAGE_NUMBER
 RepairIntroPage(PINPUT_RECORD Ir)
 {
@@ -920,7 +992,7 @@ InstallIntroPage(PINPUT_RECORD Ir)
         return SELECT_PARTITION_PAGE;
     }
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -957,7 +1029,7 @@ ScsiControllerPage(PINPUT_RECORD Ir)
 
     SetStatusText("   ENTER = Continue   F3 = Quit");
 
-    while(TRUE)
+    while (TRUE)
     {
         ConInKey(Ir);
 
@@ -1046,7 +1118,7 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
         return SELECT_PARTITION_PAGE;
     }
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -1118,19 +1190,19 @@ ComputerSettingsPage(PINPUT_RECORD 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 */
@@ -1169,19 +1241,19 @@ DisplaySettingsPage(PINPUT_RECORD Ir)
 
     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 */
@@ -1222,19 +1294,19 @@ KeyboardSettingsPage(PINPUT_RECORD Ir)
 
     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 */
@@ -1273,29 +1345,29 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
 
     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 */
@@ -1318,7 +1390,7 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
         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);
         }
     }
 
@@ -1326,6 +1398,38 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
 }
 
 
+static BOOL
+IsDiskSizeValid(PPARTENTRY PartEntry)
+{
+    ULONGLONG m;
+
+    /*  check for unpartitioned space  */
+    m = PartEntry->UnpartitionedLength; 
+    m = (m + (1 << 19)) >> 20;  /* in MBytes (rounded) */
+
+    DPRINT1("Unpartitioned space is %lu MB\n", m);
+
+    if( m > RequiredPartitionDiskSpace)
+    {
+        return TRUE;
+    }
+
+    /* check for partitioned space */
+    m = PartEntry->PartInfo[0].PartitionLength.QuadPart;
+    m = (m + (1 << 19)) >> 20;  /* in MBytes (rounded) */
+    if (m < RequiredPartitionDiskSpace)
+    {
+        /* partition is too small so ask for another partion */
+        DPRINT1("Partition is too small (%lu MB), required disk space is %lu MB\n", m, RequiredPartitionDiskSpace);
+        return FALSE;
+    }
+    else
+    {
+        return TRUE;
+    }
+}
+
+
 static PAGE_NUMBER
 SelectPartitionPage(PINPUT_RECORD Ir)
 {
@@ -1333,11 +1437,10 @@ 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 */
@@ -1345,9 +1448,9 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         }
     }
 
-    CheckActiveBootPartition (PartitionList);
+    CheckActiveBootPartition(PartitionList);
 
-    DrawPartitionList (PartitionList);
+    DrawPartitionList(PartitionList);
 
     /* Warn about partitions created by Linux Fdisk */
     if (WarnLinuxPartitions == TRUE &&
@@ -1378,23 +1481,34 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         {
             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 ||
@@ -1414,7 +1528,7 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         {
             if (ConfirmQuit(Ir) == TRUE)
             {
-                DestroyPartitionList (PartitionList);
+                DestroyPartitionList(PartitionList);
                 PartitionList = NULL;
                 return QUIT_PAGE;
             }
@@ -1424,21 +1538,26 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         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;
@@ -1471,9 +1590,9 @@ SelectPartitionPage(PINPUT_RECORD Ir)
 
 static VOID
 DrawInputField(ULONG FieldLength,
-    SHORT Left,
-    SHORT Top,
-    PCHAR FieldContent)
+               SHORT Left,
+               SHORT Top,
+               PCHAR FieldContent)
 {
     CHAR buf[100];
     COORD coPos;
@@ -1485,11 +1604,11 @@ DrawInputField(ULONG FieldLength,
     buf[FieldLength - strlen(FieldContent)] = 0;
     strcat(buf, FieldContent);
 
-    WriteConsoleOutputCharacterA (StdOutput,
-                                  buf,
-                                  strlen (buf),
-                                  coPos,
-                                  &Written);
+    WriteConsoleOutputCharacterA(StdOutput,
+                                 buf,
+                                 strlen(buf),
+                                 coPos,
+                                 &Written);
 }
 
 
@@ -1499,13 +1618,13 @@ DrawInputField(ULONG FieldLength,
 
 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;
@@ -1527,8 +1646,8 @@ ShowPartitionSizeInputBox(SHORT Left,
     /* 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,
@@ -1537,7 +1656,7 @@ ShowPartitionSizeInputBox(SHORT Left,
                                  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,
@@ -1548,10 +1667,10 @@ ShowPartitionSizeInputBox(SHORT Left,
 
     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)
     {
@@ -1584,10 +1703,10 @@ ShowPartitionSizeInputBox(SHORT Left,
             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))
@@ -1600,20 +1719,20 @@ ShowPartitionSizeInputBox(SHORT Left,
                 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;
@@ -1660,32 +1779,32 @@ CreatePartitionPage (PINPUT_RECORD Ir)
     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));
@@ -1697,8 +1816,8 @@ CreatePartitionPage (PINPUT_RECORD Ir)
 
         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)
         {
@@ -1736,8 +1855,8 @@ CreatePartitionPage (PINPUT_RECORD Ir)
             else
             {
                 /* Round-up by cylinder size */
-                PartSize = ROUND_UP (PartSize * 1024 * 1024,
-                                     DiskEntry->CylinderSize);
+                PartSize = (PartSize * 1024 * 1024 + DiskEntry->CylinderSize - 1) /
+                           DiskEntry->CylinderSize * DiskEntry->CylinderSize;
 
                 /* But never get larger than the unpartitioned disk space */
                 if (PartSize > PartEntry->UnpartitionedLength)
@@ -1746,9 +1865,9 @@ CreatePartitionPage (PINPUT_RECORD Ir)
 
             DPRINT ("Partition size: %I64u bytes\n", PartSize);
 
-            CreateNewPartition (PartitionList,
-                                PartSize,
-                                FALSE);
+            CreateNewPartition(PartitionList,
+                               PartSize,
+                               FALSE);
 
             return SELECT_PARTITION_PAGE;
         }
@@ -1759,7 +1878,7 @@ CreatePartitionPage (PINPUT_RECORD Ir)
 
 
 static PAGE_NUMBER
-DeletePartitionPage (PINPUT_RECORD Ir)
+DeletePartitionPage(PINPUT_RECORD Ir)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -1767,6 +1886,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
     ULONGLONG PartSize;
     PCHAR Unit;
     PCHAR PartType;
+    UCHAR PartNumber;
 
     if (PartitionList == NULL ||
         PartitionList->CurrentDisk == NULL ||
@@ -1778,6 +1898,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
 
     DiskEntry = PartitionList->CurrentDisk;
     PartEntry = PartitionList->CurrentPartition;
+    PartNumber = PartitionList->CurrentPartitionNumber;
 
     MUIDisplayPage(DELETE_PARTITION_PAGE);
 
@@ -1789,66 +1910,66 @@ DeletePartitionPage (PINPUT_RECORD Ir)
     }
     else if (PartEntry->Unpartitioned == FALSE)
     {
-        if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_12) ||
-            (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_16) ||
-            (PartEntry->PartInfo[0].PartitionType == PARTITION_HUGE) ||
-            (PartEntry->PartInfo[0].PartitionType == PARTITION_XINT13))
+        if ((PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT_12) ||
+            (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT_16) ||
+            (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_HUGE) ||
+            (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_XINT13))
         {
             PartType = "FAT";
         }
-        else if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32) ||
-                 (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
+        else if ((PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT32) ||
+                 (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT32_XINT13))
         {
             PartType = "FAT32";
         }
-        else if (PartEntry->PartInfo[0].PartitionType == PARTITION_EXT2)
+        else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_EXT2)
         {
             PartType = "EXT2";
         }
-        else if (PartEntry->PartInfo[0].PartitionType == PARTITION_IFS)
+        else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_IFS)
         {
             PartType = "NTFS"; /* FIXME: Not quite correct! */
         }
     }
 
 #if 0
-    if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */
+    if (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */
     {
-        PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 29)) >> 30;
+        PartSize = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 29)) >> 30;
         Unit = MUIGetString(STRING_GB);
     }
     else
 #endif
-    if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0xA00000LL) /* 10 MB */
+    if (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart >= 0xA00000LL) /* 10 MB */
     {
-        PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 19)) >> 20;
+        PartSize = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 19)) >> 20;
         Unit = MUIGetString(STRING_MB);
     }
     else
     {
-        PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 9)) >> 10;
+        PartSize = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 9)) >> 10;
         Unit = MUIGetString(STRING_KB);
     }
 
     if (PartType == NULL)
     {
         CONSOLE_PrintTextXY(6, 10,
-                             MUIGetString(STRING_HDDINFOUNK2),
-                             (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
-                             (PartEntry->DriveLetter == 0) ? '-' : ':',
-                             PartEntry->PartInfo[0].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 == 0) ? '-' : PartEntry->DriveLetter,
-                             (PartEntry->DriveLetter == 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
@@ -1871,25 +1992,25 @@ DeletePartitionPage (PINPUT_RECORD Ir)
     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)
@@ -1899,7 +2020,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
         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;
             }
@@ -1912,7 +2033,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
         }
         else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'D') /* D */
         {
-            DeleteCurrentPartition (PartitionList);
+            DeleteCurrentPartition(PartitionList);
 
             return SELECT_PARTITION_PAGE;
         }
@@ -1923,10 +2044,11 @@ DeletePartitionPage (PINPUT_RECORD Ir)
 
 
 static PAGE_NUMBER
-SelectFileSystemPage (PINPUT_RECORD Ir)
+SelectFileSystemPage(PINPUT_RECORD Ir)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
+    UCHAR      PartNumber;
     ULONGLONG DiskSize;
     ULONGLONG PartSize;
     PCHAR DiskUnit;
@@ -1943,6 +2065,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
 
     DiskEntry = PartitionList->CurrentDisk;
     PartEntry = PartitionList->CurrentPartition;
+    PartNumber = PartitionList->CurrentPartitionNumber;
 
     /* adjust disk size */
     if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */
@@ -1957,39 +2080,39 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
     }
 
     /* adjust partition size */
-    if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */
+    if (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */
     {
-        PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 29)) >> 30;
+        PartSize = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 29)) >> 30;
         PartUnit = MUIGetString(STRING_GB);
     }
     else
     {
-        PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 19)) >> 20;
+        PartSize = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 19)) >> 20;
         PartUnit = MUIGetString(STRING_MB);
     }
 
     /* adjust partition type */
-    if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_12) ||
-        (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_16) ||
-        (PartEntry->PartInfo[0].PartitionType == PARTITION_HUGE) ||
-        (PartEntry->PartInfo[0].PartitionType == PARTITION_XINT13))
+    if ((PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT_12) ||
+        (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT_16) ||
+        (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_HUGE) ||
+        (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_XINT13))
     {
         PartType = "FAT";
     }
-    else if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32) ||
-             (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
+    else if ((PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT32) ||
+             (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT32_XINT13))
     {
         PartType = "FAT32";
     }
-    else if (PartEntry->PartInfo[0].PartitionType == PARTITION_EXT2)
+    else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_EXT2)
     {
         PartType = "EXT2";
     }
-    else if (PartEntry->PartInfo[0].PartitionType == PARTITION_IFS)
+    else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_IFS)
     {
         PartType = "NTFS"; /* FIXME: Not quite correct! */
     }
-    else if (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED)
+    else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_ENTRY_UNUSED)
     {
         PartType = MUIGetString(STRING_FORMATUNUSED);
     }
@@ -2004,7 +2127,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
 
 #if 0
         CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
-                            PartEntry->PartInfo[0].PartitionNumber,
+                            PartEntry->PartInfo[PartNumber].PartitionNumber,
                             PartSize,
                             PartUnit,
                             PartType);
@@ -2036,19 +2159,19 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
         if (PartType == NULL)
         {
             CONSOLE_PrintTextXY(8, 10,
-                                 MUIGetString(STRING_HDDINFOUNK4),
-                                 (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
-                                 (PartEntry->DriveLetter == 0) ? '-' : ':',
-                                 PartEntry->PartInfo[0].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",
-                                (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
-                                (PartEntry->DriveLetter == 0) ? '-' : ':',
+                                "%c%c  %s    %I64u %s",
+                                (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : PartEntry->DriveLetter[PartNumber],
+                                (PartEntry->DriveLetter[PartNumber] == 0) ? '-' : ':',
                                 PartType,
                                 PartSize,
                                 PartUnit);
@@ -2068,7 +2191,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
 
     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 */
@@ -2077,7 +2200,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
 
         /* FIXME: Add file systems to list */
     }
-    DrawFileSystemList (FileSystemList);
+    DrawFileSystemList(FileSystemList);
 
     if (RepairUpdateFlag)
     {
@@ -2092,7 +2215,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
             return FORMAT_PARTITION_PAGE;
         }
 
-        return(CHECK_FILE_SYSTEM_PAGE);
+        return CHECK_FILE_SYSTEM_PAGE;
     }
 
     while (TRUE)
@@ -2102,7 +2225,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
         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;
             }
@@ -2117,12 +2240,12 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
         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 */
         {
@@ -2142,11 +2265,12 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
 
 
 static ULONG
-FormatPartitionPage (PINPUT_RECORD Ir)
+FormatPartitionPage(PINPUT_RECORD Ir)
 {
     WCHAR PathBuffer[MAX_PATH];
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
+    UCHAR PartNum;
     NTSTATUS Status;
 
 #ifndef NDEBUG
@@ -2167,8 +2291,9 @@ FormatPartitionPage (PINPUT_RECORD Ir)
 
     DiskEntry = PartitionList->CurrentDisk;
     PartEntry = PartitionList->CurrentPartition;
+    PartNum = PartitionList->CurrentPartitionNumber;
 
-    while(TRUE)
+    while (TRUE)
     {
         if (!IsUnattendedSetup)
         {
@@ -2178,7 +2303,7 @@ FormatPartitionPage (PINPUT_RECORD Ir)
         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;
             }
@@ -2189,65 +2314,62 @@ FormatPartitionPage (PINPUT_RECORD Ir)
         {
             CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
 
-            if (PartEntry->PartInfo[0].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))
                 {
-                    if (PartEntry->PartInfo[0].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))
+                {
+                    /* 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[0].PartitionType = PARTITION_FAT_12;
+                        /* FAT16 CHS partition (partiton size < 32MB) */
+                        PartEntry->PartInfo[PartNum].PartitionType = PARTITION_FAT_16;
                     }
-                    else if (PartEntry->PartInfo[0].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[0].PartitionLength.QuadPart < (32LL * 1024LL * 1024LL))
-                        {
-                            /* FAT16 CHS partition (partiton size < 32MB) */
-                            PartEntry->PartInfo[0].PartitionType = PARTITION_FAT_16;
-                        }
-                        else if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
-                        {
-                            /* FAT16 CHS partition (partition size < 512MB) */
-                            PartEntry->PartInfo[0].PartitionType = PARTITION_HUGE;
-                        }
-                        else
-                        {
-                            /* FAT32 CHS partition (partition size >= 512MB) */
-                            PartEntry->PartInfo[0].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[0].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
-                        {
-                            /* FAT16 LBA partition (partition size < 512MB) */
-                            PartEntry->PartInfo[0].PartitionType = PARTITION_XINT13;
-                        }
-                        else
-                        {
-                            /* FAT32 LBA partition (partition size >= 512MB) */
-                            PartEntry->PartInfo[0].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[0].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;
@@ -2262,14 +2384,14 @@ FormatPartitionPage (PINPUT_RECORD Ir)
                     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++;
                     }
@@ -2284,38 +2406,40 @@ FormatPartitionPage (PINPUT_RECORD Ir)
             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[0].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[0].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);
@@ -2331,17 +2455,17 @@ FormatPartitionPage (PINPUT_RECORD Ir)
             if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
             {
                 /* FIXME: Install boot code. This is a hack! */
-                if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13) ||
-                    (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32))
+                if ((PartEntry->PartInfo[PartNum].PartitionType == PARTITION_FAT32_XINT13) ||
+                    (PartEntry->PartInfo[PartNum].PartitionType == PARTITION_FAT32))
                 {
                     wcscpy(PathBuffer, SourceRootPath.Buffer);
                     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);
@@ -2357,10 +2481,10 @@ FormatPartitionPage (PINPUT_RECORD Ir)
                     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);
@@ -2377,10 +2501,10 @@ FormatPartitionPage (PINPUT_RECORD Ir)
                 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);
@@ -2419,6 +2543,7 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
     WCHAR PathBuffer[MAX_PATH];
     CHAR Buffer[MAX_PATH];
     NTSTATUS Status;
+    UCHAR PartNum = PartitionList->CurrentPartitionNumber;
 
     /* FIXME: code duplicated in FormatPartitionPage */
     /* Set DestinationRootPath */
@@ -2426,7 +2551,7 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
     swprintf(PathBuffer,
              L"\\Device\\Harddisk%lu\\Partition%lu",
     PartitionList->CurrentDisk->DiskNumber,
-    PartitionList->CurrentPartition->PartInfo[0].PartitionNumber);
+    PartitionList->CurrentPartition->PartInfo[PartNum].PartitionNumber);
     RtlCreateUnicodeString(&DestinationRootPath, PathBuffer);
     DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath);
 
@@ -2435,7 +2560,7 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
     swprintf(PathBuffer,
              L"\\Device\\Harddisk%lu\\Partition%lu",
     PartitionList->ActiveBootDisk->DiskNumber,
-    PartitionList->ActiveBootPartition->PartInfo[0].PartitionNumber);
+    PartitionList->ActiveBootPartition->PartInfo[PartNum].PartitionNumber);
     RtlCreateUnicodeString(&SystemRootPath, PathBuffer);
     DPRINT("SystemRootPath: %wZ\n", &SystemRootPath);
 
@@ -2459,7 +2584,7 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
                    MUIGetString(STRING_QUITCONTINUE),
                    NULL, POPUP_WAIT_NONE);
 
-        while(TRUE)
+        while (TRUE)
         {
             CONSOLE_ConInKey(Ir);
 
@@ -2499,7 +2624,10 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
 
 
 static PAGE_NUMBER
-InstallDirectoryPage1(PWCHAR InstallDir, PDISKENTRY DiskEntry, PPARTENTRY PartEntry)
+InstallDirectoryPage1(PWCHAR InstallDir,
+                      PDISKENTRY DiskEntry,
+                      PPARTENTRY PartEntry,
+                      UCHAR PartNum)
 {
     WCHAR PathBuffer[MAX_PATH];
 
@@ -2523,7 +2651,7 @@ InstallDirectoryPage1(PWCHAR InstallDir, PDISKENTRY DiskEntry, PPARTENTRY PartEn
     swprintf(PathBuffer,
              L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
              DiskEntry->BiosDiskNumber,
-             PartEntry->PartInfo[0].PartitionNumber);
+             PartEntry->PartInfo[PartNum].PartitionNumber);
 
     if (InstallDir[0] != L'\\')
         wcscat(PathBuffer, L"\\");
@@ -2531,7 +2659,7 @@ InstallDirectoryPage1(PWCHAR InstallDir, PDISKENTRY DiskEntry, PPARTENTRY PartEn
     wcscat(PathBuffer, InstallDir);
     RtlCreateUnicodeString(&DestinationArcPath, PathBuffer);
 
-    return(PREPARE_COPY_PAGE);
+    return PREPARE_COPY_PAGE;
 }
 
 
@@ -2557,14 +2685,14 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
     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);
     }
@@ -2579,10 +2707,13 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
 
     if (IsUnattendedSetup)
     {
-        return(InstallDirectoryPage1 (InstallDir, DiskEntry, PartEntry));
+        return InstallDirectoryPage1(InstallDir,
+                                     DiskEntry,
+                                     PartEntry,
+                                     PartitionList->CurrentPartitionNumber);
     }
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -2590,13 +2721,16 @@ InstallDirectoryPage(PINPUT_RECORD 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));
+            return InstallDirectoryPage1(InstallDir,
+                                         DiskEntry,
+                                         PartEntry,
+                                         PartitionList->CurrentPartitionNumber);
         }
         else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
         {
@@ -2619,15 +2753,16 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
         }
     }
 
-    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;
@@ -2637,12 +2772,12 @@ AddSectionToCopyQueueCab(HINF InfFile,
     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;
     }
 
     /*
@@ -2652,7 +2787,7 @@ AddSectionToCopyQueueCab(HINF InfFile,
     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");
@@ -2660,20 +2795,20 @@ AddSectionToCopyQueueCab(HINF InfFile,
         }
 
         /* 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");
@@ -2681,12 +2816,12 @@ AddSectionToCopyQueueCab(HINF InfFile,
         }
 
         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");
@@ -2696,12 +2831,13 @@ AddSectionToCopyQueueCab(HINF InfFile,
     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;
@@ -2714,7 +2850,7 @@ AddSectionToCopyQueue(HINF InfFile,
         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);
@@ -2723,13 +2859,13 @@ AddSectionToCopyQueue(HINF InfFile,
     }
 
     /*
-    * 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");
@@ -2737,7 +2873,7 @@ AddSectionToCopyQueue(HINF InfFile,
         }
 
         /* Get target directory id */
-        if (!INF_GetDataField (&FilesContext, 13, &FileKeyValue))
+        if (!INF_GetDataField(&FilesContext, 13, &FileKeyValue))
         {
             /* FIXME: Handle error! */
             DPRINT1("INF_GetData() failed\n");
@@ -2745,22 +2881,22 @@ AddSectionToCopyQueue(HINF InfFile,
         }
 
         /* 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");
@@ -2783,10 +2919,11 @@ AddSectionToCopyQueue(HINF InfFile,
     return TRUE;
 }
 
+
 static BOOLEAN
 PrepareCopyPageInfFile(HINF InfFile,
-    PWCHAR SourceCabinet,
-    PINPUT_RECORD Ir)
+                       PWCHAR SourceCabinet,
+                       PINPUT_RECORD Ir)
 {
     WCHAR PathBuffer[MAX_PATH];
     INFCONTEXT DirContext;
@@ -2856,7 +2993,7 @@ PrepareCopyPageInfFile(HINF InfFile,
     /* 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;
@@ -2893,6 +3030,7 @@ PrepareCopyPageInfFile(HINF InfFile,
     return TRUE;
 }
 
+
 static PAGE_NUMBER
 PrepareCopyPage(PINPUT_RECORD Ir)
 {
@@ -2920,18 +3058,18 @@ 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);
@@ -2965,6 +3103,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
                                           InfFileSize,
                                           (const CHAR*) NULL,
                                           INF_STYLE_WIN4,
+                                          LanguageId,
                                           &ErrorLine);
 
         if (InfHandle == INVALID_HANDLE_VALUE)
@@ -2980,15 +3119,16 @@ PrepareCopyPage(PINPUT_RECORD Ir)
             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;
 
@@ -3008,25 +3148,18 @@ SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext,
     }
 
     /* Set current values */
-    ProgressSetStep(CopyContext->MemoryBars[0], PerfInfo.PagedPoolPages);
-    ProgressSetStep(CopyContext->MemoryBars[1], PerfInfo.NonPagedPoolPages);
+    ProgressSetStep(CopyContext->MemoryBars[0], PerfInfo.PagedPoolPages + PerfInfo.NonPagedPoolPages);
+    ProgressSetStep(CopyContext->MemoryBars[1], PerfInfo.ResidentSystemCachePage);
     ProgressSetStep(CopyContext->MemoryBars[2], PerfInfo.AvailablePages);
-
-    /* Check if memory dropped below 40%! */
-    if (CopyContext->MemoryBars[2]->Percent <= 40)
-    {
-        /* Wait a while until Mm does its thing */
-        LARGE_INTEGER Interval;
-        Interval.QuadPart = -1 * 15 * 1000 * 100;
-        NtDelayExecution(FALSE, &Interval);
-    }
 }
 
-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;
 
@@ -3043,7 +3176,7 @@ FileCopyCallback(PVOID Context,
 
         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;
 
@@ -3057,11 +3190,13 @@ FileCopyCallback(PVOID Context,
     return 0;
 }
 
+
 static
 PAGE_NUMBER
 FileCopyPage(PINPUT_RECORD Ir)
 {
     COPYCONTEXT CopyContext;
+    unsigned int mem_bar_width;
 
     MUIDisplayPage(FILE_COPY_PAGE);
 
@@ -3082,35 +3217,35 @@ FileCopyPage(PINPUT_RECORD Ir)
                                                 MUIGetString(STRING_SETUPCOPYINGFILES));
 
     // fit memory bars to screen width, distribute them uniform
-    unsigned int mem_bar_width = (xScreen - 26) / 5;
+    mem_bar_width = (xScreen - 26) / 5;
     mem_bar_width -= mem_bar_width % 2;  // make even
     /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
     /* 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,
-                                                  "Paged Memory");
+                                                  "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,
                                                   FALSE,
-                                                  "Nonpaged Memory");
+                                                  "Kernel Cache");
 
     /* 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");
@@ -3132,6 +3267,7 @@ FileCopyPage(PINPUT_RECORD Ir)
     return REGISTRY_PAGE;
 }
 
+
 static PAGE_NUMBER
 RegistryPage(PINPUT_RECORD Ir)
 {
@@ -3187,6 +3323,9 @@ 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;
@@ -3202,14 +3341,14 @@ RegistryPage(PINPUT_RECORD Ir)
 
         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));
@@ -3235,14 +3374,25 @@ RegistryPage(PINPUT_RECORD Ir)
         return QUIT_PAGE;
     }
 
-    /* Update keyboard layout settings */
-    CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE));
-    if (!ProcessKeyboardLayoutRegistry(LayoutList))
+    /* Set GeoID */
+
+    if (!SetGeoID(MUIGetGeoID()))
     {
-        MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);
+        MUIDisplayError(ERROR_UPDATE_GEOID, 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())
@@ -3269,7 +3419,20 @@ BootLoaderPage(PINPUT_RECORD Ir)
 
     CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
 
-    PartitionType = PartitionList->ActiveBootPartition->PartInfo[0].PartitionType;
+    PartitionType = PartitionList->ActiveBootPartition->
+        PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionType;
+
+    if (IsUnattendedSetup)
+    {
+        if (UnattendMBRInstallType == 0) /* skip MBR installation */
+        {
+            return SUCCESS_PAGE;
+        }
+        else if (UnattendMBRInstallType == 1) /* install on floppy */
+        {
+            return BOOT_LOADER_FLOPPY_PAGE;
+        }
+    }
 
     if (PartitionType == PARTITION_ENTRY_UNUSED)
     {
@@ -3316,26 +3479,16 @@ BootLoaderPage(PINPUT_RECORD Ir)
         return BOOT_LOADER_FLOPPY_PAGE;
     }
 
-    if (IsUnattendedSetup)
+    /* Unattended install on hdd? */
+    if (IsUnattendedSetup && UnattendMBRInstallType == 2)
     {
-        if (UnattendMBRInstallType == 0) /* skip MBR installation */
-        {
-            return SUCCESS_PAGE;
-        }
-        else if (UnattendMBRInstallType == 1) /* install on floppy */
-        {
-            return BOOT_LOADER_FLOPPY_PAGE;
-        }
-        else if (UnattendMBRInstallType == 2) /* install on hdd */
-        {
-            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);
 
@@ -3345,8 +3498,11 @@ BootLoaderPage(PINPUT_RECORD 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);
         }
@@ -3356,8 +3512,11 @@ BootLoaderPage(PINPUT_RECORD 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);
         }
@@ -3373,15 +3532,19 @@ BootLoaderPage(PINPUT_RECORD Ir)
         {
             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 SUCCESS_PAGE;;
+                return BOOT_LOADER_FLOPPY_PAGE;
+            }
+            else if (Line == 15)
+            {
+                return SUCCESS_PAGE;
             }
 
             return BOOT_LOADER_PAGE;
@@ -3401,7 +3564,7 @@ BootLoaderFloppyPage(PINPUT_RECORD Ir)
 
 //  SetStatusText("   Please wait...");
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -3435,40 +3598,72 @@ BootLoaderFloppyPage(PINPUT_RECORD 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];
 
-    PartitionType = PartitionList->ActiveBootPartition->PartInfo[0].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;
-        }
+    /* Step 1: Write the VBR */
+    PartitionType = PartitionList->ActiveBootPartition->
+        PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionType;
 
-        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;
 }
 
 
@@ -3527,7 +3722,7 @@ QuitPage(PINPUT_RECORD Ir)
 
     CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2));
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -3549,7 +3744,7 @@ SuccessPage(PINPUT_RECORD Ir)
         return FLUSH_PAGE;
     }
 
-    while(TRUE)
+    while (TRUE)
     {
         CONSOLE_ConInKey(Ir);
 
@@ -3582,7 +3777,16 @@ RunUSetup(VOID)
 
     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;
 
@@ -3726,8 +3930,12 @@ RunUSetup(VOID)
                 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 */
@@ -3752,10 +3960,6 @@ RunUSetup(VOID)
         }
     }
 
-    /// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
-    /// DO NOT REMOVE!!!
-    DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE\n");
-
     FreeConsole();
 
     /* Avoid bugcheck */