From a0a4ba44f4dc01c86499c0fc80730940b53f75c6 Mon Sep 17 00:00:00 2001
From: srs5694
Originally written: 3/14/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
diff --git a/docs/refind/configfile.html b/docs/refind/configfile.html index a2e7085..e512a12 100644 --- a/docs/refind/configfile.html +++ b/docs/refind/configfile.html @@ -90,7 +90,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comMany casual users will be able to use rEFInd without making further changes; in its default configuration, the boot manager automatically detects all the EFI boot loader programs you have on your ESP (or your OS X boot partition, in the case of Macs) and displays icons for them. Sometimes, though, you may want to tweak rEFInd's configuration. Sometimes you can obtain your desired results by adjusting the filenames of your boot loaders. Other times, you can edit rEFInd's configuration file, refind.conf, which resides in the same directory as its binary file (refind.efi or whatever you've renamed it).
+Many casual users will be able to use rEFInd without making changes to its settings; in its default configuration, the boot manager automatically detects all the EFI boot loader programs you have on your ESP (or your OS X boot partition, in the case of Macs) and displays icons for them. On Macs, rEFInd also presents legacy BIOS boot options by default. Sometimes, though, you may want to tweak rEFInd's configuration. Sometimes you can obtain your desired results by adjusting the filenames of your boot loaders. Other times, you can edit rEFInd's configuration file, refind.conf, which resides in the same directory as its binary file (refind.efi or whatever you've renamed it).
Broadly speaking, rEFInd's configuration file is broken down into two sections: global options and OS stanzas. The global options section sets options that apply globally—to set the timeout period, enable graphics or text mode, and so on. OS stanzas are optional, but if present, they enable you to add new boot options or replace the auto-detected options with customized ones. Both sections include configuration lines and comment lines, the latter being denoted by a leading hash mark (#). rEFInd ignores comment lines, so you can add explanatory text. The default configuration file includes numerous comments explaining each of the options.
@@ -98,7 +98,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com -Before delving into the configuration file, you should be aware of what you can do by renaming files. By default, rEFInd scans all the filesystems it can read for boot loaders. It scans most of the subdirectories of the EFI directory on every filesystem it can access for files with names that end in .efi. (rEFIt gives special treatment to the TOOLS subdirectory, where it looks for system tools rather than boot loaders.)
+Before delving into the configuration file, you should be aware of what you can do by renaming files. By default, rEFInd scans all the filesystems it can read for boot loaders. It scans most of the subdirectories of the EFI directory on every filesystem it can access for files with names that end in .efi. (rEFInd gives special treatment to the tools subdirectory, where it looks for system tools rather than boot loaders.)
If you're like me, you may sometimes want to hide a boot loader from rEFInd's menu for a brief period—say, because you're testing a variety of configurations but you don't want them all to clutter the menu at once. You might also want to hide a boot loader if you want to override its default settings using a custom entry in refind.conf and you don't want an automatic search to duplicate that entry. You can easily hide a boot loader by removing or changing its .efi filename extension—for instance, changing grub.efi to grub.
@@ -191,12 +191,12 @@ timeout 20Originally written: 4/19/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
diff --git a/docs/refind/features.html b/docs/refind/features.html index cfccba2..6fd8ecf 100644 --- a/docs/refind/features.html +++ b/docs/refind/features.html @@ -99,9 +99,9 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 3/14/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
@@ -97,46 +97,49 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comIf you're using another platform, you can give rEFInd a try; however, you'll need to build it from source code yourself or track down a binary from another source. (Perhaps by the time you read this it will be included in Linux distributions built for unusual CPUs.)
+If you're using a platform other than x86 or x86-64, you can give rEFInd a try; however, you'll need to build it from source code yourself or track down a binary from another source. (Perhaps by the time you read this it will be included in Linux distributions built for unusual CPUs.)
To extract the files from the zip file images I've provided, you'll need a tool such as unzip, which is included with Linux and Mac OS X. Numerous Windows utilities also support this format, such as PKZIP and 7-Zip.
diff --git a/docs/refind/index.html b/docs/refind/index.html index 5795014..00a66f2 100644 --- a/docs/refind/index.html +++ b/docs/refind/index.html @@ -15,7 +15,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 3/14/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
@@ -160,6 +160,8 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 3/14/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
diff --git a/docs/refind/linux.html b/docs/refind/linux.html index f80c41f..158961e 100644 --- a/docs/refind/linux.html +++ b/docs/refind/linux.html @@ -15,7 +15,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 3/19/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
@@ -150,7 +150,7 @@ another possibility. initial RAM disk is identified, rEFInd passes a suitable initrd= option to the kernel when it boots. - +by Roderick W. Smith, rodsmith@rodsbooks.com
-Last Web page update: 8/12/2012
+Last Web page update: 10/6/2012
I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
@@ -93,6 +93,8 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 4/19/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
diff --git a/docs/refind/todo.html b/docs/refind/todo.html index 993af2d..1fc80b0 100644 --- a/docs/refind/todo.html +++ b/docs/refind/todo.html @@ -15,7 +15,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 3/14/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
@@ -131,6 +131,14 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.comOriginally written: 3/14/2012; last Web page update: -8/12/2012, referencing rEFInd 0.4.5
+10/6/2012, referencing rEFInd 0.4.6I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
@@ -132,7 +132,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com -Ordinarily, rEFInd displays tags for OSes it finds on internal hard disks, external hard disks (including USB flash drives, CF disks, and so on), and optical discs. Sometimes, though, the firmware hasn't had time to fully examine these devices by the time rEFInd starts; or you might only insert or plug in the media after rEFInd appears. In these cases, you can press the Esc key to have rEFInd re-read its configuration file and re-scan your media for boot loaders. This action can take a few seconds to complete, so be patient. You can also use this feature to detect OSes if you launch a shell and use it to load a driver or edit the refind.conf file.
+Ordinarily, rEFInd displays tags for OSes it finds on internal hard disks, external hard disks (including USB flash drives, CF disks, and so on), and optical discs. Sometimes, though, the firmware hasn't had time to fully examine these devices by the time rEFInd starts; or you might only insert or plug in the media after rEFInd appears. In these cases, you can press the Esc key to have rEFInd re-read its configuration file and re-scan your media for boot loaders. This action can take a few seconds to complete, so be patient. You can also use this feature to detect OSes if you launch a shell and use it to load a driver or edit the refind.conf file. If you regularly need to press Esc, you might look into the scan_delay configuration file option, described on the Configuring the Boot Manager page.
rEFInd assigns shortcut letters to most OS entries based on the first letter of the directory in which the OS's boot loader is stored. For instance, if you have a boot loader called /EFI/debian/elilo.efi, rEFInd attempts to assign it a shortcut letter of D. rEFInd overrides this default for Mac OS X, Windows, and for Linux's GRUB, ELILO, and EFI stub boot loaders if the distribution can't be more precisely identified, as noted in the preceding table. This method works well for many installations, but it can produce conflicts. For instance, if you have a Macintosh that holds both Mac OS X and Mandriva, both OSes would normally use the M shortcut key. In practice, which works depends on the order in which rEFInd detects the OSes.
+ +Sometimes it's necessary to boot a legacy (BIOS-based) OS on an EFI computer. This is especially true on Macs, since this is the usual method of dual-booting OS X and Windows. In fact, even most Linux distributions install more easily in BIOS mode on Macs, although running Linux in EFI mode has its advantages. (See my EFI-Booting Ubuntu on a Mac page for an in-depth look at this topic.)
+ +On UEFI-based PCs, booting some OSes in EFI mode and others in BIOS mode is less often necessary, since it's usually easy to install all your OSes in BIOS mode. If you have a working EFI-mode OS installation, though, and if you want to install an OS that lacks EFI-mode boot support, you may need to boot in both modes. This may happen if you want to add one of the BSDs (FreeBSD, OpenBSD, NetBSD, and so on) to a working system, for instance. You might also want to boot a BIOS-mode emergency recovery CD, such as Parted Magic or System Rescue CD.
+ +For all such cases, rEFInd supports booting legacy OSes; however, the details vary between Macs and UEFI PCs. Also, be aware that some UEFI PCs lack the Compatibility Support Module (CSM) that's required for this feature to work. This is true even of some computers that can boot BIOS-based OSes natively. This can happen because the firmware is basically a BIOS with a UEFI implementation tacked on top of it; such systems rely on the native BIOS to boot, and may not provide a way for EFI applications to access the BIOS features via CSM mechanisms. If you have such a computer and if you enable a legacy boot option in the configuration file, rEFInd notifies you of its inability to present legacy boot options when it starts up. rEFInd's legacy boot support also depends on features that are not available in the GNU-EFI development package, so you may see a similar notice if you run a version of rEFInd compiled with that package. (The primary build available on the Getting rEFInd page is compiled with the TianoCore EDK2 package, which does support the BIOS boot features.)
+ +The scanfor option, described on the Configuring the Boot Manager page, controls rEFInd's detection of legacy OSes. On Macs, the default is to scan for such OSes, since a common boot scenario on Macs is dual-booting OS X and Windows, and of course BIOS support is required for this. (rEFInd 0.4.5 and earlier did not scan for legacy OSes by default, though, so you may need to change this option if you're upgrading and don't want to scan for legacy OSes.) On UEFI PCs, rEFInd defaults to not scanning for legacy OSes; thus, you must edit the scanfor item in the configuration file if you want to boot a legacy OS on a UEFI PC.
+ + + +On Macs, rEFInd uses a flexible scanning algorithm inherited from rEFIt. This procedure detects most legacy OSes on most disks, although it can sometimes miss an OS. This scanning algorithm can often identify the legacy OS you've installed and present a suitable icon. On UEFI PCs, rEFInd relies on the computer's NVRAM settings to determine which legacy boot loaders to scan; if an OS isn't listed in the NVRAM settings, rEFInd won't present it as an option. On most UEFI PCs, at least one hard disk and your optical drive appear as options. The two computers I've tested have failed to present USB flash drives as boot options when inserted, though. You may be able to get additional options to appear by editing your boot list in your firmware's setup utility, but I can make no promises about this. The UEFI scanning procedure is also incapable of detecting the OS type, so you'll see a generic legacy OS icon, as shown at the right.
+copyright © 2012 by Roderick W. Smith
diff --git a/filesystems/fsw_efi.c b/filesystems/fsw_efi.c index 5500eec..a24bf2e 100644 --- a/filesystems/fsw_efi.c +++ b/filesystems/fsw_efi.c @@ -80,7 +80,7 @@ /** Helper macro for stringification. */ #define FSW_EFI_STRINGIFY(x) #x /** Expands to the EFI driver name given the file system type name. */ -#define FSW_EFI_DRIVER_NAME(t) L"rEFInd 0.4.4 " FSW_EFI_STRINGIFY(t) L" File System Driver" +#define FSW_EFI_DRIVER_NAME(t) L"rEFInd 0.4.6 " FSW_EFI_STRINGIFY(t) L" File System Driver" // function prototypes diff --git a/refind.conf-sample b/refind.conf-sample index 5ed1480..af28dd0 100644 --- a/refind.conf-sample +++ b/refind.conf-sample @@ -119,7 +119,10 @@ timeout 20 # biosexternal - BIOS external boot loaders (USB, eSATA, etc.) # cd - BIOS optical-disc boot loaders # manual - use stanzas later in this configuration file -# Default is internal,external,optical,manual +# Note that the legacy BIOS options require firmware support, which is +# not present on all computers. +# On UEFI PCs, default is internal,external,optical,manual +# On Macs, default is internal,hdbios,external,biosexternal,optical,cd,manual # #scanfor internal,external,optical,manual diff --git a/refind/config.c b/refind/config.c index c9d76e3..c1756af 100644 --- a/refind/config.c +++ b/refind/config.c @@ -97,7 +97,7 @@ static EFI_STATUS ReadFile(IN EFI_FILE_HANDLE BaseDir, CHAR16 *FileName, REFIT_F File->Buffer = AllocatePool(File->BufferSize); Status = refit_call3_wrapper(FileHandle->Read, FileHandle, &File->BufferSize, File->Buffer); if (CheckError(Status, L"while loading the configuration file")) { - FreePool(File->Buffer); + MyFreePool(File->Buffer); File->Buffer = NULL; refit_call1_wrapper(FileHandle->Close, FileHandle); return Status; @@ -277,8 +277,7 @@ static VOID HandleInt(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT UINTN *Val // handle a parameter with a single string argument static VOID HandleString(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16 **Target) { if (TokenCount == 2) { - if (*Target != NULL) - FreePool(*Target); + MyFreePool(*Target); *Target = StrDuplicate(TokenList[1]); } // if } // static VOID HandleString() @@ -433,7 +432,7 @@ VOID ReadConfig(VOID) FreeTokenLine(&TokenList, &TokenCount); } - FreePool(File.Buffer); + MyFreePool(File.Buffer); } /* VOID ReadConfig() */ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volume, CHAR16 *Title) { @@ -454,22 +453,19 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu while (((TokenCount = ReadTokenLine(File, &TokenList)) > 0) && (StriCmp(TokenList[0], L"}") != 0)) { if ((StriCmp(TokenList[0], L"loader") == 0) && (TokenCount > 1)) { // set the boot loader filename - if (SubEntry->LoaderPath != NULL) - FreePool(SubEntry->LoaderPath); + MyFreePool(SubEntry->LoaderPath); SubEntry->LoaderPath = StrDuplicate(TokenList[1]); SubEntry->DevicePath = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath); } else if (StriCmp(TokenList[0], L"initrd") == 0) { - if (SubEntry->InitrdPath != NULL) - FreePool(SubEntry->InitrdPath); + MyFreePool(SubEntry->InitrdPath); SubEntry->InitrdPath = NULL; if (TokenCount > 1) { SubEntry->InitrdPath = StrDuplicate(TokenList[1]); } } else if (StriCmp(TokenList[0], L"options") == 0) { - if (SubEntry->LoadOptions != NULL) - FreePool(SubEntry->LoadOptions); + MyFreePool(SubEntry->LoadOptions); SubEntry->LoadOptions = NULL; if (TokenCount > 1) { SubEntry->LoadOptions = StrDuplicate(TokenList[1]); @@ -491,7 +487,7 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu if (SubEntry->InitrdPath != NULL) { MergeStrings(&SubEntry->LoadOptions, L"initrd=", L' '); MergeStrings(&SubEntry->LoadOptions, SubEntry->InitrdPath, 0); - FreePool(SubEntry->InitrdPath); + MyFreePool(SubEntry->InitrdPath); SubEntry->InitrdPath = NULL; } // if if (SubEntry->Enabled == TRUE) { @@ -562,30 +558,28 @@ static LOADER_ENTRY * AddStanzaEntries(REFIT_FILE *File, REFIT_VOLUME *Volume, C Entry->LoaderPath = StrDuplicate(TokenList[1]); Entry->DevicePath = FileDevicePath(CurrentVolume->DeviceHandle, Entry->LoaderPath); SetLoaderDefaults(Entry, TokenList[1], CurrentVolume); - FreePool(Entry->LoadOptions); + MyFreePool(Entry->LoadOptions); Entry->LoadOptions = NULL; // Discard default options, if any DefaultsSet = TRUE; } else if ((StriCmp(TokenList[0], L"volume") == 0) && (TokenCount > 1)) { if (FindVolume(&CurrentVolume, TokenList[1])) { - FreePool(Entry->me.Title); + MyFreePool(Entry->me.Title); Entry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16)); SPrint(Entry->me.Title, 255, L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", CurrentVolume->VolName); Entry->me.BadgeImage = CurrentVolume->VolBadgeImage; Entry->VolName = CurrentVolume->VolName; } // if match found } else if ((StriCmp(TokenList[0], L"icon") == 0) && (TokenCount > 1)) { - FreePool(Entry->me.Image); + MyFreePool(Entry->me.Image); Entry->me.Image = LoadIcns(CurrentVolume->RootDir, TokenList[1], 128); if (Entry->me.Image == NULL) { Entry->me.Image = DummyImage(128); } } else if ((StriCmp(TokenList[0], L"initrd") == 0) && (TokenCount > 1)) { - if (Entry->InitrdPath) - FreePool(Entry->InitrdPath); + MyFreePool(Entry->InitrdPath); Entry->InitrdPath = StrDuplicate(TokenList[1]); } else if ((StriCmp(TokenList[0], L"options") == 0) && (TokenCount > 1)) { - if (Entry->LoadOptions) - FreePool(Entry->LoadOptions); + MyFreePool(Entry->LoadOptions); Entry->LoadOptions = StrDuplicate(TokenList[1]); } else if ((StriCmp(TokenList[0], L"ostype") == 0) && (TokenCount > 1)) { if (TokenCount > 1) { @@ -608,7 +602,7 @@ static LOADER_ENTRY * AddStanzaEntries(REFIT_FILE *File, REFIT_VOLUME *Volume, C if (Entry->InitrdPath) { MergeStrings(&Entry->LoadOptions, L"initrd=", L' '); MergeStrings(&Entry->LoadOptions, Entry->InitrdPath, 0); - FreePool(Entry->InitrdPath); + MyFreePool(Entry->InitrdPath); Entry->InitrdPath = NULL; } // if @@ -646,9 +640,9 @@ VOID ScanUserConfigured(VOID) GenerateSubScreen(Entry, Volume); AddPreparedLoaderEntry(Entry); } else { - FreePool(Entry); + MyFreePool(Entry); } // if/else - FreePool(Title); + MyFreePool(Title); } // if FreeTokenLine(&TokenList, &TokenCount); } // while() @@ -694,10 +688,8 @@ REFIT_FILE * ReadLinuxOptionsFile(IN CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume } else { // a filename string is NULL GoOn = FALSE; } // if/else - if (OptionsFilename != NULL) - FreePool(OptionsFilename); - if (FullFilename != NULL) - FreePool(FullFilename); + MyFreePool(OptionsFilename); + MyFreePool(FullFilename); OptionsFilename = FullFilename = NULL; } while (GoOn); return (File); @@ -717,7 +709,7 @@ CHAR16 * GetFirstOptionsFromFile(IN CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume) Options = StrDuplicate(TokenList[1]); FreeTokenLine(&TokenList, &TokenCount); FreePool(File); - } + } // if return Options; } // static CHAR16 * GetOptionsFile() diff --git a/refind/driver_support.c b/refind/driver_support.c index 4780dae..b8cb8b0 100644 --- a/refind/driver_support.c +++ b/refind/driver_support.c @@ -228,24 +228,19 @@ LibScanHandleDatabase ( } } - FreePool (OpenInfo); + MyFreePool (OpenInfo); } } - FreePool (ProtocolGuidArray); + MyFreePool (ProtocolGuidArray); } } return EFI_SUCCESS; Error: - if (*HandleType != NULL) { - FreePool (*HandleType); - } - - if (*HandleBuffer != NULL) { - FreePool (*HandleBuffer); - } + MyFreePool (*HandleType); + MyFreePool (*HandleBuffer); *HandleCount = 0; *HandleBuffer = NULL; diff --git a/refind/global.h b/refind/global.h index 82aa65f..101b597 100644 --- a/refind/global.h +++ b/refind/global.h @@ -67,7 +67,7 @@ #define TAG_EXIT (7) #define TAG_SHELL (8) #define TAG_GPTSYNC (9) -#define TAG_LEGACY_NON_MAC (10) +#define TAG_LEGACY_UEFI (10) #define NUM_TOOLS (9) #define NUM_SCAN_OPTIONS 10 diff --git a/refind/icns.c b/refind/icns.c index f9be58b..df469ef 100644 --- a/refind/icns.c +++ b/refind/icns.c @@ -102,10 +102,10 @@ EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconNam // try to load it Image = egLoadIcon(SelfDir, FileName, 128); if (Image != NULL) { - FreePool(CutoutName); + MyFreePool(CutoutName); return Image; } - FreePool(CutoutName); + MyFreePool(CutoutName); } // while // try the fallback name diff --git a/refind/lib.c b/refind/lib.c index 2112721..6fa9e2f 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -144,10 +144,9 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle) // find the current directory DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath); CleanUpPathNameSlashes(DevicePathAsString); - if (SelfDirPath != NULL) - FreePool(SelfDirPath); + MyFreePool(SelfDirPath); SelfDirPath = FindPath(DevicePathAsString); - FreePool(DevicePathAsString); + MyFreePool(DevicePathAsString); return FinishInitRefitLib(); } @@ -249,14 +248,14 @@ VOID FreeList(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount) { UINTN i; - if (*ElementCount > 0) { + if ((*ElementCount > 0) && (**ListPtr != NULL)) { for (i = 0; i < *ElementCount; i++) { // TODO: call a user-provided routine for each element here - FreePool((*ListPtr)[i]); + MyFreePool((*ListPtr)[i]); } - FreePool(*ListPtr); + MyFreePool(*ListPtr); } -} +} // VOID FreeList() // // firmware device path discovery @@ -325,7 +324,7 @@ VOID ExtractLegacyLoaderPaths(EFI_DEVICE_PATH **PathList, UINTN MaxPaths, EFI_DE PathList[PathCount++] = AppendDevicePath(DevicePath, LegacyLoaderMediaPath); } - FreePool(Handles); + MyFreePool(Handles); if (HardcodedPathList) { for (HardcodedIndex = 0; HardcodedPathList[HardcodedIndex] && PathCount < MaxPaths; HardcodedIndex++) @@ -730,7 +729,7 @@ VOID ScanVolumes(VOID) UINT8 *SectorBuffer1, *SectorBuffer2; UINTN SectorSum, i; - FreePool(Volumes); + MyFreePool(Volumes); Volumes = NULL; VolumesCount = 0; @@ -754,7 +753,7 @@ VOID ScanVolumes(VOID) if (Volume->DeviceHandle == SelfLoadedImage->DeviceHandle) SelfVolume = Volume; } - FreePool(Handles); + MyFreePool(Handles); if (SelfVolume == NULL) Print(L"WARNING: SelfVolume not found"); @@ -826,8 +825,8 @@ VOID ScanVolumes(VOID) break; } - FreePool(SectorBuffer1); - FreePool(SectorBuffer2); + MyFreePool(SectorBuffer1); + MyFreePool(SectorBuffer2); } } @@ -924,8 +923,8 @@ EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, // free pointer from last call if (*DirEntry != NULL) { - FreePool(*DirEntry); - *DirEntry = NULL; + FreePool(*DirEntry); + *DirEntry = NULL; } // read next directory entry @@ -1049,8 +1048,8 @@ BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR CHAR16 *OnePattern; if (DirIter->LastFileInfo != NULL) { - FreePool(DirIter->LastFileInfo); - DirIter->LastFileInfo = NULL; + FreePool(DirIter->LastFileInfo); + DirIter->LastFileInfo = NULL; } if (EFI_ERROR(DirIter->LastStatus)) @@ -1081,12 +1080,12 @@ BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR EFI_STATUS DirIterClose(IN OUT REFIT_DIR_ITER *DirIter) { - if (DirIter->LastFileInfo != NULL) { - FreePool(DirIter->LastFileInfo); - DirIter->LastFileInfo = NULL; - } - if (DirIter->CloseDirHandle) - refit_call1_wrapper(DirIter->DirHandle->Close, DirIter->DirHandle); + if (DirIter->LastFileInfo != NULL) { + FreePool(DirIter->LastFileInfo); + DirIter->LastFileInfo = NULL; + } + if (DirIter->CloseDirHandle) + refit_call1_wrapper(DirIter->DirHandle->Close, DirIter->DirHandle); return DirIter->LastStatus; } @@ -1166,8 +1165,8 @@ BOOLEAN StriSubCmp(IN CHAR16 *SmallStr, IN CHAR16 *BigStr) { while ((!Found) && (StartPoint < NumCompares)) { Found = (StrnCmp(SmallCopy, &BigCopy[StartPoint++], SmallLen) == 0); } // while - FreePool(SmallCopy); - FreePool(BigCopy); + MyFreePool(SmallCopy); + MyFreePool(BigCopy); } // if return (Found); @@ -1202,7 +1201,7 @@ VOID MergeStrings(IN OUT CHAR16 **First, IN CHAR16 *Second, CHAR16 AddChar) { } // if (*First != NULL) if (Second != NULL) StrCat(NewString, Second); - FreePool(*First); + MyFreePool(*First); *First = NewString; } else { Print(L"Error! Unable to allocate memory in MergeStrings()!\n"); @@ -1368,6 +1367,13 @@ BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List) { return Found; } // BOOLEAN IsIn() +// Implement FreePool the way it should have been done to begin with, so that +// it doesn't throw an ASSERT message if fed a NULL pointer.... +VOID MyFreePool(IN OUT VOID *Pointer) { + if (Pointer != NULL) + FreePool(Pointer); +} + static EFI_GUID AppleRemovableMediaGuid = APPLE_REMOVABLE_MEDIA_PROTOCOL_GUID; // Eject all removable media. @@ -1391,7 +1397,7 @@ BOOLEAN EjectMedia(VOID) { if (!EFI_ERROR(Status)) Ejected++; } - FreePool(Handles); + MyFreePool(Handles); return (Ejected > 0); } // VOID EjectMedia() diff --git a/refind/lib.h b/refind/lib.h index 147ae3c..b67ae7f 100644 --- a/refind/lib.h +++ b/refind/lib.h @@ -111,6 +111,7 @@ CHAR16 *FindPath(IN CHAR16* FullPath); CHAR16 *FindNumbers(IN CHAR16 *InString); CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index); BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List); +VOID MyFreePool(IN OUT VOID *Pointer); BOOLEAN EjectMedia(VOID); diff --git a/refind/main.c b/refind/main.c index c459d72..beac3bf 100644 --- a/refind/main.c +++ b/refind/main.c @@ -115,7 +115,7 @@ static VOID AboutrEFInd(VOID) if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.5.6"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.6"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith"); @@ -233,8 +233,7 @@ bailout_unload: // unload the image, we don't care if it works or not... Status = refit_call1_wrapper(BS->UnloadImage, ChildImageHandle); bailout: - if (FullLoadOptions != NULL) - FreePool(FullLoadOptions); + MyFreePool(FullLoadOptions); return ReturnStatus; } /* static EFI_STATUS StartEFIImageList() */ @@ -309,14 +308,13 @@ static CHAR16 * FindInitrd(IN CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume) { MergeStrings(&InitrdName, DirEntry->FileName, 0); } // if } // if/else - if (InitrdVersion != NULL) - FreePool(InitrdVersion); + MyFreePool(InitrdVersion); } // while DirIterClose(&DirIter); // Note: Don't FreePool(FileName), since Basename returns a pointer WITHIN the string it's passed. - FreePool(KernelVersion); - FreePool(Path); + MyFreePool(KernelVersion); + MyFreePool(Path); return (InitrdName); } // static CHAR16 * FindInitrd() @@ -335,8 +333,8 @@ static REFIT_MENU_SCREEN* CopyMenuScreen(REFIT_MENU_SCREEN *Entry) { NewEntry = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); if ((Entry != NULL) && (NewEntry != NULL)) { CopyMem(NewEntry, Entry, sizeof(REFIT_MENU_SCREEN)); - NewEntry->Title = StrDuplicate(Entry->Title); - NewEntry->TimeoutText = StrDuplicate(Entry->TimeoutText); + NewEntry->Title = (Entry->Title) ? StrDuplicate(Entry->Title) : NULL; + NewEntry->TimeoutText = (Entry->TimeoutText) ? StrDuplicate(Entry->TimeoutText) : NULL; if (Entry->TitleImage != NULL) { NewEntry->TitleImage = AllocatePool(sizeof(EG_IMAGE)); if (NewEntry->TitleImage != NULL) @@ -344,7 +342,7 @@ static REFIT_MENU_SCREEN* CopyMenuScreen(REFIT_MENU_SCREEN *Entry) { } // if NewEntry->InfoLines = (CHAR16**) AllocateZeroPool(Entry->InfoLineCount * (sizeof(CHAR16*))); for (i = 0; i < Entry->InfoLineCount && NewEntry->InfoLines; i++) { - NewEntry->InfoLines[i] = StrDuplicate(Entry->InfoLines[i]); + NewEntry->InfoLines[i] = (Entry->InfoLines[i]) ? StrDuplicate(Entry->InfoLines[i]) : NULL; } // for NewEntry->Entries = (REFIT_MENU_ENTRY**) AllocateZeroPool(Entry->EntryCount * (sizeof (REFIT_MENU_ENTRY*))); for (i = 0; i < Entry->EntryCount && NewEntry->Entries; i++) { @@ -365,7 +363,7 @@ static REFIT_MENU_ENTRY* CopyMenuEntry(REFIT_MENU_ENTRY *Entry) { NewEntry = AllocateZeroPool(sizeof(REFIT_MENU_ENTRY)); if ((Entry != NULL) && (NewEntry != NULL)) { CopyMem(NewEntry, Entry, sizeof(REFIT_MENU_ENTRY)); - NewEntry->Title = StrDuplicate(Entry->Title); + NewEntry->Title = (Entry->Title) ? StrDuplicate(Entry->Title) : NULL; if (Entry->BadgeImage != NULL) { NewEntry->BadgeImage = AllocatePool(sizeof(EG_IMAGE)); if (NewEntry->BadgeImage != NULL) @@ -399,12 +397,12 @@ LOADER_ENTRY *InitializeLoaderEntry(IN LOADER_ENTRY *Entry) { NewEntry->UseGraphicsMode = FALSE; NewEntry->OSType = 0; if (Entry != NULL) { - NewEntry->LoaderPath = StrDuplicate(Entry->LoaderPath); - NewEntry->VolName = StrDuplicate(Entry->VolName); + NewEntry->LoaderPath = (Entry->LoaderPath) ? StrDuplicate(Entry->LoaderPath) : NULL; + NewEntry->VolName = (Entry->VolName) ? StrDuplicate(Entry->VolName) : NULL; NewEntry->DevicePath = Entry->DevicePath; NewEntry->UseGraphicsMode = Entry->UseGraphicsMode; - NewEntry->LoadOptions = StrDuplicate(Entry->LoadOptions); - NewEntry->InitrdPath = StrDuplicate(Entry->InitrdPath); + NewEntry->LoadOptions = (Entry->LoadOptions) ? StrDuplicate(Entry->LoadOptions) : NULL; + NewEntry->InitrdPath = (Entry->InitrdPath) ? StrDuplicate(Entry->InitrdPath) : NULL; } } // if return (NewEntry); @@ -438,7 +436,7 @@ REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry) { MergeStrings(&Temp, L"initrd=", 0); MergeStrings(&Temp, SubEntry->InitrdPath, 0); MergeStrings(&SubEntry->LoadOptions, Temp, L' '); - FreePool(Temp); + MyFreePool(Temp); } // if AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry); } // if (SubEntry != NULL) @@ -460,7 +458,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) { // create the submenu if (StrLen(Entry->Title) == 0) { - FreePool(Entry->Title); + MyFreePool(Entry->Title); Entry->Title = NULL; } SubScreen = InitializeSubScreen(Entry); @@ -527,7 +525,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) { SubEntry = InitializeLoaderEntry(Entry); if (SubEntry != NULL) { SubEntry->me.Title = L"Run Apple Hardware Test"; - FreePool(SubEntry->LoaderPath); + MyFreePool(SubEntry->LoaderPath); SubEntry->LoaderPath = StrDuplicate(DiagsFileName); SubEntry->DevicePath = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath); SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX; @@ -547,19 +545,16 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) { while ((TokenCount = ReadTokenLine(File, &TokenList)) > 1) { SubEntry = InitializeLoaderEntry(Entry); SubEntry->me.Title = StrDuplicate(TokenList[0]); - if (SubEntry->LoadOptions != NULL) - FreePool(SubEntry->LoadOptions); + MyFreePool(SubEntry->LoadOptions); SubEntry->LoadOptions = StrDuplicate(TokenList[1]); MergeStrings(&SubEntry->LoadOptions, InitrdOption, L' '); FreeTokenLine(&TokenList, &TokenCount); SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_LINUX; AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry); } // while - if (InitrdOption) - FreePool(InitrdOption); - if (Temp) - FreePool(Temp); - FreePool(File); + MyFreePool(InitrdOption); + MyFreePool(Temp); + MyFreePool(File); } // if Linux options file exists } else if (Entry->OSType == 'E') { // entries for ELILO @@ -647,10 +642,8 @@ static CHAR16 * GetMainLinuxOptions(IN CHAR16 * LoaderPath, IN REFIT_VOLUME *Vol MergeStrings(&InitrdOption, InitrdName, 0); } // if MergeStrings(&Options, InitrdOption, ' '); - if (InitrdOption != NULL) - FreePool(InitrdOption); - if (InitrdName != NULL) - FreePool(InitrdName); + MyFreePool(InitrdOption); + MyFreePool(InitrdName); return (Options); } // static CHAR16 * GetMainLinuxOptions() @@ -676,7 +669,7 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME Temp = FindLastDirName(LoaderPath); MergeStrings(&OSIconName, Temp, L','); - FreePool(Temp); + MyFreePool(Temp); if (OSIconName != NULL) { ShortcutLetter = OSIconName[0]; } @@ -733,8 +726,7 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME Entry->me.ShortcutLetter = ShortcutLetter; if (Entry->me.Image == NULL) Entry->me.Image = LoadOSIcon(OSIconName, L"unknown", FALSE); - if (PathOnly != NULL) - FreePool(PathOnly); + MyFreePool(PathOnly); } // VOID SetLoaderDefaults() // Add a specified EFI boot loader to the list, using automatic settings @@ -818,8 +810,8 @@ static VOID CleanUpLoaderList(struct LOADER_LIST *LoaderList) { while (LoaderList != NULL) { Temp = LoaderList; LoaderList = LoaderList->NextEntry; - FreePool(Temp->FileName); - FreePool(Temp); + MyFreePool(Temp->FileName); + MyFreePool(Temp); } // while } // static VOID CleanUpLoaderList() @@ -859,7 +851,7 @@ static VOID ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16 *P NewLoader->TimeStamp = DirEntry->ModificationTime; LoaderList = AddLoaderListEntry(LoaderList, NewLoader); } // if - FreePool(Extension); + MyFreePool(Extension); } // while NewLoader = LoaderList; while (NewLoader != NULL) { @@ -870,9 +862,9 @@ static VOID ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16 *P Status = DirIterClose(&DirIter); if (Status != EFI_NOT_FOUND) { if (Path) - SPrint(FileName, 255, L"while scanning the %s directory", Path); + SPrint(FileName, 255, L"while scanning the %s directory", Path); else - StrCpy(FileName, L"while scanning the root directory"); + StrCpy(FileName, L"while scanning the root directory"); CheckError(Status, FileName); } // if (Status != EFI_NOT_FOUND) } // if not scanning our own directory @@ -885,9 +877,9 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { CHAR16 FileName[256], *Directory, *MatchPatterns; UINTN i, Length; - MatchPatterns = StrDuplicate(LOADER_MATCH_PATTERNS); - if (GlobalConfig.ScanAllLinux) - MergeStrings(&MatchPatterns, LINUX_MATCH_PATTERNS, L','); + MatchPatterns = StrDuplicate(LOADER_MATCH_PATTERNS); + if (GlobalConfig.ScanAllLinux) + MergeStrings(&MatchPatterns, LINUX_MATCH_PATTERNS, L','); if ((Volume->RootDir != NULL) && (Volume->VolName != NULL)) { // check for Mac OS X boot loader @@ -932,7 +924,7 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { Length = StrLen(Directory); if (Length > 0) ScanLoaderDir(Volume, Directory, MatchPatterns); - FreePool(Directory); + MyFreePool(Directory); } // while } // if } // static VOID ScanEfiFiles() @@ -1269,7 +1261,7 @@ static LEGACY_ENTRY * AddLegacyEntryUEFI(BDS_COMMON_OPTION *BdsOption, IN UINT16 Entry = AllocateZeroPool(sizeof(LEGACY_ENTRY)); Entry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16)); SPrint(Entry->me.Title, 255, L"Boot legacy target %s", LegacyDescription); - Entry->me.Tag = TAG_LEGACY_NON_MAC; + Entry->me.Tag = TAG_LEGACY_UEFI; Entry->me.Row = 0; Entry->me.ShortcutLetter = ShortcutLetter; Entry->me.Image = LoadOSIcon(L"legacy", L"legacy", TRUE); @@ -1290,7 +1282,7 @@ static LEGACY_ENTRY * AddLegacyEntryUEFI(BDS_COMMON_OPTION *BdsOption, IN UINT16 SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY)); SubEntry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16)); SPrint(SubEntry->me.Title, 255, L"Boot %s", LegacyDescription); - SubEntry->me.Tag = TAG_LEGACY_NON_MAC; + SubEntry->me.Tag = TAG_LEGACY_UEFI; Entry->BdsOption = BdsOption; AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry); @@ -1341,7 +1333,6 @@ static VOID ScanLegacyUEFI(IN UINTN DiskType) // Grab each boot option variable from the boot order, and convert // the variable into a BDS boot option UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]); - Print(L"Scanning '%s'\n", BootOption); BdsOption = BdsLibVariableToOption (&TempList, BootOption); if (BdsOption != NULL) { @@ -1474,7 +1465,7 @@ static LOADER_ENTRY * AddToolEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle Entry->me.Row = 1; Entry->me.ShortcutLetter = ShortcutLetter; Entry->me.Image = Image; - Entry->LoaderPath = StrDuplicate(LoaderPath); + Entry->LoaderPath = (LoaderPath) ? StrDuplicate(LoaderPath) : NULL; Entry->DevicePath = FileDevicePath(SelfLoadedImage->DeviceHandle, Entry->LoaderPath); Entry->UseGraphicsMode = UseGraphicsMode; @@ -1574,12 +1565,12 @@ static EFI_STATUS ConnectAllDriversToAllControllers(VOID) } } - FreePool (HandleBuffer); - FreePool (HandleType); + MyFreePool (HandleBuffer); + MyFreePool (HandleType); } Done: - FreePool (AllHandleBuffer); + MyFreePool (AllHandleBuffer); return Status; } /* EFI_STATUS ConnectAllDriversToAllControllers() */ #else @@ -1600,12 +1591,12 @@ static VOID LoadDrivers(VOID) // load drivers from the subdirectories of rEFInd's home directory specified // in the DRIVER_DIRS constant. while ((Directory = FindCommaDelimited(DRIVER_DIRS, i++)) != NULL) { - SelfDirectory = StrDuplicate(SelfDirPath); + SelfDirectory = SelfDirPath ? StrDuplicate(SelfDirPath) : NULL; CleanUpPathNameSlashes(SelfDirectory); MergeStrings(&SelfDirectory, Directory, L'\\'); NumFound += ScanDriverDir(SelfDirectory); - FreePool(Directory); - FreePool(SelfDirectory); + MyFreePool(Directory); + MyFreePool(SelfDirectory); } // Scan additional user-specified driver directories.... @@ -1615,7 +1606,7 @@ static VOID LoadDrivers(VOID) Length = StrLen(Directory); if (Length > 0) NumFound += ScanDriverDir(Directory); - FreePool(Directory); + MyFreePool(Directory); } // while // connect all devices @@ -1649,6 +1640,35 @@ static VOID FindLegacyBootType(VOID) { GlobalConfig.LegacyType = LEGACY_TYPE_MAC; } // static VOID FindLegacyBootType +// Warn the user if legacy OS scans are enabled but the firmware or this +// application can't support them.... +static VOID WarnIfLegacyProblems() { + BOOLEAN found = FALSE; + UINTN i = 0; + + if (GlobalConfig.LegacyType == LEGACY_TYPE_NONE) { + do { + if (GlobalConfig.ScanFor[i] == 'h' || GlobalConfig.ScanFor[i] == 'b' || GlobalConfig.ScanFor[i] == 'c') + found = TRUE; + i++; + } while ((i < NUM_SCAN_OPTIONS) && (!found)); + if (found) { + Print(L"NOTE: refind.conf's 'scanfor' line specifies scanning for one or more legacy\n"); + Print(L"(BIOS) boot options; however, this is not possible because "); +#ifdef __MAKEWITH_TIANO + Print(L"your computer lacks\n"); + Print(L"the necessary Compatibility Support Module (CSM) support.\n"); +#else + Print(L"this program was\n"); + Print(L"compiled without the necessary support. Please visit\n"); + Print(L"http://www.rodsbooks.com/refind/getting.html and download and install a rEFInd\n"); + Print(L"binary built with the TianoCore EDK2 to enable legacy boot support.\n"); +#endif + PauseForKey(); + } // if (found) + } // if no legacy support +} // static VOID WarnIfLegacyProblems() + // Locates boot loaders. NOTE: This assumes that GlobalConfig.LegacyType is set correctly. static VOID ScanForBootloaders(VOID) { UINTN i; @@ -1734,10 +1754,8 @@ static VOID ScanForTools(VOID) { } break; } // switch() - if (FileName != NULL) { - FreePool(FileName); - FileName = NULL; - } + MyFreePool(FileName); + FileName = NULL; } // for } // static VOID ScanForTools @@ -1798,12 +1816,12 @@ efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) return Status; // read configuration + CopyMem(GlobalConfig.ScanFor, "ieom ", NUM_SCAN_OPTIONS); FindLegacyBootType(); if (GlobalConfig.LegacyType == LEGACY_TYPE_MAC) CopyMem(GlobalConfig.ScanFor, "ihebocm ", NUM_SCAN_OPTIONS); - else - CopyMem(GlobalConfig.ScanFor, "ieom ", NUM_SCAN_OPTIONS); ReadConfig(); + WarnIfLegacyProblems(); MainMenu.TimeoutSeconds = GlobalConfig.Timeout; // disable EFI watchdog timer @@ -1861,7 +1879,7 @@ efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) break; #ifdef __MAKEWITH_TIANO - case TAG_LEGACY_NON_MAC: // Boot a legacy OS on a non-Mac + case TAG_LEGACY_UEFI: // Boot a legacy OS on a non-Mac StartLegacyUEFI((LEGACY_ENTRY *)ChosenEntry); break; #endif // __MAKEWITH_TIANO @@ -1876,8 +1894,8 @@ efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) break; } // switch() - FreePool(Selection); - Selection = StrDuplicate(ChosenEntry->Title); + MyFreePool(Selection); + Selection = (ChosenEntry->Title) ? StrDuplicate(ChosenEntry->Title) : NULL; } // while() // If we end up here, things have gone wrong. Try to reboot, and if that diff --git a/refind/menu.c b/refind/menu.c index 221be00..700f7d8 100644 --- a/refind/menu.c +++ b/refind/menu.c @@ -308,11 +308,6 @@ VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry) AddListElement((VOID ***) &(Screen->Entries), &(Screen->EntryCount), Entry); } -VOID FreeMenu(IN REFIT_MENU_SCREEN *Screen) -{ - if (Screen->Entries) - FreePool(Screen->Entries); -} static INTN FindMenuShortcutEntry(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *Shortcut) { @@ -552,8 +547,8 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, case MENU_FUNCTION_CLEANUP: // release temporary memory for (i = 0; i <= State->MaxIndex; i++) - FreePool(DisplayStrings[i]); - FreePool(DisplayStrings); + MyFreePool(DisplayStrings[i]); + MyFreePool(DisplayStrings); break; case MENU_FUNCTION_PAINT_ALL: @@ -874,7 +869,7 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT break; case MENU_FUNCTION_CLEANUP: - FreePool(itemPosX); + MyFreePool(itemPosX); break; case MENU_FUNCTION_PAINT_ALL: diff --git a/refind/menu.h b/refind/menu.h index 6e4170b..2d3e658 100644 --- a/refind/menu.h +++ b/refind/menu.h @@ -94,7 +94,6 @@ struct _refit_menu_screen; VOID AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *InfoLine); VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry); -VOID FreeMenu(IN REFIT_MENU_SCREEN *Screen); VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText); UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_MENU_ENTRY **ChosenEntry); UINTN RunMainMenu(IN REFIT_MENU_SCREEN *Screen, IN CHAR16* DefaultSelection, OUT REFIT_MENU_ENTRY **ChosenEntry); -- 2.39.2