mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Reworked LoadAndBootPartition() function, got rid of warnings.
svn path=/trunk/; revision=2696
This commit is contained in:
parent
1058361a99
commit
1bd3b67ed2
2 changed files with 27 additions and 51 deletions
|
@ -76,7 +76,6 @@ BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||||
|
|
||||||
// Now try to read the boot sector
|
// Now try to read the boot sector
|
||||||
// If this fails then abort
|
// If this fails then abort
|
||||||
|
|
||||||
if (!DiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, FatVolumeBootSector))
|
if (!DiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, FatVolumeBootSector))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -103,72 +103,50 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
|
||||||
|
|
||||||
VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
|
VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
|
||||||
{
|
{
|
||||||
char name[260];
|
UCHAR SettingName[80];
|
||||||
char value[260];
|
UCHAR SettingValue[80];
|
||||||
int head, sector, cylinder;
|
ULONG SectionId;
|
||||||
int offset;
|
PARTITION_TABLE_ENTRY PartitionTableEntry;
|
||||||
int i;
|
|
||||||
|
|
||||||
// Find all the message box settings and run them
|
// Find all the message box settings and run them
|
||||||
/*for (i=1; i<=GetNumSectionItems(OSList[nOSToBoot].name); i++)
|
ShowMessageBoxesInSection(OperatingSystemName);
|
||||||
|
|
||||||
|
// Try to open the operating system section in the .ini file
|
||||||
|
if (!OpenSection(OperatingSystemName, &SectionId))
|
||||||
{
|
{
|
||||||
ReadSectionSettingByNumber(OSList[nOSToBoot].name, i, name, value);
|
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemName);
|
||||||
if (stricmp(name, "MessageBox") == 0)
|
MessageBox(SettingName);
|
||||||
MessageBox(value);
|
return;
|
||||||
if (stricmp(name, "MessageLine") == 0)
|
|
||||||
MessageLine(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadSectionSettingByName(OSList[nOSToBoot].name, "BootDrive", value))
|
// Read the boot drive
|
||||||
|
if (!ReadSectionSettingByName(SectionId, "BootDrive", SettingValue, 80))
|
||||||
{
|
{
|
||||||
MessageBox("Boot drive not specified for selected OS!");
|
MessageBox("Boot drive not specified for selected OS!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BootDrive = atoi(value);
|
BootDrive = atoi(SettingValue);
|
||||||
|
|
||||||
if (!ReadSectionSettingByName(OSList[nOSToBoot].name, "BootPartition", value))
|
// Read the boot partition
|
||||||
|
if (!ReadSectionSettingByName(SectionId, "BootPartition", SettingValue, 80))
|
||||||
{
|
{
|
||||||
MessageBox("Boot partition not specified for selected OS!");
|
MessageBox("Boot partition not specified for selected OS!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BootPartition = atoi(value);
|
BootPartition = atoi(SettingValue);
|
||||||
|
|
||||||
if (!BiosInt13Read(BootDrive, 0, 0, 1, 1, DISKREADBUFFER))
|
// Get the partition table entry
|
||||||
|
if (!DiskGetPartitionEntry(BootDrive, BootPartition, &PartitionTableEntry))
|
||||||
{
|
{
|
||||||
MessageBox("Disk Read Error");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for validity
|
// Now try to read the partition boot sector
|
||||||
if (*((WORD*)(DISKREADBUFFER + 0x1fe)) != 0xaa55)
|
// If this fails then abort
|
||||||
|
if (!DiskReadLogicalSectors(BootDrive, PartitionTableEntry.SectorCountBeforePartition, 1, (PVOID)0x7C00))
|
||||||
{
|
{
|
||||||
MessageBox("Invalid partition table magic (0xaa55)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = 0x1BE + ((BootPartition-1) * 0x10);
|
|
||||||
|
|
||||||
// Check for valid partition
|
|
||||||
if (SectorBuffer[offset + 4] == 0)
|
|
||||||
{
|
|
||||||
MessageBox("Invalid boot partition");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
head = SectorBuffer[offset + 1];
|
|
||||||
sector = (SectorBuffer[offset + 2] & 0x3F);
|
|
||||||
cylinder = SectorBuffer[offset + 3];
|
|
||||||
if (SectorBuffer[offset + 2] & 0x80)
|
|
||||||
cylinder += 0x200;
|
|
||||||
if (SectorBuffer[offset + 2] & 0x40)
|
|
||||||
cylinder += 0x100;
|
|
||||||
|
|
||||||
// Read partition boot sector
|
|
||||||
if (!biosdisk(_DISK_READ, BootDrive, head, cylinder, sector, 1, (void*)0x7c00))
|
|
||||||
{
|
|
||||||
MessageBox("Disk Read Error");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +157,10 @@ VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreScreen(ScreenBuffer);
|
clrscr();
|
||||||
showcursor();
|
showcursor();
|
||||||
gotoxy(CursorXPos, CursorYPos);
|
|
||||||
|
|
||||||
stop_floppy();
|
stop_floppy();
|
||||||
JumpToBootCode();*/
|
JumpToBootCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
|
VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
|
||||||
|
@ -212,9 +188,10 @@ VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
|
||||||
|
|
||||||
BootDrive = atoi(SettingValue);
|
BootDrive = atoi(SettingValue);
|
||||||
|
|
||||||
if (!BiosInt13Read(BootDrive, 0, 0, 1, 1, (PVOID)0x7C00))
|
// Now try to read the boot sector (or mbr)
|
||||||
|
// If this fails then abort
|
||||||
|
if (!DiskReadLogicalSectors(BootDrive, 0, 1, (PVOID)0x7C00))
|
||||||
{
|
{
|
||||||
DiskError("Disk read error.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue