Author: hpoussin
Date: Sat Aug 8 19:08:51 2009
New Revision: 42527
URL:
http://svn.reactos.org/svn/reactos?rev=42527&view=rev
Log:
Read freeldr.ini file using ARC file infrastructure
Modified:
trunk/reactos/boot/freeldr/freeldr/include/inifile.h
trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/inifile.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/inifile.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/inifile.h [iso-8859-1] Sat Aug 8 19:08:51
2009
@@ -54,8 +54,6 @@
extern ULONG IniFileSectionCount;
extern ULONG IniFileSettingCount;
-PFILE IniOpenIniFile();
-
BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize);
ULONG IniGetNextLineSize(PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset);
ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG
BufferSize, ULONG CurrentOffset);
Modified: trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inifi…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/inifile/ini_init.c [iso-8859-1] Sat Aug 8 19:08:51
2009
@@ -1,6 +1,6 @@
/*
* FreeLoader
- * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com>
+ * Copyright (C) 2009 Hervé Poussineau <hpoussin(a)reactos.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,58 +19,86 @@
#include <freeldr.h>
+static LONG IniOpenIniFile(ULONG* FileId)
+{
+ CHAR FreeldrPath[MAX_PATH];
+ LONG ret;
+
+ //
+ // Create full freeldr.ini path
+ //
+ MachDiskGetBootPath(FreeldrPath, sizeof(FreeldrPath));
+ strcat(FreeldrPath, "\\freeldr.ini");
+
+ // Try to open freeldr.ini
+ ret = ArcOpen(FreeldrPath, OpenReadOnly, FileId);
+
+ return ret;
+}
+
BOOLEAN IniFileInitialize(VOID)
{
- PFILE Freeldr_Ini; // File handle for freeldr.ini
- PCHAR FreeLoaderIniFileData;
- ULONG FreeLoaderIniFileSize;
- BOOLEAN Success;
+ FILEINFORMATION FileInformation;
+ ULONG FileId; // File handle for freeldr.ini
+ PCHAR FreeLoaderIniFileData;
+ ULONG FreeLoaderIniFileSize, Count;
+ LONG ret;
+ BOOLEAN Success;
+ //
// Open freeldr.ini
- Freeldr_Ini = IniOpenIniFile();
-
- if (Freeldr_Ini == NULL)
+ //
+ ret = IniOpenIniFile(&FileId);
+ if (ret != ESUCCESS)
{
UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to
re-install FreeLoader.");
return FALSE;
}
- // Get the file size & allocate enough memory for it
- FreeLoaderIniFileSize = FsGetFileSize(Freeldr_Ini);
+ //
+ // Get the file size
+ //
+ ret = ArcGetFileInformation(FileId, &FileInformation);
+ if (ret != ESUCCESS || FileInformation.EndingAddress.HighPart != 0)
+ {
+ UiMessageBoxCritical("Error while getting informations about freeldr.ini.\nYou
need to re-install FreeLoader.");
+ return FALSE;
+ }
+ FreeLoaderIniFileSize = FileInformation.EndingAddress.LowPart;
+
+ //
+ // Allocate memory to cache the whole freeldr.ini
+ //
FreeLoaderIniFileData = MmHeapAlloc(FreeLoaderIniFileSize);
-
- // If we are out of memory then return FALSE
- if (FreeLoaderIniFileData == NULL)
+ if (!FreeLoaderIniFileData)
{
UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
- FsCloseFile(Freeldr_Ini);
+ ArcClose(FileId);
return FALSE;
}
+ //
// Read freeldr.ini off the disk
- if (!FsReadFile(Freeldr_Ini, FreeLoaderIniFileSize, NULL, FreeLoaderIniFileData))
+ //
+ ret = ArcRead(FileId, FreeLoaderIniFileData, FreeLoaderIniFileSize, &Count);
+ if (ret != ESUCCESS || Count != FreeLoaderIniFileSize)
{
- FsCloseFile(Freeldr_Ini);
+ UiMessageBoxCritical("Error while reading freeldr.ini.");
+ ArcClose(FileId);
MmHeapFree(FreeLoaderIniFileData);
return FALSE;
}
- FsCloseFile(Freeldr_Ini);
-
+ //
// Parse the .ini file data
+ //
Success = IniParseFile(FreeLoaderIniFileData, FreeLoaderIniFileSize);
+ //
+ // Do some cleanup, and return
+ //
+ ArcClose(FileId);
MmHeapFree(FreeLoaderIniFileData);
return Success;
}
-
-PFILE IniOpenIniFile()
-{
- PFILE IniFileHandle; // File handle for freeldr.ini
-
- // Try to open freeldr.ini
- IniFileHandle = FsOpenFile("freeldr.ini");
-
- return IniFileHandle;
-}