Add Find/Replace with mask tests.

Improve unit test framework.
This commit is contained in:
jief666 2020-10-12 17:49:43 +03:00
parent d2bec9ba0c
commit a2ffdf8642
30 changed files with 1208 additions and 314 deletions

View File

@ -0,0 +1,25 @@
//
// Base.h
// cpp_tests
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef Base_h
#define Base_h
#include <Library/ProcessorBind.h>
typedef __builtin_va_list VA_LIST;
#define VA_START(Marker, Parameter) __builtin_va_start (Marker, Parameter)
#define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
#define VA_END(Marker) __builtin_va_end (Marker)
#define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)
#endif /* Base_h */

View File

@ -0,0 +1,119 @@
//
// BaseLib.c
// cpp_tests UTF16 signed char
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#include "BaseLib.h"
#include "../../../rEFIt_UEFI/Platform/Posix/abort.h"
#if defined(__APPLE__) && defined(__clang__) && __WCHAR_MAX__ <= 0xFFFFu
// 2020-03 : w... function are broken under macOs and clang with short-wchar.
// Currently with clang version Apple LLVM version 10.0.0 (clang-1000.11.45.5) with High Sierra
// If it's fixed one day, a version number could added to this #ifdef
# include "xcode_utf_fixed.h"
#else
# include <wchar.h>
#endif
#include "../../../rEFIt_UEFI/cpp_foundation/unicode_conversions.h"
CHAR16* StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
{
return (CHAR16*)wcsstr_fixed(String, SearchString);
}
UINTN StrLen(const wchar_t* String)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return wchar_size_of_utf16_string(String);
#else
return wchar_size_of_utf32_string(String);
#endif
}
#if __WCHAR_MAX__ > 0xFFFFu
UINTN StrLen(const char16_t* String)
{
return wchar_size_of_utf16_string(String);
}
#endif
UINTN
EFIAPI
AsciiStrDecimalToUintn (
IN CONST CHAR8 *String
)
{
if ( !String ) panic("AsciiStrDecimalToUintn : !String");
UINTN value;
int ret = sscanf(String, "%llu", &value);
if ( ret == 0 ) return 0;
return value;
}
RETURN_STATUS
EFIAPI
AsciiStrDecimalToUintnS (
IN CONST CHAR8 *String,
OUT CHAR8 **EndPointer, OPTIONAL
OUT UINTN *Data
)
{
*Data = 0;
if ( !String ) return RETURN_INVALID_PARAMETER;
int ret = sscanf(String, "%llu", Data);
if ( EndPointer ) *EndPointer += ret;
if ( ret == 0 ) return RETURN_INVALID_PARAMETER;
return RETURN_SUCCESS;
}
UINTN EFIAPI AsciiStrHexToUintn(IN CONST CHAR8 *String)
{
if ( !String ) return RETURN_INVALID_PARAMETER;
UINTN value = 0;
int ret = sscanf(String, "%llx", &value);
if ( ret == 0 ) return 0;
return value;
}
///*
// * Not sure it works exactly like EDK. Espscially in case of error.
// */
//RETURN_STATUS
//EFIAPI
//AsciiStrHexToUint64S (
// IN CONST CHAR8 *String,
// OUT CHAR8 **EndPointer, OPTIONAL
// OUT UINT64 *Data
// )
//{
//(void)EndPointer;
// if ( !String ) return RETURN_INVALID_PARAMETER;
// int ret = sscanf(String, "%llx", Data);
// if ( ret == 0 ) return 0;
// return EFI_SUCCESS;
//}
UINT64
EFIAPI
AsciiStrHexToUint64 (
IN CONST CHAR8 *String
)
{
if ( !String ) return RETURN_INVALID_PARAMETER;
UINTN value = 0;
int ret = sscanf(String, "%llx", &value);
if ( ret == 0 ) return 0;
return value;
}

View File

@ -0,0 +1,75 @@
//
// BaseLib.h
// cpp_tests UTF16 signed char
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef BaseLib_h
#define BaseLib_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <Uefi.h>
//UINTN StrLen(const char16_t* String);
UINTN StrLen(const wchar_t* String);
//int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString);
//int StrnCmp(const wchar_t* FirstString, const wchar_t* SecondString, UINTN Length);
//UINTN StrLen(const wchar_t* String);
//UINTN AsciiStrLen(const char* String);
//INTN AsciiStrCmp (const char *FirstString,const char *SecondString);
CHAR16* StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString);
UINTN
EFIAPI
AsciiStrDecimalToUintn (
IN CONST CHAR8 *String
);
RETURN_STATUS
EFIAPI
AsciiStrDecimalToUintnS (
IN CONST CHAR8 *String,
OUT CHAR8 **EndPointer, OPTIONAL
OUT UINTN *Data
);
RETURN_STATUS
EFIAPI
AsciiStrHexToUintnS (
IN CONST CHAR8 *String,
OUT CHAR8 **EndPointer, OPTIONAL
OUT UINTN *Data
);
UINTN
EFIAPI
AsciiStrHexToUintn (
IN CONST CHAR8 *String
);
//RETURN_STATUS
//EFIAPI
//AsciiStrHexToUint64S (
// IN CONST CHAR8 *String,
// OUT CHAR8 **EndPointer, OPTIONAL
// OUT UINT64 *Data
// );
UINT64
EFIAPI
AsciiStrHexToUint64 (
IN CONST CHAR8 *String
);
#ifdef __cplusplus
}
#endif
#endif /* BaseLib_h */

View File

@ -0,0 +1,32 @@
//
// BaseMemoryLib.c
// cpp_tests UTF16 signed char
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#include "BaseMemoryLib.h"
#include <memory.h>
void* SetMem(void *Destination, UINTN Length, UINT8 c)
{
return memset(Destination, c, (size_t)Length);
}
INTN CompareMem(const void* DestinationBuffer, const void* SourceBuffer, UINTN Length)
{
return memcmp(SourceBuffer, DestinationBuffer, Length);
}
void* CopyMem(void *Destination, const void *Source, UINTN Length)
{
return memmove(Destination, Source, (size_t)Length);
}
void* ZeroMem(void *Destination, UINTN Length)
{
return memset(Destination, 0, (size_t)Length);
}

View File

@ -0,0 +1,507 @@
//
// BaseMemoryLib.h
// cpp_tests UTF16 signed char
//
// Created by jief666 on 12/10/2020.
// Copyright © 2020 jief666. All rights reserved.
//
/** @file
Provides copy memory, fill memory, zero memory, and GUID functions.
The Base Memory Library provides optimized implementations for common memory-based operations.
These functions should be used in place of coding your own loops to do equivalent common functions.
This allows optimized library implementations to help increase performance.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __BASE_MEMORY_LIB__
#define __BASE_MEMORY_LIB__
#ifdef __cplusplus
extern "C" {
#endif
#include <Uefi.h>
/**
Copies a source buffer to a destination buffer, and returns the destination buffer.
This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
DestinationBuffer. The implementation must be reentrant, and it must handle the case
where SourceBuffer overlaps DestinationBuffer.
If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
@param DestinationBuffer The pointer to the destination buffer of the memory copy.
@param SourceBuffer The pointer to the source buffer of the memory copy.
@param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
@return DestinationBuffer.
**/
VOID *
EFIAPI
CopyMem (
OUT VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
);
/**
Fills a target buffer with a byte value, and returns the target buffer.
This function fills Length bytes of Buffer with Value, and returns Buffer.
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The memory to set.
@param Length The number of bytes to set.
@param Value The value with which to fill Length bytes of Buffer.
@return Buffer.
**/
VOID *
EFIAPI
SetMem (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
);
/**
Fills a target buffer with a 16-bit value, and returns the target buffer.
This function fills Length bytes of Buffer with the 16-bit value specified by
Value, and returns Buffer. Value is repeated every 16-bits in for Length
bytes of Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
If Length is not aligned on a 16-bit boundary, then ASSERT().
@param Buffer The pointer to the target buffer to fill.
@param Length The number of bytes in Buffer to fill.
@param Value The value with which to fill Length bytes of Buffer.
@return Buffer.
**/
VOID *
EFIAPI
SetMem16 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
);
/**
Fills a target buffer with a 32-bit value, and returns the target buffer.
This function fills Length bytes of Buffer with the 32-bit value specified by
Value, and returns Buffer. Value is repeated every 32-bits in for Length
bytes of Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
If Length is not aligned on a 32-bit boundary, then ASSERT().
@param Buffer The pointer to the target buffer to fill.
@param Length The number of bytes in Buffer to fill.
@param Value The value with which to fill Length bytes of Buffer.
@return Buffer.
**/
VOID *
EFIAPI
SetMem32 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
);
/**
Fills a target buffer with a 64-bit value, and returns the target buffer.
This function fills Length bytes of Buffer with the 64-bit value specified by
Value, and returns Buffer. Value is repeated every 64-bits in for Length
bytes of Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
If Length is not aligned on a 64-bit boundary, then ASSERT().
@param Buffer The pointer to the target buffer to fill.
@param Length The number of bytes in Buffer to fill.
@param Value The value with which to fill Length bytes of Buffer.
@return Buffer.
**/
VOID *
EFIAPI
SetMem64 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
);
/**
Fills a target buffer with a value that is size UINTN, and returns the target buffer.
This function fills Length bytes of Buffer with the UINTN sized value specified by
Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length
bytes of Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
If Buffer is not aligned on a UINTN boundary, then ASSERT().
If Length is not aligned on a UINTN boundary, then ASSERT().
@param Buffer The pointer to the target buffer to fill.
@param Length The number of bytes in Buffer to fill.
@param Value The value with which to fill Length bytes of Buffer.
@return Buffer.
**/
VOID *
EFIAPI
SetMemN (
OUT VOID *Buffer,
IN UINTN Length,
IN UINTN Value
);
/**
Fills a target buffer with zeros, and returns the target buffer.
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the target buffer to fill with zeros.
@param Length The number of bytes in Buffer to fill with zeros.
@return Buffer.
**/
VOID *
EFIAPI
ZeroMem (
OUT VOID *Buffer,
IN UINTN Length
);
/**
Compares the contents of two buffers.
This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
value returned is the first mismatched byte in SourceBuffer subtracted from the first
mismatched byte in DestinationBuffer.
If Length > 0 and DestinationBuffer is NULL, then ASSERT().
If Length > 0 and SourceBuffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
@param DestinationBuffer The pointer to the destination buffer to compare.
@param SourceBuffer The pointer to the source buffer to compare.
@param Length The number of bytes to compare.
@return 0 All Length bytes of the two buffers are identical.
@retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
mismatched byte in DestinationBuffer.
**/
INTN
EFIAPI
CompareMem (
IN CONST VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
);
/**
Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
in the target buffer.
This function searches target the buffer specified by Buffer and Length from the lowest
address to the highest address for an 8-bit value that matches Value. If a match is found,
then a pointer to the matching byte in the target buffer is returned. If no match is found,
then NULL is returned. If Length is 0, then NULL is returned.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the target buffer to scan.
@param Length The number of bytes in Buffer to scan.
@param Value The value to search for in the target buffer.
@return A pointer to the matching byte in the target buffer, otherwise NULL.
**/
VOID *
EFIAPI
ScanMem8 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
);
/**
Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
in the target buffer.
This function searches target the buffer specified by Buffer and Length from the lowest
address to the highest address for a 16-bit value that matches Value. If a match is found,
then a pointer to the matching byte in the target buffer is returned. If no match is found,
then NULL is returned. If Length is 0, then NULL is returned.
If Length > 0 and Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
If Length is not aligned on a 16-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the target buffer to scan.
@param Length The number of bytes in Buffer to scan.
@param Value The value to search for in the target buffer.
@return A pointer to the matching byte in the target buffer, otherwise NULL.
**/
VOID *
EFIAPI
ScanMem16 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
);
/**
Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
in the target buffer.
This function searches target the buffer specified by Buffer and Length from the lowest
address to the highest address for a 32-bit value that matches Value. If a match is found,
then a pointer to the matching byte in the target buffer is returned. If no match is found,
then NULL is returned. If Length is 0, then NULL is returned.
If Length > 0 and Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
If Length is not aligned on a 32-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the target buffer to scan.
@param Length The number of bytes in Buffer to scan.
@param Value The value to search for in the target buffer.
@return A pointer to the matching byte in the target buffer, otherwise NULL.
**/
VOID *
EFIAPI
ScanMem32 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
);
/**
Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
in the target buffer.
This function searches target the buffer specified by Buffer and Length from the lowest
address to the highest address for a 64-bit value that matches Value. If a match is found,
then a pointer to the matching byte in the target buffer is returned. If no match is found,
then NULL is returned. If Length is 0, then NULL is returned.
If Length > 0 and Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
If Length is not aligned on a 64-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the target buffer to scan.
@param Length The number of bytes in Buffer to scan.
@param Value The value to search for in the target buffer.
@return A pointer to the matching byte in the target buffer, otherwise NULL.
**/
VOID *
EFIAPI
ScanMem64 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
);
/**
Scans a target buffer for a UINTN sized value, and returns a pointer to the matching
UINTN sized value in the target buffer.
This function searches target the buffer specified by Buffer and Length from the lowest
address to the highest address for a UINTN sized value that matches Value. If a match is found,
then a pointer to the matching byte in the target buffer is returned. If no match is found,
then NULL is returned. If Length is 0, then NULL is returned.
If Length > 0 and Buffer is NULL, then ASSERT().
If Buffer is not aligned on a UINTN boundary, then ASSERT().
If Length is not aligned on a UINTN boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the target buffer to scan.
@param Length The number of bytes in Buffer to scan.
@param Value The value to search for in the target buffer.
@return A pointer to the matching byte in the target buffer, otherwise NULL.
**/
VOID *
EFIAPI
ScanMemN (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINTN Value
);
///**
// Copies a source GUID to a destination GUID.
//
// This function copies the contents of the 128-bit GUID specified by SourceGuid to
// DestinationGuid, and returns DestinationGuid.
//
// If DestinationGuid is NULL, then ASSERT().
// If SourceGuid is NULL, then ASSERT().
//
// @param DestinationGuid The pointer to the destination GUID.
// @param SourceGuid The pointer to the source GUID.
//
// @return DestinationGuid.
//
//**/
//GUID *
//EFIAPI
//CopyGuid (
// OUT GUID *DestinationGuid,
// IN CONST GUID *SourceGuid
// );
//
///**
// Compares two GUIDs.
//
// This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
// If there are any bit differences in the two GUIDs, then FALSE is returned.
//
// If Guid1 is NULL, then ASSERT().
// If Guid2 is NULL, then ASSERT().
//
// @param Guid1 A pointer to a 128 bit GUID.
// @param Guid2 A pointer to a 128 bit GUID.
//
// @retval TRUE Guid1 and Guid2 are identical.
// @retval FALSE Guid1 and Guid2 are not identical.
//
//**/
//BOOLEAN
//EFIAPI
//CompareGuid (
// IN CONST GUID *Guid1,
// IN CONST GUID *Guid2
// );
//
///**
// Scans a target buffer for a GUID, and returns a pointer to the matching GUID
// in the target buffer.
//
// This function searches target the buffer specified by Buffer and Length from
// the lowest address to the highest address at 128-bit increments for the 128-bit
// GUID value that matches Guid. If a match is found, then a pointer to the matching
// GUID in the target buffer is returned. If no match is found, then NULL is returned.
// If Length is 0, then NULL is returned.
//
// If Length > 0 and Buffer is NULL, then ASSERT().
// If Buffer is not aligned on a 32-bit boundary, then ASSERT().
// If Length is not aligned on a 128-bit boundary, then ASSERT().
// If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
//
// @param Buffer The pointer to the target buffer to scan.
// @param Length The number of bytes in Buffer to scan.
// @param Guid The value to search for in the target buffer.
//
// @return A pointer to the matching Guid in the target buffer, otherwise NULL.
//
//**/
//VOID *
//EFIAPI
//ScanGuid (
// IN CONST VOID *Buffer,
// IN UINTN Length,
// IN CONST GUID *Guid
// );
//
///**
// Checks if the given GUID is a zero GUID.
//
// This function checks whether the given GUID is a zero GUID. If the GUID is
// identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.
//
// If Guid is NULL, then ASSERT().
//
// @param Guid The pointer to a 128 bit GUID.
//
// @retval TRUE Guid is a zero GUID.
// @retval FALSE Guid is not a zero GUID.
//
//**/
//BOOLEAN
//EFIAPI
//IsZeroGuid (
// IN CONST GUID *Guid
// );
/**
Checks if the contents of a buffer are all zeros.
This function checks whether the contents of a buffer are all zeros. If the
contents are all zeros, return TRUE. Otherwise, return FALSE.
If Length > 0 and Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to be checked.
@param Length The size of the buffer (in bytes) to be checked.
@retval TRUE Contents of the buffer are all zeros.
@retval FALSE Contents of the buffer are not all zeros.
**/
BOOLEAN
EFIAPI
IsZeroBuffer (
IN CONST VOID *Buffer,
IN UINTN Length
);
#ifdef __cplusplus
}
#endif
#endif // __BASE_MEMORY_LIB__

View File

@ -0,0 +1,9 @@
//
// DebugLib.c
// cpp_tests UTF16 signed char
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#include "DebugLib.h"

View File

@ -0,0 +1,14 @@
//
// DebugLib.h
// cpp_tests UTF16 signed char
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef DebugLib_h
#define DebugLib_h
#include <stdio.h>
#endif /* DebugLib_h */

View File

@ -0,0 +1,13 @@
//
// OcMiscLib.h
// cpp_tests
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef OcMiscLib_h
#define OcMiscLib_h
#endif /* OcMiscLib_h */

View File

@ -0,0 +1,57 @@
//
// ProcessorBind.h
// cpp_tests
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef ProcessorBind_h
#define ProcessorBind_h
#include <limits.h>
//#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
//#include <string.h>
//#include <inttypes.h>
//#include <wchar.h>
#include <stdbool.h>
//
//#define MAX_UINTN ULONG_MAX
#define BOOLEAN bool
#define CHAR8 char
//#define CHAR16 char16_t
#define CHAR16 wchar_t
//
#define UINT8 uint8_t
#define UINT16 uint16_t
#define UINT32 uint32_t
#define UINT64 uint64_t
#define INT8 int8_t
#define INT16 int16_t
#define INT32 int32_t
#define INT64 int64_t
#define MAX_INT8 ((INT8)0x7F)
#define MAX_UINT8 ((UINT8)0xFF)
#define MAX_INT16 ((INT16)0x7FFF)
#define MAX_UINT16 ((UINT16)0xFFFF)
#define MAX_INT32 ((INT32)0x7FFFFFFF)
#define MAX_UINT32 ((UINT32)0xFFFFFFFF)
#define MAX_INT64 ((INT64)0x7FFFFFFFFFFFFFFFULL)
//#define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL)
#define MAX_UINT64 0xFFFFFFFFFFFFFFFFULL
#define UINTN uint64_t
#define INTN int64_t
#define MAX_UINTN MAX_UINT64
#define MAX_INTN MAX_UINT64
#endif /* ProcessorBind_h */

View File

@ -149,13 +149,16 @@
9A838CA7253425A3008303F5 /* DataPatcher.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838A4A253423A5008303F5 /* DataPatcher.c */; }; 9A838CA7253425A3008303F5 /* DataPatcher.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838A4A253423A5008303F5 /* DataPatcher.c */; };
9A838CA8253425A4008303F5 /* DataPatcher.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838A4A253423A5008303F5 /* DataPatcher.c */; }; 9A838CA8253425A4008303F5 /* DataPatcher.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838A4A253423A5008303F5 /* DataPatcher.c */; };
9A838CA9253425A4008303F5 /* DataPatcher.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838A4A253423A5008303F5 /* DataPatcher.c */; }; 9A838CA9253425A4008303F5 /* DataPatcher.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838A4A253423A5008303F5 /* DataPatcher.c */; };
9A838CAC25342626008303F5 /* MemoryOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CAB25342626008303F5 /* MemoryOperation.cpp */; };
9A838CAD25342629008303F5 /* MemoryOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CAB25342626008303F5 /* MemoryOperation.cpp */; };
9A838CAE2534262A008303F5 /* MemoryOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CAB25342626008303F5 /* MemoryOperation.cpp */; };
9A838CAF2534262A008303F5 /* MemoryOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CAB25342626008303F5 /* MemoryOperation.cpp */; };
9A838CB025345E93008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */; }; 9A838CB025345E93008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */; };
9A838CB125345E93008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */; }; 9A838CB125345E93008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */; };
9A838CB225345E94008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */; }; 9A838CB225345E94008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */; };
9A838CB425347C36008303F5 /* MemoryOperation.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CB325347C36008303F5 /* MemoryOperation.c */; };
9A838CBA25348237008303F5 /* BaseMemoryLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CB925348237008303F5 /* BaseMemoryLib.c */; };
9A838CBB25348530008303F5 /* BaseMemoryLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CB925348237008303F5 /* BaseMemoryLib.c */; };
9A838CBC25348530008303F5 /* BaseMemoryLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CB925348237008303F5 /* BaseMemoryLib.c */; };
9A838CBD25348530008303F5 /* BaseMemoryLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CB925348237008303F5 /* BaseMemoryLib.c */; };
9A838CC0253485C8008303F5 /* BaseLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CBF253485C8008303F5 /* BaseLib.c */; };
9A838CC3253485DC008303F5 /* DebugLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A838CC2253485DC008303F5 /* DebugLib.c */; };
9A9223312402FD1000483CBA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; }; 9A9223312402FD1000483CBA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
9A9AEB8D243F73CE00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; }; 9A9AEB8D243F73CE00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB8E243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; }; 9A9AEB8E243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
@ -286,22 +289,30 @@
9A7D518124FC32F700FA1CC3 /* XBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBuffer.cpp; sourceTree = "<group>"; }; 9A7D518124FC32F700FA1CC3 /* XBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBuffer.cpp; sourceTree = "<group>"; };
9A7D518224FC32F700FA1CC3 /* XRBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XRBuffer.h; sourceTree = "<group>"; }; 9A7D518224FC32F700FA1CC3 /* XRBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XRBuffer.h; sourceTree = "<group>"; };
9A7D518324FC32F700FA1CC3 /* XRBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XRBuffer.cpp; sourceTree = "<group>"; }; 9A7D518324FC32F700FA1CC3 /* XRBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XRBuffer.cpp; sourceTree = "<group>"; };
9A838A4A253423A5008303F5 /* DataPatcher.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp.preprocessed; path = DataPatcher.c; sourceTree = "<group>"; }; 9A838A4A253423A5008303F5 /* DataPatcher.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = DataPatcher.c; sourceTree = "<group>"; };
9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = find_replace_mask_Clover_tests.cpp; sourceTree = "<group>"; }; 9A838CA0253423F0008303F5 /* find_replace_mask_Clover_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = find_replace_mask_Clover_tests.cpp; sourceTree = "<group>"; };
9A838CA1253423F0008303F5 /* find_replace_mask_OC_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_replace_mask_OC_tests.h; sourceTree = "<group>"; }; 9A838CA1253423F0008303F5 /* find_replace_mask_OC_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_replace_mask_OC_tests.h; sourceTree = "<group>"; };
9A838CA2253423F0008303F5 /* find_replace_mask_Clover_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_replace_mask_Clover_tests.h; sourceTree = "<group>"; }; 9A838CA2253423F0008303F5 /* find_replace_mask_Clover_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_replace_mask_Clover_tests.h; sourceTree = "<group>"; };
9A838CA3253423F0008303F5 /* find_replace_mask_OC_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = find_replace_mask_OC_tests.cpp; sourceTree = "<group>"; }; 9A838CA3253423F0008303F5 /* find_replace_mask_OC_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = find_replace_mask_OC_tests.cpp; sourceTree = "<group>"; };
9A838CAA25342626008303F5 /* MemoryOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryOperation.h; sourceTree = "<group>"; }; 9A838CAA25342626008303F5 /* MemoryOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryOperation.h; sourceTree = "<group>"; };
9A838CAB25342626008303F5 /* MemoryOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryOperation.cpp; sourceTree = "<group>"; }; 9A838CB325347C36008303F5 /* MemoryOperation.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp.preprocessed; fileEncoding = 4; path = MemoryOperation.c; sourceTree = "<group>"; };
9A838CB52534808A008303F5 /* Uefi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Uefi.h; sourceTree = "<group>"; };
9A838CB825348237008303F5 /* BaseMemoryLib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseMemoryLib.h; sourceTree = "<group>"; };
9A838CB925348237008303F5 /* BaseMemoryLib.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = BaseMemoryLib.c; sourceTree = "<group>"; };
9A838CBE253485C8008303F5 /* BaseLib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseLib.h; sourceTree = "<group>"; };
9A838CBF253485C8008303F5 /* BaseLib.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = BaseLib.c; sourceTree = "<group>"; };
9A838CC1253485DC008303F5 /* DebugLib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DebugLib.h; sourceTree = "<group>"; };
9A838CC2253485DC008303F5 /* DebugLib.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = DebugLib.c; sourceTree = "<group>"; };
9A838CC425348610008303F5 /* OcMiscLib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OcMiscLib.h; sourceTree = "<group>"; };
9A838CC52534933F008303F5 /* Base.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = "<group>"; };
9A838CC62534946C008303F5 /* ProcessorBind.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProcessorBind.h; sourceTree = "<group>"; };
9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 signed char"; sourceTree = BUILT_PRODUCTS_DIR; }; 9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 signed char"; sourceTree = BUILT_PRODUCTS_DIR; };
9A9223302402FD1000483CBA /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; 9A9223302402FD1000483CBA /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
9A92234D2402FD9500483CBA /* Platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; }; 9A92234D2402FD9500483CBA /* Platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
9A9AEB8B243F73CE00FBD7D8 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; }; 9A9AEB8B243F73CE00FBD7D8 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; }; 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c.preprocessed; fileEncoding = 4; path = unicode_conversions.cpp; sourceTree = "<group>"; };
9A9EA7F6245AAB310076EC02 /* XToolsCommon_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XToolsCommon_test.h; sourceTree = "<group>"; }; 9A9EA7F6245AAB310076EC02 /* XToolsCommon_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XToolsCommon_test.h; sourceTree = "<group>"; };
9A9EA7F7245AAB310076EC02 /* XToolsCommon_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XToolsCommon_test.cpp; sourceTree = "<group>"; }; 9A9EA7F7245AAB310076EC02 /* XToolsCommon_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XToolsCommon_test.cpp; sourceTree = "<group>"; };
9AA045732425D200000D6970 /* IO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IO.h; sourceTree = "<group>"; };
9AA045742425D200000D6970 /* IO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IO.cpp; sourceTree = "<group>"; };
9AA045882425F94D000D6970 /* printf_lite-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test.h"; sourceTree = "<group>"; }; 9AA045882425F94D000D6970 /* printf_lite-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test.h"; sourceTree = "<group>"; };
9AA045892425F94D000D6970 /* printf_lite-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printf_lite-test.cpp"; sourceTree = "<group>"; }; 9AA045892425F94D000D6970 /* printf_lite-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printf_lite-test.cpp"; sourceTree = "<group>"; };
9AC790112452C45A0004FBE9 /* abort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = abort.h; sourceTree = "<group>"; }; 9AC790112452C45A0004FBE9 /* abort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = abort.h; sourceTree = "<group>"; };
@ -433,7 +444,7 @@
9A28CCAC241B816400F3D247 /* Platform */ = { 9A28CCAC241B816400F3D247 /* Platform */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9A838CAB25342626008303F5 /* MemoryOperation.cpp */, 9A838CB325347C36008303F5 /* MemoryOperation.c */,
9A838CAA25342626008303F5 /* MemoryOperation.h */, 9A838CAA25342626008303F5 /* MemoryOperation.h */,
9A36E51E24F3B82A007A1107 /* b64cdecode.cpp */, 9A36E51E24F3B82A007A1107 /* b64cdecode.cpp */,
9A36E51D24F3B82A007A1107 /* b64cdecode.h */, 9A36E51D24F3B82A007A1107 /* b64cdecode.h */,
@ -531,9 +542,34 @@
path = OcMiscLib; path = OcMiscLib;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9A838CB6253481F5008303F5 /* Include */ = {
isa = PBXGroup;
children = (
9A838CB7253481FF008303F5 /* Library */,
);
path = Include;
sourceTree = "<group>";
};
9A838CB7253481FF008303F5 /* Library */ = {
isa = PBXGroup;
children = (
9A838CB825348237008303F5 /* BaseMemoryLib.h */,
9A838CB925348237008303F5 /* BaseMemoryLib.c */,
9A838CBE253485C8008303F5 /* BaseLib.h */,
9A838CBF253485C8008303F5 /* BaseLib.c */,
9A838CC1253485DC008303F5 /* DebugLib.h */,
9A838CC2253485DC008303F5 /* DebugLib.c */,
9A838CC425348610008303F5 /* OcMiscLib.h */,
9A838CC52534933F008303F5 /* Base.h */,
9A838CC62534946C008303F5 /* ProcessorBind.h */,
);
path = Library;
sourceTree = "<group>";
};
9A9223242402FD1000483CBA = { 9A9223242402FD1000483CBA = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9A838CB6253481F5008303F5 /* Include */,
9A83876E253423A4008303F5 /* OpenCorePkg */, 9A83876E253423A4008303F5 /* OpenCorePkg */,
9A36E51C24F3B5B4007A1107 /* rEFIt_UEFI */, 9A36E51C24F3B5B4007A1107 /* rEFIt_UEFI */,
9A1A3FD82424BC22008C89EB /* MemLogLibDefault */, 9A1A3FD82424BC22008C89EB /* MemLogLibDefault */,
@ -563,26 +599,17 @@
9A9223302402FD1000483CBA /* main.cpp */, 9A9223302402FD1000483CBA /* main.cpp */,
9A0B085D240300E000E2B470 /* Platform.cpp */, 9A0B085D240300E000E2B470 /* Platform.cpp */,
9A92234D2402FD9500483CBA /* Platform.h */, 9A92234D2402FD9500483CBA /* Platform.h */,
9AA045782425D44D000D6970 /* PoolPrint */,
9A28CD13241B9FEE00F3D247 /* posix.h */, 9A28CD13241B9FEE00F3D247 /* posix.h */,
9AF4156E242CBC6000D2644C /* printf_lite-conf.h */, 9AF4156E242CBC6000D2644C /* printf_lite-conf.h */,
9AF4156B242CBB5600D2644C /* printf_lite-test-cpp_conf.h */, 9AF4156B242CBB5600D2644C /* printf_lite-test-cpp_conf.h */,
9A28CD4A241F4CCE00F3D247 /* xcode_utf_fixed.cpp */, 9A28CD4A241F4CCE00F3D247 /* xcode_utf_fixed.cpp */,
9A28CD49241F437C00F3D247 /* xcode_utf_fixed.h */, 9A28CD49241F437C00F3D247 /* xcode_utf_fixed.h */,
9A838CB52534808A008303F5 /* Uefi.h */,
); );
name = Main; name = Main;
path = src; path = src;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9AA045782425D44D000D6970 /* PoolPrint */ = {
isa = PBXGroup;
children = (
9AA045742425D200000D6970 /* IO.cpp */,
9AA045732425D200000D6970 /* IO.h */,
);
path = PoolPrint;
sourceTree = "<group>";
};
9AD469462452B30500D6D0DB /* gui */ = { 9AD469462452B30500D6D0DB /* gui */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -705,7 +732,6 @@
files = ( files = (
9A36E50524F3B537007A1107 /* TagInt64.cpp in Sources */, 9A36E50524F3B537007A1107 /* TagInt64.cpp in Sources */,
9A36E50124F3B537007A1107 /* TagDict.cpp in Sources */, 9A36E50124F3B537007A1107 /* TagDict.cpp in Sources */,
9A838CAD25342629008303F5 /* MemoryOperation.cpp in Sources */,
9A36E50D24F3B537007A1107 /* TagData.cpp in Sources */, 9A36E50D24F3B537007A1107 /* TagData.cpp in Sources */,
9A4185B22439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */, 9A4185B22439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A36E52D24F3C846007A1107 /* plist_tests.cpp in Sources */, 9A36E52D24F3C846007A1107 /* plist_tests.cpp in Sources */,
@ -739,6 +765,7 @@
9A4185C12439F73A00BEAFB8 /* XStringArray.cpp in Sources */, 9A4185C12439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A36E52024F3B82A007A1107 /* b64cdecode.cpp in Sources */, 9A36E52024F3B82A007A1107 /* b64cdecode.cpp in Sources */,
9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */, 9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */,
9A838CBB25348530008303F5 /* BaseMemoryLib.c in Sources */,
9A670D1D24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */, 9A670D1D24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */, 9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
9A36E51524F3B537007A1107 /* TagFloat.cpp in Sources */, 9A36E51524F3B537007A1107 /* TagFloat.cpp in Sources */,
@ -752,7 +779,6 @@
files = ( files = (
9A36E50724F3B537007A1107 /* TagInt64.cpp in Sources */, 9A36E50724F3B537007A1107 /* TagInt64.cpp in Sources */,
9A36E50324F3B537007A1107 /* TagDict.cpp in Sources */, 9A36E50324F3B537007A1107 /* TagDict.cpp in Sources */,
9A838CAF2534262A008303F5 /* MemoryOperation.cpp in Sources */,
9A36E50F24F3B537007A1107 /* TagData.cpp in Sources */, 9A36E50F24F3B537007A1107 /* TagData.cpp in Sources */,
9A2A7C6C24576CCE00422263 /* LoadOptions_test.cpp in Sources */, 9A2A7C6C24576CCE00422263 /* LoadOptions_test.cpp in Sources */,
9A36E52F24F3C846007A1107 /* plist_tests.cpp in Sources */, 9A36E52F24F3C846007A1107 /* plist_tests.cpp in Sources */,
@ -786,6 +812,7 @@
9A2A7C7D24576CCE00422263 /* XStringArray.cpp in Sources */, 9A2A7C7D24576CCE00422263 /* XStringArray.cpp in Sources */,
9A36E52224F3B82A007A1107 /* b64cdecode.cpp in Sources */, 9A36E52224F3B82A007A1107 /* b64cdecode.cpp in Sources */,
9A2A7C7E24576CCE00422263 /* XArray_tests.cpp in Sources */, 9A2A7C7E24576CCE00422263 /* XArray_tests.cpp in Sources */,
9A838CBD25348530008303F5 /* BaseMemoryLib.c in Sources */,
9A670D1F24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */, 9A670D1F24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9A2A7C7F24576CCE00422263 /* printf_lite-test.cpp in Sources */, 9A2A7C7F24576CCE00422263 /* printf_lite-test.cpp in Sources */,
9A36E51724F3B537007A1107 /* TagFloat.cpp in Sources */, 9A36E51724F3B537007A1107 /* TagFloat.cpp in Sources */,
@ -799,7 +826,6 @@
files = ( files = (
9A36E50624F3B537007A1107 /* TagInt64.cpp in Sources */, 9A36E50624F3B537007A1107 /* TagInt64.cpp in Sources */,
9A36E50224F3B537007A1107 /* TagDict.cpp in Sources */, 9A36E50224F3B537007A1107 /* TagDict.cpp in Sources */,
9A838CAE2534262A008303F5 /* MemoryOperation.cpp in Sources */,
9A36E50E24F3B537007A1107 /* TagData.cpp in Sources */, 9A36E50E24F3B537007A1107 /* TagData.cpp in Sources */,
9A4185B32439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */, 9A4185B32439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A36E52E24F3C846007A1107 /* plist_tests.cpp in Sources */, 9A36E52E24F3C846007A1107 /* plist_tests.cpp in Sources */,
@ -833,6 +859,7 @@
9A4185C22439F73A00BEAFB8 /* XStringArray.cpp in Sources */, 9A4185C22439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A36E52124F3B82A007A1107 /* b64cdecode.cpp in Sources */, 9A36E52124F3B82A007A1107 /* b64cdecode.cpp in Sources */,
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */, 9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */,
9A838CBC25348530008303F5 /* BaseMemoryLib.c in Sources */,
9A670D1E24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */, 9A670D1E24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */, 9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
9A36E51624F3B537007A1107 /* TagFloat.cpp in Sources */, 9A36E51624F3B537007A1107 /* TagFloat.cpp in Sources */,
@ -844,7 +871,6 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9A838CAC25342626008303F5 /* MemoryOperation.cpp in Sources */,
9A36E50424F3B537007A1107 /* TagInt64.cpp in Sources */, 9A36E50424F3B537007A1107 /* TagInt64.cpp in Sources */,
9A36E50024F3B537007A1107 /* TagDict.cpp in Sources */, 9A36E50024F3B537007A1107 /* TagDict.cpp in Sources */,
9A36E50C24F3B537007A1107 /* TagData.cpp in Sources */, 9A36E50C24F3B537007A1107 /* TagData.cpp in Sources */,
@ -860,6 +886,8 @@
9A36E51824F3B537007A1107 /* TagKey.cpp in Sources */, 9A36E51824F3B537007A1107 /* TagKey.cpp in Sources */,
9A9EA7F8245AAB310076EC02 /* XToolsCommon_test.cpp in Sources */, 9A9EA7F8245AAB310076EC02 /* XToolsCommon_test.cpp in Sources */,
9A36E52624F3BB6B007A1107 /* FloatLib.cpp in Sources */, 9A36E52624F3BB6B007A1107 /* FloatLib.cpp in Sources */,
9A838CB425347C36008303F5 /* MemoryOperation.c in Sources */,
9A838CC0253485C8008303F5 /* BaseLib.c in Sources */,
9A838CA4253423F0008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */, 9A838CA4253423F0008303F5 /* find_replace_mask_Clover_tests.cpp in Sources */,
9A28CD4B241F4CCE00F3D247 /* xcode_utf_fixed.cpp in Sources */, 9A28CD4B241F4CCE00F3D247 /* xcode_utf_fixed.cpp in Sources */,
9A9223312402FD1000483CBA /* main.cpp in Sources */, 9A9223312402FD1000483CBA /* main.cpp in Sources */,
@ -882,7 +910,9 @@
9A36E4F024F3B537007A1107 /* TagString8.cpp in Sources */, 9A36E4F024F3B537007A1107 /* TagString8.cpp in Sources */,
9A36E50824F3B537007A1107 /* TagDate.cpp in Sources */, 9A36E50824F3B537007A1107 /* TagDate.cpp in Sources */,
9A36E51F24F3B82A007A1107 /* b64cdecode.cpp in Sources */, 9A36E51F24F3B82A007A1107 /* b64cdecode.cpp in Sources */,
9A838CC3253485DC008303F5 /* DebugLib.c in Sources */,
9A0B085B2402FF8700E2B470 /* XArray_tests.cpp in Sources */, 9A0B085B2402FF8700E2B470 /* XArray_tests.cpp in Sources */,
9A838CBA25348237008303F5 /* BaseMemoryLib.c in Sources */,
9A670D1C24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */, 9A670D1C24E535AB00B5D780 /* XBuffer_tests.cpp in Sources */,
9AA0458A2425F94D000D6970 /* printf_lite-test.cpp in Sources */, 9AA0458A2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
9A36E51424F3B537007A1107 /* TagFloat.cpp in Sources */, 9A36E51424F3B537007A1107 /* TagFloat.cpp in Sources */,
@ -970,7 +1000,7 @@
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ASSIGN_ENUM = YES;
@ -1042,7 +1072,10 @@
GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/src"; HEADER_SEARCH_PATHS = (
"$(PROJECT_DIR)/src",
"$(PROJECT_DIR)/Include",
);
MACOSX_DEPLOYMENT_TARGET = 10.13; MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
@ -1061,7 +1094,7 @@
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = NO;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ASSIGN_ENUM = YES;
@ -1128,7 +1161,10 @@
GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/src"; HEADER_SEARCH_PATHS = (
"$(PROJECT_DIR)/src",
"$(PROJECT_DIR)/Include",
);
MACOSX_DEPLOYMENT_TARGET = 10.13; MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;

View File

@ -82,57 +82,7 @@ const char* efiStrError(EFI_STATUS Status)
} }
RETURN_STATUS
EFIAPI
AsciiStrDecimalToUintnS (
IN CONST CHAR8 *String,
OUT CHAR8 **EndPointer, OPTIONAL
OUT UINTN *Data
)
{
*Data = 0;
if ( !String ) return RETURN_INVALID_PARAMETER;
int ret = sscanf(String, "%llu", Data);
if ( EndPointer ) *EndPointer += ret;
if ( ret == 0 ) return RETURN_INVALID_PARAMETER;
return RETURN_SUCCESS;
}
UINTN EFIAPI AsciiStrHexToUintn(IN CONST CHAR8 *String)
{
if ( !String ) return RETURN_INVALID_PARAMETER;
UINTN value = 0;
int ret = sscanf(String, "%llx", &value);
if ( ret == 0 ) return 0;
return value;
}
UINTN
EFIAPI
AsciiStrDecimalToUintn (
IN CONST CHAR8 *String
)
{
if ( !String ) panic("AsciiStrDecimalToUintn : !String");
UINTN value;
int ret = sscanf(String, "%llu", &value);
if ( ret == 0 ) return 0;
return value;
}
UINTN StrLen(const wchar_t* String)
{
return size_of_utf_string(String);
}
UINTN StrLen(const char16_t* String)
{
return size_of_utf_string(String);
}
@ -161,34 +111,9 @@ void FreePool(const void* Buffer)
free((void*)Buffer); free((void*)Buffer);
} }
void ZeroMem(void *Destination, UINTN Length)
{
memset(Destination, 0, (size_t)Length);
}
void SetMem(void *Destination, UINTN Length, char c)
{
memset(Destination, c, (size_t)Length);
}
void CopyMem(void *Destination, const void *Source, UINTN Length)
{
memmove(Destination, Source, (size_t)Length);
}
INTN CompareMem(const void* DestinationBuffer, const void* SourceBuffer, UINTN Length)
{
return memcmp(SourceBuffer, DestinationBuffer, Length);
}
CHAR16* EfiStrDuplicate (IN CONST CHAR16 *Src) CHAR16* EfiStrDuplicate (IN CONST CHAR16 *Src)
{ {
CHAR16* newS = (CHAR16*)malloc((wcslen_fixed(Src)+1)*sizeof(wchar_t)); CHAR16* newS = (CHAR16*)malloc((wcslen_fixed(Src)+1)*sizeof(wchar_t));
memcpy(newS, Src, (wcslen_fixed(Src)+1)*sizeof(wchar_t)); memcpy(newS, Src, (wcslen_fixed(Src)+1)*sizeof(wchar_t));
return newS; return newS;
} }
CHAR16* StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
{
return (CHAR16*)wcsstr_fixed(String, SearchString);
}

View File

@ -13,6 +13,10 @@
#include <Windows.h> #include <Windows.h>
#endif #endif
#include "Uefi.h"
#include "../Include/Library/BaseLib.h"
#include "../Include/Library/BaseMemoryLib.h"
#include "../../../rEFIt_UEFI/Platform/Utils.h"
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>
@ -28,119 +32,6 @@ typedef uint16_t char16_t;
#endif #endif
#define IN
#define OUT
#ifndef TRUE
#define TRUE true
#endif
#ifndef FALSE
#define FALSE false
#endif
#define VA_LIST va_list
#define VA_START va_start
#define VA_END va_end
#define VA_ARG va_arg
#define VA_COPY va_copy
#define VOID void
#define EFIAPI
#define CONST const
typedef UINTN RETURN_STATUS;
typedef RETURN_STATUS EFI_STATUS;
#define MAX_BIT 0x8000000000000000ULL
#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode)))
#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9)
#define RETURN_SUCCESS 0
#define RETURN_LOAD_ERROR ENCODE_ERROR (1)
#define RETURN_INVALID_PARAMETER ENCODE_ERROR (2)
#define RETURN_UNSUPPORTED ENCODE_ERROR (3)
#define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4)
#define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5)
#define RETURN_NOT_READY ENCODE_ERROR (6)
#define RETURN_DEVICE_ERROR ENCODE_ERROR (7)
#define RETURN_WRITE_PROTECTED ENCODE_ERROR (8)
#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9)
#define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10)
#define RETURN_VOLUME_FULL ENCODE_ERROR (11)
#define RETURN_NO_MEDIA ENCODE_ERROR (12)
#define RETURN_MEDIA_CHANGED ENCODE_ERROR (13)
#define RETURN_NOT_FOUND ENCODE_ERROR (14)
#define RETURN_ACCESS_DENIED ENCODE_ERROR (15)
#define RETURN_NO_RESPONSE ENCODE_ERROR (16)
#define RETURN_NO_MAPPING ENCODE_ERROR (17)
#define RETURN_TIMEOUT ENCODE_ERROR (18)
#define RETURN_NOT_STARTED ENCODE_ERROR (19)
#define RETURN_ALREADY_STARTED ENCODE_ERROR (20)
#define RETURN_ABORTED ENCODE_ERROR (21)
#define RETURN_ICMP_ERROR ENCODE_ERROR (22)
#define RETURN_TFTP_ERROR ENCODE_ERROR (23)
#define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24)
#define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25)
#define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26)
#define RETURN_CRC_ERROR ENCODE_ERROR (27)
#define RETURN_END_OF_MEDIA ENCODE_ERROR (28)
#define RETURN_END_OF_FILE ENCODE_ERROR (31)
#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1)
#define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2)
#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3)
#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)
//
// Enumeration of EFI_STATUS.
//
#define EFI_SUCCESS RETURN_SUCCESS
#define EFI_LOAD_ERROR RETURN_LOAD_ERROR
#define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER
#define EFI_UNSUPPORTED RETURN_UNSUPPORTED
#define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE
#define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL
#define EFI_NOT_READY RETURN_NOT_READY
#define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR
#define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED
#define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES
#define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED
#define EFI_VOLUME_FULL RETURN_VOLUME_FULL
#define EFI_NO_MEDIA RETURN_NO_MEDIA
#define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED
#define EFI_NOT_FOUND RETURN_NOT_FOUND
#define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED
#define EFI_NO_RESPONSE RETURN_NO_RESPONSE
#define EFI_NO_MAPPING RETURN_NO_MAPPING
#define EFI_TIMEOUT RETURN_TIMEOUT
#define EFI_NOT_STARTED RETURN_NOT_STARTED
#define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED
#define EFI_ABORTED RETURN_ABORTED
#define EFI_ICMP_ERROR RETURN_ICMP_ERROR
#define EFI_TFTP_ERROR RETURN_TFTP_ERROR
#define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR
#define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION
#define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION
#define EFI_CRC_ERROR RETURN_CRC_ERROR
#define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA
#define EFI_END_OF_FILE RETURN_END_OF_FILE
#define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH
#define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE
#define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE
#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL
#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_STATUS)(StatusCode)) < 0)
#define EFI_ERROR(A) RETURN_ERROR(A)
#define OPTIONAL
#define ASSERT(x)
#ifdef _MSC_VER
#define __typeof__(x) decltype(x)
#endif
#include "../../../rEFIt_UEFI/Platform/Posix/abort.h" #include "../../../rEFIt_UEFI/Platform/Posix/abort.h"
#include "../../../rEFIt_UEFI/cpp_foundation/unicode_conversions.h" #include "../../../rEFIt_UEFI/cpp_foundation/unicode_conversions.h"
@ -158,28 +49,6 @@ void PauseForKey(const wchar_t* msg);
const char* efiStrError(EFI_STATUS Status); const char* efiStrError(EFI_STATUS Status);
RETURN_STATUS
EFIAPI
AsciiStrDecimalToUintnS (
IN CONST CHAR8 *String,
OUT CHAR8 **EndPointer, OPTIONAL
OUT UINTN *Data
);
UINTN EFIAPI AsciiStrHexToUintn (IN CONST CHAR8 *String);
inline
UINTN EFIAPI AsciiStrHexToUintn (const XString8& String)
{
return AsciiStrHexToUintn(String.c_str());
}
UINTN
EFIAPI
AsciiStrDecimalToUintn (
IN CONST CHAR8 *String
);
@ -189,22 +58,12 @@ void* AllocateZeroPool(UINTN AllocationSize);
void* ReallocatePool(UINTN OldSize, UINTN NewSize, void* OldBuffer); void* ReallocatePool(UINTN OldSize, UINTN NewSize, void* OldBuffer);
void FreePool(const void* Buffer); void FreePool(const void* Buffer);
void ZeroMem(void *Destination, UINTN Length); //void ZeroMem(void *Destination, UINTN Length);
void SetMem(void *Destination, UINTN Length, char c); //void SetMem(void *Destination, UINTN Length, char c);
void CopyMem(void *Destination, const void *Source, UINTN Length); //void CopyMem(void *Destination, const void *Source, UINTN Length);
INTN CompareMem(const void* DestinationBuffer, const void* SourceBuffer, UINTN Length); //INTN CompareMem(const void* DestinationBuffer, const void* SourceBuffer, UINTN Length);
CHAR16* EfiStrDuplicate (IN CONST CHAR16 *Src); CHAR16* EfiStrDuplicate (IN CONST CHAR16 *Src);
CHAR16* StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString);
//UINTN StrLen(const char16_t* String);
UINTN StrLen(const wchar_t* String);
//int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString);
//int StrnCmp(const wchar_t* FirstString, const wchar_t* SecondString, UINTN Length);
//UINTN StrLen(const wchar_t* String);
//UINTN AsciiStrLen(const char* String);
//INTN AsciiStrCmp (const char *FirstString,const char *SecondString);

128
Xcode/cpp_tests/src/Uefi.h Normal file
View File

@ -0,0 +1,128 @@
//
// Uefi.h
// cpp_tests
//
// Created by Jief on 12/10/2020.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef Uefi_h
#define Uefi_h
#include <Library/ProcessorBind.h>
#define IN
#define OUT
#ifndef TRUE
#define TRUE true
#endif
#ifndef FALSE
#define FALSE false
#endif
//#define VA_LIST va_list
//#define VA_START va_start
//#define VA_END va_end
//#define VA_ARG va_arg
//#define VA_COPY va_copy
#define VOID void
#define EFIAPI
#define CONST const
typedef UINTN RETURN_STATUS;
typedef RETURN_STATUS EFI_STATUS;
#define MAX_BIT 0x8000000000000000ULL
#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode)))
#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9)
#define RETURN_SUCCESS 0
#define RETURN_LOAD_ERROR ENCODE_ERROR (1)
#define RETURN_INVALID_PARAMETER ENCODE_ERROR (2)
#define RETURN_UNSUPPORTED ENCODE_ERROR (3)
#define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4)
#define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5)
#define RETURN_NOT_READY ENCODE_ERROR (6)
#define RETURN_DEVICE_ERROR ENCODE_ERROR (7)
#define RETURN_WRITE_PROTECTED ENCODE_ERROR (8)
#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9)
#define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10)
#define RETURN_VOLUME_FULL ENCODE_ERROR (11)
#define RETURN_NO_MEDIA ENCODE_ERROR (12)
#define RETURN_MEDIA_CHANGED ENCODE_ERROR (13)
#define RETURN_NOT_FOUND ENCODE_ERROR (14)
#define RETURN_ACCESS_DENIED ENCODE_ERROR (15)
#define RETURN_NO_RESPONSE ENCODE_ERROR (16)
#define RETURN_NO_MAPPING ENCODE_ERROR (17)
#define RETURN_TIMEOUT ENCODE_ERROR (18)
#define RETURN_NOT_STARTED ENCODE_ERROR (19)
#define RETURN_ALREADY_STARTED ENCODE_ERROR (20)
#define RETURN_ABORTED ENCODE_ERROR (21)
#define RETURN_ICMP_ERROR ENCODE_ERROR (22)
#define RETURN_TFTP_ERROR ENCODE_ERROR (23)
#define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24)
#define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25)
#define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26)
#define RETURN_CRC_ERROR ENCODE_ERROR (27)
#define RETURN_END_OF_MEDIA ENCODE_ERROR (28)
#define RETURN_END_OF_FILE ENCODE_ERROR (31)
#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1)
#define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2)
#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3)
#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)
//
// Enumeration of EFI_STATUS.
//
#define EFI_SUCCESS RETURN_SUCCESS
#define EFI_LOAD_ERROR RETURN_LOAD_ERROR
#define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER
#define EFI_UNSUPPORTED RETURN_UNSUPPORTED
#define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE
#define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL
#define EFI_NOT_READY RETURN_NOT_READY
#define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR
#define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED
#define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES
#define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED
#define EFI_VOLUME_FULL RETURN_VOLUME_FULL
#define EFI_NO_MEDIA RETURN_NO_MEDIA
#define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED
#define EFI_NOT_FOUND RETURN_NOT_FOUND
#define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED
#define EFI_NO_RESPONSE RETURN_NO_RESPONSE
#define EFI_NO_MAPPING RETURN_NO_MAPPING
#define EFI_TIMEOUT RETURN_TIMEOUT
#define EFI_NOT_STARTED RETURN_NOT_STARTED
#define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED
#define EFI_ABORTED RETURN_ABORTED
#define EFI_ICMP_ERROR RETURN_ICMP_ERROR
#define EFI_TFTP_ERROR RETURN_TFTP_ERROR
#define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR
#define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION
#define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION
#define EFI_CRC_ERROR RETURN_CRC_ERROR
#define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA
#define EFI_END_OF_FILE RETURN_END_OF_FILE
#define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH
#define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE
#define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE
#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL
#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_STATUS)(StatusCode)) < 0)
#define EFI_ERROR(A) RETURN_ERROR(A)
#define OPTIONAL
#define ASSERT(x)
#ifdef _MSC_VER
#define __typeof__(x) decltype(x)
#endif
#endif /* Uefi_h */

View File

@ -23,9 +23,10 @@
#define Xrealloc(ptr, newsize, oldsize) realloc(ptr, newsize) #define Xrealloc(ptr, newsize, oldsize) realloc(ptr, newsize)
#include <Platform.h> //#include <Platform.h>
#include <posix.h> #include <posix.h>
#include <inttypes.h>
#include "../../../rEFIt_UEFI/Platform/Posix/abort.h"
#include <Library/Base.h>
#endif #endif

View File

@ -29,5 +29,5 @@ printf("sizeof(size_t)=%zu\n", sizeof(size_t));
//printf("%zd\n", (size_t)MAX_UINT64); //printf("%zd\n", (size_t)MAX_UINT64);
#endif #endif
return all_tests(); return all_tests() ? 0 : -1 ;
} }

View File

@ -23,39 +23,6 @@
# include <wchar.h> # include <wchar.h>
#endif #endif
//
//#define MAX_UINTN ULONG_MAX
#define BOOLEAN bool
#define CHAR8 char
//#define CHAR16 char16_t
#define CHAR16 wchar_t
//
#define UINT8 uint8_t
#define UINT16 uint16_t
#define UINT32 uint32_t
#define UINT64 uint64_t
#define INT8 int8_t
#define INT16 int16_t
#define INT32 int32_t
#define INT64 int64_t
#define MAX_INT8 ((INT8)0x7F)
#define MAX_UINT8 ((UINT8)0xFF)
#define MAX_INT16 ((INT16)0x7FFF)
#define MAX_UINT16 ((UINT16)0xFFFF)
#define MAX_INT32 ((INT32)0x7FFFFFFF)
#define MAX_UINT32 ((UINT32)0xFFFFFFFF)
#define MAX_INT64 ((INT64)0x7FFFFFFFFFFFFFFFULL)
//#define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL)
#define MAX_UINT64 0xFFFFFFFFFFFFFFFFULL
#define UINTN uint64_t
#define INTN int64_t
#define MAX_UINTN MAX_UINT64
#define MAX_INTN MAX_UINT64
//// ////
//// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions //// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions

View File

@ -12,6 +12,7 @@
* So, for this to work, pass macro definition argument on command line : wcslen=utf16_wcslen wcsncmp=utf16_wcsncmp wcsstr=utf16_wcsstr * So, for this to work, pass macro definition argument on command line : wcslen=utf16_wcslen wcsncmp=utf16_wcsncmp wcsstr=utf16_wcsstr
*/ */
#include "xcode_utf_fixed.h"
#include <wchar.h> #include <wchar.h>
#include <vector> #include <vector>
#include <cwchar> #include <cwchar>

View File

@ -9,7 +9,11 @@
#ifndef __xcode_utf16_h__ #ifndef __xcode_utf16_h__
#define __xcode_utf16_h__ #define __xcode_utf16_h__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
/* /*
* all the functions w... seems to expect utf32 even when compiled with short-wchar * all the functions w... seems to expect utf32 even when compiled with short-wchar
*/ */
@ -18,5 +22,8 @@ size_t wcslen_fixed(const wchar_t *s);
int wcsncmp_fixed(const wchar_t *s1, const wchar_t * s2, size_t n); int wcsncmp_fixed(const wchar_t *s1, const wchar_t * s2, size_t n);
const wchar_t* wcsstr_fixed(const wchar_t* s1, const wchar_t* s2); const wchar_t* wcsstr_fixed(const wchar_t* s1, const wchar_t* s2);
#ifdef __cplusplus
}
#endif
#endif /* wfunction_hpp */ #endif /* wfunction_hpp */

View File

@ -5,9 +5,7 @@
#include "MemoryOperation.h" #include "MemoryOperation.h"
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
// //

View File

@ -11,12 +11,12 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <Uefi.h>
//#include <Library/BaseLib.h> //#include <Library/BaseLib.h>
//#include <Library/BaseMemoryLib.h> //#include <Library/BaseMemoryLib.h>

View File

@ -29,6 +29,7 @@ Headers collection for procedures
#include "BootLog.h" #include "BootLog.h"
#include "BasicIO.h" #include "BasicIO.h"
#include "VersionString.h" #include "VersionString.h"
#include "Utils.h"
//#include "Settings.h" //#include "Settings.h"
#ifndef CLOVERAPPLICATION #ifndef CLOVERAPPLICATION

View File

@ -8,24 +8,27 @@
extern bool stop_at_panic; extern bool stop_at_panic;
extern bool i_have_panicked; extern bool i_have_panicked;
#ifdef __cplusplus // C cannot accept 2 functions with same name and different parameters.
void panic(void) void panic(void)
#ifndef PANIC_CAN_RETURN #ifndef PANIC_CAN_RETURN
__attribute__ ((noreturn)); __attribute__ ((noreturn))
#endif #endif
; ;
#endif
void panic(const char* format, ...) __attribute__((__format__(__printf__, 1, 2))) void panic(const char* format, ...) __attribute__((__format__(__printf__, 1, 2)))
#ifndef PANIC_CAN_RETURN #ifndef PANIC_CAN_RETURN
__attribute__ ((noreturn)); __attribute__ ((noreturn))
#endif #endif
; ;
#ifdef __cplusplus
class DontStopAtPanic class DontStopAtPanic
{ {
public: public:
DontStopAtPanic() { stop_at_panic = false; i_have_panicked = false; } DontStopAtPanic() { stop_at_panic = false; i_have_panicked = false; }
~DontStopAtPanic() { stop_at_panic = true; i_have_panicked = false; } ~DontStopAtPanic() { stop_at_panic = true; i_have_panicked = false; }
}; };
#endif
#endif #endif

View File

@ -2,6 +2,8 @@
Slice 2012 Slice 2012
*/ */
#include <Platform.h>
#include "../entry_scan/entry_scan.h" #include "../entry_scan/entry_scan.h"
#include "../entry_scan/loader.h" #include "../entry_scan/loader.h"
#include "kernel_patcher.h" #include "kernel_patcher.h"

View File

@ -18,6 +18,17 @@
#include "../cpp_foundation/XString.h" #include "../cpp_foundation/XString.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <Library/BaseLib.h>
#ifdef __cplusplus
}
#endif
//Unicode //Unicode
#define IS_COMMA(a) ((a) == L',') #define IS_COMMA(a) ((a) == L',')
#define IS_HYPHEN(a) ((a) == L'-') #define IS_HYPHEN(a) ((a) == L'-')

View File

@ -79,7 +79,12 @@ class XBuffer : public XBuffer_Super
size_t size() const { return XRBuffer<T>::size(); } size_t size() const { return XRBuffer<T>::size(); }
template<typename IntegralType, enable_if(is_integral(IntegralType))> template<typename IntegralType, enable_if(is_integral(IntegralType))>
void setSize(IntegralType size) { CheckSize(size); XBuffer_Super::m_size = size; }; void setSize(IntegralType size) {
if ( size<0 ) panic("XBuffer::setSize() -> i < 0");
if ( (unsigned_type(IntegralType))size > MAX_XSIZE ) panic("XBuffer::setSize() -> i > MAX_XSIZE");
CheckSize((unsigned_type(IntegralType))size);
XBuffer_Super::m_size = (unsigned_type(IntegralType))size;
};
void setEmpty() { setSize(0); }; void setEmpty() { setSize(0); };

View File

@ -780,7 +780,7 @@ public:
{ {
if ( size<0 ) panic("T* dataSized() -> i < 0"); if ( size<0 ) panic("T* dataSized() -> i < 0");
if ( (unsigned_type(IntegralType))size > MAX_XSIZE ) panic("T* dataSized() -> i > MAX_XSIZE"); if ( (unsigned_type(IntegralType))size > MAX_XSIZE ) panic("T* dataSized() -> i > MAX_XSIZE");
CheckSize((size_t)size); CheckSize((unsigned_type(IntegralType))size);
return __String<T, ThisXStringClass>::_data(0); return __String<T, ThisXStringClass>::_data(0);
} }
// //

View File

@ -6,7 +6,14 @@
#include "unicode_conversions.h" #include "unicode_conversions.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h> // for memcpy #include <string.h> // for memcpy
//#include <uintptr_t.h> // for memcpy
//#include <sys/_types/_uintptr_t.h>
#ifndef MIN #ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
@ -49,7 +56,7 @@ static inline int is_high_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0
static inline int is_low_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xdc00; } static inline int is_low_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xdc00; }
static inline char32_t surrogate_to_utf32(char16_t high, char16_t low) { static inline char32_t surrogate_to_utf32(char16_t high, char16_t low) {
return char32_t((high << 10) + low - 0x35fdc00); // Safe cast, it fits in 32 bits return (char32_t)((high << 10) + low - 0x35fdc00); // Safe cast, it fits in 32 bits
} }
@ -239,21 +246,21 @@ const char* get_char32_from_utf8_string(const char* s, char32_t* char32)
return s; return s;
} }
/* 4-byte code */ /* 4-byte code */
c = char32_t((*s & 0x7) << 18); // & result type is int. We know it fits in 32 bits. Safe to cast to char32_t c = (char32_t)((*s & 0x7) << 18); // & result type is int. We know it fits in 32 bits. Safe to cast to char32_t
c |= char32_t((*(s+1) & 0x3f) << 12); c |= (char32_t)((*(s+1) & 0x3f) << 12);
c |= char32_t((*(s+2) & 0x3f) << 6); c |= (char32_t)((*(s+2) & 0x3f) << 6);
c |= *(s+3) & 0x3f; c |= *(s+3) & 0x3f;
s += 4; s += 4;
} else { } else {
/* 3-byte code */ /* 3-byte code */
c = char32_t((*s & 0xf) << 12); c = (char32_t)((*s & 0xf) << 12);
c |= char32_t((*(s+1) & 0x3f) << 6); c |= (char32_t)((*(s+1) & 0x3f) << 6);
c |= *(s+2) & 0x3f; c |= *(s+2) & 0x3f;
s += 3; s += 3;
} }
} else { } else {
/* 2-byte code */ /* 2-byte code */
c = char32_t((*s & 0x1f) << 6); c = (char32_t)((*s & 0x1f) << 6);
c |= *(s+1) & 0x3f; c |= *(s+1) & 0x3f;
s += 2; s += 2;
} }
@ -1245,7 +1252,7 @@ size_t utf8_size_of_utf8_string(const char* s)
while ( char32 ) { while ( char32 ) {
p = get_char32_from_utf8_string(p, &char32); p = get_char32_from_utf8_string(p, &char32);
} }
return (uintptr_t(p)-uintptr_t(s)); return (uintptr_t)p - (uintptr_t)s;
// //
// const char* p = s; // const char* p = s;
// while ( *p++ ); // while ( *p++ );
@ -1338,7 +1345,7 @@ size_t utf8_stringnn_from_utf8_string(char* dst, size_t dst_max_size, const char
if ( dst_max_size <= 0 ) break; if ( dst_max_size <= 0 ) break;
s = get_char32_from_utf8_string(s, &char32); s = get_char32_from_utf8_string(s, &char32);
} }
return uintptr_t(p)-uintptr_t(dst); return (uintptr_t)p - (uintptr_t)dst;
} }
size_t utf8_string_from_utf8_string(char* dst, size_t dst_max_size, const char *s) size_t utf8_string_from_utf8_string(char* dst, size_t dst_max_size, const char *s)
@ -1388,7 +1395,7 @@ size_t utf8_string_from_utf8_string_len(char* dst, size_t dst_max_size, const ch
len--; len--;
} }
*p = 0; *p = 0;
return uintptr_t(p)-uintptr_t(dst)-1; return (uintptr_t)p - (uintptr_t)dst - 1;
} }
size_t utf16_stringnn_from_utf16_string(char16_t* dst, size_t dst_max_size, const char16_t *s) size_t utf16_stringnn_from_utf16_string(char16_t* dst, size_t dst_max_size, const char16_t *s)
@ -1403,7 +1410,7 @@ size_t utf16_stringnn_from_utf16_string(char16_t* dst, size_t dst_max_size, cons
if ( dst_max_size <= 0 ) break; if ( dst_max_size <= 0 ) break;
s = get_char32_from_utf16_string(s, &char32); s = get_char32_from_utf16_string(s, &char32);
} }
return uintptr_t(p - dst); return (uintptr_t)(p - dst);
} }
@ -1461,7 +1468,7 @@ size_t utf16_string_from_utf16_string_len(char16_t* dst, size_t dst_max_size, co
len--; len--;
} }
*p = 0; *p = 0;
return uintptr_t(p)-uintptr_t(dst)-1; return (uintptr_t)p - (uintptr_t)dst - 1;
} }
size_t utf32_stringnn_from_utf32_string(char32_t* dst, size_t dst_max_size, const char32_t *s) size_t utf32_stringnn_from_utf32_string(char32_t* dst, size_t dst_max_size, const char32_t *s)
@ -1559,6 +1566,9 @@ char32_t get_char32_from_utf32_string_at_pos(const char32_t* s, size_t pos)
} }
/****** convenience *****/ /****** convenience *****/
size_t length_of_utf8_string(const char* s) {return utf32_size_of_utf8_string(s); }
size_t length_of_utf16_string(const char16_t* s) {return utf32_size_of_utf16_string(s); }
size_t length_of_utf32_string(const char32_t* s) {return utf32_size_of_utf32_string(s); } // UTF32 length == size
size_t length_of_wchar_string(const wchar_t* s) size_t length_of_wchar_string(const wchar_t* s)
{ {
@ -1569,3 +1579,6 @@ size_t length_of_wchar_string(const wchar_t* s)
#endif #endif
} }
#ifdef __cplusplus
}
#endif

View File

@ -7,11 +7,16 @@
#ifndef __unicode_conversions_h__ #ifndef __unicode_conversions_h__
#define __unicode_conversions_h__ #define __unicode_conversions_h__
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h> #include <stddef.h>
#include <wchar.h> #include <wchar.h>
#include <string.h> #include <string.h>
#ifndef __cplusplus #ifndef __cplusplus
#include <stdint.h>
//typedef uint16_t wchar_t; //typedef uint16_t wchar_t;
typedef uint32_t char32_t; typedef uint32_t char32_t;
typedef uint16_t char16_t; typedef uint16_t char16_t;
@ -244,12 +249,18 @@ char32_t get_char32_from_utf32_string_at_pos(const char32_t* s, size_t pos);
/****** convenience *****/ /****** convenience *****/
inline size_t length_of_utf8_string(const char* s) {return utf32_size_of_utf8_string(s); } inline size_t length_of_utf8_string(const char* s);
inline size_t length_of_utf16_string(const char16_t* s) {return utf32_size_of_utf16_string(s); } inline size_t length_of_utf16_string(const char16_t* s);
inline size_t length_of_utf32_string(const char32_t* s) {return utf32_size_of_utf32_string(s); } // UTF32 length == size inline size_t length_of_utf32_string(const char32_t* s); // UTF32 length == size
size_t length_of_wchar_string(const wchar_t* s); inline size_t length_of_wchar_string(const wchar_t* s);
#ifdef __cplusplus
}
#endif
/* ================================== C++ Convienience ============================================= */
#ifdef __cplusplus #ifdef __cplusplus
inline char* get_char32_from_string(char* s, char32_t* char32) { return (char*)get_char32_from_utf8_string(s, char32); } inline char* get_char32_from_string(char* s, char32_t* char32) { return (char*)get_char32_from_utf8_string(s, char32); }

View File

@ -24,6 +24,21 @@ int find_replace_mask_Clover_tests()
uintn = FindMemMask((UINT8*)"\x00\xCC\x00", 3, (UINT8*)"\xC0", 1, (UINT8*)"\xF0", 1); uintn = FindMemMask((UINT8*)"\x00\xCC\x00", 3, (UINT8*)"\xC0", 1, (UINT8*)"\xF0", 1);
if ( uintn != 1 ) breakpoint(1); if ( uintn != 1 ) breakpoint(1);
/*
* For Clover, the mask pattern is NOT required to be applied to the source, first.
* Bits corresponding to a 0 in mask are ignored. Here, the F in 0xCF is just ignored because of 0 in mask 0xF0.
*/
uintn = FindMemMask((UINT8*)"\x00\xCC\x00", 3, (UINT8*)"\xCF", 1, (UINT8*)"\xF0", 1);
if ( uintn != 1 ) breakpoint(1);
// Search in clever
uintn = FindMemMask((UINT8*)"\x01\x63\x6c\x65\x76\x65\x72\x02", 8, (UINT8*)"\x43\x6c\x65\x76\x65\x72", 6, (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6);
if ( uintn != 1 ) breakpoint(1);
// Search in Clever
uintn = FindMemMask((UINT8*)"\x01\x43\x6c\x65\x76\x65\x72\x02", 8, (UINT8*)"\x43\x6c\x65\x76\x65\x72", 6, (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6);
if ( uintn != 1 ) breakpoint(1);
// Simple patch of 3 bytes // Simple patch of 3 bytes
{ {
UINT8 buf[] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20 }; UINT8 buf[] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20 };
@ -81,6 +96,28 @@ int find_replace_mask_Clover_tests()
if ( uintn != 1 ) breakpoint(1); if ( uintn != 1 ) breakpoint(1);
if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1); if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1);
} }
// Patch clever to clover
{
UINT8 buf[] = { 0x01, 0x63, 0x6c, 0x65, 0x76, 0x65, 0x72, 0x02 };
UINT8 expectedBuf[] = { 0x01, 0x63, 0x6c, 0x6f, 0x76, 0x65, 0x72, 0x02 };
uintn = SearchAndReplaceMask(buf, 8,
(UINT8*)"\x43\x6c\x65\x76\x65\x72", (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6,
(UINT8*)"\x43\x6c\x6f\x76\x65\x72", (UINT8*)"\x00\x00\xFF\x00\x00\x00",
0);
if ( uintn != 1 ) breakpoint(1);
if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1);
}
// Patch Clever to clover
{
UINT8 buf[] = { 0x01, 0x43, 0x6c, 0x65, 0x76, 0x65, 0x72, 0x02 };
UINT8 expectedBuf[] = { 0x01, 0x43, 0x6c, 0x6f, 0x76, 0x65, 0x72, 0x02 };
uintn = SearchAndReplaceMask(buf, 8,
(UINT8*)"\x43\x6c\x65\x76\x65\x72", (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6,
(UINT8*)"\x43\x6c\x6f\x76\x65\x72", (UINT8*)"\x00\x00\xFF\x00\x00\x00",
0);
if ( uintn != 1 ) breakpoint(1);
if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1);
}
return 0; return 0;
} }

View File

@ -2,6 +2,7 @@
//#include "../../OpenCorePkg/Include/Acidanthera/Library/OcMiscLib.h" //#include "../../OpenCorePkg/Include/Acidanthera/Library/OcMiscLib.h"
extern "C" {
INT32 INT32
FindPattern ( FindPattern (
@ -26,6 +27,8 @@ ApplyPatch (
IN UINT32 Skip IN UINT32 Skip
); );
}
static int breakpoint(int i) static int breakpoint(int i)
{ {
return i; return i;
@ -49,6 +52,21 @@ int find_replace_mask_OC_tests()
int32 = FindPattern((UINT8*)"\xC0", (UINT8*)"\xF0", 1, (UINT8*)"\x00\xCC\x00", 3, 0); int32 = FindPattern((UINT8*)"\xC0", (UINT8*)"\xF0", 1, (UINT8*)"\x00\xCC\x00", 3, 0);
if ( int32 != 1 ) breakpoint(1); if ( int32 != 1 ) breakpoint(1);
/*
* For OC, the mask pattern must applied to the source, first.
* 0xCF & 0xF0 = 0xC0
*/
int32 = FindPattern((UINT8*)"\xCF", (UINT8*)"\xF0", 1, (UINT8*)"\x00\xCC\x00", 3, 0);
if ( int32 != -1 ) breakpoint(1);
// Search in clever
int32 = FindPattern((UINT8*)"\x43\x6c\x65\x76\x65\x72", (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6, (UINT8*)"\x01\x63\x6c\x65\x76\x65\x72\x02", 8, 0);
if ( int32 != 1 ) breakpoint(1);
// Search in Clever
int32 = FindPattern((UINT8*)"\x43\x6c\x65\x76\x65\x72", (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6, (UINT8*)"\x01\x43\x6c\x65\x76\x65\x72\x02", 8, 0);
if ( int32 != 1 ) breakpoint(1);
// Simple patch of 3 bytes // Simple patch of 3 bytes
{ {
UINT8 buf[] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20 }; UINT8 buf[] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20 };
@ -94,6 +112,26 @@ int find_replace_mask_OC_tests()
if ( uint32 != 1 ) breakpoint(1); if ( uint32 != 1 ) breakpoint(1);
if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1); if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1);
} }
// Patch clever to clover
{
UINT8 buf[] = { 0x01, 0x63, 0x6c, 0x65, 0x76, 0x65, 0x72, 0x02 };
UINT8 expectedBuf[] = { 0x01, 0x63, 0x6c, 0x6f, 0x76, 0x65, 0x72, 0x02 };
uint32 = ApplyPatch((UINT8*)"\x43\x6c\x65\x76\x65\x72", (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6,
(UINT8*)"\x43\x6c\x6f\x76\x65\x72", (UINT8*)"\x00\x00\xFF\x00\x00\x00",
buf, 8, 0, 0);
if ( uint32 != 1 ) breakpoint(1);
if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1);
}
// Patch Clever to clover
{
UINT8 buf[] = { 0x01, 0x43, 0x6c, 0x65, 0x76, 0x65, 0x72, 0x02 };
UINT8 expectedBuf[] = { 0x01, 0x43, 0x6c, 0x6f, 0x76, 0x65, 0x72, 0x02 };
uint32 = ApplyPatch((UINT8*)"\x43\x6c\x65\x76\x65\x72", (UINT8*)"\xDF\xFF\xFF\xFF\xFF\xFF", 6,
(UINT8*)"\x43\x6c\x6f\x76\x65\x72", (UINT8*)"\x00\x00\xFF\x00\x00\x00",
buf, 8, 0, 0);
if ( uint32 != 1 ) breakpoint(1);
if ( memcmp(buf, expectedBuf, 3) != 0 ) breakpoint(1);
}
return 0; return 0;
} }