ReactOS  0.4.11-dev-721-g95bc44e
oslist.c File Reference
#include <freeldr.h>
Include dependency graph for oslist.c:

Go to the source code of this file.

Macros

#define TAG_STRING   ' rtS'
 
#define TAG_OS_ITEM   'tISO'
 

Functions

static PCSTR CopyString (PCSTR Source)
 
OperatingSystemItemInitOperatingSystemList (ULONG *OperatingSystemCountPointer)
 

Macro Definition Documentation

#define TAG_OS_ITEM   'tISO'

Definition at line 25 of file oslist.c.

Referenced by InitOperatingSystemList().

Function Documentation

static PCSTR CopyString ( PCSTR  Source)
static

Definition at line 29 of file oslist.c.

Referenced by InitOperatingSystemList().

30 {
31  PSTR Dest;
32 
33  if (!Source)
34  return NULL;
35 
36  Dest = FrLdrHeapAlloc(strlen(Source) + 1, TAG_STRING);
37  if (Dest)
38  strcpy(Dest, Source);
39 
40  return Dest;
41 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TAG_STRING
Definition: oslist.c:24
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
signed char * PSTR
Definition: retypes.h:7
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
OperatingSystemItem* InitOperatingSystemList ( ULONG OperatingSystemCountPointer)

Definition at line 43 of file oslist.c.

Referenced by RunLoader().

44 {
45  ULONG Idx;
46  CHAR SettingName[260];
47  CHAR SettingValue[260];
48  ULONG_PTR SectionId;
49  PCHAR TitleStart, TitleEnd;
50  PCSTR OsLoadOptions;
51  ULONG Count;
52  OperatingSystemItem* Items;
53 
54  /* Open the [FreeLoader] section */
55  if (!IniOpenSection("Operating Systems", &SectionId))
56  return NULL;
57 
58  /* Count number of operating systems in the section */
59  Count = IniGetNumSectionItems(SectionId);
60 
61  /* Allocate memory to hold operating system lists */
62  Items = FrLdrHeapAlloc(Count * sizeof(OperatingSystemItem), TAG_OS_ITEM);
63  if (!Items)
64  return NULL;
65 
66  /* Now loop through and read the operating system section and display names */
67  for (Idx = 0; Idx < Count; Idx++)
68  {
69  IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue));
70 
71  /* Search start and end of the title */
72  OsLoadOptions = NULL;
73  TitleStart = SettingValue;
74  while (*TitleStart == ' ' || *TitleStart == '"')
75  TitleStart++;
76  TitleEnd = TitleStart;
77  if (*TitleEnd != ANSI_NULL)
78  TitleEnd++;
79  while (*TitleEnd != ANSI_NULL && *TitleEnd != '"')
80  TitleEnd++;
81  if (*TitleEnd != ANSI_NULL)
82  {
83  *TitleEnd = ANSI_NULL;
84  OsLoadOptions = TitleEnd + 1;
85  }
86 
87  /* Copy the system partition, identifier and options */
88  Items[Idx].SystemPartition = CopyString(SettingName);
89  Items[Idx].LoadIdentifier = CopyString(TitleStart);
90  Items[Idx].OsLoadOptions = CopyString(OsLoadOptions);
91  }
92 
93  /* Return success */
94  *OperatingSystemCountPointer = Count;
95  return Items;
96 }
signed char * PCHAR
Definition: retypes.h:7
const char * PCSTR
Definition: typedefs.h:51
char CHAR
Definition: xmlstorage.h:175
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
BOOLEAN IniOpenSection(PCSTR SectionName, ULONG_PTR *SectionId)
Definition: inifile.c:25
static PCSTR CopyString(PCSTR Source)
Definition: oslist.c:29
unsigned int ULONG
Definition: retypes.h:1
ULONG IniGetNumSectionItems(ULONG_PTR SectionId)
Definition: inifile.c:54
#define TAG_OS_ITEM
Definition: oslist.c:25
BOOLEAN IniReadSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize)
Definition: inifile.c:114