From: srs5694 Date: Sat, 31 Oct 2015 00:34:30 +0000 (-0400) Subject: Further tweaks to spoof_osx_version feature. X-Git-Url: https://code.delx.au/refind/commitdiff_plain/5a00f7538d94898a32e2714c7b0a06d6efede8c4 Further tweaks to spoof_osx_version feature. --- diff --git a/refind/main.c b/refind/main.c index ebbb9e2..4d201bf 100644 --- a/refind/main.c +++ b/refind/main.c @@ -2144,6 +2144,11 @@ static VOID SetConfigFilename(EFI_HANDLE ImageHandle) { } // if } // VOID SetConfigFilename() +/* + * The below definitions and SetAppleOSInfo() function are based on a GRUB patch + * by Andreas Heider: + * https://lists.gnu.org/archive/html/grub-devel/2013-12/msg00442.html + */ #define EFI_APPLE_SET_OS_PROTOCOL_GUID \ { 0xc5c5da95, 0x7d5c, 0x45e6, \ @@ -2176,25 +2181,26 @@ static EFI_STATUS SetAppleOSInfo() { if ((SetOs->Version != 0) && GlobalConfig.SpoofOSXVersion) { AppleOSVersion = StrDuplicate(L"Mac OS X"); MergeStrings(&AppleOSVersion, GlobalConfig.SpoofOSXVersion, ' '); - AppleOSVersion8 = AllocateZeroPool((StrLen(AppleOSVersion) + 1) * sizeof(CHAR8)); - UnicodeStrToAsciiStr(AppleOSVersion, AppleOSVersion8); - if (AppleOSVersion8) { - Status = refit_call1_wrapper (SetOs->SetOsVersion, AppleOSVersion8); - if (!EFI_ERROR(Status)) - Status = EFI_SUCCESS; - } else { - Status = EFI_OUT_OF_RESOURCES; - Print(L"Out of resources!\n"); - } - if ((Status == EFI_SUCCESS) && (SetOs->Version == 2)) - Status = refit_call1_wrapper (SetOs->SetOsVendor, "Apple Inc."); + if (AppleOSVersion) { + AppleOSVersion8 = AllocateZeroPool((StrLen(AppleOSVersion) + 1) * sizeof(CHAR8)); + UnicodeStrToAsciiStr(AppleOSVersion, AppleOSVersion8); + if (AppleOSVersion8) { + Status = refit_call1_wrapper (SetOs->SetOsVersion, AppleOSVersion8); + if (!EFI_ERROR(Status)) + Status = EFI_SUCCESS; + MyFreePool(AppleOSVersion8); + } else { + Status = EFI_OUT_OF_RESOURCES; + Print(L"Out of resources in SetAppleOSInfo!\n"); + } + if ((Status == EFI_SUCCESS) && (SetOs->Version == 2)) + Status = refit_call1_wrapper (SetOs->SetOsVendor, "Apple Inc."); + MyFreePool(AppleOSVersion); + } // if (AppleOSVersion) } // if - if (Status != EFI_SUCCESS) Print(L"Unable to set firmware boot type!\n"); - MyFreePool(AppleOSVersion); - MyFreePool(AppleOSVersion8); return (Status); } // EFI_STATUS SetAppleOSInfo()