3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 BOOL
IniFileInitialize(VOID
)
30 PFILE Freeldr_Ini
; // File handle for freeldr.ini
31 PUCHAR FreeLoaderIniFileData
;
32 U32 FreeLoaderIniFileSize
;
36 // BootDrive & BootPartition are passed
37 // in from the boot sector code in the
39 Freeldr_Ini
= IniOpenIniFile(BootDrive
, BootPartition
);
41 // If we couldn't open freeldr.ini on the partition
42 // they specified in the boot sector then try
43 // opening the active (boot) partition.
44 if ((Freeldr_Ini
== NULL
) && (BootPartition
!= 0))
48 Freeldr_Ini
= IniOpenIniFile(BootDrive
, BootPartition
);
53 if (Freeldr_Ini
== NULL
)
55 printf("Error opening freeldr.ini or file not found.\n");
56 printf("You need to re-install FreeLoader.\n");
60 // Get the file size & allocate enough memory for it
61 FreeLoaderIniFileSize
= FsGetFileSize(Freeldr_Ini
);
62 FreeLoaderIniFileData
= MmAllocateMemory(FreeLoaderIniFileSize
);
64 // If we are out of memory then return FALSE
65 if (FreeLoaderIniFileData
== NULL
)
67 printf("Out of memory while loading freeldr.ini.\n");
68 FsCloseFile(Freeldr_Ini
);
72 // Read freeldr.ini off the disk
73 if (!FsReadFile(Freeldr_Ini
, FreeLoaderIniFileSize
, NULL
, FreeLoaderIniFileData
))
75 FsCloseFile(Freeldr_Ini
);
76 MmFreeMemory(FreeLoaderIniFileData
);
80 FsCloseFile(Freeldr_Ini
);
82 // Parse the .ini file data
83 Success
= IniParseFile(FreeLoaderIniFileData
, FreeLoaderIniFileSize
);
85 MmFreeMemory(FreeLoaderIniFileData
);
90 PFILE
IniOpenIniFile(U8 BootDriveNumber
, U8 BootPartitionNumber
)
92 PFILE IniFileHandle
; // File handle for freeldr.ini
94 if (!FsOpenVolume(BootDriveNumber
, BootPartitionNumber
))
96 if (BootPartitionNumber
== 0)
98 printf("Error opening active (bootable) partition on boot drive 0x%x for file access.\n", BootDriveNumber
);
102 printf("Error opening partition %d on boot drive 0x%x for file access.\n", BootPartitionNumber
, BootDriveNumber
);
108 // Try to open freeldr.ini
109 IniFileHandle
= FsOpenFile("freeldr.ini");
111 return IniFileHandle
;