2019-09-03 11:58:42 +02:00
|
|
|
/*
|
|
|
|
* refit/scan/tool.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/menu.h"
|
|
|
|
#include "../refit/screen.h"
|
2020-03-30 10:34:16 +02:00
|
|
|
#include "../libeg/XImage.h"
|
2020-04-26 15:07:30 +02:00
|
|
|
#include "../refit/lib.h"
|
|
|
|
#include "../gui/REFIT_MENU_SCREEN.h"
|
2021-03-22 13:40:01 +01:00
|
|
|
#include "../gui/REFIT_MAINMENU_SCREEN.h"
|
2021-04-28 20:30:34 +02:00
|
|
|
#include "../Settings/Self.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"
|
2021-02-04 15:04:31 +01:00
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
//
|
|
|
|
// Clover File location to boot from on removable media devices
|
|
|
|
//
|
2020-10-03 19:02:31 +02:00
|
|
|
#define CLOVER_MEDIA_FILE_NAME_IA32 L"CLOVERIA32.EFI"_XSW
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME_IA64 L"CLOVERIA64.EFI"_XSW
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME_X64 L"CLOVERX64.EFI"_XSW
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME_ARM L"CLOVERARM.EFI"_XSW
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
#if defined (MDE_CPU_IA32)
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME CLOVER_MEDIA_FILE_NAME_IA32
|
|
|
|
#elif defined (MDE_CPU_IPF)
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME CLOVER_MEDIA_FILE_NAME_IA64
|
|
|
|
#elif defined (MDE_CPU_X64)
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME CLOVER_MEDIA_FILE_NAME_X64
|
|
|
|
#elif defined (MDE_CPU_EBC)
|
|
|
|
#elif defined (MDE_CPU_ARM)
|
|
|
|
#define CLOVER_MEDIA_FILE_NAME CLOVER_MEDIA_FILE_NAME_ARM
|
|
|
|
//#else
|
|
|
|
//#error Unknown Processor Type
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DEBUG_ALL
|
2022-08-01 21:34:35 +02:00
|
|
|
#define DEBUG_SCAN_TOOL 1
|
2019-09-03 11:58:42 +02:00
|
|
|
#else
|
|
|
|
#define DEBUG_SCAN_TOOL DEBUG_ALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_SCAN_TOOL == 0
|
|
|
|
#define DBG(...)
|
|
|
|
#else
|
|
|
|
#define DBG(...) DebugLog(DEBUG_SCAN_TOOL, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2021-09-28 10:28:45 +02:00
|
|
|
STATIC XBool AddToolEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
|
2020-05-16 21:30:29 +02:00
|
|
|
IN REFIT_VOLUME *Volume, const XIcon& Image,
|
2023-11-26 15:10:53 +01:00
|
|
|
IN wchar_t ShortcutLetter, IN CONST XString8Array& Options)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
2020-02-28 21:28:33 +01:00
|
|
|
REFIT_MENU_ENTRY_LOADER_TOOL *Entry;
|
2019-09-03 11:58:42 +02:00
|
|
|
// Check the loader exists
|
2020-04-27 11:50:49 +02:00
|
|
|
if ((LoaderPath.isEmpty()) || (Volume == NULL) || (Volume->RootDir == NULL) ||
|
2020-04-27 14:13:09 +02:00
|
|
|
!FileExists(Volume->RootDir, LoaderPath)) {
|
2021-09-28 10:28:45 +02:00
|
|
|
return false;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
// Allocate the entry
|
2021-05-05 19:10:10 +02:00
|
|
|
Entry = new REFIT_MENU_ENTRY_LOADER_TOOL;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
if (FullTitle) {
|
2020-03-10 17:50:55 +01:00
|
|
|
Entry->Title.takeValueFrom(FullTitle);
|
2019-09-03 11:58:42 +02:00
|
|
|
} else {
|
2020-03-31 18:10:30 +02:00
|
|
|
Entry->Title.SWPrintf("Start %ls", LoaderTitle);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2020-02-28 21:28:33 +01:00
|
|
|
// Entry->Tag = TAG_TOOL;
|
|
|
|
Entry->Row = 1;
|
|
|
|
Entry->ShortcutLetter = ShortcutLetter;
|
|
|
|
Entry->Image = Image;
|
|
|
|
// Entry->ImageHover = ImageHover;
|
2020-04-27 11:50:49 +02:00
|
|
|
Entry->LoaderPath = LoaderPath;
|
2020-04-27 14:13:09 +02:00
|
|
|
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
|
2020-08-09 17:55:30 +02:00
|
|
|
Entry->DevicePathString = FileDevicePathToXStringW(Entry->DevicePath);
|
2020-04-05 14:25:39 +02:00
|
|
|
Entry->LoadOptions = Options;
|
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 = ActionHelp;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-04-27 11:50:49 +02:00
|
|
|
DBG("found tool %ls\n", LoaderPath.s());
|
2020-03-03 21:44:07 +01:00
|
|
|
MainMenu.AddMenuEntry(Entry, true);
|
2021-09-28 10:28:45 +02:00
|
|
|
return true;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
STATIC void AddCloverEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
2020-02-28 21:28:33 +01:00
|
|
|
REFIT_MENU_ENTRY_CLOVER *Entry;
|
2020-03-10 10:45:17 +01:00
|
|
|
REFIT_MENU_ENTRY_CLOVER *SubEntry;
|
2019-09-03 11:58:42 +02:00
|
|
|
REFIT_MENU_SCREEN *SubScreen;
|
|
|
|
// EFI_STATUS Status;
|
|
|
|
|
|
|
|
// prepare the menu entry
|
2021-05-05 19:10:10 +02:00
|
|
|
Entry = new REFIT_MENU_ENTRY_CLOVER;
|
2020-03-10 17:50:55 +01:00
|
|
|
Entry->Title.takeValueFrom(LoaderTitle);
|
2020-02-28 21:28:33 +01:00
|
|
|
// Entry->Tag = TAG_CLOVER;
|
|
|
|
Entry->Row = 1;
|
2023-11-26 15:10:53 +01:00
|
|
|
Entry->ShortcutLetter = L'C';
|
2023-11-06 21:53:57 +01:00
|
|
|
Entry->Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_CLOVER);
|
2019-09-03 11:58:42 +02:00
|
|
|
Entry->Volume = Volume;
|
2020-04-27 11:50:49 +02:00
|
|
|
Entry->LoaderPath = LoaderPath;
|
2019-09-03 11:58:42 +02:00
|
|
|
Entry->VolName = Volume->VolName;
|
2020-04-27 14:13:09 +02:00
|
|
|
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
|
2020-08-09 17:55:30 +02:00
|
|
|
Entry->DevicePathString = FileDevicePathToXStringW(Entry->DevicePath);
|
2019-09-03 11:58:42 +02:00
|
|
|
Entry->Flags = 0;
|
2020-04-05 14:25:39 +02:00
|
|
|
Entry->LoadOptions.setEmpty();
|
2020-03-10 10:45:17 +01:00
|
|
|
// Entry->LoaderType = OSTYPE_OTHER;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
//actions
|
2020-02-28 21:28:33 +01:00
|
|
|
Entry->AtClick = ActionEnter;
|
|
|
|
Entry->AtDoubleClick = ActionDetails;
|
|
|
|
Entry->AtRightClick = ActionDetails;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// create the submenu
|
2020-03-04 07:21:43 +01:00
|
|
|
SubScreen = new REFIT_MENU_SCREEN;
|
2020-04-10 12:04:21 +02:00
|
|
|
|
2020-03-22 11:48:13 +01:00
|
|
|
SubScreen->Title.takeValueFrom(LoaderTitle);
|
|
|
|
|
2020-05-16 21:30:29 +02:00
|
|
|
SubScreen->TitleImage = Entry->Image;
|
2019-09-03 11:58:42 +02:00
|
|
|
SubScreen->ID = SCREEN_BOOT;
|
2020-04-15 18:30:39 +02:00
|
|
|
SubScreen->GetAnime();
|
2020-08-09 17:55:30 +02:00
|
|
|
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToXStringW(Volume->DevicePath).wc_str());
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
if (gEmuVariableControl != NULL) {
|
|
|
|
gEmuVariableControl->UninstallEmulation(gEmuVariableControl);
|
|
|
|
}
|
|
|
|
|
|
|
|
//always add and always remove menu entries
|
2020-03-10 10:45:17 +01:00
|
|
|
SubEntry = Entry->getPartiallyDuplicatedEntry();
|
2019-09-03 11:58:42 +02:00
|
|
|
if (SubEntry) {
|
2020-03-31 18:10:30 +02:00
|
|
|
SubEntry->Title.SWPrintf("Add Clover boot options for all entries");
|
2020-04-26 15:07:30 +02:00
|
|
|
SubEntry->LoadOptions.setEmpty();
|
2022-08-01 21:34:35 +02:00
|
|
|
SubEntry->LoadOptions.Add(L"BO-ADD");
|
|
|
|
SubEntry->AtDoubleClick = ActionEnter;
|
2020-03-03 21:44:07 +01:00
|
|
|
SubScreen->AddMenuEntry(SubEntry, true);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
SubEntry = Entry->getPartiallyDuplicatedEntry();
|
2019-09-03 11:58:42 +02:00
|
|
|
if (SubEntry) {
|
2020-03-31 18:10:30 +02:00
|
|
|
SubEntry->Title.SWPrintf("Remove all Clover boot options");
|
2020-04-26 15:07:30 +02:00
|
|
|
SubEntry->LoadOptions.setEmpty();
|
2022-08-01 21:34:35 +02:00
|
|
|
SubEntry->LoadOptions.Add(L"BO-REMOVE");
|
2020-03-03 21:44:07 +01:00
|
|
|
SubScreen->AddMenuEntry(SubEntry, true);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2020-03-10 10:45:17 +01:00
|
|
|
SubEntry = Entry->getPartiallyDuplicatedEntry();
|
2019-09-03 11:58:42 +02:00
|
|
|
if (SubEntry) {
|
2020-03-31 18:10:30 +02:00
|
|
|
SubEntry->Title.SWPrintf("Print all UEFI boot options to log");
|
2020-04-26 15:07:30 +02:00
|
|
|
SubEntry->LoadOptions.setEmpty();
|
2022-08-01 21:34:35 +02:00
|
|
|
SubEntry->LoadOptions.Add(L"BO-PRINT");
|
2020-03-03 21:44:07 +01:00
|
|
|
SubScreen->AddMenuEntry(SubEntry, true);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2020-03-03 21:44:07 +01:00
|
|
|
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);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
void ScanTool(void)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN VolumeIndex;
|
|
|
|
REFIT_VOLUME *Volume;
|
2020-10-03 19:02:31 +02:00
|
|
|
void *Interface;
|
2023-11-06 21:53:57 +01:00
|
|
|
if (ThemeX->HideUIFlags & HIDEUI_FLAG_TOOLS)
|
2020-03-30 10:34:16 +02:00
|
|
|
return;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-03-28 07:36:07 +01:00
|
|
|
// DBG("Scanning for tools...\n");
|
2023-11-06 21:53:57 +01:00
|
|
|
if (!(ThemeX->HideUIFlags & HIDEUI_FLAG_SHELL)) {
|
|
|
|
if (!AddToolEntry(SWPrintf("%ls\\tools\\Shell64U.efi", self.getCloverDirFullPath().wc_str()), NULL, L"UEFI Shell 64", SelfVolume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXString8Array)) {
|
|
|
|
AddToolEntry(SWPrintf("%ls\\tools\\Shell64.efi", self.getCloverDirFullPath().wc_str()), NULL, L"EFI Shell 64", SelfVolume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXString8Array);
|
2020-03-30 10:34:16 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// if (!gFirmwareClover) { //Slice: I wish to extend functionality on emulated nvram
|
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->RootDir || !Volume->DeviceHandle) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = gBS->HandleProtocol (Volume->DeviceHandle, &gEfiPartTypeSystemPartGuid, &Interface);
|
|
|
|
if (Status == EFI_SUCCESS) {
|
2020-03-25 19:32:44 +01:00
|
|
|
DBG("Checking EFI partition Volume %llu for Clover\n", VolumeIndex);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// OSX adds label "EFI" to EFI volumes and some UEFIs see that
|
|
|
|
// as a file. This file then blocks access to the /EFI directory.
|
|
|
|
// We will delete /EFI file here and leave only /EFI directory.
|
|
|
|
if (DeleteFile(Volume->RootDir, L"EFI")) {
|
|
|
|
DBG(" Deleted /EFI label\n");
|
|
|
|
}
|
|
|
|
|
2020-10-03 19:02:31 +02:00
|
|
|
if (FileExists(&self.getCloverDir(), CLOVER_MEDIA_FILE_NAME)) {
|
2019-09-03 11:58:42 +02:00
|
|
|
DBG(" Found Clover\n");
|
|
|
|
// Volume->BootType = BOOTING_BY_EFI;
|
2020-10-17 15:01:33 +02:00
|
|
|
AddCloverEntry(SWPrintf("%ls\\%ls", self.getCloverDirFullPath().wc_str(), CLOVER_MEDIA_FILE_NAME.wc_str()), L"Clover Boot Options", Volume);
|
2019-09-03 11:58:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add custom tool entries
|
2020-10-03 19:02:31 +02:00
|
|
|
void AddCustomTool(void)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
|
|
|
UINTN VolumeIndex;
|
|
|
|
REFIT_VOLUME *Volume;
|
2020-05-16 21:30:29 +02:00
|
|
|
XIcon Image;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// DBG("Custom tool start\n");
|
|
|
|
DbgHeader("AddCustomTool");
|
|
|
|
// Traverse the custom entries
|
2021-03-23 20:59:30 +01:00
|
|
|
for (size_t i = 0 ; i < GlobalConfig.CustomToolsEntries.size(); ++i) {
|
|
|
|
CUSTOM_TOOL_ENTRY& Custom = GlobalConfig.CustomToolsEntries[i];
|
|
|
|
if (OSFLAG_ISSET(Custom.getFlags(), OSFLAG_DISABLED)) {
|
2021-03-23 22:23:44 +01:00
|
|
|
DBG("Custom tool %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 tool %llu skipped because it is hidden.\n", i);
|
|
|
|
// continue;
|
|
|
|
// }
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-03-23 20:59:30 +01:00
|
|
|
if (Custom.settings.Volume.notEmpty()) {
|
2021-03-23 22:23:44 +01:00
|
|
|
DBG("Custom tool %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
|
|
|
|
2021-03-23 22:23:44 +01:00
|
|
|
DBG(" Checking volume \"%ls\" (%ls) ... ", Volume->VolName.wc_str(), Volume->DevicePathString.wc_str());
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
// Skip Whole Disc Boot
|
|
|
|
if (Volume->RootDir == NULL) {
|
|
|
|
DBG("skipped because volume is not readable\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Volume->Hidden) {
|
|
|
|
DBG("skipped because volume is hidden\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 the tool exists on the volume
|
2021-03-23 20:59:30 +01:00
|
|
|
if (!FileExists(Volume->RootDir, Custom.settings.Path)) {
|
2021-03-23 22:23:44 +01:00
|
|
|
DBG("skipped because path '%ls' does not exist\n", Custom.settings.Path.wc_str());
|
2019-09-03 11:58:42 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Change to custom image if needed
|
2021-03-19 21:32:42 +01:00
|
|
|
Image = Custom.Image;
|
2021-03-23 20:59:30 +01:00
|
|
|
if (Image.isEmpty() && Custom.settings.ImagePath.notEmpty()) {
|
2023-11-06 21:53:57 +01:00
|
|
|
Image.LoadXImage(&ThemeX->getThemeDir(), Custom.settings.ImagePath);
|
2020-04-03 22:00:42 +02:00
|
|
|
}
|
2021-03-23 22:23:44 +01:00
|
|
|
DBG("match!\n");
|
2020-04-03 22:00:42 +02:00
|
|
|
if (Image.isEmpty()) {
|
2023-11-06 21:53:57 +01:00
|
|
|
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom.settings.Hotkey, Custom.getLoadOptions());
|
2020-03-30 10:34:16 +02:00
|
|
|
} else {
|
|
|
|
// Create a legacy entry for this volume
|
2021-03-23 20:59:30 +01:00
|
|
|
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, Image, Custom.settings.Hotkey, Custom.getLoadOptions());
|
2020-03-30 10:34:16 +02:00
|
|
|
}
|
2019-09-03 11:58:42 +02:00
|
|
|
// break; // break scan volumes, continue scan entries -- why?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// DBG("Custom tool end\n");
|
|
|
|
}
|