Version 0.2.4

Better shitty LZMA section handling.
Thank you, Intel, for breaking your own specifications.
This commit is contained in:
Nikolaj Schlej 2013-10-09 10:30:58 +02:00
parent a86829a27e
commit 56a0ed00b0
4 changed files with 50 additions and 3 deletions

39
ffs.cpp
View File

@ -154,4 +154,43 @@ QString sectionTypeToQString(const UINT8 type)
default:
return QObject::tr("Unknown");
}
}
UINT32 sizeOfSectionHeaderOfType(const UINT8 type)
{
switch (type)
{
case EFI_SECTION_COMPRESSION:
return sizeof(EFI_COMMON_SECTION_HEADER);
case EFI_SECTION_GUID_DEFINED:
return sizeof(EFI_GUID_DEFINED_SECTION);
case EFI_SECTION_DISPOSABLE:
return sizeof(EFI_DISPOSABLE_SECTION);
case EFI_SECTION_PE32:
return sizeof(EFI_PE32_SECTION);
case EFI_SECTION_PIC:
return sizeof(EFI_PIC_SECTION);
case EFI_SECTION_TE:
return sizeof(EFI_TE_SECTION);
case EFI_SECTION_DXE_DEPEX:
return sizeof(EFI_DXE_DEPEX_SECTION);
case EFI_SECTION_VERSION:
return sizeof(EFI_VERSION_SECTION);
case EFI_SECTION_USER_INTERFACE:
return sizeof(EFI_USER_INTERFACE_SECTION);
case EFI_SECTION_COMPATIBILITY16:
return sizeof(EFI_COMPATIBILITY16_SECTION);
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
return sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION);
case EFI_SECTION_FREEFORM_SUBTYPE_GUID:
return sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION);
case EFI_SECTION_RAW:
return sizeof(EFI_RAW_SECTION);
case EFI_SECTION_PEI_DEPEX:
return sizeof(EFI_PEI_DEPEX_SECTION);
case EFI_SECTION_SMM_DEPEX:
return sizeof(EFI_SMM_DEPEX_SECTION);
default:
return sizeof(EFI_COMMON_SECTION_HEADER);
}
}

3
ffs.h
View File

@ -406,6 +406,9 @@ typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
//Section routines
extern UINT32 sizeOfSectionHeaderOfType(const UINT8 type);
// Restore previous packing rules
#pragma pack(pop)

View File

@ -744,6 +744,8 @@ UINT8 UEFITool::parseFile(const QByteArray & file, UINT8 revision, bool erasePol
UINT32 dataSize;
QModelIndex index;
UINT32 result;
UINT32 shittySectionSize;
EFI_COMMON_SECTION_HEADER* shittySectionHeader;
switch (sectionHeader->Type)
{
@ -804,8 +806,11 @@ UINT8 UEFITool::parseFile(const QByteArray & file, UINT8 revision, bool erasePol
|| decompressedSize != compressedSectionHeader->UncompressedLength)
{
// Shitty file with a section header between COMPRESSED_SECTION_HEADER and LZMA_HEADER
data = (VOID*) (file.constData() + sectionIndex + sizeof(EFI_COMPRESSION_SECTION) + sizeof(EFI_COMMON_SECTION_HEADER));
dataSize = uint24ToUint32(sectionHeader->Size) - sizeof(EFI_COMPRESSION_SECTION) - sizeof(EFI_COMMON_SECTION_HEADER);
// We must determine section header size by checking it's type before we can unpack that non-standard compressed section
shittySectionHeader = (EFI_COMMON_SECTION_HEADER*) data;
shittySectionSize = sizeOfSectionHeaderOfType(shittySectionHeader->Type);
data = (VOID*) (file.constData() + sectionIndex + sizeof(EFI_COMPRESSION_SECTION) + shittySectionSize);
dataSize = uint24ToUint32(sectionHeader->Size) - sizeof(EFI_COMPRESSION_SECTION) - shittySectionSize;
if (LzmaGetInfo(data, dataSize, &decompressedSize) != ERR_SUCCESS)
debug(tr("LzmaGetInfo failed"));
}

View File

@ -20,7 +20,7 @@
<bool>true</bool>
</property>
<property name="windowTitle">
<string>UEFITool 0.2.3</string>
<string>UEFITool 0.2.4</string>
</property>
<widget class="QWidget" name="centralWidget">
<property name="sizePolicy">