Offer an explanation why AllocConsole() might have failed
[reactos.git] / reactos / subsys / system / usetup / usetup.c
index 6f80aa1..474c311 100644 (file)
  *                  Casper S. Hornstrup (chorns@users.sourceforge.net)
  */
 
-
-#include "precomp.h"
-#include <ntdll/rtl.h>
-
-#include <ntos/minmax.h>
-#include <reactos/resource.h>
-#include <rosrtl/string.h>
-
-#include "usetup.h"
-#include "console.h"
-#include "partlist.h"
-#include "inicache.h"
-#include "infcache.h"
-#include "filequeue.h"
-#include "progress.h"
-#include "bootsup.h"
-#include "registry.h"
-#include "format.h"
-#include "fslist.h"
-#include "cabinet.h"
-#include "filesup.h"
-#include "drivesup.h"
-#include "genlist.h"
-#include "settings.h"
+#include <usetup.h>
 
 #define NDEBUG
 #include <debug.h>
 
-
 typedef enum _PAGE_NUMBER
 {
   START_PAGE,
@@ -69,7 +45,6 @@ typedef enum _PAGE_NUMBER
   DISPLAY_SETTINGS_PAGE,
   KEYBOARD_SETTINGS_PAGE,
   LAYOUT_SETTINGS_PAGE,
-  POINTER_SETTINGS_PAGE,
 
   SELECT_PARTITION_PAGE,
   CREATE_PARTITION_PAGE,
@@ -141,7 +116,6 @@ static PGENERIC_LIST ComputerList = NULL;
 static PGENERIC_LIST DisplayList = NULL;
 static PGENERIC_LIST KeyboardList = NULL;
 static PGENERIC_LIST LayoutList = NULL;
-static PGENERIC_LIST PointerList = NULL;
 
 
 /* FUNCTIONS ****************************************************************/
@@ -370,7 +344,7 @@ PopupError(PCHAR Text,
       coPos.Y++;
       coPos.X = xLeft + 2;
       WriteConsoleOutputCharacters(Status,
-                                  min(strlen(Status), Width - 4),
+                                  min(strlen(Status), (SIZE_T)Width - 4),
                                   coPos);
     }
 }
@@ -421,7 +395,7 @@ CheckUnattendedSetup(VOID)
 {
   WCHAR UnattendInfPath[MAX_PATH];
   UNICODE_STRING FileName;
-  INFCONTEXT Context;
+  PINFCONTEXT Context;
   HINF UnattendInf;
   ULONG ErrorLine;
   NTSTATUS Status;
@@ -455,14 +429,16 @@ CheckUnattendedSetup(VOID)
   if (!InfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context))
     {
       DPRINT("InfFindFirstLine() failed for section 'Unattend'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
 
   /* Get pointer 'Signature' key */
-  if (!InfGetData(&Context, NULL, &Value))
+  if (!InfGetData(Context, NULL, &Value))
     {
       DPRINT("InfGetData() failed for key 'Signature'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
@@ -471,6 +447,7 @@ CheckUnattendedSetup(VOID)
   if (_wcsicmp(Value, L"$ReactOS$") != 0)
     {
       DPRINT("Signature not $ReactOS$\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
@@ -479,31 +456,37 @@ CheckUnattendedSetup(VOID)
   if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
     {
       DPRINT("InfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
-  if (!InfGetIntField(&Context, 0, &IntValue))
+  if (!InfGetIntField(Context, 0, &IntValue))
     {
       DPRINT("InfGetIntField() failed for key 'DestinationDiskNumber'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
   UnattendDestinationDiskNumber = IntValue;
+  InfFreeContext(Context);
 
   /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
   if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
     {
       DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
-  if (!InfGetIntField(&Context, 0, &IntValue))
+  if (!InfGetIntField(Context, 0, &IntValue))
     {
       DPRINT("InfGetIntField() failed for key 'DestinationPartitionNumber'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
   UnattendDestinationPartitionNumber = IntValue;
+  InfFreeContext(Context);
 
   /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
   if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
@@ -514,14 +497,16 @@ CheckUnattendedSetup(VOID)
     }
 
   /* Get pointer 'InstallationDirectory' key */
-  if (!InfGetData(&Context, NULL, &Value))
+  if (!InfGetData(Context, NULL, &Value))
     {
       DPRINT("InfGetData() failed for key 'InstallationDirectory'\n");
+      InfFreeContext(Context);
       InfCloseFile(UnattendInf);
       return;
     }
   wcscpy(UnattendInstallationDirectory, Value);
 
+  InfFreeContext(Context);
   InfCloseFile(UnattendInf);
 
   IsUnattendedSetup = TRUE;
@@ -536,13 +521,13 @@ CheckUnattendedSetup(VOID)
  *     Number of the next page.
  */
 static PAGE_NUMBER
-StartPage(PINPUT_RECORD Ir)
+SetupStartPage(PINPUT_RECORD Ir)
 {
   SYSTEM_DEVICE_INFORMATION Sdi;
   NTSTATUS Status;
   WCHAR FileNameBuffer[MAX_PATH];
   UNICODE_STRING FileName;
-  INFCONTEXT Context;
+  PINFCONTEXT Context;
   PWCHAR Value;
   ULONG ErrorLine;
   ULONG ReturnSize;
@@ -656,8 +641,9 @@ StartPage(PINPUT_RECORD Ir)
 
 
   /* Get pointer 'Signature' key */
-  if (!InfGetData (&Context, NULL, &Value))
+  if (!InfGetData (Context, NULL, &Value))
     {
+      InfFreeContext(Context);
       PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
                 "ENTER = Reboot computer");
 
@@ -675,6 +661,7 @@ StartPage(PINPUT_RECORD Ir)
   /* Check 'Signature' string */
   if (_wcsicmp(Value, L"$ReactOS$") != 0)
     {
+      InfFreeContext(Context);
       PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
                 "ENTER = Reboot computer");
 
@@ -688,6 +675,7 @@ StartPage(PINPUT_RECORD Ir)
            }
        }
     }
+  InfFreeContext(Context);
 
   CheckUnattendedSetup();
 
@@ -962,7 +950,7 @@ ScsiControllerPage(PINPUT_RECORD Ir)
 static PAGE_NUMBER
 DeviceSettingsPage(PINPUT_RECORD Ir)
 {
-  static ULONG Line = 17;
+  static ULONG Line = 16;
 
   /* Initialize the computer settings list */
   if (ComputerList == NULL)
@@ -1016,42 +1004,30 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
        }
     }
 
-  /* Initialize the pointer settings list */
-  if (PointerList == NULL)
-    {
-      PointerList = CreateMouseDriverList(SetupInf);
-      if (PointerList == NULL)
-       {
-         /* FIXME: report error */
-       }
-    }
-
   SetTextXY(6, 8, "The list below shows the current device settings.");
 
   SetTextXY(8, 11, "       Computer:");
   SetTextXY(8, 12, "        Display:");
   SetTextXY(8, 13, "       Keyboard:");
   SetTextXY(8, 14, "Keyboard layout:");
-  SetTextXY(8, 15, " Pointer device:");
 
-  SetTextXY(8, 17, "         Accept:");
+  SetTextXY(8, 16, "         Accept:");
 
   SetTextXY(25, 11, GetGenericListEntry(ComputerList)->Text);
   SetTextXY(25, 12, GetGenericListEntry(DisplayList)->Text);
   SetTextXY(25, 13, GetGenericListEntry(KeyboardList)->Text);
   SetTextXY(25, 14, GetGenericListEntry(LayoutList)->Text);
-  SetTextXY(25, 15, GetGenericListEntry(PointerList)->Text);
 
-  SetTextXY(25, 17, "Accept these device settings");
+  SetTextXY(25, 16, "Accept these device settings");
   InvertTextXY (24, Line, 48, 1);
 
 
-  SetTextXY(6, 20, "You can change the hardware settings by pressing the UP or DOWN keys");
-  SetTextXY(6, 21, "to select an entry. Then press the ENTER key to select alternative");
-  SetTextXY(6, 22, "settings.");
+  SetTextXY(6, 19, "You can change the hardware settings by pressing the UP or DOWN keys");
+  SetTextXY(6, 20, "to select an entry. Then press the ENTER key to select alternative");
+  SetTextXY(6, 21, "settings.");
 
-  SetTextXY(6, 24, "When all settings are correct, select \"Accept these device settings\"");
-  SetTextXY(6, 25, "and press ENTER.");
+  SetTextXY(6, 23, "When all settings are correct, select \"Accept these device settings\"");
+  SetTextXY(6, 24, "and press ENTER.");
 
   SetStatusText("   ENTER = Continue   F3 = Quit");
 
@@ -1063,9 +1039,9 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
          (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
        {
          NormalTextXY (24, Line, 48, 1);
-         if (Line == 15)
-           Line = 17;
-         else if (Line == 17)
+         if (Line == 14)
+           Line = 16;
+         else if (Line == 16)
            Line = 11;
          else
            Line++;
@@ -1076,9 +1052,9 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
        {
          NormalTextXY (24, Line, 48, 1);
          if (Line == 11)
-           Line = 17;
-         else if (Line == 17)
-           Line = 15;
+           Line = 16;
+         else if (Line == 16)
+           Line = 14;
          else
            Line--;
          InvertTextXY (24, Line, 48, 1);
@@ -1100,9 +1076,7 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
            return KEYBOARD_SETTINGS_PAGE;
          else if (Line == 14)
            return LAYOUT_SETTINGS_PAGE;
-         else if (Line == 15)
-           return POINTER_SETTINGS_PAGE;
-         else if (Line == 17)
+         else if (Line == 16)
            return SELECT_PARTITION_PAGE;
        }
     }
@@ -1365,69 +1339,6 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
 }
 
 
-static PAGE_NUMBER
-PointerSettingsPage(PINPUT_RECORD Ir)
-{
-  SHORT xScreen;
-  SHORT yScreen;
-
-  SetTextXY(6, 8, "You want to change the pointing device to be installed.");
-
-  SetTextXY(8, 10, "\x07  Press the UP or DOWN key to select the desired pointing");
-  SetTextXY(8, 11, "    device. Then press ENTER.");
-
-  SetTextXY(8, 13, "\x07  Press the ESC key to return to the previous page without changing");
-  SetTextXY(8, 14, "   the pointing device.");
-
-  GetScreenSize(&xScreen, &yScreen);
-
-  DrawGenericList(PointerList,
-                 2,
-                 18,
-                 xScreen - 3,
-                 yScreen - 3);
-
-  SetStatusText("   ENTER = Continue   ESC = Cancel   F3 = Quit");
-
-  SaveGenericListState(PointerList);
-
-  while(TRUE)
-    {
-      ConInKey(Ir);
-
-      if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
-         (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
-       {
-         ScrollDownGenericList(PointerList);
-       }
-      else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
-         (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
-       {
-         ScrollUpGenericList(PointerList);
-       }
-      else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
-              (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
-       {
-         if (ConfirmQuit(Ir) == TRUE)
-           return QUIT_PAGE;
-         break;
-       }
-      else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
-              (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
-       {
-         RestoreGenericListState(PointerList);
-         return DEVICE_SETTINGS_PAGE;
-       }
-      else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
-       {
-         return DEVICE_SETTINGS_PAGE;
-       }
-    }
-
-  return DISPLAY_SETTINGS_PAGE;
-}
-
-
 static PAGE_NUMBER
 SelectPartitionPage(PINPUT_RECORD Ir)
 {
@@ -1548,7 +1459,7 @@ SelectPartitionPage(PINPUT_RECORD Ir)
 
          return SELECT_FILE_SYSTEM_PAGE;
        }
-      else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_C) /* C */
+      else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'C') /* C */
        {
          if (PartitionList->CurrentPartition->Unpartitioned == FALSE)
            {
@@ -1564,7 +1475,7 @@ SelectPartitionPage(PINPUT_RECORD Ir)
 
          return CREATE_PARTITION_PAGE;
        }
-      else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_D) /* D */
+      else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'D') /* D */
        {
          if (PartitionList->CurrentPartition->Unpartitioned == TRUE)
            {
@@ -1716,7 +1627,7 @@ ShowPartitionSizeInputBox(SHORT Left,
                                strlen (Buffer),
                                coPos);
 
-  sprintf(Buffer, "%d", MaxSize);
+  sprintf(Buffer, "%lu", MaxSize);
   Index = strlen(Buffer);
   DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
                  iLeft,
@@ -1972,14 +1883,14 @@ DeletePartitionPage (PINPUT_RECORD Ir)
     }
 
 #if 0
-  if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000ULL) /* 10 GB */
+  if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */
     {
       PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 29)) >> 30;
       Unit = "GB";
     }
   else
 #endif
-  if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0xA00000ULL) /* 10 MB */
+  if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0xA00000LL) /* 10 MB */
     {
       PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 19)) >> 20;
       Unit = "MB";
@@ -2074,7 +1985,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
        {
          return SELECT_PARTITION_PAGE;
        }
-      else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_D) /* D */
+      else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'D') /* D */
        {
          DeleteCurrentPartition (PartitionList);
 
@@ -2121,7 +2032,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
     }
 
   /* adjust partition size */
-  if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000ULL) /* 10 GB */
+  if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */
     {
       PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 29)) >> 30;
       PartUnit = "GB";
@@ -2351,21 +2262,21 @@ FormatPartitionPage (PINPUT_RECORD Ir)
              switch (FileSystemList->CurrentFileSystem)
                {
                  case FsFat:
-                   if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (4200ULL * 1024ULL))
+                   if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (4200LL * 1024LL))
                      {
                        /* FAT12 CHS partition (disk is smaller than 4.1MB) */
                        PartEntry->PartInfo[0].PartitionType = PARTITION_FAT_12;
                      }
-                   else if (PartEntry->PartInfo[0].StartingOffset.QuadPart < (1024ULL * 255ULL * 63ULL * 512ULL))
+                   else if (PartEntry->PartInfo[0].StartingOffset.QuadPart < (1024LL * 255LL * 63LL * 512LL))
                      {
                        /* Partition starts below the 8.4GB boundary ==> CHS partition */
 
-                       if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (32ULL * 1024ULL * 1024ULL))
+                       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 < (512ULL * 1024ULL * 1024ULL))
+                       else if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
                          {
                            /* FAT16 CHS partition (partition size < 512MB) */
                            PartEntry->PartInfo[0].PartitionType = PARTITION_HUGE;
@@ -2380,7 +2291,7 @@ FormatPartitionPage (PINPUT_RECORD Ir)
                      {
                        /* Partition starts above the 8.4GB boundary ==> LBA partition */
 
-                       if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (512ULL * 1024ULL * 1024ULL))
+                       if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
                          {
                            /* FAT16 LBA partition (partition size < 512MB) */
                            PartEntry->PartInfo[0].PartitionType = PARTITION_XINT13;
@@ -2648,7 +2559,7 @@ InstallDirectoryPage1(PWCHAR InstallDir, PDISKENTRY DiskEntry, PPARTENTRY PartEn
   RtlFreeUnicodeString(&DestinationArcPath);
   swprintf(PathBuffer,
           L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
-          DiskEntry->DiskNumber,
+          DiskEntry->BiosDiskNumber,
           PartEntry->PartInfo[0].PartitionNumber);
   if (InstallDir[0] != L'\\')
     wcscat(PathBuffer,
@@ -2668,7 +2579,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
   PPARTENTRY PartEntry;
   WCHAR InstallDir[51];
   PWCHAR DefaultPath;
-  INFCONTEXT Context;
+  PINFCONTEXT Context;
   ULONG Length;
 
   if (PartitionList == NULL ||
@@ -2701,7 +2612,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
     }
 
   /* Read the 'DefaultPath' data */
-  if (InfGetData (&Context, NULL, &DefaultPath))
+  if (InfGetData (Context, NULL, &DefaultPath))
     {
       wcscpy(InstallDir, DefaultPath);
     }
@@ -2709,6 +2620,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
     {
       wcscpy(InstallDir, L"\\ReactOS");
     }
+  InfFreeContext(Context);
   Length = wcslen(InstallDir);
 
   SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
@@ -2773,8 +2685,8 @@ AddSectionToCopyQueue(HINF InfFile,
                       PWCHAR SourceCabinet,
                       PINPUT_RECORD Ir)
 {
-  INFCONTEXT FilesContext;
-  INFCONTEXT DirContext;
+  PINFCONTEXT FilesContext;
+  PINFCONTEXT DirContext;
   PWCHAR FileKeyName;
   PWCHAR FileKeyValue;
   PWCHAR DirKeyValue;
@@ -2805,7 +2717,7 @@ AddSectionToCopyQueue(HINF InfFile,
   do
     {
       /* Get source file name and target directory id */
-      if (!InfGetData (&FilesContext, &FileKeyName, &FileKeyValue))
+      if (!InfGetData (FilesContext, &FileKeyName, &FileKeyValue))
        {
          /* FIXME: Handle error! */
          DPRINT1("InfGetData() failed\n");
@@ -2813,7 +2725,7 @@ AddSectionToCopyQueue(HINF InfFile,
        }
 
       /* Get optional target file name */
-      if (!InfGetDataField (&FilesContext, 2, &TargetFileName))
+      if (!InfGetDataField (FilesContext, 2, &TargetFileName))
        TargetFileName = NULL;
 
       DPRINT ("FileKeyName: '%S'  FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
@@ -2826,9 +2738,10 @@ AddSectionToCopyQueue(HINF InfFile,
          break;
        }
 
-      if (!InfGetData (&DirContext, NULL, &DirKeyValue))
+      if (!InfGetData (DirContext, NULL, &DirKeyValue))
        {
          /* FIXME: Handle error! */
+          InfFreeContext(DirContext);
          DPRINT1("InfGetData() failed\n");
          break;
        }
@@ -2844,8 +2757,11 @@ AddSectionToCopyQueue(HINF InfFile,
          /* FIXME: Handle error! */
          DPRINT1("SetupQueueCopy() failed\n");
        }
+      InfFreeContext(DirContext);
     }
-  while (InfFindNextLine(&FilesContext, &FilesContext));
+  while (InfFindNextLine(FilesContext, FilesContext));
+
+  InfFreeContext(FilesContext);
 
   return TRUE;
 }
@@ -2856,8 +2772,8 @@ PrepareCopyPageInfFile(HINF InfFile,
                       PINPUT_RECORD Ir)
 {
   WCHAR PathBuffer[MAX_PATH];
-  INFCONTEXT DirContext;
-  PWCHAR AdditionalSectionName;
+  PINFCONTEXT DirContext;
+  PWCHAR AdditionalSectionName = NULL;
   PWCHAR KeyValue;
   ULONG Length;
   NTSTATUS Status;
@@ -2896,7 +2812,7 @@ PrepareCopyPageInfFile(HINF InfFile,
     }
 
   /* Create the install directory */
-  Status = CreateDirectory(PathBuffer);
+  Status = SetupCreateDirectory(PathBuffer);
   if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
     {
       DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer, Status);
@@ -2943,7 +2859,7 @@ PrepareCopyPageInfFile(HINF InfFile,
   /* Enumerate the directory values and create the subdirectories */
   do
     {
-      if (!InfGetData (&DirContext, NULL, &KeyValue))
+      if (!InfGetData (DirContext, NULL, &KeyValue))
        {
          DPRINT1("break\n");
          break;
@@ -2967,7 +2883,7 @@ PrepareCopyPageInfFile(HINF InfFile,
 
          DPRINT("FullPath: '%S'\n", PathBuffer);
 
-         Status = CreateDirectory(PathBuffer);
+         Status = SetupCreateDirectory(PathBuffer);
          if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
            {
              DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer, Status);
@@ -2986,7 +2902,9 @@ PrepareCopyPageInfFile(HINF InfFile,
            }
        }
     }
-  while (InfFindNextLine (&DirContext, &DirContext));
+  while (InfFindNextLine (DirContext, DirContext));
+
+  InfFreeContext(DirContext);
 
   return(TRUE);
 }
@@ -2997,7 +2915,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
 {
   HINF InfHandle;
   WCHAR PathBuffer[MAX_PATH];
-  INFCONTEXT CabinetsContext;
+  PINFCONTEXT CabinetsContext;
   ULONG InfFileSize;
   PWCHAR KeyValue;
   NTSTATUS Status;
@@ -3043,7 +2961,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
    */
   do
     {
-      if (!InfGetData (&CabinetsContext, NULL, &KeyValue))
+      if (!InfGetData (CabinetsContext, NULL, &KeyValue))
        break;
 
       wcscpy(PathBuffer, SourcePath.Buffer);
@@ -3120,7 +3038,9 @@ PrepareCopyPage(PINPUT_RECORD Ir)
           return QUIT_PAGE;
         }
     }
-  while (InfFindNextLine (&CabinetsContext, &CabinetsContext));
+  while (InfFindNextLine (CabinetsContext, CabinetsContext));
+
+  InfFreeContext(CabinetsContext);
 
   return FILE_COPY_PAGE;
 }
@@ -3198,7 +3118,7 @@ FileCopyPage(PINPUT_RECORD Ir)
 static PAGE_NUMBER
 RegistryPage(PINPUT_RECORD Ir)
 {
-  INFCONTEXT InfContext;
+  PINFCONTEXT InfContext;
   PWSTR Action;
   PWSTR File;
   PWSTR Section;
@@ -3267,9 +3187,9 @@ RegistryPage(PINPUT_RECORD Ir)
 
   do
     {
-      InfGetDataField (&InfContext, 0, &Action);
-      InfGetDataField (&InfContext, 1, &File);
-      InfGetDataField (&InfContext, 2, &Section);
+      InfGetDataField (InfContext, 0, &Action);
+      InfGetDataField (InfContext, 1, &File);
+      InfGetDataField (InfContext, 2, &Section);
 
       DPRINT("Action: %S  File: %S  Section %S\n", Action, File, Section);
 
@@ -3306,7 +3226,9 @@ RegistryPage(PINPUT_RECORD Ir)
            }
        }
     }
-  while (InfFindNextLine (&InfContext, &InfContext));
+  while (InfFindNextLine (InfContext, InfContext));
+
+  InfFreeContext(InfContext);
 
   /* Update display registry settings */
   SetStatusText("   Updating display registry settings...");
@@ -3344,23 +3266,8 @@ RegistryPage(PINPUT_RECORD Ir)
        }
     }
 
-  /* Update mouse registry settings */
-  SetStatusText("   Updating mouse registry settings...");
-  if (!ProcessMouseRegistry(SetupInf, PointerList))
-    {
-      PopupError("Setup failed to update mouse registry settings.",
-                "ENTER = Reboot computer");
-
-      while(TRUE)
-       {
-         ConInKey(Ir);
-
-         if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)       /* ENTER */
-           {
-             return QUIT_PAGE;
-           }
-       }
-    }
+  /* Update the mounted devices list */
+  SetMountedDeviceValues(PartitionList);
 
   SetStatusText("   Done...");
 
@@ -3428,6 +3335,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
 
   SetTextXY(8, 12, "Install bootloader on the harddisk (MBR).");
   SetTextXY(8, 13, "Install bootloader on a floppy disk.");
+  SetTextXY(8, 14, "Skip install bootloader.");
   InvertTextXY (8, Line, 48, 1);
 
   SetStatusText("   ENTER = Continue   F3 = Quit");
@@ -3440,28 +3348,25 @@ BootLoaderPage(PINPUT_RECORD Ir)
          (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
        {
          NormalTextXY (8, Line, 48, 1);
-         if (Line == 12)
-           Line = 13;
-         else if (Line == 13)
-           Line = 12;
-#if 0
-         else
-           Line++;
-#endif
+         
+         Line++;
+      if (Line<12) Line=14;
+      if (Line>14) Line=12;
+        
+       
+
          InvertTextXY (8, Line, 48, 1);
        }
       else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
               (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
        {
          NormalTextXY (8, Line, 48, 1);
-         if (Line == 12)
-           Line = 13;
-         else if (Line == 13)
-           Line = 12;
-#if 0
-         else
-           Line--;
-#endif
+         
+         Line--;
+      if (Line<12) Line=14;
+      if (Line>14) Line=12;
+
+
          InvertTextXY (8, Line, 48, 1);
        }
       else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
@@ -3481,6 +3386,10 @@ BootLoaderPage(PINPUT_RECORD Ir)
            {
              return BOOT_LOADER_FLOPPY_PAGE;
            }
+      else if (Line == 14)
+           {
+              return SUCCESS_PAGE;;
+           }
 
          return BOOT_LOADER_PAGE;
        }
@@ -3660,13 +3569,6 @@ QuitPage(PINPUT_RECORD Ir)
       LayoutList = NULL;
     }
 
-  /* Destroy pointer device list */
-  if (PointerList != NULL)
-    {
-      DestroyGenericList(PointerList, TRUE);
-      PointerList = NULL;
-    }
-
   SetStatusText("   ENTER = Reboot computer");
 
   while(TRUE)
@@ -3729,13 +3631,12 @@ SignalInitEvent()
 {
   NTSTATUS Status;
   OBJECT_ATTRIBUTES ObjectAttributes;
-  UNICODE_STRING UnicodeString;
+  UNICODE_STRING UnicodeString = RTL_CONSTANT_STRING(L"\\ReactOSInitDone");
   HANDLE ReactOSInitEvent;
 
-  RtlRosInitUnicodeStringFromLiteral(&UnicodeString, L"\\ReactOSInitDone");
   InitializeObjectAttributes(&ObjectAttributes,
     &UnicodeString,
-    EVENT_ALL_ACCESS,
+    0,
     0,
     NULL);
   Status = NtOpenEvent(&ReactOSInitEvent,
@@ -3771,13 +3672,16 @@ NtProcessStartup(PPEB Peb)
   RtlNormalizeProcessParams(Peb->ProcessParameters);
 
   ProcessHeap = Peb->ProcessHeap;
+  InfSetHeap(ProcessHeap);
 
   SignalInitEvent();
 
   Status = AllocConsole();
   if (!NT_SUCCESS(Status))
     {
-      PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status);
+      PrintString("Unable to open the console (Status = 0x%08lx)\n\n", Status);
+      PrintString("The most common cause of this is using an USB keyboard\n");
+      PrintString("USB keyboards are not fully supported yet\n");
 
       /* Raise a hard error (crash the system/BSOD) */
       NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
@@ -3808,7 +3712,7 @@ NtProcessStartup(PPEB Peb)
        {
          /* Start page */
          case START_PAGE:
-           Page = StartPage(&Ir);
+           Page = SetupStartPage(&Ir);
            break;
 
          /* License page */
@@ -3863,10 +3767,6 @@ NtProcessStartup(PPEB Peb)
            Page = LayoutSettingsPage(&Ir);
            break;
 
-         case POINTER_SETTINGS_PAGE:
-           Page = PointerSettingsPage(&Ir);
-           break;
-
          case SELECT_PARTITION_PAGE:
            Page = SelectPartitionPage(&Ir);
            break;