#define SAMPLE_SIZE 69632 /* 68 KiB -- ReiserFS superblock begins at 64 KiB */
// Default names for volume badges (mini-icon to define disk type) and icons
-#define VOLUME_BADGE_NAME L".VolumeBadge.icns"
-#define VOLUME_ICON_NAME L".VolumeIcon.icns"
+#define VOLUME_BADGE_NAMES L".VolumeBadge.icns,.VolumeBadge.png"
+#define VOLUME_ICON_NAMES L".VolumeIcon.icns,.VolumeIcon.png"
// functions
// after that string (after some cleanup) as the return value, and truncating the original
// input value.
// If InString contains no ")" character, this function leaves the original input string
-// unmodified and also returns that string.
+// unmodified and also returns that string. If InString is NULL, this function returns NULL.
static CHAR16* SplitDeviceString(IN OUT CHAR16 *InString) {
INTN i;
CHAR16 *FileName = NULL;
BOOLEAN Found = FALSE;
- i = StrLen(InString) - 1;
- while ((i >= 0) && (!Found)) {
- if (InString[i] == L')') {
- Found = TRUE;
- FileName = StrDuplicate(&InString[i + 1]);
- CleanUpPathNameSlashes(FileName);
- InString[i + 1] = '\0';
- } // if
- i--;
- } // while
- if (FileName == NULL)
- FileName = StrDuplicate(InString);
+ if (InString != NULL) {
+ i = StrLen(InString) - 1;
+ while ((i >= 0) && (!Found)) {
+ if (InString[i] == L')') {
+ Found = TRUE;
+ FileName = StrDuplicate(&InString[i + 1]);
+ CleanUpPathNameSlashes(FileName);
+ InString[i + 1] = '\0';
+ } // if
+ i--;
+ } // while
+ if (FileName == NULL)
+ FileName = StrDuplicate(InString);
+ } // if
return FileName;
} // static CHAR16* SplitDeviceString()
Volume->VolName = GetVolumeName(Volume);
// get custom volume icon if present
- if (FileExists(Volume->RootDir, VOLUME_BADGE_NAME))
- Volume->VolBadgeImage = LoadIcns(Volume->RootDir, VOLUME_BADGE_NAME, 32);
- if (FileExists(Volume->RootDir, VOLUME_ICON_NAME)) {
- Volume->VolIconImage = LoadIcns(Volume->RootDir, VOLUME_ICON_NAME, 128);
- }
+ if (!Volume->VolBadgeImage)
+ Volume->VolBadgeImage = LoadIcns(Volume->RootDir, VOLUME_BADGE_NAMES, 32);
+ if (!Volume->VolIconImage)
+ Volume->VolIconImage = LoadIcns(Volume->RootDir, VOLUME_ICON_NAMES, 128);
} // ScanVolume()
static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_INFO *MbrEntry)
VOID ScanVolumes(VOID)
{
EFI_STATUS Status;
- UINTN HandleCount = 0;
- UINTN HandleIndex;
EFI_HANDLE *Handles;
REFIT_VOLUME *Volume, *WholeDiskVolume;
- UINTN VolumeIndex, VolumeIndex2;
MBR_PARTITION_INFO *MbrTable;
+ UINTN HandleCount = 0;
+ UINTN HandleIndex;
+ UINTN VolumeIndex, VolumeIndex2;
UINTN PartitionIndex;
- UINT8 *SectorBuffer1, *SectorBuffer2;
UINTN SectorSum, i, VolNumber = 0;
+ UINT8 *SectorBuffer1, *SectorBuffer2;
MyFreePool(Volumes);
Volumes = NULL;
ScanVolume(Volume);
if (Volume->IsReadable)
Volume->VolNumber = VolNumber++;
+ else
+ Volume->VolNumber = VOL_UNREADABLE;
AddListElement((VOID ***) &Volumes, &VolumesCount, Volume);
return FileName;
}
-// Replaces a filename extension of ".efi" with the specified string
-// (Extension). If the input Path doesn't end in ".efi", Extension
-// is added to the existing filename.
-VOID ReplaceEfiExtension(IN OUT CHAR16 *Path, IN CHAR16 *Extension)
-{
- UINTN PathLen;
-
- PathLen = StrLen(Path);
- // Note: Do StriCmp() twice to work around Gigabyte Hybrid EFI case-sensitivity bug....
- if ((PathLen >= 4) && ((StriCmp(&Path[PathLen - 4], L".efi") == 0) || (StriCmp(&Path[PathLen - 4], L".EFI") == 0))) {
- Path[PathLen - 4] = 0;
- } // if
- StrCat(Path, Extension);
-} // VOID ReplaceEfiExtension()
+// Remove the .efi extension from FileName -- for instance, if FileName is
+// "fred.efi", returns "fred". If the filename contains no .efi extension,
+// returns a copy of the original input.
+CHAR16 * StripEfiExtension(CHAR16 *FileName) {
+ UINTN Length;
+ CHAR16 *Copy = NULL;
+
+ if ((FileName != NULL) && ((Copy = StrDuplicate(FileName)) != NULL)) {
+ Length = StrLen(Copy);
+ // Note: Do StriCmp() twice to work around Gigabyte Hybrid EFI case-sensitivity bug....
+ if ((Length >= 4) && ((StriCmp(&Copy[Length - 4], L".efi") == 0) || (StriCmp(&Copy[Length - 4], L".EFI") == 0))) {
+ Copy[Length - 4] = 0;
+ } // if
+ } // if
+ return Copy;
+} // CHAR16 * StripExtension()
//
// memory string search
UINTN i, StartOfElement = 0, EndOfElement = 0, PathLength, CopyLength;
CHAR16 *Found = NULL;
+ if (Path == NULL)
+ return NULL;
+
PathLength = StrLen(Path);
// Find start & end of target element
for (i = 0; i < PathLength; i++) {
// freeing the returned string's memory.
CHAR16 *FindPath(IN CHAR16* FullPath) {
UINTN i, LastBackslash = 0;
- CHAR16 *PathOnly;
+ CHAR16 *PathOnly = NULL;
- for (i = 0; i < StrLen(FullPath); i++) {
- if (FullPath[i] == '\\')
- LastBackslash = i;
- } // for
- PathOnly = StrDuplicate(FullPath);
- PathOnly[LastBackslash] = 0;
+ if (FullPath != NULL) {
+ for (i = 0; i < StrLen(FullPath); i++) {
+ if (FullPath[i] == '\\')
+ LastBackslash = i;
+ } // for
+ PathOnly = StrDuplicate(FullPath);
+ PathOnly[LastBackslash] = 0;
+ } // if
return (PathOnly);
}
UINTN i, StartOfElement, EndOfElement = 0, InLength, CopyLength;
CHAR16 *Found = NULL;
+ if (InString == NULL)
+ return NULL;
+
InLength = StartOfElement = StrLen(InString);
// Find start & end of target element
for (i = 0; i < InLength; i++) {
// 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) {
+VOID MyFreePool(IN VOID *Pointer) {
if (Pointer != NULL)
FreePool(Pointer);
}