From 2f01155383a7a9b37c8b5aea6f69c00c57731e8f Mon Sep 17 00:00:00 2001 From: asava Date: Thu, 19 Mar 2020 22:40:27 +0200 Subject: [PATCH] Correct mask handling mixup between KextPatches/KernelPatches/BootPatches --- rEFIt_UEFI/Platform/Settings.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 1b560ba7f..f9f93fc7e 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -1341,24 +1341,24 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, TmpData = GetDataSetting (Prop2, "MaskFind", &MaskLen); MaskLen = (MaskLen > FindLen)? FindLen : MaskLen; if (TmpData == NULL || MaskLen == 0) { - Patches->KernelPatches[Patches->NrKexts].MaskFind = NULL; + Patches->KernelPatches[Patches->NrKernels].MaskFind = NULL; } else { - Patches->KernelPatches[Patches->NrKexts].MaskFind = (__typeof__(Patches->KernelPatches[Patches->NrKexts].MaskFind))AllocatePool (FindLen); - SetMem(Patches->KernelPatches[Patches->NrKexts].MaskFind, FindLen, 0xFF); - CopyMem(Patches->KernelPatches[Patches->NrKexts].MaskFind, TmpData, MaskLen); + Patches->KernelPatches[Patches->NrKernels].MaskFind = (__typeof__(Patches->KernelPatches[Patches->NrKernels].MaskFind))AllocatePool (FindLen); + SetMem(Patches->KernelPatches[Patches->NrKernels].MaskFind, FindLen, 0xFF); + CopyMem(Patches->KernelPatches[Patches->NrKernels].MaskFind, TmpData, MaskLen); } FreePool(TmpData); // this is "Replace" string len of ReplaceLen Patches->KernelPatches[Patches->NrKernels].Patch = (__typeof__(Patches->KernelPatches[Patches->NrKernels].Patch))AllocateZeroPool(FindLen); - CopyMem(Patches->KernelPatches[Patches->NrKexts].Patch, TmpPatch, ReplaceLen); + CopyMem(Patches->KernelPatches[Patches->NrKernels].Patch, TmpPatch, ReplaceLen); FreePool(TmpPatch); TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen); //reuse MaskLen MaskLen = (MaskLen > FindLen)? FindLen : MaskLen; if (TmpData == NULL || MaskLen == 0) { - Patches->KernelPatches[Patches->NrKexts].MaskReplace = NULL; + Patches->KernelPatches[Patches->NrKernels].MaskReplace = NULL; } else { - Patches->KernelPatches[Patches->NrKexts].MaskReplace = (__typeof__(Patches->KernelPatches[Patches->NrKexts].MaskReplace))AllocateZeroPool (FindLen); - CopyMem(Patches->KernelPatches[Patches->NrKexts].MaskReplace, TmpData, MaskLen); + Patches->KernelPatches[Patches->NrKernels].MaskReplace = (__typeof__(Patches->KernelPatches[Patches->NrKernels].MaskReplace))AllocateZeroPool (FindLen); + CopyMem(Patches->KernelPatches[Patches->NrKernels].MaskReplace, TmpData, MaskLen); } FreePool(TmpData); Patches->KernelPatches[Patches->NrKernels].Count = 0; @@ -1468,11 +1468,11 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, TmpData = GetDataSetting (Prop2, "MaskFind", &MaskLen); MaskLen = (MaskLen > FindLen)? FindLen : MaskLen; if (TmpData == NULL || MaskLen == 0) { - Patches->BootPatches[Patches->NrKexts].MaskFind = NULL; + Patches->BootPatches[Patches->NrBoots].MaskFind = NULL; } else { - Patches->BootPatches[Patches->NrKexts].MaskFind = (__typeof__(Patches->BootPatches[Patches->NrKexts].MaskFind))AllocatePool (FindLen); - SetMem(Patches->BootPatches[Patches->NrKexts].MaskFind, FindLen, 0xFF); - CopyMem(Patches->BootPatches[Patches->NrKexts].MaskFind, TmpData, MaskLen); + Patches->BootPatches[Patches->NrBoots].MaskFind = (__typeof__(Patches->BootPatches[Patches->NrBoots].MaskFind))AllocatePool (FindLen); + SetMem(Patches->BootPatches[Patches->NrBoots].MaskFind, FindLen, 0xFF); + CopyMem(Patches->BootPatches[Patches->NrBoots].MaskFind, TmpData, MaskLen); } FreePool(TmpData); Patches->BootPatches[Patches->NrBoots].Patch = (__typeof__(Patches->BootPatches[Patches->NrBoots].Patch))AllocateCopyPool (FindLen, TmpPatch); @@ -1480,10 +1480,10 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen); MaskLen = (MaskLen > FindLen)? FindLen : MaskLen; if (TmpData == NULL || MaskLen == 0) { - Patches->BootPatches[Patches->NrKexts].MaskReplace = NULL; + Patches->BootPatches[Patches->NrBoots].MaskReplace = NULL; } else { - Patches->BootPatches[Patches->NrKexts].MaskReplace = (__typeof__(Patches->BootPatches[Patches->NrKexts].MaskReplace))AllocateZeroPool (FindLen); - CopyMem(Patches->BootPatches[Patches->NrKexts].MaskReplace, TmpData, MaskLen); + Patches->BootPatches[Patches->NrBoots].MaskReplace = (__typeof__(Patches->BootPatches[Patches->NrBoots].MaskReplace))AllocateZeroPool (FindLen); + CopyMem(Patches->BootPatches[Patches->NrBoots].MaskReplace, TmpData, MaskLen); } FreePool(TmpData); Patches->BootPatches[Patches->NrBoots].Count = 0;