mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-12 09:54:36 +01:00
repair kernel patching
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
449fa1c6d1
commit
4618b74d1a
@ -1329,8 +1329,8 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
|
||||
TmpData = GetDataSetting (Prop2, "Find", &FindLen);
|
||||
TmpPatch = GetDataSetting (Prop2, "Replace", &ReplaceLen);
|
||||
|
||||
if (!FindLen || !ReplaceLen || (FindLen != ReplaceLen)) {
|
||||
//replace len can be smaller if mask using
|
||||
if (!FindLen || !ReplaceLen /*|| (FindLen != ReplaceLen)*/) {
|
||||
DBG (" :: invalid Find/Replace data - skipping!\n");
|
||||
continue;
|
||||
}
|
||||
@ -1348,9 +1348,11 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
CopyMem(Patches->KernelPatches[Patches->NrKexts].MaskFind, TmpData, MaskLen);
|
||||
}
|
||||
FreePool(TmpData);
|
||||
Patches->KernelPatches[Patches->NrKernels].Patch = (__typeof__(Patches->KernelPatches[Patches->NrKernels].Patch))AllocateCopyPool (FindLen, TmpPatch);
|
||||
// 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);
|
||||
FreePool(TmpPatch);
|
||||
TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen);
|
||||
TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen); //reuse MaskLen
|
||||
MaskLen = (MaskLen > FindLen)? FindLen : MaskLen;
|
||||
if (TmpData == NULL || MaskLen == 0) {
|
||||
Patches->KernelPatches[Patches->NrKexts].MaskReplace = NULL;
|
||||
|
@ -1735,6 +1735,8 @@ BOOLEAN
|
||||
KernelUserPatch(IN UINT8 *UKernelData, LOADER_ENTRY *Entry)
|
||||
{
|
||||
INTN Num, i = 0, y = 0;
|
||||
// old confuse
|
||||
|
||||
for (; i < Entry->KernelAndKextPatches->NrKernels; ++i) {
|
||||
DBG_RT(Entry, "Patch[%d]: %a\n", i, Entry->KernelAndKextPatches->KernelPatches[i].Label);
|
||||
if (!Entry->KernelAndKextPatches->KernelPatches[i].MenuItem.BValue) {
|
||||
@ -1862,9 +1864,11 @@ VOID
|
||||
KernelAndKextsPatcherStart(IN LOADER_ENTRY *Entry)
|
||||
{
|
||||
BOOLEAN KextPatchesNeeded, patchedOk;
|
||||
|
||||
// it was intended for custom entries but not work if no suctom entries used
|
||||
// so set common until better solution invented
|
||||
Entry->KernelAndKextPatches = (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches));
|
||||
// we will call KernelAndKextPatcherInit() only if needed
|
||||
if ((Entry == NULL) || (Entry->KernelAndKextPatches == NULL)) return;
|
||||
if ((Entry == NULL) || (Entry->KernelAndKextPatches == NULL)) return; //entry is not null as double check
|
||||
|
||||
KextPatchesNeeded = (
|
||||
Entry->KernelAndKextPatches->KPAppleIntelCPUPM ||
|
||||
@ -1875,12 +1879,14 @@ KernelAndKextsPatcherStart(IN LOADER_ENTRY *Entry)
|
||||
);
|
||||
|
||||
DBG_RT(Entry, "\nKernelToPatch: ");
|
||||
DBG_RT(Entry, "Kernels patches: %d\n", Entry->KernelAndKextPatches->NrKernels);
|
||||
if (gSettings.KernelPatchesAllowed && (Entry->KernelAndKextPatches->KernelPatches != NULL) && Entry->KernelAndKextPatches->NrKernels) {
|
||||
DBG_RT(Entry, "Enabled: ");
|
||||
KernelAndKextPatcherInit(Entry);
|
||||
if (KernelData == NULL) goto NoKernelData;
|
||||
patchedOk = KernelUserPatch(KernelData, Entry);
|
||||
DBG_RT(Entry, patchedOk ? " OK\n" : " FAILED!\n");
|
||||
// gBS->Stall(5000000);
|
||||
} else {
|
||||
DBG_RT(Entry, "Disabled\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user