OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcValidateLib.h File Reference
#include <sys/time.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>

Go to the source code of this file.

Typedefs

typedef BOOLEAN(* DUPLICATION_CHECK) (IN CONST VOID *PrimaryEntry, IN CONST VOID *SecondaryEntry)
 

Functions

INT64 GetCurrentTimestamp (VOID)
 
BOOLEAN AsciiFileSystemPathIsLegal (IN CONST CHAR8 *Path)
 
BOOLEAN AsciiCommentIsLegal (IN CONST CHAR8 *Comment)
 
BOOLEAN AsciiIdentifierIsLegal (IN CONST CHAR8 *Identifier, IN BOOLEAN IsKernelIdentifier)
 
BOOLEAN AsciiArchIsLegal (IN CONST CHAR8 *Arch, IN BOOLEAN IsKernelArch)
 
BOOLEAN AsciiPropertyIsLegal (IN CONST CHAR8 *Property)
 
BOOLEAN AsciiUefiDriverIsLegal (IN CONST CHAR8 *Driver, IN CONST UINTN DriverIndex)
 
BOOLEAN AsciiDevicePathIsLegal (IN CONST CHAR8 *AsciiDevicePath)
 
BOOLEAN AsciiGuidIsLegal (IN CONST CHAR8 *AsciiGuid)
 
BOOLEAN DataHasProperMasking (IN CONST VOID *Data, IN CONST VOID *Mask, IN UINTN DataSize, IN UINTN MaskSize)
 
UINT32 ValidatePatch (IN CONST CHAR8 *PatchSection, IN UINT32 PatchIndex, IN BOOLEAN FindSizeCanBeZero, IN CONST UINT8 *Find, IN UINT32 FindSize, IN CONST UINT8 *Replace, IN UINT32 ReplaceSize, IN CONST UINT8 *Mask, IN UINT32 MaskSize, IN CONST UINT8 *ReplaceMask, IN UINT32 ReplaceMaskSize)
 
UINT32 FindArrayDuplication (IN VOID *First, IN UINTN Number, IN UINTN Size, IN DUPLICATION_CHECK DupChecker)
 
BOOLEAN StringIsDuplicated (IN CONST CHAR8 *EntrySection, IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
 
UINT32 ReportError (IN CONST CHAR8 *FuncName, IN UINT32 ErrorCount)
 

Detailed Description

Copyright (C) 2018, vit9696. All rights reserved. Copyright (C) 2020, PMheart. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcValidateLib.h.

Typedef Documentation

◆ DUPLICATION_CHECK

typedef BOOLEAN(* DUPLICATION_CHECK) (IN CONST VOID *PrimaryEntry, IN CONST VOID *SecondaryEntry)

Check whether PrimaryEntry and SecondaryEntry are duplicated.

Definition at line 197 of file OcValidateLib.h.

Function Documentation

◆ AsciiArchIsLegal()

BOOLEAN AsciiArchIsLegal ( IN CONST CHAR8 * Arch,
IN BOOLEAN IsKernelArch )

Check if an OpenCore Configuration Arch matches specific conventions.

Parameters
[in]ArchArch to be checked.
[in]IsKernelArchTRUE to perform special checks for Kernel->Scheme->KernelArch.
Return values
TRUEIf Arch matches conventions.

Definition at line 160 of file OcValidateLib.c.

◆ AsciiCommentIsLegal()

BOOLEAN AsciiCommentIsLegal ( IN CONST CHAR8 * Comment)

Check if an OpenCore Configuration Comment contains only ASCII printable characters.

Parameters
[in]CommentComment to be checked.
Return values
TRUEIf Comment only contains ASCII printable characters.

Definition at line 71 of file OcValidateLib.c.

◆ AsciiDevicePathIsLegal()

BOOLEAN AsciiDevicePathIsLegal ( IN CONST CHAR8 * AsciiDevicePath)

Check if a device path in ASCII is valid.

Parameters
[in]AsciiDevicePathDevice path to be checked.
Return values
TRUEIf AsciiDevicePath is valid.

Definition at line 260 of file OcValidateLib.c.

◆ AsciiFileSystemPathIsLegal()

BOOLEAN AsciiFileSystemPathIsLegal ( IN CONST CHAR8 * Path)

Check if a filesystem path contains only legal characters.

Parameters
[in]PathFilesystem path to be checked.
Return values
TRUEIf Path only contains 0-9, A-Z, a-z, '_', '-', '.', '/', and '\'.

Definition at line 37 of file OcValidateLib.c.

◆ AsciiGuidIsLegal()

BOOLEAN AsciiGuidIsLegal ( IN CONST CHAR8 * AsciiGuid)

Check if a GUID in ASCII is valid.

Parameters
[in]AsciiGuidGUID in ASCII format to be checked.
Return values
TRUEIf AsciiGuid has valid GUID format.

Definition at line 316 of file OcValidateLib.c.

◆ AsciiIdentifierIsLegal()

BOOLEAN AsciiIdentifierIsLegal ( IN CONST CHAR8 * Identifier,
IN BOOLEAN IsKernelIdentifier )

Check if an OpenCore Configuration Identifier matches specific conventions.

Parameters
[in]IdentifierIdentifier to be checked.
[in]IsKernelPatchIdentifierTRUE to perform special checks for Kernel->Patch->Identifier.
Return values
TRUEIf Identifier matches conventions.

Definition at line 93 of file OcValidateLib.c.

◆ AsciiPropertyIsLegal()

BOOLEAN AsciiPropertyIsLegal ( IN CONST CHAR8 * Property)

Check if an OpenCore Configuration Property contains only ASCII printable characters. This is mainly used in Device Properties and NVRAM Properties.

Parameters
[in]PropertyProperty to be checked.
Return values
TRUEIf Property only contains ASCII printable characters.

Definition at line 200 of file OcValidateLib.c.

◆ AsciiUefiDriverIsLegal()

BOOLEAN AsciiUefiDriverIsLegal ( IN CONST CHAR8 * Driver,
IN CONST UINTN DriverIndex )

Check if a UEFI Driver matches specific conventions.

Parameters
[in]DriverDriver path name to be checked.
[in]DriverIndexIndex of driver being checked.
Return values
TRUEIf path of Driver contains .efi suffix, and only contains 0-9, A-Z, a-z, '_', '-', '.', and '/'.

Definition at line 212 of file OcValidateLib.c.

◆ DataHasProperMasking()

BOOLEAN DataHasProperMasking ( IN CONST VOID * Data,
IN CONST VOID * Mask,
IN UINTN DataSize,
IN UINTN MaskSize )

Check if a set of data has proper masking set.

This function assumes identical sizes of Data and Mask, which must be ensured before calling.

Parameters
[in]DataData to be checked.
[in]MaskMask to be applied to Data.
[in]DataSizeSize of Data.
[in]MaskSizeSize of Mask.
Return values
TRUEIf corresponding bits of Mask to Data are active (set to non-zero).

Definition at line 332 of file OcValidateLib.c.

◆ FindArrayDuplication()

UINT32 FindArrayDuplication ( IN VOID * First,
IN UINTN Number,
IN UINTN Size,
IN DUPLICATION_CHECK DupChecker )

Check if one array has duplicated entries.

Parameters
[in]FirstPointer to the first object of the array to be checked, converted to a VOID*.
[in]NumberNumber of elements in the array pointed to by First.
[in]SizeSize in bytes of each element in the array.
[in]DupCheckerPointer to a comparator function which returns TRUE if duplication is found. See DUPLICATION_CHECK for function prototype.
Returns
Number of duplications detected, which are counted to the total number of errors discovered.

Definition at line 456 of file OcValidateLib.c.

◆ GetCurrentTimestamp()

INT64 GetCurrentTimestamp ( VOID )

Get current timestamp in milliseconds.

Returns
Current timestamp in milliseconds.

Definition at line 20 of file OcValidateLib.c.

◆ ReportError()

UINT32 ReportError ( IN CONST CHAR8 * FuncName,
IN UINT32 ErrorCount )

Report status of errors in the end of each checker function.

Parameters
[in]FuncNameChecker function name. (func in most cases)
[in]ErrorCountNumber of errors to be returned.
Returns
Number of errors detected in one checker.

Definition at line 511 of file OcValidateLib.c.

◆ StringIsDuplicated()

BOOLEAN StringIsDuplicated ( IN CONST CHAR8 * EntrySection,
IN CONST CHAR8 * FirstString,
IN CONST CHAR8 * SecondString )

Check if two strings are duplicated to each other. Used as a wrapper of AsciiStrCmp to print duplicated entries.

Parameters
[in]EntrySectionSection of strings to which they belong throughout OpenCore Configuration.
[in]FirstStringPrimary entry in string format.
[in]SecondStringSecondary entry in string format.
Return values
TRUEIf FirstString and SecondString are duplicated.

Definition at line 493 of file OcValidateLib.c.

◆ ValidatePatch()

UINT32 ValidatePatch ( IN CONST CHAR8 * PatchSection,
IN UINT32 PatchIndex,
IN BOOLEAN FindSizeCanBeZero,
IN CONST UINT8 * Find,
IN UINT32 FindSize,
IN CONST UINT8 * Replace,
IN UINT32 ReplaceSize,
IN CONST UINT8 * Mask,
IN UINT32 MaskSize,
IN CONST UINT8 * ReplaceMask,
IN UINT32 ReplaceMaskSize )

Check if an OpenCore binary patch is valid.

If size of Find cannot be zero and it is different from that of Replace, then error. If Mask/ReplaceMask is set, but its size is different from that of Find/Replace, then error. If Mask/ReplaceMask is set without corresponding bits being active for Find/Replace, then error.

Parameters
[in]PatchSectionPatch section to which the patch to be checked belongs.
[in]PatchIndexIndex of the patch to be checked.
[in]FindSizeCanBeZeroWhether size of Find can be zero. This should be set to TRUE only when Kernel->Patch->Base is used and Find is empty.
[in]FindFind pattern to be checked.
[in]FindSizeSize of Find pattern above.
[in]ReplaceReplace pattern to be checked.
[in]ReplaceSizeSize of Replace pattern above.
[in]MaskMask pattern to be checked.
[in]MaskSizeSize of Mask pattern above.
[in]ReplaceMaskReplaceMask pattern to be checked.
[in]ReplaceMaskSizeSize of ReplaceMask pattern above.
Returns
Number of errors detected, which are counted to the total number of errors discovered.

Definition at line 363 of file OcValidateLib.c.