mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-21 23:48:22 +08:00
Rename readMisaligned to readUnaligned
This commit is contained in:
parent
f2cdf7dc3b
commit
5b26775463
@ -44,9 +44,9 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
|
||||
|
||||
if (guid.isEmpty() ||
|
||||
(model->subtype(index) == EFI_SECTION_FREEFORM_SUBTYPE_GUID &&
|
||||
guidToUString(readMisaligned((const EFI_GUID*)(model->header(index).constData() + sizeof(EFI_COMMON_SECTION_HEADER)))) == guid) ||
|
||||
guidToUString(readMisaligned((const EFI_GUID*)model->header(index).constData())) == guid ||
|
||||
guidToUString(readMisaligned((const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData())) == guid) {
|
||||
guidToUString(readUnaligned((const EFI_GUID*)(model->header(index).constData() + sizeof(EFI_COMMON_SECTION_HEADER)))) == guid) ||
|
||||
guidToUString(readUnaligned((const EFI_GUID*)model->header(index).constData())) == guid ||
|
||||
guidToUString(readUnaligned((const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData())) == guid) {
|
||||
|
||||
if (!changeDirectory(path) && !makeDirectory(path))
|
||||
return U_DIR_CREATE;
|
||||
|
@ -67,12 +67,12 @@ USTATUS UEFIFind::find(const UINT8 mode, const bool count, const UString & hexPa
|
||||
std::pair<UModelIndex, UModelIndex> indexes = *citer;
|
||||
if (!model->hasEmptyHeader(indexes.first))
|
||||
data = model->header(indexes.first).left(16);
|
||||
result += guidToUString(readMisaligned((const EFI_GUID*)data.constData()));
|
||||
result += guidToUString(readUnaligned((const EFI_GUID*)data.constData()));
|
||||
|
||||
// Special case of freeform subtype GUID files
|
||||
if (indexes.second.isValid() && model->subtype(indexes.second) == EFI_SECTION_FREEFORM_SUBTYPE_GUID) {
|
||||
data = model->header(indexes.second);
|
||||
result += UString(" ") + (guidToUString(readMisaligned((const EFI_GUID*)(data.constData() + sizeof(EFI_COMMON_SECTION_HEADER)))));
|
||||
result += UString(" ") + (guidToUString(readUnaligned((const EFI_GUID*)(data.constData() + sizeof(EFI_COMMON_SECTION_HEADER)))));
|
||||
}
|
||||
|
||||
result += UString("\n");
|
||||
|
@ -1162,7 +1162,7 @@ USTATUS FfsParser::findNextRawAreaItem(const UModelIndex & index, const UINT32 l
|
||||
for (; offset < dataSize - sizeof(UINT32); offset++) {
|
||||
const UINT32* currentPos = (const UINT32*)(data.constData() + offset);
|
||||
const UINT32 restSize = dataSize - offset;
|
||||
if (readMisaligned(currentPos) == INTEL_MICROCODE_HEADER_VERSION) {// Intel microcode
|
||||
if (readUnaligned(currentPos) == INTEL_MICROCODE_HEADER_VERSION) {// Intel microcode
|
||||
// Check data size
|
||||
if (restSize < sizeof(INTEL_MICROCODE_HEADER))
|
||||
continue;
|
||||
@ -1189,7 +1189,7 @@ USTATUS FfsParser::findNextRawAreaItem(const UModelIndex & index, const UINT32 l
|
||||
nextItemOffset = offset;
|
||||
break;
|
||||
}
|
||||
else if (readMisaligned(currentPos) == EFI_FV_SIGNATURE) {
|
||||
else if (readUnaligned(currentPos) == EFI_FV_SIGNATURE) {
|
||||
if (offset < EFI_FV_SIGNATURE_OFFSET)
|
||||
continue;
|
||||
|
||||
@ -1392,7 +1392,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Check GUIDs for being equal
|
||||
if (currentGuid == anotherGuid) {
|
||||
msg(usprintf("%s: file with duplicate GUID ", __FUNCTION__) + guidToUString(readMisaligned((EFI_GUID*)(anotherGuid.data()))), another);
|
||||
msg(usprintf("%s: file with duplicate GUID ", __FUNCTION__) + guidToUString(readUnaligned((EFI_GUID*)(anotherGuid.data()))), another);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2456,8 +2456,8 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index)
|
||||
if (model->hasEmptyParsingData(index) == false) {
|
||||
UByteArray data = model->parsingData(index);
|
||||
const COMPRESSED_SECTION_PARSING_DATA* pdata = (const COMPRESSED_SECTION_PARSING_DATA*)data.constData();
|
||||
compressionType = readMisaligned(pdata).compressionType;
|
||||
uncompressedSize = readMisaligned(pdata).uncompressedSize;
|
||||
compressionType = readUnaligned(pdata).compressionType;
|
||||
uncompressedSize = readUnaligned(pdata).uncompressedSize;
|
||||
}
|
||||
|
||||
// Decompress section
|
||||
@ -2523,7 +2523,7 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index)
|
||||
if (model->hasEmptyParsingData(index) == false) {
|
||||
UByteArray data = model->parsingData(index);
|
||||
const GUIDED_SECTION_PARSING_DATA* pdata = (const GUIDED_SECTION_PARSING_DATA*)data.constData();
|
||||
guid = readMisaligned(pdata).guid;
|
||||
guid = readUnaligned(pdata).guid;
|
||||
}
|
||||
|
||||
// Check if section requires processing
|
||||
@ -2643,7 +2643,7 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index)
|
||||
return U_SUCCESS;
|
||||
}
|
||||
guid = (const EFI_GUID*)(current + EFI_DEP_OPCODE_SIZE);
|
||||
parsed += UString("\nBEFORE ") + guidToUString(readMisaligned(guid));
|
||||
parsed += UString("\nBEFORE ") + guidToUString(readUnaligned(guid));
|
||||
current += EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID);
|
||||
if (*current != EFI_DEP_END){
|
||||
msg(usprintf("%s: DEPEX section ends with non-END opcode", __FUNCTION__), index);
|
||||
@ -2656,7 +2656,7 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index)
|
||||
return U_SUCCESS;
|
||||
}
|
||||
guid = (const EFI_GUID*)(current + EFI_DEP_OPCODE_SIZE);
|
||||
parsed += UString("\nAFTER ") + guidToUString(readMisaligned(guid));
|
||||
parsed += UString("\nAFTER ") + guidToUString(readUnaligned(guid));
|
||||
current += EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID);
|
||||
if (*current != EFI_DEP_END) {
|
||||
msg(usprintf("%s: DEPEX section ends with non-END opcode", __FUNCTION__), index);
|
||||
@ -2696,7 +2696,7 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index)
|
||||
return U_SUCCESS;
|
||||
}
|
||||
guid = (const EFI_GUID*)(current + EFI_DEP_OPCODE_SIZE);
|
||||
parsed += UString("\nPUSH ") + guidToUString(readMisaligned(guid));
|
||||
parsed += UString("\nPUSH ") + guidToUString(readUnaligned(guid));
|
||||
current += EFI_DEP_OPCODE_SIZE + sizeof(EFI_GUID);
|
||||
break;
|
||||
case EFI_DEP_AND:
|
||||
@ -2769,7 +2769,7 @@ USTATUS FfsParser::parseAprioriRawSection(const UByteArray & body, UString & par
|
||||
if (count > 0) {
|
||||
for (UINT32 i = 0; i < count; i++) {
|
||||
const EFI_GUID* guid = (const EFI_GUID*)body.constData() + i;
|
||||
parsed += UString("\n") + guidToUString(readMisaligned(guid));
|
||||
parsed += UString("\n") + guidToUString(readUnaligned(guid));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3026,8 +3026,8 @@ USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index)
|
||||
if (model->hasEmptyParsingData(index) == false) {
|
||||
UByteArray data = model->parsingData(index);
|
||||
const TE_IMAGE_SECTION_PARSING_DATA* pdata = (const TE_IMAGE_SECTION_PARSING_DATA*)data.constData();
|
||||
originalImageBase = readMisaligned(pdata).imageBase;
|
||||
adjustedImageBase = readMisaligned(pdata).adjustedImageBase;
|
||||
originalImageBase = readUnaligned(pdata).imageBase;
|
||||
adjustedImageBase = readUnaligned(pdata).adjustedImageBase;
|
||||
}
|
||||
|
||||
if (imageBase != 0) {
|
||||
|
@ -39,7 +39,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
if (parentFileIndex.isValid() && model->hasEmptyParsingData(parentFileIndex) == false) {
|
||||
UByteArray data = model->parsingData(parentFileIndex);
|
||||
const FILE_PARSING_DATA* pdata = (const FILE_PARSING_DATA*)data.constData();
|
||||
emptyByte = readMisaligned(pdata).emptyByte;
|
||||
emptyByte = readUnaligned(pdata).emptyByte;
|
||||
}
|
||||
|
||||
// Rename parent file
|
||||
@ -156,7 +156,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
hasExtendedHeader = true;
|
||||
msgUnknownExtDataFormat = true;
|
||||
|
||||
extendedHeaderSize = readMisaligned((UINT16*)(body.constData() + body.size() - sizeof(UINT16)));
|
||||
extendedHeaderSize = readUnaligned((UINT16*)(body.constData() + body.size() - sizeof(UINT16)));
|
||||
if (extendedHeaderSize > (UINT32)body.size()) {
|
||||
msgExtHeaderTooLong = true;
|
||||
isInvalid = true;
|
||||
@ -203,7 +203,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
goto parsing_done;
|
||||
}
|
||||
|
||||
timestamp = readMisaligned(tail.constData() + sizeof(UINT8));
|
||||
timestamp = readUnaligned(tail.constData() + sizeof(UINT8));
|
||||
hasTimestamp = true;
|
||||
msgUnknownExtDataFormat = false;
|
||||
}
|
||||
@ -215,7 +215,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
goto parsing_done;
|
||||
}
|
||||
|
||||
timestamp = readMisaligned((UINT64*)(tail.constData()) + sizeof(UINT8));
|
||||
timestamp = readUnaligned((UINT64*)(tail.constData()) + sizeof(UINT8));
|
||||
hash = tail.mid(sizeof(UINT64) + sizeof(UINT8), SHA256_HASH_SIZE);
|
||||
hasTimestamp = true;
|
||||
hasHash = true;
|
||||
@ -272,8 +272,8 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
|
||||
// Get entry GUID
|
||||
if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_GUID) { // GUID is strored in the variable itself
|
||||
name = guidToUString(readMisaligned((EFI_GUID*)(entryHeader + 1)));
|
||||
guid = guidToUString(readMisaligned((EFI_GUID*)(entryHeader + 1)), false);
|
||||
name = guidToUString(readUnaligned((EFI_GUID*)(entryHeader + 1)));
|
||||
guid = guidToUString(readUnaligned((EFI_GUID*)(entryHeader + 1)), false);
|
||||
}
|
||||
// GUID is stored in GUID list at the end of the store
|
||||
else {
|
||||
@ -283,8 +283,8 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
|
||||
// The list begins at the end of the store and goes backwards
|
||||
const EFI_GUID* guidPtr = (const EFI_GUID*)(data.constData() + data.size()) - 1 - guidIndex;
|
||||
name = guidToUString(readMisaligned(guidPtr));
|
||||
guid = guidToUString(readMisaligned(guidPtr), false);
|
||||
name = guidToUString(readUnaligned(guidPtr));
|
||||
guid = guidToUString(readUnaligned(guidPtr), false);
|
||||
hasGuidIndex = true;
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
|
||||
// Try parsing the entry data as NVAR storage if it begins with NVAR signature
|
||||
if ((subtype == Subtypes::DataNvarEntry || subtype == Subtypes::FullNvarEntry)
|
||||
&& body.size() >= 4 && readMisaligned((const UINT32*)body.constData()) == NVRAM_NVAR_ENTRY_SIGNATURE)
|
||||
&& body.size() >= 4 && readUnaligned((const UINT32*)body.constData()) == NVRAM_NVAR_ENTRY_SIGNATURE)
|
||||
parseNvarStore(varIndex);
|
||||
|
||||
// Move to next exntry
|
||||
@ -1496,8 +1496,8 @@ USTATUS NvramParser::parseVssStoreBody(const UModelIndex & index, UINT8 alignmen
|
||||
name = UString("Invalid");
|
||||
}
|
||||
else { // Add GUID and text for valid variables
|
||||
name = guidToUString(readMisaligned(variableGuid));
|
||||
info += UString("Variable GUID: ") + guidToUString(readMisaligned(variableGuid), false) + UString("\n");
|
||||
name = guidToUString(readUnaligned(variableGuid));
|
||||
info += UString("Variable GUID: ") + guidToUString(readUnaligned(variableGuid), false) + UString("\n");
|
||||
text = UString::fromUtf16(variableName);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSi
|
||||
|
||||
// Safely dereferences misaligned pointers
|
||||
template <typename T>
|
||||
inline T readMisaligned(const T *v) {
|
||||
inline T readUnaligned(const T *v) {
|
||||
T tmp;
|
||||
memcpy(&tmp, v, sizeof(T));
|
||||
return tmp;
|
||||
|
Loading…
Reference in New Issue
Block a user