未验证 提交 c904ab67 编写于 作者: P PMheart 提交者: GitHub

Buid: Migrate all tools to Utilities (#69)

上级 ecea50a2
......@@ -7,23 +7,22 @@ xcshareddata
xcuserdata
project.xcworkspace
*.dSYM
TestsUser/DiskImage/DiskImage
TestsUser/Macho/Macho
TestsUser/Prelinked/Prelinked
TestsUser/Prelinked/Result.xml
TestsUser/RsaPreprocess/RsaPreprocess
TestsUser/Serialized/Serialized
TestsUser/Smbios/Smbios
Utilities/RsaTool/RsaTool
Utilities/EfiResTool/EfiResTool
Utilities/AppleEfiSignTool/AppleEfiSignTool
Utilities/disklabel/disklabel
Utilities/EfiResTool/EfiResTool
Utilities/macserial/macserial
Utilities/icnspack/icnspack
Utilities/DiskImage/DiskImage
Utilities/HelloWorld/HelloWorld
Utilities/KextInject/KextInject
Utilities/ConfigValidity/ConfigValidity
Utilities/disklabel/disklabel
Utilities/ocvalidate/ocvalidate
Utilities/RsaTool/RsaTool
Utilities/TestBmf/Bmf
Utilities/TestDiskImage/DiskImage
Utilities/TestHelloWorld/HelloWorld
Utilities/TestImg4/Img4
Utilities/TestKextInject/KextInject
Utilities/TestKextInject/Result.xml
Utilities/TestMacho/Macho
Utilities/TestRsaPreprocess/RsaPreprocess
Utilities/TestSmbios/Smbios
*.o
*.exe
DICT
......
......@@ -368,7 +368,7 @@ Root configuration entries consist of the following:
\end{itemize}
It is possible to perform basic validation of the configuration by using
\texttt{ConfigValidity} utility. Please note, that \texttt{ConfigValidity}
\texttt{ocvalidate} utility. Please note, that \texttt{ocvalidate}
must match the used OpenCore release and may not be able to detect all
configuration flaws present in the file.
......
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Tue Jun 2 03:55:18 2020
%DIF ADD ../Configuration.tex Fri Jun 5 12:29:25 2020
%DIF DEL PreviousConfiguration.tex Tue Jun 2 02:24:29 2020
%DIF ADD ../Configuration.tex Fri Jun 5 19:35:52 2020
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
......@@ -429,7 +429,7 @@ Root configuration entries consist of the following:
\end{itemize}
It is possible to perform basic validation of the configuration by using
\texttt{ConfigValidity} utility. Please note, that \texttt{ConfigValidity}
\texttt{\DIFdelbegin \DIFdel{ConfigValidity}\DIFdelend \DIFaddbegin \DIFadd{ocvalidate}\DIFaddend } utility. Please note, that \texttt{\DIFdelbegin \DIFdel{ConfigValidity}\DIFdelend \DIFaddbegin \DIFadd{ocvalidate}\DIFaddend }
must match the used OpenCore release and may not be able to detect all
configuration flaws present in the file.
......
......@@ -28,8 +28,8 @@
#include "libDERImg4/libDERImg4.h"
#include "libDERImg4/Img4oids.h"
GLOBAL_REMOVE_IF_UNREFERENCED const uint8_t *DERImg4RootCertificate = gAppleX86SecureBootRootCaCert;
GLOBAL_REMOVE_IF_UNREFERENCED const size_t *DERImg4RootCertificateSize = &gAppleX86SecureBootRootCaCertSize;
GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 *DERImg4RootCertificate = gAppleX86SecureBootRootCaCert;
GLOBAL_REMOVE_IF_UNREFERENCED const UINTN *DERImg4RootCertificateSize = &gAppleX86SecureBootRootCaCertSize;
bool
DERImg4VerifySignature (
......
......@@ -20,8 +20,8 @@ extern "C" {
#define DER_IMG4_MAX_DIGEST_SIZE 64
extern const uint8_t *DERImg4RootCertificate;
extern const size_t *DERImg4RootCertificateSize;
extern const UINT8 *DERImg4RootCertificate;
extern const UINTN *DERImg4RootCertificateSize;
bool
DERImg4VerifySignature (
......
......@@ -20,23 +20,35 @@ extern "C" {
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#ifndef EFIUSER
typedef UINT8 uint8_t;
typedef UINT16 uint16_t;
typedef UINT32 uint32_t;
typedef UINT64 uint64_t;
typedef UINTN size_t;
#ifndef bool
typedef BOOLEAN bool;
#endif
#endif /* bool */
#ifndef assert
#define assert ASSERT
#endif
#define DER_ENCODE_ENABLE 0
#endif /* assert */
#define memset(ptr, c, len) SetMem(ptr, len, c)
#define memmove(dst, src, len) CopyMem(dst, src, len)
#define memcmp(b1, b2, len) CompareMem(b1, b2, len)
#else /* EFIUSER */
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#endif /* !EFIUSER */
#define DER_ENCODE_ENABLE 0
#define DER_TAG_SIZE 8
//
// edk2 porting - end
......
......@@ -19,7 +19,7 @@
// Tolerance within which we consider two frequency values to be roughly
// equivalent.
//
#define OC_CPU_FREQUENCY_TOLERANCE 50000000ULL // 50 Mhz
#define OC_CPU_FREQUENCY_TOLERANCE 50000000LL // 50 Mhz
/**
Internal CPU synchronisation structure.
......
......@@ -92,7 +92,7 @@ InternalGetInterpolatedValue (
if (Value != 0) {
Bit = HighBitSet32 (ABS (Value));
return (INT64) Value * AccelerationNumbers[
MIN (Bit, ARRAY_SIZE (AccelerationNumbers) - 1)
MIN (Bit, (INTN) ARRAY_SIZE (AccelerationNumbers) - 1)
];
}
......
此差异已折叠。
/** @file
Copyright (C) 2018, vit9696. 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.
**/
#include <Library/OcSmbiosLib.h>
#include <Library/OcMiscLib.h>
#include <IndustryStandard/AppleSmBios.h>
#include <sys/time.h>
/*
TODO: ...
clang -g -fsanitize=undefined,address -fshort-wchar -I../Include -I../../Include -I../../../EfiPkg/Include/ -I../../../EfiPkg/Include/X64 -I../../../MdePkg/Include/ -I../../../UefiCpuPkg/Include/ -include ../Include/Base.h Props.c ../../Library/OcDevicePropertyLib/OcDevicePropertyLib.c ../../Library/OcStringLib/OcAsciiLib.c ../../../MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c ../../../MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c ../../../MdePkg/Library/UefiDevicePathLib/DevicePathToText.c -o Props
for fuzzing:
clang-mp-7.0 -Dmain=__main -g -fsanitize=undefined,address,fuzzer -fshort-wchar -I../Include -I../../Include -I../../../EfiPkg/Include/ -I../../../EfiPkg/Include/X64 -I../../../MdePkg/Include/ -I../../../UefiCpuPkg/Include/ -include ../Include/Base.h Props.c ../../Library/OcDevicePropertyLib/OcDevicePropertyLib.c ../../Library/OcStringLib/OcAsciiLib.c ../../../MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c ../../../MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c ../../../MdePkg/Library/UefiDevicePathLib/DevicePathToText.c -o Props
rm -rf DICT fuzz*.log ; mkdir DICT ; cp Props.bin DICT ; ./Props -jobs=4 DICT
rm -rf Props.dSYM DICT fuzz*.log Props
*/
EFI_GUID gAppleVendorVariableGuid;
EFI_GUID gEfiDevicePathPropertyDatabaseProtocolGuid;
EFI_GUID gEfiLegacyRegionProtocolGuid;
EFI_GUID gEfiDebugPortProtocolGuid;
EFI_GUID gEfiDevicePathFromTextProtocolGuid;
EFI_GUID gEfiDevicePathProtocolGuid;
EFI_GUID gEfiDevicePathToTextProtocolGuid;
EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
EFI_GUID gEfiPcAnsiGuid;
EFI_GUID gEfiPersistentVirtualCdGuid;
EFI_GUID gEfiPersistentVirtualDiskGuid;
EFI_GUID gEfiSasDevicePathGuid;
EFI_GUID gEfiUartDevicePathGuid;
EFI_GUID gEfiVT100Guid;
EFI_GUID gEfiVT100PlusGuid;
EFI_GUID gEfiVTUTF8Guid;
EFI_GUID gEfiVirtualCdGuid;
EFI_GUID gEfiVirtualDiskGuid;
_Thread_local uint32_t externalUsedPages = 0;
_Thread_local uint8_t externalBlob[EFI_PAGE_SIZE*TOTAL_PAGES];
int main(int argc, char** argv) {
return 0;
}
INT32 LLVMFuzzerTestOneInput(CONST UINT8 *Data, UINTN Size) {
if (Size > 0) {
VOID *NewData = AllocatePool (Size);
if (NewData) {
CopyMem (NewData, Data, Size);
FreePool (NewData);
}
}
return 0;
}
......@@ -7,6 +7,8 @@
#define OC_USER_BOOT_SERVICES_H
#include <Uefi.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
......@@ -18,14 +20,34 @@ extern EFI_BOOT_SERVICES mBootServices;
extern EFI_SYSTEM_TABLE mSystemTable;
extern EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mConOut;
STATIC
EFI_TPL
EFIAPI
DummyRaiseTPL (
IN EFI_TPL NewTpl
);
STATIC
EFI_STATUS
DummyLocateProtocol (
EFI_GUID *ProtocolGuid,
VOID *Registration,
VOID **Interface
);
EFI_STATUS
DummyAllocatePages (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
);
EFI_STATUS
EFIAPI
DummyInstallConfigurationTable (
IN EFI_GUID *Guid,
IN VOID *Table
);
EFI_STATUS
EFIAPI
NullTextOutputString (
......
/** @file
Copyright (c) 2020, PMheart. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
extern const CHAR8 *gEfiCallerBaseName;
extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
extern EFI_GUID gEfiHiiFontProtocolGuid;
extern EFI_GUID gEfiSimpleTextOutProtocolGuid;
extern EFI_GUID gEfiUgaDrawProtocolGuid;
......@@ -3,17 +3,13 @@
SPDX-License-Identifier: BSD-3-Clause
**/
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/DebugLib.h>
#ifndef OC_USER_FILE_H
#define OC_USER_FILE_H
VOID
EFIAPI
CpuBreakpoint (
VOID
)
{
ASSERT (FALSE);
while (TRUE);
}
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
uint8_t *readFile(const char *str, uint32_t *size);
#endif // OC_USER_FILE_H
/** @file
Copyright (c) 2020, PMheart. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#ifndef OC_USER_GLOBAL_VAR_H
#define OC_USER_GLOBAL_VAR_H
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
extern EFI_GUID gAppleBootVariableGuid;
extern EFI_GUID gAppleEventProtocolGuid;
extern EFI_GUID gAppleKeyMapAggregatorProtocolGuid;
extern EFI_GUID gAppleKeyMapDatabaseProtocolGuid;
extern EFI_GUID gAppleApfsContainerInfoGuid;
extern EFI_GUID gAppleApfsVolumeInfoGuid;
extern EFI_GUID gAppleBlessedOsxFolderInfoGuid;
extern EFI_GUID gAppleBlessedSystemFileInfoGuid;
extern EFI_GUID gAppleBlessedSystemFolderInfoGuid;
extern EFI_GUID gAppleBootPolicyProtocolGuid;
extern EFI_GUID gAppleVendorVariableGuid;
extern const CHAR8 *gEfiCallerBaseName;
extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
extern EFI_GUID gEfiHiiFontProtocolGuid;
extern EFI_GUID gEfiSimpleTextOutProtocolGuid;
extern EFI_GUID gEfiUgaDrawProtocolGuid;
extern EFI_GUID gEfiAbsolutePointerProtocolGuid;
extern EFI_GUID gEfiLoadedImageProtocolGuid;
extern EFI_GUID gEfiShellParametersProtocolGuid;
extern EFI_GUID gEfiSimplePointerProtocolGuid;
extern EFI_GUID gEfiDebugPortProtocolGuid;
extern EFI_GUID gEfiDevicePathProtocolGuid;
extern EFI_GUID gEfiPcAnsiGuid;
extern EFI_GUID gEfiPersistentVirtualCdGuid;
extern EFI_GUID gEfiPersistentVirtualDiskGuid;
extern EFI_GUID gEfiSasDevicePathGuid;
extern EFI_GUID gEfiUartDevicePathGuid;
extern EFI_GUID gEfiVT100Guid;
extern EFI_GUID gEfiVT100PlusGuid;
extern EFI_GUID gEfiVTUTF8Guid;
extern EFI_GUID gEfiVirtualCdGuid;
extern EFI_GUID gEfiVirtualDiskGuid;
extern EFI_GUID gEfiFileInfoGuid;
extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid;
extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;
extern EFI_GUID gEfiUserInterfaceThemeProtocolGuid;
extern EFI_GUID gEfiMpServiceProtocolGuid;
extern EFI_GUID gFrameworkEfiMpServiceProtocolGuid;
extern EFI_GUID gEfiGlobalVariableGuid;
extern EFI_GUID gEfiSmbios3TableGuid;
extern EFI_GUID gEfiLegacyRegionProtocolGuid;
extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
extern EFI_GUID gEfiSmbiosTableGuid;
extern EFI_GUID gOcVendorVariableGuid;
extern EFI_GUID gOcCustomSmbios3TableGuid;
extern EFI_GUID gOcCustomSmbiosTableGuid;
#endif // OC_USER_GLOBAL_VAR_H
......@@ -3,21 +3,27 @@
SPDX-License-Identifier: BSD-3-Clause
**/
#ifndef OC_USER_PCD_H
#define OC_USER_PCD_H
#include <Uefi.h>
#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/OcCryptoLib.h>
extern const UINT32 _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize;
extern const BOOLEAN _gPcd_FixedAtBuild_PcdUgaConsumeSupport;
extern const UINT8 _gPcd_FixedAtBuild_PcdDebugPropertyMask;
extern const UINT8 _gPcd_FixedAtBuild_PcdDebugClearMemoryValue;
extern const UINT32 _gPcd_FixedAtBuild_PcdFixedDebugPrintErrorLevel;
extern const UINT32 _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel;
extern const UINT32 _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength;
extern const UINT32 _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength;
extern const UINT32 _gPcd_FixedAtBuild_PcdMaximumLinkedListLength;
extern const BOOLEAN _gPcd_FixedAtBuild_PcdVerifyNodeInList;
extern UINT32 _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize;
extern BOOLEAN _gPcd_FixedAtBuild_PcdUgaConsumeSupport;
extern UINT8 _gPcd_FixedAtBuild_PcdDebugPropertyMask;
extern UINT8 _gPcd_FixedAtBuild_PcdDebugClearMemoryValue;
extern UINT32 _gPcd_FixedAtBuild_PcdFixedDebugPrintErrorLevel;
extern UINT32 _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel;
extern UINT32 _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength;
extern UINT32 _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength;
extern UINT32 _gPcd_FixedAtBuild_PcdMaximumLinkedListLength;
extern BOOLEAN _gPcd_FixedAtBuild_PcdVerifyNodeInList;
extern UINT32 _gPcd_FixedAtBuild_PcdCpuNumberOfReservedVariableMtrrs;
extern UINT32 _gPcd_FixedAtBuild_PcdMaximumDevicePathNodeCount;
#define _PCD_GET_MODE_32_PcdUefiLibMaxPrintBufferSize _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize
#define _PCD_GET_MODE_BOOL_PcdUgaConsumeSupport _gPcd_FixedAtBuild_PcdUgaConsumeSupport
......@@ -32,3 +38,9 @@ extern const BOOLEAN _gPcd_FixedAtBuild_PcdVerifyNodeInList;
#define _PCD_GET_MODE_16_PcdOcCryptoAllowedRsaModuli (512U | 256U)
#define _PCD_GET_MODE_16_PcdOcCryptoAllowedSigHashTypes \
((1U << OcSigHashTypeSha256) | (1U << OcSigHashTypeSha384) | (1U << OcSigHashTypeSha512))
#define _PCD_GET_MODE_32_PcdCpuNumberOfReservedVariableMtrrs _gPcd_FixedAtBuild_PcdCpuNumberOfReservedVariableMtrrs
// this will not be of any effect at userspace
#define _PCD_GET_MODE_64_PcdPciExpressBaseAddress 0
#define _PCD_GET_MODE_32_PcdMaximumDevicePathNodeCount _gPcd_FixedAtBuild_PcdMaximumDevicePathNodeCount
#endif // OC_USER_PCD_H
......@@ -12,6 +12,10 @@
#include <string.h>
#include <stdlib.h>
#ifdef WIN32
#include <malloc.h>
#endif // WIN32
VOID *
EFIAPI
CopyMem (
......@@ -55,6 +59,27 @@ CompareMem (
return memcmp (DestinationBuffer, SourceBuffer, Length);
}
VOID *
EFIAPI
ScanMem16 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
)
{
UINT16 *Pointer;
Pointer = (UINT16*)Buffer;
for (UINTN i = 0; i < Length; ++i) {
if (Pointer[i] == Value) {
return Pointer;
}
}
return NULL;
}
VOID *
EFIAPI
AllocatePool (
......@@ -98,6 +123,45 @@ AllocateZeroPool (
return Memory;
}
VOID *
ReallocatePool (
UINTN OldSize,
UINTN NewSize,
VOID *OldBuffer OPTIONAL
)
{
VOID *NewBuffer;
NewBuffer = AllocateZeroPool (NewSize);
if (NewBuffer != NULL && OldBuffer != NULL) {
memcpy (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
free (OldBuffer);
}
return NewBuffer;
}
VOID *
EFIAPI
AllocatePages (
IN UINTN Pages
)
{
#ifdef WIN32
return _aligned_malloc (Pages * EFI_PAGE_SIZE, EFI_PAGE_SIZE);
#else // !WIN32
VOID *Memory;
int r;
r = posix_memalign (&Memory, EFI_PAGE_SIZE, Pages * EFI_PAGE_SIZE);
if (r != 0) {
DEBUG ((DEBUG_ERROR, "posix_memalign returns error %d\n", r));
return NULL;
}
return Memory;
#endif // WIN32
}
VOID
EFIAPI
FreePool (
......@@ -105,6 +169,19 @@ FreePool (
)
{
ASSERT (Buffer != NULL);
free (Buffer);
}
VOID
EFIAPI
FreePages (
IN VOID *Buffer,
IN UINTN Pages
)
{
ASSERT (Buffer != NULL);
free (Buffer);
}
......@@ -119,6 +196,16 @@ CopyGuid (
return DestinationGuid;
}
BOOLEAN
EFIAPI
CompareGuid (
IN CONST GUID *Guid1,
IN CONST GUID *Guid2
)
{
return memcmp (Guid1, Guid2, sizeof (GUID)) == 0;
}
UINT16
EFIAPI
ReadUnaligned16 (
......@@ -143,6 +230,19 @@ WriteUnaligned16 (
return Value;
}
UINT32
EFIAPI
ReadUnaligned24 (
IN CONST UINT32 *Buffer
)
{
UINT32 Value;
Value = ReadUnaligned32 (Buffer) & 0xffffff;
return Value;
}
UINT32
EFIAPI
ReadUnaligned32 (
......@@ -153,3 +253,40 @@ ReadUnaligned32 (
memmove (&Value, Buffer, sizeof (UINT32));
return Value;
}
UINT64
EFIAPI
ReadUnaligned64 (
IN CONST UINT64 *Buffer
)
{
UINT64 Value;
memmove (&Value, Buffer, sizeof (UINT64));
return Value;
}
UINT32
EFIAPI
WriteUnaligned32 (
OUT UINT32 *Buffer,
IN UINT32 Value
)
{
ASSERT (Buffer != NULL);
memmove (Buffer, &Value, sizeof (UINT32));
return Value;
}
UINT64
EFIAPI
WriteUnaligned64 (
OUT UINT64 *Buffer,
IN UINT64 Value
)
{
ASSERT (Buffer != NULL);
memmove (Buffer, &Value, sizeof (UINT64));
return Value;
}
......@@ -7,7 +7,10 @@
EFI_BOOT_SERVICES mBootServices =
{
.RaiseTPL = DummyRaiseTPL
.RaiseTPL = DummyRaiseTPL,
.LocateProtocol = DummyLocateProtocol,
.AllocatePages = DummyAllocatePages,
.InstallConfigurationTable = DummyInstallConfigurationTable
};
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mConOut =
......@@ -21,6 +24,10 @@ EFI_SYSTEM_TABLE mSystemTable =
.ConOut = &mConOut
};
EFI_RUNTIME_SERVICES mRuntimeServices = {
};
EFI_SYSTEM_TABLE *gST = &mSystemTable;
EFI_BOOT_SERVICES *gBS = &mBootServices;
......@@ -29,7 +36,11 @@ EFI_HANDLE gImageHandle = (EFI_HANDLE)(UINTN) 0x12345;
BOOLEAN mPostEBS = FALSE;
EFI_SYSTEM_TABLE *mDebugST = &mSystemTable;
STATIC
EFI_RUNTIME_SERVICES *gRT = &mRuntimeServices;
#define CONFIG_TABLE_SIZE_INCREASED 0x10
UINTN mSystemTableAllocateSize = 0;
EFI_TPL
EFIAPI
DummyRaiseTPL (
......@@ -40,7 +51,175 @@ DummyRaiseTPL (
return 0;
}
STATIC
EFI_STATUS
DummyLocateProtocol (
EFI_GUID *ProtocolGuid,
VOID *Registration,
VOID **Interface
)
{
(VOID) ProtocolGuid;
(VOID) Registration;
(VOID) Interface;
return EFI_NOT_FOUND;
}
EFI_STATUS
DummyAllocatePages (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
*Memory = (UINTN) AllocatePages (Pages);
return Memory != NULL ? EFI_SUCCESS : EFI_NOT_FOUND;
}
EFI_STATUS
EFIAPI
DummyInstallConfigurationTable (
IN EFI_GUID *Guid,
IN VOID *Table
)
{
UINTN Index;
EFI_CONFIGURATION_TABLE *EfiConfigurationTable;
EFI_CONFIGURATION_TABLE *OldTable;
//
// If Guid is NULL, then this operation cannot be performed
//
if (Guid == NULL) {
return EFI_INVALID_PARAMETER;
}
EfiConfigurationTable = gST->ConfigurationTable;
//
// Search all the table for an entry that matches Guid
//
for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
if (CompareGuid (Guid, &(gST->ConfigurationTable[Index].VendorGuid))) {
break;
}
}
if (Index < gST->NumberOfTableEntries) {
//
// A match was found, so this is either a modify or a delete operation
//
if (Table != NULL) {
//
// If Table is not NULL, then this is a modify operation.
// Modify the table entry and return.
//
gST->ConfigurationTable[Index].VendorTable = Table;
return EFI_SUCCESS;
}
//
// A match was found and Table is NULL, so this is a delete operation.
//
gST->NumberOfTableEntries--;
//
// Copy over deleted entry
//
CopyMem (
&(EfiConfigurationTable[Index]),
&(gST->ConfigurationTable[Index + 1]),
(gST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
);
} else {
//
// No matching GUIDs were found, so this is an add operation.
//
if (Table == NULL) {
//
// If Table is NULL on an add operation, then return an error.
//
return EFI_NOT_FOUND;
}
//
// Assume that Index == gST->NumberOfTableEntries
//
if ((Index * sizeof (EFI_CONFIGURATION_TABLE)) >= mSystemTableAllocateSize) {
//
// Allocate a table with one additional entry.
//
mSystemTableAllocateSize += (CONFIG_TABLE_SIZE_INCREASED * sizeof (EFI_CONFIGURATION_TABLE));
EfiConfigurationTable = AllocatePool (mSystemTableAllocateSize);
if (EfiConfigurationTable == NULL) {
//
// If a new table could not be allocated, then return an error.
//
return EFI_OUT_OF_RESOURCES;
}
if (gST->ConfigurationTable != NULL) {
//
// Copy the old table to the new table.
//
CopyMem (
EfiConfigurationTable,
gST->ConfigurationTable,
Index * sizeof (EFI_CONFIGURATION_TABLE)
);
//
// Record the old table pointer.
//
OldTable = gST->ConfigurationTable;
//
// As the CoreInstallConfigurationTable() may be re-entered by CoreFreePool()
// in its calling stack, updating System table to the new table pointer must
// be done before calling CoreFreePool() to free the old table.
// It can make sure the gST->ConfigurationTable point to the new table
// and avoid the errors of use-after-free to the old table by the reenter of
// CoreInstallConfigurationTable() in CoreFreePool()'s calling stack.
//
gST->ConfigurationTable = EfiConfigurationTable;
//
// Free the old table after updating System Table to the new table pointer.
//
FreePool (OldTable);
} else {
//
// Update System Table
//
gST->ConfigurationTable = EfiConfigurationTable;
}
}
//
// Fill in the new entry
//
CopyGuid ((VOID *)&EfiConfigurationTable[Index].VendorGuid, Guid);
EfiConfigurationTable[Index].VendorTable = Table;
//
// This is an add operation, so increment the number of table entries
//
gST->NumberOfTableEntries++;
}
//
// Fix up the CRC-32 in the EFI System Table
//
// CalculateEfiHdrCrc (&gST->Hdr);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
NullTextOutputString (
......
/** @file
Copyright (c) 2020, PMheart. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#include <EfiVar.h>
const CHAR8 *gEfiCallerBaseName = "OpenCore";
EFI_GUID gEfiGraphicsOutputProtocolGuid = { 0x9042A9DE, 0x23DC, 0x4A38, { 0x96, 0xFB, 0x7A, 0xDE, 0xD0, 0x80, 0x51, 0x6A }};
EFI_GUID gEfiHiiFontProtocolGuid = {0xe9ca4775, 0x8657, 0x47fc, {0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x08, 0x43, 0x24}};
EFI_GUID gEfiSimpleTextOutProtocolGuid = { 0x387477C2, 0x69C7, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
EFI_GUID gEfiUgaDrawProtocolGuid = { 0x982C298B, 0xF4FA, 0x41CB, { 0xB8, 0x38, 0x77, 0xAA, 0x68, 0x8F, 0xB8, 0x39 }};
/** @file
Copyright (c) 2020, PMheart. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#include <File.h>
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize + 1);
fread(string, fsize, 1, f);
fclose(f);
string[fsize] = 0;
*size = fsize;
return string;
}
/** @file
Copyright (c) 2020, PMheart. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#include <GlobalVar.h>
EFI_GUID gAppleBootVariableGuid = { 0x7C436110, 0xAB2A, 0x4BBB, { 0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82 }};
EFI_GUID gAppleEventProtocolGuid = { 0x33BE0EF1, 0x89C9, 0x4A6D, { 0xBB, 0x9F, 0x69, 0xDC, 0x8D, 0xD5, 0x16, 0xB9 }};
EFI_GUID gAppleKeyMapAggregatorProtocolGuid = { 0x5B213447, 0x6E73, 0x4901, { 0xA4, 0xF1, 0xB8, 0x64, 0xF3, 0xB7, 0xA1, 0x72 }};
EFI_GUID gAppleKeyMapDatabaseProtocolGuid = { 0x584B9EBE, 0x80C1, 0x4BD6, { 0x98, 0xB0, 0xA7, 0x78, 0x6E, 0xC2, 0xF2, 0xE2 }};
EFI_GUID gAppleApfsContainerInfoGuid = { 0x3533CF0D, 0x685F, 0x5EBF, { 0x8D, 0xC6, 0x73, 0x93, 0x48, 0x5B, 0xAF, 0xA2 }};
EFI_GUID gAppleApfsVolumeInfoGuid = { 0x900C7693, 0x8C14, 0x58BA, { 0xB4, 0x4E, 0x97, 0x45, 0x15, 0xD2, 0x7C, 0x78 }};
EFI_GUID gAppleBlessedOsxFolderInfoGuid = { 0x893CA450, 0x5F5E, 0x48BA, { 0x85, 0x8F, 0x08, 0xC4, 0x5D, 0x80, 0x23, 0x18 }};
EFI_GUID gAppleBlessedSystemFileInfoGuid = { 0xCA7E4814, 0x2ADC, 0x4ADD, { 0xAB, 0xFF, 0x73, 0x4E, 0x3C, 0xFE, 0x13, 0xF3 }};
EFI_GUID gAppleBlessedSystemFolderInfoGuid = { 0x7BD1F02D, 0x9C2F, 0x4581, { 0xBF, 0x12, 0xD5, 0x4a, 0xBA, 0x0D, 0x98, 0xD6 }};
EFI_GUID gAppleBootPolicyProtocolGuid = { 0x62257758, 0x350C, 0x4D0A, { 0xB0, 0xBD, 0xF6, 0xBE, 0x2E, 0x1E, 0x27, 0x2C }};
EFI_GUID gAppleVendorVariableGuid = { 0x4D1EDE05, 0x38C7, 0x4A6A, { 0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14 }};
const CHAR8 *gEfiCallerBaseName = "OpenCore";
EFI_GUID gEfiGraphicsOutputProtocolGuid = { 0x9042A9DE, 0x23DC, 0x4A38, { 0x96, 0xFB, 0x7A, 0xDE, 0xD0, 0x80, 0x51, 0x6A }};
EFI_GUID gEfiHiiFontProtocolGuid = {0xe9ca4775, 0x8657, 0x47fc, {0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x08, 0x43, 0x24}};
EFI_GUID gEfiSimpleTextOutProtocolGuid = { 0x387477C2, 0x69C7, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
EFI_GUID gEfiUgaDrawProtocolGuid = { 0x982C298B, 0xF4FA, 0x41CB, { 0xB8, 0x38, 0x77, 0xAA, 0x68, 0x8F, 0xB8, 0x39 }};
EFI_GUID gEfiAbsolutePointerProtocolGuid = { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } };
EFI_GUID gEfiLoadedImageProtocolGuid = { 0x5B1B31A1, 0x9562, 0x11D2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
EFI_GUID gEfiShellParametersProtocolGuid = { 0x752f3136, 0x4e16, 0x4fdc, {0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca }};
EFI_GUID gEfiSimplePointerProtocolGuid = { 0x31878C87, 0x0B75, 0x11D5, { 0x9A, 0x4F, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gEfiDebugPortProtocolGuid = { 0xEBA4E8D2, 0x3858, 0x41EC, { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 }};
EFI_GUID gEfiDevicePathProtocolGuid = { 0x09576E91, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
EFI_GUID gEfiPcAnsiGuid = { 0xE0C14753, 0xF9BE, 0x11D2, { 0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gEfiPersistentVirtualCdGuid = { 0x08018188, 0x42CD, 0xBB48, {0x10, 0x0F, 0x53, 0x87, 0xD5, 0x3D, 0xED, 0x3D }};
EFI_GUID gEfiPersistentVirtualDiskGuid = { 0x5CEA02C9, 0x4D07, 0x69D3, {0x26, 0x9F ,0x44, 0x96, 0xFB, 0xE0, 0x96, 0xF9 }};
EFI_GUID gEfiSasDevicePathGuid = { 0xd487ddb4, 0x008b, 0x11d9, { 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d }};
EFI_GUID gEfiUartDevicePathGuid = { 0x37499a9d, 0x542f, 0x4c89, { 0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 }};
EFI_GUID gEfiVT100Guid = { 0xDFA66065, 0xB419, 0x11D3, { 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gEfiVT100PlusGuid = { 0x7BAEC70B, 0x57E0, 0x4C76, { 0x8E, 0x87, 0x2F, 0x9E, 0x28, 0x08, 0x83, 0x43 }};
EFI_GUID gEfiVTUTF8Guid = { 0xAD15A0D6, 0x8BEC, 0x4ACF, { 0xA0, 0x73, 0xD0, 0x1D, 0xE7, 0x7E, 0x2D, 0x88 }};
EFI_GUID gEfiVirtualCdGuid = { 0x3D5ABD30, 0x4175, 0x87CE, {0x6D, 0x64, 0xD2, 0xAD, 0xE5, 0x23, 0xC4, 0xBB }};
EFI_GUID gEfiVirtualDiskGuid = { 0x77AB535A, 0x45FC, 0x624B, {0x55, 0x60, 0xF7, 0xB2, 0x81, 0xD1, 0xF9, 0x6E }};
EFI_GUID gEfiFileInfoGuid = { 0x09576E92, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = { 0xDB47D7D3, 0xFE81, 0x11D3, { 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gEfiSimpleFileSystemProtocolGuid = { 0x964E5B22, 0x6459, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
EFI_GUID gEfiUserInterfaceThemeProtocolGuid = { 0xD5B0AC65, 0x9A2D, 0x4D2A, { 0xBB, 0xD6, 0xE8, 0x71, 0xA9, 0x5E, 0x04, 0x35 }};
EFI_GUID gEfiMpServiceProtocolGuid = { 0x3fdda605, 0xa76e, 0x4f46, { 0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08 }};
EFI_GUID gFrameworkEfiMpServiceProtocolGuid = { 0xF33261E7, 0x23CB, 0x11D5, { 0xBD, 0x5C, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }};
EFI_GUID gEfiGlobalVariableGuid = { 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }};
EFI_GUID gEfiSmbios3TableGuid = { 0xF2FD1544, 0x9794, 0x4A2C, { 0x99, 0x2E, 0xE5, 0xBB, 0xCF, 0x20, 0xE3, 0x94 }};
EFI_GUID gEfiLegacyRegionProtocolGuid = { 0x0fc9013a, 0x0568, 0x4ba9, { 0x9b, 0x7e, 0xc9, 0xc3, 0x90, 0xa6, 0x60, 0x9b }};
EFI_GUID gEfiPciRootBridgeIoProtocolGuid = { 0x2F707EBB, 0x4A1A, 0x11D4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gEfiSmbiosTableGuid = { 0xEB9D2D31, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
EFI_GUID gOcVendorVariableGuid = { 0x4D1FDA02, 0x38C7, 0x4A6A, { 0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x01, 0x02 }};
EFI_GUID gOcCustomSmbios3TableGuid = { 0xF2FD1545, 0x9794, 0x4A2C, { 0x99, 0x2E, 0xE5, 0xBB, 0xCF, 0x20, 0xE3, 0x94 }};
EFI_GUID gOcCustomSmbiosTableGuid = { 0xEB9D2D35, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
......@@ -7,7 +7,7 @@
#define _PCD_VALUE_PcdUefiLibMaxPrintBufferSize 320U
#define _PCD_VALUE_PcdUgaConsumeSupport ((BOOLEAN)1U)
#define _PCD_VALUE_PcdDebugPropertyMask 2U
#define _PCD_VALUE_PcdDebugPropertyMask 0x23U
#define _PCD_VALUE_PcdDebugClearMemoryValue 0xAFU
#define _PCD_VALUE_PcdFixedDebugPrintErrorLevel 0x80000002U
#define _PCD_VALUE_PcdDebugPrintErrorLevel 0x80000002U
......@@ -15,14 +15,18 @@
#define _PCD_VALUE_PcdMaximumUnicodeStringLength 1000000U
#define _PCD_VALUE_PcdMaximumLinkedListLength 1000000U
#define _PCD_VALUE_PcdVerifyNodeInList ((BOOLEAN)0U)
#define _PCD_VALUE_PcdCpuNumberOfReservedVariableMtrrs 0x2U
#define _PCD_VALUE_PcdMaximumDevicePathNodeCount 0U
const UINT32 _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize = _PCD_VALUE_PcdUefiLibMaxPrintBufferSize;
const BOOLEAN _gPcd_FixedAtBuild_PcdUgaConsumeSupport = _PCD_VALUE_PcdUgaConsumeSupport;
const UINT8 _gPcd_FixedAtBuild_PcdDebugPropertyMask = _PCD_VALUE_PcdDebugPropertyMask;
const UINT8 _gPcd_FixedAtBuild_PcdDebugClearMemoryValue = _PCD_VALUE_PcdDebugClearMemoryValue;
const UINT32 _gPcd_FixedAtBuild_PcdFixedDebugPrintErrorLevel = _PCD_VALUE_PcdFixedDebugPrintErrorLevel;
const UINT32 _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel = _PCD_VALUE_PcdDebugPrintErrorLevel;
const UINT32 _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength = _PCD_VALUE_PcdMaximumAsciiStringLength;
const UINT32 _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength = _PCD_VALUE_PcdMaximumUnicodeStringLength;
const UINT32 _gPcd_FixedAtBuild_PcdMaximumLinkedListLength = _PCD_VALUE_PcdMaximumLinkedListLength;
const BOOLEAN _gPcd_FixedAtBuild_PcdVerifyNodeInList = _PCD_VALUE_PcdVerifyNodeInList;
UINT32 _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize = _PCD_VALUE_PcdUefiLibMaxPrintBufferSize;
BOOLEAN _gPcd_FixedAtBuild_PcdUgaConsumeSupport = _PCD_VALUE_PcdUgaConsumeSupport;
UINT8 _gPcd_FixedAtBuild_PcdDebugPropertyMask = _PCD_VALUE_PcdDebugPropertyMask;
UINT8 _gPcd_FixedAtBuild_PcdDebugClearMemoryValue = _PCD_VALUE_PcdDebugClearMemoryValue;
UINT32 _gPcd_FixedAtBuild_PcdFixedDebugPrintErrorLevel = _PCD_VALUE_PcdFixedDebugPrintErrorLevel;
UINT32 _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel = _PCD_VALUE_PcdDebugPrintErrorLevel;
UINT32 _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength = _PCD_VALUE_PcdMaximumAsciiStringLength;
UINT32 _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength = _PCD_VALUE_PcdMaximumUnicodeStringLength;
UINT32 _gPcd_FixedAtBuild_PcdMaximumLinkedListLength = _PCD_VALUE_PcdMaximumLinkedListLength;
BOOLEAN _gPcd_FixedAtBuild_PcdVerifyNodeInList = _PCD_VALUE_PcdVerifyNodeInList;
UINT32 _gPcd_FixedAtBuild_PcdCpuNumberOfReservedVariableMtrrs = _PCD_VALUE_PcdCpuNumberOfReservedVariableMtrrs;
UINT32 _gPcd_FixedAtBuild_PcdMaximumDevicePathNodeCount = _PCD_VALUE_PcdMaximumDevicePathNodeCount;
......@@ -16,6 +16,7 @@ DivU64x32 (
)
{
ASSERT (Divisor != 0);
return Dividend / Divisor;
}
......@@ -27,12 +28,46 @@ DivU64x32Remainder (
OUT UINT32 *Remainder OPTIONAL
)
{
ASSERT (Divisor != 0);
if (Remainder != NULL) {
*Remainder = (UINT32)(Dividend % Divisor);
}
return Dividend / Divisor;
}
INT64
EFIAPI
DivS64x64Remainder (
IN INT64 Dividend,
IN INT64 Divisor,
OUT INT64 *Remainder OPTIONAL
)
{
ASSERT (Divisor != 0);
if (Remainder != NULL) {
*Remainder = Dividend % Divisor;
}
return Dividend / Divisor;
}
UINT64
EFIAPI
DivU64x64Remainder (
IN UINT64 Dividend,
IN UINT64 Divisor,
OUT UINT64 *Remainder OPTIONAL
)
{
ASSERT (Divisor != 0);
if (Remainder != NULL) {
*Remainder = Dividend % Divisor;
}
return Dividend / Divisor;
}
UINT64
EFIAPI
LShiftU64 (
......
/** @file
Copyright (c) 2020, PMheart. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
**/
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/DebugLib.h>
VOID
EFIAPI
CpuBreakpoint (
VOID
)
{
ASSERT (FALSE);
while (TRUE);
}
VOID
EFIAPI
CpuPause (
VOID
)
{
}
VOID
EFIAPI
DisableInterrupts (
VOID
)
{
}
VOID
EFIAPI
EnableInterrupts (
VOID
)
{
}
UINT32
AsmCpuid (
UINT32 Index,
UINT32 *Eax,
UINT32 *Ebx,
UINT32 *Ecx,
UINT32 *Edx
)
{
UINT32 eax = 0, ebx = 0, ecx = 0, edx = 0;
asm ("cpuid\n"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "0" (Index));
if (Eax) *Eax = eax;
if (Ebx) *Ebx = ebx;
if (Ecx) *Ecx = ecx;
if (Edx) *Edx = edx;
return Index;
}
UINT32
AsmCpuidEx (
IN UINT32 Index,
IN UINT32 SubIndex,
OUT UINT32 *Eax, OPTIONAL
OUT UINT32 *Ebx, OPTIONAL
OUT UINT32 *Ecx, OPTIONAL
OUT UINT32 *Edx OPTIONAL
)
{
UINT32 eax = 0, ebx = 0, ecx = 0, edx = 0;
asm ("cpuid\n"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "0" (Index), "2" (SubIndex));
if (Eax) *Eax = eax;
if (Ebx) *Ebx = ebx;
if (Ecx) *Ecx = ecx;
if (Edx) *Edx = edx;
return Index;
}
UINT32
EFIAPI
AsmIncrementUint32 (
IN volatile UINT32 *Value
)
{
ASSERT (FALSE);
return 0;
}
UINT32
EFIAPI
AsmReadIntelMicrocodeRevision (
VOID
)
{
return 0;
}
UINTN
EFIAPI
AsmReadCr4 (
VOID
)
{
return 0;
}
UINT16
EFIAPI
AsmReadCs (
VOID
)
{
return 3;
}
UINTN
EFIAPI
AsmReadEflags (
VOID
)
{
return 0;
}
UINT64
EFIAPI
AsmReadMsr64 (
IN UINT32 Index
)
{
return 0;
}
UINT64
EFIAPI
AsmReadTsc (
VOID
)
{
return 0;
}
UINTN
EFIAPI
AsmWriteCr4 (
UINTN Cr4
)
{
return 0;
}
UINT64
EFIAPI
AsmWriteMsr64 (
IN UINT32 Index,
IN UINT64 Value
)
{
return 0;
}
UINT64
EFIAPI
AsmMsrAndThenOr64 (
IN UINT32 Index,
IN UINT64 AndData,
IN UINT64 OrData
)
{
//
// MSRs cannot be read at userspace level.
//
return 0;
}
VOID
EFIAPI
AsmDisableCache (
VOID
)
{
}
VOID
EFIAPI
AsmEnableCache (
VOID
)
{
}
VOID
EFIAPI
CpuFlushTlb (
VOID
)
{
}
UINT32
EFIAPI
IoRead32 (
IN UINTN Port
)
{
return 0;
}
UINT16
EFIAPI
MmioAnd16 (
IN UINTN Address,
IN UINT16 AndData
)
{
return 0;
}
UINT32
EFIAPI
MmioAnd32 (
IN UINTN Address,
IN UINT16 AndData
)
{
return 0;
}
UINT8
EFIAPI
MmioAnd8 (
IN UINTN Address,
IN UINT8 AndData
)
{
return 0;
}
UINT16
EFIAPI
MmioAndThenOr16 (
IN UINTN Address,
IN UINT16 AndData,
IN UINT16 OrData
)
{
return 0;
}
UINT32
EFIAPI
MmioAndThenOr32 (
IN UINTN Address,
IN UINT32 AndData,
IN UINT32 OrData
)
{
return 0;
}
UINT8
EFIAPI
MmioAndThenOr8 (
IN UINTN Address,
IN UINT8 AndData,
IN UINT8 OrData
)
{
return 0;
}
UINT16
EFIAPI
MmioBitFieldAnd16 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 AndData
)
{
return 0;
}
UINT32
EFIAPI
MmioBitFieldAnd32 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 AndData
)
{
return 0;
}
UINT8
EFIAPI
MmioBitFieldAnd8 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 AndData
)
{
return 0;
}
UINT16
EFIAPI
MmioBitFieldAndThenOr16 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 AndData,
IN UINT16 OrData
)
{
return 0;
}
UINT32
EFIAPI
MmioBitFieldAndThenOr32 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 AndData,
IN UINT32 OrData
)
{
return 0;
}
UINT8
EFIAPI
MmioBitFieldAndThenOr8 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 AndData,
IN UINT8 OrData
)
{
return 0;
}
UINT16
EFIAPI
MmioBitFieldOr16 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 OrData
)
{
return 0;
}
UINT32
EFIAPI
MmioBitFieldOr32 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 OrData
)
{
return 0;
}
UINT8
EFIAPI
MmioBitFieldOr8 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 OrData
)
{
return 0;
}
UINT16
EFIAPI
MmioBitFieldRead16 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit
)
{
return 0;
}
UINT32
EFIAPI
MmioBitFieldRead32 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit
)
{
return 0;
}
UINT8
EFIAPI
MmioBitFieldRead8 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit
)
{
return 0;
}
UINT16
EFIAPI
MmioBitFieldWrite16 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 Value
)
{
return 0;
}
UINT32
EFIAPI
MmioBitFieldWrite32 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 Value
)
{
return 0;
}
UINT8
EFIAPI
MmioBitFieldWrite8 (
IN UINTN Address,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 Value
)
{
return 0;
}
UINT16
EFIAPI
MmioOr16 (
IN UINTN Address,
IN UINT16 OrData
)
{
return 0;
}
UINT32
EFIAPI
MmioOr32 (
IN UINTN Address,
IN UINT32 OrData
)
{
return 0;
}
UINT8
EFIAPI
MmioOr8 (
IN UINTN Address,
IN UINT8 OrData
)
{
return 0;
}
UINT16
EFIAPI
MmioRead16 (
IN UINTN Address
)
{
return 0;
}
UINT32
EFIAPI
MmioRead32 (
IN UINTN Address
)
{
return 0;
}
UINT8
EFIAPI
MmioRead8 (
IN UINTN Address
)
{
return 0;
}
UINT16
EFIAPI
MmioWrite16 (
IN UINTN Address,
IN UINT16 Value
)
{
return 0;
}
UINT32
EFIAPI
MmioWrite32 (
IN UINTN Address,
IN UINT32 Value
)
{
return 0;
}
UINT8
EFIAPI
MmioWrite8 (
IN UINTN Address,
IN UINT8 Value
)
{
return 0;
}
......@@ -10,7 +10,7 @@ MKDIR := mkdir -p
ifeq ($(UDK_PATH),)
ifneq ($(PACKAGES_PATH),)
UDK_PATH = $(PACKAGES_PATH)
UDK_PATH := $(PACKAGES_PATH)
else
UDK_PATH ?= ../../UDK
endif
......@@ -22,9 +22,15 @@ else
DIST ?= $(shell uname)
endif
CFLAGS = -c -fshort-wchar -Wall -Wextra -Wno-implicit-fallthrough -Wno-unused-parameter
CFLAGS += -I../../User/Include
CFLAGS += -I../../Include/Acidanthera -I../../Include/Apple -I../../Include/Generic -I../../Include/Intel
#
# Primary architecture.
#
UDK_ARCH ?= X64
#
# Primary CFLAGS.
#
CFLAGS := -c -fshort-wchar -Wall -Wextra -Wno-implicit-fallthrough -Wno-unused-parameter -D EFIUSER
ifeq ($(DIST),Darwin)
CFLAGS += -mmacosx-version-min=10.6
......@@ -34,9 +40,6 @@ endif
ifeq ($(DIST),Windows)
SUFFIX := .exe
CFLAGS += -D_ISOC99_SOURCE=1
UDK_ARCH ?= Ia32
else
UDK_ARCH ?= X64
endif
ifeq ($(SANITIZE),1)
......@@ -60,44 +63,112 @@ else
STRIPFLAGS ?= -x
endif
#
# Search Paths.
#
CFLAGS += -I../../User/Include
CFLAGS += -I../../Include/Acidanthera -I../../Include/Apple -I../../Include/Apple/$(UDK_ARCH) -I../../Include/Generic -I../../Include/Intel -I../../Include/Microsoft
#
# Skip including UDK when suggesting STANDALONE mode.
#
ifneq ($(STANDALONE),1)
CFLAGS += -D NO_MSABI_VA_FUNCS -D OC_TARGET_DEBUG
CFLAGS += -I$(UDK_PATH)/MdePkg/Include -I$(UDK_PATH)/MdePkg/Include/Library -I$(UDK_PATH)/MdePkg/Include/$(UDK_ARCH)
CFLAGS += -I$(UDK_PATH)/MdePkg/Include -I$(UDK_PATH)/MdePkg/Include/Library -I$(UDK_PATH)/MdePkg/Include/$(UDK_ARCH) -I$(UDK_PATH)/MdePkg/Library/BaseLib
CFLAGS += -I$(UDK_PATH)/MdeModulePkg/Include
CFLAGS += -I$(UDK_PATH)/UefiCpuPkg/Include
#
# Compatibility headers.
#
CFLAGS += -include ../../User/Include/Pcd.h -include ../../User/Include/EfiVar.h
CFLAGS += -include ../../User/Include/Pcd.h -include ../../User/Include/GlobalVar.h
#
# UDK implementations.
#
OBJS += UefiLibPrint.o CpuDeadLoop.o BaseDebugPrintErrorLevelLib.o DebugLib.o PrintLib.o PrintLibInternal.o String.o SafeString.o SwapBytes16.o SwapBytes32.o LinkedList.o
OBJS += UefiLib.o UefiLibPrint.o CpuDeadLoop.o BaseDebugPrintErrorLevelLib.o DebugLib.o PrintLib.o PrintLibInternal.o String.o SafeString.o SwapBytes16.o SwapBytes32.o LinkedList.o HighBitSet32.o HighBitSet64.o MtrrLib.o GetPowerOfTwo32.o GetPowerOfTwo64.o Cpu.o BmpSupportLib.o SafeIntLib.o X86GetInterruptState.o PciLib.o PciExpressLib.o DevicePathUtilities.o UefiDevicePathLib.o DevicePathToText.o DevicePathFromText.o BitField.o CheckSum.o
#
# Customised/Simplified implementations at userspace level.
#
OBJS += BaseMemoryLib.o BootServices.o DebugBreak.o EfiVar.o UserMath.o Pcd.o
OBJS += BaseMemoryLib.o BootServices.o GlobalVar.o UserMath.o UserMisc.o Pcd.o
#
# OcGuardLib targets.
#
OBJS += BitOverflow.o NativeOverflow.o TripleOverflow.o
#
# OcSerializeLib targets.
#
OBJS += OcSerializeLib.o
#
# OcTemplateLib targets.
#
OBJS += OcTemplateLib.o
#
# OcXmlLib targets.
#
OBJS += OcXmlLib.o
#
# OcStringLib targets.
#
OBJS += OcAsciiLib.o OcUnicodeLib.o
#
# OcCryptoLib targets.
#
OBJS += RsaDigitalSign.o BigNumMontgomery.o BigNumPrimitives.o BigNumWordMul64.o Sha2.o SecureMem.o
#
# OcMachoLib targets.
#
OBJS += CxxSymbols.o Header.o Symbols.o Relocations.o
#
# OcAppleKeysLib targets.
#
OBJS += OcAppleKeysLib.o
#
# OcCpuLib targets.
#
OBJS += FrequencyDetect.o AppleCpuSupport.o OcCpuLib.o
#
# OcMiscLib targets.
#
OBJS += Math.o ProtocolSupport.o
#
# Add source searchpath for transparent compilation.
# This way make will find any file in path in VPATH and apply "%.o: %.c" rule.
#
VPATH += :$(UDK_PATH)/MdePkg/Library/UefiLib:$\
$(UDK_PATH)/MdePkg/Library/BaseLib:$\
$(UDK_PATH)/MdePkg/Library/BaseDebugPrintErrorLevelLib:$\
$(UDK_PATH)/MdePkg/Library/UefiDebugLibConOut:$\
$(UDK_PATH)/MdePkg/Library/BasePrintLib:$\
$(UDK_PATH)/MdePkg/Library/BasePrintLib:$\
../../User/Library:$\
../../Library/OcGuardLib
VPATH += :$(UDK_PATH)/MdePkg/Library/UefiLib:$\
$(UDK_PATH)/MdePkg/Library/BaseLib:$\
$(UDK_PATH)/MdePkg/Library/BaseLib/$(UDK_ARCH):$\
$(UDK_PATH)/MdePkg/Library/BaseDebugPrintErrorLevelLib:$\
$(UDK_PATH)/MdePkg/Library/UefiDebugLibConOut:$\
$(UDK_PATH)/MdePkg/Library/BasePrintLib:$\
$(UDK_PATH)/MdePkg/Library/BaseSafeIntLib:$\
$(UDK_PATH)/MdePkg/Library/BasePciLibPciExpress:$\
$(UDK_PATH)/MdePkg/Library/BasePciExpressLib:$\
$(UDK_PATH)/MdePkg/Library/UefiDevicePathLib:$\
$(UDK_PATH)/MdeModulePkg/Library/BaseBmpSupportLib:$\
$(UDK_PATH)/UefiCpuPkg/Library/MtrrLib:$\
../../Library/OcGuardLib:$\
../../Library/OcSerializeLib:$\
../../Library/OcTemplateLib:$\
../../Library/OcXmlLib:$\
../../Library/OcStringLib:$\
../../Library/OcCryptoLib:$\
../../Library/OcCryptoLib/$(UDK_ARCH):$\
../../Library/OcMachoLib:$\
../../Library/OcAppleKeysLib:$\
../../Library/OcCpuLib:$\
../../Library/OcMiscLib
endif
#
# Miscellaneous implementations that do not depend on UDK.
#
VPATH += ../../User/Library:$
OBJS += File.o
#
# Directory where objects will be produced.
# As well, OBJS will be prepended with actual paths.
#
OUT_DIR := $(DIST)_$(UDK_ARCH)
OBJS := $(addprefix $(OUT_DIR)/,$(OBJS))
......@@ -108,8 +179,8 @@ $(OUT_DIR)/%.o: %.c
all: $(PRODUCT)
$(PRODUCT): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $(PRODUCT)
$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(PRODUCT)
$(STRIP) $(STRIPFLAGS) $(PRODUCT)
clean:
rm -rf $(OUT_DIR) $(PRODUCT)
rm -rf $(OUT_DIR) $(PRODUCT) $(PRODUCT).exe
......@@ -4,17 +4,9 @@
# SPDX-License-Identifier: BSD-3-Clause
##
PRODUCT = AppleEfiSignTool$(SUFFIX)
OBJS = main.o \
AppleEfiBinary.o \
Sha2.o \
BigNumWordMul64.o \
BigNumPrimitives.o \
BigNumMontgomery.o \
RsaDigitalSign.o \
SecureMem.o \
OcAppleKeysLib.o
VPATH = ../../Library/OcCryptoLib:$\
../../Library/OcCryptoLib/Ia32:$\
../../Library/OcAppleKeysLib
PROJECT = AppleEfiSignTool
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o \
AppleEfiBinary.o
VPATH = ../../Library/OcCryptoLib
include ../../User/Makefile
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PRODUCT = ConfigValidity$(SUFFIX)
OBJS = ConfigValidity.o \
OcConfigurationLib.o \
OcTemplateLib.o \
OcSerializeLib.o \
OcXmlLib.o \
OcAsciiLib.o
VPATH = ../../Library/OcConfigurationLib:$\
../../Library/OcTemplateLib:$\
../../Library/OcSerializeLib:$\
../../Library/OcXmlLib:$\
../../Library/OcStringLib
include ../../User/Makefile
......@@ -5,6 +5,7 @@
##
STANDALONE = 1
PRODUCT = EfiResTool$(SUFFIX)
OBJS = EfiResTool.o
PROJECT = EfiResTool
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
CC ?= gcc
CFLAGS=-Wall -Wextra -pedantic -O3 -I/usr/local/opt/openssl/include -I/opt/local/include
LDFLAGS=-L/usr/local/opt/openssl/lib -L/opt/local/lib
LDLIBS=-lcrypto
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
all: RsaTool
STANDALONE = 1
PROJECT = RsaTool
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
clean:
rm RsaTool
CFLAGS += -I/usr/local/opt/openssl/include -I/opt/local/include
LDFLAGS += -L/usr/local/opt/openssl/lib -L/opt/local/lib
LDLIBS += -lcrypto
......@@ -5,18 +5,13 @@
SPDX-License-Identifier: BSD-3-Clause
**/
/*
clang -g -fshort-wchar -fsanitize=undefined,address -I$WORKSPACE/Public/Vendor/Acidanthera/OcSupportPkg/Include -I$WORKSPACE/Public/Vendor/Acidanthera/OcSupportPkg/TestsUser/Include -I$WORKSPACE/Public/edk2/MdePkg/Include/ -I$WORKSPACE/Public/edk2/MdeModulePkg/Include/ -include $WORKSPACE/Public/Vendor/Acidanthera/OcSupportPkg/TestsUser/Include/Base.h BitmapFontUser.c BitmapFont.c Images/Helvetica_bmp.c Images/Helvetica_fnt.c $WORKSPACE/Public/Vendor/Acidanthera/OcSupportPkg/Library/BaseBmpSupportLib/BmpSupportLib.c -o Bmf
*/
#include <stdio.h>
#include <File.h>
#include <Base.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/BmpSupportLib.h>
#include "GUI.h"
#include "BmfLib.h"
EFI_STATUS
......@@ -58,23 +53,29 @@ GuiBmpToImage (
return EFI_SUCCESS;
}
int main (void)
int main (int argc, char** argv)
{
BOOLEAN Result;
GUI_FONT_CONTEXT HelveticaContext;
GUI_FONT_CONTEXT Context;
uint8_t *FontImage;
uint32_t FontImageSize;
uint8_t *FontMetrics;
uint32_t FontMetricsSize;
GUI_IMAGE Label;
EFI_STATUS Status;
VOID *BmpImage;
UINT32 BmpImageSize;
FILE *write_ptr;
Result = GuiInitializeFontHelvetica (&HelveticaContext);
FontImage = readFile (argv[1], &FontImageSize);
FontMetrics = readFile (argv[2], &FontMetricsSize);
Result = GuiFontConstruct (&Context, FontImage, FontImageSize, FontMetrics, FontMetricsSize);
if (!Result) {
DEBUG ((DEBUG_WARN, "BMF: Helvetica failed\n"));
return -1;
}
Result = GuiGetLabel (&Label, &HelveticaContext, L"Time Machine HD", sizeof ("Time Machine HD") - 1);
Result = GuiGetLabel (&Label, &Context, L"Time Machine HD", sizeof ("Time Machine HD") - 1, FALSE);
if (!Result) {
DEBUG ((DEBUG_WARN, "BMF: label failed\n"));
return -1;
......@@ -103,7 +104,7 @@ int main (void)
FreePool (BmpImage);
FreePool (HelveticaContext.FontImage.Buffer);
FreePool (Context.FontImage.Buffer);
FreePool (Label.Buffer);
return 0;
......
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT = Bmf
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
#
# From OpenCanopy.
#
OBJS += BitmapFont.o OpenCanopy.o InputSimTextIn.o InputSimAbsPtr.o OutputStGop.o BootPicker.o GuiApp.o
#
# From OpenCore.
#
OBJS += OcPng.o lodepng.o OcCompressionLib.o OcTimerLib.o OcAppleKeyMapLib.o HotKeySupport.o BootArguments.o BootEntryInfo.o OcAppleBootPolicyLib.o OcDevicePathLib.o DebugPrint.o GetFileInfo.o GetVolumeLabel.o ReadFile.o OpenFile.o FileProtocol.o OcStorageLib.o
VPATH = ../../Platform/OpenCanopy:$\
../../Platform/OpenCanopy/Input:$\
../../Platform/OpenCanopy/Output:$\
../../Platform/OpenCanopy/Views:$\
../../Library/OcPngLib:$\
../../Library/OcCompressionLib:$\
../../Library/OcTimerLib:$\
../../Library/OcAppleKeyMapLib:$\
../../Library/OcBootManagementLib:$\
../../Library/OcAppleBootPolicyLib:$\
../../Library/OcDevicePathLib:$\
../../Library/OcStringLib:$\
../../Library/OcDebugLogLib:$\
../../Library/OcFileLib:$\
../../Library/OcStorageLib:$\
../../Library/OcTemplateLib
include ../../User/Makefile
CFLAGS += -I../../Platform/OpenCanopy
......@@ -13,11 +13,10 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <File.h>
/**
clang -g -fsanitize=undefined,address -Wno-incompatible-pointer-types-discards-qualifiers -fshort-wchar -I../Include -I../../Include -I../../../MdePkg/Include/ -I../../../EfiPkg/Include/ -include ../Include/Base.h DiskImage.c ../../Library/OcXmlLib/OcXmlLib.c ../../Library/OcTemplateLib/OcTemplateLib.c ../../Library/OcSerializeLib/OcSerializeLib.c ../../Library/OcMiscLib/Base64Decode.c ../../Library/OcStringLib/OcAsciiLib.c ../../Library/OcAppleDiskImageLib/OcAppleDiskImageLib.c ../../Library/OcAppleDiskImageLib/OcAppleDiskImageLibInternal.c ../../Library/OcMiscLib/DataPatcher.c ../../Library/OcCompressionLib/zlib/zlib_uefi.c ../../Library/OcCompressionLib/zlib/adler32.c ../../Library/OcCompressionLib/zlib/deflate.c ../../Library/OcCompressionLib/zlib/crc32.c ../../Library/OcCompressionLib/zlib/compress.c ../../Library/OcCompressionLib/zlib/infback.c ../../Library/OcCompressionLib/zlib/inffast.c ../../Library/OcCompressionLib/zlib/inflate.c ../../Library/OcCompressionLib/zlib/inftrees.c ../../Library/OcCompressionLib/zlib/trees.c ../../Library/OcCompressionLib/zlib/uncompr.c ../../Library/OcCryptoLib/Sha256.c ../../Library/OcCryptoLib/Rsa2048Sha256.c ../../Library/OcAppleKeysLib/OcAppleKeysLib.c ../../Library/OcAppleChunklistLib/OcAppleChunklistLib.c ../../Library/OcAppleRamDiskLib/OcAppleRamDiskLib.c ../../Library/OcFileLib/ReadFile.c ../../Library/OcFileLib/FileProtocol.c -o DiskImage
......@@ -29,25 +28,6 @@ rm -rf DICT fuzz*.log ; mkdir DICT ; UBSAN_OPTIONS='halt_on_error=1' ./DiskImage
EFI_GUID gOcVendorVariableGuid;
uint8_t *readFile(const char *str, long *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize + 1);
fread(string, fsize, 1, f);
fclose(f);
string[fsize] = 0;
*size = fsize;
return string;
}
#ifdef FUZZING_TEST
#define main no_main
#include <sanitizer/asan_interface.h>
......@@ -72,11 +52,11 @@ int main (int argc, char *argv[]) {
for (int i = 1; i < (argc - 1); i+=2) {
int DmgContextValid = 0;
uint8_t *Dmg = NULL;
long DmgSize;
uint8_t *Dmg = NULL;
uint32_t DmgSize;
uint8_t *Chunklist = NULL;
long ChunklistSize;
uint8_t *Chunklist = NULL;
uint32_t ChunklistSize;
uint8_t *UncompDmg = NULL;
uint32_t UncompSize;
......
......@@ -3,41 +3,27 @@
# SPDX-License-Identifier: BSD-3-Clause
##
PRODUCT = DiskImage$(SUFFIX)
OBJS = DiskImage.o \
PROJECT = DiskImage
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o \
FileDummy.o \
OcAppleChunklistLib.o \
OcAppleDiskImageLib.o \
OcAppleDiskImageLibInternal.o \
OcXmlLib.o \
Sha2.o \
BigNumWordMul64.o \
BigNumPrimitives.o \
BigNumMontgomery.o \
RsaDigitalSign.o \
SecureMem.o \
OcAppleKeysLib.o \
OcAsciiLib.o \
OcAppleRamDiskLib.o \
adler32.o \
compress.o \
crc32.o \
deflate.o \
infback.o \
inffast.o \
inflate.o \
inftrees.o \
trees.o \
uncompr.o \
zlib_uefi.o
adler32.o \
compress.o \
crc32.o \
deflate.o \
infback.o \
inffast.o \
inflate.o \
inftrees.o \
trees.o \
uncompr.o \
zlib_uefi.o
VPATH = ../../Library/OcAppleChunklistLib:$\
../../Library/OcAppleDiskImageLib:$\
../../Library/OcAppleRamDiskLib:$\
../../Library/OcXmlLib:$\
../../Library/OcCryptoLib:$\
../../Library/OcCryptoLib/Ia32:$\
../../Library/OcAppleKeysLib:$\
../../Library/OcStringLib:$\
../../Library/OcFileLib:$\
../../Library/OcCompressionLib/zlib
include ../../User/Makefile
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT = HelloWorld
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <File.h>
#include <Base.h>
......@@ -47,23 +51,6 @@ void InternalDebugEnvInfo (
);
}
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize);
fread(string, fsize, 1, f);
fclose(f);
*size = fsize;
return string;
}
int verifyImg4 (char *imageName, char *manifestName, char *type)
{
void *Manifest, *Image;
......
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT = Img4
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
#
# From OcAppleImg4Lib.
#
OBJS += OcAppleImg4Lib.o DER_Img4Manifest.o DER_Keys.o DER_Decode.o DER_CertCrl.o oids.o Img4oids.o
VPATH = ../../Library/OcAppleImg4Lib:$\
../../Library/OcAppleImg4Lib/libDERImg4:$\
../../Library/OcAppleImg4Lib/libDER:$\
include ../../User/Makefile
CFLAGS += -I../../Library/OcAppleImg4Lib
......@@ -20,11 +20,10 @@
#include <Library/OcAppleKernelLib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <File.h>
/*
for fuzzing (TODO):
clang-mp-7.0 -DFUZZING_TEST=1 -g -fsanitize=undefined,address,fuzzer -Wno-incompatible-pointer-types-discards-qualifiers -I../Include -I../../Include -I../../../MdePkg/Include/ -I../../../EfiPkg/Include/ -include ../Include/Base.h Prelinked.c ../../Library/OcXmlLib/OcXmlLib.c ../../Library/OcTemplateLib/OcTemplateLib.c ../../Library/OcSerializeLib/OcSerializeLib.c ../../Library/OcMiscLib/Base64Decode.c ../../Library/OcStringLib/OcAsciiLib.c ../../Library/OcMachoLib/CxxSymbols.c ../../Library/OcMachoLib/Header.c ../../Library/OcMachoLib/Relocations.c ../../Library/OcMachoLib/Symbols.c ../../Library/OcAppleKernelLib/PrelinkedContext.c ../../Library/OcAppleKernelLib/PrelinkedKext.c ../../Library/OcAppleKernelLib/KextPatcher.c ../../Library/OcMiscLib/DataPatcher.c ../../Library/OcAppleKernelLib/Link.c ../../Library/OcAppleKernelLib/Vtables.c ../../Library/OcAppleKernelLib/KernelReader.c ../../Library/OcCompressionLib/lzss/lzss.c ../../Library/OcCompressionLib/lzvn/lzvn.c ../../Tests/KernelTest/Lilu.c ../../Tests/KernelTest/Vsmc.c -o Prelinked
......@@ -208,25 +207,6 @@ long long current_timestamp() {
return milliseconds;
}
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize + 1);
fread(string, fsize, 1, f);
fclose(f);
string[fsize] = 0;
*size = fsize;
return string;
}
#if 0
STATIC
UINT8
......
......@@ -3,8 +3,9 @@
# SPDX-License-Identifier: BSD-3-Clause
##
PRODUCT = KextInject$(SUFFIX)
OBJS = KextInject.o \
PROJECT = KextInject
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o \
Lilu.o \
Vsmc.o \
KextPatcher.o \
......@@ -14,19 +15,10 @@ OBJS = KextInject.o \
Link.o \
KernelReader.o \
DataPatcher.o \
CxxSymbols.o \
Header.o \
Symbols.o \
Relocations.o \
OcXmlLib.o \
OcAsciiLib.o \
lzss.o \
lzvn.o
VPATH = ../../Library/OcAppleKernelLib:$\
../../Library/OcMiscLib:$\
../../Library/OcMachoLib:$\
../../Library/OcXmlLib:$\
../../Library/OcStringLib:$\
../../Library/OcCompressionLib/lzss:$\
../../Library/OcCompressionLib/lzvn
include ../../User/Makefile
......@@ -12,15 +12,18 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcMiscLib.h>
#include <string.h>
#include <sys/time.h>
/*
clang -g -fsanitize=undefined,address -I../Include -I../../Include -I../../../MdePkg/Include/ -include ../Include/Base.h -I../../../EfiPkg/Include/ Macho.c ../../Library/OcMiscLib/Base64Decode.c ../../Library/OcStringLib/OcAsciiLib.c ../../Library/OcMachoLib/CxxSymbols.c ../../Library/OcMachoLib/Header.c ../../Library/OcMachoLib/Relocations.c ../../Library/OcMachoLib/Symbols.c -o Macho
#include <File.h>
for fuzzing:
/*
for fuzzing (TODO):
clang-mp-7.0 -Dmain=__main -g -fsanitize=undefined,address,fuzzer -I../Include -I../../Include -I../../../MdePkg/Include/ -include ../Include/Base.h -I../../../EfiPkg/Include/ Macho.c ../../Library/OcMiscLib/Base64Decode.c ../../Library/OcStringLib/OcAsciiLib.c ../../Library/OcMachoLib/CxxSymbols.c ../../Library/OcMachoLib/Header.c ../../Library/OcMachoLib/Relocations.c ../../Library/OcMachoLib/Symbols.c -o Macho
rm -rf DICT fuzz*.log ; mkdir DICT ; cp /System/Library/Kernels/kernel DICT ; ./Macho -rss_limit_mb=4096M -jobs=4 DICT
......@@ -29,25 +32,6 @@
rm -rf Macho.dSYM DICT fuzz*.log Macho
*/
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize + 1);
fread(string, fsize, 1, f);
fclose(f);
string[fsize] = 0;
*size = fsize;
return string;
}
MACH_HEADER_64 Header;
MACH_SECTION_64 Sect;
MACH_SEGMENT_COMMAND_64 Seg;
......@@ -138,7 +122,8 @@ static int FeedMacho(void *file, uint32_t size) {
}
char out[64];
if (MachoGetClassNameFromSuperMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)) {
if (MachoSymbolNameIsSmcp64 (&Context, MachoGetSymbolName64 (&Context, Symbol))
&& MachoGetClassNameFromSuperMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)) {
code++;
}
......@@ -153,7 +138,8 @@ static int FeedMacho(void *file, uint32_t size) {
code++;
}
if (MachoGetClassNameFromMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)
if (MachoSymbolNameIsMetaclassPointer64 (&Context, MachoGetSymbolName64 (&Context, Symbol))
&& MachoGetClassNameFromMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)
&& !AsciiStrCmp("SomeReallyLongStringJustInCaseToCheckIt", out)) {
code++;
}
......@@ -241,7 +227,8 @@ static int FeedMacho(void *file, uint32_t size) {
}
char out[64];
if (MachoGetClassNameFromSuperMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)
if (MachoSymbolNameIsSmcp64 (&Context, MachoGetSymbolName64 (&Context, Symbol))
&& MachoGetClassNameFromSuperMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)
&& !AsciiStrCmp("SomeReallyLongStringJustInCaseToCheckIt", out)) {
code++;
}
......@@ -257,7 +244,8 @@ static int FeedMacho(void *file, uint32_t size) {
code++;
}
if (MachoGetClassNameFromMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)
if (MachoSymbolNameIsMetaclassPointer64 (&Context, MachoGetSymbolName64 (&Context, Symbol))
&& MachoGetClassNameFromMetaClassPointer (&Context, MachoGetSymbolName64 (&Context, Symbol), sizeof(out), out)
&& !AsciiStrCmp("SomeReallyLongStringJustInCaseToCheckIt", out)) {
code++;
}
......@@ -283,7 +271,7 @@ static int FeedMacho(void *file, uint32_t size) {
}
for (size_t i = 0x1000000; i < 0x100000000; i+= 0x1000000) {
if ((Symbol = MachoGetSymbolByRelocationOffset64 (&Context, i))) {
if (MachoGetSymbolByRelocationOffset64 (&Context, i, &Symbol)) {
if (!AsciiStrCmp (MachoGetSymbolName64 (&Context, Symbol), "__hack")) {
code++;
}
......
......@@ -3,6 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause
##
PRODUCT = HelloWorld$(SUFFIX)
OBJS = main.o
PROJECT = Macho
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT = RsaPreprocess
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
CFLAGS += -I../../Library/OcCryptoLib
......@@ -12,10 +12,12 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
clang -g -fsanitize=undefined,address -I../Include -I../../Include -I../../Library/OcCryptoLib -I../../../MdePkg/Include/ -I../../../EfiPkg/Include/ -include ../Include/Base.h RsaPreprocess.c ../../Library/OcAppleKeysLib/OcAppleKeysLib.c ../../Library/OcCryptoLib/BigNumMontgomery.c ../../Library/OcCryptoLib/BigNumPrimitives.c ../../Library/OcCryptoLib/X64/BigNumWordMul64.c -o RsaPreprocess
**/
#include <File.h>
#include <Base.h>
......@@ -24,24 +26,6 @@ clang -g -fsanitize=undefined,address -I../Include -I../../Include -I../../Libr
#include <BigNumLib.h>
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize);
fread(string, fsize, 1, f);
fclose(f);
*size = fsize;
return string;
}
int verifyRsa (CONST OC_RSA_PUBLIC_KEY *PublicKey, char *Name)
{
OC_BN_WORD N0Inv;
......@@ -81,7 +65,7 @@ int main(int argc, char *argv[]) {
OC_RSA_PUBLIC_KEY *PublicKey;
uint32_t PkSize;
for (Index = 1; Index < argc; ++Index) {
for (Index = 1; (int) Index < argc; ++Index) {
PublicKey = (OC_RSA_PUBLIC_KEY *)readFile (argv[Index], &PkSize);
if (PublicKey == NULL) {
printf ("read error\n");
......@@ -92,7 +76,7 @@ int main(int argc, char *argv[]) {
free (PublicKey);
}
for (Index = 0; Index < ARRAY_SIZE (PkDataBase); ++Index) {
for (Index = 0; (unsigned long) Index < ARRAY_SIZE (PkDataBase); ++Index) {
verifyRsa (PkDataBase[Index].PublicKey, "inbuilt");
}
......
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT = Smbios
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
#
# From OpenCore.
#
OBJS += SmbiosPatch.o SmbiosInternal.o DebugSmbios.o LegacyRegionLock.o LegacyRegionUnLock.o
VPATH = ../../Library/OcSmbiosLib:$\
../../Library/OcMemoryLib
include ../../User/Makefile
......@@ -12,16 +12,25 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <File.h>
#include <GlobalVar.h>
#include <BootServices.h>
#include <Pcd.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcSmbiosLib.h>
#include <Library/OcMiscLib.h>
#include <IndustryStandard/AppleSmBios.h>
#include <sys/time.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
/*
clang -g -fshort-wchar -DCONFIG_TABLE_INSTALLER=NilInstallConfigurationTableCustom -fsanitize=undefined,address -I../Include -I../../Include -I../../../EfiPkg/Include/ -I../../../MdePkg/Include/ -I../../../UefiCpuPkg/Include/ -include ../Include/Base.h Smbios.c ../../Library/OcSmbiosLib/DebugSmbios.c ../../Library/OcSmbiosLib/SmbiosInternal.c ../../Library/OcSmbiosLib/SmbiosPatch.c ../../Library/OcStringLib/OcAsciiLib.c ../../Library/OcMiscLib/LegacyRegionLock.c ../../Library/OcMiscLib/LegacyRegionUnlock.c ../../Library/OcCpuLib/OcCpuLib.c -o Smbios
for fuzzing:
for fuzzing (TODO):
clang-mp-7.0 -fshort-wchar -DCONFIG_TABLE_INSTALLER=NilInstallConfigurationTableCustom -Dmain=__main -g -fsanitize=undefined,address,fuzzer -I../Include -I../../Include -I../../../EfiPkg/Include/ -I../../../MdePkg/Include/ -I../../../UefiCpuPkg/Include/ -include ../Include/Base.h Smbios.c ../../Library/OcSmbiosLib/DebugSmbios.c ../../Library/OcSmbiosLib/SmbiosInternal.c ../../Library/OcSmbiosLib/SmbiosPatch.c ../../Library/OcStringLib/OcAsciiLib.c ../../Library/OcMiscLib/LegacyRegionLock.c ../../Library/OcMiscLib/LegacyRegionUnlock.c ../../Library/OcCpuLib/OcCpuLib.c -o Smbios
rm -rf DICT fuzz*.log ; mkdir DICT ; cp Smbios.bin DICT ; ./Smbios -jobs=4 DICT
......@@ -29,35 +38,11 @@
rm -rf Smbios.dSYM DICT fuzz*.log Smbios
*/
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize + 1);
fread(string, fsize, 1, f);
fclose(f);
string[fsize] = 0;
*size = fsize;
return string;
}
EFI_GUID gEfiLegacyRegionProtocolGuid;
EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
EFI_GUID gEfiSmbios3TableGuid;
EFI_GUID gEfiSmbiosTableGuid;
EFI_GUID gOcCustomSmbiosTableGuid;
STATIC GUID SystemUUID = {0x5BC82C38, 0x4DB6, 0x4883, {0x85, 0x2E, 0xE7, 0x8D, 0x78, 0x0A, 0x6F, 0xE6}};
STATIC UINT8 BoardType = 0xA; // Motherboard (BaseBoardTypeMotherBoard)
STATIC UINT8 MemoryFormFactor = 0xD; // SODIMM, 0x9 for DIMM (MemoryFormFactorSodimm)
STATIC UINT8 ChassisType = 0xD; // All in one (MiscChassisTypeAllInOne)
STATIC UINT32 PlatformFeature = 1;
STATIC OC_SMBIOS_DATA SmbiosData = {
.BIOSVendor = NULL, // Do not change BIOS Vendor
.BIOSVersion = "134.0.0.0.0",
......@@ -85,44 +70,18 @@ STATIC OC_SMBIOS_DATA SmbiosData = {
.FirmwareFeatures = 0xE00FE137,
.FirmwareFeaturesMask = 0xFF1FFF3F,
.ProcessorType = NULL, // Will be calculated automatically
.PlatformFeature = 1
.PlatformFeature = &PlatformFeature
};
bool doDump = false;
_Thread_local uint32_t externalUsedPages = 0;
_Thread_local uint8_t externalBlob[EFI_PAGE_SIZE*TOTAL_PAGES];
_Thread_local SMBIOS_TABLE_ENTRY_POINT gSmbios;
_Thread_local SMBIOS_TABLE_3_0_ENTRY_POINT gSmbios3;
EFI_STATUS EfiGetSystemConfigurationTable (EFI_GUID *TableGuid, OUT VOID **Table) {
/*if (Table && TableGuid == &gEfiSmbiosTableGuid) {
*Table = &gSmbios;
return EFI_SUCCESS;
} else*/ if (Table && TableGuid == &gEfiSmbios3TableGuid) {
*Table = &gSmbios3;
return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
}
EFI_STATUS NilInstallConfigurationTableCustom(EFI_GUID *Guid, VOID *Table) {
printf("Set table %p, looking for %p\n", Guid, &gEfiSmbios3TableGuid);
if (Guid == &gEfiSmbios3TableGuid && doDump) {
SMBIOS_TABLE_3_0_ENTRY_POINT *Ep = (SMBIOS_TABLE_3_0_ENTRY_POINT *) Table;
(void)remove("out.bin");
FILE *fh = fopen("out.bin", "wb");
if (fh != NULL) {
fwrite((void *)Ep->TableAddress, Ep->TableMaximumSize, 1, fh);
fclose(fh);
}
}
return EFI_SUCCESS;
}
SMBIOS_TABLE_ENTRY_POINT gSmbios;
SMBIOS_TABLE_3_0_ENTRY_POINT gSmbios3;
int main(int argc, char** argv) {
PcdGet32 (PcdFixedDebugPrintErrorLevel) |= DEBUG_INFO;
PcdGet32 (PcdDebugPrintErrorLevel) |= DEBUG_INFO;
uint32_t f;
uint8_t *b;
if ((b = readFile(argc > 1 ? argv[1] : "Smbios.bin", &f)) == NULL) {
......@@ -134,15 +93,42 @@ int main(int argc, char** argv) {
gSmbios3.TableMaximumSize = f;
gSmbios3.TableAddress = (uintptr_t)b;
gSmbios3.EntryPointLength = sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT);
EFI_STATUS Status;
Status = gBS->InstallConfigurationTable (&gEfiSmbios3TableGuid, &gSmbios3);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed to install gSmbios3 - %r", Status));
}
OC_CPU_INFO CpuInfo;
OcCpuScanProcessor (&CpuInfo);
CreateSmbios (
&SmbiosData,
1,
&CpuInfo
);
OC_SMBIOS_TABLE SmbiosTable;
Status = OcSmbiosTablePrepare (&SmbiosTable);
if (!EFI_ERROR (Status)) {
Status = OcSmbiosCreate (&SmbiosTable, &SmbiosData, OcSmbiosUpdateCreate, &CpuInfo);
if (!EFI_ERROR (Status)) {
SMBIOS_TABLE_3_0_ENTRY_POINT *patchedTablePtr = NULL;
Status = EfiGetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID **) &patchedTablePtr);
if (doDump && !EFI_ERROR (Status)) {
(void)remove("out.bin");
FILE *fh = fopen("out.bin", "wb");
if (fh != NULL) {
fwrite((const void *)patchedTablePtr->TableAddress, patchedTablePtr->TableMaximumSize, 1, fh);
fclose(fh);
} else {
DEBUG ((DEBUG_ERROR, "Failed to produce out.bin - %r", Status));
}
} else {
DEBUG ((DEBUG_ERROR, "EfiGetSystemConfigurationTable returns error - %r", Status));
}
} else {
DEBUG ((DEBUG_ERROR, "OcSmbiosCreate returns error - %r", Status));
}
OcSmbiosTableFree (&SmbiosTable);
} else {
DEBUG ((DEBUG_ERROR, "Failed to prepare smbios table - %r", Status));
}
return 0;
}
......@@ -153,7 +139,6 @@ INT32 LLVMFuzzerTestOneInput(CONST UINT8 *Data, UINTN Size) {
if (NewData) {
CopyMem (NewData, Data, Size);
externalUsedPages = 0;
gSmbios3.TableMaximumSize = Size;
gSmbios3.TableAddress = (uintptr_t)NewData;
gSmbios3.EntryPointLength = sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT);
......@@ -161,11 +146,13 @@ INT32 LLVMFuzzerTestOneInput(CONST UINT8 *Data, UINTN Size) {
OC_CPU_INFO CpuInfo;
OcCpuScanProcessor (&CpuInfo);
CreateSmbios (
&SmbiosData,
0,
&CpuInfo
);
EFI_STATUS Status;
OC_SMBIOS_TABLE SmbiosTable;
Status = OcSmbiosTablePrepare (&SmbiosTable);
if (!EFI_ERROR (Status)) {
OcSmbiosCreate (&SmbiosTable, &SmbiosData, OcSmbiosUpdateCreate, &CpuInfo);
OcSmbiosTableFree (&SmbiosTable);
}
FreePool (NewData);
}
......
......@@ -5,8 +5,9 @@
##
STANDALONE = 1
PRODUCT = disklabel$(SUFFIX)
OBJS = disklabel.o
PROJECT = disklabel
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
ifeq ($(DIST),Darwin)
......
......@@ -5,6 +5,7 @@
##
STANDALONE = 1
PRODUCT = icnspack$(SUFFIX)
OBJS = icnspack.o
PROJECT = icnspack
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
......@@ -4,8 +4,9 @@
# SPDX-License-Identifier: BSD-3-Clause
##
STANDALONE = 1
PRODUCT = macserial$(SUFFIX)
OBJS = macserial.o
PROJECT = macserial
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o
include ../../User/Makefile
ifeq ($(DIST),Darwin)
......
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT = ocvalidate
PRODUCT = $(PROJECT)$(SUFFIX)
OBJS = $(PROJECT).o \
OcConfigurationLib.o
VPATH = ../../Library/OcConfigurationLib
include ../../User/Makefile
......@@ -23,9 +23,7 @@
#include <Library/OcMiscLib.h>
#include <Library/OcConfigurationLib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <File.h>
#include <sys/time.h>
/*
......@@ -45,25 +43,6 @@ long long current_timestamp() {
return milliseconds;
}
uint8_t *readFile(const char *str, uint32_t *size) {
FILE *f = fopen(str, "rb");
if (!f) return NULL;
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *string = malloc(fsize + 1);
fread(string, fsize, 1, f);
fclose(f);
string[fsize] = 0;
*size = fsize;
return string;
}
int main(int argc, char** argv) {
uint32_t f;
uint8_t *b;
......@@ -77,7 +56,7 @@ int main(int argc, char** argv) {
OC_GLOBAL_CONFIG Config;
OcConfigurationInit (&Config, b, f);
DEBUG ((EFI_D_ERROR, "Done checking %a in %llu ms\n", argc > 1 ? argv[1] : "./config.plist", current_timestamp() - a));
DEBUG ((DEBUG_ERROR, "Done checking %a in %llu ms\n", argc > 1 ? argv[1] : "./config.plist", current_timestamp() - a));
OcConfigurationFree (&Config);
......
......@@ -3,14 +3,19 @@
buildutil() {
UTILS=(
"AppleEfiSignTool"
"ConfigValidity"
"EfiResTool"
"DiskImage"
"disklabel"
"HelloWorld"
"icnspack"
"KextInject"
"macserial"
"ocvalidate"
"TestBmf"
"TestDiskImage"
"TestHelloWorld"
"TestImg4"
"TestKextInject"
"TestMacho"
"TestRsaPreprocess"
"TestSmbios"
)
if [ "$HAS_OPENSSL_BUILD" = "1" ]; then
......@@ -31,8 +36,8 @@ buildutil() {
if [ "$(which i686-w64-mingw32-gcc)" != "" ]; then
echo "Building ${util} for Windows..."
CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make clean || exit 1
CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make || exit 1
UDK_ARCH=Ia32 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make clean || exit 1
UDK_ARCH=Ia32 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip DIST=Windows make || exit 1
fi
cd - || exit 1
done
......@@ -138,7 +143,6 @@ package() {
cp "${selfdir}/Changelog.md" tmp/Docs/ || exit 1
cp -r "${selfdir}/Docs/AcpiSamples/" tmp/Docs/AcpiSamples/ || exit 1
utilScpts=(
"LegacyBoot"
"CreateVault"
......@@ -153,7 +157,7 @@ package() {
buildutil || exit 1
utils=(
"macserial"
"ConfigValidity"
"ocvalidate"
"disklabel"
"icnspack"
)
......@@ -161,8 +165,8 @@ package() {
dest="tmp/Utilities/${util}"
mkdir -p "${dest}" || exit 1
bin="${selfdir}/Utilities/${util}/${util}"
binEXE="${selfdir}/Utilities/${util}/${util}.exe"
cp "${bin}" "${dest}" || exit 1
binEXE="${bin}.exe"
if [ -f "${binEXE}" ]; then
cp "${binEXE}" "${dest}" || exit 1
fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册