From 95e5ee24967ab12296ec21e19a99d30db091f6b1 Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Mon, 21 Mar 2016 10:19:02 +0100 Subject: [PATCH] Fix wrong GUIDs and release build --- common/ffsparser.cpp | 13 ++++++++++--- common/nvram.cpp | 2 +- common/nvram.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index bf2bd40..d6c7473 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -2895,7 +2895,9 @@ STATUS FfsParser::parseNvarStorage(const QByteArray & data, const QModelIndex & bool hasExtendedHeader = false; bool hasChecksum = false; bool hasTimestampAndHash = false; + bool hasGuidIndex = false; + UINT32 guidIndex = 0; UINT8 storedChecksum = 0; UINT8 calculatedChecksum = 0; UINT16 extendedHeaderSize = 0; @@ -3093,13 +3095,14 @@ STATUS FfsParser::parseNvarStorage(const QByteArray & data, const QModelIndex & } // GUID is stored in GUID list at the end of the storage else { - UINT32 guidIndex = *(UINT8*)(variableHeader + 1); + guidIndex = *(UINT8*)(variableHeader + 1); if (guidsInStorage < guidIndex + 1) guidsInStorage = guidIndex + 1; // The list begins at the end of the storage and goes backwards - const EFI_GUID* guidPtr = (const EFI_GUID*)(data.constData() + data.size()) - guidIndex; + const EFI_GUID* guidPtr = (const EFI_GUID*)(data.constData() + data.size()) - 1 - guidIndex; name = guidToQString(*guidPtr); + hasGuidIndex = true; } // Include variable name and GUID into the header and remove them from body @@ -3122,6 +3125,10 @@ parsing_done: else // Add GUID info for valid variables info += QObject::tr("Variable GUID: %1\n").arg(name); + // Add GUID index information + if (hasGuidIndex) + info += QObject::tr("GUID index: %1\n").arg(guidIndex); + // Add header, body and extended data info info += QObject::tr("Full size: %1h (%2)\nHeader size %3h (%4)\nBody size: %5h (%6)") .hexarg(variableHeader->Size).arg(variableHeader->Size) @@ -3180,7 +3187,7 @@ parsing_done: .hexarg(extendedData.size()), varIndex); // Check variable name to be in the list of nesting variables - for (std::vector::const_iterator iter = nestingVariableNames.cbegin(); iter != nestingVariableNames.cend(); ++iter) + for (std::vector::const_iterator iter = nestingVariableNames.cbegin(); iter != nestingVariableNames.cend(); ++iter) if (QString(*iter) == text.toLatin1()) { STATUS result = parseNvarStorage(body, varIndex); if (result) diff --git a/common/nvram.cpp b/common/nvram.cpp index a98ae10..e3f1998 100644 --- a/common/nvram.cpp +++ b/common/nvram.cpp @@ -41,7 +41,7 @@ QString variableAttributesToQstring(UINT8 attributes) return str.mid(2); // Remove the first comma and space } -std::vector nestingVariableNames = { +std::vector nestingVariableNames = { "StdDefaults", "MfgDefaults" }; \ No newline at end of file diff --git a/common/nvram.h b/common/nvram.h index 80655c5..bf6d1c8 100644 --- a/common/nvram.h +++ b/common/nvram.h @@ -33,7 +33,7 @@ const QByteArray NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID extern QString variableAttributesToQstring(UINT8 attributes); -extern std::vector nestingVariableNames; +extern std::vector nestingVariableNames; // Make sure we use right packing rules #pragma pack(push,1)