2003-01-18 10:21:23 +00:00
/*
* FreeLoader
* Copyright ( C ) 1998 - 2003 Brian Palmer < brianp @ sginet . com >
*
* 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
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
2009-10-27 10:34:16 +00:00
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2003-01-18 10:21:23 +00:00
*/
2005-05-08 02:15:21 +00:00
2003-01-18 10:21:23 +00:00
# include <freeldr.h>
2005-11-11 18:11:17 +00:00
const CHAR BootDrivePrompt [ ] = " Enter the boot drive. \n \n Examples: \n fd0 - first floppy drive \n hd0 - first hard drive \n hd1 - second hard drive \n cd0 - first CD-ROM drive. \n \n BIOS drive numbers may also be used: \n 0 - first floppy drive \n 0x80 - first hard drive \n 0x81 - second hard drive " ;
const CHAR BootPartitionPrompt [ ] = " Enter the boot partition. \n \n Enter 0 for the active (bootable) partition. " ;
const CHAR BootSectorFilePrompt [ ] = " Enter the boot sector file path. \n \n Examples: \n \\ BOOTSECT.DOS \n /boot/bootsect.dos " ;
const CHAR LinuxKernelPrompt [ ] = " Enter the Linux kernel image path. \n \n Examples: \n /vmlinuz \n /boot/vmlinuz-2.4.18 " ;
const CHAR LinuxInitrdPrompt [ ] = " Enter the initrd image path. \n \n Examples: \n /initrd.gz \n /boot/root.img.gz \n \n Leave blank for no initial ram disk. " ;
const CHAR LinuxCommandLinePrompt [ ] = " Enter the Linux kernel command line. \n \n Examples: \n root=/dev/hda1 \n root=/dev/fd0 read-only \n root=/dev/sdb1 init=/sbin/init " ;
const CHAR ReactOSSystemPathPrompt [ ] = " Enter the path to your ReactOS system directory. \n \n Examples: \n \\ REACTOS \n \\ ROS " ;
const CHAR ReactOSOptionsPrompt [ ] = " Enter the options you want passed to the kernel. \n \n Examples: \n /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 \n /FASTDETECT /SOS /NOGUIBOOT \n /BASEVIDEO /MAXMEM=64 \n /KERNEL=NTKRNLMP.EXE /HAL=HALMPS.DLL " ;
2003-01-18 10:21:23 +00:00
2005-11-11 18:11:17 +00:00
const CHAR CustomBootPrompt [ ] = " Press ENTER to boot your custom boot setup. " ;
2003-01-18 10:21:23 +00:00
VOID OptionMenuCustomBoot ( VOID )
{
2007-01-10 19:48:35 +00:00
PCSTR CustomBootMenuList [ ] = {
" Disk " ,
" Partition " ,
" Boot Sector File " ,
" ReactOS " ,
" Linux "
} ;
2012-12-13 00:46:55 +00:00
ULONG CustomBootMenuCount = sizeof ( CustomBootMenuList ) / sizeof ( CustomBootMenuList [ 0 ] ) ;
ULONG SelectedMenuItem ;
2003-01-18 10:21:23 +00:00
2012-12-24 23:03:11 +00:00
if ( ! UiDisplayMenu ( " Please choose a boot method: " , " " ,
2012-12-26 01:40:18 +00:00
FALSE ,
2012-12-09 15:01:51 +00:00
CustomBootMenuList ,
CustomBootMenuCount ,
0 , - 1 ,
& SelectedMenuItem ,
TRUE ,
NULL ) )
2003-01-18 10:21:23 +00:00
{
// The user pressed ESC
return ;
}
switch ( SelectedMenuItem )
{
case 0 : // Disk
OptionMenuCustomBootDisk ( ) ;
break ;
case 1 : // Partition
OptionMenuCustomBootPartition ( ) ;
break ;
case 2 : // Boot Sector File
OptionMenuCustomBootBootSectorFile ( ) ;
break ;
2012-12-27 21:52:40 +00:00
case 3 : // ReactOS
OptionMenuCustomBootReactOS ( ) ;
break ;
2003-01-18 10:21:23 +00:00
case 4 : // Linux
OptionMenuCustomBootLinux ( ) ;
break ;
}
}
VOID OptionMenuCustomBootDisk ( VOID )
{
2012-12-13 00:46:55 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
2009-04-24 20:35:11 +00:00
TIMEINFO * TimeInfo ;
2012-12-13 00:46:55 +00:00
OperatingSystemItem OperatingSystem ;
2003-01-18 10:21:23 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
{
return ;
}
// Generate a unique section name
2009-04-24 20:35:11 +00:00
TimeInfo = ArcGetTime ( ) ;
sprintf ( SectionName , " CustomBootDisk%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
2003-01-18 10:21:23 +00:00
// Add the section
if ( ! IniAddSection ( SectionName , & SectionId ) )
{
return ;
}
// Add the BootType
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Drive " ) )
{
return ;
}
// Add the BootDrive
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
{
return ;
}
UiMessageBox ( CustomBootPrompt ) ;
2012-12-13 00:46:55 +00:00
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ;
2012-12-27 21:52:40 +00:00
// LoadAndBootDrive(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
VOID OptionMenuCustomBootPartition ( VOID )
{
2012-12-13 00:46:55 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
2009-04-24 20:35:11 +00:00
TIMEINFO * TimeInfo ;
2012-12-13 00:46:55 +00:00
OperatingSystemItem OperatingSystem ;
2003-01-18 10:21:23 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
RtlZeroMemory ( BootPartitionString , sizeof ( BootPartitionString ) ) ;
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( BootPartitionPrompt , BootPartitionString , 20 ) )
{
return ;
}
// Generate a unique section name
2009-04-24 20:35:11 +00:00
TimeInfo = ArcGetTime ( ) ;
sprintf ( SectionName , " CustomBootPartition%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
2003-01-18 10:21:23 +00:00
// Add the section
if ( ! IniAddSection ( SectionName , & SectionId ) )
{
return ;
}
// Add the BootType
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Partition " ) )
{
return ;
}
// Add the BootDrive
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
{
return ;
}
// Add the BootPartition
if ( ! IniAddSettingValueToSection ( SectionId , " BootPartition " , BootPartitionString ) )
{
return ;
}
UiMessageBox ( CustomBootPrompt ) ;
2012-12-13 00:46:55 +00:00
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ;
2012-12-27 21:52:40 +00:00
// LoadAndBootPartition(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
VOID OptionMenuCustomBootBootSectorFile ( VOID )
{
2012-12-13 00:46:55 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
CHAR BootSectorFileString [ 200 ] ;
2009-04-24 20:35:11 +00:00
TIMEINFO * TimeInfo ;
2012-12-13 00:46:55 +00:00
OperatingSystemItem OperatingSystem ;
2003-01-18 10:21:23 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
RtlZeroMemory ( BootPartitionString , sizeof ( BootPartitionString ) ) ;
RtlZeroMemory ( BootSectorFileString , sizeof ( BootSectorFileString ) ) ;
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( BootPartitionPrompt , BootPartitionString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( BootSectorFilePrompt , BootSectorFileString , 200 ) )
{
return ;
}
// Generate a unique section name
2009-04-24 20:35:11 +00:00
TimeInfo = ArcGetTime ( ) ;
sprintf ( SectionName , " CustomBootSectorFile%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
2003-01-18 10:21:23 +00:00
// Add the section
if ( ! IniAddSection ( SectionName , & SectionId ) )
{
return ;
}
// Add the BootType
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " BootSector " ) )
{
return ;
}
// Add the BootDrive
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
{
return ;
}
// Add the BootPartition
if ( ! IniAddSettingValueToSection ( SectionId , " BootPartition " , BootPartitionString ) )
{
return ;
}
// Add the BootSectorFile
if ( ! IniAddSettingValueToSection ( SectionId , " BootSectorFile " , BootSectorFileString ) )
{
return ;
}
UiMessageBox ( CustomBootPrompt ) ;
2012-12-13 00:46:55 +00:00
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ;
2012-12-27 21:52:40 +00:00
// LoadAndBootBootSector(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
}
VOID OptionMenuCustomBootReactOS ( VOID )
{
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
CHAR ReactOSSystemPath [ 200 ] ;
CHAR ReactOSARCPath [ 200 ] ;
CHAR ReactOSOptions [ 200 ] ;
TIMEINFO * TimeInfo ;
OperatingSystemItem OperatingSystem ;
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
RtlZeroMemory ( BootPartitionString , sizeof ( BootPartitionString ) ) ;
RtlZeroMemory ( ReactOSSystemPath , sizeof ( ReactOSSystemPath ) ) ;
RtlZeroMemory ( ReactOSOptions , sizeof ( ReactOSOptions ) ) ;
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( BootPartitionPrompt , BootPartitionString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( ReactOSSystemPathPrompt , ReactOSSystemPath , 200 ) )
{
return ;
}
if ( ! UiEditBox ( ReactOSOptionsPrompt , ReactOSOptions , 200 ) )
{
return ;
}
// Generate a unique section name
TimeInfo = ArcGetTime ( ) ;
sprintf ( SectionName , " CustomReactOS%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
// Add the section
if ( ! IniAddSection ( SectionName , & SectionId ) )
{
return ;
}
// Add the BootType
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Windows2003 " ) )
{
return ;
}
// Construct the ReactOS ARC system path
ConstructArcPath ( ReactOSARCPath , ReactOSSystemPath , DriveMapGetBiosDriveNumber ( BootDriveString ) , atoi ( BootPartitionString ) ) ;
// Add the system path
if ( ! IniAddSettingValueToSection ( SectionId , " SystemPath " , ReactOSARCPath ) )
{
return ;
}
// Add the CommandLine
if ( ! IniAddSettingValueToSection ( SectionId , " Options " , ReactOSOptions ) )
{
return ;
}
UiMessageBox ( CustomBootPrompt ) ;
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ; // ReactOSOptions
// LoadAndBootWindows(&OperatingSystem, _WIN32_WINNT_WS03);
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
VOID OptionMenuCustomBootLinux ( VOID )
{
2012-12-13 00:46:55 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
CHAR LinuxKernelString [ 200 ] ;
CHAR LinuxInitrdString [ 200 ] ;
CHAR LinuxCommandLineString [ 200 ] ;
2009-04-24 20:35:11 +00:00
TIMEINFO * TimeInfo ;
2012-12-13 00:46:55 +00:00
OperatingSystemItem OperatingSystem ;
2003-01-18 10:21:23 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
RtlZeroMemory ( BootPartitionString , sizeof ( BootPartitionString ) ) ;
RtlZeroMemory ( LinuxKernelString , sizeof ( LinuxKernelString ) ) ;
RtlZeroMemory ( LinuxInitrdString , sizeof ( LinuxInitrdString ) ) ;
RtlZeroMemory ( LinuxCommandLineString , sizeof ( LinuxCommandLineString ) ) ;
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( BootPartitionPrompt , BootPartitionString , 20 ) )
{
return ;
}
if ( ! UiEditBox ( LinuxKernelPrompt , LinuxKernelString , 200 ) )
{
return ;
}
if ( ! UiEditBox ( LinuxInitrdPrompt , LinuxInitrdString , 200 ) )
{
return ;
}
if ( ! UiEditBox ( LinuxCommandLinePrompt , LinuxCommandLineString , 200 ) )
{
return ;
}
// Generate a unique section name
2009-04-24 20:35:11 +00:00
TimeInfo = ArcGetTime ( ) ;
sprintf ( SectionName , " CustomLinux%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
2003-01-18 10:21:23 +00:00
// Add the section
if ( ! IniAddSection ( SectionName , & SectionId ) )
{
return ;
}
// Add the BootType
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Linux " ) )
{
return ;
}
// Add the BootDrive
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
{
return ;
}
// Add the BootPartition
if ( ! IniAddSettingValueToSection ( SectionId , " BootPartition " , BootPartitionString ) )
{
return ;
}
// Add the Kernel
if ( ! IniAddSettingValueToSection ( SectionId , " Kernel " , LinuxKernelString ) )
{
return ;
}
// Add the Initrd
if ( strlen ( LinuxInitrdString ) > 0 )
{
if ( ! IniAddSettingValueToSection ( SectionId , " Initrd " , LinuxInitrdString ) )
{
return ;
}
}
// Add the CommandLine
if ( ! IniAddSettingValueToSection ( SectionId , " CommandLine " , LinuxCommandLineString ) )
{
return ;
}
UiMessageBox ( CustomBootPrompt ) ;
2012-12-13 00:46:55 +00:00
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = " Custom Linux Setup " ;
OperatingSystem . OsLoadOptions = NULL ;
2012-12-27 21:52:40 +00:00
// LoadAndBootLinux(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
2009-10-30 21:48:21 +00:00
VOID OptionMenuReboot ( VOID )
{
UiMessageBox ( " The system will now reboot. " ) ;
DiskStopFloppyMotor ( ) ;
2012-12-17 00:22:11 +00:00
Reboot ( ) ;
2009-10-30 21:48:21 +00:00
}