mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 17:38:22 +08:00
More minor structure init fixes
This commit is contained in:
parent
83548d4c8a
commit
eb3185224b
@ -49,7 +49,7 @@ const UByteArray EFI_FMP_CAPSULE_GUID // 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
|
|||||||
("\xED\xD5\xCB\x6D\x2D\xE8\x44\x4C\xBD\xA1\x71\x94\x19\x9A\xD9\x2A", 16);
|
("\xED\xD5\xCB\x6D\x2D\xE8\x44\x4C\xBD\xA1\x71\x94\x19\x9A\xD9\x2A", 16);
|
||||||
|
|
||||||
// Standard EFI capsule GUID
|
// Standard EFI capsule GUID
|
||||||
const UByteArray EFI_CAPSULE_GUID
|
const UByteArray EFI_CAPSULE_GUID // 3B6686BD-0D76-4030-B70E-B5519E2FC5A0
|
||||||
("\xBD\x86\x66\x3B\x76\x0D\x30\x40\xB7\x0E\xB5\x51\x9E\x2F\xC5\xA0", 16);
|
("\xBD\x86\x66\x3B\x76\x0D\x30\x40\xB7\x0E\xB5\x51\x9E\x2F\xC5\xA0", 16);
|
||||||
|
|
||||||
// Intel capsule GUID
|
// Intel capsule GUID
|
||||||
@ -73,7 +73,7 @@ typedef struct TOSHIBA_CAPSULE_HEADER_ {
|
|||||||
} TOSHIBA_CAPSULE_HEADER;
|
} TOSHIBA_CAPSULE_HEADER;
|
||||||
|
|
||||||
// Toshiba capsule GUID
|
// Toshiba capsule GUID
|
||||||
const UByteArray TOSHIBA_CAPSULE_GUID
|
const UByteArray TOSHIBA_CAPSULE_GUID // 3BE07062-1D51-45D2-832B-F093257ED461
|
||||||
("\x62\x70\xE0\x3B\x51\x1D\xD2\x45\x83\x2B\xF0\x93\x25\x7E\xD4\x61", 16);
|
("\x62\x70\xE0\x3B\x51\x1D\xD2\x45\x83\x2B\xF0\x93\x25\x7E\xD4\x61", 16);
|
||||||
|
|
||||||
// AMI Aptio extended capsule header
|
// AMI Aptio extended capsule header
|
||||||
|
@ -607,7 +607,6 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l
|
|||||||
// Add descriptor tree item
|
// Add descriptor tree item
|
||||||
UModelIndex regionIndex = model->addItem(localOffset, Types::Region, Subtypes::DescriptorRegion, name, UString(), info, UByteArray(), body, UByteArray(), Fixed, index);
|
UModelIndex regionIndex = model->addItem(localOffset, Types::Region, Subtypes::DescriptorRegion, name, UString(), info, UByteArray(), body, UByteArray(), Fixed, index);
|
||||||
|
|
||||||
|
|
||||||
// Parse regions
|
// Parse regions
|
||||||
USTATUS result = U_SUCCESS;
|
USTATUS result = U_SUCCESS;
|
||||||
USTATUS parseResult = U_SUCCESS;
|
USTATUS parseResult = U_SUCCESS;
|
||||||
@ -920,7 +919,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse current volume's header
|
// Parse current volume header
|
||||||
if (itemType == Types::Volume) {
|
if (itemType == Types::Volume) {
|
||||||
UModelIndex volumeIndex;
|
UModelIndex volumeIndex;
|
||||||
UByteArray volume = data.mid(itemOffset, itemSize);
|
UByteArray volume = data.mid(itemOffset, itemSize);
|
||||||
@ -1190,7 +1189,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc
|
|||||||
index = model->addItem(localOffset, Types::Volume, subtype, name, text, info, header, body, UByteArray(), Movable, parent);
|
index = model->addItem(localOffset, Types::Volume, subtype, name, text, info, header, body, UByteArray(), Movable, parent);
|
||||||
|
|
||||||
// Set parsing data for created volume
|
// Set parsing data for created volume
|
||||||
VOLUME_PARSING_DATA pdata;
|
VOLUME_PARSING_DATA pdata = {};
|
||||||
pdata.emptyByte = emptyByte;
|
pdata.emptyByte = emptyByte;
|
||||||
pdata.ffsVersion = ffsVersion;
|
pdata.ffsVersion = ffsVersion;
|
||||||
pdata.hasExtendedHeader = hasExtendedHeader ? TRUE : FALSE;
|
pdata.hasExtendedHeader = hasExtendedHeader ? TRUE : FALSE;
|
||||||
@ -1554,6 +1553,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
|||||||
|
|
||||||
// Move to next file
|
// Move to next file
|
||||||
fileOffset += fileSize;
|
fileOffset += fileSize;
|
||||||
|
// TODO: check that alignment bytes are all of erase polarity bit, warn if not so
|
||||||
fileOffset = ALIGN8(fileOffset);
|
fileOffset = ALIGN8(fileOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1784,7 +1784,7 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf
|
|||||||
index = model->addItem(localOffset, Types::File, fileHeader->Type, name, text, info, header, body, tail, fixed, parent);
|
index = model->addItem(localOffset, Types::File, fileHeader->Type, name, text, info, header, body, tail, fixed, parent);
|
||||||
|
|
||||||
// Set parsing data for created file
|
// Set parsing data for created file
|
||||||
FILE_PARSING_DATA pdata;
|
FILE_PARSING_DATA pdata = {};
|
||||||
pdata.emptyByte = (fileHeader->State & EFI_FILE_ERASE_POLARITY) ? 0xFF : 0x00;
|
pdata.emptyByte = (fileHeader->State & EFI_FILE_ERASE_POLARITY) ? 0xFF : 0x00;
|
||||||
pdata.guid = fileHeader->Name;
|
pdata.guid = fileHeader->Name;
|
||||||
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
||||||
@ -2012,7 +2012,7 @@ USTATUS FfsParser::parseSections(const UByteArray & sections, const UModelIndex
|
|||||||
result = parseSectionHeader(sections.mid(sectionOffset, sectionSize), headerSize + sectionOffset, index, sectionIndex, insertIntoTree);
|
result = parseSectionHeader(sections.mid(sectionOffset, sectionSize), headerSize + sectionOffset, index, sectionIndex, insertIntoTree);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (insertIntoTree)
|
if (insertIntoTree)
|
||||||
msg(UString("parseSections: section header parsing failed with error ") + errorCodeToUString(result), index);
|
msg(usprintf("%s: section header parsing failed with error ", __FUNCTION__) + errorCodeToUString(result), index);
|
||||||
else
|
else
|
||||||
return U_INVALID_SECTION;
|
return U_INVALID_SECTION;
|
||||||
}
|
}
|
||||||
@ -2205,7 +2205,7 @@ USTATUS FfsParser::parseCompressedSectionHeader(const UByteArray & section, cons
|
|||||||
index = model->addItem(localOffset, Types::Section, sectionHeader->Type, name, UString(), info, header, body, UByteArray(), Movable, parent);
|
index = model->addItem(localOffset, Types::Section, sectionHeader->Type, name, UString(), info, header, body, UByteArray(), Movable, parent);
|
||||||
|
|
||||||
// Set section parsing data
|
// Set section parsing data
|
||||||
COMPRESSED_SECTION_PARSING_DATA pdata;
|
COMPRESSED_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.compressionType = compressionType;
|
pdata.compressionType = compressionType;
|
||||||
pdata.uncompressedSize = uncompressedLength;
|
pdata.uncompressedSize = uncompressedLength;
|
||||||
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
||||||
@ -2378,7 +2378,7 @@ USTATUS FfsParser::parseGuidedSectionHeader(const UByteArray & section, const UI
|
|||||||
index = model->addItem(localOffset, Types::Section, sectionHeader->Type, name, UString(), info, header, body, UByteArray(), Movable, parent);
|
index = model->addItem(localOffset, Types::Section, sectionHeader->Type, name, UString(), info, header, body, UByteArray(), Movable, parent);
|
||||||
|
|
||||||
// Set parsing data
|
// Set parsing data
|
||||||
GUIDED_SECTION_PARSING_DATA pdata;
|
GUIDED_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.guid = guid;
|
pdata.guid = guid;
|
||||||
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
||||||
|
|
||||||
@ -2462,7 +2462,7 @@ USTATUS FfsParser::parseFreeformGuidedSectionHeader(const UByteArray & section,
|
|||||||
index = model->addItem(localOffset, Types::Section, type, name, UString(), info, header, body, UByteArray(), Movable, parent);
|
index = model->addItem(localOffset, Types::Section, type, name, UString(), info, header, body, UByteArray(), Movable, parent);
|
||||||
|
|
||||||
// Set parsing data
|
// Set parsing data
|
||||||
FREEFORM_GUIDED_SECTION_PARSING_DATA pdata;
|
FREEFORM_GUIDED_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.guid = guid;
|
pdata.guid = guid;
|
||||||
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
||||||
|
|
||||||
@ -2651,13 +2651,14 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index)
|
|||||||
UByteArray efiDecompressed;
|
UByteArray efiDecompressed;
|
||||||
USTATUS result = decompress(model->body(index), compressionType, algorithm, dictionarySize, decompressed, efiDecompressed);
|
USTATUS result = decompress(model->body(index), compressionType, algorithm, dictionarySize, decompressed, efiDecompressed);
|
||||||
if (result) {
|
if (result) {
|
||||||
msg(UString("parseCompressedSectionBody: decompression failed with error ") + errorCodeToUString(result), index);
|
msg(usprintf("%s: decompression failed with error ", __FUNCTION__) + errorCodeToUString(result), index);
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check reported uncompressed size
|
// Check reported uncompressed size
|
||||||
if (uncompressedSize != (UINT32)decompressed.size()) {
|
if (uncompressedSize != (UINT32)decompressed.size()) {
|
||||||
msg(usprintf("parseCompressedSectionBody: decompressed size stored in header %Xh (%u) differs from actual %" PRIXQ "h (%" PRIuQ ")",
|
msg(usprintf("%s: decompressed size stored in header %Xh (%u) differs from actual %" PRIXQ "h (%" PRIuQ ")",
|
||||||
|
__FUNCTION__,
|
||||||
uncompressedSize, uncompressedSize,
|
uncompressedSize, uncompressedSize,
|
||||||
decompressed.size(), decompressed.size()),
|
decompressed.size(), decompressed.size()),
|
||||||
index);
|
index);
|
||||||
@ -2676,7 +2677,7 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index)
|
|||||||
decompressed = efiDecompressed;
|
decompressed = efiDecompressed;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg(UString("parseCompressedSectionBody: can't guess the correct decompression algorithm, both preparse steps are failed"), index);
|
msg(usprintf("%s: can't guess the correct decompression algorithm, both preparse steps are failed", __FUNCTION__), index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2693,7 +2694,7 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set parsing data
|
// Set parsing data
|
||||||
COMPRESSED_SECTION_PARSING_DATA pdata;
|
COMPRESSED_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.algorithm = algorithm;
|
pdata.algorithm = algorithm;
|
||||||
pdata.dictionarySize = dictionarySize;
|
pdata.dictionarySize = dictionarySize;
|
||||||
pdata.compressionType = compressionType;
|
pdata.compressionType = compressionType;
|
||||||
@ -2807,7 +2808,7 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index)
|
|||||||
model->addInfo(index, info);
|
model->addInfo(index, info);
|
||||||
|
|
||||||
// Set parsing data
|
// Set parsing data
|
||||||
GUIDED_SECTION_PARSING_DATA pdata;
|
GUIDED_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.dictionarySize = dictionarySize;
|
pdata.dictionarySize = dictionarySize;
|
||||||
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
|
||||||
|
|
||||||
@ -3175,7 +3176,7 @@ USTATUS FfsParser::parseTeImageSectionBody(const UModelIndex & index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update parsing data
|
// Update parsing data
|
||||||
TE_IMAGE_SECTION_PARSING_DATA pdata;
|
TE_IMAGE_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.imageBaseType = EFI_IMAGE_TE_BASE_OTHER; // Will be determined later
|
pdata.imageBaseType = EFI_IMAGE_TE_BASE_OTHER; // Will be determined later
|
||||||
pdata.originalImageBase = (UINT32)teHeader->ImageBase;
|
pdata.originalImageBase = (UINT32)teHeader->ImageBase;
|
||||||
pdata.adjustedImageBase = (UINT32)(teHeader->ImageBase + teHeader->StrippedSize - sizeof(EFI_IMAGE_TE_HEADER));
|
pdata.adjustedImageBase = (UINT32)(teHeader->ImageBase + teHeader->StrippedSize - sizeof(EFI_IMAGE_TE_HEADER));
|
||||||
@ -3302,7 +3303,7 @@ USTATUS FfsParser::checkTeImageBase(const UModelIndex & index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update parsing data
|
// Update parsing data
|
||||||
TE_IMAGE_SECTION_PARSING_DATA pdata;
|
TE_IMAGE_SECTION_PARSING_DATA pdata = {};
|
||||||
pdata.imageBaseType = imageBaseType;
|
pdata.imageBaseType = imageBaseType;
|
||||||
pdata.originalImageBase = originalImageBase;
|
pdata.originalImageBase = originalImageBase;
|
||||||
pdata.adjustedImageBase = adjustedImageBase;
|
pdata.adjustedImageBase = adjustedImageBase;
|
||||||
@ -3372,7 +3373,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index)
|
|||||||
bgProtectedRanges[i].Offset -= (UINT32)addressDiff;
|
bgProtectedRanges[i].Offset -= (UINT32)addressDiff;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Explore this.
|
// TODO: Explore this.
|
||||||
msg(usprintf("%s: Suspicious BG protection offset", __FUNCTION__), index);
|
msg(usprintf("%s: suspicious BG protection offset", __FUNCTION__), index);
|
||||||
}
|
}
|
||||||
protectedParts += openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size);
|
protectedParts += openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size);
|
||||||
markProtectedRangeRecursive(index, bgProtectedRanges[i]);
|
markProtectedRangeRecursive(index, bgProtectedRanges[i]);
|
||||||
@ -3434,8 +3435,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index)
|
|||||||
if (!dxeRootVolumeIndex.isValid()) {
|
if (!dxeRootVolumeIndex.isValid()) {
|
||||||
msg(usprintf("%s: can't determine DXE volume offset, post-IBB protected range hash can't be checked", __FUNCTION__), index);
|
msg(usprintf("%s: can't determine DXE volume offset, post-IBB protected range hash can't be checked", __FUNCTION__), index);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
bgProtectedRanges[i].Offset = model->base(dxeRootVolumeIndex);
|
bgProtectedRanges[i].Offset = model->base(dxeRootVolumeIndex);
|
||||||
bgProtectedRanges[i].Size = (UINT32)(model->header(dxeRootVolumeIndex).size() + model->body(dxeRootVolumeIndex).size() + model->tail(dxeRootVolumeIndex).size());
|
bgProtectedRanges[i].Size = (UINT32)(model->header(dxeRootVolumeIndex).size() + model->body(dxeRootVolumeIndex).size() + model->tail(dxeRootVolumeIndex).size());
|
||||||
protectedParts = openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size);
|
protectedParts = openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size);
|
||||||
@ -3473,7 +3473,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index)
|
|||||||
markProtectedRangeRecursive(index, bgProtectedRanges[i]);
|
markProtectedRangeRecursive(index, bgProtectedRanges[i]);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Explore this.
|
// TODO: Explore this.
|
||||||
msg(usprintf("%s: Suspicious AMI new BG protection offset", __FUNCTION__), index);
|
msg(usprintf("%s: suspicious AMI new BG protection offset", __FUNCTION__), index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bgProtectedRanges[i].Type == BG_PROTECTED_RANGE_VENDOR_HASH_PHOENIX
|
else if (bgProtectedRanges[i].Type == BG_PROTECTED_RANGE_VENDOR_HASH_PHOENIX
|
||||||
@ -3722,7 +3722,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index)
|
|||||||
|
|
||||||
// Check fit header type
|
// Check fit header type
|
||||||
if (fitHeader->Type != FIT_TYPE_HEADER) {
|
if (fitHeader->Type != FIT_TYPE_HEADER) {
|
||||||
msg(UString("Invalid FIT header type"), fitIndex);
|
msg(usprintf("%s: invalid FIT header type", __FUNCTION__), fitIndex);
|
||||||
return U_INVALID_FIT;
|
return U_INVALID_FIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4010,15 +4010,14 @@ USTATUS FfsParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Add KM header info
|
// Add KM header info
|
||||||
securityInfo += usprintf(
|
securityInfo += usprintf("Intel BootGuard Key manifest found at base %Xh\n"
|
||||||
"Intel BootGuard Key manifest found at base %Xh\n"
|
"Tag: __KEYM__ Version: %02Xh KmVersion: %02Xh KmSvn: %02Xh KmId: %02Xh",
|
||||||
"Tag: __KEYM__ Version: %02Xh KmVersion: %02Xh KmSvn: %02Xh KmId: %02Xh",
|
model->base(parent) + localOffset,
|
||||||
model->base(parent) + localOffset,
|
header->Version,
|
||||||
header->Version,
|
header->KmVersion,
|
||||||
header->KmVersion,
|
header->KmSvn,
|
||||||
header->KmSvn,
|
header->KmId
|
||||||
header->KmId
|
);
|
||||||
);
|
|
||||||
|
|
||||||
// Add hash of Key Manifest PubKey, this hash will be written to FPFs
|
// Add hash of Key Manifest PubKey, this hash will be written to FPFs
|
||||||
UINT8 hash[SHA256_DIGEST_SIZE];
|
UINT8 hash[SHA256_DIGEST_SIZE];
|
||||||
|
@ -129,7 +129,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
|||||||
UINT32 lastVariableFlag = emptyByte ? 0xFFFFFF : 0;
|
UINT32 lastVariableFlag = emptyByte ? 0xFFFFFF : 0;
|
||||||
|
|
||||||
// Set default next to predefined last value
|
// Set default next to predefined last value
|
||||||
NVAR_ENTRY_PARSING_DATA pdata;
|
NVAR_ENTRY_PARSING_DATA pdata = {};
|
||||||
pdata.emptyByte = emptyByte;
|
pdata.emptyByte = emptyByte;
|
||||||
pdata.next = lastVariableFlag;
|
pdata.next = lastVariableFlag;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user