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

Method parseDepexSection

ffsengine.cpp:1465–1557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1463}
1464
1465UINT8 FfsEngine::parseDepexSection(const QByteArray & body, QString & parsed)
1466{
1467 parsed.clear();
1468 // Check data to be present
1469 if (!body.size())
1470 return ERR_INVALID_PARAMETER;
1471
1472 const EFI_GUID * guid;
1473 const UINT8* current = (const UINT8*)body.constData();
1474
1475 // Special cases of first opcode
1476 switch (*current) {
1477 case EFI_DEP_BEFORE:
1478 if (body.size() != 2*EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID))
1479 return ERR_DEPEX_PARSE_FAILED;
1480 guid = (const EFI_GUID*)(current + EFI_DEP_OPCODE_SIZE);
1481 parsed += tr("\nBEFORE %1").arg(guidToQString(*guid));
1482 current += EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID);
1483 if (*current != EFI_DEP_END)
1484 return ERR_DEPEX_PARSE_FAILED;
1485 return ERR_SUCCESS;
1486 case EFI_DEP_AFTER:
1487 if (body.size() != 2 * EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID))
1488 return ERR_DEPEX_PARSE_FAILED;
1489 guid = (const EFI_GUID*)(current + EFI_DEP_OPCODE_SIZE);
1490 parsed += tr("\nAFTER %1").arg(guidToQString(*guid));
1491 current += EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID);
1492 if (*current != EFI_DEP_END)
1493 return ERR_DEPEX_PARSE_FAILED;
1494 return ERR_SUCCESS;
1495 case EFI_DEP_SOR:
1496 if (body.size() <= 2 * EFI_DEP_OPCODE_SIZE) {
1497 return ERR_DEPEX_PARSE_FAILED;
1498 }
1499 parsed += tr("\nSOR");
1500 current += EFI_DEP_OPCODE_SIZE;
1501 break;
1502 }
1503
1504 // Parse the rest of depex
1505 while (current - (const UINT8*)body.constData() < body.size()) {
1506 switch (*current) {
1507 case EFI_DEP_BEFORE:
1508 case EFI_DEP_AFTER:
1509 case EFI_DEP_SOR:
1510 return ERR_DEPEX_PARSE_FAILED;
1511 case EFI_DEP_PUSH:
1512 // Check that the rest of depex has correct size
1513 if ((UINT32)body.size() - (UINT32)(current - (const UINT8*)body.constData()) <= EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID)) {
1514 parsed.clear();
1515 return ERR_DEPEX_PARSE_FAILED;
1516 }
1517 guid = (const EFI_GUID*)(current + EFI_DEP_OPCODE_SIZE);
1518 parsed += tr("\nPUSH %1").arg(guidToQString(*guid));
1519 current += EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID);
1520 break;
1521 case EFI_DEP_AND:
1522 parsed += tr("\nAND");

Callers

nothing calls this directly

Calls 1

guidToQStringFunction · 0.85

Tested by

no test coverage detected