]> code.delx.au - refind/commitdiff
Fixed an icon display bug & very minor incorrect error message bug.
authorsrs5694 <srs5694@users.sourceforge.net>
Mon, 9 Apr 2012 02:15:11 +0000 (22:15 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Mon, 9 Apr 2012 02:15:11 +0000 (22:15 -0400)
NEWS.txt
mkcdimage
refind/config.c
refind/icns.c
refind/lib.c
refind/main.c
refind/menu.c

index 9896a58d38b87ff480ed97e459a8070d247303fc..e0a3e84de0f65fa88c291a84f9207f0cc806f772 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,16 @@
-0.2.4 (?/??/2012):
+0.2.5 (?/??/2012):
 ------------------
 
+- Fixed bug that caused icons to drop back to generic icons when rEFInd
+  was launched in certain ways (such as from an EFI shell in rEFInd's
+  directory) on certain systems.
+
+- Fixed bug that caused "unknown disable flag" to be shown (very briefly)
+  instead of "unknown hideui flag" when an improper hideui flag was set.
+
+0.2.4 (4/5/2012):
+-----------------
+
 - Created new refind.conf entry: "showtools". This entry takes options of
   "shell", "gptsync", "about", "exit", "reboot", and "shutdown". This
   option is in some respects an affirmative version of portions of the old
index d38bcd86fc41a7fbfd0fdaae8bf2603bbe43f45e..ff58829ce47788bc7fa1cb760c5f5cb15887e13a 100755 (executable)
--- a/mkcdimage
+++ b/mkcdimage
@@ -61,7 +61,7 @@ mkisofs -A "Bootable rEFInd" -V "rEFInd $Version" -volset "rEFInd $Version" \
     -J -r -v -x ./lost+found -o ../../refind-cd-$Version.iso \
     -eltorito-alt-boot -efi-boot refind-bin-$Version.img \
     -no-emul-boot ./
-    
+
 # Below is like above, but also creates an El Torito entry for BIOS
 # booting. That's useless, but in case something flakes out without
 # it, I'll preserve this version for a while....
@@ -71,5 +71,28 @@ mkisofs -A "Bootable rEFInd" -V "rEFInd $Version" -volset "rEFInd $Version" \
 #    -eltorito-alt-boot -efi-boot refind-bin-$Version.img \
 #    -no-emul-boot ./
 
-cd ../../
-rm -r temp/
+# Create a bootable USB flash drive image, using the FAT filesystem
+# created above and a stored partition table image (plus some empty
+# sectors)....
+rm ../../refind-flashdrive-$Version.*
+cat $StartDir/flashparts.img refind-bin-$Version.img > refind-flashdrive-$Version.img
+cp $StartDir/README-flashdrive.txt ./
+cd ..
+mv refind-bin-$Version refind-flashdrive-$Version
+zip -9r ../refind-flashdrive-$Version.zip \
+    refind-flashdrive-$Version/refind-flashdrive-$Version.img \
+    refind-flashdrive-$Version/docs refind-flashdrive-$Version/LICENSE.txt \
+    refind-flashdrive-$Version/COPYING.txt \
+    refind-flashdrive-$Version/CREDITS.txt \
+    refind-flashdrive-$Version/README.txt \
+    refind-flashdrive-$Version/SHELLS.txt \
+    refind-flashdrive-$Version/README-flashdrive.txt
+mv refind-flashdrive-$Version/refind-flashdrive-$Version.img ../
+
+cd ../
+
+# Zip up the optical disc image....
+rm refind-cd-$Version.zip
+zip -9 refind-cd-$Version.zip refind-cd-$Version.iso
+
+#rm -r temp/
index 803ce61bde5bf852bbc1e5fdc070ce2204163a5d..955948b7abbc740bc88da0235b42d655651293ab 100644 (file)
@@ -81,7 +81,7 @@ static EFI_STATUS ReadFile(IN EFI_FILE_HANDLE BaseDir, CHAR16 *FileName, REFIT_F
     Status = refit_call5_wrapper(BaseDir->Open, BaseDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0);
     if (CheckError(Status, L"while loading the configuration file"))
         return Status;
-    
+
     FileInfo = LibFileInfo(FileHandle);
     if (FileInfo == NULL) {
         // TODO: print and register the error
@@ -92,7 +92,7 @@ static EFI_STATUS ReadFile(IN EFI_FILE_HANDLE BaseDir, CHAR16 *FileName, REFIT_F
     if (ReadSize > MAXCONFIGFILESIZE)
         ReadSize = MAXCONFIGFILESIZE;
     FreePool(FileInfo);
-    
+
     File->BufferSize = (UINTN)ReadSize;   // was limited to a few K before, so this is safe
     File->Buffer = AllocatePool(File->BufferSize);
     Status = refit_call3_wrapper(FileHandle->Read, FileHandle, &File->BufferSize, File->Buffer);
@@ -103,7 +103,7 @@ static EFI_STATUS ReadFile(IN EFI_FILE_HANDLE BaseDir, CHAR16 *FileName, REFIT_F
         return Status;
     }
     Status = refit_call1_wrapper(FileHandle->Close, FileHandle);
-    
+
     // setup for reading
     File->Current8Ptr  = (CHAR8 *)File->Buffer;
     File->End8Ptr      = File->Current8Ptr + File->BufferSize;
@@ -346,7 +346,7 @@ VOID ReadConfig(VOID)
                 } else if (StriCmp(FlagName, L"all") == 0) {
                     GlobalConfig.HideUIFlags = HIDEUI_ALL;
                 } else {
-                    Print(L" unknown disable flag: '%s'\n", FlagName);
+                    Print(L" unknown hideui flag: '%s'\n", FlagName);
                 }
             }
 
index 09f28cffabf6adf699f1a87a0ca75b25e1712d95..459dece88172a45411193a3ce1616e06058342db 100644 (file)
@@ -66,10 +66,10 @@ EG_IMAGE * BuiltinIcon(IN UINTN Id)
 {
     if (Id >= BUILTIN_ICON_COUNT)
         return NULL;
-    
+
     if (BuiltinIconTable[Id].Image == NULL)
         BuiltinIconTable[Id].Image = LoadIcnsFallback(SelfDir, BuiltinIconTable[Id].Path, BuiltinIconTable[Id].PixelSize);
-    
+
     return BuiltinIconTable[Id].Image;
 }
 
@@ -104,11 +104,11 @@ EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconNam
     Image = egLoadIcon(SelfDir, FileName, 128);
     if (Image != NULL)
         return Image;
-    
+
     // try the fallback name with os_ instead of boot_
     if (BootLogo)
         return LoadOSIcon(NULL, FallbackIconName, FALSE);
-    
+
     return DummyImage(128);
 } /* EG_IMAGE * LoadOSIcon() */
 
index b0090c66c43a406065d286421b74699a38d4c7fe..f5278aeac27231895c3fbc4d99bef9f1bf798271 100644 (file)
@@ -73,13 +73,39 @@ static VOID UninitVolumes(VOID);
 // self recognition stuff
 //
 
+// Converts forward slashes to backslashes and removes duplicate slashes.
+// Necessary because some (buggy?) EFI implementations produce "\/" strings
+// in pathnames.
+static VOID CleanUpPathNameSlashes(IN OUT CHAR16 *PathName) {
+   CHAR16   *NewName;
+   UINTN    i, j = 0;
+   BOOLEAN  LastWasSlash = FALSE;
+
+   NewName = AllocateZeroPool(sizeof(CHAR16) * (StrLen(PathName) + 1));
+   if (NewName != NULL) {
+      for (i = 0; i < StrLen(PathName); i++) {
+         if ((PathName[i] == L'/') || (PathName[i] == L'\\')) {
+            if (!LastWasSlash)
+               NewName[j++] = L'\\';
+            LastWasSlash = TRUE;
+         } else {
+            NewName[j++] = PathName[i];
+            LastWasSlash = FALSE;
+         } // if/else
+      } // for
+      NewName[j] = 0;
+      // Copy the transformed name back....
+      StrCpy(PathName, NewName);
+      FreePool(NewName);
+   } // if allocation OK
+} // CleanUpPathNameSlashes()
+
 EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle)
 {
     EFI_STATUS  Status;
     CHAR16      *DevicePathAsString;
-    CHAR16      BaseDirectory[256];
     UINTN       i;
-    
+
     SelfImageHandle = ImageHandle;
     Status = refit_call3_wrapper(BS->HandleProtocol, SelfImageHandle, &LoadedImageProtocol, (VOID **) &SelfLoadedImage);
     if (CheckFatalError(Status, L"while getting a LoadedImageProtocol handle"))
@@ -87,15 +113,15 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle)
 
     // find the current directory
     DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath);
+    CleanUpPathNameSlashes(DevicePathAsString);
     if (DevicePathAsString != NULL) {
-        StrCpy(BaseDirectory, DevicePathAsString);
-        FreePool(DevicePathAsString);
-        for (i = StrLen(BaseDirectory); i > 0 && BaseDirectory[i] != '\\'; i--) ;
-        BaseDirectory[i] = 0;
+        for (i = StrLen(DevicePathAsString); (i > 0) && (DevicePathAsString[i] != '\\'); i--) ;
+        DevicePathAsString[i] = 0;
     } else
-        BaseDirectory[0] = 0;
-    SelfDirPath = StrDuplicate(BaseDirectory);
-    
+        DevicePathAsString[0] = 0;
+    SelfDirPath = StrDuplicate(DevicePathAsString);
+    FreePool(DevicePathAsString);
+
     return FinishInitRefitLib();
 }
 
@@ -135,7 +161,7 @@ EFI_STATUS ReinitRefitLib(VOID)
 }
 
 static EFI_STATUS FinishInitRefitLib(VOID)
-{    
+{
     EFI_STATUS  Status;
 
     if (SelfRootDir == NULL) {
@@ -949,9 +975,9 @@ CHAR16 * Basename(IN CHAR16 *Path)
 {
     CHAR16  *FileName;
     UINTN   i;
-    
+
     FileName = Path;
-    
+
     if (Path != NULL) {
         for (i = StrLen(Path); i > 0; i--) {
             if (Path[i-1] == '\\' || Path[i-1] == '/') {
@@ -960,14 +986,14 @@ CHAR16 * Basename(IN CHAR16 *Path)
             }
         }
     }
-    
+
     return FileName;
 }
 
 VOID ReplaceExtension(IN OUT CHAR16 *Path, IN CHAR16 *Extension)
 {
     UINTN i;
-    
+
     for (i = StrLen(Path); i >= 0; i--) {
         if (Path[i] == '.') {
             Path[i] = 0;
@@ -987,14 +1013,14 @@ INTN FindMem(IN VOID *Buffer, IN UINTN BufferLength, IN VOID *SearchString, IN U
 {
     UINT8 *BufferPtr;
     UINTN Offset;
-    
+
     BufferPtr = Buffer;
     BufferLength -= SearchStringLength;
     for (Offset = 0; Offset < BufferLength; Offset++, BufferPtr++) {
         if (CompareMem(BufferPtr, SearchString, SearchStringLength) == 0)
             return (INTN)Offset;
     }
-    
+
     return -1;
 }
 
@@ -1018,7 +1044,7 @@ BOOLEAN StriSubCmp(IN CHAR16 *SmallStr, IN CHAR16 *BigStr) {
       FreePool(SmallCopy);
       FreePool(BigCopy);
    } // if
-   
+
    return (Found);
 } // BOOLEAN StriSubCmp()
 
@@ -1034,7 +1060,7 @@ BOOLEAN StriSubCmp(IN CHAR16 *SmallStr, IN CHAR16 *BigStr) {
 VOID MergeStrings(IN OUT CHAR16 **First, IN CHAR16 *Second, CHAR16 AddChar) {
    UINTN Length1 = 0, Length2 = 0;
    CHAR16* NewString;
-   
+
    if (*First != NULL)
       Length1 = StrLen(*First);
    if (Second != NULL)
@@ -1065,7 +1091,7 @@ VOID MergeStrings(IN OUT CHAR16 **First, IN CHAR16 *Second, CHAR16 AddChar) {
 CHAR16 *FindLastDirName(IN CHAR16 *Path) {
    UINTN i, StartOfElement = 0, EndOfElement = 0, PathLength, CopyLength;
    CHAR16 *Found = NULL;
-   
+
    PathLength = StrLen(Path);
    // Find start & end of target element
    for (i = 0; i < PathLength; i++) {
@@ -1113,7 +1139,7 @@ CHAR16 *FindPath(IN CHAR16* FullPath) {
 CHAR16 *FindNumbers(IN CHAR16 *InString) {
    UINTN i, StartOfElement, EndOfElement = 0, InLength, CopyLength;
    CHAR16 *Found = NULL;
-   
+
    InLength = StartOfElement = StrLen(InString);
    // Find start & end of target element
    for (i = 0; i < InLength; i++) {
index 5ccd5773bdddcfc52ad1350a8f630ef97d66293a..ea16053127e9e90e25040e95fee0383d6529114d 100644 (file)
@@ -83,7 +83,7 @@ static VOID AboutrEFInd(VOID)
 {
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.2.4");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.2.4.2");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
@@ -525,14 +525,14 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME
    CHAR16          ShortcutLetter = 0;
 
    FileName = Basename(LoaderPath);
-   
+
    // locate a custom icon for the loader
    StrCpy(IconFileName, LoaderPath);
    ReplaceExtension(IconFileName, L".icns");
    if (FileExists(Volume->RootDir, IconFileName)) {
       Entry->me.Image = LoadIcns(Volume->RootDir, IconFileName, 128);
    } // if
-   
+
    Temp = FindLastDirName(LoaderPath);
    MergeStrings(&OSIconName, Temp, L',');
    FreePool(Temp);
@@ -582,7 +582,7 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME
    if (Entry->me.Image == NULL)
       Entry->me.Image = LoadOSIcon(OSIconName, L"unknown", FALSE);
 } // VOID SetLoaderDefaults()
-      
+
 // Add a specified EFI boot loader to the list, using automatic settings
 // for icons, options, etc.
 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume) {
index 90df56b164c2a75652151497f7424f0fac9e3933..4a7f1c9b2dc82aa587784d4c6b1b6f3a7c1c6137 100644 (file)
@@ -96,12 +96,12 @@ static VOID InitSelection(VOID)
 {
     UINTN       x, y, src_x, src_y;
     EG_PIXEL    *DestPtr, *SrcPtr;
-    
+
     if (!AllowGraphicsMode)
         return;
     if (SelectionImages[0] != NULL)
         return;
-    
+
     // load small selection image
     if (GlobalConfig.SelectionSmallFileName != NULL) {
         SelectionImages[2] = egLoadImage(SelfDir, GlobalConfig.SelectionSmallFileName, FALSE);
@@ -112,7 +112,7 @@ static VOID InitSelection(VOID)
                                            ROW1_TILESIZE, ROW1_TILESIZE, &MenuBackgroundPixel);
     if (SelectionImages[2] == NULL)
         return;
-    
+
     // load big selection image
     if (GlobalConfig.SelectionBigFileName != NULL) {
         SelectionImages[0] = egLoadImage(SelfDir, GlobalConfig.SelectionBigFileName, FALSE);
@@ -121,14 +121,14 @@ static VOID InitSelection(VOID)
     }
     if (SelectionImages[0] == NULL) {
         // calculate big selection image from small one
-        
+
         SelectionImages[0] = egCreateImage(ROW0_TILESIZE, ROW0_TILESIZE, FALSE);
         if (SelectionImages[0] == NULL) {
             egFreeImage(SelectionImages[2]);
             SelectionImages[2] = NULL;
             return;
         }
-        
+
         DestPtr = SelectionImages[0]->PixelData;
         SrcPtr  = SelectionImages[2]->PixelData;
         for (y = 0; y < ROW0_TILESIZE; y++) {
@@ -138,7 +138,7 @@ static VOID InitSelection(VOID)
                 src_y = (ROW1_TILESIZE >> 1);
             else
                 src_y = y - (ROW0_TILESIZE - ROW1_TILESIZE);
-            
+
             for (x = 0; x < ROW0_TILESIZE; x++) {
                 if (x < (ROW1_TILESIZE >> 1))
                     src_x = x;
@@ -146,12 +146,12 @@ static VOID InitSelection(VOID)
                     src_x = (ROW1_TILESIZE >> 1);
                 else
                     src_x = x - (ROW0_TILESIZE - ROW1_TILESIZE);
-                
+
                 *DestPtr++ = SrcPtr[src_y * ROW1_TILESIZE + src_x];
             }
         }
     }
-    
+
     // non-selected background images
     SelectionImages[1] = egCreateFilledImage(ROW0_TILESIZE, ROW0_TILESIZE, FALSE, &MenuBackgroundPixel);
     SelectionImages[3] = egCreateFilledImage(ROW1_TILESIZE, ROW1_TILESIZE, FALSE, &MenuBackgroundPixel);
@@ -385,9 +385,9 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
                 break;
         }
     }
-    
+
     StyleFunc(Screen, &State, MENU_FUNCTION_CLEANUP, NULL);
-    
+
     if (ChosenEntry)
         *ChosenEntry = Screen->Entries[State.CurrentSelection];
     return MenuExit;
@@ -404,9 +404,9 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
     static UINTN MenuPosY;
     static CHAR16 **DisplayStrings;
     CHAR16 *TimeoutMessage;
-    
+
     switch (Function) {
-        
+
         case MENU_FUNCTION_INIT:
             // vertical layout
             MenuPosY = 4;
@@ -416,7 +416,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             if (Screen->TimeoutSeconds > 0)
                 MenuHeight -= 2;
             InitScroll(State, Screen->EntryCount, MenuHeight);
-            
+
             // determine width of the menu
             MenuWidth = 20;  // minimum
             for (i = 0; i <= State->MaxIndex; i++) {
@@ -426,7 +426,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             }
             if (MenuWidth > ConWidth - 6)
                 MenuWidth = ConWidth - 6;
-            
+
             // prepare strings for display
             DisplayStrings = AllocatePool(sizeof(CHAR16 *) * Screen->EntryCount);
             for (i = 0; i <= State->MaxIndex; i++)
@@ -434,7 +434,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             // TODO: shorten strings that are too long (PoolPrint doesn't do that...)
             // TODO: use more elaborate techniques for shortening too long strings (ellipses in the middle)
             // TODO: account for double-width characters
-                
+
             // initial painting
             BeginTextScreen(Screen->Title);
             if (Screen->InfoLineCount > 0) {
@@ -444,16 +444,16 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
                     refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, Screen->InfoLines[i]);
                 }
             }
-            
+
             break;
-            
+
         case MENU_FUNCTION_CLEANUP:
             // release temporary memory
             for (i = 0; i <= State->MaxIndex; i++)
                 FreePool(DisplayStrings[i]);
             FreePool(DisplayStrings);
             break;
-            
+
         case MENU_FUNCTION_PAINT_ALL:
             // paint the whole screen (initially and after scrolling)
             for (i = 0; i <= State->MaxIndex; i++) {
@@ -479,7 +479,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             else
                refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, L" ");
             break;
-            
+
         case MENU_FUNCTION_PAINT_SELECTION:
             // redraw selection cursor
             refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 2, MenuPosY + (State->LastSelection - State->FirstVisible));
@@ -489,7 +489,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_CHOICE_CURRENT);
             refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, DisplayStrings[State->CurrentSelection]);
             break;
-            
+
         case MENU_FUNCTION_PAINT_TIMEOUT:
             if (ParamText[0] == 0) {
                 // clear message
@@ -768,11 +768,11 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT
             InitSelection();
             SwitchToGraphicsAndClear();
             break;
-            
+
         case MENU_FUNCTION_CLEANUP:
             FreePool(itemPosX);
             break;
-            
+
         case MENU_FUNCTION_PAINT_ALL:
             BltClearScreen(TRUE);
             PaintAll(Screen, State, itemPosX, row0PosY, row1PosY, textPosY);
@@ -791,12 +791,12 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT
         case MENU_FUNCTION_PAINT_SELECTION:
             PaintSelection(Screen, State, itemPosX, row0PosY, row1PosY, textPosY);
             break;
-            
+
         case MENU_FUNCTION_PAINT_TIMEOUT:
             if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL))
                 DrawMainMenuText(ParamText, (UGAWidth - LAYOUT_TEXT_WIDTH) >> 1, textPosY + TEXT_LINE_HEIGHT);
             break;
-            
+
     }
 }