MCPcopy Create free account
hub / github.com/LongSoft/UEFITool / parseSection

Method parseSection

ffsengine.cpp:1575–2197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1573}
1574
1575UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, const QModelIndex & parent, const UINT8 mode)
1576{
1577 const EFI_COMMON_SECTION_HEADER* sectionHeader = (const EFI_COMMON_SECTION_HEADER*)(section.constData());
1578 QString name = sectionTypeToQString(sectionHeader->Type) + tr(" section");
1579 QString info;
1580 QByteArray header;
1581 QByteArray body;
1582 UINT32 headerSize = sizeOfSectionHeader(sectionHeader);
1583 UINT8 result;
1584
1585 switch (sectionHeader->Type) {
1586 // Encapsulated sections
1587 case EFI_SECTION_COMPRESSION:
1588 {
1589 bool parseCurrentSection = true;
1590 QByteArray decompressed;
1591 UINT8 algorithm;
1592 const EFI_COMPRESSION_SECTION* compressedSectionHeader = (const EFI_COMPRESSION_SECTION*)sectionHeader;
1593 header = section.left(headerSize);
1594 body = section.mid(headerSize);
1595 algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
1596 // Decompress section
1597 result = decompress(body, compressedSectionHeader->CompressionType, decompressed, &algorithm);
1598 if (result)
1599 parseCurrentSection = false;
1600
1601 // Get info
1602 info = tr("Type: %1h\nFull size: %2h (%3)\nHeader size: %4h (%5)\nBody size: %6h (%7)\nCompression type: %8\nDecompressed size: %9h (%10)")
1603 .hexarg2(sectionHeader->Type, 2)
1604 .hexarg(section.size()).arg(section.size())
1605 .hexarg(header.size()).arg(header.size())
1606 .hexarg(body.size()).arg(body.size())
1607 .arg(compressionTypeToQString(algorithm))
1608 .hexarg(compressedSectionHeader->UncompressedLength).arg(compressedSectionHeader->UncompressedLength);
1609
1610 UINT32 dictionarySize = DEFAULT_LZMA_DICTIONARY_SIZE;
1611 if (algorithm == COMPRESSION_ALGORITHM_LZMA) {
1612 // Dictionary size is stored in bytes 1-4 of LZMA-compressed data
1613 dictionarySize = *(UINT32*)(body.constData() + 1);
1614 info += tr("\nLZMA dictionary size: %1h").hexarg(dictionarySize);
1615 }
1616
1617 // Add tree item
1618 index = model->addItem(Types::Section, sectionHeader->Type, algorithm, name, "", info, header, body, parent, mode);
1619 model->setDictionarySize(index, dictionarySize);
1620
1621 // Show message
1622 if (!parseCurrentSection)
1623 msg(tr("parseSection: decompression failed with error \"%1\"").arg(errorMessage(result)), index);
1624 else { // Parse decompressed data
1625 result = parseSections(decompressed, index);
1626 if (result)
1627 return result;
1628 }
1629 } break;
1630
1631 case EFI_SECTION_GUID_DEFINED:
1632 {

Callers

nothing calls this directly

Calls 15

sectionTypeToQStringFunction · 0.85
sizeOfSectionHeaderFunction · 0.85
compressionTypeToQStringFunction · 0.85
errorMessageFunction · 0.85
guidToQStringFunction · 0.85
x86ConvertFunction · 0.85
machineTypeToQStringFunction · 0.85
addItemMethod · 0.80
findParentOfTypeMethod · 0.80
setDictionarySizeMethod · 0.45
subtypeMethod · 0.45
bodyMethod · 0.45

Tested by

no test coverage detected