From ade966e11f95bf55a5f9c1dd90d2407bfc5ec5ca Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Wed, 21 Aug 2024 17:50:51 -0400 Subject: [PATCH] Fix the issue (thanks for bringing it to my attention) --- TeraScaleFixup/kern_start.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/TeraScaleFixup/kern_start.cpp b/TeraScaleFixup/kern_start.cpp index d430eb8..fca60ee 100644 --- a/TeraScaleFixup/kern_start.cpp +++ b/TeraScaleFixup/kern_start.cpp @@ -61,51 +61,60 @@ static void processKext(KernelPatcher &patcher, size_t index, mach_vm_address_t const UInt8 *genericFind; const UInt8 *genericReplace; - + size_t patchSize = 0; + switch (getKernelVersion()) { case KernelVersion::Lion: genericFind = findLion; genericReplace = replaceLion; + patchSize = sizeof(findLion); break; case KernelVersion::MountainLion: genericFind = findMountainLion; genericReplace = replaceMountainLion; + patchSize = sizeof(findMountainLion); break; case KernelVersion::Mavericks: genericFind = findMavericks; genericReplace = replaceMavericks; + patchSize = sizeof(findMavericks); break; case KernelVersion::Yosemite: genericFind = findYosemite; genericReplace = replaceYosemite; + patchSize = sizeof(findYosemite); break; case KernelVersion::ElCapitan: genericFind = findElCapitan; genericReplace = replaceElCapitan; + patchSize = sizeof(findElCapitan); break; case KernelVersion::Sierra: genericFind = findSierra; genericReplace = replaceSierra; + patchSize = sizeof(findSierra); break; case KernelVersion::HighSierra: genericFind = findHighSierra; genericReplace = replaceHighSierra; + patchSize = sizeof(findHighSierra); break; default: // Assume kexts are installed and functional - no harm is done if they are not present. genericFind = findHighSierra; genericReplace = replaceHighSierra; + patchSize = sizeof(findHighSierra); } - + // Apply patch const KernelPatcher::LookupPatch patchGeneric = { &kextList[0], genericFind, genericReplace, - sizeof(genericFind), + patchSize, 1 }; patcher.applyLookupPatch(&patchGeneric); - + if (patcher.getError() != KernelPatcher::Error::NoError) { SYSLOG(MODULE_SHORT, "Failed to apply ATIRadeonX2000 patch"); patcher.clearError();