Ejemplo n.º 1
0
VOID
LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem,
                 IN USHORT OperatingSystemVersion)
{
    ULONG_PTR    SectionId;
    PCSTR    SectionName = OperatingSystem->SystemPartition;
    CHAR    SettingName[80];
    CHAR    SettingValue[80];
    UCHAR    DriveNumber;

    // Find all the message box settings and run them
    UiShowMessageBoxesInSection(SectionName);

    // Try to open the operating system section in the .ini file
    if (!IniOpenSection(SectionName, &SectionId))
    {
        sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName);
        UiMessageBox(SettingName);
        return;
    }

    if (!IniReadSettingByName(SectionId, "BootDrive", SettingValue, sizeof(SettingValue)))
    {
        UiMessageBox("Boot drive not specified for selected OS!");
        return;
    }

    DriveNumber = DriveMapGetBiosDriveNumber(SettingValue);

    // Now try to read the boot sector (or mbr)
    // If this fails then abort
    if (!MachDiskReadLogicalSectors(DriveNumber, 0, 1, (PVOID)0x7C00))
    {
        UiMessageBox("Unable to read boot sector");
        return;
    }

    // Check for validity
    if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
    {
        UiMessageBox("Invalid boot sector magic (0xaa55)");
        return;
    }

    UiUnInitialize("Booting...");
    // Don't stop the floppy drive motor when we
    // are just booting a bootsector, or drive, or partition.
    // If we were to stop the floppy motor then
    // the BIOS wouldn't be informed and if the
    // next read is to a floppy then the BIOS will
    // still think the motor is on and this will
    // result in a read error.
    //DiskStopFloppyMotor();
    //DisableA20();
    ChainLoadBiosBootSectorCode();
}
Ejemplo n.º 2
0
VOID RunLoader(VOID)
{
    ULONG_PTR SectionId;
    ULONG     OperatingSystemCount;
    OperatingSystemItem* OperatingSystemList;
    PCSTR*    OperatingSystemDisplayNames;
    ULONG     DefaultOperatingSystem;
    LONG      TimeOut;
    ULONG     SelectedOperatingSystem;
    ULONG     i;

    if (!MachInitializeBootDevices())
    {
        UiMessageBoxCritical("Error when detecting hardware.");
        return;
    }

#ifdef _M_IX86
    /* Load additional SCSI driver (if any) */
    if (LoadBootDeviceDriver() != ESUCCESS)
    {
        UiMessageBoxCritical("Unable to load additional boot device drivers.");
    }
#endif

    if (!IniFileInitialize())
    {
        UiMessageBoxCritical("Error initializing .ini file.");
        return;
    }

    /* Debugger main initialization */
    DebugInit(TRUE);

    if (!IniOpenSection("FreeLoader", &SectionId))
    {
        UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
        return;
    }

    TimeOut = GetTimeOut();

    /* UI main initialization */
    if (!UiInitialize(TRUE))
    {
        UiMessageBoxCritical("Unable to initialize UI.");
        return;
    }

    OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount);
    if (!OperatingSystemList)
    {
        UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
        goto Reboot;
    }

    if (OperatingSystemCount == 0)
    {
        UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
        goto Reboot;
    }

    DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemList, OperatingSystemCount);

    /* Create list of display names */
    OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
    if (!OperatingSystemDisplayNames)
        goto Reboot;

    for (i = 0; i < OperatingSystemCount; i++)
    {
        OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
    }

    /* Find all the message box settings and run them */
    UiShowMessageBoxesInSection("FreeLoader");

    for (;;)
    {
        /* Redraw the backdrop */
        UiDrawBackdrop();

        /* Show the operating system list menu */
        if (!UiDisplayMenu("Please select the operating system to start:",
                           "For troubleshooting and advanced startup options for "
                               "ReactOS, press F8.",
                           TRUE,
                           OperatingSystemDisplayNames,
                           OperatingSystemCount,
                           DefaultOperatingSystem,
                           TimeOut,
                           &SelectedOperatingSystem,
                           FALSE,
                           MainBootMenuKeyPressFilter))
        {
            UiMessageBox("Press ENTER to reboot.");
            goto Reboot;
        }

        TimeOut = -1;

        /* Load the chosen operating system */
        LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
    }

Reboot:
    UiUnInitialize("Rebooting...");
    return;
}
Ejemplo n.º 3
0
VOID
LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem,
                      IN USHORT OperatingSystemVersion)
{
    ULONG_PTR    SectionId;
    PCSTR    SectionName = OperatingSystem->SystemPartition;
    CHAR    FileName[260];
    PFILE    FilePointer;
    ULONG    BytesRead;
    CHAR    SettingName[80];

    // Find all the message box settings and run them
    UiShowMessageBoxesInSection(SectionName);

    // Try to open the operating system section in the .ini file
    if (!IniOpenSection(SectionName, &SectionId))
    {
        sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName);
        UiMessageBox(SettingName);
        return;
    }

    if (!IniReadSettingByName(SectionId, "BootSectorFile", FileName, sizeof(FileName)))
    {
        UiMessageBox("Boot sector file not specified for selected OS!");
        return;
    }

    FilePointer = FsOpenFile(FileName);
    if (!FilePointer)
    {
        strcat(FileName, " not found.");
        UiMessageBox(FileName);
        return;
    }

    // Read boot sector
    if (!FsReadFile(FilePointer, 512, &BytesRead, (void*)0x7c00) || (BytesRead != 512))
    {
        UiMessageBox("Unable to read boot sector.");
        return;
    }

    // Check for validity
    if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
    {
        UiMessageBox("Invalid boot sector magic (0xaa55)");
        return;
    }

    UiUnInitialize("Booting...");
    // Don't stop the floppy drive motor when we
    // are just booting a bootsector, or drive, or partition.
    // If we were to stop the floppy motor then
    // the BIOS wouldn't be informed and if the
    // next read is to a floppy then the BIOS will
    // still think the motor is on and this will
    // result in a read error.
    //DiskStopFloppyMotor();
    //DisableA20();
    ChainLoadBiosBootSectorCode();
}