3 * Copyright (C) 2009 Hervé Poussineau <hpoussin@reactos.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 DBG_DEFAULT_CHANNEL(INIFILE
);
25 BOOLEAN
IniFileInitialize(VOID
)
27 FILEINFORMATION FileInformation
;
28 ULONG FileId
; // File handle for freeldr.ini
29 PCHAR FreeLoaderIniFileData
;
30 ULONG FreeLoaderIniFileSize
, Count
;
34 TRACE("IniFileInitialize()\n");
36 /* Try to open freeldr.ini */
37 Status
= FsOpenFile("freeldr.ini", FrLdrBootPath
, OpenReadOnly
, &FileId
);
38 if (Status
!= ESUCCESS
)
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.");
45 /* Get the file size */
46 Status
= ArcGetFileInformation(FileId
, &FileInformation
);
47 if (Status
!= ESUCCESS
|| FileInformation
.EndingAddress
.HighPart
!= 0)
49 UiMessageBoxCritical("Error while getting informations about freeldr.ini.\nYou need to re-install FreeLoader.");
53 FreeLoaderIniFileSize
= FileInformation
.EndingAddress
.LowPart
;
55 /* Allocate memory to cache the whole freeldr.ini */
56 FreeLoaderIniFileData
= FrLdrTempAlloc(FreeLoaderIniFileSize
, TAG_INI_FILE
);
57 if (!FreeLoaderIniFileData
)
59 UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
64 /* Load freeldr.ini from the disk */
65 Status
= ArcRead(FileId
, FreeLoaderIniFileData
, FreeLoaderIniFileSize
, &Count
);
66 if (Status
!= ESUCCESS
|| Count
!= FreeLoaderIniFileSize
)
68 ERR("Error while reading freeldr.ini, Status: %d\n", Status
);
69 UiMessageBoxCritical("Error while reading freeldr.ini.");
71 FrLdrTempFree(FreeLoaderIniFileData
, TAG_INI_FILE
);
75 /* Parse the .ini file data */
76 Success
= IniParseFile(FreeLoaderIniFileData
, FreeLoaderIniFileSize
);
78 /* Do some cleanup, and return */
80 FrLdrTempFree(FreeLoaderIniFileData
, TAG_INI_FILE
);