ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

custom.c
Go to the documentation of this file.
00001 /*
00002  *  FreeLoader
00003  *  Copyright (C) 1998-2003  Brian Palmer  <brianp@sginet.com>
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 
00022 
00023 const CHAR  BootDrivePrompt[] = "Enter the boot drive.\n\nExamples:\nfd0 - first floppy drive\nhd0 - first hard drive\nhd1 - second hard drive\ncd0 - first CD-ROM drive.\n\nBIOS drive numbers may also be used:\n0 - first floppy drive\n0x80 - first hard drive\n0x81 - second hard drive";
00024 const CHAR  BootPartitionPrompt[] = "Enter the boot partition.\n\nEnter 0 for the active (bootable) partition.";
00025 const CHAR  BootSectorFilePrompt[] = "Enter the boot sector file path.\n\nExamples:\n\\BOOTSECT.DOS\n/boot/bootsect.dos";
00026 const CHAR  LinuxKernelPrompt[] = "Enter the Linux kernel image path.\n\nExamples:\n/vmlinuz\n/boot/vmlinuz-2.4.18";
00027 const CHAR  LinuxInitrdPrompt[] = "Enter the initrd image path.\n\nExamples:\n/initrd.gz\n/boot/root.img.gz\n\nLeave blank for no initial ram disk.";
00028 const CHAR  LinuxCommandLinePrompt[] = "Enter the Linux kernel command line.\n\nExamples:\nroot=/dev/hda1\nroot=/dev/fd0 read-only\nroot=/dev/sdb1 init=/sbin/init";
00029 const CHAR  ReactOSSystemPathPrompt[] = "Enter the path to your ReactOS system directory.\n\nExamples:\n\\REACTOS\n\\ROS";
00030 const CHAR  ReactOSOptionsPrompt[] = "Enter the options you want passed to the kernel.\n\nExamples:\n/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200\n/FASTDETECT /SOS /NOGUIBOOT\n/BASEVIDEO /MAXMEM=64\n/KERNEL=NTKRNLMP.EXE /HAL=HALMPS.DLL";
00031 
00032 const CHAR  CustomBootPrompt[] = "Press ENTER to boot your custom boot setup.";
00033 
00034 VOID OptionMenuCustomBoot(VOID)
00035 {
00036     PCSTR   CustomBootMenuList[] = {
00037         "Disk",
00038         "Partition",
00039         "Boot Sector File",
00040         "ReactOS",
00041         "Linux"
00042         };
00043     ULONG       CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
00044     ULONG       SelectedMenuItem;
00045 
00046     if (!UiDisplayMenu(CustomBootMenuList, CustomBootMenuCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
00047     {
00048         // The user pressed ESC
00049         return;
00050     }
00051 
00052     switch (SelectedMenuItem)
00053     {
00054     case 0: // Disk
00055         OptionMenuCustomBootDisk();
00056         break;
00057     case 1: // Partition
00058         OptionMenuCustomBootPartition();
00059         break;
00060     case 2: // Boot Sector File
00061         OptionMenuCustomBootBootSectorFile();
00062         break;
00063     case 4: // Linux
00064         OptionMenuCustomBootLinux();
00065         break;
00066     }
00067 }
00068 
00069 VOID OptionMenuCustomBootDisk(VOID)
00070 {
00071     CHAR    SectionName[100];
00072     CHAR    BootDriveString[20];
00073     ULONG   SectionId;
00074     TIMEINFO*   TimeInfo;
00075 
00076     RtlZeroMemory(SectionName, sizeof(SectionName));
00077     RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
00078 
00079     if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
00080     {
00081         return;
00082     }
00083 
00084     // Generate a unique section name
00085     TimeInfo = ArcGetTime();
00086     sprintf(SectionName, "CustomBootDisk%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
00087 
00088     // Add the section
00089     if (!IniAddSection(SectionName, &SectionId))
00090     {
00091         return;
00092     }
00093 
00094     // Add the BootType
00095     if (!IniAddSettingValueToSection(SectionId, "BootType", "Drive"))
00096     {
00097         return;
00098     }
00099 
00100     // Add the BootDrive
00101     if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
00102     {
00103         return;
00104     }
00105 
00106     UiMessageBox(CustomBootPrompt);
00107 
00108     LoadAndBootDrive(SectionName);
00109 }
00110 
00111 VOID OptionMenuCustomBootPartition(VOID)
00112 {
00113     CHAR    SectionName[100];
00114     CHAR    BootDriveString[20];
00115     CHAR    BootPartitionString[20];
00116     ULONG   SectionId;
00117     TIMEINFO*   TimeInfo;
00118 
00119     RtlZeroMemory(SectionName, sizeof(SectionName));
00120     RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
00121     RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
00122 
00123     if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
00124     {
00125         return;
00126     }
00127 
00128     if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
00129     {
00130         return;
00131     }
00132 
00133     // Generate a unique section name
00134     TimeInfo = ArcGetTime();
00135     sprintf(SectionName, "CustomBootPartition%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
00136 
00137     // Add the section
00138     if (!IniAddSection(SectionName, &SectionId))
00139     {
00140         return;
00141     }
00142 
00143     // Add the BootType
00144     if (!IniAddSettingValueToSection(SectionId, "BootType", "Partition"))
00145     {
00146         return;
00147     }
00148 
00149     // Add the BootDrive
00150     if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
00151     {
00152         return;
00153     }
00154 
00155     // Add the BootPartition
00156     if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
00157     {
00158         return;
00159     }
00160 
00161     UiMessageBox(CustomBootPrompt);
00162 
00163     LoadAndBootPartition(SectionName);
00164 }
00165 
00166 VOID OptionMenuCustomBootBootSectorFile(VOID)
00167 {
00168     CHAR    SectionName[100];
00169     CHAR    BootDriveString[20];
00170     CHAR    BootPartitionString[20];
00171     CHAR    BootSectorFileString[200];
00172     ULONG   SectionId;
00173     TIMEINFO*   TimeInfo;
00174 
00175     RtlZeroMemory(SectionName, sizeof(SectionName));
00176     RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
00177     RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
00178     RtlZeroMemory(BootSectorFileString, sizeof(BootSectorFileString));
00179 
00180     if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
00181     {
00182         return;
00183     }
00184 
00185     if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
00186     {
00187         return;
00188     }
00189 
00190     if (!UiEditBox(BootSectorFilePrompt, BootSectorFileString, 200))
00191     {
00192         return;
00193     }
00194 
00195     // Generate a unique section name
00196     TimeInfo = ArcGetTime();
00197     sprintf(SectionName, "CustomBootSectorFile%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
00198 
00199     // Add the section
00200     if (!IniAddSection(SectionName, &SectionId))
00201     {
00202         return;
00203     }
00204 
00205     // Add the BootType
00206     if (!IniAddSettingValueToSection(SectionId, "BootType", "BootSector"))
00207     {
00208         return;
00209     }
00210 
00211     // Add the BootDrive
00212     if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
00213     {
00214         return;
00215     }
00216 
00217     // Add the BootPartition
00218     if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
00219     {
00220         return;
00221     }
00222 
00223     // Add the BootSectorFile
00224     if (!IniAddSettingValueToSection(SectionId, "BootSectorFile", BootSectorFileString))
00225     {
00226         return;
00227     }
00228 
00229     UiMessageBox(CustomBootPrompt);
00230 
00231     LoadAndBootBootSector(SectionName);
00232 }
00233 
00234 VOID OptionMenuCustomBootLinux(VOID)
00235 {
00236     CHAR    SectionName[100];
00237     CHAR    BootDriveString[20];
00238     CHAR    BootPartitionString[20];
00239     CHAR    LinuxKernelString[200];
00240     CHAR    LinuxInitrdString[200];
00241     CHAR    LinuxCommandLineString[200];
00242     ULONG   SectionId;
00243     TIMEINFO*   TimeInfo;
00244 
00245     RtlZeroMemory(SectionName, sizeof(SectionName));
00246     RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
00247     RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
00248     RtlZeroMemory(LinuxKernelString, sizeof(LinuxKernelString));
00249     RtlZeroMemory(LinuxInitrdString, sizeof(LinuxInitrdString));
00250     RtlZeroMemory(LinuxCommandLineString, sizeof(LinuxCommandLineString));
00251 
00252     if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
00253     {
00254         return;
00255     }
00256 
00257     if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
00258     {
00259         return;
00260     }
00261 
00262     if (!UiEditBox(LinuxKernelPrompt, LinuxKernelString, 200))
00263     {
00264         return;
00265     }
00266 
00267     if (!UiEditBox(LinuxInitrdPrompt, LinuxInitrdString, 200))
00268     {
00269         return;
00270     }
00271 
00272     if (!UiEditBox(LinuxCommandLinePrompt, LinuxCommandLineString, 200))
00273     {
00274         return;
00275     }
00276 
00277     // Generate a unique section name
00278     TimeInfo = ArcGetTime();
00279     sprintf(SectionName, "CustomLinux%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
00280 
00281     // Add the section
00282     if (!IniAddSection(SectionName, &SectionId))
00283     {
00284         return;
00285     }
00286 
00287     // Add the BootType
00288     if (!IniAddSettingValueToSection(SectionId, "BootType", "Linux"))
00289     {
00290         return;
00291     }
00292 
00293     // Add the BootDrive
00294     if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
00295     {
00296         return;
00297     }
00298 
00299     // Add the BootPartition
00300     if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
00301     {
00302         return;
00303     }
00304 
00305     // Add the Kernel
00306     if (!IniAddSettingValueToSection(SectionId, "Kernel", LinuxKernelString))
00307     {
00308         return;
00309     }
00310 
00311     // Add the Initrd
00312     if (strlen(LinuxInitrdString) > 0)
00313     {
00314         if (!IniAddSettingValueToSection(SectionId, "Initrd", LinuxInitrdString))
00315         {
00316             return;
00317         }
00318     }
00319 
00320     // Add the CommandLine
00321     if (!IniAddSettingValueToSection(SectionId, "CommandLine", LinuxCommandLineString))
00322     {
00323         return;
00324     }
00325 
00326     UiMessageBox(CustomBootPrompt);
00327 
00328     LoadAndBootLinux(SectionName, "Custom Linux Setup");
00329 }
00330 
00331 VOID OptionMenuReboot(VOID)
00332 {
00333     UiMessageBox("The system will now reboot.");
00334 
00335     DiskStopFloppyMotor();
00336     SoftReboot();
00337 }

Generated on Sun May 27 2012 04:19:07 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.