| 1070 | } |
| 1071 | |
| 1072 | VOID ScanVolumes(VOID) |
| 1073 | { |
| 1074 | EFI_STATUS Status; |
| 1075 | UINTN HandleCount = 0; |
| 1076 | UINTN HandleIndex; |
| 1077 | EFI_HANDLE *Handles = NULL; |
| 1078 | REFIT_VOLUME *WholeDiskVolume; |
| 1079 | UINTN VolumeIndex, VolumeIndex2; |
| 1080 | MBR_PARTITION_INFO *MbrTable; |
| 1081 | UINTN PartitionIndex; |
| 1082 | UINT8 *SectorBuffer1, *SectorBuffer2; |
| 1083 | UINTN SectorSum, i; |
| 1084 | // EFI_DEVICE_PATH_PROTOCOL *VolumeDevicePath; |
| 1085 | // EFI_GUID *Guid; //for debug only |
| 1086 | // EFI_INPUT_KEY Key; |
| 1087 | |
| 1088 | // DBG("Scanning volumes...\n"); |
| 1089 | DbgHeader("ScanVolumes"); |
| 1090 | |
| 1091 | // get all BlockIo handles |
| 1092 | Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &HandleCount, &Handles); |
| 1093 | if (Status == EFI_NOT_FOUND) |
| 1094 | return; |
| 1095 | DBG("Found %llu volumes with blockIO\n", HandleCount); |
| 1096 | // first pass: collect information about all handles |
| 1097 | for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { |
| 1098 | |
| 1099 | REFIT_VOLUME* Volume = new REFIT_VOLUME; |
| 1100 | Volume->LegacyOS = new LEGACY_OS; |
| 1101 | Volume->DeviceHandle = Handles[HandleIndex]; |
| 1102 | if (Volume->DeviceHandle == SelfDeviceHandle) { |
| 1103 | SelfVolume = Volume; |
| 1104 | } |
| 1105 | |
| 1106 | DBG("- [%02llu]: Volume:", HandleIndex); |
| 1107 | |
| 1108 | Volume->Hidden = FALSE; // default to not hidden |
| 1109 | |
| 1110 | Status = ScanVolume(Volume); |
| 1111 | if (!EFI_ERROR(Status)) { |
| 1112 | Volumes.AddReference(Volume, false); |
| 1113 | for (size_t HVi = 0; HVi < gSettings.HVHideStrings.size(); HVi++) { |
| 1114 | if ( Volume->DevicePathString.containsIC(gSettings.HVHideStrings[HVi]) || |
| 1115 | Volume->VolName.containsIC(gSettings.HVHideStrings[HVi]) |
| 1116 | ) { |
| 1117 | Volume->Hidden = TRUE; |
| 1118 | DBG(" hiding this volume\n"); |
| 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | // Guid = FindGPTPartitionGuidInDevicePath(Volume->DevicePath); |
| 1123 | if (Volume->LegacyOS->IconName.isEmpty()) { |
| 1124 | Volume->LegacyOS->IconName = L"legacy"_XSW; |
| 1125 | } |
| 1126 | // DBG(" Volume '%ls', LegacyOS '%ls', LegacyIcon(s) '%ls', GUID = %s\n", |
| 1127 | // Volume->VolName, Volume->LegacyOS->Name ? Volume->LegacyOS->Name : L"", Volume->LegacyOS->IconName, strguid(Guid)); |
| 1128 | if (SelfVolume == Volume) { |
| 1129 | DBG(" This is SelfVolume !!\n"); |
no test coverage detected