From cf8cab562126ea992bfca093829fd2832cf1414b Mon Sep 17 00:00:00 2001 From: srs5694 Date: Tue, 31 Dec 2013 19:45:24 -0500 Subject: [PATCH] Added "windows_recovery" option to "showtools" token and "windows_recovery_files" option. --- docs/refind/configfile.html | 7 +++++- refind.conf-sample | 45 ++++++++++++++++++++++--------------- refind/config.c | 6 +++++ refind/config.h | 4 ++-- refind/global.h | 34 +++++++++++++++------------- refind/icns.c | 1 + refind/icns.h | 31 ++++++++++++------------- refind/main.c | 29 +++++++++++++++++++----- 8 files changed, 101 insertions(+), 56 deletions(-) diff --git a/docs/refind/configfile.html b/docs/refind/configfile.html index d2ec210..94a5b70 100644 --- a/docs/refind/configfile.html +++ b/docs/refind/configfile.html @@ -246,7 +246,7 @@ timeout 20 showtools shell, memtest, gptsync, apple_recovery, mok_tool, about, exit, shutdown, reboot, and firmware - Specifies which tool tags to display on the second row. shell launches an EFI shell, memtest (or memtest86 launches the Memtest86 program, gptsync launches a tool that creates a hybrid MBR, apple_recovery boots the OS X Recovery HD, mok_tool launches a tool to manage Machine Owner Keys (MOKs) on systems with Secure Boot active, about displays information about the program, exit terminates rEFInd, shutdown shuts down the computer (or reboots it, on some UEFI PCs), reboot reboots the computer, and firmware reboots the computer into the computer's own setup utility. The tags appear in the order in which you specify them. The default is shell, memtest, apple_recovery, mok_tool, about, shutdown, reboot, firmware. Note that the shell, memtest, apple_recovery, and mok_tool options all require the presence of programs not included with rEFInd. The gptsync option requires use of a like-named program which, although it ships with rEFInd 0.6.9 and later, is not installed by default except under OS X. See the "Installing Additional Components" section of the Installing rEFInd page for pointers to the shell, Memtest86, and gptsync programs. The apple_recovery option will appear only if you've got an Apple Recovery HD partition (which has a boot loader called com.apple.recovery.boot/boot.efi). The firmware option works only on computers that support this option; on other computers, the option is quietly ignored. See the Secure Boot page for information on Secure Boot and MOK management. + Specifies which tool tags to display on the second row. shell launches an EFI shell, memtest (or memtest86 launches the Memtest86 program, gptsync launches a tool that creates a hybrid MBR, apple_recovery boots the OS X Recovery HD, windows_recovery boots a Windows recovery tool, mok_tool launches a tool to manage Machine Owner Keys (MOKs) on systems with Secure Boot active, about displays information about the program, exit terminates rEFInd, shutdown shuts down the computer (or reboots it, on some UEFI PCs), reboot reboots the computer, and firmware reboots the computer into the computer's own setup utility. The tags appear in the order in which you specify them. The default is shell, memtest, apple_recovery, mok_tool, about, shutdown, reboot, firmware. Note that the shell, memtest, apple_recovery, and mok_tool options all require the presence of programs not included with rEFInd. The gptsync option requires use of a like-named program which, although it ships with rEFInd 0.6.9 and later, is not installed by default except under OS X. See the "Installing Additional Components" section of the Installing rEFInd page for pointers to the shell, Memtest86, and gptsync programs. The apple_recovery option will appear only if you've got an Apple Recovery HD partition (which has a boot loader called com.apple.recovery.boot/boot.efi). The firmware option works only on computers that support this option; on other computers, the option is quietly ignored. See the Secure Boot page for information on Secure Boot and MOK management. font @@ -308,6 +308,11 @@ timeout 20 filename(s) Adds the specified filename or filenames to a filename "blacklist"—these files are not included as boot loader options even if they're found on the disk. This is useful to exclude support programs (such as shim.efi and MokManager.efi) and drivers from your OS list. The default value is shim.efi, shim-fedora.efi, PreLoader.efi, TextMode.efi, ebounce.efi, GraphicsConsole.efi, MokManager.efi, HashTool.efi, HashTool-signed.efi. To add files to the default list rather than replace the list, specify + as the first option, as in dont_scan_files + badloader.efi. + + windows_recovery_files + filename(s) + Adds the specified filename or filenames to list that will be recognized as Windows recovery tools and presented as such on the second row, if windows_recovery is among the options to showtools. The filename must include a complete path and may optionally include a filesystem label, as in LRS_EFI:\EFI\Microsoft\Boot\LrsBootmgr.efi. + scan_all_linux_kernels none or 0 diff --git a/refind.conf-sample b/refind.conf-sample index c8f2a5d..15beb1f 100644 --- a/refind.conf-sample +++ b/refind.conf-sample @@ -132,26 +132,33 @@ timeout 20 # Which non-bootloader tools to show on the tools line, and in what # order to display them: -# shell - the EFI shell (requires external program; see rEFInd -# documentation for details) -# memtest - the memtest86 program, in EFI/tools, EFI/memtest86, -# EFI/memtest, EFI/tools/memtest86, or EFI/tools/memtest -# gptsync - the (dangerous) gptsync.efi utility (requires external -# program; see rEFInd documentation for details) -# apple_recovery - boots the Apple Recovery HD partition, if present -# mok_tool - makes available the Machine Owner Key (MOK) maintenance -# tool, MokManager.efi, used on Secure Boot systems -# about - an "about this program" option -# exit - a tag to exit from rEFInd -# shutdown - shuts down the computer (a bug causes this to reboot -# many UEFI systems) -# reboot - a tag to reboot the computer -# firmware - a tag to reboot the computer into the firmware's -# user interface (ignored on older computers) +# shell - the EFI shell (requires external program; see rEFInd +# documentation for details) +# memtest - the memtest86 program, in EFI/tools, EFI/memtest86, +# EFI/memtest, EFI/tools/memtest86, or EFI/tools/memtest +# gptsync - the (dangerous) gptsync.efi utility (requires external +# program; see rEFInd documentation for details) +# apple_recovery - boots the Apple Recovery HD partition, if present +# windows_recovery - boots an OEM Windows recovery tool, if present +# (see also the windows_recovery_files option) +# mok_tool - makes available the Machine Owner Key (MOK) maintenance +# tool, MokManager.efi, used on Secure Boot systems +# about - an "about this program" option +# exit - a tag to exit from rEFInd +# shutdown - shuts down the computer (a bug causes this to reboot +# many UEFI systems) +# reboot - a tag to reboot the computer +# firmware - a tag to reboot the computer into the firmware's +# user interface (ignored on older computers) # Default is shell,memtest,apple_recovery,mok_tool,about,shutdown,reboot,firmware # #showtools shell, memtest, mok_tool, about, reboot, exit, firmware +# Boot loaders that can launch a Windows restore or emergency system. +# These tend to be OEM-specific. +# +#windows_recovery_files LRS_ESP:/EFI/Microsoft/Boot/LrsBootmgr.efi + # Directories in which to search for EFI drivers. These drivers can # provide filesystem support, give access to hard disks on plug-in # controllers, etc. In most cases none are needed, but if you add @@ -206,7 +213,7 @@ timeout 20 # label, which you can obtain in an EFI shell by typing "vol", from # Linux by typing "blkid /dev/{devicename}", or by examining the # disk's label in various OSes' file browsers. -# The default is "Recovery HD". +# The default is "Recovery HD,LRS_ESP". # #dont_scan_volumes "Recovery HD" @@ -238,7 +245,9 @@ timeout 20 # set of tools. Most notably, MokManager.efi is in this blacklist, # but will show up as a tool if present in certain directories. You # can control the tools row with the showtools token. -# The default is shim.efi,PreLoader.efi,TextMode.efi,ebounce.efi,GraphicsConsole.efi,MokManager.efi,HashTool.efi,HashTool-signed.efi +# The default is shim.efi,PreLoader.efi,TextMode.efi,ebounce.efi, +# GraphicsConsole.efi,MokManager.efi,HashTool.efi,HashTool-signed.efi, +# bootmgr.efi # #dont_scan_files shim.efi,MokManager.efi diff --git a/refind/config.c b/refind/config.c index 3d8f970..cfd3f78 100644 --- a/refind/config.c +++ b/refind/config.c @@ -441,6 +441,7 @@ VOID ReadConfig(CHAR16 *FileName) MergeStrings(&(GlobalConfig.DontScanFiles), MOK_NAMES, L','); MyFreePool(GlobalConfig.DontScanVolumes); GlobalConfig.DontScanVolumes = StrDuplicate(DONT_SCAN_VOLUMES); + GlobalConfig.WindowsRecoveryFiles = StrDuplicate(WINDOWS_RECOVERY_FILES); } // if if (!FileExists(SelfDir, FileName)) { @@ -517,6 +518,9 @@ VOID ReadConfig(CHAR16 *FileName) } else if ((StriCmp(TokenList[0], L"don't_scan_files") == 0) || (StriCmp(TokenList[0], L"dont_scan_files") == 0)) { HandleStrings(TokenList, TokenCount, &(GlobalConfig.DontScanFiles)); + } else if (StriCmp(TokenList[0], L"windows_recovery_files") == 0) { + HandleStrings(TokenList, TokenCount, &(GlobalConfig.WindowsRecoveryFiles)); + } else if (StriCmp(TokenList[0], L"scan_driver_dirs") == 0) { HandleStrings(TokenList, TokenCount, &(GlobalConfig.DriverDirs)); @@ -538,6 +542,8 @@ VOID ReadConfig(CHAR16 *FileName) GlobalConfig.ShowTools[i - 1] = TAG_SHUTDOWN; } else if (StriCmp(FlagName, L"apple_recovery") == 0) { GlobalConfig.ShowTools[i - 1] = TAG_APPLE_RECOVERY; + } else if (StriCmp(FlagName, L"windows_recovery") == 0) { + GlobalConfig.ShowTools[i - 1] = TAG_WINDOWS_RECOVERY; } else if (StriCmp(FlagName, L"mok_tool") == 0) { GlobalConfig.ShowTools[i - 1] = TAG_MOK_TOOL; } else if (StriCmp(FlagName, L"firmware") == 0) { diff --git a/refind/config.h b/refind/config.h index 3c92fdb..45d1924 100644 --- a/refind/config.h +++ b/refind/config.h @@ -81,8 +81,8 @@ typedef struct { #define CONFIG_FILE_NAME L"refind.conf" // Note: Below is combined with MOK_NAMES to make default -#define DONT_SCAN_FILES L"shim.efi,shim-fedora.efi,PreLoader.efi,TextMode.efi,ebounce.efi,GraphicsConsole.efi" -#define DONT_SCAN_VOLUMES L"Recovery HD" +#define DONT_SCAN_FILES L"shim.efi,shim-fedora.efi,PreLoader.efi,TextMode.efi,ebounce.efi,GraphicsConsole.efi,bootmgr.efi" +#define DONT_SCAN_VOLUMES L"Recovery HD,LRS_ESP" #define ALSO_SCAN_DIRS L"boot" EFI_STATUS ReadFile(IN EFI_FILE_HANDLE BaseDir, CHAR16 *FileName, REFIT_FILE *File, UINTN *size); diff --git a/refind/global.h b/refind/global.h index 8dc6d59..ee48764 100644 --- a/refind/global.h +++ b/refind/global.h @@ -58,21 +58,22 @@ #define REFIT_DEBUG (0) // Tag classifications; used in various ways. -#define TAG_ABOUT (1) -#define TAG_REBOOT (2) -#define TAG_SHUTDOWN (3) -#define TAG_TOOL (4) -#define TAG_LOADER (5) -#define TAG_LEGACY (6) -#define TAG_EXIT (7) -#define TAG_SHELL (8) -#define TAG_GPTSYNC (9) -#define TAG_LEGACY_UEFI (10) -#define TAG_APPLE_RECOVERY (11) -#define TAG_MOK_TOOL (12) -#define TAG_FIRMWARE (13) -#define TAG_MEMTEST (14) -#define NUM_TOOLS (14) +#define TAG_ABOUT (1) +#define TAG_REBOOT (2) +#define TAG_SHUTDOWN (3) +#define TAG_TOOL (4) +#define TAG_LOADER (5) +#define TAG_LEGACY (6) +#define TAG_EXIT (7) +#define TAG_SHELL (8) +#define TAG_GPTSYNC (9) +#define TAG_LEGACY_UEFI (10) +#define TAG_APPLE_RECOVERY (11) +#define TAG_WINDOWS_RECOVERY (12) +#define TAG_MOK_TOOL (13) +#define TAG_FIRMWARE (14) +#define TAG_MEMTEST (15) +#define NUM_TOOLS (16) #define NUM_SCAN_OPTIONS 10 @@ -130,6 +131,8 @@ #define MOK_LOCATIONS L"\\,EFI\\tools,EFI\\fedora,EFI\\redhat,EFI\\ubuntu,EFI\\suse,EFI\\opensuse,EFI\\altlinux" // Directories to search for memtest86.... #define MEMTEST_LOCATIONS L"EFI\\tools,EFI\\tools\\memtest86,EFI\\tools\\memtest,EFI\\memtest86,EFI\\memtest" +// Files that may be Windows recovery files +#define WINDOWS_RECOVERY_FILES L"EFI\\Microsoft\\Boot\\LrsBootmgr.efi" // // global definitions @@ -246,6 +249,7 @@ typedef struct { CHAR16 *DontScanVolumes; CHAR16 *DontScanDirs; CHAR16 *DontScanFiles; + CHAR16 *WindowsRecoveryFiles; CHAR16 *DriverDirs; CHAR16 *IconsDir; UINTN ShowTools[NUM_TOOLS]; diff --git a/refind/icns.c b/refind/icns.c index a61bca3..45c5049 100644 --- a/refind/icns.c +++ b/refind/icns.c @@ -60,6 +60,7 @@ BUILTIN_ICON BuiltinIconTable[BUILTIN_ICON_COUNT] = { { NULL, L"tool_part", 48 }, { NULL, L"tool_rescue", 48 }, { NULL, L"tool_apple_rescue", 48 }, + { NULL, L"tool_windows_rescue", 48 }, { NULL, L"tool_mok_tool", 48 }, { NULL, L"tool_memtest", 48 }, { NULL, L"vol_internal", 32 }, diff --git a/refind/icns.h b/refind/icns.h index 507f365..229594f 100644 --- a/refind/icns.h +++ b/refind/icns.h @@ -55,21 +55,22 @@ EG_IMAGE * DummyImage(IN UINTN PixelSize); EG_IMAGE * BuiltinIcon(IN UINTN Id); -#define BUILTIN_ICON_FUNC_ABOUT (0) -#define BUILTIN_ICON_FUNC_RESET (1) -#define BUILTIN_ICON_FUNC_SHUTDOWN (2) -#define BUILTIN_ICON_FUNC_EXIT (3) -#define BUILTIN_ICON_FUNC_FIRMWARE (4) -#define BUILTIN_ICON_TOOL_SHELL (5) -#define BUILTIN_ICON_TOOL_PART (6) -#define BUILTIN_ICON_TOOL_RESCUE (7) -#define BUILTIN_ICON_TOOL_APPLE_RESCUE (8) -#define BUILTIN_ICON_TOOL_MOK_TOOL (9) -#define BUILTIN_ICON_TOOL_MEMTEST (10) -#define BUILTIN_ICON_VOL_INTERNAL (11) -#define BUILTIN_ICON_VOL_EXTERNAL (12) -#define BUILTIN_ICON_VOL_OPTICAL (13) -#define BUILTIN_ICON_COUNT (14) +#define BUILTIN_ICON_FUNC_ABOUT (0) +#define BUILTIN_ICON_FUNC_RESET (1) +#define BUILTIN_ICON_FUNC_SHUTDOWN (2) +#define BUILTIN_ICON_FUNC_EXIT (3) +#define BUILTIN_ICON_FUNC_FIRMWARE (4) +#define BUILTIN_ICON_TOOL_SHELL (5) +#define BUILTIN_ICON_TOOL_PART (6) +#define BUILTIN_ICON_TOOL_RESCUE (7) +#define BUILTIN_ICON_TOOL_APPLE_RESCUE (8) +#define BUILTIN_ICON_TOOL_WINDOWS_RESCUE (9) +#define BUILTIN_ICON_TOOL_MOK_TOOL (10) +#define BUILTIN_ICON_TOOL_MEMTEST (11) +#define BUILTIN_ICON_VOL_INTERNAL (12) +#define BUILTIN_ICON_VOL_EXTERNAL (13) +#define BUILTIN_ICON_VOL_OPTICAL (14) +#define BUILTIN_ICON_COUNT (15) #endif diff --git a/refind/main.c b/refind/main.c index 31fd886..30895bb 100644 --- a/refind/main.c +++ b/refind/main.c @@ -132,9 +132,9 @@ static REFIT_MENU_SCREEN MainMenu = { L"Main Menu", NULL, 0, NULL, 0, NULL static REFIT_MENU_SCREEN AboutMenu = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL, L"Press Enter to return to main menu", L"" }; REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 0, DONT_CHANGE_TEXT_MODE, 20, 0, 0, GRAPHICS_FOR_OSX, LEGACY_TYPE_MAC, 0, 0, - NULL, NULL, CONFIG_FILE_NAME, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - { TAG_SHELL, TAG_MEMTEST, TAG_APPLE_RECOVERY, TAG_MOK_TOOL, TAG_ABOUT, TAG_SHUTDOWN, - TAG_REBOOT, TAG_FIRMWARE, 0, 0, 0, 0, 0, 0 } + NULL, NULL, CONFIG_FILE_NAME, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + { TAG_SHELL, TAG_MEMTEST, TAG_APPLE_RECOVERY, TAG_WINDOWS_RECOVERY, TAG_MOK_TOOL, TAG_ABOUT, + TAG_SHUTDOWN, TAG_REBOOT, TAG_FIRMWARE, 0, 0, 0, 0, 0, 0 } }; EFI_GUID GlobalGuid = EFI_GLOBAL_VARIABLE; @@ -2235,7 +2235,7 @@ static VOID FindTool(CHAR16 *Locations, CHAR16 *Names, CHAR16 *Description, UINT // Add the second-row tags containing built-in and external tools (EFI shell, // reboot, etc.) static VOID ScanForTools(VOID) { - CHAR16 *FileName = NULL, *MokLocations, Description[256]; + CHAR16 *FileName = NULL, *VolName = NULL, *MokLocations, Description[256]; REFIT_MENU_ENTRY *TempMenuEntry; UINTN i, j, VolumeIndex; UINT64 osind; @@ -2313,12 +2313,31 @@ static VOID ScanForTools(VOID) { SPrint(Description, 255, L"Apple Recovery on %s", Volumes[VolumeIndex]->VolName); AddToolEntry(Volumes[VolumeIndex]->DeviceHandle, FileName, Description, BuiltinIcon(BUILTIN_ICON_TOOL_APPLE_RESCUE), 'R', TRUE); - } + } // if } // for MyFreePool(FileName); FileName = NULL; break; + case TAG_WINDOWS_RECOVERY: + j = 0; + while ((FileName = FindCommaDelimited(GlobalConfig.WindowsRecoveryFiles, j++)) != NULL) { + SplitVolumeAndFilename(&FileName, &VolName); + for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) { + if ((Volumes[VolumeIndex]->RootDir != NULL) && (FileExists(Volumes[VolumeIndex]->RootDir, FileName)) && + ((VolName == NULL) || (StriCmp(VolName, Volumes[VolumeIndex]->VolName) == 0))) { + SPrint(Description, 255, L"Microsoft Recovery on %s", Volumes[VolumeIndex]->VolName); + AddToolEntry(Volumes[VolumeIndex]->DeviceHandle, FileName, Description, + BuiltinIcon(BUILTIN_ICON_TOOL_WINDOWS_RESCUE), 'R', TRUE); + } // if + } // for + } // while + MyFreePool(FileName); + FileName = NULL; + MyFreePool(VolName); + VolName = NULL; + break; + case TAG_MOK_TOOL: FindTool(MokLocations, MOK_NAMES, L"MOK utility utility", BUILTIN_ICON_TOOL_MOK_TOOL); break; -- 2.39.2