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(); }
VOID DriveMapMapDrivesInSection(PCSTR SectionName) { CHAR SettingName[80]; CHAR SettingValue[80]; CHAR Drive1[80]; CHAR Drive2[80]; ULONG_PTR SectionId; ULONG SectionItemCount; ULONG Index; ULONG Index2; DRIVE_MAP_LIST DriveMapList; RtlZeroMemory(&DriveMapList, sizeof(DRIVE_MAP_LIST)); if (!IniOpenSection(SectionName, &SectionId)) { return; } // Get the number of items in this section SectionItemCount = IniGetNumSectionItems(SectionId); // Loop through each one and check if its a DriveMap= setting for (Index=0; Index<SectionItemCount; Index++) { // Get the next setting from the .ini file section if (IniReadSettingByNumber(SectionId, Index, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue))) { if (_stricmp(SettingName, "DriveMap") == 0) { // Make sure we haven't exceeded the drive map max count if (DriveMapList.DriveMapCount >= 4) { UiMessageBox("Max DriveMap count exceeded in section [%s]:\n\n%s=%s", SectionName, SettingName, SettingValue); continue; } RtlZeroMemory(Drive1, 80); RtlZeroMemory(Drive2, 80); strcpy(Drive1, SettingValue); // Parse the setting value and separate a string "hd0,hd1" // into two strings "hd0" and "hd1" for (Index2=0; Index2<strlen(Drive1); Index2++) { // Check if this character is the separater character (comma - ',') if (Drive1[Index2] == ',') { Drive1[Index2] = '\0'; strcpy(Drive2, &Drive1[Index2+1]); break; } } // Make sure we got good values before we add them to the map if (!DriveMapIsValidDriveString(Drive1) || !DriveMapIsValidDriveString(Drive2)) { UiMessageBox("Error in DriveMap setting in section [%s]:\n\n%s=%s", SectionName, SettingName, SettingValue); continue; } // Add them to the map DriveMapList.DriveMap[(DriveMapList.DriveMapCount * 2)] = DriveMapGetBiosDriveNumber(Drive1); DriveMapList.DriveMap[(DriveMapList.DriveMapCount * 2)+1] = DriveMapGetBiosDriveNumber(Drive2); DriveMapList.DriveMapCount++; TRACE("Mapping BIOS drive 0x%x to drive 0x%x\n", DriveMapGetBiosDriveNumber(Drive1), DriveMapGetBiosDriveNumber(Drive2)); } } } if (DriveMapList.DriveMapCount) { TRACE("Installing Int13 drive map for %d drives.\n", DriveMapList.DriveMapCount); DriveMapInstallInt13Handler(&DriveMapList); } else { TRACE("Removing any previously installed Int13 drive map.\n"); DriveMapRemoveInt13Handler(); } }
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); }