diff --git a/rEFIt_UEFI/Platform/Platform.h b/rEFIt_UEFI/Platform/Platform.h
index d4a0fb73..7c1e7000 100644
--- a/rEFIt_UEFI/Platform/Platform.h
+++ b/rEFIt_UEFI/Platform/Platform.h
@@ -998,6 +998,9 @@ typedef struct {
UINT8 pad7[2];
UINT8 CustomBoot;
EG_IMAGE *CustomLogo;
+
+ //SpoofOSXVersion
+ CHAR16 *SpoofOSXVersion;
UINT32 RefCLK;
diff --git a/rEFIt_UEFI/Platform/Settings.c b/rEFIt_UEFI/Platform/Settings.c
index c6f6e15e..5a45aaa6 100644
--- a/rEFIt_UEFI/Platform/Settings.c
+++ b/rEFIt_UEFI/Platform/Settings.c
@@ -2027,6 +2027,13 @@ GetEarlyUserSettings (
}
DBG ("Custom boot %s (0x%X)\n", CustomBootModeToStr (gSettings.CustomBoot), gSettings.CustomLogo);
+
+ // Spoof OSX Version
+ Prop = GetProperty (DictPointer, "SpoofOSXVersion");
+ if (Prop != NULL) {
+ gSettings.SpoofOSXVersion = AllocateZeroPool (AsciiStrSize (Prop->string) * sizeof(CHAR16));
+ AsciiStrToUnicodeStr (Prop->string, gSettings.SpoofOSXVersion);
+ }
}
//*** SYSTEM ***
diff --git a/rEFIt_UEFI/Platform/apple.c b/rEFIt_UEFI/Platform/apple.c
new file mode 100644
index 00000000..4b06c167
--- /dev/null
+++ b/rEFIt_UEFI/Platform/apple.c
@@ -0,0 +1,83 @@
+/*
+ * refind/apple.c
+ * Functions specific to Apple computers
+ *
+ * Copyright (c) 2015 Roderick W. Smith
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "entry_scan.h"
+#include "lib.h"
+#include "apple.h"
+
+/*
+ * 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, \
+ { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 } \
+ }
+
+typedef struct EfiAppleSetOsInterface {
+ UINT64 Version;
+ EFI_STATUS EFIAPI (*SetOsVersion) (IN CHAR8 *Version);
+ EFI_STATUS EFIAPI (*SetOsVendor) (IN CHAR8 *Vendor);
+} EfiAppleSetOsInterface;
+
+// Function to tell the firmware that OS X is being launched. This is
+// required to work around problems on some Macs that don't fully
+// initialize some hardware (especially video displays) when third-party
+// OSes are launched in EFI mode.
+EFI_STATUS SetAppleOSInfo() {
+ CHAR16 *AppleOSVersion = NULL;
+ CHAR8 *AppleOSVersion8 = NULL;
+ EFI_STATUS Status;
+ EFI_GUID apple_set_os_guid = EFI_APPLE_SET_OS_PROTOCOL_GUID;
+ EfiAppleSetOsInterface *SetOs = NULL;
+
+ Status = gBS->LocateProtocol (&apple_set_os_guid, NULL, (VOID**) &SetOs);
+
+ // If not a Mac, ignore the call....
+ if ((Status != EFI_SUCCESS) || (!SetOs))
+ return EFI_SUCCESS;
+
+ if ((SetOs->Version != 0) && gSettings.SpoofOSXVersion) {
+ AppleOSVersion = PoolPrint (L"Mac OS X %s", gSettings.SpoofOSXVersion);
+ if (AppleOSVersion) {
+ AppleOSVersion8 = AllocateZeroPool((StrLen(AppleOSVersion) + 1) * sizeof(CHAR8));
+ UnicodeStrToAsciiStr(AppleOSVersion, AppleOSVersion8);
+ if (AppleOSVersion8) {
+ Status = SetOs->SetOsVersion (AppleOSVersion8);
+ if (!EFI_ERROR(Status))
+ Status = EFI_SUCCESS;
+ FreePool(AppleOSVersion8);
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ Print(L"Out of resources in SetAppleOSInfo!\n");
+ }
+ if ((Status == EFI_SUCCESS) && (SetOs->Version >= 2))
+ Status = SetOs->SetOsVendor ((CHAR8 *) "Apple Inc.");
+ FreePool(AppleOSVersion);
+ } // if (AppleOSVersion)
+ } // if
+ if (Status != EFI_SUCCESS)
+ Print(L"Unable to set firmware boot type!\n");
+
+ return (Status);
+} // EFI_STATUS SetAppleOSInfo()
diff --git a/rEFIt_UEFI/Platform/apple.h b/rEFIt_UEFI/Platform/apple.h
new file mode 100644
index 00000000..304cbf80
--- /dev/null
+++ b/rEFIt_UEFI/Platform/apple.h
@@ -0,0 +1,26 @@
+/*
+ * refind/apple.h
+ *
+ * Copyright (c) 2015 Roderick W. Smith
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#ifndef __APPLE_H_
+#define __APPLE_H_
+
+EFI_STATUS SetAppleOSInfo();
+
+#endif
\ No newline at end of file
diff --git a/rEFIt_UEFI/refit.inf b/rEFIt_UEFI/refit.inf
index ee8f3d9f..dbae9027 100644
--- a/rEFIt_UEFI/refit.inf
+++ b/rEFIt_UEFI/refit.inf
@@ -123,6 +123,7 @@
Platform/PlatformDriverOverride.c
Platform/Hibernate.c
Platform/Net.c
+ Platform/apple.c
[Packages]
Clover/CloverPkg.dec
diff --git a/rEFIt_UEFI/refit/main.c b/rEFIt_UEFI/refit/main.c
index 2876cdb2..617ec1b6 100644
--- a/rEFIt_UEFI/refit/main.c
+++ b/rEFIt_UEFI/refit/main.c
@@ -35,9 +35,9 @@
*/
#include "entry_scan.h"
+#include "apple.h"
//#include "Platform.h"
//#include "../include/Handle.h"
-
#include "Version.h"
#ifndef DEBUG_ALL
@@ -1981,6 +1981,11 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
}
+ // spoof OSX version if needed
+ if (gSettings.SpoofOSXVersion && gSettings.SpoofOSXVersion[0] != L'\0') {
+ SetAppleOSInfo();
+ }
+
#ifdef ENABLE_SECURE_BOOT
// Install secure boot shim
if (EFI_ERROR(Status = InstallSecureBoot())) {