Author: hbelusca
Date: Wed Dec 30 18:26:42 2015
New Revision: 70467

URL: http://svn.reactos.org/svn/reactos?rev=70467&view=rev
Log:
[USETUP]
Factorize the code that creates ReactOS freeldr.ini entries, and use it to 
create a freeldr.ini at a clean ReactOS installation, and when it is installed 
in the same partition as Win9x/DOS.
CORE-4870 #comment Should be fixed with revision 70467, please retest.

Modified:
    trunk/reactos/base/setup/usetup/bootsup.c
    trunk/reactos/base/setup/usetup/inicache.c
    trunk/reactos/base/setup/usetup/inicache.h

Modified: trunk/reactos/base/setup/usetup/bootsup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/bootsup.c?rev=70467&r1=70466&r2=70467&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/bootsup.c   [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/bootsup.c   [iso-8859-1] Wed Dec 30 
18:26:42 2015
@@ -93,8 +93,7 @@
     PINICACHESECTION IniSection;
 
     /* Create "FREELOADER" section */
-    IniSection = IniCacheAppendSection(IniCache,
-                                       L"FREELOADER");
+    IniSection = IniCacheAppendSection(IniCache, L"FREELOADER");
 
 #if DBG
     if (IsUnattendedSetup)
@@ -287,123 +286,6 @@
                       L"TimeText",
                       L"Seconds until highlighted choice will be started 
automatically:   ");
 }
-
-
-NTSTATUS
-CreateFreeLoaderIniForDos(
-    PWCHAR IniPath,
-    PWCHAR ArcPath)
-{
-    PINICACHE IniCache;
-    PINICACHESECTION IniSection;
-
-    IniCache = IniCacheCreate();
-
-    CreateCommonFreeLoaderSections(IniCache);
-
-    /* Create "Operating Systems" section */
-    IniSection = IniCacheAppendSection(IniCache, L"Operating Systems");
-
-    /* REACTOS=ReactOS */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"ReactOS",
-                      L"\"ReactOS\"");
-
-    /* ReactOS_Debug="ReactOS (Debug)" */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"ReactOS_Debug",
-                      L"\"ReactOS (Debug)\"");
-
-    /* DOS=Dos/Windows */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"DOS",
-                      L"\"DOS/Windows\"");
-
-    /* Create "ReactOS" section */
-    IniSection = IniCacheAppendSection(IniCache, L"ReactOS");
-
-    /* BootType=ReactOS */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"BootType",
-                      L"ReactOS");
-
-    /* SystemPath=<ArcPath> */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"SystemPath",
-                      ArcPath);
-
-    /* Create "ReactOS_Debug" section */
-    IniSection = IniCacheAppendSection(IniCache, L"ReactOS_Debug");
-
-    /* BootType=ReactOS */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"BootType",
-                      L"ReactOS");
-
-    /* SystemPath=<ArcPath> */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"SystemPath",
-                      ArcPath);
-
-    /* Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"Options",
-                      L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS");
-
-    /* Create "DOS" section */
-    IniSection = IniCacheAppendSection(IniCache,
-                                       L"DOS");
-
-    /* BootType=BootSector */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"BootType",
-                      L"BootSector");
-
-    /* BootDrive=hd0 */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"BootDrive",
-                      L"hd0");
-
-    /* BootPartition=1 */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"BootPartition",
-                      L"1");
-
-    /* BootSector=BOOTSECT.DOS */
-    IniCacheInsertKey(IniSection,
-                      NULL,
-                      INSERT_LAST,
-                      L"BootSectorFile",
-                      L"BOOTSECT.DOS");
-
-    IniCacheSave(IniCache, IniPath);
-    IniCacheDestroy(IniCache);
-
-    return STATUS_SUCCESS;
-}
-
 
 NTSTATUS
 CreateFreeLoaderEntry(
@@ -451,17 +333,13 @@
     return STATUS_SUCCESS;
 }
 
-NTSTATUS
-CreateFreeLoaderIniForReactOS(
-    PWCHAR IniPath,
+static
+VOID
+CreateFreeLoaderReactOSEntries(
+    PINICACHE IniCache,
     PWCHAR ArcPath)
 {
-    PINICACHE IniCache;
     PINICACHESECTION IniSection;
-
-    IniCache = IniCacheCreate();
-
-    CreateCommonFreeLoaderSections(IniCache);
 
     /* Create "Operating Systems" section */
     IniSection = IniCacheAppendSection(IniCache, L"Operating Systems");
@@ -517,8 +395,90 @@
                           L"Windows2003", ArcPath,
                           L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS 
/redirect=com2 /redirectbaudrate=115200");
 #endif
-
-    /* Save the ini file */
+}
+
+NTSTATUS
+CreateFreeLoaderIniForReactOS(
+    PWCHAR IniPath,
+    PWCHAR ArcPath)
+{
+    PINICACHE IniCache;
+
+    /* Initialize the INI file */
+    IniCache = IniCacheCreate();
+
+    /* Create the common FreeLdr sections */
+    CreateCommonFreeLoaderSections(IniCache);
+
+    /* Add the ReactOS entries */
+    CreateFreeLoaderReactOSEntries(IniCache, ArcPath);
+
+    /* Save the INI file */
+    IniCacheSave(IniCache, IniPath);
+    IniCacheDestroy(IniCache);
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+CreateFreeLoaderIniForDos(
+    PWCHAR IniPath,
+    PWCHAR ArcPath)
+{
+    PINICACHE IniCache;
+    PINICACHESECTION IniSection;
+
+    /* Initialize the INI file */
+    IniCache = IniCacheCreate();
+
+    /* Create the common FreeLdr sections */
+    CreateCommonFreeLoaderSections(IniCache);
+
+    /* Add the ReactOS entries */
+    CreateFreeLoaderReactOSEntries(IniCache, ArcPath);
+
+    /* Get "Operating Systems" section */
+    IniSection = IniCacheGetSection(IniCache, L"Operating Systems");
+
+    /* DOS=DOS/Windows */
+    IniCacheInsertKey(IniSection,
+                      NULL,
+                      INSERT_LAST,
+                      L"DOS",
+                      L"\"DOS/Windows\"");
+
+    /* Create the "DOS" section */
+    IniSection = IniCacheAppendSection(IniCache, L"DOS");
+
+    /* BootType=BootSector */
+    IniCacheInsertKey(IniSection,
+                      NULL,
+                      INSERT_LAST,
+                      L"BootType",
+                      L"BootSector");
+
+    /* BootDrive=hd0 */
+    IniCacheInsertKey(IniSection,
+                      NULL,
+                      INSERT_LAST,
+                      L"BootDrive",
+                      L"hd0");
+
+    /* BootPartition=1 */
+    IniCacheInsertKey(IniSection,
+                      NULL,
+                      INSERT_LAST,
+                      L"BootPartition",
+                      L"1");
+
+    /* BootSector=BOOTSECT.DOS */
+    IniCacheInsertKey(IniSection,
+                      NULL,
+                      INSERT_LAST,
+                      L"BootSectorFile",
+                      L"BOOTSECT.DOS");
+
+    /* Save the INI file */
     IniCacheSave(IniCache, IniPath);
     IniCacheDestroy(IniCache);
 
@@ -531,7 +491,6 @@
     PWCHAR IniPath,
     PWCHAR ArcPath)
 {
-    UNICODE_STRING Name;
     PINICACHE IniCache;
     PINICACHESECTION IniSection;
     PINICACHESECTION OsIniSection;
@@ -543,9 +502,7 @@
     ULONG i,j;
     NTSTATUS Status;
 
-    RtlInitUnicodeString(&Name, IniPath);
-
-    Status = IniCacheLoad(&IniCache, &Name, FALSE);
+    Status = IniCacheLoad(&IniCache, IniPath, FALSE);
     if (!NT_SUCCESS(Status))
         return Status;
 
@@ -1944,16 +1901,13 @@
     PWSTR EntryName,
     PWSTR EntryValue)
 {
-    UNICODE_STRING Name;
     PINICACHE Cache = NULL;
     PINICACHESECTION Section = NULL;
     NTSTATUS Status;
     ULONG FileAttribute;
     PWCHAR OldValue = NULL;
 
-    RtlInitUnicodeString(&Name, BootIniPath);
-
-    Status = IniCacheLoad(&Cache, &Name, FALSE);
+    Status = IniCacheLoad(&Cache, BootIniPath, FALSE);
     if (!NT_SUCCESS(Status))
     {
         return Status;

Modified: trunk/reactos/base/setup/usetup/inicache.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/inicache.c?rev=70467&r1=70466&r2=70467&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/inicache.c  [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/inicache.c  [iso-8859-1] Wed Dec 30 
18:26:42 2015
@@ -514,9 +514,10 @@
 NTSTATUS
 IniCacheLoad(
     PINICACHE *Cache,
-    PUNICODE_STRING FileName,
+    PWCHAR FileName,
     BOOLEAN String)
 {
+    UNICODE_STRING Name;
     OBJECT_ATTRIBUTES ObjectAttributes;
     FILE_STANDARD_INFORMATION FileInfo;
     IO_STATUS_BLOCK IoStatusBlock;
@@ -542,8 +543,10 @@
     *Cache = NULL;
 
     /* Open ini file */
+    RtlInitUnicodeString(&Name, FileName);
+
     InitializeObjectAttributes(&ObjectAttributes,
-                               FileName,
+                               &Name,
                                0,
                                NULL,
                                NULL);
@@ -1066,8 +1069,7 @@
     }
 
     /* Create ini file */
-    RtlInitUnicodeString(&Name,
-                         FileName);
+    RtlInitUnicodeString(&Name, FileName);
 
     InitializeObjectAttributes(&ObjectAttributes,
                                &Name,

Modified: trunk/reactos/base/setup/usetup/inicache.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/inicache.h?rev=70467&r1=70466&r2=70467&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/inicache.h  [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/inicache.h  [iso-8859-1] Wed Dec 30 
18:26:42 2015
@@ -76,7 +76,7 @@
 NTSTATUS
 IniCacheLoad(
     PINICACHE *Cache,
-    PUNICODE_STRING FileName,
+    PWCHAR FileName,
     BOOLEAN String);
 
 VOID


Reply via email to