[ros-diffs] [hpoussin] 43467: [freeldr] List in menu all entries from [Operating Systems] section, even if they don't have an associated section Try to infer the boot type if not specified See issue #4455 for more details.

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Wed Oct 14 23:04:44 CEST 2009


Author: hpoussin
Date: Wed Oct 14 23:04:44 2009
New Revision: 43467

URL: http://svn.reactos.org/svn/reactos?rev=43467&view=rev
Log:
[freeldr] List in menu all entries from [Operating Systems] section, even if they don't have an associated section
Try to infer the boot type if not specified
See issue #4455 for more details.

Modified:
    trunk/reactos/boot/freeldr/freeldr/bootmgr.c
    trunk/reactos/boot/freeldr/freeldr/oslist.c
    trunk/reactos/boot/freeldr/freeldr/ui/ui.c

Modified: trunk/reactos/boot/freeldr/freeldr/bootmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/bootmgr.c?rev=43467&r1=43466&r2=43467&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] Wed Oct 14 23:04:44 2009
@@ -21,12 +21,12 @@
 
 VOID RunLoader(VOID)
 {
-	CHAR	SettingName[80];
 	CHAR	SettingValue[80];
 	ULONG_PTR	SectionId;
 	ULONG		OperatingSystemCount;
 	PCSTR	*OperatingSystemSectionNames;
 	PCSTR	*OperatingSystemDisplayNames;
+	PCSTR SectionName;
 	ULONG		DefaultOperatingSystem;
 	LONG		TimeOut;
 	ULONG		SelectedOperatingSystem;
@@ -93,28 +93,48 @@
 		TimeOut = -1;
 
 		// Try to open the operating system section in the .ini file
-		if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
-		{
-			sprintf(SettingName, "Section [%s] not found in freeldr.ini.", OperatingSystemSectionNames[SelectedOperatingSystem]);
-			UiMessageBox(SettingName);
-			continue;
-		}
-
-		// Try to read the boot type
-		if (!IniReadSettingByName(SectionId, "BootType", SettingValue, sizeof(SettingValue)))
-		{
-			sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.", OperatingSystemSectionNames[SelectedOperatingSystem]);
-			UiMessageBox(SettingName);
-			continue;
+		SettingValue[0] = ANSI_NULL;
+		SectionName = OperatingSystemSectionNames[SelectedOperatingSystem];
+		if (IniOpenSection(SectionName, &SectionId))
+		{
+			// Try to read the boot type
+			IniReadSettingByName(SectionId, "BootType", SettingValue, sizeof(SettingValue));
+		}
+
+		if (SettingValue[0] == ANSI_NULL && SectionName[0] != ANSI_NULL)
+		{
+			// Try to infere boot type value
+#ifdef __i386__
+			CHAR LastChar;
+			LastChar = SectionName[strlen(SectionName) - 1];
+			if (LastChar == '\\' ||
+			    (strstr(SectionName, ")partition(") != NULL &&
+			     strstr(SectionName, ")partition(0)") == NULL))
+			{
+				strcpy(SettingValue, "Partition");
+			}
+			else if (LastChar == ')' || LastChar == ':')
+			{
+				strcpy(SettingValue, "Drive");
+			}
+			else if (TRUE)
+			{
+				strcpy(SettingValue, "BootSector");
+			}
+			else
+#endif
+			{
+				strcpy(SettingValue, "Windows2003");
+			}
 		}
 
 		// Install the drive mapper according to this sections drive mappings
 #ifdef __i386__
-		DriveMapMapDrivesInSection(OperatingSystemSectionNames[SelectedOperatingSystem]);
+		DriveMapMapDrivesInSection(SectionName);
 #endif
 		if (_stricmp(SettingValue, "ReactOS") == 0)
 		{
-			LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
+			LoadAndBootReactOS(SectionName);
 		}
 #ifdef FREELDR_REACTOS_SETUP
 		else if (_stricmp(SettingValue, "ReactOSSetup") == 0)
@@ -134,27 +154,27 @@
 #ifdef __i386__
 		else if (_stricmp(SettingValue, "WindowsNT40") == 0)
 		{
-			LoadAndBootWindows(OperatingSystemSectionNames[SelectedOperatingSystem], _WIN32_WINNT_NT4);
+			LoadAndBootWindows(SectionName, _WIN32_WINNT_NT4);
 		}
 		else if (_stricmp(SettingValue, "Windows2003") == 0)
 		{
-			LoadAndBootWindows(OperatingSystemSectionNames[SelectedOperatingSystem], _WIN32_WINNT_WS03);
+			LoadAndBootWindows(SectionName, _WIN32_WINNT_WS03);
 		}
 		else if (_stricmp(SettingValue, "Linux") == 0)
 		{
-			LoadAndBootLinux(OperatingSystemSectionNames[SelectedOperatingSystem], OperatingSystemDisplayNames[SelectedOperatingSystem]);
+			LoadAndBootLinux(SectionName, OperatingSystemDisplayNames[SelectedOperatingSystem]);
 		}
 		else if (_stricmp(SettingValue, "BootSector") == 0)
 		{
-			LoadAndBootBootSector(OperatingSystemSectionNames[SelectedOperatingSystem]);
+			LoadAndBootBootSector(SectionName);
 		}
 		else if (_stricmp(SettingValue, "Partition") == 0)
 		{
-			LoadAndBootPartition(OperatingSystemSectionNames[SelectedOperatingSystem]);
+			LoadAndBootPartition(SectionName);
 		}
 		else if (_stricmp(SettingValue, "Drive") == 0)
 		{
-			LoadAndBootDrive(OperatingSystemSectionNames[SelectedOperatingSystem]);
+			LoadAndBootDrive(SectionName);
 		}
 #endif
 	}

Modified: trunk/reactos/boot/freeldr/freeldr/oslist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/oslist.c?rev=43467&r1=43466&r2=43467&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/oslist.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/oslist.c [iso-8859-1] Wed Oct 14 23:04:44 2009
@@ -27,7 +27,6 @@
 	CHAR	SettingValue[260];
 	ULONG		OperatingSystemCount;
 	ULONG_PTR	SectionId;
-	ULONG_PTR	OperatingSystemSectionId;
 	ULONG		SectionSettingCount;
 	PCHAR	*OperatingSystemSectionNames;
 	PCHAR	*OperatingSystemDisplayNames;
@@ -60,17 +59,14 @@
 	{
 		IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue));
 
-		if (IniOpenSection(SettingName, &OperatingSystemSectionId))
-		{
-			// Copy the section name
-			strcpy(OperatingSystemSectionNames[CurrentOperatingSystemIndex], SettingName);
+		// Copy the section name
+		strcpy(OperatingSystemSectionNames[CurrentOperatingSystemIndex], SettingName);
 
-			// Copy the display name
-			RemoveQuotes(SettingValue);
-			strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue);
+		// Copy the display name
+		RemoveQuotes(SettingValue);
+		strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue);
 
-			CurrentOperatingSystemIndex++;
-		}
+		CurrentOperatingSystemIndex++;
 	}
 
 	*OperatingSystemCountPointer = OperatingSystemCount;
@@ -82,32 +78,7 @@
 
 ULONG CountOperatingSystems(ULONG SectionId)
 {
-	ULONG		Idx;
-	CHAR	SettingName[260];
-	CHAR	SettingValue[260];
-	ULONG		OperatingSystemCount = 0;
-	ULONG		SectionSettingCount;
-
-	//
-	// Loop through and count the operating systems
-	//
-	SectionSettingCount = IniGetNumSectionItems(SectionId);
-	for (Idx=0; Idx<SectionSettingCount; Idx++)
-	{
-		IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue));
-
-		if (IniOpenSection(SettingName, NULL))
-		{
-			OperatingSystemCount++;
-		}
-		else
-		{
-			sprintf(SettingName, "Operating System '%s' is listed in\nfreeldr.ini but doesn't have a [section].", SettingValue);
-			UiMessageBox(SettingName);
-		}
-	}
-
-	return OperatingSystemCount;
+	return IniGetNumSectionItems(SectionId);
 }
 
 BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPointer, ULONG OperatingSystemCount)

Modified: trunk/reactos/boot/freeldr/freeldr/ui/ui.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/ui.c?rev=43467&r1=43466&r2=43467&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/ui.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/ui/ui.c [iso-8859-1] Wed Oct 14 23:04:44 2009
@@ -412,8 +412,6 @@
 
 	if (!IniOpenSection(SectionName, &SectionId))
 	{
-		sprintf(SettingName, "Section %s not found in freeldr.ini.\n", SectionName);
-		UiMessageBox(SettingName);
 		return;
 	}
 




More information about the Ros-diffs mailing list