diff --git a/Include/Acidanthera/Library/OcAppleKernelLib.h b/Include/Acidanthera/Library/OcAppleKernelLib.h index 1c8df7d5..240baf68 100644 --- a/Include/Acidanthera/Library/OcAppleKernelLib.h +++ b/Include/Acidanthera/Library/OcAppleKernelLib.h @@ -326,6 +326,10 @@ typedef struct { // Pointer to KXLD state (read only, it is allocated in PrelinkedStateKexts). // UINT32 KxldStateSize; + // + // Patcher context is contained within a kernel collection. + // + BOOLEAN IsKernelCollection; } PATCHER_CONTEXT; // diff --git a/Library/OcAppleKernelLib/KextPatcher.c b/Library/OcAppleKernelLib/KextPatcher.c index 4855f678..cdca240a 100644 --- a/Library/OcAppleKernelLib/KextPatcher.c +++ b/Library/OcAppleKernelLib/KextPatcher.c @@ -97,10 +97,11 @@ PatcherInitContextFromBuffer ( return EFI_NOT_FOUND; } - Context->VirtualBase = Segment->VirtualAddress - Segment->FileOffset; - Context->VirtualKmod = 0; - Context->KxldState = NULL; - Context->KxldStateSize = 0; + Context->VirtualBase = Segment->VirtualAddress - Segment->FileOffset; + Context->VirtualKmod = 0; + Context->KxldState = NULL; + Context->KxldStateSize = 0; + Context->IsKernelCollection = FALSE; Status = InternalConnectExternalSymtab ( &Context->MachContext, @@ -284,7 +285,9 @@ PatcherBlockKext ( KmodOffset = Context->VirtualKmod - Context->VirtualBase; KmodInfo = (KMOD_INFO_64_V1 *)((UINT8 *) MachoGetMachHeader64 (&Context->MachContext) + KmodOffset); - StartAddr = KcFixupValue (KmodInfo->StartAddr, NULL);; + if (Context->IsKernelCollection) { + StartAddr = KcFixupValue (KmodInfo->StartAddr, NULL); + } if (OcOverflowAddU64 (KmodOffset, sizeof (KMOD_INFO_64_V1), &TmpOffset) || TmpOffset > MachoGetFileSize (&Context->MachContext) diff --git a/Library/OcAppleKernelLib/PrelinkedKext.c b/Library/OcAppleKernelLib/PrelinkedKext.c index 0b5a3f58..208ca027 100644 --- a/Library/OcAppleKernelLib/PrelinkedKext.c +++ b/Library/OcAppleKernelLib/PrelinkedKext.c @@ -221,12 +221,13 @@ InternalCreatePrelinkedKext ( return NULL; } - NewKext->Signature = PRELINKED_KEXT_SIGNATURE; - NewKext->Identifier = KextIdentifier; - NewKext->BundleLibraries = BundleLibraries; - NewKext->CompatibleVersion = CompatibleVersion; - NewKext->Context.VirtualBase = VirtualBase; - NewKext->Context.VirtualKmod = VirtualKmod; + NewKext->Signature = PRELINKED_KEXT_SIGNATURE; + NewKext->Identifier = KextIdentifier; + NewKext->BundleLibraries = BundleLibraries; + NewKext->CompatibleVersion = CompatibleVersion; + NewKext->Context.VirtualBase = VirtualBase; + NewKext->Context.VirtualKmod = VirtualKmod; + NewKext->Context.IsKernelCollection = Prelinked->IsKernelCollection; // // Provide pointer to 10.6.8 KXLD state. @@ -738,12 +739,13 @@ InternalCachedPrelinkedKernel ( return NULL; } - NewKext->Signature = PRELINKED_KEXT_SIGNATURE; - NewKext->Identifier = PRELINK_KERNEL_IDENTIFIER; - NewKext->BundleLibraries = NULL; - NewKext->CompatibleVersion = "0"; - NewKext->Context.VirtualBase = Segment->VirtualAddress - Segment->FileOffset; - NewKext->Context.VirtualKmod = 0; + NewKext->Signature = PRELINKED_KEXT_SIGNATURE; + NewKext->Identifier = PRELINK_KERNEL_IDENTIFIER; + NewKext->BundleLibraries = NULL; + NewKext->CompatibleVersion = "0"; + NewKext->Context.VirtualBase = Segment->VirtualAddress - Segment->FileOffset; + NewKext->Context.VirtualKmod = 0; + NewKext->Context.IsKernelCollection = Prelinked->IsKernelCollection; if (!Prelinked->IsKernelCollection) { //