From 7a460d57c5bdd3b112392f570051aefd431f4458 Mon Sep 17 00:00:00 2001 From: PMheart <17109513+PMheart@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:39:57 +0200 Subject: [PATCH] ocvalidate: Drop useless pointer access --- Utilities/ocvalidate/ValidateAcpi.c | 44 +++--- Utilities/ocvalidate/ValidateBooter.c | 66 ++++---- .../ocvalidate/ValidateDeviceProperties.c | 36 ++--- Utilities/ocvalidate/ValidateKernel.c | 146 ++++++++---------- Utilities/ocvalidate/ValidateMisc.c | 104 ++++++------- Utilities/ocvalidate/ValidateNvram.c | 58 ++++--- Utilities/ocvalidate/ValidatePlatformInfo.c | 16 +- Utilities/ocvalidate/ValidateUefi.c | 112 ++++++-------- 8 files changed, 250 insertions(+), 332 deletions(-) diff --git a/Utilities/ocvalidate/ValidateAcpi.c b/Utilities/ocvalidate/ValidateAcpi.c index 3f55916e..86f89ffc 100644 --- a/Utilities/ocvalidate/ValidateAcpi.c +++ b/Utilities/ocvalidate/ValidateAcpi.c @@ -56,17 +56,15 @@ CheckACPIAdd ( { UINT32 ErrorCount; UINT32 Index; - OC_ACPI_CONFIG *UserAcpi; CONST CHAR8 *Path; CONST CHAR8 *Comment; UINTN AcpiAddSumSize; ErrorCount = 0; - UserAcpi = &Config->Acpi; - for (Index = 0; Index < UserAcpi->Add.Count; ++Index) { - Path = OC_BLOB_GET (&UserAcpi->Add.Values[Index]->Path); - Comment = OC_BLOB_GET (&UserAcpi->Add.Values[Index]->Comment); + for (Index = 0; Index < Config->Acpi.Add.Count; ++Index) { + Path = OC_BLOB_GET (&Config->Acpi.Add.Values[Index]->Path); + Comment = OC_BLOB_GET (&Config->Acpi.Add.Values[Index]->Comment); // // Sanitise strings. @@ -106,9 +104,9 @@ CheckACPIAdd ( // Check duplicated entries in ACPI->Add. // ErrorCount += FindArrayDuplication ( - UserAcpi->Add.Values, - UserAcpi->Add.Count, - sizeof (UserAcpi->Add.Values[0]), + Config->Acpi.Add.Values, + Config->Acpi.Add.Count, + sizeof (Config->Acpi.Add.Values[0]), ACPIAddHasDuplication ); @@ -123,14 +121,12 @@ CheckACPIDelete ( { UINT32 ErrorCount; UINT32 Index; - OC_ACPI_CONFIG *UserAcpi; CONST CHAR8 *Comment; ErrorCount = 0; - UserAcpi = &Config->Acpi; - for (Index = 0; Index < UserAcpi->Delete.Count; ++Index) { - Comment = OC_BLOB_GET (&UserAcpi->Delete.Values[Index]->Comment); + for (Index = 0; Index < Config->Acpi.Delete.Count; ++Index) { + Comment = OC_BLOB_GET (&Config->Acpi.Delete.Values[Index]->Comment); // // Sanitise strings. @@ -157,7 +153,6 @@ CheckACPIPatch ( { UINT32 ErrorCount; UINT32 Index; - OC_ACPI_CONFIG *UserAcpi; CONST CHAR8 *Comment; CONST UINT8 *Find; UINT32 FindSize; @@ -169,18 +164,17 @@ CheckACPIPatch ( UINT32 ReplaceMaskSize; ErrorCount = 0; - UserAcpi = &Config->Acpi; - - for (Index = 0; Index < UserAcpi->Patch.Count; ++Index) { - Comment = OC_BLOB_GET (&UserAcpi->Patch.Values[Index]->Comment); - Find = OC_BLOB_GET (&UserAcpi->Patch.Values[Index]->Find); - FindSize = UserAcpi->Patch.Values[Index]->Find.Size; - Replace = OC_BLOB_GET (&UserAcpi->Patch.Values[Index]->Replace); - ReplaceSize = UserAcpi->Patch.Values[Index]->Replace.Size; - Mask = OC_BLOB_GET (&UserAcpi->Patch.Values[Index]->Mask); - MaskSize = UserAcpi->Patch.Values[Index]->Mask.Size; - ReplaceMask = OC_BLOB_GET (&UserAcpi->Patch.Values[Index]->ReplaceMask); - ReplaceMaskSize = UserAcpi->Patch.Values[Index]->ReplaceMask.Size; + + for (Index = 0; Index < Config->Acpi.Patch.Count; ++Index) { + Comment = OC_BLOB_GET (&Config->Acpi.Patch.Values[Index]->Comment); + Find = OC_BLOB_GET (&Config->Acpi.Patch.Values[Index]->Find); + FindSize = Config->Acpi.Patch.Values[Index]->Find.Size; + Replace = OC_BLOB_GET (&Config->Acpi.Patch.Values[Index]->Replace); + ReplaceSize = Config->Acpi.Patch.Values[Index]->Replace.Size; + Mask = OC_BLOB_GET (&Config->Acpi.Patch.Values[Index]->Mask); + MaskSize = Config->Acpi.Patch.Values[Index]->Mask.Size; + ReplaceMask = OC_BLOB_GET (&Config->Acpi.Patch.Values[Index]->ReplaceMask); + ReplaceMaskSize = Config->Acpi.Patch.Values[Index]->ReplaceMask.Size; // // Sanitise strings. diff --git a/Utilities/ocvalidate/ValidateBooter.c b/Utilities/ocvalidate/ValidateBooter.c index 232c8ed6..db1a75e9 100644 --- a/Utilities/ocvalidate/ValidateBooter.c +++ b/Utilities/ocvalidate/ValidateBooter.c @@ -24,21 +24,19 @@ CheckBooterMmioWhitelist ( { UINT32 ErrorCount; UINT32 Index; - OC_BOOTER_CONFIG *UserBooter; CONST CHAR8 *Comment; BOOLEAN IsMmioWhitelistEnabled; BOOLEAN ShouldEnableDevirtualiseMmio; BOOLEAN IsDevirtualiseMmioEnabled; ErrorCount = 0; - UserBooter = &Config->Booter; - IsDevirtualiseMmioEnabled = UserBooter->Quirks.DevirtualiseMmio; + IsDevirtualiseMmioEnabled = Config->Booter.Quirks.DevirtualiseMmio; IsMmioWhitelistEnabled = FALSE; ShouldEnableDevirtualiseMmio = FALSE; - for (Index = 0; Index < UserBooter->MmioWhitelist.Count; ++Index) { - Comment = OC_BLOB_GET (&UserBooter->MmioWhitelist.Values[Index]->Comment); - IsMmioWhitelistEnabled = UserBooter->MmioWhitelist.Values[Index]->Enabled; + for (Index = 0; Index < Config->Booter.MmioWhitelist.Count; ++Index) { + Comment = OC_BLOB_GET (&Config->Booter.MmioWhitelist.Values[Index]->Comment); + IsMmioWhitelistEnabled = Config->Booter.MmioWhitelist.Values[Index]->Enabled; // // DevirtualiseMmio should be enabled if at least one entry is enabled. // @@ -68,7 +66,6 @@ CheckBooterPatch ( { UINT32 ErrorCount; UINT32 Index; - OC_BOOTER_CONFIG *UserBooter; CONST CHAR8 *Comment; CONST CHAR8 *Arch; CONST CHAR8 *Identifier; @@ -82,20 +79,19 @@ CheckBooterPatch ( UINT32 ReplaceMaskSize; ErrorCount = 0; - UserBooter = &Config->Booter; - - for (Index = 0; Index < UserBooter->Patch.Count; ++Index) { - Comment = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->Comment); - Arch = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->Arch); - Identifier = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->Identifier); - Find = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->Find); - FindSize = UserBooter->Patch.Values[Index]->Find.Size; - Replace = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->Replace); - ReplaceSize = UserBooter->Patch.Values[Index]->Replace.Size; - Mask = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->Mask); - MaskSize = UserBooter->Patch.Values[Index]->Mask.Size; - ReplaceMask = OC_BLOB_GET (&UserBooter->Patch.Values[Index]->ReplaceMask); - ReplaceMaskSize = UserBooter->Patch.Values[Index]->ReplaceMask.Size; + + for (Index = 0; Index < Config->Booter.Patch.Count; ++Index) { + Comment = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Comment); + Arch = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Arch); + Identifier = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Identifier); + Find = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Find); + FindSize = Config->Booter.Patch.Values[Index]->Find.Size; + Replace = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Replace); + ReplaceSize = Config->Booter.Patch.Values[Index]->Replace.Size; + Mask = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Mask); + MaskSize = Config->Booter.Patch.Values[Index]->Mask.Size; + ReplaceMask = OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->ReplaceMask); + ReplaceMaskSize = Config->Booter.Patch.Values[Index]->ReplaceMask.Size; // // Sanitise strings. @@ -142,8 +138,6 @@ CheckBooterQuirks ( { UINT32 ErrorCount; UINT32 Index; - OC_BOOTER_CONFIG *UserBooter; - OC_UEFI_CONFIG *UserUefi; OC_UEFI_DRIVER_ENTRY *DriverEntry; CONST CHAR8 *Driver; UINT8 MaxSlide; @@ -156,19 +150,17 @@ CheckBooterQuirks ( INT8 ResizeAppleGpuBars; ErrorCount = 0; - UserBooter = &Config->Booter; - UserUefi = &Config->Uefi; - IsAllowRelocationBlockEnabled = UserBooter->Quirks.AllowRelocationBlock; - IsProvideCustomSlideEnabled = UserBooter->Quirks.ProvideCustomSlide; - IsEnableSafeModeSlideEnabled = UserBooter->Quirks.EnableSafeModeSlide; - IsDisableVariableWriteEnabled = UserBooter->Quirks.DisableVariableWrite; - IsEnableWriteUnprotectorEnabled = UserBooter->Quirks.EnableWriteUnprotector; + IsAllowRelocationBlockEnabled = Config->Booter.Quirks.AllowRelocationBlock; + IsProvideCustomSlideEnabled = Config->Booter.Quirks.ProvideCustomSlide; + IsEnableSafeModeSlideEnabled = Config->Booter.Quirks.EnableSafeModeSlide; + IsDisableVariableWriteEnabled = Config->Booter.Quirks.DisableVariableWrite; + IsEnableWriteUnprotectorEnabled = Config->Booter.Quirks.EnableWriteUnprotector; HasOpenRuntimeEfiDriver = FALSE; - MaxSlide = UserBooter->Quirks.ProvideMaxSlide; - ResizeAppleGpuBars = UserBooter->Quirks.ResizeAppleGpuBars; + MaxSlide = Config->Booter.Quirks.ProvideMaxSlide; + ResizeAppleGpuBars = Config->Booter.Quirks.ResizeAppleGpuBars; - for (Index = 0; Index < UserUefi->Drivers.Count; ++Index) { - DriverEntry = UserUefi->Drivers.Values[Index]; + for (Index = 0; Index < Config->Uefi.Drivers.Count; ++Index) { + DriverEntry = Config->Uefi.Drivers.Values[Index]; Driver = OC_BLOB_GET (&DriverEntry->Path); // @@ -211,13 +203,13 @@ CheckBooterQuirks ( } if (ResizeAppleGpuBars > 10) { - DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unsupported by macOS!\n", UserBooter->Quirks.ResizeAppleGpuBars)); + DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unsupported by macOS!\n", Config->Booter.Quirks.ResizeAppleGpuBars)); ++ErrorCount; } else if (ResizeAppleGpuBars > 8) { - DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unstable with macOS sleep-wake!\n", UserBooter->Quirks.ResizeAppleGpuBars)); + DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unstable with macOS sleep-wake!\n", Config->Booter.Quirks.ResizeAppleGpuBars)); ++ErrorCount; } else if (ResizeAppleGpuBars > 0) { - DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is not useful for macOS!\n", UserBooter->Quirks.ResizeAppleGpuBars)); + DEBUG ((DEBUG_WARN, "Booter->Quirks->ResizeAppleGpuBars is set to %d, which is not useful for macOS!\n", Config->Booter.Quirks.ResizeAppleGpuBars)); ++ErrorCount; } diff --git a/Utilities/ocvalidate/ValidateDeviceProperties.c b/Utilities/ocvalidate/ValidateDeviceProperties.c index 47bf9387..816995e4 100644 --- a/Utilities/ocvalidate/ValidateDeviceProperties.c +++ b/Utilities/ocvalidate/ValidateDeviceProperties.c @@ -81,23 +81,21 @@ CheckDevicePropertiesAdd ( UINT32 ErrorCount; UINT32 DeviceIndex; UINT32 PropertyIndex; - OC_DEV_PROP_CONFIG *UserDevProp; CONST CHAR8 *AsciiDevicePath; CONST CHAR8 *AsciiProperty; OC_ASSOC *PropertyMap; ErrorCount = 0; - UserDevProp = &Config->DeviceProperties; - for (DeviceIndex = 0; DeviceIndex < UserDevProp->Add.Count; ++DeviceIndex) { - AsciiDevicePath = OC_BLOB_GET (UserDevProp->Add.Keys[DeviceIndex]); + for (DeviceIndex = 0; DeviceIndex < Config->DeviceProperties.Add.Count; ++DeviceIndex) { + AsciiDevicePath = OC_BLOB_GET (Config->DeviceProperties.Add.Keys[DeviceIndex]); if (!AsciiDevicePathIsLegal (AsciiDevicePath)) { DEBUG ((DEBUG_WARN, "DeviceProperties->Add[%u]->DevicePath is borked! Please check the information above!\n", DeviceIndex)); ++ErrorCount; } - PropertyMap = UserDevProp->Add.Values[DeviceIndex]; + PropertyMap = Config->DeviceProperties.Add.Values[DeviceIndex]; for (PropertyIndex = 0; PropertyIndex < PropertyMap->Count; ++PropertyIndex) { AsciiProperty = OC_BLOB_GET (PropertyMap->Keys[PropertyIndex]); @@ -130,9 +128,9 @@ CheckDevicePropertiesAdd ( // Check duplicated entries in DeviceProperties->Add. // ErrorCount += FindArrayDuplication ( - UserDevProp->Add.Keys, - UserDevProp->Add.Count, - sizeof (UserDevProp->Add.Keys[0]), + Config->DeviceProperties.Add.Keys, + Config->DeviceProperties.Add.Count, + sizeof (Config->DeviceProperties.Add.Keys[0]), DevPropsAddHasDuplication ); @@ -148,23 +146,21 @@ CheckDevicePropertiesDelete ( UINT32 ErrorCount; UINT32 DeviceIndex; UINT32 PropertyIndex; - OC_DEV_PROP_CONFIG *UserDevProp; CONST CHAR8 *AsciiDevicePath; CONST CHAR8 *AsciiProperty; ErrorCount = 0; - UserDevProp = &Config->DeviceProperties; - for (DeviceIndex = 0; DeviceIndex < UserDevProp->Delete.Count; ++DeviceIndex) { - AsciiDevicePath = OC_BLOB_GET (UserDevProp->Delete.Keys[DeviceIndex]); + for (DeviceIndex = 0; DeviceIndex < Config->DeviceProperties.Delete.Count; ++DeviceIndex) { + AsciiDevicePath = OC_BLOB_GET (Config->DeviceProperties.Delete.Keys[DeviceIndex]); if (!AsciiDevicePathIsLegal (AsciiDevicePath)) { DEBUG ((DEBUG_WARN, "DeviceProperties->Delete[%u]->DevicePath is borked! Please check the information above!\n", DeviceIndex)); ++ErrorCount; } - for (PropertyIndex = 0; PropertyIndex < UserDevProp->Delete.Values[DeviceIndex]->Count; ++PropertyIndex) { - AsciiProperty = OC_BLOB_GET (UserDevProp->Delete.Values[DeviceIndex]->Values[PropertyIndex]); + for (PropertyIndex = 0; PropertyIndex < Config->DeviceProperties.Delete.Values[DeviceIndex]->Count; ++PropertyIndex) { + AsciiProperty = OC_BLOB_GET (Config->DeviceProperties.Delete.Values[DeviceIndex]->Values[PropertyIndex]); // // Sanitise strings. @@ -184,9 +180,9 @@ CheckDevicePropertiesDelete ( // Check duplicated properties in DeviceProperties->Delete[N]. // ErrorCount += FindArrayDuplication ( - UserDevProp->Delete.Values[DeviceIndex]->Values, - UserDevProp->Delete.Values[DeviceIndex]->Count, - sizeof (UserDevProp->Delete.Values[DeviceIndex]->Values[0]), + Config->DeviceProperties.Delete.Values[DeviceIndex]->Values, + Config->DeviceProperties.Delete.Values[DeviceIndex]->Count, + sizeof (Config->DeviceProperties.Delete.Values[DeviceIndex]->Values[0]), DevPropsDeleteHasDuplication ); } @@ -195,9 +191,9 @@ CheckDevicePropertiesDelete ( // Check duplicated entries in DeviceProperties->Delete. // ErrorCount += FindArrayDuplication ( - UserDevProp->Delete.Keys, - UserDevProp->Delete.Count, - sizeof (UserDevProp->Delete.Keys[0]), + Config->DeviceProperties.Delete.Keys, + Config->DeviceProperties.Delete.Count, + sizeof (Config->DeviceProperties.Delete.Keys[0]), DevPropsDeleteHasDuplication ); diff --git a/Utilities/ocvalidate/ValidateKernel.c b/Utilities/ocvalidate/ValidateKernel.c index 76f5dd05..96c3330b 100644 --- a/Utilities/ocvalidate/ValidateKernel.c +++ b/Utilities/ocvalidate/ValidateKernel.c @@ -126,7 +126,6 @@ CheckKernelAdd ( { UINT32 ErrorCount; UINT32 Index; - OC_KERNEL_CONFIG *UserKernel; CONST CHAR8 *Arch; CONST CHAR8 *BundlePath; UINTN BundlePathSumSize; @@ -149,16 +148,15 @@ CheckKernelAdd ( CONST CHAR8 *ChildKext; ErrorCount = 0; - UserKernel = &Config->Kernel; - for (Index = 0; Index < UserKernel->Add.Count; ++Index) { - Arch = OC_BLOB_GET (&UserKernel->Add.Values[Index]->Arch); - BundlePath = OC_BLOB_GET (&UserKernel->Add.Values[Index]->BundlePath); - Comment = OC_BLOB_GET (&UserKernel->Add.Values[Index]->Comment); - ExecutablePath = OC_BLOB_GET (&UserKernel->Add.Values[Index]->ExecutablePath); - MaxKernel = OC_BLOB_GET (&UserKernel->Add.Values[Index]->MaxKernel); - MinKernel = OC_BLOB_GET (&UserKernel->Add.Values[Index]->MinKernel); - PlistPath = OC_BLOB_GET (&UserKernel->Add.Values[Index]->PlistPath); + for (Index = 0; Index < Config->Kernel.Add.Count; ++Index) { + Arch = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->Arch); + BundlePath = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->BundlePath); + Comment = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->Comment); + ExecutablePath = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->ExecutablePath); + MaxKernel = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->MaxKernel); + MinKernel = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->MinKernel); + PlistPath = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->PlistPath); // // Sanitise strings. @@ -277,8 +275,8 @@ CheckKernelAdd ( // Special check for Lilu and Quirks->DisableLinkeditJettison. // if (IndexKextInfo == INDEX_KEXT_LILU) { - IsLiluUsed = UserKernel->Add.Values[Index]->Enabled; - IsDisableLinkeditJettisonEnabled = UserKernel->Quirks.DisableLinkeditJettison; + IsLiluUsed = Config->Kernel.Add.Values[Index]->Enabled; + IsDisableLinkeditJettisonEnabled = Config->Kernel.Quirks.DisableLinkeditJettison; if (IsLiluUsed && !IsDisableLinkeditJettisonEnabled) { DEBUG ((DEBUG_WARN, "Lilu.kext is loaded at Kernel->Add[%u], but DisableLinkeditJettison is not enabled at Kernel->Quirks!\n", Index)); ++ErrorCount; @@ -305,8 +303,8 @@ CheckKernelAdd ( for (IndexKextPrecedence = 0; IndexKextPrecedence < mKextPrecedenceSize; ++IndexKextPrecedence) { HasParent = FALSE; - for (Index = 0; Index < UserKernel->Add.Count; ++Index) { - CurrentKext = OC_BLOB_GET (&UserKernel->Add.Values[Index]->BundlePath); + for (Index = 0; Index < Config->Kernel.Add.Count; ++Index) { + CurrentKext = OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->BundlePath); ParentKext = mKextPrecedence[IndexKextPrecedence].Parent; ChildKext = mKextPrecedence[IndexKextPrecedence].Child; @@ -329,9 +327,9 @@ CheckKernelAdd ( // Check duplicated entries in Kernel->Add. // ErrorCount += FindArrayDuplication ( - UserKernel->Add.Values, - UserKernel->Add.Count, - sizeof (UserKernel->Add.Values[0]), + Config->Kernel.Add.Values, + Config->Kernel.Add.Count, + sizeof (Config->Kernel.Add.Values[0]), KernelAddHasDuplication ); @@ -346,7 +344,6 @@ CheckKernelBlock ( { UINT32 ErrorCount; UINT32 Index; - OC_KERNEL_CONFIG *UserKernel; CONST CHAR8 *Arch; CONST CHAR8 *Comment; CONST CHAR8 *MaxKernel; @@ -355,15 +352,14 @@ CheckKernelBlock ( CONST CHAR8 *Strategy; ErrorCount = 0; - UserKernel = &Config->Kernel; - - for (Index = 0; Index < UserKernel->Block.Count; ++Index) { - Arch = OC_BLOB_GET (&UserKernel->Block.Values[Index]->Arch); - Comment = OC_BLOB_GET (&UserKernel->Block.Values[Index]->Comment); - Identifier = OC_BLOB_GET (&UserKernel->Block.Values[Index]->Identifier); - MaxKernel = OC_BLOB_GET (&UserKernel->Block.Values[Index]->MaxKernel); - MinKernel = OC_BLOB_GET (&UserKernel->Block.Values[Index]->MinKernel); - Strategy = OC_BLOB_GET (&UserKernel->Block.Values[Index]->Strategy); + + for (Index = 0; Index < Config->Kernel.Block.Count; ++Index) { + Arch = OC_BLOB_GET (&Config->Kernel.Block.Values[Index]->Arch); + Comment = OC_BLOB_GET (&Config->Kernel.Block.Values[Index]->Comment); + Identifier = OC_BLOB_GET (&Config->Kernel.Block.Values[Index]->Identifier); + MaxKernel = OC_BLOB_GET (&Config->Kernel.Block.Values[Index]->MaxKernel); + MinKernel = OC_BLOB_GET (&Config->Kernel.Block.Values[Index]->MinKernel); + Strategy = OC_BLOB_GET (&Config->Kernel.Block.Values[Index]->Strategy); // // Sanitise strings. @@ -412,9 +408,9 @@ CheckKernelBlock ( // Check duplicated entries in Kernel->Block. // ErrorCount += FindArrayDuplication ( - UserKernel->Block.Values, - UserKernel->Block.Count, - sizeof (UserKernel->Block.Values[0]), + Config->Kernel.Block.Values, + Config->Kernel.Block.Count, + sizeof (Config->Kernel.Block.Values[0]), KernelBlockHasDuplication ); @@ -428,16 +424,14 @@ CheckKernelEmulate ( ) { UINT32 ErrorCount; - OC_KERNEL_CONFIG *UserKernel; CONST CHAR8 *MaxKernel; CONST CHAR8 *MinKernel; BOOLEAN Result; ErrorCount = 0; - UserKernel = &Config->Kernel; - MaxKernel = OC_BLOB_GET (&UserKernel->Emulate.MaxKernel); - MinKernel = OC_BLOB_GET (&UserKernel->Emulate.MinKernel); + MaxKernel = OC_BLOB_GET (&Config->Kernel.Emulate.MaxKernel); + MinKernel = OC_BLOB_GET (&Config->Kernel.Emulate.MinKernel); // // MinKernel must not be below macOS 10.4 (Darwin version 8). @@ -459,10 +453,10 @@ CheckKernelEmulate ( } Result = DataHasProperMasking ( - UserKernel->Emulate.Cpuid1Data, - UserKernel->Emulate.Cpuid1Mask, - sizeof (UserKernel->Emulate.Cpuid1Data), - sizeof (UserKernel->Emulate.Cpuid1Mask) + Config->Kernel.Emulate.Cpuid1Data, + Config->Kernel.Emulate.Cpuid1Mask, + sizeof (Config->Kernel.Emulate.Cpuid1Data), + sizeof (Config->Kernel.Emulate.Cpuid1Mask) ); if (!Result) { @@ -481,7 +475,6 @@ CheckKernelForce ( { UINT32 ErrorCount; UINT32 Index; - OC_KERNEL_CONFIG *UserKernel; CONST CHAR8 *Arch; CONST CHAR8 *BundlePath; CONST CHAR8 *Comment; @@ -492,17 +485,16 @@ CheckKernelForce ( CONST CHAR8 *PlistPath; ErrorCount = 0; - UserKernel = &Config->Kernel; - for (Index = 0; Index < UserKernel->Force.Count; ++Index) { - Arch = OC_BLOB_GET (&UserKernel->Force.Values[Index]->Arch); - BundlePath = OC_BLOB_GET (&UserKernel->Force.Values[Index]->BundlePath); - Comment = OC_BLOB_GET (&UserKernel->Force.Values[Index]->Comment); - ExecutablePath = OC_BLOB_GET (&UserKernel->Force.Values[Index]->ExecutablePath); - Identifier = OC_BLOB_GET (&UserKernel->Force.Values[Index]->Identifier); - MaxKernel = OC_BLOB_GET (&UserKernel->Force.Values[Index]->MaxKernel); - MinKernel = OC_BLOB_GET (&UserKernel->Force.Values[Index]->MinKernel); - PlistPath = OC_BLOB_GET (&UserKernel->Force.Values[Index]->PlistPath); + for (Index = 0; Index < Config->Kernel.Force.Count; ++Index) { + Arch = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->Arch); + BundlePath = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->BundlePath); + Comment = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->Comment); + ExecutablePath = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->ExecutablePath); + Identifier = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->Identifier); + MaxKernel = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->MaxKernel); + MinKernel = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->MinKernel); + PlistPath = OC_BLOB_GET (&Config->Kernel.Force.Values[Index]->PlistPath); // // Sanitise strings. @@ -574,9 +566,9 @@ CheckKernelForce ( // Check duplicated entries in Kernel->Force. // ErrorCount += FindArrayDuplication ( - UserKernel->Force.Values, - UserKernel->Force.Count, - sizeof (UserKernel->Force.Values[0]), + Config->Kernel.Force.Values, + Config->Kernel.Force.Count, + sizeof (Config->Kernel.Force.Values[0]), KernelForceHasDuplication ); @@ -591,7 +583,6 @@ CheckKernelPatch ( { UINT32 ErrorCount; UINT32 Index; - OC_KERNEL_CONFIG *UserKernel; CONST CHAR8 *Arch; CONST CHAR8 *Comment; CONST CHAR8 *MaxKernel; @@ -608,23 +599,22 @@ CheckKernelPatch ( UINT32 ReplaceMaskSize; ErrorCount = 0; - UserKernel = &Config->Kernel; - - for (Index = 0; Index < UserKernel->Patch.Count; ++Index) { - Base = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Base); - Comment = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Comment); - Arch = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Arch); - Identifier = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Identifier); - Find = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Find); - FindSize = UserKernel->Patch.Values[Index]->Find.Size; - Replace = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Replace); - ReplaceSize = UserKernel->Patch.Values[Index]->Replace.Size; - Mask = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->Mask); - MaskSize = UserKernel->Patch.Values[Index]->Mask.Size; - ReplaceMask = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->ReplaceMask); - ReplaceMaskSize = UserKernel->Patch.Values[Index]->ReplaceMask.Size; - MaxKernel = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->MaxKernel); - MinKernel = OC_BLOB_GET (&UserKernel->Patch.Values[Index]->MinKernel); + + for (Index = 0; Index < Config->Kernel.Patch.Count; ++Index) { + Base = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Base); + Comment = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Comment); + Arch = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Arch); + Identifier = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Identifier); + Find = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Find); + FindSize = Config->Kernel.Patch.Values[Index]->Find.Size; + Replace = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Replace); + ReplaceSize = Config->Kernel.Patch.Values[Index]->Replace.Size; + Mask = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->Mask); + MaskSize = Config->Kernel.Patch.Values[Index]->Mask.Size; + ReplaceMask = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->ReplaceMask); + ReplaceMaskSize = Config->Kernel.Patch.Values[Index]->ReplaceMask.Size; + MaxKernel = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->MaxKernel); + MinKernel = OC_BLOB_GET (&Config->Kernel.Patch.Values[Index]->MinKernel); // // Sanitise strings. @@ -690,27 +680,23 @@ CheckKernelQuirks ( ) { UINT32 ErrorCount; - OC_KERNEL_CONFIG *UserKernel; - OC_PLATFORM_CONFIG *UserPlatformInfo; BOOLEAN IsCustomSMBIOSGuidEnabled; CONST CHAR8 *UpdateSMBIOSMode; INT64 SetApfsTrimTimeout; ErrorCount = 0; - UserKernel = &Config->Kernel; - UserPlatformInfo = &Config->PlatformInfo; // // CustomSMBIOSGuid quirk requires UpdateSMBIOSMode at PlatformInfo set to Custom. // - IsCustomSMBIOSGuidEnabled = UserKernel->Quirks.CustomSmbiosGuid; - UpdateSMBIOSMode = OC_BLOB_GET (&UserPlatformInfo->UpdateSmbiosMode); + IsCustomSMBIOSGuidEnabled = Config->Kernel.Quirks.CustomSmbiosGuid; + UpdateSMBIOSMode = OC_BLOB_GET (&Config->PlatformInfo.UpdateSmbiosMode); if (IsCustomSMBIOSGuidEnabled && AsciiStrCmp (UpdateSMBIOSMode, "Custom") != 0) { DEBUG ((DEBUG_WARN, "Kernel->Quirks->CustomSMBIOSGuid is enabled, but PlatformInfo->UpdateSMBIOSMode is not set to Custom!\n")); ++ErrorCount; } - SetApfsTrimTimeout = UserKernel->Quirks.SetApfsTrimTimeout; + SetApfsTrimTimeout = Config->Kernel.Quirks.SetApfsTrimTimeout; if (SetApfsTrimTimeout > MAX_UINT32 || SetApfsTrimTimeout < -1) { DEBUG ((DEBUG_WARN, "Kernel->Quirks->SetApfsTrimTimeout is invalid value %d!\n", SetApfsTrimTimeout)); @@ -727,23 +713,21 @@ CheckKernelScheme ( ) { UINT32 ErrorCount; - OC_KERNEL_CONFIG *UserKernel; CONST CHAR8 *Arch; CONST CHAR8 *KernelCache; ErrorCount = 0; - UserKernel = &Config->Kernel; // // Sanitise Kernel->Scheme keys. // - Arch = OC_BLOB_GET (&UserKernel->Scheme.KernelArch); + Arch = OC_BLOB_GET (&Config->Kernel.Scheme.KernelArch); if (!AsciiArchIsLegal (Arch, TRUE)) { DEBUG ((DEBUG_WARN, "Kernel->Scheme->KernelArch is borked (Can only be Auto, i386, i386-user32, or x86_64)!\n")); ++ErrorCount; } - KernelCache = OC_BLOB_GET (&UserKernel->Scheme.KernelCache); + KernelCache = OC_BLOB_GET (&Config->Kernel.Scheme.KernelCache); if (AsciiStrCmp (KernelCache, "Auto") != 0 && AsciiStrCmp (KernelCache, "Cacheless") != 0 && AsciiStrCmp (KernelCache, "Mkext") != 0 diff --git a/Utilities/ocvalidate/ValidateMisc.c b/Utilities/ocvalidate/ValidateMisc.c index ab2ccdce..bc32afaa 100644 --- a/Utilities/ocvalidate/ValidateMisc.c +++ b/Utilities/ocvalidate/ValidateMisc.c @@ -149,7 +149,6 @@ CheckBlessOverride ( UINT32 ErrorCount; UINT32 Index; UINTN Index2; - OC_MISC_CONFIG *UserMisc; CONST CHAR8 *BlessOverrideEntry; STATIC CONST CHAR8 *DisallowedBlessOverrideValues[] = { "\\EFI\\Microsoft\\Boot\\bootmgfw.efi", @@ -157,10 +156,9 @@ CheckBlessOverride ( }; ErrorCount = 0; - UserMisc = &Config->Misc; - for (Index = 0; Index < UserMisc->BlessOverride.Count; ++Index) { - BlessOverrideEntry = OC_BLOB_GET (UserMisc->BlessOverride.Values[Index]); + for (Index = 0; Index < Config->Misc.BlessOverride.Count; ++Index) { + BlessOverrideEntry = OC_BLOB_GET (Config->Misc.BlessOverride.Values[Index]); // // &DisallowedBlessOverrideValues[][1] means no first '\\'. @@ -185,8 +183,6 @@ CheckMiscBoot ( ) { UINT32 ErrorCount; - OC_MISC_CONFIG *UserMisc; - OC_UEFI_CONFIG *UserUefi; UINT32 ConsoleAttributes; CONST CHAR8 *HibernateMode; UINT32 PickerAttributes; @@ -204,16 +200,14 @@ CheckMiscBoot ( CONST CHAR8 *LauncherPath; ErrorCount = 0; - UserMisc = &Config->Misc; - UserUefi = &Config->Uefi; - ConsoleAttributes = UserMisc->Boot.ConsoleAttributes; + ConsoleAttributes = Config->Misc.Boot.ConsoleAttributes; if ((ConsoleAttributes & ~0x7FU) != 0) { DEBUG ((DEBUG_WARN, "Misc->Boot->ConsoleAttributes has unknown bits set!\n")); ++ErrorCount; } - HibernateMode = OC_BLOB_GET (&UserMisc->Boot.HibernateMode); + HibernateMode = OC_BLOB_GET (&Config->Misc.Boot.HibernateMode); if (AsciiStrCmp (HibernateMode, "None") != 0 && AsciiStrCmp (HibernateMode, "Auto") != 0 && AsciiStrCmp (HibernateMode, "RTC") != 0 @@ -222,22 +216,22 @@ CheckMiscBoot ( ++ErrorCount; } - PickerAttributes = UserMisc->Boot.PickerAttributes; + PickerAttributes = Config->Misc.Boot.PickerAttributes; if ((PickerAttributes & ~OC_ATTR_ALL_BITS) != 0) { DEBUG ((DEBUG_WARN, "Misc->Boot->PickerAttributes has unknown bits set!\n")); ++ErrorCount; } HasOpenCanopyEfiDriver = FALSE; - for (Index = 0; Index < UserUefi->Drivers.Count; ++Index) { - DriverEntry = UserUefi->Drivers.Values[Index]; + for (Index = 0; Index < Config->Uefi.Drivers.Count; ++Index) { + DriverEntry = Config->Uefi.Drivers.Values[Index]; Driver = OC_BLOB_GET (&DriverEntry->Path); if (DriverEntry->Enabled && AsciiStrCmp (Driver, "OpenCanopy.efi") == 0) { HasOpenCanopyEfiDriver = TRUE; } } - PickerMode = OC_BLOB_GET (&UserMisc->Boot.PickerMode); + PickerMode = OC_BLOB_GET (&Config->Misc.Boot.PickerMode); if (AsciiStrCmp (PickerMode, "Builtin") != 0 && AsciiStrCmp (PickerMode, "External") != 0 && AsciiStrCmp (PickerMode, "Apple") != 0) { @@ -248,7 +242,7 @@ CheckMiscBoot ( ++ErrorCount; } - PickerVariant = OC_BLOB_GET (&UserMisc->Boot.PickerVariant); + PickerVariant = OC_BLOB_GET (&Config->Misc.Boot.PickerVariant); if (PickerVariant[0] == '\0') { DEBUG ((DEBUG_WARN, "Misc->Boot->PickerVariant cannot be empty!\n")); ++ErrorCount; @@ -270,8 +264,8 @@ CheckMiscBoot ( ++ErrorCount; } - IsPickerAudioAssistEnabled = UserMisc->Boot.PickerAudioAssist; - IsAudioSupportEnabled = UserUefi->Audio.AudioSupport; + IsPickerAudioAssistEnabled = Config->Misc.Boot.PickerAudioAssist; + IsAudioSupportEnabled = Config->Uefi.Audio.AudioSupport; if (IsPickerAudioAssistEnabled && !IsAudioSupportEnabled) { DEBUG ((DEBUG_WARN, "Misc->Boot->PickerAudioAssist is enabled, but UEFI->Audio->AudioSupport is not enabled altogether!\n")); ++ErrorCount; @@ -300,7 +294,6 @@ CheckMiscDebug ( ) { UINT32 ErrorCount; - OC_MISC_CONFIG *UserMisc; UINT64 DisplayLevel; UINT64 AllowedDisplayLevel; UINT64 HaltLevel; @@ -308,12 +301,11 @@ CheckMiscDebug ( UINT32 Target; ErrorCount = 0; - UserMisc = &Config->Misc; // // FIXME: Check whether DisplayLevel only supports values within AllowedDisplayLevel, or all possible levels in DebugLib.h? // - DisplayLevel = UserMisc->Debug.DisplayLevel; + DisplayLevel = Config->Misc.Debug.DisplayLevel; AllowedDisplayLevel = DEBUG_WARN | DEBUG_INFO | DEBUG_VERBOSE | DEBUG_ERROR; if ((DisplayLevel & ~AllowedDisplayLevel) != 0) { DEBUG ((DEBUG_WARN, "Misc->Debug->DisplayLevel has unknown bits set!\n")); @@ -326,7 +318,7 @@ CheckMiscDebug ( ++ErrorCount; } - Target = UserMisc->Debug.Target; + Target = Config->Misc.Debug.Target; if ((Target & ~OC_LOG_ALL_BITS) != 0) { DEBUG ((DEBUG_WARN, "Misc->Debug->Target has unknown bits set!\n")); ++ErrorCount; @@ -400,7 +392,6 @@ CheckMiscEntries ( { UINT32 ErrorCount; UINT32 Index; - OC_MISC_CONFIG *UserMisc; CONST CHAR8 *Arguments; CONST CHAR8 *Comment; CONST CHAR8 *AsciiName; @@ -409,14 +400,13 @@ CheckMiscEntries ( CONST CHAR8 *Flavour; ErrorCount = 0; - UserMisc = &Config->Misc; - for (Index = 0; Index < UserMisc->Entries.Count; ++Index) { - Arguments = OC_BLOB_GET (&UserMisc->Entries.Values[Index]->Arguments); - Comment = OC_BLOB_GET (&UserMisc->Entries.Values[Index]->Comment); - AsciiName = OC_BLOB_GET (&UserMisc->Entries.Values[Index]->Name); - Path = OC_BLOB_GET (&UserMisc->Entries.Values[Index]->Path); - Flavour = OC_BLOB_GET (&UserMisc->Entries.Values[Index]->Flavour); + for (Index = 0; Index < Config->Misc.Entries.Count; ++Index) { + Arguments = OC_BLOB_GET (&Config->Misc.Entries.Values[Index]->Arguments); + Comment = OC_BLOB_GET (&Config->Misc.Entries.Values[Index]->Comment); + AsciiName = OC_BLOB_GET (&Config->Misc.Entries.Values[Index]->Name); + Path = OC_BLOB_GET (&Config->Misc.Entries.Values[Index]->Path); + Flavour = OC_BLOB_GET (&Config->Misc.Entries.Values[Index]->Flavour); // // Sanitise strings. @@ -458,9 +448,9 @@ CheckMiscEntries ( // Check duplicated entries in Entries. // ErrorCount += FindArrayDuplication ( - UserMisc->Entries.Values, - UserMisc->Entries.Count, - sizeof (UserMisc->Entries.Values[0]), + Config->Misc.Entries.Values, + Config->Misc.Entries.Count, + sizeof (Config->Misc.Entries.Values[0]), MiscEntriesHasDuplication ); @@ -475,8 +465,6 @@ CheckMiscSecurity ( { UINT32 ErrorCount; UINT32 Index; - OC_KERNEL_CONFIG *UserKernel; - OC_MISC_CONFIG *UserMisc; BOOLEAN IsAuthRestartEnabled; BOOLEAN HasVSMCKext; CONST CHAR8 *AsciiDmgLoading; @@ -487,22 +475,20 @@ CheckMiscSecurity ( CONST CHAR8 *SecureBootModel; ErrorCount = 0; - UserKernel = &Config->Kernel; - UserMisc = &Config->Misc; HasVSMCKext = FALSE; - for (Index = 0; Index < UserKernel->Add.Count; ++Index) { - if (AsciiStrCmp (OC_BLOB_GET (&UserKernel->Add.Values[Index]->BundlePath), mKextInfo[INDEX_KEXT_VSMC].KextBundlePath) == 0) { + for (Index = 0; Index < Config->Kernel.Add.Count; ++Index) { + if (AsciiStrCmp (OC_BLOB_GET (&Config->Kernel.Add.Values[Index]->BundlePath), mKextInfo[INDEX_KEXT_VSMC].KextBundlePath) == 0) { HasVSMCKext = TRUE; } } - IsAuthRestartEnabled = UserMisc->Security.AuthRestart; + IsAuthRestartEnabled = Config->Misc.Security.AuthRestart; if (IsAuthRestartEnabled && !HasVSMCKext) { DEBUG ((DEBUG_WARN, "Misc->Security->AuthRestart is enabled, but VirtualSMC is not loaded at Kernel->Add!\n")); ++ErrorCount; } - AsciiDmgLoading = OC_BLOB_GET (&UserMisc->Security.DmgLoading); + AsciiDmgLoading = OC_BLOB_GET (&Config->Misc.Security.DmgLoading); if (AsciiStrCmp (AsciiDmgLoading, "Disabled") != 0 && AsciiStrCmp (AsciiDmgLoading, "Signed") != 0 && AsciiStrCmp (AsciiDmgLoading, "Any") != 0) { @@ -510,13 +496,13 @@ CheckMiscSecurity ( ++ErrorCount; } - ExposeSensitiveData = UserMisc->Security.ExposeSensitiveData; + ExposeSensitiveData = Config->Misc.Security.ExposeSensitiveData; if ((ExposeSensitiveData & ~OCS_EXPOSE_ALL_BITS) != 0) { DEBUG ((DEBUG_WARN, "Misc->Security->ExposeSensitiveData has unknown bits set!\n")); ++ErrorCount; } - AsciiVault = OC_BLOB_GET (&UserMisc->Security.Vault); + AsciiVault = OC_BLOB_GET (&Config->Misc.Security.Vault); if (AsciiStrCmp (AsciiVault, "Optional") != 0 && AsciiStrCmp (AsciiVault, "Basic") != 0 && AsciiStrCmp (AsciiVault, "Secure") != 0) { @@ -524,7 +510,7 @@ CheckMiscSecurity ( ++ErrorCount; } - ScanPolicy = UserMisc->Security.ScanPolicy; + ScanPolicy = Config->Misc.Security.ScanPolicy; AllowedScanPolicy = OC_SCAN_FILE_SYSTEM_LOCK | OC_SCAN_DEVICE_LOCK | OC_SCAN_DEVICE_BITS | OC_SCAN_FILE_SYSTEM_BITS; // // ScanPolicy can be zero (failsafe value), skipping such. @@ -549,7 +535,7 @@ CheckMiscSecurity ( // // Validate SecureBootModel. // - SecureBootModel = OC_BLOB_GET (&UserMisc->Security.SecureBootModel); + SecureBootModel = OC_BLOB_GET (&Config->Misc.Security.SecureBootModel); if (!ValidateSecureBootModel (SecureBootModel)) { DEBUG ((DEBUG_WARN, "Misc->Security->SecureBootModel is borked!\n")); ++ErrorCount; @@ -611,26 +597,24 @@ CheckMiscSerial ( ) { UINT32 ErrorCount; - OC_MISC_CONFIG *UserMisc; UINT32 RegisterAccessWidth; UINT32 BaudRate; CONST UINT8 *PciDeviceInfo; UINT32 PciDeviceInfoSize; ErrorCount = 0; - UserMisc = &Config->Misc; // // Reference: // https://github.com/acidanthera/audk/blob/bb1bba3d776733c41dbfa2d1dc0fe234819a79f2/MdeModulePkg/MdeModulePkg.dec#L1199-L1200 // - RegisterAccessWidth = UserMisc->Serial.RegisterAccessWidth; + RegisterAccessWidth = Config->Misc.Serial.RegisterAccessWidth; if (RegisterAccessWidth != 8U && RegisterAccessWidth != 32U) { DEBUG ((DEBUG_WARN, "Misc->Serial->RegisterAccessWidth can only be 8 or 32!\n")); ++ErrorCount; } - BaudRate = UserMisc->Serial.BaudRate; + BaudRate = Config->Misc.Serial.BaudRate; if (!ValidateBaudRate (BaudRate)) { ++ErrorCount; } @@ -639,8 +623,8 @@ CheckMiscSerial ( // Reference: // https://github.com/acidanthera/audk/blob/bb1bba3d776733c41dbfa2d1dc0fe234819a79f2/MdeModulePkg/MdeModulePkg.dec#L1393 // - PciDeviceInfo = OC_BLOB_GET (&UserMisc->Serial.PciDeviceInfo); - PciDeviceInfoSize = UserMisc->Serial.PciDeviceInfo.Size; + PciDeviceInfo = OC_BLOB_GET (&Config->Misc.Serial.PciDeviceInfo); + PciDeviceInfoSize = Config->Misc.Serial.PciDeviceInfo.Size; if (PciDeviceInfoSize > OC_SERIAL_PCI_DEVICE_INFO_MAX_SIZE) { DEBUG ((DEBUG_WARN, "Size of Misc->Serial->PciDeviceInfo cannot exceed %u!\n", OC_SERIAL_PCI_DEVICE_INFO_MAX_SIZE)); ++ErrorCount; @@ -670,7 +654,6 @@ CheckMiscTools ( { UINT32 ErrorCount; UINT32 Index; - OC_MISC_CONFIG *UserMisc; CONST CHAR8 *Arguments; CONST CHAR8 *Comment; CONST CHAR8 *AsciiName; @@ -679,14 +662,13 @@ CheckMiscTools ( CONST CHAR8 *Flavour; ErrorCount = 0; - UserMisc = &Config->Misc; - for (Index = 0; Index < UserMisc->Tools.Count; ++Index) { - Arguments = OC_BLOB_GET (&UserMisc->Tools.Values[Index]->Arguments); - Comment = OC_BLOB_GET (&UserMisc->Tools.Values[Index]->Comment); - AsciiName = OC_BLOB_GET (&UserMisc->Tools.Values[Index]->Name); - Path = OC_BLOB_GET (&UserMisc->Tools.Values[Index]->Path); - Flavour = OC_BLOB_GET (&UserMisc->Tools.Values[Index]->Flavour); + for (Index = 0; Index < Config->Misc.Tools.Count; ++Index) { + Arguments = OC_BLOB_GET (&Config->Misc.Tools.Values[Index]->Arguments); + Comment = OC_BLOB_GET (&Config->Misc.Tools.Values[Index]->Comment); + AsciiName = OC_BLOB_GET (&Config->Misc.Tools.Values[Index]->Name); + Path = OC_BLOB_GET (&Config->Misc.Tools.Values[Index]->Path); + Flavour = OC_BLOB_GET (&Config->Misc.Tools.Values[Index]->Flavour); // // Sanitise strings. @@ -736,9 +718,9 @@ CheckMiscTools ( // Check duplicated entries in Tools. // ErrorCount += FindArrayDuplication ( - UserMisc->Tools.Values, - UserMisc->Tools.Count, - sizeof (UserMisc->Tools.Values[0]), + Config->Misc.Tools.Values, + Config->Misc.Tools.Count, + sizeof (Config->Misc.Tools.Values[0]), MiscToolsHasDuplication ); diff --git a/Utilities/ocvalidate/ValidateNvram.c b/Utilities/ocvalidate/ValidateNvram.c index b26b0540..1fc3ea11 100644 --- a/Utilities/ocvalidate/ValidateNvram.c +++ b/Utilities/ocvalidate/ValidateNvram.c @@ -166,23 +166,21 @@ CheckNvramAdd ( UINT32 ErrorCount; UINT32 GuidIndex; UINT32 VariableIndex; - OC_NVRAM_CONFIG *UserNvram; CONST CHAR8 *AsciiGuid; CONST CHAR8 *AsciiNvramKey; OC_ASSOC *VariableMap; ErrorCount = 0; - UserNvram = &Config->Nvram; - for (GuidIndex = 0; GuidIndex < UserNvram->Add.Count; ++GuidIndex) { - AsciiGuid = OC_BLOB_GET (UserNvram->Add.Keys[GuidIndex]); + for (GuidIndex = 0; GuidIndex < Config->Nvram.Add.Count; ++GuidIndex) { + AsciiGuid = OC_BLOB_GET (Config->Nvram.Add.Keys[GuidIndex]); if (!AsciiGuidIsLegal (AsciiGuid)) { DEBUG ((DEBUG_WARN, "NVRAM->Add[%u] has borked GUID!\n", GuidIndex)); ++ErrorCount; } - VariableMap = UserNvram->Add.Values[GuidIndex]; + VariableMap = Config->Nvram.Add.Values[GuidIndex]; for (VariableIndex = 0; VariableIndex < VariableMap->Count; ++VariableIndex) { AsciiNvramKey = OC_BLOB_GET (VariableMap->Keys[VariableIndex]); @@ -221,9 +219,9 @@ CheckNvramAdd ( // Check duplicated entries in NVRAM->Add. // ErrorCount += FindArrayDuplication ( - UserNvram->Add.Keys, - UserNvram->Add.Count, - sizeof (UserNvram->Add.Keys[0]), + Config->Nvram.Add.Keys, + Config->Nvram.Add.Count, + sizeof (Config->Nvram.Add.Keys[0]), NvramAddHasDuplication ); @@ -239,23 +237,21 @@ CheckNvramDelete ( UINT32 ErrorCount; UINT32 GuidIndex; UINT32 VariableIndex; - OC_NVRAM_CONFIG *UserNvram; CONST CHAR8 *AsciiGuid; CONST CHAR8 *AsciiNvramKey; ErrorCount = 0; - UserNvram = &Config->Nvram; - for (GuidIndex = 0; GuidIndex < UserNvram->Delete.Count; ++GuidIndex) { - AsciiGuid = OC_BLOB_GET (UserNvram->Delete.Keys[GuidIndex]); + for (GuidIndex = 0; GuidIndex < Config->Nvram.Delete.Count; ++GuidIndex) { + AsciiGuid = OC_BLOB_GET (Config->Nvram.Delete.Keys[GuidIndex]); if (!AsciiGuidIsLegal (AsciiGuid)) { DEBUG ((DEBUG_WARN, "NVRAM->Delete[%u] has borked GUID!\n", GuidIndex)); ++ErrorCount; } - for (VariableIndex = 0; VariableIndex < UserNvram->Delete.Values[GuidIndex]->Count; ++VariableIndex) { - AsciiNvramKey = OC_BLOB_GET (UserNvram->Delete.Values[GuidIndex]->Values[VariableIndex]); + for (VariableIndex = 0; VariableIndex < Config->Nvram.Delete.Values[GuidIndex]->Count; ++VariableIndex) { + AsciiNvramKey = OC_BLOB_GET (Config->Nvram.Delete.Values[GuidIndex]->Values[VariableIndex]); // // Sanitise strings. @@ -275,9 +271,9 @@ CheckNvramDelete ( // Check duplicated properties in NVRAM->Delete. // ErrorCount += FindArrayDuplication ( - UserNvram->Delete.Values[GuidIndex]->Values, - UserNvram->Delete.Values[GuidIndex]->Count, - sizeof (UserNvram->Delete.Values[GuidIndex]->Values[0]), + Config->Nvram.Delete.Values[GuidIndex]->Values, + Config->Nvram.Delete.Values[GuidIndex]->Count, + sizeof (Config->Nvram.Delete.Values[GuidIndex]->Values[0]), NvramDeleteHasDuplication ); } @@ -286,9 +282,9 @@ CheckNvramDelete ( // Check duplicated entries in NVRAM->Delete. // ErrorCount += FindArrayDuplication ( - UserNvram->Delete.Keys, - UserNvram->Delete.Count, - sizeof (UserNvram->Delete.Keys[0]), + Config->Nvram.Delete.Keys, + Config->Nvram.Delete.Count, + sizeof (Config->Nvram.Delete.Keys[0]), NvramDeleteHasDuplication ); @@ -304,23 +300,21 @@ CheckNvramSchema ( UINT32 ErrorCount; UINT32 GuidIndex; UINT32 VariableIndex; - OC_NVRAM_CONFIG *UserNvram; CONST CHAR8 *AsciiGuid; CONST CHAR8 *AsciiNvramKey; ErrorCount = 0; - UserNvram = &Config->Nvram; - for (GuidIndex = 0; GuidIndex < UserNvram->Legacy.Count; ++GuidIndex) { - AsciiGuid = OC_BLOB_GET (UserNvram->Legacy.Keys[GuidIndex]); + for (GuidIndex = 0; GuidIndex < Config->Nvram.Legacy.Count; ++GuidIndex) { + AsciiGuid = OC_BLOB_GET (Config->Nvram.Legacy.Keys[GuidIndex]); if (!AsciiGuidIsLegal (AsciiGuid)) { DEBUG ((DEBUG_WARN, "NVRAM->LegacySchema[%u] has borked GUID!\n", GuidIndex)); ++ErrorCount; } - for (VariableIndex = 0; VariableIndex < UserNvram->Legacy.Values[GuidIndex]->Count; ++VariableIndex) { - AsciiNvramKey = OC_BLOB_GET (UserNvram->Legacy.Values[GuidIndex]->Values[VariableIndex]); + for (VariableIndex = 0; VariableIndex < Config->Nvram.Legacy.Values[GuidIndex]->Count; ++VariableIndex) { + AsciiNvramKey = OC_BLOB_GET (Config->Nvram.Legacy.Values[GuidIndex]->Values[VariableIndex]); // // Sanitise strings. @@ -340,9 +334,9 @@ CheckNvramSchema ( // Check duplicated properties in NVRAM->LegacySchema. // ErrorCount += FindArrayDuplication ( - UserNvram->Legacy.Values[GuidIndex]->Values, - UserNvram->Legacy.Values[GuidIndex]->Count, - sizeof (UserNvram->Legacy.Values[GuidIndex]->Values[0]), + Config->Nvram.Legacy.Values[GuidIndex]->Values, + Config->Nvram.Legacy.Values[GuidIndex]->Count, + sizeof (Config->Nvram.Legacy.Values[GuidIndex]->Values[0]), NvramLegacySchemaHasDuplication ); } @@ -351,9 +345,9 @@ CheckNvramSchema ( // Check duplicated entries in NVRAM->LegacySchema. // ErrorCount += FindArrayDuplication ( - UserNvram->Legacy.Keys, - UserNvram->Legacy.Count, - sizeof (UserNvram->Legacy.Keys[0]), + Config->Nvram.Legacy.Keys, + Config->Nvram.Legacy.Count, + sizeof (Config->Nvram.Legacy.Keys[0]), NvramLegacySchemaHasDuplication ); diff --git a/Utilities/ocvalidate/ValidatePlatformInfo.c b/Utilities/ocvalidate/ValidatePlatformInfo.c index e046c9ec..1ee5c7a9 100644 --- a/Utilities/ocvalidate/ValidatePlatformInfo.c +++ b/Utilities/ocvalidate/ValidatePlatformInfo.c @@ -70,22 +70,20 @@ CheckPlatformInfoGeneric ( ) { UINT32 ErrorCount; - OC_PLATFORM_CONFIG *UserPlatformInfo; CONST CHAR8 *SystemProductName; CONST CHAR8 *SystemMemoryStatus; CONST CHAR8 *AsciiSystemUUID; UINT16 ProcessorType; ErrorCount = 0; - UserPlatformInfo = &Config->PlatformInfo; - SystemProductName = OC_BLOB_GET (&UserPlatformInfo->Generic.SystemProductName); + SystemProductName = OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemProductName); if (!HasMacInfo (SystemProductName)) { DEBUG ((DEBUG_WARN, "PlatformInfo->Generic->SystemProductName has unknown model set!\n")); ++ErrorCount; } - SystemMemoryStatus = OC_BLOB_GET (&UserPlatformInfo->Generic.SystemMemoryStatus); + SystemMemoryStatus = OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemMemoryStatus); if (AsciiStrCmp (SystemMemoryStatus, "Auto") != 0 && AsciiStrCmp (SystemMemoryStatus, "Upgradable") != 0 && AsciiStrCmp (SystemMemoryStatus, "Soldered") != 0) { @@ -93,7 +91,7 @@ CheckPlatformInfoGeneric ( ++ErrorCount; } - AsciiSystemUUID = OC_BLOB_GET (&UserPlatformInfo->Generic.SystemUuid); + AsciiSystemUUID = OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemUuid); if (AsciiSystemUUID[0] != '\0' && AsciiStrCmp (AsciiSystemUUID, "OEM") != 0 && !AsciiGuidIsLegal (AsciiSystemUUID)) { @@ -101,7 +99,7 @@ CheckPlatformInfoGeneric ( ++ErrorCount; } - ProcessorType = UserPlatformInfo->Generic.ProcessorType; + ProcessorType = Config->PlatformInfo.Generic.ProcessorType; if (!ValidateProcessorType (ProcessorType)) { DEBUG ((DEBUG_WARN, "PlatformInfo->Generic->ProcessorType is borked!\n")); ++ErrorCount; @@ -120,7 +118,6 @@ CheckPlatformInfo ( ) { UINT32 ErrorCount; - OC_PLATFORM_CONFIG *UserPlatformInfo; BOOLEAN IsAutomaticEnabled; CONST CHAR8 *UpdateSMBIOSMode; UINTN Index; @@ -131,9 +128,8 @@ CheckPlatformInfo ( DEBUG ((DEBUG_VERBOSE, "config loaded into %a!\n", __func__)); ErrorCount = 0; - UserPlatformInfo = &Config->PlatformInfo; - UpdateSMBIOSMode = OC_BLOB_GET (&UserPlatformInfo->UpdateSmbiosMode); + UpdateSMBIOSMode = OC_BLOB_GET (&Config->PlatformInfo.UpdateSmbiosMode); if (AsciiStrCmp (UpdateSMBIOSMode, "TryOverwrite") != 0 && AsciiStrCmp (UpdateSMBIOSMode, "Create") != 0 && AsciiStrCmp (UpdateSMBIOSMode, "Overwrite") != 0 @@ -142,7 +138,7 @@ CheckPlatformInfo ( ++ErrorCount; } - IsAutomaticEnabled = UserPlatformInfo->Automatic; + IsAutomaticEnabled = Config->PlatformInfo.Automatic; if (!IsAutomaticEnabled) { // // This is not an error, but we need to stop checking further. diff --git a/Utilities/ocvalidate/ValidateUefi.c b/Utilities/ocvalidate/ValidateUefi.c index c17761cb..90fb9284 100644 --- a/Utilities/ocvalidate/ValidateUefi.c +++ b/Utilities/ocvalidate/ValidateUefi.c @@ -120,20 +120,16 @@ CheckUefiAPFS ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; - OC_MISC_CONFIG *UserMisc; BOOLEAN IsEnableJumpstartEnabled; UINT32 ScanPolicy; ErrorCount = 0; - UserUefi = &Config->Uefi; - UserMisc = &Config->Misc; // // If FS restrictions is enabled but APFS FS scanning is disabled, it is an error. // - IsEnableJumpstartEnabled = UserUefi->Apfs.EnableJumpstart; - ScanPolicy = UserMisc->Security.ScanPolicy; + IsEnableJumpstartEnabled = Config->Uefi.Apfs.EnableJumpstart; + ScanPolicy = Config->Misc.Security.ScanPolicy; if (IsEnableJumpstartEnabled && (ScanPolicy & OC_SCAN_FILE_SYSTEM_LOCK) != 0 && (ScanPolicy & OC_SCAN_ALLOW_FS_APFS) == 0) { @@ -151,15 +147,11 @@ CheckUefiAppleInput ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; CONST CHAR8 *AppleEvent; ErrorCount = 0; - UserUefi = &Config->Uefi; - ErrorCount = 0; - - AppleEvent = OC_BLOB_GET (&UserUefi->AppleInput.AppleEvent); + AppleEvent = OC_BLOB_GET (&Config->Uefi.AppleInput.AppleEvent); if (AsciiStrCmp (AppleEvent, "Auto") != 0 && AsciiStrCmp (AppleEvent, "Builtin") != 0 && AsciiStrCmp (AppleEvent, "OEM") != 0) { @@ -167,13 +159,13 @@ CheckUefiAppleInput ( ++ErrorCount; } - if (UserUefi->Input.KeySupport && UserUefi->AppleInput.CustomDelays) { - if (UserUefi->AppleInput.KeyInitialDelay != 0 - && UserUefi->AppleInput.KeyInitialDelay < UserUefi->Input.KeyForgetThreshold) { + if (Config->Uefi.Input.KeySupport && Config->Uefi.AppleInput.CustomDelays) { + if (Config->Uefi.AppleInput.KeyInitialDelay != 0 + && Config->Uefi.AppleInput.KeyInitialDelay < Config->Uefi.Input.KeyForgetThreshold) { DEBUG ((DEBUG_WARN, "KeyInitialDelay is enabled in KeySupport mode, is non-zero and is less than the KeyForgetThreshold value (will result in uncontrolled key repeats)!\n")); ++ErrorCount; } - if (UserUefi->AppleInput.KeySubsequentDelay < UserUefi->Input.KeyForgetThreshold) { + if (Config->Uefi.AppleInput.KeySubsequentDelay < Config->Uefi.Input.KeyForgetThreshold) { DEBUG ((DEBUG_WARN, "KeySubsequentDelay is enabled in KeySupport mode and is less than the KeyForgetThreshold value (will result in uncontrolled key repeats)!\n")); ++ErrorCount; } @@ -223,19 +215,17 @@ CheckUefiAudio ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; BOOLEAN IsAudioSupportEnabled; UINT64 AudioOutMask; CONST CHAR8 *AsciiAudioDevicePath; CONST CHAR8 *AsciiPlayChime; ErrorCount = 0; - UserUefi = &Config->Uefi; - IsAudioSupportEnabled = UserUefi->Audio.AudioSupport; - AudioOutMask = UserUefi->Audio.AudioOutMask; - AsciiAudioDevicePath = OC_BLOB_GET (&UserUefi->Audio.AudioDevice); - AsciiPlayChime = OC_BLOB_GET (&UserUefi->Audio.PlayChime); + IsAudioSupportEnabled = Config->Uefi.Audio.AudioSupport; + AudioOutMask = Config->Uefi.Audio.AudioOutMask; + AsciiAudioDevicePath = OC_BLOB_GET (&Config->Uefi.Audio.AudioDevice); + AsciiPlayChime = OC_BLOB_GET (&Config->Uefi.Audio.PlayChime); if (IsAudioSupportEnabled) { if (AudioOutMask == 0) { DEBUG ((DEBUG_WARN, "UEFI->Audio->AudioOutMask is zero when AudioSupport is enabled, no sound will play!\n")); @@ -243,7 +233,7 @@ CheckUefiAudio ( } ErrorCount += CheckUefiGain ( - UserUefi->Audio.MaximumGain, + Config->Uefi.Audio.MaximumGain, "MaximumGain", 0, NULL @@ -251,23 +241,23 @@ CheckUefiAudio ( // No operational reason for MinimumAssistGain <= MaximumGain, but is safer to ensure non-deafening sound levels. ErrorCount += CheckUefiGain ( - UserUefi->Audio.MinimumAssistGain, + Config->Uefi.Audio.MinimumAssistGain, "MinimumAssistGain", - UserUefi->Audio.MaximumGain, + Config->Uefi.Audio.MaximumGain, "MaximumGain" ); ErrorCount += CheckUefiGain ( - UserUefi->Audio.MinimumAudibleGain, + Config->Uefi.Audio.MinimumAudibleGain, "MinimumAudibleGain", - UserUefi->Audio.MinimumAssistGain, + Config->Uefi.Audio.MinimumAssistGain, "MinimumAssistGain" ); ErrorCount += CheckUefiGain ( - UserUefi->Audio.MinimumAudibleGain, + Config->Uefi.Audio.MinimumAudibleGain, "MinimumAudibleGain", - UserUefi->Audio.MaximumGain, + Config->Uefi.Audio.MaximumGain, "MaximumGain" ); @@ -297,7 +287,6 @@ CheckUefiDrivers ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; UINT32 Index; OC_UEFI_DRIVER_ENTRY *DriverEntry; CONST CHAR8 *Comment; @@ -317,7 +306,6 @@ CheckUefiDrivers ( BOOLEAN IsConnectDriversEnabled; ErrorCount = 0; - UserUefi = &Config->Uefi; HasOpenRuntimeEfiDriver = FALSE; HasOpenUsbKbDxeEfiDriver = FALSE; @@ -328,8 +316,8 @@ CheckUefiDrivers ( IndexHfsEfiDriver = 0; HasAudioDxeEfiDriver = FALSE; IndexAudioDxeEfiDriver = 0; - for (Index = 0; Index < UserUefi->Drivers.Count; ++Index) { - DriverEntry = UserUefi->Drivers.Values[Index]; + for (Index = 0; Index < Config->Uefi.Drivers.Count; ++Index) { + DriverEntry = Config->Uefi.Drivers.Values[Index]; Comment = OC_BLOB_GET (&DriverEntry->Comment); Driver = OC_BLOB_GET (&DriverEntry->Path); @@ -393,13 +381,13 @@ CheckUefiDrivers ( // Check duplicated Drivers. // ErrorCount += FindArrayDuplication ( - UserUefi->Drivers.Values, - UserUefi->Drivers.Count, - sizeof (UserUefi->Drivers.Values[0]), + Config->Uefi.Drivers.Values, + Config->Uefi.Drivers.Count, + sizeof (Config->Uefi.Drivers.Values[0]), UefiDriverHasDuplication ); - IsRequestBootVarRoutingEnabled = UserUefi->Quirks.RequestBootVarRouting; + IsRequestBootVarRoutingEnabled = Config->Uefi.Quirks.RequestBootVarRouting; if (IsRequestBootVarRoutingEnabled) { if (!HasOpenRuntimeEfiDriver) { DEBUG ((DEBUG_WARN, "UEFI->Quirks->RequestBootVarRouting is enabled, but OpenRuntime.efi is not loaded at UEFI->Drivers!\n")); @@ -407,7 +395,7 @@ CheckUefiDrivers ( } } - IsKeySupportEnabled = UserUefi->Input.KeySupport; + IsKeySupportEnabled = Config->Uefi.Input.KeySupport; if (IsKeySupportEnabled) { if (HasOpenUsbKbDxeEfiDriver) { DEBUG ((DEBUG_WARN, "OpenUsbKbDxe.efi at UEFI->Drivers[%u] should NEVER be used together with UEFI->Input->KeySupport!\n", IndexOpenUsbKbDxeEfiDriver)); @@ -430,7 +418,7 @@ CheckUefiDrivers ( ++ErrorCount; } - IsConnectDriversEnabled = UserUefi->ConnectDrivers; + IsConnectDriversEnabled = Config->Uefi.ConnectDrivers; if (!IsConnectDriversEnabled) { if (HasHfsEfiDriver) { DEBUG ((DEBUG_WARN, "HFS+ filesystem driver is loaded at UEFI->Drivers[%u], but UEFI->ConnectDrivers is not enabled!\n", IndexHfsEfiDriver)); @@ -452,22 +440,20 @@ CheckUefiInput ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; BOOLEAN IsPointerSupportEnabled; CONST CHAR8 *PointerSupportMode; CONST CHAR8 *KeySupportMode; ErrorCount = 0; - UserUefi = &Config->Uefi; - IsPointerSupportEnabled = UserUefi->Input.PointerSupport; - PointerSupportMode = OC_BLOB_GET (&UserUefi->Input.PointerSupportMode); + IsPointerSupportEnabled = Config->Uefi.Input.PointerSupport; + PointerSupportMode = OC_BLOB_GET (&Config->Uefi.Input.PointerSupportMode); if (IsPointerSupportEnabled && AsciiStrCmp (PointerSupportMode, "ASUS") != 0) { DEBUG ((DEBUG_WARN, "UEFI->Input->PointerSupport is enabled, but PointerSupportMode is not ASUS!\n")); ++ErrorCount; } - KeySupportMode = OC_BLOB_GET (&UserUefi->Input.KeySupportMode); + KeySupportMode = OC_BLOB_GET (&Config->Uefi.Input.KeySupportMode); if (AsciiStrCmp (KeySupportMode, "Auto") != 0 && AsciiStrCmp (KeySupportMode, "V1") != 0 && AsciiStrCmp (KeySupportMode, "V2") != 0 @@ -486,7 +472,6 @@ CheckUefiOutput ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; CONST CHAR8 *TextRenderer; CONST CHAR8 *GopPassThrough; BOOLEAN IsTextRendererSystem; @@ -504,14 +489,13 @@ CheckUefiOutput ( BOOLEAN HasUefiOutputUIScale; ErrorCount = 0; - UserUefi = &Config->Uefi; IsTextRendererSystem = FALSE; HasUefiOutputUIScale = FALSE; // // Sanitise strings. // - TextRenderer = OC_BLOB_GET (&UserUefi->Output.TextRenderer); + TextRenderer = OC_BLOB_GET (&Config->Uefi.Output.TextRenderer); if (AsciiStrCmp (TextRenderer, "BuiltinGraphics") != 0 && AsciiStrCmp (TextRenderer, "BuiltinText") != 0 && AsciiStrCmp (TextRenderer, "SystemGraphics") != 0 @@ -527,32 +511,32 @@ CheckUefiOutput ( } if (!IsTextRendererSystem) { - IsClearScreenOnModeSwitchEnabled = UserUefi->Output.ClearScreenOnModeSwitch; + IsClearScreenOnModeSwitchEnabled = Config->Uefi.Output.ClearScreenOnModeSwitch; if (IsClearScreenOnModeSwitchEnabled) { DEBUG ((DEBUG_WARN, "UEFI->Output->ClearScreenOnModeSwitch is enabled on non-System TextRenderer (currently %a)!\n", TextRenderer)); ++ErrorCount; } - IsIgnoreTextInGraphicsEnabled = UserUefi->Output.IgnoreTextInGraphics; + IsIgnoreTextInGraphicsEnabled = Config->Uefi.Output.IgnoreTextInGraphics; if (IsIgnoreTextInGraphicsEnabled) { DEBUG ((DEBUG_WARN, "UEFI->Output->IgnoreTextInGraphics is enabled on non-System TextRenderer (currently %a)!\n", TextRenderer)); ++ErrorCount; } - IsReplaceTabWithSpaceEnabled = UserUefi->Output.ReplaceTabWithSpace; + IsReplaceTabWithSpaceEnabled = Config->Uefi.Output.ReplaceTabWithSpace; if (IsReplaceTabWithSpaceEnabled) { DEBUG ((DEBUG_WARN, "UEFI->Output->ReplaceTabWithSpace is enabled on non-System TextRenderer (currently %a)!\n", TextRenderer)); ++ErrorCount; } - IsSanitiseClearScreenEnabled = UserUefi->Output.SanitiseClearScreen; + IsSanitiseClearScreenEnabled = Config->Uefi.Output.SanitiseClearScreen; if (IsSanitiseClearScreenEnabled) { DEBUG ((DEBUG_WARN, "UEFI->Output->SanitiseClearScreen is enabled on non-System TextRenderer (currently %a)!\n", TextRenderer)); ++ErrorCount; } } - GopPassThrough = OC_BLOB_GET (&UserUefi->Output.GopPassThrough); + GopPassThrough = OC_BLOB_GET (&Config->Uefi.Output.GopPassThrough); if (AsciiStrCmp (GopPassThrough, "Enabled") != 0 && AsciiStrCmp (GopPassThrough, "Disabled") != 0 && AsciiStrCmp (GopPassThrough, "Apple") != 0) { @@ -563,7 +547,7 @@ CheckUefiOutput ( // // Parse Output->ConsoleMode by calling OpenCore libraries. // - ConsoleMode = OC_BLOB_GET (&UserUefi->Output.ConsoleMode); + ConsoleMode = OC_BLOB_GET (&Config->Uefi.Output.ConsoleMode); OcParseConsoleMode ( ConsoleMode, &UserWidth, @@ -580,7 +564,7 @@ CheckUefiOutput ( // // Parse Output->Resolution by calling OpenCore libraries. // - Resolution = OC_BLOB_GET (&UserUefi->Output.Resolution); + Resolution = OC_BLOB_GET (&Config->Uefi.Output.Resolution); OcParseScreenResolution ( Resolution, &UserWidth, @@ -595,7 +579,7 @@ CheckUefiOutput ( ++ErrorCount; } - UIScale = UserUefi->Output.UIScale; + UIScale = Config->Uefi.Output.UIScale; if (UIScale < -1 || UIScale > 2) { DEBUG ((DEBUG_WARN, "UEFI->Output->UIScale is borked (Can only be between -1 and 2)!\n")); ++ErrorCount; @@ -621,12 +605,10 @@ CheckUefiQuirks ( ) { UINT32 ErrorCount; - OC_UEFI_CONFIG *UserUefi; INT8 ResizeGpuBars; ErrorCount = 0; - UserUefi = &Config->Uefi; - ResizeGpuBars = UserUefi->Quirks.ResizeGpuBars; + ResizeGpuBars = Config->Uefi.Quirks.ResizeGpuBars; if (ResizeGpuBars < -1 || ResizeGpuBars > 19) { DEBUG ((DEBUG_WARN, "UEFI->Quirks->ResizeGpuBars is borked (Can only be between -1 and 19)!\n")); @@ -644,21 +626,19 @@ CheckUefiReservedMemory ( { UINT32 ErrorCount; UINT32 Index; - OC_UEFI_CONFIG *UserUefi; CONST CHAR8 *AsciiReservedMemoryType; UINT64 ReservedMemoryAddress; UINT64 ReservedMemorySize; ErrorCount = 0; - UserUefi = &Config->Uefi; // // Validate ReservedMemory[N]. // - for (Index = 0; Index < UserUefi->ReservedMemory.Count; ++Index) { - AsciiReservedMemoryType = OC_BLOB_GET (&UserUefi->ReservedMemory.Values[Index]->Type); - ReservedMemoryAddress = UserUefi->ReservedMemory.Values[Index]->Address; - ReservedMemorySize = UserUefi->ReservedMemory.Values[Index]->Size; + for (Index = 0; Index < Config->Uefi.ReservedMemory.Count; ++Index) { + AsciiReservedMemoryType = OC_BLOB_GET (&Config->Uefi.ReservedMemory.Values[Index]->Type); + ReservedMemoryAddress = Config->Uefi.ReservedMemory.Values[Index]->Address; + ReservedMemorySize = Config->Uefi.ReservedMemory.Values[Index]->Size; if (!ValidateReservedMemoryType (AsciiReservedMemoryType)) { DEBUG ((DEBUG_WARN, "UEFI->ReservedMemory[%u]->Type is borked!\n", Index)); @@ -682,9 +662,9 @@ CheckUefiReservedMemory ( // Now overlapping check amongst Address and Size. // ErrorCount += FindArrayDuplication ( - UserUefi->ReservedMemory.Values, - UserUefi->ReservedMemory.Count, - sizeof (UserUefi->ReservedMemory.Values[0]), + Config->Uefi.ReservedMemory.Values, + Config->Uefi.ReservedMemory.Count, + sizeof (Config->Uefi.ReservedMemory.Values[0]), UefiReservedMemoryHasOverlap ); -- GitLab