diff --git a/common/basetypes.h b/common/basetypes.h index b85708d..9e93f27 100644 --- a/common/basetypes.h +++ b/common/basetypes.h @@ -85,19 +85,19 @@ typedef size_t USTATUS; #define U_NOT_IMPLEMENTED 255 // EDK2 porting definitions -typedef uint8_t BOOLEAN; -typedef int8_t INT8; -typedef uint8_t UINT8; -typedef int16_t INT16; -typedef uint16_t UINT16; -typedef int32_t INT32; -typedef uint32_t UINT32; -typedef int64_t INT64; -typedef uint64_t UINT64; -typedef char CHAR8; -typedef uint16_t CHAR16; -typedef size_t UINTN; -typedef ptrdiff_t INTN; +typedef uint8_t BOOLEAN; +typedef int8_t INT8; +typedef uint8_t UINT8; +typedef int16_t INT16; +typedef uint16_t UINT16; +typedef int32_t INT32; +typedef uint32_t UINT32; +typedef int64_t INT64; +typedef uint64_t UINT64; +typedef char CHAR8; +typedef uint16_t CHAR16; +typedef size_t UINTN; +typedef ptrdiff_t INTN; #define CONST const #define VOID void @@ -137,7 +137,6 @@ typedef ptrdiff_t INTN; #define COMPRESSION_ALGORITHM_GZIP 8 #define COMPRESSION_ALGORITHM_ZLIB 9 - // Item create modes #define CREATE_MODE_APPEND 0 #define CREATE_MODE_PREPEND 1 diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 75ced0f..9ec3ee0 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -1222,20 +1222,10 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc return U_SUCCESS; } -BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeader) +bool FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeader) { - // Check main reserved bytes to be zero bool reservedBytesValid = true; - for (UINT32 i = 0; i < sizeof(ucodeHeader->Reserved); i++) { - if (ucodeHeader->Reserved[i] != 0x00) { - reservedBytesValid = false; - break; - } - } - if (!reservedBytesValid) { - return FALSE; - } - + // Check CpuFlags reserved bytes to be zero for (UINT32 i = 0; i < sizeof(ucodeHeader->ProcessorFlagsReserved); i++) { if (ucodeHeader->ProcessorFlagsReserved[i] != 0x00) { @@ -1244,19 +1234,19 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade } } if (!reservedBytesValid) { - return FALSE; + return false; } // Check data size to be multiple of 4 and less than 0x1000000 if (ucodeHeader->DataSize % 4 != 0 || ucodeHeader->DataSize > 0xFFFFFF) { - return FALSE; + return false; } // Check TotalSize to be greater or equal than DataSize and less than 0x1000000 if (ucodeHeader->TotalSize < ucodeHeader->DataSize || ucodeHeader->TotalSize > 0xFFFFFF) { - return FALSE; + return false; } // Check date to be sane @@ -1266,7 +1256,7 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade (ucodeHeader->DateDay > 0x19 && ucodeHeader->DateDay < 0x20) || (ucodeHeader->DateDay > 0x29 && ucodeHeader->DateDay < 0x30) || ucodeHeader->DateDay > 0x31) { - return FALSE; + return false; } // Check month to be in 0x01-0x09, 0x10-0x12 if (ucodeHeader->DateMonth < 0x01 || diff --git a/common/ffsparser.h b/common/ffsparser.h index 3cd6ab7..b62367f 100644 --- a/common/ffsparser.h +++ b/common/ffsparser.h @@ -175,7 +175,7 @@ private: UINT32 getSectionSize(const UByteArray & file, const UINT32 sectionOffset, const UINT8 ffsVersion); USTATUS parseIntelMicrocodeHeader(const UByteArray & store, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); - BOOLEAN microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeader); + bool microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeader); USTATUS parseVendorHashFile(const UByteArray & fileGuid, const UModelIndex & index); diff --git a/common/treemodel.h b/common/treemodel.h index d5fe023..7ff4c8c 100644 --- a/common/treemodel.h +++ b/common/treemodel.h @@ -117,7 +117,7 @@ public: UString headerData(int section, int orientation, int role = 0) const; TreeModel() : markingEnabledFlag(false) { - rootItem = new TreeItem(0, Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), TRUE, FALSE); + rootItem = new TreeItem(0, Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), true, false); } bool hasIndex(int row, int column, const UModelIndex &parent = UModelIndex()) const { @@ -162,7 +162,7 @@ public: UString info(const UModelIndex &index) const; void setInfo(const UModelIndex &index, const UString &info); - void addInfo(const UModelIndex &index, const UString &info, const bool append = TRUE); + void addInfo(const UModelIndex &index, const UString &info, const bool append = true); bool fixed(const UModelIndex &index) const; void setFixed(const UModelIndex &index, const bool fixed); diff --git a/common/utility.cpp b/common/utility.cpp index ba6d9c9..e14258a 100755 --- a/common/utility.cpp +++ b/common/utility.cpp @@ -469,10 +469,10 @@ INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSi return -1; while (dataOff + patternSize < dataSize) { - BOOLEAN matches = TRUE; + bool matches = true; for (UINTN i = 0; i < patternSize; i++) { if ((data[dataOff + i] & patternMask[i]) != pattern[i]) { - matches = FALSE; + matches = true; break; } } @@ -486,12 +486,12 @@ INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSi return -1; } -BOOLEAN makePattern(const CHAR8 *textPattern, std::vector &pattern, std::vector &patternMask) +bool makePattern(const CHAR8 *textPattern, std::vector &pattern, std::vector &patternMask) { UINTN len = std::strlen(textPattern); if (len == 0 || len % 2 != 0) - return FALSE; + return false; len /= 2; @@ -503,7 +503,7 @@ BOOLEAN makePattern(const CHAR8 *textPattern, std::vector &pattern, std:: int v2 = char2hex(std::toupper(textPattern[i * 2 + 1])); if (v1 == -1 || v2 == -1) - return FALSE; + return false; if (v1 != -2) { patternMask[i] = 0xF0; @@ -516,7 +516,7 @@ BOOLEAN makePattern(const CHAR8 *textPattern, std::vector &pattern, std:: } } - return TRUE; + return true; } USTATUS gzipDecompress(const UByteArray & input, UByteArray & output) diff --git a/common/utility.h b/common/utility.h index 8f8dfe2..7a24e2a 100755 --- a/common/utility.h +++ b/common/utility.h @@ -60,7 +60,7 @@ UINT32 calculateChecksum32(const UINT32* buffer, UINT32 bufferSize); UINT8 getPaddingType(const UByteArray & padding); // Make pattern from a hexstring with an assumption of . being any char -BOOLEAN makePattern(const CHAR8 *textPattern, std::vector &pattern, std::vector &patternMask); +bool makePattern(const CHAR8 *textPattern, std::vector &pattern, std::vector &patternMask); // Find pattern in a binary blob INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSize,