ReactOS 0.4.16-dev-2110-ge3521eb
settings.c File Reference
#include <freeldr.h>
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

static VOID CmdLineParse (_In_ PCSTR CmdLine)
 
VOID LoadSettings (_In_opt_ PCSTR CmdLine)
 
PBOOTMGRINFO GetBootMgrInfo (VOID)
 

Variables

static CCHAR DebugString [256]
 
static CCHAR VideoOptions [128]
 
static CCHAR DefaultOs [256]
 
BOOTMGRINFO BootMgrInfo = {NULL, NULL, NULL, -1, 0}
 

Function Documentation

◆ CmdLineParse()

static VOID CmdLineParse ( _In_ PCSTR  CmdLine)
static

Definition at line 24 of file settings.c.

26{
27 PCHAR Setting;
28 size_t Length;
29 ULONG_PTR Offset = 0;
30
31 /*
32 * Get the debug string, in the following format:
33 * "debug=option1=XXX;option2=YYY;..."
34 * and translate it into the format:
35 * "OPTION1=XXX OPTION2=YYY ..."
36 */
37 Setting = strstr(CmdLine, "debug=");
38 if (Setting)
39 {
40 /* Check if there are more command-line parameters following */
41 Setting += sizeof("debug=") - sizeof(ANSI_NULL);
42 Length = strcspn(Setting, " \t");
43
44 /* Copy the debug string and upcase it */
47
48 /* Replace all separators ';' by spaces */
49 Setting = DebugString;
50 while (*Setting)
51 {
52 if (*Setting == ';') *Setting = ' ';
53 Setting++;
54 }
55
57 }
58
59 /* Get the video options */
60 Setting = strstr(CmdLine, "video=");
61 if (Setting)
62 {
63 Setting += sizeof("video=") - sizeof(ANSI_NULL);
64 }
65#if (defined(_M_IX86) || defined(_M_AMD64)) && !defined(SARCH_XBOX) && !defined(SARCH_PC98)
66 else
67 {
68 Setting = strstr(CmdLine, "vga=");
69 if (Setting)
70 Setting += sizeof("vga=") - sizeof(ANSI_NULL);
71 }
72#endif
73 if (Setting)
74 {
75 /* Check if there are more command-line parameters following */
76 Length = strcspn(Setting, " \t");
77
78 /* Copy the string */
81 }
82
83 /* Get the timeout */
84 Setting = strstr(CmdLine, "timeout=");
85 if (Setting)
86 {
87 BootMgrInfo.TimeOut = atoi(Setting +
88 sizeof("timeout=") - sizeof(ANSI_NULL));
89 }
90
91 /* Get the default OS */
92 Setting = strstr(CmdLine, "defaultos=");
93 if (Setting)
94 {
95 /* Check if there are more command-line parameters following */
96 Setting += sizeof("defaultos=") - sizeof(ANSI_NULL);
97 Length = strcspn(Setting, " \t");
98
99 /* Copy the default OS */
100 RtlStringCbCopyNA(DefaultOs, sizeof(DefaultOs), Setting, Length);
102 }
103
104 /* Get the ramdisk base address */
105 Setting = strstr(CmdLine, "rdbase=");
106 if (Setting)
107 {
109 (PVOID)(ULONG_PTR)strtoull(Setting +
110 sizeof("rdbase=") - sizeof(ANSI_NULL),
111 NULL, 0);
112 }
113
114 /* Get the ramdisk size */
115 Setting = strstr(CmdLine, "rdsize=");
116 if (Setting)
117 {
118 gInitRamDiskSize = strtoul(Setting +
119 sizeof("rdsize=") - sizeof(ANSI_NULL),
120 NULL, 0);
121 }
122
123 /* Get the ramdisk offset */
124 Setting = strstr(CmdLine, "rdoffset=");
125 if (Setting)
126 {
127 Offset = strtoul(Setting +
128 sizeof("rdoffset=") - sizeof(ANSI_NULL),
129 NULL, 0);
130 }
131
132 /* Fix it up */
134}
PVOID gInitRamDiskBase
Definition: ramdisk.c:20
ULONG gInitRamDiskSize
Definition: ramdisk.c:21
static CCHAR VideoOptions[128]
Definition: settings.c:17
static CCHAR DebugString[256]
Definition: settings.c:16
BOOTMGRINFO BootMgrInfo
Definition: settings.c:19
static CCHAR DefaultOs[256]
Definition: settings.c:18
#define NULL
Definition: types.h:112
_ACRTIMP int __cdecl atoi(const char *)
Definition: string.c:1715
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
Definition: string.c:1859
_ACRTIMP size_t __cdecl strcspn(const char *, const char *)
Definition: string.c:3493
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415
static const WCHAR CmdLine[]
Definition: install.c:48
#define ANSI_NULL
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTRSAFEAPI RtlStringCbCopyNA(_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:395
_strupr
Definition: string.h:453
#define strtoull
Definition: stabs.c:58
PCSTR VideoOptions
Definition: settings.h:13
PCSTR DefaultOs
Definition: settings.h:14
LONG TimeOut
Definition: settings.h:15
PCSTR DebugString
Definition: settings.h:12
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
char * PCHAR
Definition: typedefs.h:51

Referenced by LoadSettings().

◆ GetBootMgrInfo()

PBOOTMGRINFO GetBootMgrInfo ( VOID  )

Definition at line 215 of file settings.c.

216{
217 return &BootMgrInfo;
218}

Referenced by InitOperatingSystemList(), MainBootMenuKeyPressFilter(), and RunLoader().

◆ LoadSettings()

VOID LoadSettings ( _In_opt_ PCSTR  CmdLine)

Definition at line 137 of file settings.c.

139{
140 /* Pre-initialization: The settings originate from the command-line.
141 * Main initialization: Overwrite them if needed with those from freeldr.ini */
142 if (CmdLine)
143 {
145 return;
146 }
148 {
149 // ERR("LoadSettings() called but no freeldr.ini\n");
150 return;
151 }
152
153 BOOLEAN FoundLoaderSection = FALSE;
154 PCSTR LoaderSections[] = {
155 "FreeLoader",
156 "Boot Loader",
157 "FlexBoot",
158 "MultiBoot",
159 };
160
161 /* Search for the first section in LoaderSections and load the settings,
162 * prioritizing the order in the file.
163 * If a section is already loaded, skip further checks. */
165 {
166 for (ULONG i = 0; i < sizeof(LoaderSections) / sizeof(LoaderSections[0]); i++)
167 {
168 PCSTR Section = LoaderSections[i];
169
171 {
172 FoundLoaderSection = TRUE;
173 break;
174 }
175 }
176
177 if (!FoundLoaderSection)
178 {
179 UiMessageBoxCritical("Bootloader Section not found in freeldr.ini");
180 return;
181 }
182 }
183
184 /* Get the debug string. Always override it with the one from freeldr.ini */
186 DebugString, sizeof(DebugString)))
187 {
189 }
190
191 /* Get the timeout. Keep the existing one if it is valid,
192 * otherwise retrieve it from freeldr.ini */
193 if (BootMgrInfo.TimeOut < 0)
194 {
195 CHAR TimeOutText[20];
196 BootMgrInfo.TimeOut = -1;
198 TimeOutText, sizeof(TimeOutText)))
199 {
200 BootMgrInfo.TimeOut = atoi(TimeOutText);
201 }
202 }
203
204 /* Get the default OS */
206 {
208 DefaultOs, sizeof(DefaultOs)))
209 {
211 }
212 }
213}
unsigned char BOOLEAN
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
static VOID CmdLineParse(_In_ PCSTR CmdLine)
Definition: settings.c:24
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOLEAN IniReadSettingByName(ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize)
Definition: inifile.c:154
BOOLEAN IniOpenSection(PCSTR SectionName, ULONG_PTR *SectionId)
Definition: inifile.c:30
PLIST_ENTRY IniGetFileSectionListHead(VOID)
Definition: inifile.c:25
ULONG_PTR FrLdrSection
Definition: settings.h:16
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
char CHAR
Definition: xmlstorage.h:175

Variable Documentation

◆ BootMgrInfo

BOOTMGRINFO BootMgrInfo = {NULL, NULL, NULL, -1, 0}

Definition at line 19 of file settings.c.

Referenced by BootMain(), CmdLineParse(), EfiEntry(), GetBootMgrInfo(), LoadSettings(), and PcVideoInit().

◆ DebugString

◆ DefaultOs

CCHAR DefaultOs[256]
static

Definition at line 18 of file settings.c.

Referenced by CmdLineParse(), and LoadSettings().

◆ VideoOptions

CCHAR VideoOptions[128]
static

Definition at line 17 of file settings.c.

Referenced by CmdLineParse().