ReactOS  0.4.15-dev-1632-g4e289ce
ini_init.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for ini_init.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (INIFILE)
 
BOOLEAN IniFileInitialize (VOID)
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( INIFILE  )

◆ IniFileInitialize()

BOOLEAN IniFileInitialize ( VOID  )

Definition at line 25 of file ini_init.c.

26 {
28  ULONG FileId; // File handle for freeldr.ini
29  PCHAR FreeLoaderIniFileData;
30  ULONG FreeLoaderIniFileSize, Count;
33 
34  TRACE("IniFileInitialize()\n");
35 
36  /* Try to open freeldr.ini */
37  Status = FsOpenFile("freeldr.ini", FrLdrBootPath, OpenReadOnly, &FileId);
38  if (Status != ESUCCESS)
39  {
40  ERR("Error while opening freeldr.ini, Status: %d\n", Status);
41  UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to re-install FreeLoader.");
42  return FALSE;
43  }
44 
45  /* Get the file size */
47  if (Status != ESUCCESS || FileInformation.EndingAddress.HighPart != 0)
48  {
49  UiMessageBoxCritical("Error while getting informations about freeldr.ini.\nYou need to re-install FreeLoader.");
50  ArcClose(FileId);
51  return FALSE;
52  }
53  FreeLoaderIniFileSize = FileInformation.EndingAddress.LowPart;
54 
55  /* Allocate memory to cache the whole freeldr.ini */
56  FreeLoaderIniFileData = FrLdrTempAlloc(FreeLoaderIniFileSize, TAG_INI_FILE);
57  if (!FreeLoaderIniFileData)
58  {
59  UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
60  ArcClose(FileId);
61  return FALSE;
62  }
63 
64  /* Load freeldr.ini from the disk */
65  Status = ArcRead(FileId, FreeLoaderIniFileData, FreeLoaderIniFileSize, &Count);
66  if (Status != ESUCCESS || Count != FreeLoaderIniFileSize)
67  {
68  ERR("Error while reading freeldr.ini, Status: %d\n", Status);
69  UiMessageBoxCritical("Error while reading freeldr.ini.");
70  ArcClose(FileId);
71  FrLdrTempFree(FreeLoaderIniFileData, TAG_INI_FILE);
72  return FALSE;
73  }
74 
75  /* Parse the .ini file data */
76  Success = IniParseFile(FreeLoaderIniFileData, FreeLoaderIniFileSize);
77 
78  /* Do some cleanup, and return */
79  ArcClose(FileId);
80  FrLdrTempFree(FreeLoaderIniFileData, TAG_INI_FILE);
81 
82  return Success;
83 }
signed char * PCHAR
Definition: retypes.h:7
Definition: arc.h:32
BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
Definition: parse.c:31
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
ULONG ARC_STATUS
Definition: arc.h:4
ARC_STATUS FsOpenFile(IN PCSTR FileName, IN PCSTR DefaultPath OPTIONAL, IN OPENMODE OpenMode, OUT PULONG FileId)
Definition: fs.c:266
#define FALSE
Definition: types.h:117
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
unsigned char BOOLEAN
Status
Definition: gdiplustypes.h:24
int Count
Definition: noreturn.cpp:7
#define TRACE(s)
Definition: solgame.cpp:4
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
#define ERR(fmt,...)
Definition: debug.h:110
#define TAG_INI_FILE
Definition: inifile.h:24
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
unsigned int ULONG
Definition: retypes.h:1
CHAR FrLdrBootPath[MAX_PATH]
Definition: mach.c:34
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:331
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by RunLoader().