2019-09-03 11:58:42 +02:00
|
|
|
/*
|
|
|
|
* refit/scan/legacy.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006-2010 Christoph Pfisterer
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of Christoph Pfisterer nor the names of the
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2021-02-07 15:39:03 +01:00
|
|
|
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
2019-09-03 11:58:42 +02:00
|
|
|
#include "entry_scan.h"
|
2020-02-29 08:30:21 +01:00
|
|
|
#include "../refit/screen.h"
|
|
|
|
#include "../refit/menu.h"
|
2020-08-09 17:55:30 +02:00
|
|
|
#include "../gui/REFIT_MENU_SCREEN.h"
|
2021-03-22 13:40:01 +01:00
|
|
|
#include "../gui/REFIT_MAINMENU_SCREEN.h"
|
2021-02-04 15:04:31 +01:00
|
|
|
#include "../Platform/Volumes.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
#include "../libeg/XTheme.h"
|
|
|
|
#include "../include/OSFlags.h"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
#ifndef DEBUG_ALL
|
|
|
|
#define DEBUG_SCAN_LEGACY 1
|
|
|
|
#else
|
|
|
|
#define DEBUG_SCAN_LEGACY DEBUG_ALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_SCAN_LEGACY == 0
|
|
|
|
#define DBG(...)
|
|
|
|
#else
|
|
|
|
#define DBG(...) DebugLog(DEBUG_SCAN_LEGACY, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2020-03-04 07:20:37 +01:00
|
|
|
//the function is not in the class and deals always with MainMenu
|
2020-04-03 22:00:42 +02:00
|
|
|
//I made args as pointers to have an ability to call with NULL
|
2021-09-28 10:28:45 +02:00
|
|
|
XBool AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& _LoaderTitle, IN REFIT_VOLUME *Volume, IN const XIcon* Image, IN const XIcon* DriveImage, IN char32_t Hotkey, IN XBool CustomEntry)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
LEGACY_ENTRY *Entry, *SubEntry;
|
|
|
|
REFIT_MENU_SCREEN *SubScreen;
|
2020-08-09 17:55:30 +02:00
|
|
|
XStringW VolDesc;
|
2019-09-03 11:58:42 +02:00
|
|
|
CHAR16 ShortcutLetter = 0;
|
2020-02-28 21:28:33 +01:00
|
|
|
// INTN i;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-04-23 14:20:48 +02:00
|
|
|
DBG(" AddLegacyEntry:\n");
|
2022-01-25 18:07:33 +01:00
|
|
|
if (Volume == NULL) {
|
|
|
|
DBG(" Volume==0\n");
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-23 14:20:48 +02:00
|
|
|
DBG(" FullTitle=%ls\n", FullTitle.wc_str());
|
|
|
|
DBG(" LoaderTitle=%ls\n", _LoaderTitle.wc_str());
|
|
|
|
DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// Ignore this loader if it's device path is already present in another loader
|
2021-04-23 14:20:48 +02:00
|
|
|
for (UINTN i = 0; i < MainMenu.Entries.size(); ++i) {
|
|
|
|
REFIT_ABSTRACT_MENU_ENTRY& MainEntry = MainMenu.Entries[i];
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG("entry %lld\n", i);
|
2021-04-23 14:20:48 +02:00
|
|
|
// Only want legacy
|
|
|
|
if (MainEntry.getLEGACY_ENTRY()) {
|
|
|
|
if ( MainEntry.getLEGACY_ENTRY()->DevicePathString.isEqualIC(Volume->DevicePathString) ) {
|
|
|
|
return true;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-23 14:20:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
XStringW LoaderTitle;
|
|
|
|
if ( _LoaderTitle.isEmpty() ) {
|
|
|
|
LoaderTitle = Volume->LegacyOS->Name;
|
|
|
|
}else{
|
|
|
|
LoaderTitle = _LoaderTitle;
|
|
|
|
}
|
|
|
|
|
2020-04-03 22:00:42 +02:00
|
|
|
XStringW LTitle;
|
2020-04-04 05:46:41 +02:00
|
|
|
if (LoaderTitle.isEmpty()) {
|
2020-08-10 13:06:06 +02:00
|
|
|
if (Volume->LegacyOS->Name.notEmpty()) {
|
2020-04-03 22:00:42 +02:00
|
|
|
LTitle.takeValueFrom(Volume->LegacyOS->Name);
|
|
|
|
if (Volume->LegacyOS->Name[0] == 'W' || Volume->LegacyOS->Name[0] == 'L')
|
2020-11-02 14:45:11 +01:00
|
|
|
ShortcutLetter = (wchar_t)Volume->LegacyOS->Name[0]; // cast safe because value is 'W' or 'L'
|
2020-04-03 22:00:42 +02:00
|
|
|
} else
|
|
|
|
LTitle = L"Legacy OS"_XSW;
|
|
|
|
} else
|
2020-04-04 05:46:41 +02:00
|
|
|
LTitle = LoaderTitle;
|
2020-08-09 17:55:30 +02:00
|
|
|
if (Volume->VolName.notEmpty())
|
2019-09-03 11:58:42 +02:00
|
|
|
VolDesc = Volume->VolName;
|
|
|
|
else
|
2020-08-09 17:55:30 +02:00
|
|
|
VolDesc.takeValueFrom((Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : L"HD");
|
2020-03-25 19:32:44 +01:00
|
|
|
//DBG("VolDesc=%ls\n", VolDesc);
|
2020-04-03 22:00:42 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// prepare the menu entry
|
2021-05-05 19:10:10 +02:00
|
|
|
Entry = new LEGACY_ENTRY;
|
2021-04-23 14:20:48 +02:00
|
|
|
if ( FullTitle.notEmpty() ) {
|
2020-04-04 05:46:41 +02:00
|
|
|
Entry->Title = FullTitle;
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2020-03-26 15:24:20 +01:00
|
|
|
if (ThemeX.BootCampStyle) {
|
2020-04-03 22:00:42 +02:00
|
|
|
Entry->Title = LTitle;
|
2020-03-26 15:24:20 +01:00
|
|
|
} else {
|
2021-04-23 14:20:48 +02:00
|
|
|
Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle.wc_str(), VolDesc.wc_str());
|
2020-03-26 15:24:20 +01:00
|
|
|
}
|
2020-04-03 22:00:42 +02:00
|
|
|
}
|
2021-04-23 14:20:48 +02:00
|
|
|
DBG(" Entry->Title=%ls\n", Entry->Title.wc_str());
|
2020-03-26 15:24:20 +01:00
|
|
|
|
2020-02-28 21:28:33 +01:00
|
|
|
Entry->Row = 0;
|
|
|
|
Entry->ShortcutLetter = (Hotkey == 0) ? ShortcutLetter : Hotkey;
|
2020-03-26 15:24:20 +01:00
|
|
|
|
2021-04-23 14:20:48 +02:00
|
|
|
if ( Image && !Image->isEmpty() ) {
|
2020-04-03 22:00:42 +02:00
|
|
|
Entry->Image = *Image;
|
2020-03-26 15:24:20 +01:00
|
|
|
} else {
|
2020-04-05 23:14:27 +02:00
|
|
|
Entry->Image = ThemeX.LoadOSIcon(Volume->LegacyOS->IconName);
|
2020-05-16 21:30:29 +02:00
|
|
|
if (Entry->Image.Image.isEmpty()) {
|
2020-04-30 08:22:26 +02:00
|
|
|
Entry->Image = ThemeX.GetIcon("os_win"_XS8); //we have no legacy.png
|
2020-04-03 22:00:42 +02:00
|
|
|
}
|
2020-03-26 15:24:20 +01:00
|
|
|
}
|
|
|
|
|
2020-03-25 19:32:44 +01:00
|
|
|
// DBG("IconName=%ls\n", Volume->LegacyOS->IconName);
|
2020-04-10 12:04:21 +02:00
|
|
|
|
2020-04-03 22:00:42 +02:00
|
|
|
Entry->DriveImage = (DriveImage != NULL) ? *DriveImage : ScanVolumeDefaultIcon(Volume, Volume->LegacyOS->Type, Volume->DevicePath);
|
|
|
|
|
2020-03-25 19:32:44 +01:00
|
|
|
// DBG("HideBadges=%d Volume=%ls\n", GlobalConfig.HideBadges, Volume->VolName);
|
|
|
|
// DBG("Title=%ls OSName=%ls OSIconName=%ls\n", LoaderTitle, Volume->OSName, Volume->OSIconName);
|
2019-09-03 11:58:42 +02:00
|
|
|
//actions
|
2020-02-28 21:28:33 +01:00
|
|
|
Entry->AtClick = ActionSelect;
|
|
|
|
Entry->AtDoubleClick = ActionEnter;
|
|
|
|
Entry->AtRightClick = ActionDetails;
|
2020-03-24 16:17:12 +01:00
|
|
|
if (ThemeX.HideBadges & HDBADGES_SHOW) {
|
2020-04-21 11:08:55 +02:00
|
|
|
if (ThemeX.HideBadges & HDBADGES_SWAP) { //will be scaled later
|
2020-05-16 21:30:29 +02:00
|
|
|
Entry->BadgeImage.Image = XImage(Entry->DriveImage.Image, 0); //ThemeX.BadgeScale/16.f); //0 accepted
|
2020-03-24 16:17:12 +01:00
|
|
|
} else {
|
2020-05-16 21:30:29 +02:00
|
|
|
Entry->BadgeImage.Image = XImage(Entry->Image.Image, 0); //ThemeX.BadgeScale/16.f);
|
2020-03-24 16:17:12 +01:00
|
|
|
}
|
|
|
|
}
|
2019-09-03 11:58:42 +02:00
|
|
|
Entry->Volume = Volume;
|
|
|
|
Entry->DevicePathString = Volume->DevicePathString;
|
2020-04-30 08:22:26 +02:00
|
|
|
// Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD"_XS8 : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB"_XS8 : "HD"_XS8);
|
2020-04-26 15:07:30 +02:00
|
|
|
Entry->LoadOptions.setEmpty();
|
|
|
|
Entry->LoadOptions.Add((Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD" : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB" : "HD"));
|
2020-08-15 22:39:25 +02:00
|
|
|
|
|
|
|
// If this isn't a custom entry make sure it's not hidden by a custom entry
|
|
|
|
if (!CustomEntry) {
|
2021-03-23 20:59:30 +01:00
|
|
|
for (size_t CustomIndex = 0 ; CustomIndex < GlobalConfig.CustomLegacyEntries.size() ; ++CustomIndex ) {
|
|
|
|
CUSTOM_LEGACY_ENTRY& Custom = GlobalConfig.CustomLegacyEntries[CustomIndex];
|
|
|
|
if ( Custom.settings.Disabled || OSFLAG_ISSET(Custom.getFlags(), OSFLAG_DISABLED) || Custom.settings.Hidden ) {
|
|
|
|
if (Custom.settings.Volume.notEmpty()) {
|
|
|
|
if ( !Volume->DevicePathString.contains(Custom.settings.Volume) && !Volume->VolName.contains(Custom.settings.Volume) ) {
|
|
|
|
if (Custom.settings.Type != 0) {
|
|
|
|
if (Custom.settings.Type == Volume->LegacyOS->Type) {
|
2020-08-15 22:39:25 +02:00
|
|
|
Entry->Hidden = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Entry->Hidden = true;
|
|
|
|
}
|
|
|
|
}
|
2021-03-23 20:59:30 +01:00
|
|
|
} else if (Custom.settings.Type != 0) {
|
|
|
|
if (Custom.settings.Type == Volume->LegacyOS->Type) {
|
2020-08-15 22:39:25 +02:00
|
|
|
Entry->Hidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// create the submenu
|
2021-05-05 19:10:10 +02:00
|
|
|
SubScreen = new REFIT_MENU_SCREEN;
|
2020-04-10 12:04:21 +02:00
|
|
|
// SubScreen->Title = L"Boot Options for "_XSW + LoaderTitle + L" on "_XSW + VolDesc;
|
2020-08-09 17:55:30 +02:00
|
|
|
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle.wc_str(), VolDesc.wc_str());
|
2020-04-10 12:04:21 +02:00
|
|
|
|
2020-05-16 21:30:29 +02:00
|
|
|
SubScreen->TitleImage = Entry->Image; //it is XIcon
|
2020-04-15 18:30:39 +02:00
|
|
|
SubScreen->ID = SCREEN_BOOT;
|
|
|
|
SubScreen->GetAnime();
|
2019-09-03 11:58:42 +02:00
|
|
|
// default entry
|
2021-05-05 19:10:10 +02:00
|
|
|
SubEntry = new LEGACY_ENTRY;
|
2020-04-04 05:46:41 +02:00
|
|
|
SubEntry->Title = L"Boot "_XSW + LoaderTitle;
|
2020-02-28 21:28:33 +01:00
|
|
|
// SubEntry->Tag = TAG_LEGACY;
|
2019-09-03 11:58:42 +02:00
|
|
|
SubEntry->Volume = Entry->Volume;
|
|
|
|
SubEntry->DevicePathString = Entry->DevicePathString;
|
|
|
|
SubEntry->LoadOptions = Entry->LoadOptions;
|
2020-02-28 21:28:33 +01:00
|
|
|
SubEntry->AtClick = ActionEnter;
|
2020-03-03 21:44:07 +01:00
|
|
|
SubScreen->AddMenuEntry(SubEntry, true);
|
|
|
|
SubScreen->AddMenuEntry(&MenuEntryReturn, false);
|
2020-02-28 21:28:33 +01:00
|
|
|
Entry->SubScreen = SubScreen;
|
2020-03-03 21:44:07 +01:00
|
|
|
MainMenu.AddMenuEntry(Entry, true);
|
2020-03-25 19:32:44 +01:00
|
|
|
// DBG(" added '%ls' OSType=%d Icon=%ls\n", Entry->Title, Volume->LegacyOS->Type, Volume->LegacyOS->IconName);
|
2020-03-04 07:20:37 +01:00
|
|
|
return true;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
void ScanLegacy(void)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
UINTN VolumeIndex, VolumeIndex2;
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool ShowVolume, HideIfOthersFound;
|
2019-09-03 11:58:42 +02:00
|
|
|
REFIT_VOLUME *Volume;
|
|
|
|
|
|
|
|
DBG("Scanning legacy ...\n");
|
|
|
|
|
2020-02-27 15:34:29 +01:00
|
|
|
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) {
|
|
|
|
Volume = &Volumes[VolumeIndex];
|
2019-09-03 11:58:42 +02:00
|
|
|
if ((Volume->BootType != BOOTING_BY_PBR) &&
|
|
|
|
(Volume->BootType != BOOTING_BY_MBR) &&
|
|
|
|
(Volume->BootType != BOOTING_BY_CD)) {
|
|
|
|
// DBG(" not legacy\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-04-23 11:08:10 +02:00
|
|
|
if (((1ull<<Volume->DiskKind) & GlobalConfig.DisableFlags) != 0)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG(" hidden\n");
|
2019-09-03 11:58:42 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG("not hidden\n");
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = false;
|
|
|
|
HideIfOthersFound = false;
|
2019-09-03 11:58:42 +02:00
|
|
|
if (Volume->IsAppleLegacy) {
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = true;
|
|
|
|
HideIfOthersFound = true;
|
2019-09-03 11:58:42 +02:00
|
|
|
} else if (Volume->HasBootCode) {
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = true;
|
2019-09-03 11:58:42 +02:00
|
|
|
if ((Volume->WholeDiskBlockIO == 0) &&
|
2023-06-16 23:44:39 +02:00
|
|
|
Volume->BlockIOOffset == 0 )
|
2019-09-03 11:58:42 +02:00
|
|
|
// this is a whole disk (MBR) entry; hide if we have entries for partitions
|
2021-09-28 10:28:45 +02:00
|
|
|
HideIfOthersFound = true;
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG("Hide it!\n");
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
if (HideIfOthersFound) {
|
|
|
|
// check for other bootable entries on the same disk
|
|
|
|
//if PBR exists then Hide MBR
|
2020-02-27 15:34:29 +01:00
|
|
|
for (VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) {
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG("what to hide %d\n", VolumeIndex2);
|
2019-09-03 11:58:42 +02:00
|
|
|
if (VolumeIndex2 != VolumeIndex &&
|
2020-02-27 15:34:29 +01:00
|
|
|
Volumes[VolumeIndex2].HasBootCode &&
|
|
|
|
Volumes[VolumeIndex2].WholeDiskBlockIO == Volume->BlockIO){
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = false;
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG("PBR volume at index %d\n", VolumeIndex2);
|
2019-09-03 11:58:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ShowVolume && (!Volume->Hidden)){
|
2020-03-04 07:20:37 +01:00
|
|
|
// DBG(" add legacy\n");
|
2021-09-28 10:28:45 +02:00
|
|
|
if (!AddLegacyEntry(L""_XSW, L""_XSW, Volume, NULL, NULL, 0, false)) {
|
2020-03-04 07:20:37 +01:00
|
|
|
DBG("...entry not added\n");
|
|
|
|
};
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
|
|
|
DBG(" hidden\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add custom legacy
|
2020-10-03 19:02:31 +02:00
|
|
|
void AddCustomLegacy(void)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
UINTN VolumeIndex, VolumeIndex2;
|
2021-09-28 15:54:31 +02:00
|
|
|
XBool ShowVolume, HideIfOthersFound;
|
2019-09-03 11:58:42 +02:00
|
|
|
REFIT_VOLUME *Volume;
|
2020-05-16 21:30:29 +02:00
|
|
|
XIcon MainIcon;
|
|
|
|
XIcon DriveIcon;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// DBG("Custom legacy start\n");
|
2021-03-23 20:59:30 +01:00
|
|
|
if (GlobalConfig.CustomLegacyEntries.notEmpty()) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DbgHeader("AddCustomLegacy");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Traverse the custom entries
|
2021-03-23 20:59:30 +01:00
|
|
|
for (size_t i = 0 ; i < GlobalConfig.CustomLegacyEntries.size() ; ++i ) {
|
|
|
|
CUSTOM_LEGACY_ENTRY& Custom = GlobalConfig.CustomLegacyEntries[i];
|
|
|
|
if (Custom.settings.Disabled || OSFLAG_ISSET(Custom.getFlags(), OSFLAG_DISABLED)) {
|
2021-03-19 21:32:42 +01:00
|
|
|
DBG("Custom legacy %zu skipped because it is disabled.\n", i);
|
2019-09-03 11:58:42 +02:00
|
|
|
continue;
|
|
|
|
}
|
2021-03-19 21:32:42 +01:00
|
|
|
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.Flags, OSFLAG_HIDDEN)) {
|
2020-08-15 22:39:25 +02:00
|
|
|
// DBG("Custom legacy %llu skipped because it is hidden.\n", i);
|
|
|
|
// continue;
|
|
|
|
// }
|
2021-03-23 20:59:30 +01:00
|
|
|
if (Custom.settings.Volume.notEmpty()) {
|
|
|
|
DBG("Custom legacy %zu matching \"%ls\" ...\n", i, Custom.settings.Volume.wc_str());
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2020-02-27 15:34:29 +01:00
|
|
|
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
|
|
|
|
Volume = &Volumes[VolumeIndex];
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-08-09 17:55:30 +02:00
|
|
|
DBG(" Checking volume \"%ls\" (%ls) ... ", Volume->VolName.wc_str(), Volume->DevicePathString.wc_str());
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// skip volume if its kind is configured as disabled
|
2020-04-23 11:08:10 +02:00
|
|
|
if (((1ull<<Volume->DiskKind) & GlobalConfig.DisableFlags) != 0)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
DBG("skipped because media is disabled\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-03-23 20:59:30 +01:00
|
|
|
if (Custom.settings.VolumeType != 0) {
|
|
|
|
if (((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) == 0) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("skipped because media is ignored\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2021-04-23 14:20:48 +02:00
|
|
|
if ((Volume->BootType != BOOTING_BY_PBR) &&
|
|
|
|
(Volume->BootType != BOOTING_BY_MBR) &&
|
|
|
|
(Volume->BootType != BOOTING_BY_CD)) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("skipped because volume is not legacy bootable\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = false;
|
|
|
|
HideIfOthersFound = false;
|
2019-09-03 11:58:42 +02:00
|
|
|
if (Volume->IsAppleLegacy) {
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = true;
|
|
|
|
HideIfOthersFound = true;
|
2019-09-03 11:58:42 +02:00
|
|
|
} else if (Volume->HasBootCode) {
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = true;
|
2019-09-03 11:58:42 +02:00
|
|
|
if ((Volume->WholeDiskBlockIO == 0) &&
|
|
|
|
Volume->BlockIOOffset == 0) {
|
|
|
|
// this is a whole disk (MBR) entry; hide if we have entries for partitions
|
2021-09-28 10:28:45 +02:00
|
|
|
HideIfOthersFound = true;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (HideIfOthersFound) {
|
|
|
|
// check for other bootable entries on the same disk
|
|
|
|
//if PBR exists then Hide MBR
|
2020-02-27 15:34:29 +01:00
|
|
|
for (VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) {
|
2019-09-03 11:58:42 +02:00
|
|
|
if (VolumeIndex2 != VolumeIndex &&
|
2020-02-27 15:34:29 +01:00
|
|
|
Volumes[VolumeIndex2].HasBootCode &&
|
|
|
|
Volumes[VolumeIndex2].WholeDiskBlockIO == Volume->BlockIO) {
|
2021-09-28 10:28:45 +02:00
|
|
|
ShowVolume = false;
|
2019-09-03 11:58:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 14:20:48 +02:00
|
|
|
if ( !ShowVolume ) {
|
|
|
|
DBG("skipped because volume ShowVolume==false\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( Volume->Hidden ) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("skipped because volume is hidden\n");
|
|
|
|
continue;
|
|
|
|
}
|
2021-04-23 14:20:48 +02:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// Check for exact volume matches
|
2021-03-23 20:59:30 +01:00
|
|
|
if (Custom.settings.Volume.notEmpty()) {
|
|
|
|
if ((StrStr(Volume->DevicePathString.wc_str(), Custom.settings.Volume.wc_str()) == NULL) &&
|
|
|
|
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.settings.Volume.wc_str()) == NULL))) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("skipped\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Check if the volume should be of certain os type
|
2021-03-23 20:59:30 +01:00
|
|
|
if ((Custom.settings.Type != 0) && (Custom.settings.Type != Volume->LegacyOS->Type)) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("skipped because wrong type\n");
|
|
|
|
continue;
|
|
|
|
}
|
2021-03-23 20:59:30 +01:00
|
|
|
} else if ((Custom.settings.Type != 0) && (Custom.settings.Type != Volume->LegacyOS->Type)) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG("skipped because wrong type\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Change to custom image if needed
|
2021-03-19 21:32:42 +01:00
|
|
|
MainIcon = Custom.Image;
|
2020-05-16 21:30:29 +02:00
|
|
|
if (MainIcon.Image.isEmpty()) {
|
2021-03-23 20:59:30 +01:00
|
|
|
MainIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.ImagePath);
|
2020-04-03 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
// Change to custom drive image if needed
|
2021-03-19 21:32:42 +01:00
|
|
|
DriveIcon = Custom.DriveImage;
|
2020-05-16 21:30:29 +02:00
|
|
|
if (DriveIcon.Image.isEmpty()) {
|
2021-03-23 20:59:30 +01:00
|
|
|
DriveIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.DriveImagePath);
|
2020-04-03 22:00:42 +02:00
|
|
|
}
|
|
|
|
// Create a legacy entry for this volume
|
2021-04-23 14:20:48 +02:00
|
|
|
DBG("\n");
|
2021-09-28 10:28:45 +02:00
|
|
|
if (AddLegacyEntry(Custom.settings.FullTitle, Custom.settings.Title, Volume, &MainIcon, &DriveIcon, Custom.settings.Hotkey, true))
|
2020-04-03 22:00:42 +02:00
|
|
|
{
|
2021-04-23 14:20:48 +02:00
|
|
|
// DBG("match!\n");
|
2020-04-03 22:00:42 +02:00
|
|
|
}
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//DBG("Custom legacy end\n");
|
|
|
|
}
|