Skip to content

Commit 6ed46ba

Browse files
authored
[FREELDR] Improve disk detection (reactos#8074)
Improve disk detection on UEFI by using PublicBootHandle index JIRA issue: CORE-11954
1 parent 6243d16 commit 6ed46ba

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

boot/freeldr/freeldr/arch/uefi/uefidisk.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -431,30 +431,23 @@ UefiSetupBlockDevices(VOID)
431431
}
432432
else if (handles[i] == PublicBootHandle)
433433
{
434-
ULONG increment = 0;
435-
ULONG i;
436-
437-
/* 3) Grab the offset into the array of handles and decrement per volume (valid partition) */
438-
for (increment = OffsetToBoot; increment > 0; increment--)
434+
GlobalSystemTable->BootServices->HandleProtocol(handles[i], &bioGuid, (void**)&bio);
435+
if (bio->Media->LogicalPartition == FALSE)
439436
{
440-
GlobalSystemTable->BootServices->HandleProtocol(handles[increment], &bioGuid, (void**)&bio);
441-
if (bio->Media->LogicalPartition == FALSE)
442-
{
443-
TRACE("Found root at increment %u\n", increment);
444-
UefiBootRootIdentifier = increment;
437+
ULONG j;
438+
439+
TRACE("Found root at index %u\n", i);
440+
UefiBootRootIdentifier = i;
445441

446-
for (i = 0; i <= PcBiosDiskCount; ++i)
442+
for (j = 0; j <= PcBiosDiskCount; ++j)
443+
{
444+
/* Now only of the root drive number is equal to this drive we found above */
445+
if (InternalUefiDisk[j].UefiRootNumber == UefiBootRootIdentifier)
447446
{
448-
/* Now only of the root drive number is equal to this drive we found above */
449-
if (InternalUefiDisk[i].UefiRootNumber == UefiBootRootIdentifier)
450-
{
451-
InternalUefiDisk[i].IsThisTheBootDrive = TRUE;
452-
PublicBootArcDisk = i;
453-
TRACE("Found Boot drive\n");
454-
}
447+
InternalUefiDisk[j].IsThisTheBootDrive = TRUE;
448+
PublicBootArcDisk = j;
449+
TRACE("Found Boot drive\n");
455450
}
456-
457-
break;
458451
}
459452
}
460453
}

0 commit comments

Comments
 (0)