Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenini_init.c
Go to the documentation of this file.
00001 /* 00002 * FreeLoader 00003 * Copyright (C) 2009 Hervé Poussineau <hpoussin@reactos.org> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #include <freeldr.h> 00021 #include <debug.h> 00022 DBG_DEFAULT_CHANNEL(INIFILE); 00023 00024 static LONG IniOpenIniFile(ULONG* FileId) 00025 { 00026 CHAR FreeldrPath[MAX_PATH]; 00027 LONG ret; 00028 00029 // 00030 // Create full freeldr.ini path 00031 // 00032 MachDiskGetBootPath(FreeldrPath, sizeof(FreeldrPath)); 00033 strcat(FreeldrPath, "\\freeldr.ini"); 00034 00035 // Try to open freeldr.ini 00036 ret = ArcOpen(FreeldrPath, OpenReadOnly, FileId); 00037 00038 return ret; 00039 } 00040 00041 BOOLEAN IniFileInitialize(VOID) 00042 { 00043 FILEINFORMATION FileInformation; 00044 ULONG FileId; // File handle for freeldr.ini 00045 PCHAR FreeLoaderIniFileData; 00046 ULONG FreeLoaderIniFileSize, Count; 00047 LONG ret; 00048 BOOLEAN Success; 00049 TRACE("IniFileInitialize()\n"); 00050 00051 // 00052 // Open freeldr.ini 00053 // 00054 ret = IniOpenIniFile(&FileId); 00055 if (ret != ESUCCESS) 00056 { 00057 UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to re-install FreeLoader."); 00058 return FALSE; 00059 } 00060 00061 // 00062 // Get the file size 00063 // 00064 ret = ArcGetFileInformation(FileId, &FileInformation); 00065 if (ret != ESUCCESS || FileInformation.EndingAddress.HighPart != 0) 00066 { 00067 UiMessageBoxCritical("Error while getting informations about freeldr.ini.\nYou need to re-install FreeLoader."); 00068 return FALSE; 00069 } 00070 FreeLoaderIniFileSize = FileInformation.EndingAddress.LowPart; 00071 00072 // 00073 // Allocate memory to cache the whole freeldr.ini 00074 // 00075 FreeLoaderIniFileData = MmHeapAlloc(FreeLoaderIniFileSize); 00076 if (!FreeLoaderIniFileData) 00077 { 00078 UiMessageBoxCritical("Out of memory while loading freeldr.ini."); 00079 ArcClose(FileId); 00080 return FALSE; 00081 } 00082 00083 // 00084 // Read freeldr.ini off the disk 00085 // 00086 ret = ArcRead(FileId, FreeLoaderIniFileData, FreeLoaderIniFileSize, &Count); 00087 if (ret != ESUCCESS || Count != FreeLoaderIniFileSize) 00088 { 00089 UiMessageBoxCritical("Error while reading freeldr.ini."); 00090 ArcClose(FileId); 00091 MmHeapFree(FreeLoaderIniFileData); 00092 return FALSE; 00093 } 00094 00095 // 00096 // Parse the .ini file data 00097 // 00098 Success = IniParseFile(FreeLoaderIniFileData, FreeLoaderIniFileSize); 00099 00100 // 00101 // Do some cleanup, and return 00102 // 00103 ArcClose(FileId); 00104 MmHeapFree(FreeLoaderIniFileData); 00105 00106 return Success; 00107 } Generated on Fri May 25 2012 04:17:20 for ReactOS by
1.7.6.1
|