diff --git a/Changelog.md b/Changelog.md index 26ae4a36a34cb595103386bcf16a55e6d2dece66..89c16f272c94f8218afe13e7cb9ca0e06b019ee5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ OpenCore Changelog - Removed default codec connection delay from AudioDxe - Added optional `--codec-setup-delay` argument to AudioDxe - Changed units of `Audio` -> `SetupDelay` from microseconds to milliseconds (divide previous value by 1000 if using this setting) +- Fixed incorrect FAT binary slice being selected under macOS 10.4.11 when performing a cacheless boot #### v0.8.2 - Fixed `AppleCpuPmCfgLock` on macOS 13 diff --git a/Include/Acidanthera/Library/OcAppleKernelLib.h b/Include/Acidanthera/Library/OcAppleKernelLib.h index 590ef570f07e09f56cc6536a843b4cb94aa45e79..ad4144418d7da5d442ab78f980bb72b20a6f006d 100644 --- a/Include/Acidanthera/Library/OcAppleKernelLib.h +++ b/Include/Acidanthera/Library/OcAppleKernelLib.h @@ -1307,7 +1307,7 @@ CachelessContextAddKext ( IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *InfoPlist, IN UINT32 InfoPlistSize, - IN CONST UINT8 *Executable OPTIONAL, + IN UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, OUT CHAR8 BundleVersion[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] OPTIONAL ); diff --git a/Library/OcAppleKernelLib/CachelessContext.c b/Library/OcAppleKernelLib/CachelessContext.c index 589b4212f0f6c8c13cc2f9f90238264c9bfe040e..6c97e5ece1712baed3c8182178338cdd6e59f964 100644 --- a/Library/OcAppleKernelLib/CachelessContext.c +++ b/Library/OcAppleKernelLib/CachelessContext.c @@ -27,6 +27,7 @@ #include #include "CachelessInternal.h" +#include "MkextInternal.h" #include "PrelinkedInternal.h" STATIC @@ -807,7 +808,7 @@ CachelessContextAddKext ( IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *InfoPlist, IN UINT32 InfoPlistSize, - IN CONST UINT8 *Executable OPTIONAL, + IN UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, OUT CHAR8 BundleVersion[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] OPTIONAL ) @@ -1031,6 +1032,17 @@ CachelessContextAddKext ( // ASSERT (NewKext->BinaryFileName != NULL); + // + // Use only the binary for the current arch. + // Some versions of macOS 10.4 may incorrectly chose the 64-bit slice + // despite 32-bit being the only supported Intel architecture. + // + if (!InternalParseKextBinary (&Executable, &ExecutableSize, Context->Is32Bit)) { + FreePool (NewKext->PlistData); + FreePool (NewKext); + return EFI_INVALID_PARAMETER; + } + NewKext->BinaryData = AllocateCopyPool (ExecutableSize, Executable); if (NewKext->BinaryData == NULL) { if (NewKext->BinaryFileName != NULL) { diff --git a/Library/OcAppleKernelLib/MkextContext.c b/Library/OcAppleKernelLib/MkextContext.c index 6e65473d97283ee497b5b0f2efe5fbd728ab669c..fa6a4ebcd59cc4ef6b60d123962816526b087ec8 100644 --- a/Library/OcAppleKernelLib/MkextContext.c +++ b/Library/OcAppleKernelLib/MkextContext.c @@ -32,9 +32,8 @@ // #define MKEXT_ALIGN(a) (ALIGN_VALUE (a, sizeof (UINT64))) -STATIC BOOLEAN -ParseKextBinary ( +InternalParseKextBinary ( IN OUT UINT8 **Buffer, IN OUT UINT32 *BufferSize, IN BOOLEAN Is32Bit @@ -1363,7 +1362,7 @@ MkextInjectKext ( ASSERT (ExecutableSize > 0); BinOffset = MkextNewSize; - if (!ParseKextBinary (&Executable, &ExecutableSize, Context->Is32Bit)) { + if (!InternalParseKextBinary (&Executable, &ExecutableSize, Context->Is32Bit)) { return EFI_INVALID_PARAMETER; } @@ -1412,7 +1411,7 @@ MkextInjectKext ( ASSERT (ExecutableSize > 0); BinOffset = PlistOffset; - if (!ParseKextBinary (&Executable, &ExecutableSize, Context->Is32Bit)) { + if (!InternalParseKextBinary (&Executable, &ExecutableSize, Context->Is32Bit)) { XmlDocumentFree (PlistXml); FreePool (PlistBuffer); return EFI_INVALID_PARAMETER; diff --git a/Library/OcAppleKernelLib/MkextInternal.h b/Library/OcAppleKernelLib/MkextInternal.h index 1ff4b28fbf6be9b67f77c34b4e32a6f42bac1f33..fb5dd35bdc3fc56f744257c0ffd961909853cae8 100644 --- a/Library/OcAppleKernelLib/MkextInternal.h +++ b/Library/OcAppleKernelLib/MkextInternal.h @@ -68,4 +68,11 @@ InternalCachedMkextKext ( IN CONST CHAR8 *BundleId ); +BOOLEAN +InternalParseKextBinary ( + IN OUT UINT8 **Buffer, + IN OUT UINT32 *BufferSize, + IN BOOLEAN Is32Bit + ); + #endif // MKEXT_INTERNAL_H