Add support for NVRAM_NVAR_PEI_EXTERNAL_DEFAULTS_FILE_GUID, fixes #163

This commit is contained in:
vit9696 2019-02-10 18:38:37 +03:00
parent 5c98152c58
commit f34894b9fd
4 changed files with 46 additions and 39 deletions

View File

@ -913,7 +913,10 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Export discovered GUIDs...</string> <string>&amp;Export discovered GUIDs...</string>
</property>
<property name="shortcut">
<string>Ctrl+Alt+E</string>
</property> </property>
</action> </action>
</widget> </widget>

View File

@ -1659,12 +1659,20 @@ USTATUS FfsParser::parseFileBody(const UModelIndex & index)
UByteArray fileGuid = UByteArray(model->header(index).constData(), sizeof(EFI_GUID)); UByteArray fileGuid = UByteArray(model->header(index).constData(), sizeof(EFI_GUID));
// Parse NVAR store // Parse NVAR store
if (fileGuid == NVRAM_NVAR_STORE_FILE_GUID) if (fileGuid == NVRAM_NVAR_STORE_FILE_GUID) {
model->setText(index, UString("NVAR store"));
return nvramParser->parseNvarStore(index); return nvramParser->parseNvarStore(index);
}
if (fileGuid == NVRAM_NVAR_PEI_EXTERNAL_DEFAULTS_FILE_GUID) {
model->setText(index, UString("NVRAM external defaults"));
return nvramParser->parseNvarStore(index);
}
// Parse vendor hash file // Parse vendor hash file
else if (fileGuid == BG_VENDOR_HASH_FILE_GUID_PHOENIX) else if (fileGuid == BG_VENDOR_HASH_FILE_GUID_PHOENIX) {
return parseVendorHashFile(fileGuid, index); return parseVendorHashFile(fileGuid, index);
}
return parseRawArea(index); return parseRawArea(index);
} }
@ -2796,39 +2804,34 @@ USTATUS FfsParser::parseRawSectionBody(const UModelIndex & index)
// Get parent file parsing data // Get parent file parsing data
UByteArray parentFileGuid(model->header(parentFile).constData(), sizeof(EFI_GUID)); UByteArray parentFileGuid(model->header(parentFile).constData(), sizeof(EFI_GUID));
if (parentFileGuid == EFI_PEI_APRIORI_FILE_GUID) { // PEI apriori file if (parentFileGuid == EFI_PEI_APRIORI_FILE_GUID) { // PEI apriori file
// Parse apriori file list
UString str;
USTATUS result = parseAprioriRawSection(model->body(index), str);
if (!result && !str.isEmpty())
model->addInfo(index, UString("\nFile list:") + str);
// Set parent file text // Set parent file text
model->setText(parentFile, UString("PEI apriori file")); model->setText(parentFile, UString("PEI apriori file"));
return U_SUCCESS;
}
else if (parentFileGuid == EFI_DXE_APRIORI_FILE_GUID) { // DXE apriori file
// Parse apriori file list // Parse apriori file list
UString str; UString str;
USTATUS result = parseAprioriRawSection(model->body(index), str); USTATUS result = parseAprioriRawSection(model->body(index), str);
if (!result && !str.isEmpty()) if (!result && !str.isEmpty())
model->addInfo(index, UString("\nFile list:") + str); model->addInfo(index, UString("\nFile list:") + str);
return result;
// Set parent file text }
else if (parentFileGuid == EFI_DXE_APRIORI_FILE_GUID) { // DXE apriori file
// Rename parent file
model->setText(parentFile, UString("DXE apriori file")); model->setText(parentFile, UString("DXE apriori file"));
// Parse apriori file list
return U_SUCCESS; UString str;
USTATUS result = parseAprioriRawSection(model->body(index), str);
if (!result && !str.isEmpty())
model->addInfo(index, UString("\nFile list:") + str);
return result;
} }
else if (parentFileGuid == NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID) { // AMI NVRAM external defaults else if (parentFileGuid == NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID) { // AMI NVRAM external defaults
// Parse NVAR area // Rename parent file
nvramParser->parseNvarStore(index);
// Set parent file text
model->setText(parentFile, UString("NVRAM external defaults")); model->setText(parentFile, UString("NVRAM external defaults"));
// Parse NVAR area
return nvramParser->parseNvarStore(index);
} }
else if (parentFileGuid == BG_VENDOR_HASH_FILE_GUID_AMI) { // AMI vendor hash file else if (parentFileGuid == BG_VENDOR_HASH_FILE_GUID_AMI) { // AMI vendor hash file
// Parse AMI vendor hash file // Parse AMI vendor hash file
parseVendorHashFile(parentFileGuid, index); return parseVendorHashFile(parentFileGuid, index);
} }
// Parse as raw area // Parse as raw area

View File

@ -34,6 +34,10 @@ const UByteArray NVRAM_NVAR_STORE_FILE_GUID
const UByteArray NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID const UByteArray NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID
("\x5B\x31\x21\x92\xBB\x30\xB5\x46\x81\x3E\x1B\x1B\xF4\x71\x2B\xD3", 16); ("\x5B\x31\x21\x92\xBB\x30\xB5\x46\x81\x3E\x1B\x1B\xF4\x71\x2B\xD3", 16);
// 77D3DC50-D42B-4916-AC80-8F469035D150
const UByteArray NVRAM_NVAR_PEI_EXTERNAL_DEFAULTS_FILE_GUID
("\x50\xDC\xD3\x77\x2B\xD4\x16\x49\xAC\x80\x8F\x46\x90\x35\xD1\x50", 16);
extern UString nvarAttributesToUString(const UINT8 attributes); extern UString nvarAttributesToUString(const UINT8 attributes);
extern UString nvarExtendedAttributesToUString(const UINT8 attributes); extern UString nvarExtendedAttributesToUString(const UINT8 attributes);
extern UString efiTimeToUString(const EFI_TIME & time); extern UString efiTimeToUString(const EFI_TIME & time);
@ -41,7 +45,7 @@ extern UString efiTimeToUString(const EFI_TIME & time);
typedef struct NVAR_ENTRY_HEADER_ { typedef struct NVAR_ENTRY_HEADER_ {
UINT32 Signature; // NVAR UINT32 Signature; // NVAR
UINT16 Size; // Size of the entry including header UINT16 Size; // Size of the entry including header
UINT32 Next : 24; // Offset to the next entry in a list, or empty if latest in the list UINT32 Next : 24; // Offset to the next entry in a list, or empty if the latest in the list
UINT32 Attributes : 8; // Attributes UINT32 Attributes : 8; // Attributes
} NVAR_ENTRY_HEADER; } NVAR_ENTRY_HEADER;
@ -49,14 +53,14 @@ typedef struct NVAR_ENTRY_HEADER_ {
#define NVRAM_NVAR_ENTRY_SIGNATURE 0x5241564E #define NVRAM_NVAR_ENTRY_SIGNATURE 0x5241564E
// Attributes // Attributes
#define NVRAM_NVAR_ENTRY_RUNTIME 0x01 #define NVRAM_NVAR_ENTRY_RUNTIME 0x01
#define NVRAM_NVAR_ENTRY_ASCII_NAME 0x02 #define NVRAM_NVAR_ENTRY_ASCII_NAME 0x02
#define NVRAM_NVAR_ENTRY_GUID 0x04 #define NVRAM_NVAR_ENTRY_GUID 0x04
#define NVRAM_NVAR_ENTRY_DATA_ONLY 0x08 #define NVRAM_NVAR_ENTRY_DATA_ONLY 0x08
#define NVRAM_NVAR_ENTRY_EXT_HEADER 0x10 #define NVRAM_NVAR_ENTRY_EXT_HEADER 0x10
#define NVRAM_NVAR_ENTRY_HW_ERROR_RECORD 0x20 #define NVRAM_NVAR_ENTRY_HW_ERROR_RECORD 0x20
#define NVRAM_NVAR_ENTRY_AUTH_WRITE 0x40 #define NVRAM_NVAR_ENTRY_AUTH_WRITE 0x40
#define NVRAM_NVAR_ENTRY_VALID 0x80 #define NVRAM_NVAR_ENTRY_VALID 0x80
// Extended attributes // Extended attributes
#define NVRAM_NVAR_ENTRY_EXT_CHECKSUM 0x01 #define NVRAM_NVAR_ENTRY_EXT_CHECKSUM 0x01

View File

@ -44,9 +44,6 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
emptyByte = readUnaligned(pdata).emptyByte; emptyByte = readUnaligned(pdata).emptyByte;
} }
// Rename parent file
model->setText(parentFileIndex, UString("NVAR store"));
// Get local offset // Get local offset
UINT32 localOffset = model->header(index).size(); UINT32 localOffset = model->header(index).size();
@ -539,7 +536,7 @@ USTATUS NvramParser::findNextStore(const UModelIndex & index, const UByteArray &
UINT32 offset = storeOffset; UINT32 offset = storeOffset;
for (; offset < dataSize - sizeof(UINT32); offset++) { for (; offset < dataSize - sizeof(UINT32); offset++) {
const UINT32* currentPos = (const UINT32*)(volume.constData() + offset); const UINT32* currentPos = (const UINT32*)(volume.constData() + offset);
if (*currentPos == NVRAM_VSS_STORE_SIGNATURE || *currentPos == NVRAM_APPLE_SVS_STORE_SIGNATURE) { //$VSS or $SVS signatures found, perform checks if (*currentPos == NVRAM_VSS_STORE_SIGNATURE || *currentPos == NVRAM_APPLE_SVS_STORE_SIGNATURE) { // $VSS or $SVS signatures found, perform checks
const VSS_VARIABLE_STORE_HEADER* vssHeader = (const VSS_VARIABLE_STORE_HEADER*)currentPos; const VSS_VARIABLE_STORE_HEADER* vssHeader = (const VSS_VARIABLE_STORE_HEADER*)currentPos;
if (vssHeader->Format != NVRAM_VSS_VARIABLE_STORE_FORMATTED) { if (vssHeader->Format != NVRAM_VSS_VARIABLE_STORE_FORMATTED) {
msg(usprintf("%s: VSS store candidate at offset %Xh skipped, has invalid format %02Xh", __FUNCTION__, localOffset + offset, vssHeader->Format), index); msg(usprintf("%s: VSS store candidate at offset %Xh skipped, has invalid format %02Xh", __FUNCTION__, localOffset + offset, vssHeader->Format), index);
@ -552,7 +549,7 @@ USTATUS NvramParser::findNextStore(const UModelIndex & index, const UByteArray &
// All checks passed, store found // All checks passed, store found
break; break;
} }
else if (*currentPos == NVRAM_VSS2_AUTH_VAR_KEY_DATABASE_GUID_PART1 || *currentPos == NVRAM_VSS2_STORE_GUID_PART1) { //VSS2 store signatures found, perform checks else if (*currentPos == NVRAM_VSS2_AUTH_VAR_KEY_DATABASE_GUID_PART1 || *currentPos == NVRAM_VSS2_STORE_GUID_PART1) { // VSS2 store signatures found, perform checks
UByteArray guid = UByteArray(volume.constData() + offset, sizeof(EFI_GUID)); UByteArray guid = UByteArray(volume.constData() + offset, sizeof(EFI_GUID));
if (guid != NVRAM_VSS2_AUTH_VAR_KEY_DATABASE_GUID && guid != NVRAM_VSS2_STORE_GUID) // Check the whole signature if (guid != NVRAM_VSS2_AUTH_VAR_KEY_DATABASE_GUID && guid != NVRAM_VSS2_STORE_GUID) // Check the whole signature
continue; continue;
@ -569,7 +566,7 @@ USTATUS NvramParser::findNextStore(const UModelIndex & index, const UByteArray &
// All checks passed, store found // All checks passed, store found
break; break;
} }
else if (*currentPos == NVRAM_FDC_VOLUME_SIGNATURE) { //FDC signature found else if (*currentPos == NVRAM_FDC_VOLUME_SIGNATURE) { // FDC signature found
const FDC_VOLUME_HEADER* fdcHeader = (const FDC_VOLUME_HEADER*)currentPos; const FDC_VOLUME_HEADER* fdcHeader = (const FDC_VOLUME_HEADER*)currentPos;
if (fdcHeader->Size == 0 || fdcHeader->Size == 0xFFFFFFFF) { if (fdcHeader->Size == 0 || fdcHeader->Size == 0xFFFFFFFF) {
msg(usprintf("%s: FDC store candidate at offset %Xh skipped, has invalid size %Xh", __FUNCTION__, localOffset + offset, fdcHeader->Size), index); msg(usprintf("%s: FDC store candidate at offset %Xh skipped, has invalid size %Xh", __FUNCTION__, localOffset + offset, fdcHeader->Size), index);
@ -578,7 +575,7 @@ USTATUS NvramParser::findNextStore(const UModelIndex & index, const UByteArray &
// All checks passed, store found // All checks passed, store found
break; break;
} }
else if (*currentPos == NVRAM_APPLE_FSYS_STORE_SIGNATURE || *currentPos == NVRAM_APPLE_GAID_STORE_SIGNATURE) { //Fsys or Gaid signature found else if (*currentPos == NVRAM_APPLE_FSYS_STORE_SIGNATURE || *currentPos == NVRAM_APPLE_GAID_STORE_SIGNATURE) { // Fsys or Gaid signature found
const APPLE_FSYS_STORE_HEADER* fsysHeader = (const APPLE_FSYS_STORE_HEADER*)currentPos; const APPLE_FSYS_STORE_HEADER* fsysHeader = (const APPLE_FSYS_STORE_HEADER*)currentPos;
if (fsysHeader->Size == 0 || fsysHeader->Size == 0xFFFF) { if (fsysHeader->Size == 0 || fsysHeader->Size == 0xFFFF) {
msg(usprintf("%s: Fsys store candidate at offset %Xh skipped, has invalid size %Xh", __FUNCTION__, localOffset + offset, fsysHeader->Size), index); msg(usprintf("%s: Fsys store candidate at offset %Xh skipped, has invalid size %Xh", __FUNCTION__, localOffset + offset, fsysHeader->Size), index);
@ -604,7 +601,7 @@ USTATUS NvramParser::findNextStore(const UModelIndex & index, const UByteArray &
offset -= sizeof(UINT32); offset -= sizeof(UINT32);
break; break;
} }
else if (*currentPos == NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 || *currentPos == EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1) { //Possible FTW block signature found else if (*currentPos == NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 || *currentPos == EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1) { // Possible FTW block signature found
UByteArray guid = UByteArray(volume.constData() + offset, sizeof(EFI_GUID)); UByteArray guid = UByteArray(volume.constData() + offset, sizeof(EFI_GUID));
if (guid != NVRAM_MAIN_STORE_VOLUME_GUID && guid != EDKII_WORKING_BLOCK_SIGNATURE_GUID && guid != VSS2_WORKING_BLOCK_SIGNATURE_GUID) // Check the whole signature if (guid != NVRAM_MAIN_STORE_VOLUME_GUID && guid != EDKII_WORKING_BLOCK_SIGNATURE_GUID && guid != VSS2_WORKING_BLOCK_SIGNATURE_GUID) // Check the whole signature
continue; continue;