mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-23 11:37:05 -04:00
Improve parsing error detection for DVARs
This commit is contained in:
parent
c235533f22
commit
7237a29b17
1 changed files with 111 additions and 94 deletions
|
@ -1171,28 +1171,46 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a normal entry
|
// Check entry format to be known
|
||||||
|
bool formatKnown = true;
|
||||||
// Check state to be known
|
// Check state to be known
|
||||||
if (entry->state() != DVAR_ENTRY_STATE_STORING &&
|
if (entry->state() != DVAR_ENTRY_STATE_STORING &&
|
||||||
entry->state() != DVAR_ENTRY_STATE_STORED &&
|
entry->state() != DVAR_ENTRY_STATE_STORED &&
|
||||||
entry->state() != DVAR_ENTRY_STATE_DELETING &&
|
entry->state() != DVAR_ENTRY_STATE_DELETING &&
|
||||||
entry->state() != DVAR_ENTRY_STATE_DELETED){
|
entry->state() != DVAR_ENTRY_STATE_DELETED){
|
||||||
// TODO: Add the rest as padding, as we encountered an unexpected entry and can't guarantee that the rest got parsed correctly
|
formatKnown = false;
|
||||||
|
msg(usprintf("%s: DVAR entry with unknown state %02X", __FUNCTION__, entry->state()), headerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check flags to be known
|
// Check flags to be known
|
||||||
if (entry->flags() != DVAR_ENTRY_FLAG_NAME_ID &&
|
if (entry->flags() != DVAR_ENTRY_FLAG_NAME_ID &&
|
||||||
entry->flags() != DVAR_ENTRY_FLAG_NAME_ID + DVAR_ENTRY_FLAG_NAMESPACE_GUID) {
|
entry->flags() != DVAR_ENTRY_FLAG_NAME_ID + DVAR_ENTRY_FLAG_NAMESPACE_GUID) {
|
||||||
// TODO: Add the rest as padding, as we encountered an unexpected entry and can't guarantee that the rest got parsed correctly
|
formatKnown = false;
|
||||||
|
msg(usprintf("%s: DVAR entry with unknown flags %02X", __FUNCTION__, entry->flags()), headerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check type to be known
|
// Check type to be known
|
||||||
if (entry->type() != DVAR_ENTRY_TYPE_NAME_ID_8_DATA_SIZE_8 &&
|
if (entry->type() != DVAR_ENTRY_TYPE_NAME_ID_8_DATA_SIZE_8 &&
|
||||||
entry->type() != DVAR_ENTRY_TYPE_NAME_ID_16_DATA_SIZE_8 &&
|
entry->type() != DVAR_ENTRY_TYPE_NAME_ID_16_DATA_SIZE_8 &&
|
||||||
entry->type() != DVAR_ENTRY_TYPE_NAME_ID_16_DATA_SIZE_16) {
|
entry->type() != DVAR_ENTRY_TYPE_NAME_ID_16_DATA_SIZE_16) {
|
||||||
// TODO: Add the rest as padding, as we encountered an unexpected entry and can't guarantee that the rest got parsed correctly
|
formatKnown = false;
|
||||||
|
msg(usprintf("%s: DVAR entry with unknown type %02X", __FUNCTION__, entry->type()), headerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is an unknown entry
|
||||||
|
if (!formatKnown) {
|
||||||
|
// No way to continue from here, because we can not be sure that the rest of the store got parsed correctly
|
||||||
|
UByteArray padding = data.mid(entryOffset, storeSize - entryOffset);
|
||||||
|
|
||||||
|
// Get info
|
||||||
|
name = UString("Padding");
|
||||||
|
info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size());
|
||||||
|
|
||||||
|
// Add tree item
|
||||||
|
model->addItem(entryOffset, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, headerIndex);
|
||||||
|
}
|
||||||
|
// This is a normal entry
|
||||||
|
else {
|
||||||
UINT32 headerSize;
|
UINT32 headerSize;
|
||||||
UINT32 bodySize;
|
UINT32 bodySize;
|
||||||
UINT32 entrySize;
|
UINT32 entrySize;
|
||||||
|
@ -1200,8 +1218,6 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
||||||
UINT8 subtype;
|
UINT8 subtype;
|
||||||
UString text;
|
UString text;
|
||||||
|
|
||||||
// TODO: find a Dell image with NameUtf8 entries
|
|
||||||
|
|
||||||
// NamespaceGUID entry
|
// NamespaceGUID entry
|
||||||
if (entry->flags() == DVAR_ENTRY_FLAG_NAME_ID + DVAR_ENTRY_FLAG_NAMESPACE_GUID) {
|
if (entry->flags() == DVAR_ENTRY_FLAG_NAME_ID + DVAR_ENTRY_FLAG_NAMESPACE_GUID) {
|
||||||
// State of this variable only applies to the NameId part, not the NamespaceGuid part
|
// State of this variable only applies to the NameId part, not the NamespaceGuid part
|
||||||
|
@ -1294,6 +1310,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
||||||
entryOffset += entrySize;
|
entryOffset += entrySize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// Parsing failed, need to add the candidate as Padding
|
// Parsing failed, need to add the candidate as Padding
|
||||||
UByteArray padding = data.mid(itemOffset, itemSize);
|
UByteArray padding = data.mid(itemOffset, itemSize);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue