#ifdef __MAKEWITH_TIANO
#include "../EfiLib/BdsHelper.h"
+#else
+#define EFI_SECURITY_VIOLATION EFIERR (26)
#endif // __MAKEWITH_TIANO
-//
+//
// variables
#define MACOSX_LOADER_PATH L"System\\Library\\CoreServices\\boot.efi"
#if defined (EFIX64)
-#define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\shellx64.efi"
+#define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\EFI\\tools\\shellx64.efi,\\shellx64.efi"
#define DRIVER_DIRS L"drivers,drivers_x64"
#elif defined (EFI32)
-#define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\shellia32.efi"
+#define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\EFI\\tools\\shellia32.efi,\\shellia32.efi"
#define DRIVER_DIRS L"drivers,drivers_ia32"
#else
#define SHELL_NAMES L"\\EFI\\tools\\shell.efi"
// a ".efi" extension to be found when scanning for boot loaders.
#define LINUX_MATCH_PATTERNS L"vmlinuz*,bzImage*"
+// Default hint text for program-launch submenus
+#define SUBSCREEN_HINT1 L"Use arrow keys to move cursor; Enter to boot;"
+#define SUBSCREEN_HINT2 L"Insert or F2 to edit options; Esc to return to main menu"
+#define SUBSCREEN_HINT2_NO_EDITOR L"Esc to return to main menu"
+
static REFIT_MENU_ENTRY MenuEntryAbout = { L"About rEFInd", TAG_ABOUT, 1, 0, 'A', NULL, NULL, NULL };
static REFIT_MENU_ENTRY MenuEntryReset = { L"Reboot Computer", TAG_REBOOT, 1, 0, 'R', NULL, NULL, NULL };
static REFIT_MENU_ENTRY MenuEntryShutdown = { L"Shut Down Computer", TAG_SHUTDOWN, 1, 0, 'U', NULL, NULL, NULL };
static REFIT_MENU_ENTRY MenuEntryReturn = { L"Return to Main Menu", TAG_RETURN, 0, 0, 0, NULL, NULL, NULL };
static REFIT_MENU_ENTRY MenuEntryExit = { L"Exit rEFInd", TAG_EXIT, 1, 0, 0, NULL, NULL, NULL };
-static REFIT_MENU_SCREEN MainMenu = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" };
-static REFIT_MENU_SCREEN AboutMenu = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL };
+static REFIT_MENU_SCREEN MainMenu = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot",
+ L"Use arrow keys to move cursor; Enter to boot;",
+ L"Insert or F2 for more options; Esc to refresh" };
+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, 20, 0, 0, GRAPHICS_FOR_OSX, LEGACY_TYPE_MAC, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
if (AboutMenu.EntryCount == 0) {
AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
- AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.0");
+ AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.0.4");
AddMenuInfoLine(&AboutMenu, L"");
AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
// ImageData, ImageSize, &ChildImageHandle);
ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
NULL, 0, &ChildImageHandle);
- if ((Status == EFI_ACCESS_DENIED) && (ShimLoaded())) {
+ if (((Status == EFI_ACCESS_DENIED) || (Status == EFI_SECURITY_VIOLATION)) && (ShimLoaded())) {
FindVolumeAndFilename(DevicePaths[DevicePathIndex], &DeviceVolume, &loader);
if (DeviceVolume != NULL) {
Status = ReadFile(DeviceVolume->RootDir, loader, &File, &ImageSize);
for (i = 0; i < Entry->EntryCount && NewEntry->Entries; i++) {
AddMenuEntry(NewEntry, Entry->Entries[i]);
} // for
+ NewEntry->Hint1 = (Entry->Hint1) ? StrDuplicate(Entry->Hint1) : NULL;
+ NewEntry->Hint2 = (Entry->Hint2) ? StrDuplicate(Entry->Hint2) : NULL;
} // if
return (NewEntry);
} // static REFIT_MENU_SCREEN* CopyMenuScreen()
MyFreePool(MainOptions);
AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
} // if (SubEntry != NULL)
+ SubScreen->Hint1 = StrDuplicate(SUBSCREEN_HINT1);
+ if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+ SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2_NO_EDITOR);
+ } else {
+ SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2);
+ } // if/else
} // if (SubScreen != NULL)
} else { // existing subscreen; less initialization, and just add new entry later....
SubScreen = Entry->me.SubScreen;
// Sets a few defaults for a loader entry -- mainly the icon, but also the OS type
// code and shortcut letter. For Linux EFI stub loaders, also sets kernel options
// that will (with luck) work fairly automatically.
-VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume) {
- CHAR16 IconFileName[256];
- CHAR16 *FileName, *PathOnly, *OSIconName = NULL, *Temp;
- CHAR16 ShortcutLetter = 0;
+VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, REFIT_VOLUME *Volume) {
+ CHAR16 IconFileName[256];
+ CHAR16 *FileName, *PathOnly, *OSIconName = NULL, *Temp, *SubString;
+ CHAR16 ShortcutLetter = 0;
+ UINTN i, Length;
FileName = Basename(LoaderPath);
PathOnly = FindPath(LoaderPath);
// locate a custom icon for the loader
+ // Anything found here takes precedence over the "hints" in the OSIconName variable
StrCpy(IconFileName, LoaderPath);
ReplaceEfiExtension(IconFileName, L".icns");
if (FileExists(Volume->RootDir, IconFileName)) {
Entry->me.Image = Volume->VolIconImage;
} // icon matched to loader or volume
+ // Begin creating icon "hints" by using last part of directory path leading
+ // to the loader
Temp = FindLastDirName(LoaderPath);
MergeStrings(&OSIconName, Temp, L',');
MyFreePool(Temp);
ShortcutLetter = OSIconName[0];
}
+ // Add every "word" in the volume label, delimited by spaces, dashes (-), or
+ // underscores (_), to the list of hints to be used in searching for OS
+ // icons.
+ if ((Volume->VolName) && (StrLen(Volume->VolName) > 0)) {
+ Temp = SubString = StrDuplicate(Volume->VolName);
+ if (Temp != NULL) {
+ Length = StrLen(Temp);
+ for (i = 0; i < Length; i++) {
+ if ((Temp[i] == L' ') || (Temp[i] == L'_') || (Temp[i] == L'-')) {
+ Temp[i] = 0;
+ if (StrLen(SubString) > 0)
+ MergeStrings(&OSIconName, SubString, L',');
+ SubString = Temp + i + 1;
+ } // if
+ } // for
+ MergeStrings(&OSIconName, SubString, L',');
+ MyFreePool(Temp);
+ } // if
+ } // if
+
// detect specific loaders
if (StriSubCmp(L"bzImage", LoaderPath) || StriSubCmp(L"vmlinuz", LoaderPath)) {
MergeStrings(&OSIconName, L"linux", L',');
Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_GRUB;
} else if (StriCmp(FileName, L"cdboot.efi") == 0 ||
StriCmp(FileName, L"bootmgr.efi") == 0 ||
- StriCmp(FileName, L"Bootmgfw.efi") == 0) {
+ StriCmp(FileName, L"bootmgfw.efi") == 0) {
MergeStrings(&OSIconName, L"win", L',');
Entry->OSType = 'W';
ShortcutLetter = 'W';
// (Time1 == Time2). Precision is only to the nearest second; since
// this is used for sorting boot loader entries, differences smaller
// than this are likely to be meaningless (and unlikely!).
-INTN TimeComp(EFI_TIME *Time1, EFI_TIME *Time2) {
+INTN TimeComp(IN EFI_TIME *Time1, IN EFI_TIME *Time2) {
INT64 Time1InSeconds, Time2InSeconds;
// Following values are overestimates; I'm assuming 31 days in every month.
SubScreen->Title = AllocateZeroPool(256 * sizeof(CHAR16));
SPrint(SubScreen->Title, 255, L"Boot Options for %s on %s", LoaderTitle, VolDesc);
SubScreen->TitleImage = Entry->me.Image;
+ SubScreen->Hint1 = StrDuplicate(SUBSCREEN_HINT1);
+ if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+ SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2_NO_EDITOR);
+ } else {
+ SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2);
+ } // if/else
// default entry
SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
SubScreen->Title = AllocateZeroPool(256 * sizeof(CHAR16));
SPrint(SubScreen->Title, 255, L"No boot options for legacy target");
SubScreen->TitleImage = Entry->me.Image;
+ SubScreen->Hint1 = StrDuplicate(SUBSCREEN_HINT1);
+ if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+ SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2_NO_EDITOR);
+ } else {
+ SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2);
+ } // if/else
// default entry
SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
BDS_COMMON_OPTION *BdsOption;
LIST_ENTRY TempList;
BBS_BBS_DEVICE_PATH * BbsDevicePath = NULL;
-// REFIT_VOLUME Volume;
InitializeListHead (&TempList);
ZeroMem (Buffer, sizeof (Buffer));
//
EFI_STATUS
EFIAPI
-efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
+efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
BOOLEAN MainLoopRunning = TRUE;