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
2015-02-01 20:22:13 +00:00
/* INCLUDES *******************************************************************/
2003-01-18 10:21:23 +00:00
# include <freeldr.h>
2015-02-01 20:22:13 +00:00
/* GLOBALS ********************************************************************/
2003-01-18 10:21:23 +00:00
2015-02-06 01:21:45 +00:00
# ifdef _M_IX86
2015-02-01 20:22:13 +00:00
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 " ;
2015-02-06 01:21:45 +00:00
# endif // _M_IX86
2015-02-15 11:10:09 +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. " ;
2015-02-01 20:22:13 +00:00
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 " ;
const CHAR CustomBootPrompt [ ] = " Press ENTER to boot your custom boot setup. " ;
2003-01-18 10:21:23 +00:00
2015-02-01 20:22:13 +00:00
/* FUNCTIONS ******************************************************************/
2003-01-18 10:21:23 +00:00
VOID OptionMenuCustomBoot ( VOID )
{
2015-02-01 20:22:13 +00:00
PCSTR CustomBootMenuList [ ] = {
2015-02-06 01:21:45 +00:00
# ifdef _M_IX86
2013-05-24 12:20:13 +00:00
" Disk " ,
" Partition " ,
" Boot Sector File " ,
2015-02-06 01:21:45 +00:00
" Linux " ,
# endif
" ReactOS "
2013-05-24 12:20:13 +00:00
} ;
2015-02-01 20:22:13 +00:00
ULONG CustomBootMenuCount = sizeof ( CustomBootMenuList ) / sizeof ( CustomBootMenuList [ 0 ] ) ;
ULONG SelectedMenuItem ;
2013-05-24 12:20:13 +00:00
if ( ! UiDisplayMenu ( " Please choose a boot method: " , " " ,
FALSE ,
CustomBootMenuList ,
CustomBootMenuCount ,
0 , - 1 ,
& SelectedMenuItem ,
TRUE ,
NULL ) )
{
2015-02-01 21:35:45 +00:00
/* The user pressed ESC */
2013-05-24 12:20:13 +00:00
return ;
}
switch ( SelectedMenuItem )
{
2015-02-06 01:21:45 +00:00
# ifdef _M_IX86
2015-02-01 20:22:13 +00:00
case 0 : // Disk
OptionMenuCustomBootDisk ( ) ;
break ;
case 1 : // Partition
OptionMenuCustomBootPartition ( ) ;
break ;
case 2 : // Boot Sector File
OptionMenuCustomBootBootSectorFile ( ) ;
break ;
2015-02-06 01:21:45 +00:00
case 3 : // Linux
2015-02-01 20:22:13 +00:00
OptionMenuCustomBootLinux ( ) ;
break ;
2015-02-06 01:21:45 +00:00
case 4 : // ReactOS
# else
case 0 :
# endif
OptionMenuCustomBootReactOS ( ) ;
break ;
2013-05-24 12:20:13 +00:00
}
2003-01-18 10:21:23 +00:00
}
2015-02-06 01:21:45 +00:00
# ifdef _M_IX86
2003-01-18 10:21:23 +00:00
VOID OptionMenuCustomBootDisk ( VOID )
{
2015-02-01 20:22:13 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
TIMEINFO * TimeInfo ;
OperatingSystemItem OperatingSystem ;
2013-05-24 12:20:13 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
return ;
2015-02-01 20:22:13 +00:00
/* Generate a unique section name */
2013-05-24 12:20:13 +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 ) ;
2015-02-01 20:22:13 +00:00
/* Add the section */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSection ( SectionName , & SectionId ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootType */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Drive " ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootDrive */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
return ;
UiMessageBox ( CustomBootPrompt ) ;
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ;
// LoadAndBootDrive(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
VOID OptionMenuCustomBootPartition ( VOID )
{
2015-02-01 20:22:13 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
TIMEINFO * TimeInfo ;
OperatingSystemItem OperatingSystem ;
2013-05-24 12:20:13 +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 ;
2015-02-01 20:22:13 +00:00
/* Generate a unique section name */
2013-05-24 12:20:13 +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 ) ;
2015-02-01 20:22:13 +00:00
/* Add the section */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSection ( SectionName , & SectionId ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootType */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Partition " ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootDrive */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootPartition */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootPartition " , BootPartitionString ) )
return ;
UiMessageBox ( CustomBootPrompt ) ;
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ;
// LoadAndBootPartition(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
VOID OptionMenuCustomBootBootSectorFile ( VOID )
{
2015-02-01 20:22:13 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
CHAR BootSectorFileString [ 200 ] ;
TIMEINFO * TimeInfo ;
OperatingSystemItem OperatingSystem ;
2013-05-24 12:20:13 +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 ;
2015-02-01 20:22:13 +00:00
/* Generate a unique section name */
2013-05-24 12:20:13 +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 ) ;
2015-02-01 20:22:13 +00:00
/* Add the section */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSection ( SectionName , & SectionId ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootType */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " BootSector " ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootDrive */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootPartition */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootPartition " , BootPartitionString ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootSectorFile */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootSectorFile " , BootSectorFileString ) )
return ;
UiMessageBox ( CustomBootPrompt ) ;
OperatingSystem . SystemPartition = SectionName ;
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ;
// LoadAndBootBootSector(&OperatingSystem, 0);
LoadOperatingSystem ( & OperatingSystem ) ;
2012-12-27 21:52:40 +00:00
}
2015-02-06 01:21:45 +00:00
VOID OptionMenuCustomBootLinux ( VOID )
2012-12-27 21:52:40 +00:00
{
2015-02-01 20:22:13 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
2015-02-06 01:21:45 +00:00
CHAR LinuxKernelString [ 200 ] ;
CHAR LinuxInitrdString [ 200 ] ;
CHAR LinuxCommandLineString [ 200 ] ;
2015-02-01 20:22:13 +00:00
TIMEINFO * TimeInfo ;
OperatingSystemItem OperatingSystem ;
2013-05-24 12:20:13 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
RtlZeroMemory ( BootPartitionString , sizeof ( BootPartitionString ) ) ;
2015-02-06 01:21:45 +00:00
RtlZeroMemory ( LinuxKernelString , sizeof ( LinuxKernelString ) ) ;
RtlZeroMemory ( LinuxInitrdString , sizeof ( LinuxInitrdString ) ) ;
RtlZeroMemory ( LinuxCommandLineString , sizeof ( LinuxCommandLineString ) ) ;
2013-05-24 12:20:13 +00:00
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
return ;
if ( ! UiEditBox ( BootPartitionPrompt , BootPartitionString , 20 ) )
return ;
2015-02-06 01:21:45 +00:00
if ( ! UiEditBox ( LinuxKernelPrompt , LinuxKernelString , 200 ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-06 01:21:45 +00:00
if ( ! UiEditBox ( LinuxInitrdPrompt , LinuxInitrdString , 200 ) )
return ;
if ( ! UiEditBox ( LinuxCommandLinePrompt , LinuxCommandLineString , 200 ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-01 20:22:13 +00:00
/* Generate a unique section name */
2013-05-24 12:20:13 +00:00
TimeInfo = ArcGetTime ( ) ;
2015-02-06 01:21:45 +00:00
sprintf ( SectionName , " CustomLinux%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
2013-05-24 12:20:13 +00:00
2015-02-01 20:22:13 +00:00
/* Add the section */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSection ( SectionName , & SectionId ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootType */
2015-02-06 01:21:45 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Linux " ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-06 01:21:45 +00:00
/* Add the BootDrive */
if ( ! IniAddSettingValueToSection ( SectionId , " BootDrive " , BootDriveString ) )
return ;
2013-05-24 12:20:13 +00:00
2015-02-06 01:21:45 +00:00
/* Add the BootPartition */
if ( ! IniAddSettingValueToSection ( SectionId , " BootPartition " , BootPartitionString ) )
return ;
/* Add the Kernel */
if ( ! IniAddSettingValueToSection ( SectionId , " Kernel " , LinuxKernelString ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-06 01:21:45 +00:00
/* Add the Initrd */
if ( strlen ( LinuxInitrdString ) > 0 )
{
if ( ! IniAddSettingValueToSection ( SectionId , " Initrd " , LinuxInitrdString ) )
return ;
}
2015-02-01 20:22:13 +00:00
/* Add the CommandLine */
2015-02-06 01:21:45 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " CommandLine " , LinuxCommandLineString ) )
2013-05-24 12:20:13 +00:00
return ;
UiMessageBox ( CustomBootPrompt ) ;
OperatingSystem . SystemPartition = SectionName ;
2015-02-06 01:21:45 +00:00
OperatingSystem . LoadIdentifier = " Custom Linux Setup " ;
OperatingSystem . OsLoadOptions = NULL ;
2013-05-24 12:20:13 +00:00
2015-02-06 01:21:45 +00:00
// LoadAndBootLinux(&OperatingSystem, 0);
2013-05-24 12:20:13 +00:00
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
2015-02-06 01:21:45 +00:00
# endif // _M_IX86
VOID OptionMenuCustomBootReactOS ( VOID )
2003-01-18 10:21:23 +00:00
{
2015-02-01 20:22:13 +00:00
ULONG_PTR SectionId ;
CHAR SectionName [ 100 ] ;
CHAR BootDriveString [ 20 ] ;
CHAR BootPartitionString [ 20 ] ;
2015-02-06 01:21:45 +00:00
CHAR ReactOSSystemPath [ 200 ] ;
CHAR ReactOSARCPath [ 200 ] ;
CHAR ReactOSOptions [ 200 ] ;
2015-02-01 20:22:13 +00:00
TIMEINFO * TimeInfo ;
OperatingSystemItem OperatingSystem ;
2013-05-24 12:20:13 +00:00
RtlZeroMemory ( SectionName , sizeof ( SectionName ) ) ;
RtlZeroMemory ( BootDriveString , sizeof ( BootDriveString ) ) ;
RtlZeroMemory ( BootPartitionString , sizeof ( BootPartitionString ) ) ;
2015-02-06 01:21:45 +00:00
RtlZeroMemory ( ReactOSSystemPath , sizeof ( ReactOSSystemPath ) ) ;
RtlZeroMemory ( ReactOSOptions , sizeof ( ReactOSOptions ) ) ;
2013-05-24 12:20:13 +00:00
if ( ! UiEditBox ( BootDrivePrompt , BootDriveString , 20 ) )
return ;
if ( ! UiEditBox ( BootPartitionPrompt , BootPartitionString , 20 ) )
return ;
2015-02-06 01:21:45 +00:00
if ( ! UiEditBox ( ReactOSSystemPathPrompt , ReactOSSystemPath , 200 ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-06 01:21:45 +00:00
if ( ! UiEditBox ( ReactOSOptionsPrompt , ReactOSOptions , 200 ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-01 20:22:13 +00:00
/* Generate a unique section name */
2013-05-24 12:20:13 +00:00
TimeInfo = ArcGetTime ( ) ;
2015-02-06 01:21:45 +00:00
sprintf ( SectionName , " CustomReactOS%u%u%u%u%u%u " , TimeInfo - > Year , TimeInfo - > Day , TimeInfo - > Month , TimeInfo - > Hour , TimeInfo - > Minute , TimeInfo - > Second ) ;
2013-05-24 12:20:13 +00:00
2015-02-01 20:22:13 +00:00
/* Add the section */
2013-05-24 12:20:13 +00:00
if ( ! IniAddSection ( SectionName , & SectionId ) )
return ;
2015-02-01 20:22:13 +00:00
/* Add the BootType */
2015-02-06 01:21:45 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " BootType " , " Windows2003 " ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-06 01:21:45 +00:00
/* Construct the ReactOS ARC system path */
ConstructArcPath ( ReactOSARCPath , ReactOSSystemPath , DriveMapGetBiosDriveNumber ( BootDriveString ) , atoi ( BootPartitionString ) ) ;
2013-05-24 12:20:13 +00:00
2015-02-06 01:21:45 +00:00
/* Add the system path */
if ( ! IniAddSettingValueToSection ( SectionId , " SystemPath " , ReactOSARCPath ) )
2013-05-24 12:20:13 +00:00
return ;
2015-02-01 20:22:13 +00:00
/* Add the CommandLine */
2015-02-06 01:21:45 +00:00
if ( ! IniAddSettingValueToSection ( SectionId , " Options " , ReactOSOptions ) )
2013-05-24 12:20:13 +00:00
return ;
UiMessageBox ( CustomBootPrompt ) ;
OperatingSystem . SystemPartition = SectionName ;
2015-02-06 01:21:45 +00:00
OperatingSystem . LoadIdentifier = NULL ;
OperatingSystem . OsLoadOptions = NULL ; // ReactOSOptions
2013-05-24 12:20:13 +00:00
2015-02-06 01:21:45 +00:00
// LoadAndBootWindows(&OperatingSystem, _WIN32_WINNT_WS03);
2013-05-24 12:20:13 +00:00
LoadOperatingSystem ( & OperatingSystem ) ;
2003-01-18 10:21:23 +00:00
}
2009-10-30 21:48:21 +00:00
VOID OptionMenuReboot ( VOID )
{
2013-05-24 12:20:13 +00:00
UiMessageBox ( " The system will now reboot. " ) ;
2009-10-30 21:48:21 +00:00
2017-07-25 18:12:33 +00:00
# if defined(__i386__) || defined(_M_AMD64)
2013-05-24 12:20:13 +00:00
DiskStopFloppyMotor ( ) ;
2017-07-25 18:12:33 +00:00
# endif
2013-05-24 12:20:13 +00:00
Reboot ( ) ;
2009-10-30 21:48:21 +00:00
}