diff --git a/UEFITool/ffsfinder.cpp b/UEFITool/ffsfinder.cpp index 38dcbfe..51a2f0e 100644 --- a/UEFITool/ffsfinder.cpp +++ b/UEFITool/ffsfinder.cpp @@ -91,7 +91,7 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray & msg(UString("Hex pattern \"") + UString(hexPattern) + UString("\" found as \"") + hexBody.mid(offset, hexPattern.length()).toUpper() + UString("\" in ") + name - + usprintf(" at %s-offset 0x%02X", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2), + + usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2), index); ret = U_SUCCESS; } @@ -193,7 +193,7 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray & msg(UString("GUID pattern \"") + UString(guidPattern) + UString("\" found as \"") + hexBody.mid(offset, hexPattern.length()).toUpper() + UString("\" in ") + name - + usprintf(" at %s-offset 0x%02X", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2), + + usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2), index); ret = U_SUCCESS; } @@ -267,7 +267,7 @@ USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pa msg((unicode ? UString("Unicode") : UString("ASCII")) + UString(" text \"") + UString(pattern) + UString("\" found in ") + name - + usprintf(" at %s-offset 0x%02X", mode == SEARCH_MODE_BODY ? "body" : "header", offset), + + usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset), index); ret = U_SUCCESS; } diff --git a/common/descriptor.cpp b/common/descriptor.cpp index 4ffb73a..324b005 100644 --- a/common/descriptor.cpp +++ b/common/descriptor.cpp @@ -249,5 +249,5 @@ UString jedecIdToUString(UINT8 vendorId, UINT8 deviceId0, UINT8 deviceId1) case 0x9D7019: return UString("ISSI Ix25WP256"); } - return usprintf("Unknown 0x%08X", jedecId); + return usprintf("Unknown %08Xh", jedecId); } diff --git a/common/ffs.cpp b/common/ffs.cpp index 6ac146a..c9b7ac2 100644 --- a/common/ffs.cpp +++ b/common/ffs.cpp @@ -296,7 +296,7 @@ UString fileTypeToUString(const UINT8 type) case EFI_FV_FILETYPE_MM_CORE_STANDALONE: return UString("MM standalone core"); case EFI_FV_FILETYPE_PAD: return UString("Pad"); }; - return usprintf("Unknown 0x%02X", type); + return usprintf("Unknown %02Xh", type); } UString sectionTypeToUString(const UINT8 type) @@ -320,7 +320,7 @@ UString sectionTypeToUString(const UINT8 type) case INSYDE_SECTION_POSTCODE: return UString("Insyde postcode"); case PHOENIX_SECTION_POSTCODE: return UString("Phoenix postcode"); } - return usprintf("Unknown 0x%02X", type); + return usprintf("Unknown %02Xh", type); } UString bpdtEntryTypeToUString(const UINT16 type) @@ -373,7 +373,7 @@ UString bpdtEntryTypeToUString(const UINT16 type) case BPDT_ENTRY_TYPE_TCCP: return UString("TCC"); case BPDT_ENTRY_TYPE_PSEP: return UString("PSE"); } - return usprintf("Unknown 0x%04X", type); + return usprintf("Unknown %04Xh", type); } UString cpdExtensionTypeToUstring(const UINT32 type) @@ -412,5 +412,5 @@ UString cpdExtensionTypeToUstring(const UINT32 type) case CPD_EXT_TYPE_SIGNED_PACKAGE_INFO_EXT: return UString("Extended Signed Package Info"); case CPD_EXT_TYPE_SPS_PLATFORM_ID: return UString("SPS Platform ID"); } - return usprintf("Unknown 0x%08X", type); + return usprintf("Unknown %08Xh", type); } diff --git a/common/ffsbuilder.cpp b/common/ffsbuilder.cpp index c1902c2..dac3fa5 100644 --- a/common/ffsbuilder.cpp +++ b/common/ffsbuilder.cpp @@ -126,11 +126,11 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule UINT32 newSize = (UINT32)capsule.size(); UINT32 oldSize = (UINT32)model->body(index).size(); if (newSize > oldSize) { - msg(usprintf("buildCapsule: new capsule size 0x%X (%u) is bigger than the original 0x%X (%u)", newSize, newSize, oldSize, oldSize), index); + msg(usprintf("buildCapsule: new capsule size %Xh (%u) is bigger than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index); return U_INVALID_CAPSULE; } else if (newSize < oldSize) { - msg(usprintf("buildCapsule: new capsule size 0x%X (%u) is smaller than the original 0x%X (%u)", newSize, newSize, oldSize, oldSize), index); + msg(usprintf("buildCapsule: new capsule size %Xh (%u) is smaller than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index); return U_INVALID_CAPSULE; } } @@ -225,11 +225,11 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte UINT32 newSize = (UINT32)intelImage.size(); UINT32 oldSize = (UINT32)model->body(index).size(); if (newSize > oldSize) { - msg(usprintf("buildIntelImage: new image size 0x%X (%u) is bigger than the original 0x%X (%u)", newSize, newSize, oldSize, oldSize), index); + msg(usprintf("buildIntelImage: new image size %Xh (%u) is bigger than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index); return U_INVALID_IMAGE; } else if (newSize < oldSize) { - msg(usprintf("buildIntelImage: new image size 0x%X (%u) is smaller than the original 0x%X (%u)", newSize, newSize, oldSize, oldSize), index); + msg(usprintf("buildIntelImage: new image size %Xh (%u) is smaller than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index); return U_INVALID_IMAGE; } @@ -296,11 +296,11 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea UINT32 newSize = (UINT32)rawArea.size(); UINT32 oldSize = (UINT32)model->body(index).size(); if (newSize > oldSize) { - msg(usprintf("buildRawArea: new area size 0x%X (%u) is bigger than the original 0x%X (%u)", newSize, newSize, oldSize, oldSize), index); + msg(usprintf("buildRawArea: new area size %Xh (%u) is bigger than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index); return U_INVALID_RAW_AREA; } else if (newSize < oldSize) { - msg(usprintf("buildRawArea: new area size 0x%X (%u) is smaller than the original 0x%X (%u)", newSize, newSize, oldSize, oldSize), index); + msg(usprintf("buildRawArea: new area size %Xh (%u) is smaller than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index); return U_INVALID_RAW_AREA; } } diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 8941009..ed89ef4 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -136,7 +136,7 @@ USTATUS FfsParser::parseGenericImage(const UByteArray & buffer, const UINT32 loc { // Parse as generic UEFI image UString name("UEFI image"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)buffer.size(), (UINT32)buffer.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)buffer.size(), (UINT32)buffer.size()); // Add tree item index = model->addItem(localOffset, Types::Image, Subtypes::UefiImage, name, UString(), info, UByteArray(), buffer, UByteArray(), Fixed, parent); @@ -167,13 +167,13 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf // Check sanity of HeaderSize and CapsuleImageSize values if (capsuleHeader->HeaderSize == 0 || capsuleHeader->HeaderSize > (UINT32)capsule.size() || capsuleHeader->HeaderSize > capsuleHeader->CapsuleImageSize) { - msg(usprintf("%s: UEFI capsule header size of 0x%X (%u) bytes is invalid", __FUNCTION__, + msg(usprintf("%s: UEFI capsule header size of %Xh (%u) bytes is invalid", __FUNCTION__, capsuleHeader->HeaderSize, capsuleHeader->HeaderSize)); return U_INVALID_CAPSULE; } if (capsuleHeader->CapsuleImageSize > (UINT32)capsule.size()) { - msg(usprintf("%s: UEFI capsule image size of 0x%X (%u) bytes is invalid", __FUNCTION__, + msg(usprintf("%s: UEFI capsule image size of %Xh (%u) bytes is invalid", __FUNCTION__, capsuleHeader->CapsuleImageSize, capsuleHeader->CapsuleImageSize)); return U_INVALID_CAPSULE; @@ -184,7 +184,7 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf UByteArray body = capsule.mid(capsuleHeaderSize); UString name("UEFI capsule"); UString info = UString("Capsule GUID: ") + guidToUString(capsuleHeader->CapsuleGuid, false) + - usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nImage size: 0x%X (%u)\nFlags: 0x%08X", + usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nImage size: %Xh (%u)\nFlags: %08Xh", (UINT32)capsule.size(), (UINT32)capsule.size(), capsuleHeaderSize, capsuleHeaderSize, capsuleHeader->CapsuleImageSize - capsuleHeaderSize, capsuleHeader->CapsuleImageSize - capsuleHeaderSize, @@ -201,12 +201,12 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf // Check sanity of HeaderSize and FullSize values if (capsuleHeader->HeaderSize == 0 || capsuleHeader->HeaderSize > (UINT32)capsule.size() || capsuleHeader->HeaderSize > capsuleHeader->FullSize) { - msg(usprintf("%s: Toshiba capsule header size of 0x%X (%u) bytes is invalid", __FUNCTION__, + msg(usprintf("%s: Toshiba capsule header size of %Xh (%u) bytes is invalid", __FUNCTION__, capsuleHeader->HeaderSize, capsuleHeader->HeaderSize)); return U_INVALID_CAPSULE; } if (capsuleHeader->FullSize > (UINT32)capsule.size()) { - msg(usprintf("%s: Toshiba capsule full size of 0x%X (%u) bytes is invalid", __FUNCTION__, + msg(usprintf("%s: Toshiba capsule full size of %Xh (%u) bytes is invalid", __FUNCTION__, capsuleHeader->FullSize, capsuleHeader->FullSize)); return U_INVALID_CAPSULE; } @@ -216,7 +216,7 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf UByteArray body = capsule.mid(capsuleHeaderSize); UString name("Toshiba capsule"); UString info = UString("Capsule GUID: ") + guidToUString(capsuleHeader->CapsuleGuid, false) + - usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nImage size: 0x%X (%u)\nFlags: 0x%08X", + usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nImage size: %Xh (%u)\nFlags: %08Xh", (UINT32)capsule.size(), (UINT32)capsule.size(), capsuleHeaderSize, capsuleHeaderSize, capsuleHeader->FullSize - capsuleHeaderSize, capsuleHeader->FullSize - capsuleHeaderSize, @@ -231,7 +231,7 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf bool signedCapsule = capsule.startsWith(APTIO_SIGNED_CAPSULE_GUID); if ((UINT32)capsule.size() <= sizeof(APTIO_CAPSULE_HEADER)) { - msg(usprintf("%s: AMI capsule image file is smaller than minimum size of 0x20 (32) bytes", __FUNCTION__)); + msg(usprintf("%s: AMI capsule image file is smaller than minimum size of 20h (32) bytes", __FUNCTION__)); return U_INVALID_CAPSULE; } @@ -241,12 +241,12 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf // Check sanity of RomImageOffset and CapsuleImageSize values if (capsuleHeader->RomImageOffset == 0 || capsuleHeader->RomImageOffset > (UINT32)capsule.size() || capsuleHeader->RomImageOffset > capsuleHeader->CapsuleHeader.CapsuleImageSize) { - msg(usprintf("%s: AMI capsule image offset of 0x%X (%u) bytes is invalid", __FUNCTION__, + msg(usprintf("%s: AMI capsule image offset of %Xh (%u) bytes is invalid", __FUNCTION__, capsuleHeader->RomImageOffset, capsuleHeader->RomImageOffset)); return U_INVALID_CAPSULE; } if (capsuleHeader->CapsuleHeader.CapsuleImageSize > (UINT32)capsule.size()) { - msg(usprintf("%s: AMI capsule image size of 0x%X (%u) bytes is invalid", __FUNCTION__, + msg(usprintf("%s: AMI capsule image size of %Xh (%u) bytes is invalid", __FUNCTION__, capsuleHeader->CapsuleHeader.CapsuleImageSize, capsuleHeader->CapsuleHeader.CapsuleImageSize)); return U_INVALID_CAPSULE; @@ -257,7 +257,7 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf UByteArray body = capsule.mid(capsuleHeaderSize); UString name("AMI Aptio capsule"); UString info = UString("Capsule GUID: ") + guidToUString(capsuleHeader->CapsuleHeader.CapsuleGuid, false) + - usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nImage size: 0x%X (%u)\nFlags: 0x%08X", + usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nImage size: %Xh (%u)\nFlags: %08Xh", (UINT32)capsule.size(), (UINT32)capsule.size(), capsuleHeaderSize, capsuleHeaderSize, capsuleHeader->CapsuleHeader.CapsuleImageSize - capsuleHeaderSize, capsuleHeader->CapsuleHeader.CapsuleImageSize - capsuleHeaderSize, @@ -293,7 +293,7 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l { // Check for buffer size to be greater or equal to descriptor region size if (intelImage.size() < FLASH_DESCRIPTOR_SIZE) { - msg(usprintf("%s: input file is smaller than minimum descriptor size of 0x%X (%u) bytes", __FUNCTION__, FLASH_DESCRIPTOR_SIZE, FLASH_DESCRIPTOR_SIZE)); + msg(usprintf("%s: input file is smaller than minimum descriptor size of %Xh (%u) bytes", __FUNCTION__, FLASH_DESCRIPTOR_SIZE, FLASH_DESCRIPTOR_SIZE)); return U_ITEM_NOT_FOUND; } @@ -313,16 +313,16 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l if (descriptorMap->MasterBase > FLASH_DESCRIPTOR_MAX_BASE || descriptorMap->MasterBase == descriptorMap->RegionBase || descriptorMap->MasterBase == descriptorMap->ComponentBase) { - msg(usprintf("%s: invalid descriptor master base 0x%02X", __FUNCTION__, descriptorMap->MasterBase)); + msg(usprintf("%s: invalid descriptor master base %02Xh", __FUNCTION__, descriptorMap->MasterBase)); return U_INVALID_FLASH_DESCRIPTOR; } if (descriptorMap->RegionBase > FLASH_DESCRIPTOR_MAX_BASE || descriptorMap->RegionBase == descriptorMap->ComponentBase) { - msg(usprintf("%s: invalid descriptor region base 0x%02X", __FUNCTION__, descriptorMap->RegionBase)); + msg(usprintf("%s: invalid descriptor region base %02Xh", __FUNCTION__, descriptorMap->RegionBase)); return U_INVALID_FLASH_DESCRIPTOR; } if (descriptorMap->ComponentBase > FLASH_DESCRIPTOR_MAX_BASE) { - msg(usprintf("%s: invalid descriptor component base 0x%02X", __FUNCTION__, descriptorMap->ComponentBase)); + msg(usprintf("%s: invalid descriptor component base %02Xh", __FUNCTION__, descriptorMap->ComponentBase)); return U_INVALID_FLASH_DESCRIPTOR; } @@ -478,7 +478,7 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l // Intel image UString name("Intel image"); - UString info = usprintf("Full size: 0x%X (%u)\nFlash chips: %u\nRegions: %u\nMasters: %u\nPCH straps: %u\nPROC straps: %u", + UString info = usprintf("Full size: %Xh (%u)\nFlash chips: %u\nRegions: %u\nMasters: %u\nPCH straps: %u\nPROC straps: %u", (UINT32)intelImage.size(), (UINT32)intelImage.size(), descriptorMap->NumberOfFlashChips + 1, // descriptorMap->NumberOfRegions + 1, // Zero-based numbers in storage @@ -497,7 +497,7 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l UByteArray body = intelImage.left(FLASH_DESCRIPTOR_SIZE); name = UString("Descriptor region"); info = usprintf("ReservedVector:\n%02X %02X %02X %02X %02X %02X %02X %02X\n" - "%02X %02X %02X %02X %02X %02X %02X %02X\nFull size: 0x%X (%u)", + "%02X %02X %02X %02X %02X %02X %02X %02X\nFull size: %Xh (%u)", descriptor->ReservedVector[0], descriptor->ReservedVector[1], descriptor->ReservedVector[2], descriptor->ReservedVector[3], descriptor->ReservedVector[4], descriptor->ReservedVector[5], descriptor->ReservedVector[6], descriptor->ReservedVector[7], descriptor->ReservedVector[8], descriptor->ReservedVector[9], descriptor->ReservedVector[10], descriptor->ReservedVector[11], @@ -508,16 +508,14 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l for (size_t i = 0; i < regions.size(); i++) { if (regions[i].type != Subtypes::ZeroPadding && regions[i].type != Subtypes::OnePadding && regions[i].type != Subtypes::DataPadding) info += "\n" + itemSubtypeToUString(Types::Region, regions[i].type) - + usprintf(" region offset: 0x%X", regions[i].offset + localOffset); + + usprintf(" region offset: %Xh", regions[i].offset + localOffset); } // Region access settings if (descriptorVersion == 1) { const FLASH_DESCRIPTOR_MASTER_SECTION* masterSection = (const FLASH_DESCRIPTOR_MASTER_SECTION*)calculateAddress8((UINT8*)descriptor, descriptorMap->MasterBase); info += UString("\nRegion access settings:"); - info += usprintf("\nBIOS: 0x%02X 0x%02X" - "\nME: 0x%02X 0x%02X" - "\nGbE: 0x%02X 0x%02X", + info += usprintf("\nBIOS: %02Xh %02Xh ME: %02Xh %02Xh\nGbE: %02Xh %02Xh", masterSection->BiosRead, masterSection->BiosWrite, masterSection->MeRead, @@ -541,10 +539,10 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l else if (descriptorVersion == 2) { const FLASH_DESCRIPTOR_MASTER_SECTION_V2* masterSection = (const FLASH_DESCRIPTOR_MASTER_SECTION_V2*)calculateAddress8((UINT8*)descriptor, descriptorMap->MasterBase); info += UString("\nRegion access settings:"); - info += usprintf("\nBIOS: 0x%03X 0x%03X" - "\nME: 0x%03X 0x%03X" - "\nGbE: 0x%03X 0x%03X" - "\nEC: 0x%03X 0x%03X", + info += usprintf("\nBIOS: %03Xh %03Xh" + "\nME: %03Xh %03Xh" + "\nGbE: %03Xh %03Xh" + "\nEC: %03Xh %03Xh", masterSection->BiosRead, masterSection->BiosWrite, masterSection->MeRead, @@ -646,7 +644,7 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item @@ -678,7 +676,7 @@ USTATUS FfsParser::parseGbeRegion(const UByteArray & gbe, const UINT32 localOffs UString name("GbE region"); const GBE_MAC_ADDRESS* mac = (const GBE_MAC_ADDRESS*)gbe.constData(); const GBE_VERSION* version = (const GBE_VERSION*)(gbe.constData() + GBE_VERSION_OFFSET); - UString info = usprintf("Full size: 0x%X (%u)\nMAC: %02X:%02X:%02X:%02X:%02X:%02X\nVersion: %u.%u", + UString info = usprintf("Full size: %Xh (%u)\nMAC: %02X:%02X:%02X:%02X:%02X:%02X\nVersion: %u.%u", (UINT32)gbe.size(), (UINT32)gbe.size(), mac->vendor[0], mac->vendor[1], mac->vendor[2], mac->device[0], mac->device[1], mac->device[2], @@ -699,7 +697,7 @@ USTATUS FfsParser::parseMeRegion(const UByteArray & me, const UINT32 localOffset // Get info UString name("ME region"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)me.size(), (UINT32)me.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)me.size(), (UINT32)me.size()); // Parse region bool versionFound = true; @@ -770,7 +768,7 @@ USTATUS FfsParser::parsePdrRegion(const UByteArray & pdr, const UINT32 localOffs // Get info UString name("PDR region"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)pdr.size(), (UINT32)pdr.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)pdr.size(), (UINT32)pdr.size()); // Check for empty region bool emptyRegion = false; @@ -806,7 +804,7 @@ USTATUS FfsParser::parseDevExp1Region(const UByteArray & devExp1, const UINT32 l // Get info UString name("DevExp1 region"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)devExp1.size(), (UINT32)devExp1.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)devExp1.size(), (UINT32)devExp1.size()); // Check for empty region bool emptyRegion = false; @@ -838,7 +836,7 @@ USTATUS FfsParser::parseGenericRegion(const UINT8 subtype, const UByteArray & re // Get info UString name = itemSubtypeToUString(Types::Region, subtype) + UString(" region"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)region.size(), (UINT32)region.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)region.size(), (UINT32)region.size()); // Check for empty region bool emptyRegion = false; @@ -867,7 +865,7 @@ USTATUS FfsParser::parseBiosRegion(const UByteArray & bios, const UINT32 localOf // Get info UString name("BIOS region"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)bios.size(), (UINT32)bios.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)bios.size(), (UINT32)bios.size()); // Add tree item index = model->addItem(localOffset, Types::Region, Subtypes::BiosRegion, name, UString(), info, UByteArray(), bios, UByteArray(), Fixed, parent); @@ -921,7 +919,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info UByteArray padding = data.left(prevItemOffset); name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item model->addItem(headerSize, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -942,7 +940,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item model->addItem(headerSize + paddingOffset, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -955,7 +953,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item UModelIndex paddingIndex = model->addItem(headerSize + itemOffset, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -977,7 +975,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) } else { // Show messages if (itemSize != itemAltSize) - msg(usprintf("%s: volume size stored in header 0x%X differs from calculated using block map 0x%X", __FUNCTION__, itemSize, itemAltSize), volumeIndex); + msg(usprintf("%s: volume size stored in header %Xh differs from calculated using block map %Xh", __FUNCTION__, itemSize, itemAltSize), volumeIndex); } } else if (itemType == Types::Microcode) { @@ -993,7 +991,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info name = UString("BPDT region"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)bpdtStore.size(), (UINT32)bpdtStore.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)bpdtStore.size(), (UINT32)bpdtStore.size()); // Add tree item UModelIndex bpdtIndex = model->addItem(headerSize + itemOffset, Types::BpdtStore, 0, name, UString(), info, UByteArray(), bpdtStore, UByteArray(), Fixed, index); @@ -1019,7 +1017,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Add info UString name = UString("Insyde H2O FlashDeviceMap"); - UString info = usprintf("Signature: HFDM\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nEntry size: 0x%X (%u)\nEntry format: 0x%02X\nRevision: 0x%02X\nExtension count: %u\nFlash descriptor base address: 0x%08X\nChecksum: 0x%02X", + UString info = usprintf("Signature: HFDM\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nEntry size: %Xh (%u)\nEntry format: %02Xh\nRevision: %02Xh\nExtension count: %u\nFlash descriptor base address: %08Xh\nChecksum: %02Xh", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -1040,13 +1038,13 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) info += UString(", valid"); } else { - info += usprintf(", invalid, should be 0x%02X", calculated); + info += usprintf(", invalid, should be %02Xh", calculated); } } // Add board IDs if (!parsed._is_null_board_ids()) { - info += usprintf("\nRegion index: 0x%X\nBoardId Count: %u", + info += usprintf("\nRegion index: %Xh\nBoardId Count: %u", parsed.board_ids()->region_index(), parsed.board_ids()->num_board_ids()); UINT32 i = 0; @@ -1075,7 +1073,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) for (UINT8 i = 0; i < 16; i++) { info += usprintf("%02X", *(const UINT8*)(entry->region_id().c_str() + i)); } - info += usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nRegion address: 0x%08X\nRegion size: 0x%08X\nAttributes: 0x%08X", + info += usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nRegion address: %08Xh\nRegion size: %08Xh\nAttributes: %08Xh", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -1085,7 +1083,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) if ((entry->attributes() & INSYDE_FLASH_DEVICE_MAP_ENTRY_ATTRIBUTE_MODIFIABLE) == 0) { if (!protectedRangeFound) { - securityInfo += usprintf("Insyde Flash Device Map found at base 0x%08X\nProtected ranges:\n", model->base(headerIndex)); + securityInfo += usprintf("Insyde Flash Device Map found at base %08Xh\nProtected ranges:\n", model->base(headerIndex)); protectedRangeFound = true; } @@ -1100,7 +1098,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) range.Hash = body; protectedRanges.push_back(range); - securityInfo += usprintf("Address: 0x%08X Size: 0x%X\nHash: ", range.Offset, range.Size) + UString(body.toHex().constData()) + "\n"; + securityInfo += usprintf("Address: %08Xh Size: %Xh\nHash: ", range.Offset, range.Size) + UString(body.toHex().constData()) + "\n"; } // Add tree item @@ -1119,7 +1117,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item model->addItem(headerSize + itemOffset, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -1140,7 +1138,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Add info UString name = UString("Dell DVAR Store"); - UString info = usprintf("Signature: DVAR\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nFlags: 0x%02X", + UString info = usprintf("Signature: DVAR\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nFlags: %02Xh", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -1158,7 +1156,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) if (entryOffset < storeSize) { UByteArray freeSpace = dvar.mid(entryOffset, storeSize - entryOffset); // Add info - info = usprintf("Full size: 0x%X (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); // Check that remaining unparsed bytes are actually empty if (freeSpace.count(emptyByte) == freeSpace.size()) { // Free space @@ -1233,7 +1231,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) name = usprintf("%X:%X", entry->namespace_id(), nameId); text = guidToUString(guid); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nState: 0x%02X\nFlags: 0x%02X\nType: 0x%02X\nNamespaceId: 0x%X\nNameId: 0x%X\n", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nState: %02Xh\nFlags: %02Xh\nType: %02Xh\nNamespaceId: %Xh\nNameId: %Xh\n", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -1269,7 +1267,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) body = dvar.mid(entryOffset + headerSize, bodySize); name = usprintf("%X:%X", entry->namespace_id(), nameId); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nState: 0x%02X\nFlags: 0x%02X\nType: 0x%02X\nNamespaceId: 0x%X\nNameId: 0x%X\n", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nState: %02Xh\nFlags: %02Xh\nType: %02Xh\nNamespaceId: %Xh\nNameId: %Xh\n", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -1302,7 +1300,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item model->addItem(headerSize + itemOffset, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -1330,7 +1328,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index) // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item model->addItem(headerSize + itemOffset, Types::Padding, getPaddingType(padding), name, UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -1378,7 +1376,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc // Check that there is space for the volume header if ((UINT32)volume.size() < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) { - msg(usprintf("%s: input volume size 0x%X (%u) is smaller than volume header size 40h (64)", __FUNCTION__, (UINT32)volume.size(), (UINT32)volume.size())); + msg(usprintf("%s: input volume size %Xh (%u) is smaller than volume header size 40h (64)", __FUNCTION__, (UINT32)volume.size(), (UINT32)volume.size())); return U_INVALID_VOLUME; } @@ -1492,7 +1490,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc bool msgInvalidChecksum = false; if (volumeHeader->HeaderLength < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) { - msg(usprintf("%s: input volume header length 0x%04X (%hu) is smaller than volume header size", __FUNCTION__, volumeHeader->HeaderLength, volumeHeader->HeaderLength)); + msg(usprintf("%s: input volume header length %04Xh (%hu) is smaller than volume header size", __FUNCTION__, volumeHeader->HeaderLength, volumeHeader->HeaderLength)); return U_INVALID_VOLUME; } UByteArray tempHeader((const char*)volumeHeader, volumeHeader->HeaderLength); @@ -1515,7 +1513,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc volumeHeader->ZeroVector[8], volumeHeader->ZeroVector[9], volumeHeader->ZeroVector[10], volumeHeader->ZeroVector[11], volumeHeader->ZeroVector[12], volumeHeader->ZeroVector[13], volumeHeader->ZeroVector[14], volumeHeader->ZeroVector[15]) + guidToUString(volumeHeader->FileSystemGuid, false) \ - + usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nRevision: %u\nAttributes: 0x%08X\nErase polarity: %u\nChecksum: 0x%04X", + + usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nRevision: %u\nAttributes: %08Xh\nErase polarity: %u\nChecksum: %04Xh", volumeSize, volumeSize, headerSize, headerSize, volumeSize - headerSize, volumeSize - headerSize, @@ -1523,7 +1521,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc volumeHeader->Attributes, (emptyByte ? 1 : 0), volumeHeader->Checksum) + - (msgInvalidChecksum ? usprintf(", invalid, should be 0x%04X", calculated) : UString(", valid")); + (msgInvalidChecksum ? usprintf(", invalid, should be %04Xh", calculated) : UString(", valid")); // Block size and blocks number const EFI_FV_BLOCK_MAP_ENTRY* entry = (const EFI_FV_BLOCK_MAP_ENTRY*)(volume.constData() + sizeof(EFI_FIRMWARE_VOLUME_HEADER)); @@ -1560,7 +1558,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc return U_INVALID_VOLUME; } const EFI_FIRMWARE_VOLUME_EXT_HEADER* extendedHeader = (const EFI_FIRMWARE_VOLUME_EXT_HEADER*)(volume.constData() + volumeHeader->ExtHeaderOffset); - info += usprintf("\nExtended header size: 0x%X (%u)\nVolume GUID: ", + info += usprintf("\nExtended header size: %Xh (%u)\nVolume GUID: ", extendedHeader->ExtHeaderSize, extendedHeader->ExtHeaderSize) + guidToUString(extendedHeader->FvName, false); name = guidToUString(extendedHeader->FvName); // Replace FFS GUID with volume GUID } @@ -1858,7 +1856,7 @@ USTATUS FfsParser::parseVolumeNonUefiData(const UByteArray & data, const UINT32 return U_INVALID_PARAMETER; // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)data.size(), (UINT32)data.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)data.size(), (UINT32)data.size()); // Add padding tree item UModelIndex paddingIndex = model->addItem(localOffset, Types::Padding, Subtypes::DataPadding, UString("Non-UEFI data"), UString(), info, UByteArray(), data, UByteArray(), Fixed, index); @@ -1959,7 +1957,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index) UByteArray free = freeSpace.left(i); // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)free.size(), (UINT32)free.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)free.size(), (UINT32)free.size()); // Add free space item model->addItem(volumeHeaderSize + fileOffset, Types::FreeSpace, 0, UString("Volume free space"), UString(), info, UByteArray(), free, UByteArray(), Movable, index); @@ -1970,7 +1968,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index) } else { // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); // Add free space item model->addItem(volumeHeaderSize + fileOffset, Types::FreeSpace, 0, UString("Volume free space"), UString(), info, UByteArray(), freeSpace, UByteArray(), Movable, index); @@ -2211,7 +2209,7 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf } info = UString("File GUID: ") + guidToUString(fileHeader->Name, false) + - usprintf("\nType: 0x%02X\nAttributes: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nTail size: 0x%X (%u)\nState: 0x%02X", + usprintf("\nType: %02Xh\nAttributes: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nTail size: %Xh (%u)\nState: %02Xh", fileHeader->Type, fileHeader->Attributes, (UINT32)(header.size() + body.size() + tail.size()), (UINT32)(header.size() + body.size() + tail.size()), @@ -2219,8 +2217,8 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf (UINT32)body.size(), (UINT32)body.size(), (UINT32)tail.size(), (UINT32)tail.size(), fileHeader->State) + - usprintf("\nHeader checksum: 0x%02X", fileHeader->IntegrityCheck.Checksum.Header) + (msgInvalidHeaderChecksum ? usprintf(", invalid, should be 0x%02X", calculatedHeader) : UString(", valid")) + - usprintf("\nData checksum: 0x%02X", fileHeader->IntegrityCheck.Checksum.File) + (msgInvalidDataChecksum ? usprintf(", invalid, should be 0x%02X", calculatedData) : UString(", valid")); + usprintf("\nHeader checksum: %02Xh", fileHeader->IntegrityCheck.Checksum.Header) + (msgInvalidHeaderChecksum ? usprintf(", invalid, should be %02Xh", calculatedHeader) : UString(", valid")) + + usprintf("\nData checksum: %02Xh", fileHeader->IntegrityCheck.Checksum.File) + (msgInvalidDataChecksum ? usprintf(", invalid, should be %02Xh", calculatedData) : UString(", valid")); UString text; bool isVtf = false; @@ -2267,15 +2265,15 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf if (msgUnalignedFile) msg(usprintf("%s: unaligned file", __FUNCTION__), index); if (msgFileAlignmentIsGreaterThanVolumeAlignment) - msg(usprintf("%s: file alignment 0x%X is greater than parent volume alignment 0x%X", __FUNCTION__, alignment, volumeAlignment), index); + msg(usprintf("%s: file alignment %Xh is greater than parent volume alignment %Xh", __FUNCTION__, alignment, volumeAlignment), index); if (msgInvalidHeaderChecksum) - msg(usprintf("%s: invalid header checksum 0x%02X, should be 0x%02X", __FUNCTION__, fileHeader->IntegrityCheck.Checksum.Header, calculatedHeader), index); + msg(usprintf("%s: invalid header checksum %02Xh, should be %02Xh", __FUNCTION__, fileHeader->IntegrityCheck.Checksum.Header, calculatedHeader), index); if (msgInvalidDataChecksum) - msg(usprintf("%s: invalid data checksum 0x%02X, should be 0x%02X", __FUNCTION__, fileHeader->IntegrityCheck.Checksum.File, calculatedData), index); + msg(usprintf("%s: invalid data checksum %02Xh, should be %02Xh", __FUNCTION__, fileHeader->IntegrityCheck.Checksum.File, calculatedData), index); if (msgInvalidTailValue) - msg(usprintf("%s: invalid tail value 0x%04X", __FUNCTION__, *(const UINT16*)tail.constData()), index); + msg(usprintf("%s: invalid tail value %04Xh", __FUNCTION__, *(const UINT16*)tail.constData()), index); if (msgUnknownType) - msg(usprintf("%s: unknown file type 0x%02X", __FUNCTION__, fileHeader->Type), index); + msg(usprintf("%s: unknown file type %02Xh", __FUNCTION__, fileHeader->Type), index); return U_SUCCESS; } @@ -2413,7 +2411,7 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index) UByteArray free = body.left(nonEmptyByteOffset); // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)free.size(), (UINT32)free.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)free.size(), (UINT32)free.size()); // Add tree item model->addItem(headerSize, Types::FreeSpace, 0, UString("Free space"), UString(), info, UByteArray(), free, UByteArray(), Movable, index); @@ -2429,7 +2427,7 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index) // https://github.com/tianocore/edk2/blob/stable/202011/BaseTools/Source/C/GenFv/GenFvInternalLib.c#L106 if (padding.left(RECOVERY_STARTUP_AP_DATA_X86_SIZE) == RECOVERY_STARTUP_AP_DATA_X86_128K) { // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item (void)model->addItem(headerSize + nonEmptyByteOffset, Types::StartupApDataEntry, Subtypes::x86128kStartupApDataEntry, UString("Startup AP data"), UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -2442,7 +2440,7 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index) } else { // Not a data array // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item UModelIndex dataIndex = model->addItem(headerSize + nonEmptyByteOffset, Types::Padding, Subtypes::DataPadding, UString("Non-UEFI data"), UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -2496,7 +2494,7 @@ USTATUS FfsParser::parseSections(const UByteArray & sections, const UModelIndex UByteArray padding = sections.mid(sectionOffset); // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item UModelIndex dataIndex = model->addItem(headerSize + sectionOffset, Types::Padding, Subtypes::DataPadding, UString("Non-UEFI data"), UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); @@ -2599,7 +2597,7 @@ USTATUS FfsParser::parseSectionHeader(const UByteArray & section, const UINT32 l // Unknown default: USTATUS result = parseCommonSectionHeader(section, localOffset, parent, index, insertIntoTree); - msg(usprintf("%s: section with unknown type 0x%02X", __FUNCTION__, sectionHeader->Type), index); + msg(usprintf("%s: section with unknown type %02Xh", __FUNCTION__, sectionHeader->Type), index); return result; } } @@ -2637,7 +2635,7 @@ USTATUS FfsParser::parseCommonSectionHeader(const UByteArray & section, const UI // Get info UString name = sectionTypeToUString(type) + UString(" section"); - UString info = usprintf("Type: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)", + UString info = usprintf("Type: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)", type, (UINT32)section.size(), (UINT32)section.size(), headerSize, headerSize, @@ -2698,7 +2696,7 @@ USTATUS FfsParser::parseCompressedSectionHeader(const UByteArray & section, cons // Get info UString name = sectionTypeToUString(sectionHeader->Type) + UString(" section"); - UString info = usprintf("Type: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nCompression type: 0x%02X\nDecompressed size: 0x%X (%u)", + UString info = usprintf("Type: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nCompression type: %02Xh\nDecompressed size: %Xh (%u)", sectionHeader->Type, (UINT32)section.size(), (UINT32)section.size(), headerSize, headerSize, @@ -2788,10 +2786,10 @@ USTATUS FfsParser::parseGuidedSectionHeader(const UByteArray & section, const UI // Calculate CRC32 of section data UINT32 calculated = (UINT32)crc32(0, (const UINT8*)section.constData() + dataOffset, (uInt)(section.size() - dataOffset)); if (crc == calculated) { - additionalInfo += usprintf("\nChecksum: 0x%08X, valid", crc); + additionalInfo += usprintf("\nChecksum: %08Xh, valid", crc); } else { - additionalInfo += usprintf("\nChecksum: 0x%08X, invalid, should be 0x%08X", crc, calculated); + additionalInfo += usprintf("\nChecksum: %08Xh, invalid, should be %08Xh", crc, calculated); msgInvalidCrc = true; } // No need to change dataOffset here @@ -2876,7 +2874,7 @@ USTATUS FfsParser::parseGuidedSectionHeader(const UByteArray & section, const UI } } else { - additionalInfo += usprintf("\nCertificate type: unknown (0x%04X)", certType); + additionalInfo += usprintf("\nCertificate type: unknown (%04Xh)", certType); msgUnknownCertType = true; } msgSignedSectionFound = true; @@ -2892,7 +2890,7 @@ USTATUS FfsParser::parseGuidedSectionHeader(const UByteArray & section, const UI // Get info UString name = guidToUString(guid); UString info = UString("Section GUID: ") + guidToUString(guid, false) + - usprintf("\nType: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nAttributes: 0x%04X", + usprintf("\nType: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nAttributes: %04Xh", sectionHeader->Type, (UINT32)section.size(), (UINT32)section.size(), (UINT32)header.size(), (UINT32)header.size(), @@ -2981,7 +2979,7 @@ USTATUS FfsParser::parseFreeformGuidedSectionHeader(const UByteArray & section, // Get info UString name = sectionTypeToUString(type) + (" section"); - UString info = usprintf("Type: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nSubtype GUID: ", + UString info = usprintf("Type: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nSubtype GUID: ", type, (UINT32)section.size(), (UINT32)section.size(), (UINT32)header.size(), (UINT32)header.size(), @@ -3048,7 +3046,7 @@ USTATUS FfsParser::parseVersionSectionHeader(const UByteArray & section, const U // Get info UString name = sectionTypeToUString(type) + (" section"); - UString info = usprintf("Type: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nBuild number: %u", + UString info = usprintf("Type: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nBuild number: %u", type, (UINT32)section.size(), (UINT32)section.size(), (UINT32)header.size(), (UINT32)header.size(), @@ -3107,7 +3105,7 @@ USTATUS FfsParser::parsePostcodeSectionHeader(const UByteArray & section, const // Get info UString name = sectionTypeToUString(type) + (" section"); - UString info = usprintf("Type: 0x%02X\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nPostcode: 0x%X", + UString info = usprintf("Type: %02Xh\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nPostcode: %Xh", type, (UINT32)section.size(), (UINT32)section.size(), (UINT32)header.size(), (UINT32)header.size(), @@ -3188,12 +3186,12 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index) // Check reported uncompressed size if (uncompressedSize != (UINT32)decompressed.size()) { - msg(usprintf("%s: decompressed size stored in header 0x%X (%u) differs from actual 0x%X (%u)", + msg(usprintf("%s: decompressed size stored in header %Xh (%u) differs from actual %Xh (%u)", __FUNCTION__, uncompressedSize, uncompressedSize, (UINT32)decompressed.size(), (UINT32)decompressed.size()), index); - model->addInfo(index, usprintf("\nActual decompressed size: 0x%X (%u)", (UINT32)decompressed.size(), (UINT32)decompressed.size())); + model->addInfo(index, usprintf("\nActual decompressed size: %Xh (%u)", (UINT32)decompressed.size(), (UINT32)decompressed.size())); } // Check for undecided compression algorithm, this is a special case @@ -3215,7 +3213,7 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index) // Add info model->addInfo(index, UString("\nCompression algorithm: ") + compressionTypeToUString(algorithm)); if (algorithm == COMPRESSION_ALGORITHM_LZMA || algorithm == COMPRESSION_ALGORITHM_LZMA_INTEL_LEGACY) { - model->addInfo(index, usprintf("\nLZMA dictionary size: 0x%X", dictionarySize)); + model->addInfo(index, usprintf("\nLZMA dictionary size: %Xh", dictionarySize)); } // Set compression data @@ -3284,7 +3282,7 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index) } info += UString("\nCompression algorithm: ") + compressionTypeToUString(algorithm); - info += usprintf("\nDecompressed size: 0x%X (%u)", (UINT32)processed.size(), (UINT32)processed.size()); + info += usprintf("\nDecompressed size: %Xh (%u)", (UINT32)processed.size(), (UINT32)processed.size()); } // LZMA compressed section else if (baGuid == EFI_GUIDED_SECTION_LZMA @@ -3298,8 +3296,8 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index) if (algorithm == COMPRESSION_ALGORITHM_LZMA) { info += UString("\nCompression algorithm: LZMA"); - info += usprintf("\nDecompressed size: 0x%X (%u)", (UINT32)processed.size(), (UINT32)processed.size()); - info += usprintf("\nLZMA dictionary size: 0x%X", dictionarySize); + info += usprintf("\nDecompressed size: %Xh (%u)", (UINT32)processed.size(), (UINT32)processed.size()); + info += usprintf("\nLZMA dictionary size: %Xh", dictionarySize); } else { info += UString("\nCompression algorithm: unknown"); @@ -3316,8 +3314,8 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index) if (algorithm == COMPRESSION_ALGORITHM_LZMAF86) { info += UString("\nCompression algorithm: LZMAF86"); - info += usprintf("\nDecompressed size: 0x%X (%u)", (UINT32)processed.size(), (UINT32)processed.size()); - info += usprintf("\nLZMA dictionary size: 0x%X", dictionarySize); + info += usprintf("\nDecompressed size: %Xh (%u)", (UINT32)processed.size(), (UINT32)processed.size()); + info += usprintf("\nLZMA dictionary size: %Xh", dictionarySize); } else { info += UString("\nCompression algorithm: unknown"); @@ -3334,7 +3332,7 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index) algorithm = COMPRESSION_ALGORITHM_GZIP; info += UString("\nCompression algorithm: GZip"); - info += usprintf("\nDecompressed size: 0x%X (%u)", (UINT32)processed.size(), (UINT32)processed.size()); + info += usprintf("\nDecompressed size: %Xh (%u)", (UINT32)processed.size(), (UINT32)processed.size()); } // Zlib compressed section else if (baGuid == EFI_GUIDED_SECTION_ZLIB_AMD) { @@ -3346,7 +3344,7 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index) algorithm = COMPRESSION_ALGORITHM_ZLIB; info += UString("\nCompression algorithm: Zlib"); - info += usprintf("\nDecompressed size: 0x%X (%u)", (UINT32)processed.size(), (UINT32)processed.size()); + info += usprintf("\nDecompressed size: %Xh (%u)", (UINT32)processed.size(), (UINT32)processed.size()); } // Add info @@ -3497,7 +3495,7 @@ USTATUS FfsParser::parseDepexSectionBody(const UModelIndex & index) } break; default: - msg(usprintf("%s: unknown opcode 0x%02X", __FUNCTION__, *current), index); + msg(usprintf("%s: unknown opcode %02Xh", __FUNCTION__, *current), index); // No further parsing required return U_SUCCESS; } @@ -3609,7 +3607,7 @@ USTATUS FfsParser::parsePeImageSectionBody(const UModelIndex & index) UString info; const EFI_IMAGE_DOS_HEADER* dosHeader = (const EFI_IMAGE_DOS_HEADER*)body.constData(); if (dosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) { - info += usprintf("\nDOS signature: 0x%04X, invalid", dosHeader->e_magic); + info += usprintf("\nDOS signature: %04Xh, invalid", dosHeader->e_magic); msg(usprintf("%s: PE32 image with invalid DOS signature", __FUNCTION__), index); model->addInfo(index, info); return U_SUCCESS; @@ -3624,7 +3622,7 @@ USTATUS FfsParser::parsePeImageSectionBody(const UModelIndex & index) } if (peHeader->Signature != EFI_IMAGE_PE_SIGNATURE) { - info += usprintf("\nPE signature: 0x%08X, invalid", peHeader->Signature); + info += usprintf("\nPE signature: %08Xh, invalid", peHeader->Signature); msg(usprintf("%s: PE32 image with invalid PE signature", __FUNCTION__), index); model->addInfo(index, info); return U_SUCCESS; @@ -3638,11 +3636,11 @@ USTATUS FfsParser::parsePeImageSectionBody(const UModelIndex & index) return U_SUCCESS; } - info += usprintf("\nDOS signature: 0x%04X\nPE signature: 0x%08X", + info += usprintf("\nDOS signature: %04Xh\nPE signature: %08Xh", dosHeader->e_magic, peHeader->Signature) + UString("\nMachine type: ") + machineTypeToUString(imageFileHeader->Machine) + - usprintf("\nNumber of sections: %u\nCharacteristics: 0x%04X", + usprintf("\nNumber of sections: %u\nCharacteristics: %04Xh", imageFileHeader->NumberOfSections, imageFileHeader->Characteristics); @@ -3656,7 +3654,7 @@ USTATUS FfsParser::parsePeImageSectionBody(const UModelIndex & index) } if (optionalHeader.H32->Magic == EFI_IMAGE_PE_OPTIONAL_HDR32_MAGIC) { - info += usprintf("\nOptional header signature: 0x%04X\nSubsystem: 0x%04X\nAddress of entry point: 0x%X\nBase of code: 0x%X\nImage base: 0x%X", + info += usprintf("\nOptional header signature: %04Xh\nSubsystem: %04Xh\nAddress of entry point: %Xh\nBase of code: %Xh\nImage base: %Xh", optionalHeader.H32->Magic, optionalHeader.H32->Subsystem, optionalHeader.H32->AddressOfEntryPoint, @@ -3664,7 +3662,7 @@ USTATUS FfsParser::parsePeImageSectionBody(const UModelIndex & index) optionalHeader.H32->ImageBase); } else if (optionalHeader.H32->Magic == EFI_IMAGE_PE_OPTIONAL_HDR64_MAGIC) { - info += usprintf("\nOptional header signature: 0x%04X\nSubsystem: 0x%04X\nAddress of entry point: 0x%X\nBase of code: 0x%X\nImage base: 0x%" PRIX64, + info += usprintf("\nOptional header signature: %04Xh\nSubsystem: %04Xh\nAddress of entry point: %Xh\nBase of code: %Xh\nImage base: %" PRIX64 "h", optionalHeader.H64->Magic, optionalHeader.H64->Subsystem, optionalHeader.H64->AddressOfEntryPoint, @@ -3672,7 +3670,7 @@ USTATUS FfsParser::parsePeImageSectionBody(const UModelIndex & index) optionalHeader.H64->ImageBase); } else { - info += usprintf("\nOptional header signature: 0x%04X, unknown", optionalHeader.H32->Magic); + info += usprintf("\nOptional header signature: %04Xh, unknown", optionalHeader.H32->Magic); msg(usprintf("%s: PE32 image with invalid optional PE header signature", __FUNCTION__), index); } @@ -3697,14 +3695,14 @@ USTATUS FfsParser::parseTeImageSectionBody(const UModelIndex & index) UString info; const EFI_IMAGE_TE_HEADER* teHeader = (const EFI_IMAGE_TE_HEADER*)body.constData(); if (teHeader->Signature != EFI_IMAGE_TE_SIGNATURE) { - info += usprintf("\nSignature: 0x%04X, invalid", teHeader->Signature); + info += usprintf("\nSignature: %04Xh, invalid", teHeader->Signature); msg(usprintf("%s: TE image with invalid TE signature", __FUNCTION__), index); } else { - info += usprintf("\nSignature: 0x%04X", teHeader->Signature) + + info += usprintf("\nSignature: %04Xh", teHeader->Signature) + UString("\nMachine type: ") + machineTypeToUString(teHeader->Machine) + - usprintf("\nNumber of sections: %u\nSubsystem: 0x%02X\nStripped size: 0x%X (%u)\n" - "Base of code: 0x%X\nAddress of entry point: 0x%X\nImage base: 0x%" PRIX64 "\nAdjusted image base: 0x%" PRIX64, + usprintf("\nNumber of sections: %u\nSubsystem: %02Xh\nStripped size: %Xh (%u)\n" + "Base of code: %Xh\nAddress of entry point: %Xh\nImage base: %" PRIX64 "h\nAdjusted image base: %" PRIX64 "h", teHeader->NumberOfSections, teHeader->Subsystem, teHeader->StrippedSize, teHeader->StrippedSize, @@ -3775,9 +3773,9 @@ USTATUS FfsParser::parseResetVectorData() // Add info UString info = usprintf("\nAP entry vector: %02X %02X %02X %02X %02X %02X %02X %02X\n" "Reset vector: %02X %02X %02X %02X %02X %02X %02X %02X\n" - "PEI core entry point: 0x%08X\n" - "AP startup segment: 0x%08X\n" - "BootFV base address: 0x%08X\n", + "PEI core entry point: %08Xh\n" + "AP startup segment: %08Xh\n" + "BootFV base address: %08Xh\n", resetVectorData->ApEntryVector[0], resetVectorData->ApEntryVector[1], resetVectorData->ApEntryVector[2], resetVectorData->ApEntryVector[3], resetVectorData->ApEntryVector[4], resetVectorData->ApEntryVector[5], resetVectorData->ApEntryVector[6], resetVectorData->ApEntryVector[7], resetVectorData->ResetVector[0], resetVectorData->ResetVector[1], resetVectorData->ResetVector[2], resetVectorData->ResetVector[3], @@ -3866,7 +3864,7 @@ USTATUS FfsParser::addInfoRecursive(const UModelIndex & index) return U_INVALID_PARAMETER; // Add offset - model->addInfo(index, usprintf("Offset: 0x%X\n", model->offset(index)), false); + model->addInfo(index, usprintf("Offset: %Xh\n", model->offset(index)), false); // Add current base if the element is not compressed // or it's compressed, but its parent isn't @@ -3876,15 +3874,15 @@ USTATUS FfsParser::addInfoRecursive(const UModelIndex & index) if (address <= 0xFFFFFFFFUL) { UINT32 headerSize = (UINT32)model->header(index).size(); if (headerSize) { - model->addInfo(index, usprintf("Data address: 0x%08X\n", (UINT32)address + headerSize),false); - model->addInfo(index, usprintf("Header address: 0x%08X\n", (UINT32)address), false); + model->addInfo(index, usprintf("Data address: %08Xh\n", (UINT32)address + headerSize),false); + model->addInfo(index, usprintf("Header address: %08Xh\n", (UINT32)address), false); } else { - model->addInfo(index, usprintf("Address: 0x%08X\n", (UINT32)address), false); + model->addInfo(index, usprintf("Address: %08Xh\n", (UINT32)address), false); } } // Add base - model->addInfo(index, usprintf("Base: 0x%X\n", model->base(index)), false); + model->addInfo(index, usprintf("Base: %Xh\n", model->base(index)), false); } model->addInfo(index, usprintf("Fixed: %s\n", model->fixed(index) ? "Yes" : "No"), false); @@ -4010,14 +4008,14 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index) digest = digest.left(SM3_HASH_SIZE); } else { - msg(usprintf("%s: post-IBB protected range [0x%X:0x%X] uses unknown hash algorithm 0x%04X", __FUNCTION__, + msg(usprintf("%s: post-IBB protected range [%Xh:%Xh] uses unknown hash algorithm %04Xh", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size, protectedRanges[i].AlgorithmId), model->findByBase(protectedRanges[i].Offset)); } // Check the hash if (digest != protectedRanges[i].Hash) { - msg(usprintf("%s: post-IBB protected range [0x%X:0x%X] hash mismatch, opened image may refuse to boot", __FUNCTION__, + msg(usprintf("%s: post-IBB protected range [%Xh:%Xh] hash mismatch, opened image may refuse to boot", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size), model->findByBase(protectedRanges[i].Offset)); } @@ -4049,7 +4047,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index) sha256(protectedParts.constData(), protectedParts.size(), digest.data()); if (digest != protectedRanges[i].Hash) { - msg(usprintf("%s: AMI v1 protected range [0x%X:0x%X] hash mismatch, opened image may refuse to boot", __FUNCTION__, + msg(usprintf("%s: AMI v1 protected range [%Xh:%Xh] hash mismatch, opened image may refuse to boot", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size), model->findByBase(protectedRanges[i].Offset)); } @@ -4071,7 +4069,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index) sha256(protectedParts.constData(), protectedParts.size(), digest.data()); if (digest != protectedRanges[i].Hash) { - msg(usprintf("%s: AMI v2 protected range [0x%X:0x%X] hash mismatch, opened image may refuse to boot", __FUNCTION__, + msg(usprintf("%s: AMI v2 protected range [%Xh:%Xh] hash mismatch, opened image may refuse to boot", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size), model->findByBase(protectedRanges[i].Offset)); } @@ -4135,7 +4133,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index) sha256(protectedParts.constData(), protectedParts.size(), digest.data()); if (digest != protectedRanges[i].Hash) { - msg(usprintf("%s: Phoenix protected range [0x%X:0x%X] hash mismatch, opened image may refuse to boot", __FUNCTION__, + msg(usprintf("%s: Phoenix protected range [%Xh:%Xh] hash mismatch, opened image may refuse to boot", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size), model->findByBase(protectedRanges[i].Offset)); } @@ -4174,14 +4172,14 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index) digest = digest.left(SM3_HASH_SIZE); } else { - msg(usprintf("%s: Microsoft PMDA protected range [0x%X:0x%X] uses unknown hash algorithm 0x%04X", __FUNCTION__, + msg(usprintf("%s: Microsoft PMDA protected range [%Xh:%Xh] uses unknown hash algorithm %04Xh", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size, protectedRanges[i].AlgorithmId), model->findByBase(protectedRanges[i].Offset)); } // Check the hash if (digest != protectedRanges[i].Hash) { - msg(usprintf("%s: Microsoft PMDA protected range [0x%X:0x%X] hash mismatch, opened image may refuse to boot", __FUNCTION__, + msg(usprintf("%s: Microsoft PMDA protected range [%Xh:%Xh] hash mismatch, opened image may refuse to boot", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size), model->findByBase(protectedRanges[i].Offset)); } @@ -4201,7 +4199,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index) sha256(protectedParts.constData(), protectedParts.size(), digest.data()); if (digest != protectedRanges[i].Hash) { - msg(usprintf("%s: Insyde protected range [0x%X:0x%X] hash mismatch, opened image may refuse to boot", __FUNCTION__, + msg(usprintf("%s: Insyde protected range [%Xh:%Xh] hash mismatch, opened image may refuse to boot", __FUNCTION__, protectedRanges[i].Offset, protectedRanges[i].Offset + protectedRanges[i].Size), model->findByBase(protectedRanges[i].Offset)); } @@ -4291,10 +4289,10 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel } if (protectedRangesFound) { - securityInfo += usprintf("Phoenix hash file found at base 0x%08X\nProtected ranges:\n", model->base(index)); + securityInfo += usprintf("Phoenix hash file found at base %08Xh\nProtected ranges:\n", model->base(index)); for (UINT32 i = 0; i < header->NumEntries; i++) { const PROTECTED_RANGE_VENDOR_HASH_FILE_ENTRY* entry = (const PROTECTED_RANGE_VENDOR_HASH_FILE_ENTRY*)(header + 1) + i; - securityInfo += usprintf("RelativeOffset: 0x%08X Size: 0x%X\nHash: ", entry->Base, entry->Size); + securityInfo += usprintf("RelativeOffset: %08Xh Size: %Xh\nHash: ", entry->Base, entry->Size); for (UINT8 j = 0; j < sizeof(entry->Hash); j++) { securityInfo += usprintf("%02X", entry->Hash[j]); } @@ -4311,9 +4309,9 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel else if (fileGuid == PROTECTED_RANGE_VENDOR_HASH_FILE_GUID_AMI) { UModelIndex fileIndex = model->parent(index); if (size == sizeof(PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V1)) { - securityInfo += usprintf("AMI protected ranges hash file v1 found at base 0x%08X\nProtected range:\n", model->base(fileIndex)); + securityInfo += usprintf("AMI protected ranges hash file v1 found at base %08Xh\nProtected range:\n", model->base(fileIndex)); const PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V1* entry = (const PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V1*)(body.constData()); - securityInfo += usprintf("Size: 0x%X\nHash (SHA256): ", entry->Size); + securityInfo += usprintf("Size: %Xh\nHash (SHA256): ", entry->Size); for (UINT8 i = 0; i < sizeof(entry->Hash); i++) { securityInfo += usprintf("%02X", entry->Hash[i]); } @@ -4334,12 +4332,12 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel else if (size == sizeof(PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V2)) { const PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V2* entry = (const PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V2*)(body.constData()); - securityInfo += usprintf("AMI v2 protected ranges hash file found at base 0x%08X\nProtected ranges:", model->base(fileIndex)); - securityInfo += usprintf("\nAddress: 0x%08X, Size: 0x%X\nHash (SHA256): ", entry->Hash0.Base, entry->Hash0.Size); + securityInfo += usprintf("AMI v2 protected ranges hash file found at base %08Xh\nProtected ranges:", model->base(fileIndex)); + securityInfo += usprintf("\nAddress: %08Xh, Size: %Xh\nHash (SHA256): ", entry->Hash0.Base, entry->Hash0.Size); for (UINT8 j = 0; j < sizeof(entry->Hash0.Hash); j++) { securityInfo += usprintf("%02X", entry->Hash0.Hash[j]); } - securityInfo += usprintf("\nAddress: 0x%08X, Size: 0x%X\nHash (SHA256): ", entry->Hash1.Base, entry->Hash1.Size); + securityInfo += usprintf("\nAddress: %08Xh, Size: %Xh\nHash (SHA256): ", entry->Hash1.Base, entry->Hash1.Size); for (UINT8 j = 0; j < sizeof(entry->Hash1.Hash); j++) { securityInfo += usprintf("%02X", entry->Hash1.Hash[j]); } @@ -4369,11 +4367,11 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel } else if (size == sizeof(PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V3)) { const PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V3* entry = (const PROTECTED_RANGE_VENDOR_HASH_FILE_HEADER_AMI_V3*)(body.constData()); - securityInfo += usprintf("AMI v3 protected ranges hash file found at base 0x%08X\nProtected ranges:", model->base(fileIndex)); - securityInfo += usprintf("\nFvBaseSegment 0 Address: 0x%08X, Size: 0x%X", entry->FvMainSegmentBase[0], entry->FvMainSegmentSize[0]); - securityInfo += usprintf("\nFvBaseSegment 1 Address: 0x%08X, Size: 0x%X", entry->FvMainSegmentBase[1], entry->FvMainSegmentSize[1]); - securityInfo += usprintf("\nFvBaseSegment 2 Address: 0x%08X, Size: 0x%X", entry->FvMainSegmentBase[2], entry->FvMainSegmentSize[2]); - securityInfo += usprintf("\nNestedFvBase Address: 0x%08X, Size: 0x%X", entry->NestedFvBase, entry->NestedFvSize); + securityInfo += usprintf("AMI v3 protected ranges hash file found at base %08Xh\nProtected ranges:", model->base(fileIndex)); + securityInfo += usprintf("\nFvBaseSegment 0 Address: %08Xh, Size: %Xh", entry->FvMainSegmentBase[0], entry->FvMainSegmentSize[0]); + securityInfo += usprintf("\nFvBaseSegment 1 Address: %08Xh, Size: %Xh", entry->FvMainSegmentBase[1], entry->FvMainSegmentSize[1]); + securityInfo += usprintf("\nFvBaseSegment 2 Address: %08Xh, Size: %Xh", entry->FvMainSegmentBase[2], entry->FvMainSegmentSize[2]); + securityInfo += usprintf("\nNestedFvBase Address: %08Xh, Size: %Xh", entry->NestedFvBase, entry->NestedFvSize); securityInfo += usprintf("\nHash (SHA256): "); for (UINT8 j = 0; j < sizeof(entry->Hash); j++) { securityInfo += usprintf("%02X", entry->Hash[j]); @@ -4455,7 +4453,7 @@ USTATUS FfsParser::parseMicrocodeVolumeBody(const UModelIndex & index) if (offset < bodySize) { // Get info UString name = UString("Padding"); - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)ucode.size(), (UINT32)ucode.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)ucode.size(), (UINT32)ucode.size()); // Add tree item model->addItem(headerSize + offset, Types::Padding, getPaddingType(ucode), name, UString(), info, UByteArray(), ucode, UByteArray(), Fixed, index); @@ -4541,10 +4539,10 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const tempExtendedHeader->Checksum = 0; UINT32 extendedCalculated = calculateChecksum32((const UINT32*)tempExtendedHeader, sizeof(INTEL_MICROCODE_EXTENDED_HEADER) + extendedHeader->EntryCount * sizeof(INTEL_MICROCODE_EXTENDED_HEADER_ENTRY)); - extendedHeaderInfo = usprintf("\nExtended header entries: %u\nExtended header checksum: 0x%08X, ", + extendedHeaderInfo = usprintf("\nExtended header entries: %u\nExtended header checksum: %08Xh, ", extendedHeader->EntryCount, extendedHeader->Checksum) - + (extendedHeader->Checksum == extendedCalculated ? UString("valid") : usprintf("invalid, should be 0x%08X", extendedCalculated)); + + (extendedHeader->Checksum == extendedCalculated ? UString("valid") : usprintf("invalid, should be %08Xh", extendedCalculated)); const INTEL_MICROCODE_EXTENDED_HEADER_ENTRY* firstEntry = (const INTEL_MICROCODE_EXTENDED_HEADER_ENTRY*)(extendedHeader + 1); for (UINT32 i = 0; i < extendedHeader->EntryCount; i++) { @@ -4556,11 +4554,11 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const tempUcodeHeader->ProcessorSignature = entry->ProcessorSignature; UINT32 entryCalculated = calculateChecksum32((const UINT32*)tempMicrocode.constData(), sizeof(INTEL_MICROCODE_HEADER) + dataSize); - extendedHeaderInfo += usprintf("\nCPU signature #%u: 0x%08X\nCPU platform Id #%u: 0x%08X\nChecksum #%u: 0x%08X, ", + extendedHeaderInfo += usprintf("\nCPU signature #%u: %08Xh\nCPU platform Id #%u: %08Xh\nChecksum #%u: %08Xh, ", i + 1, entry->ProcessorSignature, i + 1, entry->PlatformIds, i + 1, entry->Checksum) - + (entry->Checksum == entryCalculated ? UString("valid") : usprintf("invalid, should be 0x%08X", entryCalculated)); + + (entry->Checksum == entryCalculated ? UString("valid") : usprintf("invalid, should be %08Xh", entryCalculated)); } } else { @@ -4576,8 +4574,8 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const // Add info UString name("Intel microcode"); - UString info = usprintf("Full size: 0x%X (%u)\nHeader size: 0h (0u)\nBody size: 0x%X (%u)\nTail size: 0h (0u)\n" - "Date: %02X.%02X.%04x\nCPU signature: 0x%08X\nRevision: 0x%08X\nMinimal update revision: 0x%08X\nCPU platform Id: 0x%08X\nChecksum: 0x%08X, ", + UString info = usprintf("Full size: %Xh (%u)\nHeader size: 0h (0u)\nBody size: %Xh (%u)\nTail size: 0h (0u)\n" + "Date: %02X.%02X.%04x\nCPU signature: %08Xh\nRevision: %08Xh\nMinimal update revision: %08Xh\nCPU platform Id: %08Xh\nChecksum: %08Xh, ", (UINT32)microcodeBinary.size(), (UINT32)microcodeBinary.size(), (UINT32)microcodeBinary.size(), (UINT32)microcodeBinary.size(), ucodeHeader->DateDay, @@ -4588,15 +4586,15 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const ucodeHeader->UpdateRevisionMin, ucodeHeader->PlatformIds, ucodeHeader->Checksum) - + (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be 0x%08X", calculated)) + + (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be %08Xh", calculated)) + extendedHeaderInfo; // Add tree item index = model->addItem(localOffset, Types::Microcode, Subtypes::IntelMicrocode, name, UString(), info, UByteArray(), microcodeBinary, UByteArray(), Fixed, parent); if (msgInvalidChecksum) - msg(usprintf("%s: invalid microcode checksum 0x%08X, should be 0x%08X", __FUNCTION__, ucodeHeader->Checksum, calculated), index); + msg(usprintf("%s: invalid microcode checksum %08Xh, should be %08Xh", __FUNCTION__, ucodeHeader->Checksum, calculated), index); if (msgUnknownOrDamagedMicrocodeTail) - msg(usprintf("%s: extended header of size 0x%X (%u) found, but it's damaged or has unknown format", __FUNCTION__, (UINT32)tail.size(), (UINT32)tail.size()), index); + msg(usprintf("%s: extended header of size %Xh (%u) found, but it's damaged or has unknown format", __FUNCTION__, (UINT32)tail.size(), (UINT32)tail.size()), index); // No need to parse the body further for now return U_SUCCESS; @@ -4628,9 +4626,9 @@ USTATUS FfsParser::parseBpdtRegion(const UByteArray & region, const UINT32 local UByteArray body = region.mid(sizeof(BPDT_HEADER), ptBodySize); UString name = UString("BPDT partition table"); - UString info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\n" - "Number of entries: %u\nVersion: 0x%02X\nRedundancyFlag: 0x%X\n" - "IFWI version: 0x%X\nFITC version: %u.%u.%u.%u", + UString info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\n" + "Number of entries: %u\nVersion: %02Xh\nRedundancyFlag: %Xh\n" + "IFWI version: %Xh\nFITC version: %u.%u.%u.%u", ptSize, ptSize, (UINT32)header.size(), (UINT32)header.size(), ptBodySize, ptBodySize, @@ -4656,7 +4654,7 @@ USTATUS FfsParser::parseBpdtRegion(const UByteArray & region, const UINT32 local // Get info name = bpdtEntryTypeToUString(ptEntry->Type); - info = usprintf("Full size: 0x%X (%u)\nType: 0x%X\nPartition offset: 0x%X\nPartition length: 0x%X", + info = usprintf("Full size: %Xh (%u)\nType: %Xh\nPartition offset: %Xh\nPartition length: %Xh", (UINT32)sizeof(BPDT_ENTRY), (UINT32)sizeof(BPDT_ENTRY), ptEntry->Type, ptEntry->Offset, @@ -4770,7 +4768,7 @@ make_partition_table_consistent: UByteArray partition = region.mid(partitions[i].ptEntry.Offset, partitions[i].ptEntry.Size); UByteArray signature = partition.left(sizeof(UINT32)); - UString info = usprintf("Full size: 0x%X (%u)\nType: 0x%X", + UString info = usprintf("Full size: %Xh (%u)\nType: %Xh", (UINT32)partition.size(), (UINT32)partition.size(), partitions[i].ptEntry.Type) + UString("\nSplit sub-partition first part: ") + (partitions[i].ptEntry.SplitSubPartitionFirstPart ? "Yes" : "No") + @@ -4806,7 +4804,7 @@ make_partition_table_consistent: // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item @@ -4821,7 +4819,7 @@ make_partition_table_consistent: // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", + info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // Add tree item @@ -4868,7 +4866,7 @@ USTATUS FfsParser::parseCpdRegion(const UByteArray & region, const UINT32 localO UByteArray header = region.left(ptHeaderSize); UByteArray body = region.mid(ptHeaderSize, ptBodySize); UString name = usprintf("CPD partition table"); - UString info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nNumber of entries: %u\n" + UString info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nNumber of entries: %u\n" "Header version: %u\nEntry version: %u", ptSize, ptSize, (UINT32)header.size(), (UINT32)header.size(), @@ -4891,7 +4889,7 @@ USTATUS FfsParser::parseCpdRegion(const UByteArray & region, const UINT32 localO // Get info name = usprintf("%.12s", cpdEntry->EntryName); - info = usprintf("Full size: 0x%X (%u)\nEntry offset: 0x%X\nEntry length: 0x%X\nHuffman compressed: ", + info = usprintf("Full size: %Xh (%u)\nEntry offset: %Xh\nEntry length: %Xh\nHuffman compressed: ", (UINT32)entry.size(), (UINT32)entry.size(), cpdEntry->Offset.Offset, cpdEntry->Length) @@ -4920,7 +4918,7 @@ USTATUS FfsParser::parseCpdRegion(const UByteArray & region, const UINT32 localO // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", + info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item @@ -4978,7 +4976,7 @@ USTATUS FfsParser::parseCpdRegion(const UByteArray & region, const UINT32 localO partitions[j].ptEntry.Length = length; } else if (length != 0xFFFFFFFF && partitions[j].ptEntry.Length != length) { - msg(usprintf("%s: partition size mismatch between partition table (0x%X) and partition metadata (0x%X)", __FUNCTION__, + msg(usprintf("%s: partition size mismatch between partition table (%Xh) and partition metadata (%Xh)", __FUNCTION__, partitions[j].ptEntry.Length, length), partitions[j].index); partitions[j].ptEntry.Length = length; // Believe metadata } @@ -5103,9 +5101,9 @@ make_partition_table_consistent: UByteArray header = partition.left(manifestHeader->HeaderLength * sizeof(UINT32)); UByteArray body = partition.mid(manifestHeader->HeaderLength * sizeof(UINT32)); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)" - "\nHeader type: %u\nHeader length: 0x%X (%u)\nHeader version: 0x%X\nFlags: 0x%08X\nVendor: 0x%X\n" - "Date: 0x%X\nSize: 0x%X (%u)\nVersion: %u.%u.%u.%u\nSecurity version number: %u\nModulus size: 0x%X (%u)\nExponent size: 0x%X (%u)", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)" + "\nHeader type: %u\nHeader length: %Xh (%u)\nHeader version: %Xh\nFlags: %08Xh\nVendor: %Xh\n" + "Date: %Xh\nSize: %Xh (%u)\nVersion: %u.%u.%u.%u\nSecurity version number: %u\nModulus size: %Xh (%u)\nExponent size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size(), (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -5133,7 +5131,7 @@ make_partition_table_consistent: } // It's a metadata else if (name.endsWith(".met")) { - info = usprintf("Full size: 0x%X (%u)\nHuffman compressed: ", + info = usprintf("Full size: %Xh (%u)\nHuffman compressed: ", (UINT32)partition.size(), (UINT32)partition.size()) + (partitions[i].ptEntry.Offset.HuffmanCompressed ? "Yes" : "No"); @@ -5150,7 +5148,7 @@ make_partition_table_consistent: } // It's a code else { - info = usprintf("Full size: 0x%X (%u)\nHuffman compressed: ", + info = usprintf("Full size: %Xh (%u)\nHuffman compressed: ", (UINT32)partition.size(), (UINT32)partition.size()) + (partitions[i].ptEntry.Offset.HuffmanCompressed ? "Yes" : "No"); @@ -5168,7 +5166,7 @@ make_partition_table_consistent: // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)partition.size(), (UINT32)partition.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item model->addItem(localOffset + partitions[i].ptEntry.Offset.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent); @@ -5197,7 +5195,7 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index, const UINT3 UByteArray partition = body.mid(offset, extHeader->Length); UString name = cpdExtensionTypeToUstring(extHeader->Type); - UString info = usprintf("Full size: 0x%X (%u)\nType: 0x%X", (UINT32)partition.size(), (UINT32)partition.size(), extHeader->Type); + UString info = usprintf("Full size: %Xh (%u)\nType: %Xh", (UINT32)partition.size(), (UINT32)partition.size(), extHeader->Type); // Parse Signed Package Info a bit further UModelIndex extIndex; @@ -5207,8 +5205,8 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index, const UINT3 const CPD_EXT_SIGNED_PACKAGE_INFO* infoHeader = (const CPD_EXT_SIGNED_PACKAGE_INFO*)header.constData(); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nType: 0x%X\n" - "Package name: %.4s\nVersion control number: 0x%X\nSecurity version number: 0x%X\n" + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nType: %Xh\n" + "Package name: %.4s\nVersion control number: %Xh\nSecurity version number: %Xh\n" "Usage bitmap: %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", (UINT32)partition.size(), (UINT32)partition.size(), (UINT32)header.size(), (UINT32)header.size(), @@ -5243,9 +5241,9 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index, const UINT3 UByteArray hash((const char*)&attrHeader->CompletePartitionHash, hashSize); std::reverse(hash.begin(), hash.end()); - info = usprintf("Full size: 0x%X (%u)\nType: 0x%X\n" - "Partition name: %.4s\nPartition length: 0x%X\nPartition version major: 0x%X\nPartition version minor: 0x%X\n" - "Data format version: 0x%X\nInstance ID: 0x%X\nHash algorithm: 0x%X\nHash size: 0x%X\nAction on update: 0x%X", + info = usprintf("Full size: %Xh (%u)\nType: %Xh\n" + "Partition name: %.4s\nPartition length: %Xh\nPartition version major: %Xh\nPartition version minor: %Xh\n" + "Data format version: %Xh\nInstance ID: %Xh\nHash algorithm: %Xh\nHash size: %Xh\nAction on update: %Xh", (UINT32)partition.size(), (UINT32)partition.size(), attrHeader->ExtensionType, attrHeader->PartitionName, @@ -5281,8 +5279,8 @@ USTATUS FfsParser::parseCpdExtensionsArea(const UModelIndex & index, const UINT3 UByteArray hash((const char*)attrHeader + CpdExtModuleImageHashOffset, hashSize); std::reverse(hash.begin(), hash.end()); - info = usprintf("Full size: 0x%X (%u)\nType: 0x%X\n" - "Compression type: 0x%X\nUncompressed size: 0x%X (%u)\nCompressed size: 0x%X (%u)\nGlobal module ID: 0x%X\nImage hash: ", + info = usprintf("Full size: %Xh (%u)\nType: %Xh\n" + "Compression type: %Xh\nUncompressed size: %Xh (%u)\nCompressed size: %Xh (%u)\nGlobal module ID: %Xh\nImage hash: ", (UINT32)partition.size(), (UINT32)partition.size(), attrHeader->ExtensionType, attrHeader->CompressionType, @@ -5338,7 +5336,7 @@ USTATUS FfsParser::parseSignedPackageInfoData(const UModelIndex & index) UByteArray hash((const char*)moduleHeader + CpdExtSignedPkgMetadataHashOffset, moduleHeader->HashSize); std::reverse(hash.begin(), hash.end()); - UString info = usprintf("Full size: 0x%X (%u)\nType: 0x%X\nHash algorithm: 0x%X\nHash size: 0x%X (%u)\nMetadata size: 0x%X (%u)\nMetadata hash: ", + UString info = usprintf("Full size: %Xh (%u)\nType: %Xh\nHash algorithm: %Xh\nHash size: %Xh (%u)\nMetadata size: %Xh (%u)\nMetadata hash: ", (UINT32)module.size(), (UINT32)module.size(), moduleHeader->Type, moduleHeader->HashAlgorithm, diff --git a/common/fitparser.cpp b/common/fitparser.cpp index c41f1f2..641d07f 100644 --- a/common/fitparser.cpp +++ b/common/fitparser.cpp @@ -79,7 +79,7 @@ USTATUS FitParser::parseFit(const UModelIndex & index) tempFitHeader->Checksum = 0; UINT8 calculated = calculateChecksum8((const UINT8*)tempFitHeader, fitSize); if (calculated != fitHeader->Checksum) { - msg(usprintf("%s: invalid FIT table checksum 0x%02X, should be 0x%02X", __FUNCTION__, fitHeader->Checksum, calculated), fitIndex); + msg(usprintf("%s: invalid FIT table checksum %02Xh, should be %02Xh", __FUNCTION__, fitHeader->Checksum, calculated), fitIndex); } } @@ -92,9 +92,9 @@ USTATUS FitParser::parseFit(const UModelIndex & index) // Add FIT header std::vector<UString> currentStrings; currentStrings.push_back(UString("_FIT_ ")); - currentStrings.push_back(usprintf("0x%08X", fitSize)); - currentStrings.push_back(usprintf("0x%04X", fitHeader->Version)); - currentStrings.push_back(usprintf("0x%02X", fitHeader->Checksum)); + currentStrings.push_back(usprintf("%08Xh", fitSize)); + currentStrings.push_back(usprintf("%04Xh", fitHeader->Version)); + currentStrings.push_back(usprintf("%02Xh", fitHeader->Checksum)); currentStrings.push_back(fitEntryTypeToUString(fitHeader->Type)); currentStrings.push_back(UString()); // Empty info for FIT header fitTable.push_back(std::pair<std::vector<UString>, UModelIndex>(currentStrings, fitIndex)); @@ -120,7 +120,7 @@ USTATUS FitParser::parseFit(const UModelIndex & index) if ((currentEntry->Type == INTEL_FIT_TYPE_TXT_POLICY || currentEntry->Type == INTEL_FIT_TYPE_TPM_POLICY) && currentEntry->Version == 0) { const INTEL_FIT_INDEX_IO_ADDRESS* policy = (const INTEL_FIT_INDEX_IO_ADDRESS*)currentEntry; - info += usprintf("Index: 0x%04X, BitPosition: 0x%02X, AccessWidth: 0x%02X, DataRegAddr: 0x%04X, IndexRegAddr: 0x%04X", + info += usprintf("Index: %04Xh, BitPosition: %02Xh, AccessWidth: %02Xh, DataRegAddr: %04Xh, IndexRegAddr: %04Xh", policy->Index, policy->BitPosition, policy->AccessWidthInBytes, @@ -170,10 +170,10 @@ USTATUS FitParser::parseFit(const UModelIndex & index) } // Add entry to fitTable - currentStrings.push_back(usprintf("0x%016" PRIX64, currentEntry->Address)); - currentStrings.push_back(usprintf("0x%08X", currentEntrySize)); - currentStrings.push_back(usprintf("0x%04X", currentEntry->Version)); - currentStrings.push_back(usprintf("0x%02X", currentEntry->Checksum)); + currentStrings.push_back(usprintf("%016" PRIX64 "h", currentEntry->Address)); + currentStrings.push_back(usprintf("%08Xh", currentEntrySize)); + currentStrings.push_back(usprintf("%04Xh", currentEntry->Version)); + currentStrings.push_back(usprintf("%02Xh", currentEntry->Checksum)); currentStrings.push_back(fitEntryTypeToUString(currentEntry->Type)); currentStrings.push_back(info); fitTable.push_back(std::pair<std::vector<UString>, UModelIndex>(currentStrings, itemIndex)); @@ -238,7 +238,7 @@ void FitParser::findFitRecursive(const UModelIndex & index, UModelIndex & found, // Real FIT found found = index; fitOffset = offset; - msg(usprintf("%s: real FIT table found at physical address 0x%08X", __FUNCTION__, fitAddress), found); + msg(usprintf("%s: real FIT table found at physical address %08Xh", __FUNCTION__, fitAddress), found); break; } } @@ -265,7 +265,7 @@ USTATUS FitParser::parseFitEntryMicrocode(const UByteArray & microcode, const UI } // Valid microcode found - info = usprintf("CpuSignature: 0x%08X, Revision: 0x%08X, Date: %02X.%02X.%04X", + info = usprintf("CpuSignature: %08Xh, Revision: %08Xh, Date: %02X.%02X.%04X", ucodeHeader->ProcessorSignature, ucodeHeader->UpdateRevision, ucodeHeader->DateDay, @@ -290,11 +290,11 @@ USTATUS FitParser::parseFitEntryAcm(const UByteArray & acm, const UINT32 localOf // Check header version to be of a known value if (header->header_version() != intel_acm_t::KNOWN_HEADER_VERSION_V0_0 && header->header_version() != intel_acm_t::KNOWN_HEADER_VERSION_V3_0) { - msg(usprintf("%s: Intel ACM with unknown header version 0x%08X found", __FUNCTION__, header->header_version()), parent); + msg(usprintf("%s: Intel ACM with unknown header version %08Xh found", __FUNCTION__, header->header_version()), parent); } // Valid ACM found - info = usprintf("LocalOffset: 0x%08X, EntryPoint: 0x%08X, ACM SVN: 0x%04X, Date: %02X.%02X.%04X", + info = usprintf("LocalOffset: %08Xh, EntryPoint: %08Xh, ACM SVN: %04Xh, Date: %02X.%02X.%04X", localOffset, header->entry_point(), header->acm_svn(), @@ -314,30 +314,30 @@ USTATUS FitParser::parseFitEntryAcm(const UByteArray & acm, const UINT32 localOf acmInfo = "BootGuard ACM "; } else { - acmInfo = usprintf("Unknown ACM (0x%04X)", header->module_subtype()); - msg(usprintf("%s: Intel ACM with unknown subtype 0x%04X found", __FUNCTION__, header->module_subtype()), parent); + acmInfo = usprintf("Unknown ACM (%04Xh)", header->module_subtype()); + msg(usprintf("%s: Intel ACM with unknown subtype %04Xh found", __FUNCTION__, header->module_subtype()), parent); } - acmInfo += usprintf("found at base 0x%X\n" - "ModuleType: 0x%04X\n" - "ModuleSubtype: 0x%04X\n" - "HeaderSize: 0x%08X\n" - "HeaderVersion: 0x%08X\n" - "ChipsetId: 0x%04X\n" - "Flags: 0x%04X\n" - "ModuleVendor: 0x%04X\n" + acmInfo += usprintf("found at base %Xh\n" + "ModuleType: %04Xh\n" + "ModuleSubtype: %04Xh\n" + "HeaderSize: %08Xh\n" + "HeaderVersion: %08Xh\n" + "ChipsetId: %04Xh\n" + "Flags: %04Xh\n" + "ModuleVendor: %04Xh\n" "Date: %02X.%02X.%04X\n" - "ModuleSize: 0x%08X\n" - "AcmSvn: 0x%04X\n" - "SeSvn: 0x%04X\n" - "CodeControlFlags: 0x%08X\n" - "ErrorEntryPoint: 0x%08X\n" - "GdtMax: 0x%08X\n" - "GdtBase: 0x%08X\n" - "SegmentSel: 0x%08X\n" - "EntryPoint: 0x%08X\n" - "KeySize: 0x%08X\n" - "ScratchSpaceSize: 0x%08X\n", + "ModuleSize: %08Xh\n" + "AcmSvn: %04Xh\n" + "SeSvn: %04Xh\n" + "CodeControlFlags: %08Xh\n" + "ErrorEntryPoint: %08Xh\n" + "GdtMax: %08Xh\n" + "GdtBase: %08Xh\n" + "SegmentSel: %08Xh\n" + "EntryPoint: %08Xh\n" + "KeySize: %08Xh\n" + "ScratchSpaceSize: %08Xh\n", model->base(parent) + localOffset, header->module_type(), header->module_subtype(), @@ -361,10 +361,10 @@ USTATUS FitParser::parseFitEntryAcm(const UByteArray & acm, const UINT32 localOf // Add RsaPublicKey if (header->_is_null_rsa_exponent() == false) { - acmInfo += usprintf("ACM RSA Public Key Exponent: 0x%X\n", header->rsa_exponent()); + acmInfo += usprintf("ACM RSA Public Key Exponent: %Xh\n", header->rsa_exponent()); } else { - acmInfo += usprintf("ACM RSA Public Key Exponent: 0x%X\n", INTEL_ACM_HARDCODED_RSA_EXPONENT); + acmInfo += usprintf("ACM RSA Public Key Exponent: %Xh\n", INTEL_ACM_HARDCODED_RSA_EXPONENT); } acmInfo += usprintf("ACM RSA Public Key:"); for (UINT32 i = 0; i < header->rsa_public_key().size(); i++) { @@ -403,7 +403,7 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif intel_keym_v1_t parsed(&ks); // Valid KM found - info = usprintf("LocalOffset: 0x%08X, Version: 0x%02X, KM Version: 0x%02X, KM SVN: 0x%02X", + info = usprintf("LocalOffset: %08Xh, Version: %02Xh, KM Version: %02Xh, KM SVN: %02Xh", localOffset, parsed.version(), parsed.km_version(), @@ -411,12 +411,12 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif // Populate KM info UString kmInfo - = usprintf("Intel BootGuard Key manifest found at base 0x%X\n" + = usprintf("Intel BootGuard Key manifest found at base %Xh\n" "Tag: '__KEYM__'\n" - "Version: 0x%02X\n" - "KmVersion: 0x%02X\n" - "KmSvn: 0x%02X\n" - "KmId: 0x%02X\n", + "Version: %02Xh\n" + "KmVersion: %02Xh\n" + "KmSvn: %02Xh\n" + "KmId: %02Xh\n", model->base(parent) + localOffset, parsed.version(), parsed.km_version(), @@ -433,15 +433,15 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif // Add Key Signature const intel_keym_v1_t::key_signature_t* key_signature = parsed.key_signature(); kmInfo += usprintf("Key Manifest Key Signature:\n" - "Version: 0x%02X\n" - "KeyId: 0x%04X\n" - "SigScheme: 0x%04X\n", + "Version: %02Xh\n" + "KeyId: %04Xh\n" + "SigScheme: %04Xh\n", key_signature->version(), key_signature->key_id(), key_signature->sig_scheme()); // Add PubKey - kmInfo += usprintf("Key Manifest Public Key Exponent: 0x%X\n", key_signature->public_key()->exponent()); + kmInfo += usprintf("Key Manifest Public Key Exponent: %Xh\n", key_signature->public_key()->exponent()); kmInfo += usprintf("Key Manifest Public Key:"); for (UINT16 i = 0; i < (UINT16)key_signature->public_key()->modulus().length(); i++) { if (i % 32 == 0) kmInfo += UString("\n"); @@ -507,7 +507,7 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif intel_keym_v2_t::header_t* header = parsed.header(); // Valid KM found - info = usprintf("LocalOffset: 0x%08X, Version: 0x%02X, KM Version: 0x%02X, KM SVN: 0x%02X", + info = usprintf("LocalOffset: %08Xh, Version: %02Xh, KM Version: %02Xh, KM SVN: %02Xh", localOffset, header->version(), parsed.km_version(), @@ -515,15 +515,15 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif // Populate KM info UString kmInfo - = usprintf("Intel BootGuard Key manifest found at base 0x%X\n" + = usprintf("Intel BootGuard Key manifest found at base %Xh\n" "Tag: '__KEYM__'\n" - "Version: 0x%02X\n" - "KmVersion: 0x%02X\n" - "KmSvn: 0x%02X\n" - "KmId: 0x%02X\n" - "KeySignatureOffset: 0x%04X\n" - "FPFHashAlgorithmId: 0x%04X\n" - "HashCount: 0x%04X\n", + "Version: %02Xh\n" + "KmVersion: %02Xh\n" + "KmSvn: %02Xh\n" + "KmId: %02Xh\n" + "KeySignatureOffset: %04Xh\n" + "FPFHashAlgorithmId: %04Xh\n" + "HashCount: %04Xh\n", model->base(parent) + localOffset, header->version(), parsed.km_version(), @@ -544,7 +544,7 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif const auto & current_km_hash = parsed.km_hashes()->at(i); // Add KM hash - kmInfo += usprintf("UsageFlags: 0x%016" PRIX64 ", ", current_km_hash->usage_flags()) + hashTypeToUString(current_km_hash->hash_algorithm_id()) + ": "; + kmInfo += usprintf("UsageFlags: %016" PRIX64 "h, ", current_km_hash->usage_flags()) + hashTypeToUString(current_km_hash->hash_algorithm_id()) + ": "; for (UINT16 j = 0; j < current_km_hash->len_hash(); j++) { kmInfo += usprintf("%02X", (UINT8)current_km_hash->hash().data()[j]); } @@ -559,15 +559,15 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif // Add Key Signature const intel_keym_v2_t::key_signature_t* key_signature = parsed.key_signature(); kmInfo += usprintf("Key Manifest Key Signature:\n" - "Version: 0x%02X\n" - "KeyId: 0x%04X\n" - "SigScheme: 0x%04X\n", + "Version: %02Xh\n" + "KeyId: %04Xh\n" + "SigScheme: %04Xh\n", key_signature->version(), key_signature->key_id(), key_signature->sig_scheme()); // Add PubKey - kmInfo += usprintf("Key Manifest Public Key Exponent: 0x%X\n", key_signature->public_key()->exponent()); + kmInfo += usprintf("Key Manifest Public Key Exponent: %Xh\n", key_signature->public_key()->exponent()); kmInfo += usprintf("Key Manifest Public Key:"); for (UINT16 i = 0; i < (UINT16)key_signature->public_key()->modulus().length(); i++) { if (i % 32 == 0) kmInfo += UString("\n"); @@ -638,20 +638,20 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic intel_acbp_v1_t parsed(&ks); // Valid BPM found - info = usprintf("LocalOffset: 0x%08X, Version: 0x%02X, BP SVN: 0x%02X, ACM SVN: 0x%02X", + info = usprintf("LocalOffset: %08Xh, Version: %02Xh, BP SVN: %02Xh, ACM SVN: %02Xh", localOffset, parsed.version(), parsed.bp_svn(), parsed.acm_svn()); UString bpInfo - = usprintf("Intel BootGuard Boot Policy Manifest found at base 0x%X\n" + = usprintf("Intel BootGuard Boot Policy Manifest found at base %Xh\n" "StructureId: '__ACBP__'\n" - "Version: 0x%02X\n" - "BPMRevision: 0x%02X\n" - "BPSVN: 0x%02X\n" - "ACMSVN: 0x%02X\n" - "NEMDataSize: 0x%04X\n", + "Version: %02Xh\n" + "BPMRevision: %02Xh\n" + "BPSVN: %02Xh\n" + "ACMSVN: %02Xh\n" + "NEMDataSize: %04Xh\n", model->base(parent) + localOffset, parsed.version(), parsed.bpm_revision(), @@ -667,7 +667,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const char* structure_id_bytes = (const char*)&structure_id; bpInfo += usprintf("StructureId: '%c%c%c%c%c%c%c%c'\n" - "Version: 0x%02X\n", + "Version: %02Xh\n", structure_id_bytes[0], structure_id_bytes[1], structure_id_bytes[2], @@ -683,15 +683,15 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const intel_acbp_v1_t::ibbs_body_t* ibbs_body = element->ibbs_body(); // Valid IBBS element found - bpInfo += usprintf("Flags: 0x%08X\n" - "MchBar: 0x%016" PRIX64 "\n" - "VtdBar: 0x%016" PRIX64 "\n" - "DmaProtectionBase0: 0x%08X\n" - "DmaProtectionLimit0: 0x%08X\n" - "DmaProtectionBase1: 0x%016" PRIX64 "\n" - "DmaProtectionLimit1: 0x%016" PRIX64 "\n" - "IbbEntryPoint: 0x%08X\n" - "IbbSegmentsCount: 0x%02X\n", + bpInfo += usprintf("Flags: %08Xh\n" + "MchBar: %016" PRIX64 "h\n" + "VtdBar: %016" PRIX64 "h\n" + "DmaProtectionBase0: %08Xh\n" + "DmaProtectionLimit0: %08Xh\n" + "DmaProtectionBase1: %016" PRIX64 "h\n" + "DmaProtectionLimit1: %016" PRIX64 "h\n" + "IbbEntryPoint: %08Xh\n" + "IbbSegmentsCount: %02Xh\n", ibbs_body->flags(), ibbs_body->mch_bar(), ibbs_body->vtd_bar(), @@ -743,7 +743,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic for (UINT8 i = 0; i < ibbs_body->num_ibb_segments(); i++) { const auto & current_segment = ibbs_body->ibb_segments()->at(i); - bpInfo += usprintf("Flags: 0x%04X, Address: 0x%08X, Size: 0x%08X\n", + bpInfo += usprintf("Flags: %04Xh, Address: %08Xh, Size: %08Xh\n", current_segment->flags(), current_segment->base(), current_segment->size()); @@ -765,9 +765,9 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic intel_acbp_v1_t::pmda_body_t* pmda_body = element->pmda_body(); // Valid Microsoft PMDA element found - bpInfo += usprintf("TotalSize: 0x%04X\n" - "Version: 0x%08X\n" - "NumEntries: 0x%08X\n", + bpInfo += usprintf("TotalSize: %04Xh\n" + "Version: %08Xh\n" + "NumEntries: %08Xh\n", pmda_body->total_size(), pmda_body->version(), pmda_body->num_entries()); @@ -782,7 +782,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const auto & current_element = pmda_body->entries_v1()->at(i); // Add element - bpInfo += usprintf("Address: 0x%08X, Size: 0x%08X\n", + bpInfo += usprintf("Address: %08Xh, Size: %08Xh\n", current_element->base(), current_element->size()); @@ -811,7 +811,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const auto & current_element = pmda_body->entries_v2()->at(i); // Add element - bpInfo += usprintf("Address: 0x%08X, Size: 0x%08X\n", + bpInfo += usprintf("Address: %08Xh, Size: %08Xh\n", current_element->base(), current_element->size()); @@ -840,15 +840,15 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic else if (element->_is_null_pmsg_body() == false) { const intel_acbp_v1_t::pmsg_body_t* key_signature = element->pmsg_body(); bpInfo += usprintf("Boot Policy Key Signature:\n" - "Version: 0x%02X\n" - "KeyId: 0x%04X\n" - "SigScheme: 0x%04X\n", + "Version: %02Xh\n" + "KeyId: %04Xh\n" + "SigScheme: %04Xh\n", key_signature->version(), key_signature->key_id(), key_signature->sig_scheme()); // Add PubKey - bpInfo += usprintf("Boot Policy Public Key Exponent: 0x%X\n", key_signature->public_key()->exponent()); + bpInfo += usprintf("Boot Policy Public Key Exponent: %Xh\n", key_signature->public_key()->exponent()); bpInfo += usprintf("Boot Policy Public Key:"); for (UINT16 i = 0; i < (UINT16)key_signature->public_key()->modulus().length(); i++) { if (i % 32 == 0) bpInfo += UString("\n"); @@ -900,7 +900,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic kaitai::kstream ks(&is); intel_acbp_v2_t parsed(&ks); // This already verified the version to be >= 0x20 // Valid BPM found - info = usprintf("LocalOffset: 0x%08X, Version: 0x%02X, BP SVN: 0x%02X, ACM SVN: 0x%02X", + info = usprintf("LocalOffset: %08Xh, Version: %02Xh, BP SVN: %02Xh, ACM SVN: %02Xh", localOffset, parsed.version(), parsed.bp_svn(), @@ -908,16 +908,16 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic // Add BP header and body info UString bpInfo - = usprintf("Intel BootGuard Boot Policy Manifest found at base 0x%X\n" + = usprintf("Intel BootGuard Boot Policy Manifest found at base %Xh\n" "StructureId: '__ACBP__'\n" - "Version: 0x%02X\n" - "HeaderSpecific: 0x%02X\n" - "TotalSize: 0x%04X\n" - "KeySignatureOffset: 0x%04X\n" - "BPMRevision: 0x%02X\n" - "BPSVN: 0x%02X\n" - "ACMSVN: 0x%02X\n" - "NEMDataSize: 0x%04X\n", + "Version: %02Xh\n" + "HeaderSpecific: %02Xh\n" + "TotalSize: %04Xh\n" + "KeySignatureOffset: %04Xh\n" + "BPMRevision: %02Xh\n" + "BPSVN: %02Xh\n" + "ACMSVN: %02Xh\n" + "NEMDataSize: %04Xh\n", model->base(parent) + localOffset, parsed.version(), parsed.header_specific(), @@ -936,9 +936,9 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const char* structure_id_bytes = (const char*)&structure_id; bpInfo += usprintf("StructureId: '%c%c%c%c%c%c%c%c'\n" - "Version: 0x%02X\n" - "HeaderSpecific: 0x%02X\n" - "TotalSize: 0x%04X\n", + "Version: %02Xh\n" + "HeaderSpecific: %02Xh\n" + "TotalSize: %04Xh\n", structure_id_bytes[0], structure_id_bytes[1], structure_id_bytes[2], @@ -956,19 +956,19 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const intel_acbp_v2_t::ibbs_body_t* ibbs_body = element->ibbs_body(); // Valid IBBS element found - bpInfo += usprintf("SetNumber: 0x%02X\n" - "PBETValue: 0x%02X\n" - "Flags: 0x%08X\n" - "MchBar: 0x%016" PRIX64 "\n" - "VtdBar: 0x%016" PRIX64 "\n" - "DmaProtectionBase0: 0x%08X\n" - "DmaProtectionLimit0: 0x%08X\n" - "DmaProtectionBase1: 0x%016" PRIX64 "\n" - "DmaProtectionLimit1: 0x%016" PRIX64 "\n" - "IbbEntryPoint: 0x%08X\n" - "IbbDigestsSize: 0x%02X\n" - "IbbDigestsCount: 0x%02X\n" - "IbbSegmentsCount: 0x%02X\n", + bpInfo += usprintf("SetNumber: %02Xh\n" + "PBETValue: %02Xh\n" + "Flags: %08Xh\n" + "MchBar: %016" PRIX64 "h\n" + "VtdBar: %016" PRIX64 "h\n" + "DmaProtectionBase0: %08Xh\n" + "DmaProtectionLimit0: %08Xh\n" + "DmaProtectionBase1: %016" PRIX64 "h\n" + "DmaProtectionLimit1: %016" PRIX64 "h\n" + "IbbEntryPoint: %08Xh\n" + "IbbDigestsSize: %02Xh\n" + "IbbDigestsCount: %02Xh\n" + "IbbSegmentsCount: %02Xh\n", ibbs_body->set_number(), ibbs_body->pbet_value(), ibbs_body->flags(), @@ -1058,7 +1058,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic for (UINT8 i = 0; i < ibbs_body->num_ibb_segments(); i++) { const auto & current_segment = ibbs_body->ibb_segments()->at(i); - bpInfo += usprintf("Flags: 0x%04X, Address: 0x%08X, Size: 0x%08X\n", + bpInfo += usprintf("Flags: %04Xh, Address: %08Xh, Size: %08Xh\n", current_segment->flags(), current_segment->base(), current_segment->size()); @@ -1080,9 +1080,9 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const intel_acbp_v2_t::pmda_body_t* pmda_body = element->pmda_body(); // Valid Microsoft PMDA element found - bpInfo += usprintf("TotalSize: 0x%04X\n" - "Version: 0x%08X\n" - "NumEntries: 0x%08X\n", + bpInfo += usprintf("TotalSize: %04Xh\n" + "Version: %08Xh\n" + "NumEntries: %08Xh\n", pmda_body->total_size(), pmda_body->version(), pmda_body->num_entries()); @@ -1099,7 +1099,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic const char* entry_id_bytes = (const char*)&entry_id; // Add element - bpInfo += usprintf("EntryId: '%c%c%c%c', Version: 0x%04X, Address: 0x%08X, Size: 0x%08X\n", + bpInfo += usprintf("EntryId: '%c%c%c%c', Version: %04Xh, Address: %08Xh, Size: %08Xh\n", entry_id_bytes[0], entry_id_bytes[1], entry_id_bytes[2], @@ -1134,15 +1134,15 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic // Add Key Signature const intel_acbp_v2_t::key_signature_t* key_signature = parsed.key_signature(); bpInfo += usprintf("Boot Policy Key Signature:\n" - "Version: 0x%02X\n" - "KeyId: 0x%04X\n" - "SigScheme: 0x%04X\n", + "Version: %02Xh\n" + "KeyId: %04Xh\n" + "SigScheme: %04Xh\n", key_signature->version(), key_signature->key_id(), key_signature->sig_scheme()); // Add PubKey - bpInfo += usprintf("Boot Policy Public Key Exponent: 0x%X\n", key_signature->public_key()->exponent()); + bpInfo += usprintf("Boot Policy Public Key Exponent: %Xh\n", key_signature->public_key()->exponent()); bpInfo += usprintf("Boot Policy Public Key:"); for (UINT16 i = 0; i < (UINT16)key_signature->public_key()->modulus().length(); i++) { if (i % 32 == 0) bpInfo += UString("\n"); diff --git a/common/meparser.cpp b/common/meparser.cpp index 3dbcd17..aea1ae0 100755 --- a/common/meparser.cpp +++ b/common/meparser.cpp @@ -136,8 +136,8 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex & if (ptHeader->HeaderVersion == FPT_HEADER_VERSION_21) { const FPT_HEADER_21* ptHeader21 = (const FPT_HEADER_21*)ptHeader; - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: 0x%02X\nEntry version: 0x%02X\n" - "Header length: 0x%02X\nFlags: 0x%X\nTicks to add: 0x%04X\nTokens to add: 0x%04X\nSPS Flags: 0x%X\nFITC version: %u.%u.%u.%u\nCRC32 Checksum: 0x%08X", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n" + "Header length: %02Xh\nFlags: %Xh\nTicks to add: %04Xh\nTokens to add: %04Xh\nSPS Flags: %Xh\nFITC version: %u.%u.%u.%u\nCRC32 Checksum: %08Xh", ptSize, ptSize, (UINT32)header.size(), (UINT32)header.size(), ptBodySize, ptBodySize, @@ -156,8 +156,8 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex & } // Default handling for all other versions, may be too generic in some corner cases else { - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: 0x%02X\nEntry version: 0x%02X\n" - "Header length: 0x%02X\nFlash cycle life: 0x%04X\nFlash cycle limit: 0x%04X\nUMA size: 0x%X\nFlags: 0x%X\nFITC version: %u.%u.%u.%u\nChecksum: 0x%02X", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n" + "Header length: %02Xh\nFlash cycle life: %04Xh\nFlash cycle limit: %04Xh\nUMA size: %Xh\nFlags: %Xh\nFITC version: %u.%u.%u.%u\nChecksum: %02Xh", ptSize, ptSize, (UINT32)header.size(), (UINT32)header.size(), ptBodySize, ptBodySize, @@ -189,7 +189,7 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex & // Get info name = visibleAsciiOrHex((UINT8*)ptEntry->Name, 4); - info = usprintf("Full size: 0x%X (%u)\nPartition offset: 0x%X\nPartition length: 0x%X\nPartition type: 0x%02X", + info = usprintf("Full size: %Xh (%u)\nPartition offset: %Xh\nPartition length: %Xh\nPartition type: %02Xh", (UINT32)sizeof(FPT_HEADER_ENTRY), (UINT32)sizeof(FPT_HEADER_ENTRY), ptEntry->Offset, ptEntry->Size, @@ -305,7 +305,7 @@ make_partition_table_consistent: UModelIndex partitionIndex; // Get info name = visibleAsciiOrHex((UINT8*) partitions[i].ptEntry.Name, 4); - info = usprintf("Full size: 0x%X (%u)\nPartition type: 0x%02X\n", + info = usprintf("Full size: %Xh (%u)\nPartition type: %02Xh\n", (UINT32)partition.size(), (UINT32)partition.size(), partitions[i].ptEntry.Type); @@ -321,7 +321,7 @@ make_partition_table_consistent: else if (partitions[i].type == Types::Padding) { // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)partition.size(), (UINT32)partition.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent); @@ -346,14 +346,14 @@ USTATUS MeParser::parseIfwi16Region(const UByteArray & region, const UModelIndex UByteArray header = region.left(ptSize); UString name = UString("IFWI 1.6 header"); - UString info = usprintf("Full size: 0x%X (%u)\n" - "Data partition offset: 0x%X\nData partition size: 0x%X\n" - "Boot1 partition offset: 0x%X\nBoot1 partition size: 0x%X\n" - "Boot2 partition offset: 0x%X\nBoot2 partition size: 0x%X\n" - "Boot3 partition offset: 0x%X\nBoot3 partition size: 0x%X\n" - "Boot4 partition offset: 0x%X\nBoot4 partition size: 0x%X\n" - "Boot5 partition offset: 0x%X\nBoot5 partition size: 0x%X\n" - "Checksum: 0x%" PRIX64, + UString info = usprintf("Full size: %Xh (%u)\n" + "Data partition offset: %Xh\nData partition size: %Xh\n" + "Boot1 partition offset: %Xh\nBoot1 partition size: %Xh\n" + "Boot2 partition offset: %Xh\nBoot2 partition size: %Xh\n" + "Boot3 partition offset: %Xh\nBoot3 partition size: %Xh\n" + "Boot4 partition offset: %Xh\nBoot4 partition size: %Xh\n" + "Boot5 partition offset: %Xh\nBoot5 partition size: %Xh\n" + "Checksum: %" PRIX64 "h", (UINT32)header.size(), (UINT32)header.size(), ifwiHeader->DataPartition.Offset, ifwiHeader->DataPartition.Size, ifwiHeader->BootPartition[0].Offset, ifwiHeader->BootPartition[0].Size, @@ -471,7 +471,7 @@ make_partition_table_consistent: } // Get info - info = usprintf("Full size: 0x%X (%u)\n", (UINT32)partition.size(), (UINT32)partition.size()); + info = usprintf("Full size: %Xh (%u)\n", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item partitionIndex = model->addItem(partitions[i].ptEntry.Offset, partitions[i].type, partitions[i].subtype, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent); @@ -490,7 +490,7 @@ make_partition_table_consistent: else if (partitions[i].type == Types::Padding) { // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)partition.size(), (UINT32)partition.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent); @@ -516,17 +516,17 @@ USTATUS MeParser::parseIfwi17Region(const UByteArray & region, const UModelIndex UByteArray header = region.left(ptSize); UString name = UString("IFWI 1.7 header"); - UString info = usprintf("Full size: 0x%X (%u)\n" - "Flags: 0x%02X\n" - "Reserved: 0x%02X\n" - "Checksum: 0x%X\n" - "Data partition offset: 0x%X\nData partition size: 0x%X\n" - "Boot1 partition offset: 0x%X\nBoot1 partition size: 0x%X\n" - "Boot2 partition offset: 0x%X\nBoot2 partition size: 0x%X\n" - "Boot3 partition offset: 0x%X\nBoot3 partition size: 0x%X\n" - "Boot4 partition offset: 0x%X\nBoot4 partition size: 0x%X\n" - "Boot5 partition offset: 0x%X\nBoot5 partition size: 0x%X\n" - "Temp page offset: 0x%X\nTemp page size: 0x%X\n", + UString info = usprintf("Full size: %Xh (%u)\n" + "Flags: %02Xh\n" + "Reserved: %02Xh\n" + "Checksum: %Xh\n" + "Data partition offset: %Xh\nData partition size: %Xh\n" + "Boot1 partition offset: %Xh\nBoot1 partition size: %Xh\n" + "Boot2 partition offset: %Xh\nBoot2 partition size: %Xh\n" + "Boot3 partition offset: %Xh\nBoot3 partition size: %Xh\n" + "Boot4 partition offset: %Xh\nBoot4 partition size: %Xh\n" + "Boot5 partition offset: %Xh\nBoot5 partition size: %Xh\n" + "Temp page offset: %Xh\nTemp page size: %Xh\n", (UINT32)header.size(), (UINT32)header.size(), ifwiHeader->Flags, ifwiHeader->Reserved, @@ -659,7 +659,7 @@ make_partition_table_consistent: } // Get info - info = usprintf("Full size: 0x%X (%u)\n", (UINT32)partition.size(), (UINT32)partition.size()); + info = usprintf("Full size: %Xh (%u)\n", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item partitionIndex = model->addItem(partitions[i].ptEntry.Offset, partitions[i].type, partitions[i].subtype, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent); @@ -685,7 +685,7 @@ make_partition_table_consistent: else if (partitions[i].type == Types::Padding) { // Get info name = UString("Padding"); - info = usprintf("Full size: 0x%X (%u)", (UINT32)partition.size(), (UINT32)partition.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size()); // Add tree item model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent); diff --git a/common/nvramparser.cpp b/common/nvramparser.cpp index 849b69c..765c289 100644 --- a/common/nvramparser.cpp +++ b/common/nvramparser.cpp @@ -87,7 +87,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index) UByteArray padding = nvar.mid(entry->offset(), unparsedSize); // Get info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)padding.size(), (UINT32)padding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); if ((UINT32)padding.count(emptyByte) == unparsedSize) { // Free space // Add tree item @@ -108,7 +108,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index) UByteArray guidArea = nvar.right(guidAreaSize); // Get info name = UString("GUID store"); - info = usprintf("Full size: 0x%X (%u)\nGUIDs in store: %u", + info = usprintf("Full size: %Xh (%u)\nGUIDs in store: %u", (UINT32)guidArea.size(), (UINT32)guidArea.size(), guidsInStore); // Add tree item @@ -223,7 +223,7 @@ processing_done: info += usprintf("GUID index: %u\n", entry_body->guid_index()); // Add header, body and extended data info - info += usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nTail size: 0x%X (%u)", + info += usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nTail size: %Xh (%u)", entry->size(), entry->size(), (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -231,7 +231,7 @@ processing_done: // Add attributes info const NVAR_ENTRY_HEADER entryHeader = readUnaligned((NVAR_ENTRY_HEADER*)header.constData()); - info += usprintf("\nAttributes: 0x%02X", entryHeader.Attributes); + info += usprintf("\nAttributes: %02Xh", entryHeader.Attributes); // Translate attributes to text if (entryHeader.Attributes != 0x00 && entryHeader.Attributes != 0xFF) @@ -239,15 +239,15 @@ processing_done: // Add next node info if (entry->next() != 0xFFFFFF) - info += usprintf("\nNext node at offset: 0x%X", localOffset + entry->offset() + (UINT32)entry->next()); + info += usprintf("\nNext node at offset: %Xh", localOffset + entry->offset() + (UINT32)entry->next()); // Add extended header info if (entry_body->extended_header_size() > 0) { - info += usprintf("\nExtended header size: 0x%X (%u)", + info += usprintf("\nExtended header size: %Xh (%u)", entry_body->extended_header_size(), entry_body->extended_header_size()); const UINT8 extendedAttributes = *tail.constData(); - info += usprintf("\nExtended attributes: 0x%02X (", extendedAttributes) + nvarExtendedAttributesToUString(extendedAttributes) + UString(")"); + info += usprintf("\nExtended attributes: %02Xh (", extendedAttributes) + nvarExtendedAttributesToUString(extendedAttributes) + UString(")"); // Add checksum if (!entry_body->_is_null_extended_header_checksum()) { @@ -266,13 +266,13 @@ processing_done: } // Include entry attributes calculatedChecksum += entryHeader.Attributes; - info += usprintf("\nChecksum: 0x%02X, ", entry_body->extended_header_checksum()) - + (calculatedChecksum ? usprintf(", invalid, should be 0x%02X", 0x100 - calculatedChecksum) : UString(", valid")); + info += usprintf("\nChecksum: %02Xh, ", entry_body->extended_header_checksum()) + + (calculatedChecksum ? usprintf(", invalid, should be %02Xh", 0x100 - calculatedChecksum) : UString(", valid")); } // Add timestamp if (!entry_body->_is_null_extended_header_timestamp()) - info += usprintf("\nTimestamp: 0x%" PRIX64, entry_body->extended_header_timestamp()); + info += usprintf("\nTimestamp: %" PRIX64 "h", entry_body->extended_header_timestamp()); // Add hash if (!entry_body->_is_null_extended_header_hash()) { @@ -375,7 +375,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index,const UINT32 // VSS store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -395,8 +395,8 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index,const UINT32 name = UString("VSS store"); } - info = usprintf("Signature: 0x%X (", parsed.signature()) + fourCC(parsed.signature()) + UString(")\n"); - info += usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nFormat: 0x%02X\nState: 0x%02X\nReserved: 0x%02X\nReserved1: 0x%04X", + info = usprintf("Signature: %Xh (", parsed.signature()) + fourCC(parsed.signature()) + UString(")\n"); + info += usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nFormat: %02Xh\nState: %02Xh\nReserved: %02Xh\nReserved1: %04Xh", storeSize , storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -419,7 +419,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index,const UINT32 if (entryOffset < storeSize) { UByteArray freeSpace = vss.mid(entryOffset, storeSize - entryOffset); // Add info - info = usprintf("Full size: 0x%X (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); // Check that remaining unparsed bytes are actually empty if (freeSpace.count(emptyByte) == freeSpace.size()) { // Free space @@ -497,7 +497,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index,const UINT32 + (UINT32)(variable->attributes()->apple_data_checksum() << 31); // Add generic info - info += usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nState: 0x%02X\nReserved: 0x%02X\nAttributes: 0x%08X (", + info += usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nState: %02Xh\nReserved: %02Xh\nAttributes: %08Xh (", variableSize, variableSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -508,15 +508,15 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index,const UINT32 // Add specific info if (variable->is_auth()) { UINT64 monotonicCounter = (UINT64)variable->len_name() + ((UINT64)variable->len_data() << 32); - info += usprintf("\nMonotonic counter: 0x%" PRIX64 "\nTimestamp: ", monotonicCounter) + efiTimeToUString(*(const EFI_TIME*)variable->timestamp().c_str()) + info += usprintf("\nMonotonic counter: %" PRIX64 "h\nTimestamp: ", monotonicCounter) + efiTimeToUString(*(const EFI_TIME*)variable->timestamp().c_str()) + usprintf("\nPubKey index: %u", variable->pubkey_index()); } else if (!variable->_is_null_apple_data_crc32()) { // Calculate CRC32 of the variable data UINT32 calculatedCrc32 = (UINT32)crc32(0, (const UINT8*)body.constData(), (uInt)body.size()); - info += usprintf("\nData checksum: 0x%08X", variable->apple_data_crc32()) + - (variable->apple_data_crc32() != calculatedCrc32 ? usprintf(", invalid, should be 0x%08X", calculatedCrc32) : UString(", valid")); + info += usprintf("\nData checksum: %08Xh", variable->apple_data_crc32()) + + (variable->apple_data_crc32() != calculatedCrc32 ? usprintf(", invalid, should be %08Xh", calculatedCrc32) : UString(", valid")); } // Add tree item @@ -578,7 +578,7 @@ not_vss: // VSS2 store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -599,7 +599,7 @@ not_vss: info = UString("Signature: DDCF3617-3275-4164-98B6-FE85707FFE7D\n"); } - info += usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nFormat: 0x%02X\nState: 0x%02X\nReserved: 0x%02X\nReserved1: 0x%04X", + info += usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nFormat: %02Xh\nState: %02Xh\nReserved: %02Xh\nReserved1: %04Xh", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -622,7 +622,7 @@ not_vss: if (entryOffset < storeSize) { UByteArray freeSpace = vss2.mid(entryOffset, storeSize - entryOffset); // Add info - info = usprintf("Full size: 0x%X (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); // Check that remaining unparsed bytes are actually empty if (freeSpace.count(emptyByte) == freeSpace.size()) { // Free space @@ -680,7 +680,7 @@ not_vss: + (UINT32)(variable->attributes()->reserved() << 7); // Add generic info - info += usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nState: 0x%02X\nReserved: 0x%02X\nAttributes: 0x%08X (", + info += usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nState: %02Xh\nReserved: %02Xh\nAttributes: %08Xh (", variableSize, variableSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -691,7 +691,7 @@ not_vss: // Add specific info if (variable->is_auth()) { UINT64 monotonicCounter = (UINT64)variable->len_name() + ((UINT64)variable->len_data() << 32); - info += usprintf("\nMonotonic counter: 0x%" PRIX64 "\nTimestamp: ", monotonicCounter) + efiTimeToUString(*(const EFI_TIME*)variable->timestamp().c_str()) + info += usprintf("\nMonotonic counter: %" PRIX64 "h\nTimestamp: ", monotonicCounter) + efiTimeToUString(*(const EFI_TIME*)variable->timestamp().c_str()) + usprintf("\nPubKey index: %u", variable->pubkey_index()); } @@ -739,7 +739,7 @@ not_vss2: } else { // No need to parse further, unknown FTW store size - msg(usprintf("%s: can not determine FTW store size for candidate at base 0x%08X", __FUNCTION__, model->base(index) + localOffset + storeOffset), index); + msg(usprintf("%s: can not determine FTW store size for candidate at base %08Xh", __FUNCTION__, model->base(index) + localOffset + storeOffset), index); goto not_ftw; } storeSize = MIN(volumeBodySize - storeOffset, storeSize); @@ -777,7 +777,7 @@ not_vss2: // FTW store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -788,12 +788,12 @@ not_vss2: // Add info name = UString("FTW store"); info = UString("Signature: ") + guidToUString(*(const EFI_GUID*)guid.constData(), false); - info += usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nState: 0x%02X\nHeader CRC32: 0x%08X", + info += usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nState: %02Xh\nHeader CRC32: %08Xh", (UINT32)storeSize, (UINT32)storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), parsed.state(), - parsed.crc()) + (parsed.crc() != calculatedCrc ? usprintf(", invalid, should be 0x%08X", calculatedCrc) : UString(", valid")); + parsed.crc()) + (parsed.crc() != calculatedCrc ? usprintf(", invalid, should be %08Xh", calculatedCrc) : UString(", valid")); // Add header tree item model->addItem(localOffset + storeOffset, Types::FtwStore, 0, name, UString(), info, header, body, UByteArray(), Fixed, index); @@ -826,7 +826,7 @@ not_ftw: // Insyde FDC store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -837,7 +837,7 @@ not_ftw: // Add info name = UString("Insyde FDC store"); - info = usprintf("Signature: _FDC\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)", + info = usprintf("Signature: _FDC\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size()); @@ -877,7 +877,7 @@ not_fdc: // Apple SysF/Diag store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -898,13 +898,13 @@ not_fdc: name = UString("Apple Diag store"); info = UString("Signature: Gaid\n"); } - info += usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nUnknown: 0x%02X\nUnknown1: 0x%08X\nCRC32: 0x%08X", + info += usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nUnknown: %02Xh\nUnknown1: %08Xh\nCRC32: %08Xh", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), parsed.unknown(), parsed.unknown1(), - parsed.crc()) + (parsed.crc() != calculatedCrc ? usprintf(", invalid, should be 0x%08X", calculatedCrc) : UString(", valid")); + parsed.crc()) + (parsed.crc() != calculatedCrc ? usprintf(", invalid, should be %08Xh", calculatedCrc) : UString(", valid")); // Add header tree item UModelIndex headerIndex = model->addItem(localOffset + storeOffset, Types::SysFStore, 0, name, UString(), info, header, body, UByteArray(), Fixed, index); @@ -933,7 +933,7 @@ not_fdc: } // Add generic info UINT32 variableSize = (UINT32)header.size() + (UINT32)body.size(); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\n", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\n", variableSize, variableSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size()); @@ -948,7 +948,7 @@ not_fdc: if (entryOffset < storeSize) { UByteArray freeSpace = volumeBody.mid(storeOffset + entryOffset, storeSize - entryOffset); // Add info - info = usprintf("Full size: 0x%X (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); // Check that remaining unparsed bytes are actually zeroes if (freeSpace.count('\x00') == freeSpace.size() - 4) { // Free space, 4 last bytes are always CRC32 @@ -990,7 +990,7 @@ not_sysf: // Phoenix FlashMap store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -1001,7 +1001,7 @@ not_sysf: // Add info name = UString("Phoenix SCT flash map"); - info = usprintf("Signature: _FLASH_MAP\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nEntries: %u\nReserved: 0x%08X", + info = usprintf("Signature: _FLASH_MAP\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nEntries: %u\nReserved: %08Xh", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), @@ -1033,7 +1033,7 @@ not_sysf: // Add info UINT32 entrySize = (UINT32)header.size(); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0h (0)\nData type: 0x%04X\nEntry type: 0x%04X\nSize: 0x%08X\nOffset: 0x%08X\nPhysical address: 0x%" PRIX64, + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\nData type: %04Xh\nEntry type: %04Xh\nSize: %08Xh\nOffset: %08Xh\nPhysical address: %" PRIX64 "h", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), entry->data_type(), @@ -1078,7 +1078,7 @@ not_flm: // Phoenix EVSA store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -1092,14 +1092,14 @@ not_flm: // Add info name = UString("Phoenix EVSA store"); - info = usprintf("Signature: EVSA\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nAttributes: 0x%08X\nReserved: 0x%08X\nChecksum: 0x%02X", + info = usprintf("Signature: EVSA\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nAttributes: %08Xh\nReserved: %08Xh\nChecksum: %02Xh", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), parsed.attributes(), parsed.reserved(), parsed.checksum()) - + (parsed.checksum() != calculated ? usprintf(", invalid, should be 0x%02X", calculated) : UString(", valid")); + + (parsed.checksum() != calculated ? usprintf(", invalid, should be %02Xh", calculated) : UString(", valid")); // Add header tree item UModelIndex headerIndex = model->addItem(localOffset + storeOffset, Types::EvsaStore, 0, name, UString(), info, header, body, UByteArray(), Fixed, index); @@ -1118,7 +1118,7 @@ not_flm: if (entryOffset < storeSize) { UByteArray freeSpace = volumeBody.mid(storeOffset + entryOffset, storeSize - entryOffset); // Add info - info = usprintf("Full size: 0x%X (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)freeSpace.size(), (UINT32)freeSpace.size()); // Check that remaining unparsed bytes are actually empty if (freeSpace.count(emptyByte) == freeSpace.size()) { // Free space @@ -1145,14 +1145,14 @@ not_flm: EFI_GUID guid = *(const EFI_GUID*)(guidEntry->guid().c_str()); name = guidToUString(guid); info = UString("GUID: ") + guidToUString(guid, false) - + usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nType: 0x%02X\nChecksum: 0x%02X", + + usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nType: %02Xh\nChecksum: %02Xh", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), entry->entry_type(), entry->checksum()) - + (entry->checksum() != calculated ? usprintf(", invalid, should be 0x%02X", calculated) : UString(", valid")) - + usprintf("\nGuidId: 0x%04X", guidEntry->guid_id()); + + (entry->checksum() != calculated ? usprintf(", invalid, should be %02Xh", calculated) : UString(", valid")) + + usprintf("\nGuidId: %04Xh", guidEntry->guid_id()); subtype = Subtypes::GuidEvsaEntry; guidMap.insert(std::pair<UINT16, EFI_GUID>(guidEntry->guid_id(), guid)); } @@ -1164,14 +1164,14 @@ not_flm: entrySize = (UINT32)(header.size() + body.size()); name = uFromUcs2(body.constData()); info = UString("Name: ") + name - + usprintf("\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nType: 0x%02X\nChecksum: 0x%02X", + + usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nType: %02Xh\nChecksum: %02Xh", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), entry->entry_type(), entry->checksum()) - + (entry->checksum() != calculated ? usprintf(", invalid, should be 0x%02X", calculated) : UString(", valid")) - + usprintf("\nVarId: 0x%04X", nameEntry->var_id()); + + (entry->checksum() != calculated ? usprintf(", invalid, should be %02Xh", calculated) : UString(", valid")) + + usprintf("\nVarId: %04Xh", nameEntry->var_id()); subtype = Subtypes::NameEvsaEntry; nameMap.insert(std::pair<UINT16, UString>(nameEntry->var_id(), name)); } @@ -1203,14 +1203,14 @@ not_flm: + (dataEntry->attributes()->extended_header() << 28) + (UINT32)(dataEntry->attributes()->reserved1() << 29); - info = usprintf("Full size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)\nType: 0x%02X\nChecksum: 0x%02X", + info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nType: %02Xh\nChecksum: %02Xh", entrySize, entrySize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size(), entry->entry_type(), entry->checksum()) - + (entry->checksum() != calculated ? usprintf(", invalid, should be 0x%02X", calculated) : UString(", valid")) - + usprintf("\nVarId: 0x%04X\nGuidId: 0x%04X\nAttributes: 0x%08X (", + + (entry->checksum() != calculated ? usprintf(", invalid, should be %02Xh", calculated) : UString(", valid")) + + usprintf("\nVarId: %04Xh\nGuidId: %04Xh\nAttributes: %08Xh (", dataEntry->var_id(), dataEntry->guid_id(), attributes) @@ -1295,7 +1295,7 @@ not_flm: // CMDB store at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -1306,7 +1306,7 @@ not_flm: // Add info name = UString("Phoenix CMDB store"); - info = usprintf("Signature: CMDB\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0x%X (%u)", + info = usprintf("Signature: CMDB\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)", storeSize, storeSize, (UINT32)header.size(), (UINT32)header.size(), (UINT32)body.size(), (UINT32)body.size()); @@ -1344,7 +1344,7 @@ not_cmdb: // SLIC PubKey at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -1354,8 +1354,8 @@ not_cmdb: // Add info name = UString("SLIC pubkey"); - info = usprintf("Type: 0h\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0h (0)\n" - "Key type: 0x%02X\nVersion: 0x%02X\nAlgorithm: 0x%08X\nMagic: RSA1\nBit length: 0x%08X\nExponent: 0x%08X", + info = usprintf("Type: 0h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\n" + "Key type: %02Xh\nVersion: %02Xh\nAlgorithm: %08Xh\nMagic: RSA1\nBit length: %08Xh\nExponent: %08Xh", parsed.len_pubkey(), parsed.len_pubkey(), parsed.len_pubkey(), parsed.len_pubkey(), parsed.key_type(), @@ -1404,7 +1404,7 @@ not_pubkey: // SLIC marker at current offset parsed correctly // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -1414,8 +1414,8 @@ not_pubkey: // Add info name = UString("SLIC marker"); - info = usprintf("Type: 1h\nFull size: 0x%X (%u)\nHeader size: 0x%X (%u)\nBody size: 0h (0)\n" - "Version: 0x%08X\nOEM ID: %s\nOEM table ID: %s\nWindows flag: WINDOWS \nSLIC version: 0x%08X", + info = usprintf("Type: 1h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: 0h (0)\n" + "Version: %08Xh\nOEM ID: %s\nOEM table ID: %s\nWindows flag: WINDOWS \nSLIC version: %08Xh", parsed.len_marker(), parsed.len_marker(), parsed.len_marker(), parsed.len_marker(), parsed.version(), @@ -1465,7 +1465,7 @@ not_marker: // All checks passed, microcode found // Check if we need to add a padding before it if (!outerPadding.isEmpty()) { - info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); model->addItem(localOffset + previousStoreEndOffset, Types::Padding, getPaddingType(outerPadding), UString("Padding"), UString(), info, UByteArray(), outerPadding, UByteArray(), Fixed, index); outerPadding.clear(); } @@ -1523,7 +1523,7 @@ not_ffs_volume: // Add padding at the very end if (!outerPadding.isEmpty()) { // Add info - UString info = usprintf("Full size: 0x%X (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); + UString info = usprintf("Full size: %Xh (%u)", (UINT32)outerPadding.size(), (UINT32)outerPadding.size()); // Check that remaining unparsed bytes are actually empty if (outerPadding.count(emptyByte) == outerPadding.size()) { diff --git a/common/peimage.cpp b/common/peimage.cpp index b136713..7feb30b 100644 --- a/common/peimage.cpp +++ b/common/peimage.cpp @@ -31,5 +31,5 @@ UString machineTypeToUString(UINT16 machineType) case EFI_IMAGE_FILE_MACHINE_RISCV64: return UString("RISC-V 64-bit"); case EFI_IMAGE_FILE_MACHINE_RISCV128: return UString("RISC-V 128-bit"); } - return usprintf("Unknown 0x%04X", machineType); + return usprintf("Unknown %04Xh", machineType); } diff --git a/common/types.cpp b/common/types.cpp index d64caaa..3ee9ed1 100755 --- a/common/types.cpp +++ b/common/types.cpp @@ -36,7 +36,7 @@ UString regionTypeToUString(const UINT8 type) case Subtypes::PttRegion: return UString("PTT"); }; - return usprintf("Unknown 0x%02X", type); + return usprintf("Unknown %02Xh", type); } UString itemTypeToUString(const UINT8 type) @@ -87,7 +87,7 @@ UString itemTypeToUString(const UINT8 type) case Types::StartupApDataEntry: return UString("Startup AP data"); } - return usprintf("Unknown 0x%02X", type); + return usprintf("Unknown %02Xh", type); } UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype) @@ -199,7 +199,7 @@ UString compressionTypeToUString(const UINT8 algorithm) case COMPRESSION_ALGORITHM_ZLIB: return UString("Zlib"); } - return usprintf("Unknown 0x%02X", algorithm); + return usprintf("Unknown %02Xh", algorithm); } UString actionTypeToUString(const UINT8 action) @@ -214,7 +214,7 @@ UString actionTypeToUString(const UINT8 action) case Actions::Rebase: return UString("Rebase"); } - return usprintf("Unknown 0x%02X", action); + return usprintf("Unknown %02Xh", action); } UString fitEntryTypeToUString(const UINT8 type) @@ -244,7 +244,7 @@ UString fitEntryTypeToUString(const UINT8 type) case INTEL_FIT_TYPE_EMPTY: return UString("Empty"); } - return usprintf("Unknown 0x%02X", (type & 0x7F)); + return usprintf("Unknown %02Xh", (type & 0x7F)); } UString hashTypeToUString(const UINT16 algorithm_id) @@ -258,7 +258,7 @@ UString hashTypeToUString(const UINT16 algorithm_id) case TCG_HASH_ALGORITHM_ID_SM3: return UString("SM3"); } - return usprintf("Unknown 0x%04X", algorithm_id); + return usprintf("Unknown %04Xh", algorithm_id); } UString insydeFlashDeviceMapEntryTypeGuidToUString(const EFI_GUID & guid)