Big update 0.20.0

- major refactoring round done
- added replace actions for volumes
- added better Intel signature handling
- added support for unsigned Aptio capsules
- more GUIDs added to known-GUIDs database
- more information about PE and TE sections
- shown information about item full size
- hexadecimal numbers format changed from 0xAB to ABh
- AppleCRC renamed to ZVCRC because it seems not Apple-specific feature
after all
This commit is contained in:
Nikolaj Schlej 2015-01-31 15:00:00 +01:00
parent fb7e1c4c89
commit 831603dbc9
23 changed files with 1229 additions and 1157 deletions

View file

@ -1,6 +1,6 @@
/* EFI11/Tiano Compress Implementation
Copyright (c) 2014, Nikolaj Schlej
Copyright (c) 2015, Nikolaj Schlej
Copyright (c) 2006 - 2008, Intel Corporation
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -278,7 +278,7 @@ STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NU
//
// functions
//
UINT8
EFI_STATUS
EfiCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
@ -373,7 +373,7 @@ EFI_INVALID_PARAMETER - Parameter supplied is wrong.
}
UINT8
EFI_STATUS
TianoCompressLegacy (
CONST VOID *SrcBuffer,
UINT32 SrcSize,

View file

@ -1,6 +1,6 @@
/* EfiTianoDecompress.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.<BR>
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.<BR>
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -40,7 +40,7 @@ extern "C" {
EFI_STATUS
EFIAPI
EfiTianoGetInfo(
VOID *Source,
const VOID *Source,
UINT32 SrcSize,
UINT32 *DstSize,
UINT32 *ScratchSize
@ -70,7 +70,7 @@ extern "C" {
EFI_STATUS
EFIAPI
EfiDecompress(
VOID *Source,
const VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
@ -104,7 +104,7 @@ extern "C" {
EFI_STATUS
EFIAPI
TianoDecompress(
VOID *Source,
const VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,

View file

@ -18,43 +18,43 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
a.setOrganizationName("CodeRush");
a.setOrganizationDomain("coderush.me");
a.setApplicationName("UEFIExtract");
QCoreApplication a(argc, argv);
a.setOrganizationName("CodeRush");
a.setOrganizationDomain("coderush.me");
a.setApplicationName("UEFIExtract");
UEFIExtract w;
UINT8 result = ERR_SUCCESS;
UINT32 returned = 0;
UEFIExtract w;
UINT8 result = ERR_SUCCESS;
UINT32 returned = 0;
if (a.arguments().length() > 32) {
std::cout << "Too many arguments" << std::endl;
return 1;
}
if (a.arguments().length() > 32) {
std::cout << "Too many arguments" << std::endl;
return 1;
}
if (a.arguments().length() > 1 ) {
if (w.init(a.arguments().at(1)))
return 1;
if (a.arguments().length() > 1 ) {
if (w.init(a.arguments().at(1)))
return 1;
if (a.arguments().length() == 2) {
result = w.extract();
if (result)
return 2;
}
else {
for (int i = 2; i < a.arguments().length(); i++) {
result = w.extract(a.arguments().at(i));
if (result)
returned |= (1 << (i - 1));
}
return returned;
}
if (a.arguments().length() == 2) {
result = w.extract();
if (result)
return 2;
}
else {
std::cout << "UEFIExtract 0.3.5" << std::endl << std::endl <<
"Usage: uefiextract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl <<
"Returned value is a bit mask where 0 on position N meant File with GUID_N was found and unpacked, 1 otherwise" << std::endl;
return 1;
}
for (int i = 2; i < a.arguments().length(); i++) {
result = w.extract(a.arguments().at(i));
if (result)
returned |= (1 << (i - 1));
}
return returned;
}
}
else {
std::cout << "UEFIExtract 0.4.0" << std::endl << std::endl <<
"Usage: uefiextract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl <<
"Returned value is a bit mask where 0 on position N meant File with GUID_N was found and unpacked, 1 otherwise" << std::endl;
return 1;
}
}

View file

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
return ERR_SUCCESS;
}
else {
std::cout << "UEFIFind 0.1.1" << std::endl << std::endl <<
std::cout << "UEFIFind 0.2.0" << std::endl << std::endl <<
"Usage: uefifind {header | body | all} {list | count} pattern imagefile\n";
return ERR_INVALID_PARAMETER;
}

View file

@ -31,7 +31,7 @@ int main(int argc, char *argv[])
result = w.patchFromFile(a.arguments().at(1));
}
else {
std::cout << "UEFIPatch 0.2.5 - UEFI image file patching utility" << std::endl << std::endl <<
std::cout << "UEFIPatch 0.3.0 - UEFI image file patching utility" << std::endl << std::endl <<
"Usage: UEFIPatch image_file" << std::endl << std::endl <<
"Patches will be read from patches.txt file\n";
return ERR_SUCCESS;

View file

@ -1,6 +1,6 @@
/* basetypes.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -17,17 +17,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <stdarg.h>
#include <stdint.h>
typedef uint8_t BOOLEAN;
typedef int8_t INT8;
typedef uint8_t UINT8;
typedef int16_t INT16;
typedef uint16_t UINT16;
typedef int32_t INT32;
typedef uint32_t UINT32;
typedef int64_t INT64;
typedef uint64_t UINT64;
typedef char CHAR8;
typedef uint16_t CHAR16;
typedef uint8_t BOOLEAN;
typedef int8_t INT8;
typedef uint8_t UINT8;
typedef int16_t INT16;
typedef uint16_t UINT16;
typedef int32_t INT32;
typedef uint32_t UINT32;
typedef int64_t INT64;
typedef uint64_t UINT64;
typedef char CHAR8;
typedef uint16_t CHAR16;
typedef unsigned int UINTN;
#define CONST const
#define VOID void
@ -90,12 +91,12 @@ typedef uint16_t CHAR16;
#define IN
#define OUT
#define EFIAPI
#define EFI_STATUS UINT8
#define EFI_STATUS UINTN
#define EFI_SUCCESS ERR_SUCCESS
#define EFI_INVALID_PARAMETER ERR_INVALID_PARAMETER
#define EFI_OUT_OF_RESOURCES ERR_OUT_OF_RESOURCES
#define EFI_BUFFER_TOO_SMALL ERR_BUFFER_TOO_SMALL
#define EFI_ERROR(X) X
#define EFI_ERROR(X) (X)
// Compression algorithms
#define COMPRESSION_ALGORITHM_UNKNOWN 0
@ -124,8 +125,8 @@ typedef uint16_t CHAR16;
#define PATCH_MODE_BODY 1
// Patch types
#define PATCH_TYPE_OFFSET 'O'
#define PATCH_TYPE_PATTERN 'P'
#define PATCH_TYPE_OFFSET 'O'
#define PATCH_TYPE_PATTERN 'P'
// Erase polarity types
#define ERASE_POLARITY_FALSE 0
@ -133,12 +134,12 @@ typedef uint16_t CHAR16;
#define ERASE_POLARITY_UNKNOWN 0xFF
// Search modes
#define SEARCH_MODE_HEADER 1
#define SEARCH_MODE_BODY 2
#define SEARCH_MODE_ALL 3
#define SEARCH_MODE_HEADER 1
#define SEARCH_MODE_BODY 2
#define SEARCH_MODE_ALL 3
// EFI GUID
typedef struct {
typedef struct _EFI_GUID {
UINT8 Data[16];
} EFI_GUID;
@ -148,7 +149,9 @@ typedef struct {
#include <assert.h>
#define ASSERT(x) assert(x)
//Hexarg macro
#define hexarg(X, Y) arg(QString("%1").arg((X),(Y),16,QChar('0')).toUpper())
//Hexarg macros
#define hexarg(X) arg(QString("%1").arg((X),0,16).toUpper())
#define hexarg2(X, Y) arg(QString("%1").arg((X),(Y),16,QChar('0')).toUpper())
#endif

View file

@ -1,6 +1,6 @@
/* descriptor.cpp
Copyright (c) 2013, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -15,13 +15,13 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Calculate address of data structure addressed by descriptor address format
// 8 bit base or limit
UINT8* calculateAddress8(UINT8* baseAddress, const UINT8 baseOrLimit)
const UINT8* calculateAddress8(const UINT8* baseAddress, const UINT8 baseOrLimit)
{
return baseAddress + baseOrLimit * 0x10;
}
// 16 bit base or limit
UINT8* calculateAddress16(UINT8* baseAddress, const UINT16 baseOrLimit)
const UINT8* calculateAddress16(const UINT8* baseAddress, const UINT16 baseOrLimit)
{
return baseAddress + baseOrLimit * 0x1000;
}

View file

@ -1,6 +1,6 @@
/* descriptor.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -20,7 +20,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#pragma pack(push,1)
// Flash descriptor header
typedef struct {
typedef struct _FLASH_DESCRIPTOR_HEADER {
UINT8 FfVector[16]; // Must be 16 0xFFs
UINT32 Signature; // 0x0FF0A55A
} FLASH_DESCRIPTOR_HEADER;
@ -33,7 +33,7 @@ typedef struct {
// Descriptor map
// Base fields are storing bits [11:4] of actual base addresses, all other bits are 0
typedef struct {
typedef struct _FLASH_DESCRIPTOR_MAP {
UINT8 ComponentBase; // 0x03 on most machines
UINT8 NumberOfFlashChips; // Zero-based number of flash chips installed on board
UINT8 RegionBase; // 0x04 on most machines
@ -53,7 +53,7 @@ typedef struct {
// Component section
// Flash parameters DWORD structure
typedef struct {
typedef struct _FLASH_PARAMETERS {
UINT8 FirstChipDensity : 3;
UINT8 SecondChipDensity : 3;
UINT8 ReservedZero0 : 2; // Still unknown, zeros in all descriptors I have seen
@ -81,7 +81,7 @@ typedef struct {
#define FLASH_FREQUENCY_50MHZ 0x04
// Component section structure
typedef struct {
typedef struct _FLASH_DESCRIPTOR_COMPONENT_SECTION {
FLASH_PARAMETERS FlashParameters;
UINT8 InvalidInstruction0; // Instructions for SPI chip, that must not be executed, like FLASH ERASE
UINT8 InvalidInstruction1; //
@ -94,7 +94,7 @@ typedef struct {
// Region section
// All base and limit register are storing upper part of actual UINT32 base and limit
// If limit is zero - region is not present
typedef struct {
typedef struct _FLASH_DESCRIPTOR_REGION_SECTION {
UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen
UINT16 FlashBlockEraseSize; // Size of block erased by single BLOCK ERASE command
UINT16 BiosBase;
@ -113,7 +113,7 @@ typedef struct {
#define FLASH_BLOCK_ERASE_SIZE_64KB 0x000F
// Master section
typedef struct {
typedef struct _FLASH_DESCRIPTOR_MASTER_SECTION {
UINT16 BiosId;
UINT8 BiosRead;
UINT8 BiosWrite;
@ -138,14 +138,14 @@ typedef struct {
#define FLASH_DESCRIPTOR_UPPER_MAP_BASE 0x0EFC
// Descriptor upper map structure
typedef struct {
typedef struct _FLASH_DESCRIPTOR_UPPER_MAP {
UINT8 VsccTableBase; // Base address of VSCC Table for ME, bits [11:4]
UINT8 VsccTableSize; // Counted in UINT32s
UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen
} FLASH_DESCRIPTOR_UPPER_MAP;
// VSCC table entry structure
typedef struct {
typedef struct _VSCC_TABLE_ENTRY {
UINT8 VendorId; // JEDEC VendorID byte
UINT8 DeviceId0; // JEDEC DeviceID first byte
UINT8 DeviceId1; // JEDEC DeviceID second byte
@ -162,9 +162,9 @@ typedef struct {
// Calculate address of data structure addressed by descriptor address format
// 8 bit base or limit
extern UINT8* calculateAddress8(UINT8* baseAddress, const UINT8 baseOrLimit);
extern const UINT8* calculateAddress8(const UINT8* baseAddress, const UINT8 baseOrLimit);
// 16 bit base or limit
extern UINT8* calculateAddress16(UINT8* baseAddress, const UINT16 baseOrLimit);
extern const UINT8* calculateAddress16(const UINT8* baseAddress, const UINT16 baseOrLimit);
// Calculate offset of region using it's base
extern UINT32 calculateRegionOffset(const UINT16 base);

184
ffs.cpp
View file

@ -1,6 +1,6 @@
/* ffs.cpp
Copyright (c) 2013, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -16,7 +16,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
const UINT8 ffsAlignmentTable[] =
{ 0, 4, 7, 9, 10, 12, 15, 16 };
UINT8 calculateChecksum8(UINT8* buffer, UINT32 bufferSize)
UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize)
{
if (!buffer)
return 0;
@ -29,7 +29,7 @@ UINT8 calculateChecksum8(UINT8* buffer, UINT32 bufferSize)
return (UINT8)0x100 - counter;
}
UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize)
UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize)
{
if (!buffer)
return 0;
@ -53,7 +53,7 @@ VOID uint32ToUint24(UINT32 size, UINT8* ffsSize)
ffsSize[0] = (UINT8)((size));
}
UINT32 uint24ToUint32(UINT8* ffsSize)
UINT32 uint24ToUint32(const UINT8* ffsSize)
{
return (ffsSize[2] << 16) +
(ffsSize[1] << 8) +
@ -63,17 +63,17 @@ UINT32 uint24ToUint32(UINT8* ffsSize)
QString guidToQString(const EFI_GUID& guid)
{
QByteArray baGuid = QByteArray::fromRawData((const char*)guid.Data, sizeof(EFI_GUID));
UINT32 i32 = *(UINT32*)baGuid.left(4).constData();
UINT16 i16_0 = *(UINT16*)baGuid.mid(4, 2).constData();
UINT16 i16_1 = *(UINT16*)baGuid.mid(6, 2).constData();
UINT8 i8_0 = *(UINT8*)baGuid.mid(8, 1).constData();
UINT8 i8_1 = *(UINT8*)baGuid.mid(9, 1).constData();
UINT8 i8_2 = *(UINT8*)baGuid.mid(10, 1).constData();
UINT8 i8_3 = *(UINT8*)baGuid.mid(11, 1).constData();
UINT8 i8_4 = *(UINT8*)baGuid.mid(12, 1).constData();
UINT8 i8_5 = *(UINT8*)baGuid.mid(13, 1).constData();
UINT8 i8_6 = *(UINT8*)baGuid.mid(14, 1).constData();
UINT8 i8_7 = *(UINT8*)baGuid.mid(15, 1).constData();
const UINT32 i32 = *(const UINT32*)baGuid.left(4).constData();
const UINT16 i16_0 = *(const UINT16*)baGuid.mid(4, 2).constData();
const UINT16 i16_1 = *(const UINT16*)baGuid.mid(6, 2).constData();
const UINT8 i8_0 = *(const UINT8*)baGuid.mid(8, 1).constData();
const UINT8 i8_1 = *(const UINT8*)baGuid.mid(9, 1).constData();
const UINT8 i8_2 = *(const UINT8*)baGuid.mid(10, 1).constData();
const UINT8 i8_3 = *(const UINT8*)baGuid.mid(11, 1).constData();
const UINT8 i8_4 = *(const UINT8*)baGuid.mid(12, 1).constData();
const UINT8 i8_5 = *(const UINT8*)baGuid.mid(13, 1).constData();
const UINT8 i8_6 = *(const UINT8*)baGuid.mid(14, 1).constData();
const UINT8 i8_7 = *(const UINT8*)baGuid.mid(15, 1).constData();
return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11")
.arg(i32, 8, 16, QChar('0'))
@ -93,36 +93,21 @@ QString fileTypeToQString(const UINT8 type)
{
switch (type)
{
case EFI_FV_FILETYPE_RAW:
return QObject::tr("Raw");
case EFI_FV_FILETYPE_FREEFORM:
return QObject::tr("Freeform");
case EFI_FV_FILETYPE_SECURITY_CORE:
return QObject::tr("Security core");
case EFI_FV_FILETYPE_PEI_CORE:
return QObject::tr("PEI core");
case EFI_FV_FILETYPE_DXE_CORE:
return QObject::tr("DXE core");
case EFI_FV_FILETYPE_PEIM:
return QObject::tr("PEI module");
case EFI_FV_FILETYPE_DRIVER:
return QObject::tr("DXE driver");
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
return QObject::tr("Combined PEI/DXE");
case EFI_FV_FILETYPE_APPLICATION:
return QObject::tr("Application");
case EFI_FV_FILETYPE_SMM:
return QObject::tr("SMM module");
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
return QObject::tr("Volume image");
case EFI_FV_FILETYPE_COMBINED_SMM_DXE:
return QObject::tr("Combined SMM/DXE");
case EFI_FV_FILETYPE_SMM_CORE:
return QObject::tr("SMM core");
case EFI_FV_FILETYPE_PAD:
return QObject::tr("Pad");
default:
return QObject::tr("Unknown");
case EFI_FV_FILETYPE_RAW: return QObject::tr("Raw");
case EFI_FV_FILETYPE_FREEFORM: return QObject::tr("Freeform");
case EFI_FV_FILETYPE_SECURITY_CORE: return QObject::tr("SEC core");
case EFI_FV_FILETYPE_PEI_CORE: return QObject::tr("PEI core");
case EFI_FV_FILETYPE_DXE_CORE: return QObject::tr("DXE core");
case EFI_FV_FILETYPE_PEIM: return QObject::tr("PEI module");
case EFI_FV_FILETYPE_DRIVER: return QObject::tr("DXE driver");
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER: return QObject::tr("Combined PEI/DXE");
case EFI_FV_FILETYPE_APPLICATION: return QObject::tr("Application");
case EFI_FV_FILETYPE_SMM: return QObject::tr("SMM module");
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE: return QObject::tr("Volume image");
case EFI_FV_FILETYPE_COMBINED_SMM_DXE: return QObject::tr("Combined SMM/DXE");
case EFI_FV_FILETYPE_SMM_CORE: return QObject::tr("SMM core");
case EFI_FV_FILETYPE_PAD: return QObject::tr("Pad");
default: return QObject::tr("Unknown");
};
}
@ -130,88 +115,53 @@ QString sectionTypeToQString(const UINT8 type)
{
switch (type)
{
case EFI_SECTION_COMPRESSION:
return QObject::tr("Compressed");
case EFI_SECTION_GUID_DEFINED:
return QObject::tr("GUID defined");
case EFI_SECTION_DISPOSABLE:
return QObject::tr("Disposable");
case EFI_SECTION_PE32:
return QObject::tr("PE32+ image");
case EFI_SECTION_PIC:
return QObject::tr("PIC image");
case EFI_SECTION_TE:
return QObject::tr("TE image");
case EFI_SECTION_DXE_DEPEX:
return QObject::tr("DXE dependency");
case EFI_SECTION_VERSION:
return QObject::tr("Version");
case EFI_SECTION_USER_INTERFACE:
return QObject::tr("User interface");
case EFI_SECTION_COMPATIBILITY16:
return QObject::tr("16-bit image");
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
return QObject::tr("Volume image");
case EFI_SECTION_FREEFORM_SUBTYPE_GUID:
return QObject::tr("Freeform subtype GUID");
case EFI_SECTION_RAW:
return QObject::tr("Raw");
case EFI_SECTION_PEI_DEPEX:
return QObject::tr("PEI dependency");
case EFI_SECTION_SMM_DEPEX:
return QObject::tr("SMM dependency");
case HP_SECTION_POSTCODE:
return QObject::tr("HP postcode");
case SCT_SECTION_POSTCODE:
return QObject::tr("SCT postcode");
default:
return QObject::tr("Unknown");
case EFI_SECTION_COMPRESSION: return QObject::tr("Compressed");
case EFI_SECTION_GUID_DEFINED: return QObject::tr("GUID defined");
case EFI_SECTION_DISPOSABLE: return QObject::tr("Disposable");
case EFI_SECTION_PE32: return QObject::tr("PE32(+) image");
case EFI_SECTION_PIC: return QObject::tr("PIC image");
case EFI_SECTION_TE: return QObject::tr("TE image");
case EFI_SECTION_DXE_DEPEX: return QObject::tr("DXE dependency");
case EFI_SECTION_VERSION: return QObject::tr("Version");
case EFI_SECTION_USER_INTERFACE: return QObject::tr("User interface");
case EFI_SECTION_COMPATIBILITY16: return QObject::tr("16-bit image");
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: return QObject::tr("Volume image");
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: return QObject::tr("Freeform subtype GUID");
case EFI_SECTION_RAW: return QObject::tr("Raw");
case EFI_SECTION_PEI_DEPEX: return QObject::tr("PEI dependency");
case EFI_SECTION_SMM_DEPEX: return QObject::tr("SMM dependency");
case HP_SECTION_POSTCODE: return QObject::tr("HP postcode");
case SCT_SECTION_POSTCODE: return QObject::tr("SCT postcode");
default: return QObject::tr("Unknown");
}
}
UINT32 sizeOfSectionHeader(EFI_COMMON_SECTION_HEADER* header)
UINT32 sizeOfSectionHeader(const EFI_COMMON_SECTION_HEADER* header)
{
if (!header)
return 0;
switch (header->Type)
{
case EFI_SECTION_COMPRESSION:
return sizeof(EFI_COMPRESSION_SECTION);
case EFI_SECTION_GUID_DEFINED: {
EFI_GUID_DEFINED_SECTION* gdsHeader = (EFI_GUID_DEFINED_SECTION*)header;
const EFI_GUID_DEFINED_SECTION* gdsHeader = (const EFI_GUID_DEFINED_SECTION*)header;
return gdsHeader->DataOffset; }
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);
case HP_SECTION_POSTCODE:
return sizeof(POSTCODE_SECTION);
case SCT_SECTION_POSTCODE:
return sizeof(POSTCODE_SECTION);
default:
return sizeof(EFI_COMMON_SECTION_HEADER);
case EFI_SECTION_COMPRESSION: return sizeof(EFI_COMPRESSION_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);
case HP_SECTION_POSTCODE: return sizeof(POSTCODE_SECTION);
case SCT_SECTION_POSTCODE: return sizeof(POSTCODE_SECTION);
default: return sizeof(EFI_COMMON_SECTION_HEADER);
}
}

118
ffs.h
View file

@ -1,6 +1,6 @@
/* ffs.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -15,6 +15,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <QByteArray>
#include <QString>
#include <QVector>
#include "basetypes.h"
// C++ functions
@ -25,9 +26,6 @@ extern QString fileTypeToQString(const UINT8 type);
// Section type to QString routine
extern QString sectionTypeToQString(const UINT8 type);
#ifdef __cplusplus
extern "C" {
#endif
// Make sure we use right packing rules
#pragma pack(push,1)
@ -35,7 +33,7 @@ extern "C" {
// EFI Capsule
//*****************************************************************************
// Capsule header
typedef struct {
typedef struct _EFI_CAPSULE_HEADER {
EFI_GUID CapsuleGuid;
UINT32 HeaderSize;
UINT32 Flags;
@ -52,7 +50,7 @@ const QByteArray EFI_CAPSULE_GUID
("\xBD\x86\x66\x3B\x76\x0D\x30\x40\xB7\x0E\xB5\x51\x9E\x2F\xC5\xA0", 16);
// AMI Aptio extended capsule header
typedef struct {
typedef struct _APTIO_CAPSULE_HEADER {
EFI_CAPSULE_HEADER CapsuleHeader;
UINT16 RomImageOffset; // offset in bytes from the beginning of the capsule header to the start of
// the capsule volume
@ -63,22 +61,28 @@ typedef struct {
//ROM_AREA RomAreaMap[1];
} APTIO_CAPSULE_HEADER;
// AMI Aptio extended capsule GUID
const QByteArray APTIO_CAPSULE_GUID
// AMI Aptio signed extended capsule GUID
const QByteArray APTIO_SIGNED_CAPSULE_GUID
("\x8B\xA6\x3C\x4A\x23\x77\xFB\x48\x80\x3D\x57\x8C\xC1\xFE\xC4\x4D", 16);
// AMI Aptio unsigned extended capsule GUID
const QByteArray APTIO_UNSIGNED_CAPSULE_GUID
("\x90\xBB\xEE\x14\x0A\x89\xDB\x43\xAE\xD1\x5D\x3C\x45\x88\xA4\x18", 16);
//14EEBB90-890A-43DB-AED1-5D3C4588A418
//*****************************************************************************
// EFI Firmware Volume
//*****************************************************************************
// Firmware block map entry
// FvBlockMap ends with an entry {0x00000000, 0x00000000}
typedef struct {
typedef struct _EFI_FV_BLOCK_MAP_ENTRY {
UINT32 NumBlocks;
UINT32 Length;
} EFI_FV_BLOCK_MAP_ENTRY;
// Volume header
typedef struct {
typedef struct _EFI_FIRMWARE_VOLUME_HEADER {
UINT8 ZeroVector[16];
EFI_GUID FileSystemGuid;
UINT64 FvLength;
@ -92,15 +96,38 @@ typedef struct {
//EFI_FV_BLOCK_MAP_ENTRY FvBlockMap[1];
} EFI_FIRMWARE_VOLUME_HEADER;
// File system GUIDs
// Standard file system GUIDs
const QByteArray EFI_FIRMWARE_FILE_SYSTEM_GUID
("\xD9\x54\x93\x7A\x68\x04\x4A\x44\x81\xCE\x0B\xF6\x17\xD8\x90\xDF", 16);
const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);
// Vendor-specific file system GUIDs
const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID
("\xAD\xEE\xAD\x04\xFF\x61\x31\x4D\xB6\xBA\x64\xF8\xBF\x90\x1F\x5A", 16);
const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID
("\x8C\x1B\x00\xBD\x71\x6A\x7B\x48\xA1\x4F\x0C\x2A\x2D\xCF\x7A\x5D", 16);
const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);
const QByteArray EFI_INTEL_FILE_SYSTEM_GUID
("\xFF\xFF\x3F\xAD\x8B\xD2\xC4\x44\x9F\x13\x9E\xA9\x8A\x97\xF9\xF0", 16);
//AD3FFFFF-D28B-44C4-9F13-9EA98A97F9F0 //Intel 1
const QByteArray EFI_INTEL_FILE_SYSTEM2_GUID
("\x70\xCD\xA1\xD6\x33\x4B\x94\x49\xA6\xEA\x37\x5F\x2C\xCC\x54\x37", 16);
//D6A1CD70-4B33-4994-A6EA-375F2CCC5437 //Intel 2
const QByteArray EFI_SONY_FILE_SYSTEM_GUID
("\x56\x41\x49\x4F\xD6\xAE\x64\x4D\xA5\x37\xB8\xA5\x55\x7B\xCE\xEC", 16);
//4F494156-AED6-4D64-A537-B8A5557BCEEC //Sony 1
//Vector of volume GUIDs with FFSv2-compatible files
const QVector<QByteArray> FFSv2Volumes
({
EFI_FIRMWARE_FILE_SYSTEM_GUID,
EFI_FIRMWARE_FILE_SYSTEM2_GUID,
EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID,
EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID,
EFI_INTEL_FILE_SYSTEM_GUID,
EFI_INTEL_FILE_SYSTEM2_GUID,
EFI_SONY_FILE_SYSTEM_GUID
});
// Firmware volume signature
const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
@ -188,7 +215,7 @@ const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
#define EFI_FVB2_WEAK_ALIGNMENT 0x80000000
// Extended firmware volume header
typedef struct {
typedef struct _EFI_FIRMWARE_VOLUME_EXT_HEADER {
EFI_GUID FvName;
UINT32 ExtHeaderSize;
} EFI_FIRMWARE_VOLUME_EXT_HEADER;
@ -197,31 +224,31 @@ typedef struct {
// The extended header entries follow each other and are
// terminated by ExtHeaderType EFI_FV_EXT_TYPE_END
#define EFI_FV_EXT_TYPE_END 0x00
typedef struct {
typedef struct _EFI_FIRMWARE_VOLUME_EXT_ENTRY {
UINT16 ExtEntrySize;
UINT16 ExtEntryType;
} EFI_FIRMWARE_VOLUME_EXT_ENTRY;
// GUID that maps OEM file types to GUIDs
#define EFI_FV_EXT_TYPE_OEM_TYPE 0x01
typedef struct {
typedef struct _EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE {
EFI_FIRMWARE_VOLUME_EXT_ENTRY Header;
UINT32 TypeMask;
//EFI_GUID Types[1];
} EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE;
#define EFI_FV_EXT_TYPE_GUID_TYPE 0x02
typedef struct {
typedef struct _EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE {
EFI_FIRMWARE_VOLUME_EXT_ENTRY Header;
EFI_GUID FormatType;
//UINT8 Data[];
} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
// NVRAM volume signature
const QByteArray EFI_FIRMWARE_VOLUME_NVRAM_SIGNATURE("$VSS", 4);
//!TODO: add proper NVRAM parsing
//const QByteArray EFI_FIRMWARE_VOLUME_NVRAM_SIGNATURE("$VSS", 4);
// Volume header 16bit checksum calculation routine
extern UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize);
extern UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize);
//*****************************************************************************
// EFI FFS File
@ -236,7 +263,7 @@ typedef union {
UINT16 Checksum16; // Revision 2
} EFI_FFS_INTEGRITY_CHECK;
// File header
typedef struct {
typedef struct _EFI_FFS_FILE_HEADER {
EFI_GUID Name;
EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
UINT8 Type;
@ -246,15 +273,15 @@ typedef struct {
} EFI_FFS_FILE_HEADER;
// Large file header
//typedef struct {
// EFI_GUID Name;
// EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
// UINT8 Type;
// UINT8 Attributes;
// UINT8 Size[3];
// UINT8 State;
// UINT32 ExtendedSize;
//} EFI_FFS_FILE_HEADER2;
typedef struct _EFI_FFS_FILE_HEADER2 {
EFI_GUID Name;
EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
UINT8 Type;
UINT8 Attributes;
UINT8 Size[3];
UINT8 State;
UINT32 ExtendedSize;
} EFI_FFS_FILE_HEADER2;
// Standard data checksum, used if FFS_ATTRIB_CHECKSUM is clear
#define FFS_FIXED_CHECKSUM 0x5A
@ -319,25 +346,25 @@ const QByteArray EFI_FFS_PAD_FILE_GUID
// FFS size conversion routines
extern VOID uint32ToUint24(UINT32 size, UINT8* ffsSize);
extern UINT32 uint24ToUint32(UINT8* ffsSize);
extern UINT32 uint24ToUint32(const UINT8* ffsSize);
// FFS file 8bit checksum calculation routine
extern UINT8 calculateChecksum8(UINT8* buffer, UINT32 bufferSize);
extern UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize);
//*****************************************************************************
// EFI FFS File Section
//*****************************************************************************
// Common section header
typedef struct {
typedef struct _EFI_COMMON_SECTION_HEADER {
UINT8 Size[3];
UINT8 Type;
} EFI_COMMON_SECTION_HEADER;
// Large file common section header
//typedef struct {
// UINT8 Size[3]; //Must be 0xFFFFFF for this header to be used
// UINT8 Type;
// UINT32 ExtendedSize;
//} EFI_COMMON_SECTION_HEADER2;
typedef struct _EFI_COMMON_SECTION_HEADER2 {
UINT8 Size[3]; //Must be 0xFFFFFF for this header to be used
UINT8 Type;
UINT32 ExtendedSize;
} EFI_COMMON_SECTION_HEADER2;
// File section types
#define EFI_SECTION_ALL 0x00 // Impossible attribute for file in the FS
@ -364,7 +391,7 @@ typedef struct {
#define HP_SECTION_POSTCODE 0x20 // Specific to HP images
// Compression section
typedef struct {
typedef struct _EFI_COMPRESSION_SECTION {
UINT8 Size[3];
UINT8 Type;
UINT32 UncompressedLength;
@ -377,7 +404,7 @@ typedef struct {
#define EFI_CUSTOMIZED_COMPRESSION 0x02
//GUID defined section
typedef struct {
typedef struct _EFI_GUID_DEFINED_SECTION {
UINT8 Size[3];
UINT8 Type;
EFI_GUID SectionDefinitionGuid;
@ -403,21 +430,21 @@ const QByteArray EFI_GUIDED_SECTION_INTEL_SIGNED //0F9D89E8-9259-4F76-A5AF-0C89E
("\xE8\x89\x9D\x0F\x59\x92\x76\x4F\xA5\xAF\x0C\x89\xE3\x40\x23\xDF", 16);
// Version section
typedef struct {
typedef struct _EFI_VERSION_SECTION {
UINT8 Size[3];
UINT8 Type;
UINT16 BuildNumber;
} EFI_VERSION_SECTION;
// Freeform subtype GUID section
typedef struct {
typedef struct _EFI_FREEFORM_SUBTYPE_GUID_SECTION {
UINT8 Size[3];
UINT8 Type;
EFI_GUID SubTypeGuid;
} EFI_FREEFORM_SUBTYPE_GUID_SECTION;
// Phoenix SCT and HP postcode section
typedef struct {
typedef struct _POSTCODE_SECTION {
UINT8 Size[3];
UINT8 Type;
UINT32 Postcode;
@ -437,7 +464,7 @@ typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
typedef EFI_COMMON_SECTION_HEADER EFI_USER_INTERFACE_SECTION;
//Section routines
extern UINT32 sizeOfSectionHeader(EFI_COMMON_SECTION_HEADER* header);
extern UINT32 sizeOfSectionHeader(const EFI_COMMON_SECTION_HEADER* header);
//*****************************************************************************
// EFI Dependency Expression
@ -475,7 +502,4 @@ extern UINT32 sizeOfSectionHeader(EFI_COMMON_SECTION_HEADER* header);
// Restore previous packing rules
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/* ffsengine.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -110,7 +110,7 @@ private:
UINT32 newPeiCoreEntryPoint;
// Parsing helpers
UINT8 getPaddingType(const QByteArray & padding);
UINT32 getPaddingType(const QByteArray & padding);
void parseAprioriRawSection(const QByteArray & body, QString & parsed);
UINT8 parseDepexSection(const QByteArray & body, QString & parsed);
UINT8 findNextVolume(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & nextVolumeOffset);

8
gbe.h
View file

@ -1,6 +1,6 @@
/* gbe.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -18,14 +18,14 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Make sure we use right packing rules
#pragma pack(push,1)
typedef struct {
typedef struct _GBE_MAC_ADDRESS {
UINT8 vendor[3];
UINT8 device[3];
} GBE_MAC;
} GBE_MAC_ADDRESS;
#define GBE_VERSION_OFFSET 10
typedef struct {
typedef struct _GBE_VERSION {
UINT8 id : 4;
UINT8 minor : 4;
UINT8 major;

4
me.h
View file

@ -1,6 +1,6 @@
/* me.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -21,7 +21,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
const QByteArray ME_VERSION_SIGNATURE("\x24\x4D\x41\x4E", 4); //$MAN
const QByteArray ME_VERSION_SIGNATURE2("\x24\x4D\x4E\x32", 4); //$MN2
typedef struct {
typedef struct _ME_VERSION {
UINT32 signature;
UINT32 reserved; // Unknown for me
UINT16 major;

View file

@ -1,6 +1,6 @@
/* peimage.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
This program and the accompanying materials
@ -224,6 +224,12 @@ typedef struct {
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
} EFI_IMAGE_OPTIONAL_HEADER64;
// Union for pointers to either PE32 or PE32+ headers
typedef union _EFI_IMAGE_OPTIONAL_HEADER_POINTERS_UNION {
const EFI_IMAGE_OPTIONAL_HEADER32* H32;
const EFI_IMAGE_OPTIONAL_HEADER64* H64;
} EFI_IMAGE_OPTIONAL_HEADER_POINTERS_UNION;
typedef struct
{
UINT32 Signature;

View file

@ -1,6 +1,6 @@
/* treeitem.cpp
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -15,25 +15,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "treeitem.h"
#include "types.h"
TreeItem::TreeItem(const UINT8 type, const UINT8 subtype, const UINT8 compression,
TreeItem::TreeItem(const UINT8 type, const UINT32 attributes, const UINT8 compression,
const QString & name, const QString & text, const QString & info,
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
TreeItem *parent)
const QByteArray & header, const QByteArray & body,
TreeItem *parent) :
itemAction(Actions::NoAction),
itemType(type),
itemAttributes(attributes),
itemCompression(compression),
itemName(name),
itemText(text),
itemInfo(info),
itemHeader(header),
itemBody(body),
parentItem(parent)
{
itemAction = Actions::NoAction;
itemType = type;
itemSubtype = subtype;
itemCompression = compression;
itemName = name;
itemText = text;
itemInfo = info;
itemHeader = header;
itemBody = body;
itemTail = tail;
parentItem = parent;
// Set default names
setDefaultNames();
}
TreeItem::~TreeItem()
@ -41,11 +37,11 @@ TreeItem::~TreeItem()
qDeleteAll(childItems);
}
void TreeItem::setDefaultNames()
/*void TreeItem::setDefaultNames()
{
itemTypeName = itemTypeToQString(itemType);
itemSubtypeName = itemSubtypeToQString(itemType, itemSubtype);
}
}*/
void TreeItem::appendChild(TreeItem *item)
{
@ -94,15 +90,15 @@ QVariant TreeItem::data(int column) const
{
switch (column)
{
case 0: //Name
case 0: // Name
return itemName;
case 1: //Action
case 1: // Action
return actionTypeToQString(itemAction);
case 2: //Type
return itemTypeName;
case 3: //Subtype
return itemSubtypeName;
case 4: //Text
case 2: // Type
return itemTypeToQString(itemType);
case 3: // Attributes
return itemAttributesToQString(itemType, itemAttributes);
case 4: // Text
return itemText;
default:
return QVariant();
@ -114,9 +110,19 @@ TreeItem *TreeItem::parent()
return parentItem;
}
void TreeItem::setName(const QString &text)
QString TreeItem::name() const
{
itemName = text;
return itemName;
}
void TreeItem::setName(const QString &name)
{
itemName = name;
}
QString TreeItem::text() const
{
return itemText;
}
void TreeItem::setText(const QString &text)
@ -124,21 +130,21 @@ void TreeItem::setText(const QString &text)
itemText = text;
}
void TreeItem::setTypeName(const QString &text)
{
itemTypeName = text;
}
void TreeItem::setSubtypeName(const QString &text)
{
itemSubtypeName = text;
}
QString TreeItem::info() const
{
return itemInfo;
}
void TreeItem::addInfo(const QString &info)
{
itemInfo += info;
}
void TreeItem::setInfo(const QString &info)
{
itemInfo = info;
}
int TreeItem::row() const
{
if (parentItem)
@ -152,11 +158,22 @@ UINT8 TreeItem::type() const
return itemType;
}
UINT8 TreeItem::subtype() const
void TreeItem::setType(const UINT8 type)
{
return itemSubtype;
itemType = type;
}
UINT32 TreeItem::attributes() const
{
return itemAttributes;
}
void TreeItem::setAttributes(const UINT32 attributes)
{
itemAttributes = attributes;
}
UINT8 TreeItem::compression() const
{
return itemCompression;
@ -172,11 +189,6 @@ QByteArray TreeItem::body() const
return itemBody;
}
QByteArray TreeItem::tail() const
{
return itemTail;
}
bool TreeItem::hasEmptyHeader() const
{
return itemHeader.isEmpty();
@ -187,11 +199,6 @@ bool TreeItem::hasEmptyBody() const
return itemBody.isEmpty();
}
bool TreeItem::hasEmptyTail() const
{
return itemTail.isEmpty();
}
UINT8 TreeItem::action() const
{
return itemAction;
@ -212,8 +219,3 @@ void TreeItem::setAction(const UINT8 action)
parentItem->setAction(Actions::Rebuild);
}
void TreeItem::setSubtype(const UINT8 subtype)
{
itemSubtype = subtype;
itemSubtypeName = itemSubtypeToQString(itemType, itemSubtype);
}

View file

@ -1,6 +1,6 @@
/* treeitem.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -24,9 +24,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
class TreeItem
{
public:
TreeItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
TreeItem(const UINT8 type, const UINT32 attributes = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString &name = QString(), const QString &text = QString(), const QString &info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(),
TreeItem *parent = 0);
~TreeItem();
@ -45,42 +45,42 @@ public:
TreeItem *parent();
// Reading operations for item parameters
UINT8 type() const;
UINT8 subtype() const;
QByteArray header() const;
bool hasEmptyHeader() const;
QByteArray body() const;
bool hasEmptyBody() const;
QByteArray tail() const;
bool hasEmptyTail() const;
QString info() const;
UINT8 action() const;
UINT8 compression() const;
// Some values can be changed after item construction
void setAction(const UINT8 action);
void setSubtype(const UINT8 subtype);
void setTypeName(const QString &text);
void setSubtypeName(const QString &text);
QString name() const;
void setName(const QString &text);
UINT8 type() const;
void setType(const UINT8 type);
UINT32 attributes() const;
void setAttributes(const UINT32 attributes);
QString text() const;
void setText(const QString &text);
private:
// Set default names after construction
// They can later be changed by set* methods
void setDefaultNames();
QByteArray header() const;
bool hasEmptyHeader() const;
QByteArray body() const;
bool hasEmptyBody() const;
QString info() const;
void addInfo(const QString &info);
void setInfo(const QString &info);
UINT8 action() const;
void setAction(const UINT8 action);
UINT8 compression() const;
private:
QList<TreeItem*> childItems;
UINT8 itemAction;
UINT8 itemType;
UINT8 itemSubtype;
UINT8 itemCompression;
UINT8 itemAction;
UINT8 itemType;
UINT32 itemAttributes;
UINT8 itemCompression;
QByteArray itemHeader;
QByteArray itemBody;
QByteArray itemTail;
QString itemName;
QString itemTypeName;
QString itemSubtypeName;
QString itemText;
QString itemInfo;
TreeItem *parentItem;

View file

@ -1,6 +1,6 @@
/* treemodel.cpp
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -138,12 +138,12 @@ UINT8 TreeModel::type(const QModelIndex &index) const
return item->type();
}
UINT8 TreeModel::subtype(const QModelIndex &index) const
UINT32 TreeModel::attributes(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->subtype();
return item->attributes();
}
QByteArray TreeModel::header(const QModelIndex &index) const
@ -178,20 +178,20 @@ bool TreeModel::hasEmptyBody(const QModelIndex &index) const
return item->hasEmptyBody();
}
QByteArray TreeModel::tail(const QModelIndex &index) const
QString TreeModel::name(const QModelIndex &index) const
{
if (!index.isValid())
return QByteArray();
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->tail();
return item->name();
}
bool TreeModel::hasEmptyTail(const QModelIndex &index) const
QString TreeModel::text(const QModelIndex &index) const
{
if (!index.isValid())
return true;
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyTail();
return item->text();
}
QString TreeModel::info(const QModelIndex &index) const
@ -218,17 +218,17 @@ UINT8 TreeModel::compression(const QModelIndex &index) const
return item->compression();
}
void TreeModel::setSubtype(const QModelIndex & index, UINT8 subtype)
void TreeModel::setAttributes(const QModelIndex & index, const UINT32 attributes)
{
if (!index.isValid())
return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
item->setSubtype(subtype);
item->setAttributes(attributes);
emit dataChanged(index, index);
}
void TreeModel::setNameString(const QModelIndex &index, const QString &data)
void TreeModel::setName(const QModelIndex &index, const QString &data)
{
if (!index.isValid())
return;
@ -238,27 +238,17 @@ void TreeModel::setNameString(const QModelIndex &index, const QString &data)
emit dataChanged(index, index);
}
void TreeModel::setTypeString(const QModelIndex &index, const QString &data)
void TreeModel::setType(const QModelIndex &index, const UINT8 data)
{
if (!index.isValid())
return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
item->setTypeName(data);
item->setType(data);
emit dataChanged(index, index);
}
void TreeModel::setSubtypeString(const QModelIndex &index, const QString &data)
{
if (!index.isValid())
return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
item->setSubtypeName(data);
emit dataChanged(index, index);
}
void TreeModel::setTextString(const QModelIndex &index, const QString &data)
void TreeModel::setText(const QModelIndex &index, const QString &data)
{
if (!index.isValid())
return;
@ -268,50 +258,14 @@ void TreeModel::setTextString(const QModelIndex &index, const QString &data)
emit dataChanged(index, index);
}
QString TreeModel::nameString(const QModelIndex &index) const
/*QString TreeModel::name(const QModelIndex &index) const
{
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(0).toString();
}
QString TreeModel::actionString(const QModelIndex &index) const
{
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(1).toString();
}
QString TreeModel::typeString(const QModelIndex &index) const
{
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(2).toString();
}
QString TreeModel::subtypeString(const QModelIndex &index) const
{
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(3).toString();
}
QString TreeModel::textString(const QModelIndex &index) const
{
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(4).toString();
}
return item->name();
}*/
void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
{
@ -323,9 +277,9 @@ void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
emit dataChanged(this->index(0, 0), index);
}
QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype, const UINT8 compression,
QModelIndex TreeModel::addItem(const UINT8 type, const UINT32 attributes, const UINT8 compression,
const QString & name, const QString & text, const QString & info,
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
const QByteArray & header, const QByteArray & body,
const QModelIndex & parent, const UINT8 mode)
{
TreeItem *item = 0;
@ -347,7 +301,7 @@ QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype, const UINT
}
}
TreeItem *newItem = new TreeItem(type, subtype, compression, name, text, info, header, body, tail, parentItem);
TreeItem *newItem = new TreeItem(type, attributes, compression, name, text, info, header, body, parentItem);
if (mode == CREATE_MODE_APPEND) {
emit layoutAboutToBeChanged();
parentItem->appendChild(newItem);

View file

@ -1,6 +1,6 @@
/* treemodel.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -42,35 +42,27 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QString nameString(const QModelIndex &index) const;
QString actionString(const QModelIndex &index) const;
QString typeString(const QModelIndex &index) const;
QString subtypeString(const QModelIndex &index) const;
QString textString(const QModelIndex &index) const;
void setAction(const QModelIndex &index, const UINT8 action);
void setTypeString(const QModelIndex &index, const QString &text);
void setSubtypeString(const QModelIndex &index, const QString &text);
void setNameString(const QModelIndex &index, const QString &text);
void setTextString(const QModelIndex &index, const QString &text);
void setSubtype(const QModelIndex & index, UINT8 subtype);
void setType(const QModelIndex &index, const UINT8 type);
void setAttributes(const QModelIndex &index, const UINT32 attributes);
void setName(const QModelIndex &index, const QString &name);
void setText(const QModelIndex &index, const QString &text);
QString name(const QModelIndex &index) const;
QString text(const QModelIndex &index) const;
QString info(const QModelIndex &index) const;
UINT8 type(const QModelIndex &index) const;
UINT8 subtype(const QModelIndex &index) const;
UINT32 attributes(const QModelIndex &index) const;
QByteArray header(const QModelIndex &index) const;
bool hasEmptyHeader(const QModelIndex &index) const;
QByteArray body(const QModelIndex &index) const;
bool hasEmptyBody(const QModelIndex &index) const;
QByteArray tail(const QModelIndex &index) const;
bool hasEmptyTail(const QModelIndex &index) const;
QString info(const QModelIndex &index) const;
UINT8 action(const QModelIndex &index) const;
UINT8 compression(const QModelIndex &index) const;
QModelIndex addItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
QModelIndex addItem(const UINT8 type, const UINT32 attributes = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString & name = QString(), const QString & text = QString(), const QString & info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(),
const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const;

104
types.cpp
View file

@ -1,6 +1,6 @@
/* types.cpp
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -19,15 +19,15 @@ QString regionTypeToQString(const UINT8 type)
{
switch (type)
{
case Subtypes::DescriptorRegion:
case ATTR_REGION_TYPE_DESCRIPTOR:
return QObject::tr("Descriptor");
case Subtypes::GbeRegion:
case ATTR_REGION_TYPE_GBE:
return QObject::tr("GbE");
case Subtypes::MeRegion:
return QObject::tr("ME");
case Subtypes::BiosRegion:
case ATTR_REGION_TYPE_ME:
return QObject::tr("ME/TXE");
case ATTR_REGION_TYPE_BIOS:
return QObject::tr("BIOS");
case Subtypes::PdrRegion:
case ATTR_REGION_TYPE_PDR:
return QObject::tr("PDR");
default:
return QObject::tr("Unknown");
@ -58,60 +58,76 @@ QString itemTypeToQString(const UINT8 type)
}
}
QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype)
QString itemAttributesToQString(const UINT8 type, const UINT8 attributes)
{
switch (type) {
case Types::Root:
case Types::Image:
if (subtype == Subtypes::IntelImage)
if (attributes == ATTR_IMAGE_TYPE_DESCRIPTOR)
return QObject::tr("Intel");
else if (subtype == Subtypes::BiosImage)
return QObject::tr("BIOS");
else if (attributes == ATTR_IMAGE_TYPE_UEFI)
return QObject::tr("UEFI");
else
return QObject::tr("Unknown");
case Types::Padding:
if (subtype == Subtypes::ZeroPadding)
return QObject::tr("Empty(0x00)");
else if (subtype == Subtypes::OnePadding)
return QObject::tr("Empty(0xFF)");
else if (subtype == Subtypes::DataPadding)
return QObject::tr("Nonempty");
else
return "";
case Types::Volume:
if (subtype == Subtypes::BootVolume)
return QObject::tr("Boot");
else if (subtype == Subtypes::UnknownVolume)
return QObject::tr("Unknown");
else if (subtype == Subtypes::NvramVolume)
return QObject::tr("NVRAM");
else if (subtype == Subtypes::AppleCrcVolume)
return QObject::tr("AppleCRC");
else if (subtype == Subtypes::UnknownAppleCrcVolume)
return QObject::tr("AppleCRC Unknown");
else if (subtype == Subtypes::BootAppleCrcVolume)
return QObject::tr("AppleCRC Boot");
else
return "";
case Types::Capsule:
if (subtype == Subtypes::AptioCapsule)
return QObject::tr("AMI Aptio");
else if (subtype == Subtypes::UefiCapsule)
return QObject::tr("UEFI 2.0");
if (attributes == ATTR_PADDING_ZERO_EMPTY)
return QObject::tr("Empty (0x00)");
else if (attributes == ATTR_PADDING_ONE_EMPTY)
return QObject::tr("Empty (0xFF)");
else if (attributes == ATTR_PADDING_DATA)
return QObject::tr("Non-empty");
else
return QObject::tr("Unknown");
case Types::Volume: {
QString string;
VOLUME_ATTRIBUTES* volumeAttr = (VOLUME_ATTRIBUTES*)&attributes;
if (volumeAttr->ZeroVectorCrc)
string += QObject::tr("ZVCRC ");
if (volumeAttr->VtfPresent)
string += QObject::tr("Boot ");
if (volumeAttr->Unknown) {
string += QObject::tr("Unknown");
return string;
}
if (volumeAttr->FsVersion == 2 || volumeAttr->FsVersion == 3)
string += QObject::tr("FFSv%1").arg(volumeAttr->FsVersion);
else
return QObject::tr("Unknown FFS version");
return string;
}
case Types::Capsule: {
QString string;
CAPSULE_ATTRIBUTES* capsuleAttr = (CAPSULE_ATTRIBUTES*)&attributes;
if (capsuleAttr->Type == ATTR_CAPSULE_TYPE_APTIO)
string += QObject::tr("Aptio ");
else if (capsuleAttr->Type == ATTR_CAPSULE_TYPE_UEFI20)
string += QObject::tr("UEFI 2.0 ");
else
return QObject::tr("Unknown type");
if (capsuleAttr->Signed)
string += QObject::tr("signed");
else
string += QObject::tr("unsigned");
return string;
}
case Types::Region:
return regionTypeToQString(subtype);
return regionTypeToQString(attributes);
case Types::File:
return fileTypeToQString(subtype);
return fileTypeToQString(attributes);
case Types::Section:
return sectionTypeToQString(subtype);
return sectionTypeToQString(attributes);
default:
return QObject::tr("Unknown");
}
}
QString compressionTypeToQString(UINT8 algorithm)
QString compressionTypeToQString(const UINT8 algorithm)
{
switch (algorithm) {
case COMPRESSION_ALGORITHM_NONE:
@ -129,7 +145,7 @@ QString compressionTypeToQString(UINT8 algorithm)
}
}
QString actionTypeToQString(UINT8 action)
QString actionTypeToQString(const UINT8 action)
{
switch (action) {
case Actions::NoAction:

81
types.h
View file

@ -1,6 +1,6 @@
/* types.h
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -16,6 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "basetypes.h"
#pragma pack(push, 1)
// Actions
namespace Actions
{
@ -44,46 +46,57 @@ namespace Types {
};
}
namespace Subtypes {
enum ImageSubtypes{
IntelImage = 70,
BiosImage
};
// Capsule attributes
typedef struct _CAPSULE_ATTRIBUTES {
UINT32 Type : 7;
UINT32 Signed : 1;
UINT32 Reserved : 24;
} CAPSULE_ATTRIBUTES;
#define ATTR_CAPSULE_TYPE_UEFI20 0
#define ATTR_CAPSULE_TYPE_APTIO 1
enum CapsuleSubtypes {
AptioCapsule = 80,
UefiCapsule
};
typedef struct _IMAGE_ATTRIBUTES {
UINT32 IntelDescriptor : 1;
UINT32 Reserved : 31;
} IMAGE_ATTRIBUTES;
#define ATTR_IMAGE_TYPE_UEFI 0
#define ATTR_IMAGE_TYPE_DESCRIPTOR 1
enum VolumeSubtypes {
NormalVolume = 90,
BootVolume,
UnknownVolume,
NvramVolume,
AppleCrcVolume,
UnknownAppleCrcVolume,
BootAppleCrcVolume
};
typedef struct _REGION_ATTRIBUTES {
UINT32 Type : 7;
UINT32 Empty : 1;
UINT32 Reserved : 24;
} REGION_ATTRIBUTES;
enum RegionSubtypes {
DescriptorRegion = 100,
GbeRegion,
MeRegion,
BiosRegion,
PdrRegion
};
#define ATTR_REGION_TYPE_DESCRIPTOR 0
#define ATTR_REGION_TYPE_GBE 1
#define ATTR_REGION_TYPE_ME 2
#define ATTR_REGION_TYPE_BIOS 3
#define ATTR_REGION_TYPE_PDR 4
enum PaddingSubtypes {
ZeroPadding = 110,
OnePadding,
DataPadding
};
};
typedef struct _VOLUME_ATTRIBUTES {
UINT32 Unknown : 1;
UINT32 VtfPresent : 1;
UINT32 ZeroVectorCrc : 1;
UINT32 FsVersion : 5;
UINT32 Reserved : 24;
} VOLUME_ATTRIBUTES;
typedef struct _PADDING_ATTRIBUTES {
UINT32 Empty : 1;
UINT32 ErasePolarity : 1;
UINT32 Reserved : 30;
} PADDING_ATTRIBUTES;
#define ATTR_PADDING_DATA 0
#define ATTR_PADDING_ZERO_EMPTY 1
#define ATTR_PADDING_ONE_EMPTY 3
#pragma pack(pop)
// *ToQString conversion routines
extern QString actionTypeToQString(const UINT8 action);
extern QString itemTypeToQString(const UINT8 type);
extern QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype);
extern QString compressionTypeToQString(UINT8 algorithm);
extern QString itemAttributesToQString(const UINT8 type, const UINT8 attributes);
extern QString compressionTypeToQString(const UINT8 algorithm);
extern QString regionTypeToQString(const UINT8 type);
#endif

View file

@ -1,6 +1,6 @@
/* uefitool.cpp
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -17,7 +17,7 @@
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool),
version(tr("0.19.6"))
version(tr("0.20.0"))
{
clipboard = QApplication::clipboard();
@ -123,7 +123,7 @@ void UEFITool::populateUi(const QModelIndex &current)
TreeModel* model = ffsEngine->treeModel();
UINT8 type = model->type(current);
UINT8 subtype = model->subtype(current);
UINT32 attributes = model->attributes(current);
// Set info text
ui->infoEdit->setPlainText(model->info(current));
@ -138,17 +138,17 @@ void UEFITool::populateUi(const QModelIndex &current)
ui->menuSectionActions->setEnabled(type == Types::Section);
// Enable actions
ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current) && model->hasEmptyTail(current));
ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current));
ui->actionRebuild->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionExtractBody->setDisabled(model->hasEmptyBody(current));
ui->actionRemove->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionInsertInto->setEnabled((type == Types::Volume && subtype != Subtypes::UnknownVolume) ||
(type == Types::File && subtype != EFI_FV_FILETYPE_ALL && subtype != EFI_FV_FILETYPE_RAW && subtype != EFI_FV_FILETYPE_PAD) ||
(type == Types::Section && (subtype == EFI_SECTION_COMPRESSION || subtype == EFI_SECTION_GUID_DEFINED || subtype == EFI_SECTION_DISPOSABLE)));
ui->actionInsertInto->setEnabled((type == Types::Volume && ((VOLUME_ATTRIBUTES*)&attributes)->Unknown == 0) ||
(type == Types::File && attributes != EFI_FV_FILETYPE_ALL && attributes != EFI_FV_FILETYPE_RAW && attributes != EFI_FV_FILETYPE_PAD) ||
(type == Types::Section && (attributes == EFI_SECTION_COMPRESSION || attributes == EFI_SECTION_GUID_DEFINED || attributes == EFI_SECTION_DISPOSABLE)));
ui->actionInsertBefore->setEnabled(type == Types::File || type == Types::Section);
ui->actionInsertAfter->setEnabled(type == Types::File || type == Types::Section);
ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::File || type == Types::Section);
ui->actionReplaceBody->setEnabled(type == Types::File || type == Types::Section);
ui->actionReplace->setEnabled((type == Types::Region && ((REGION_ATTRIBUTES*)&attributes)->Type != ATTR_REGION_TYPE_DESCRIPTOR) || type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionReplaceBody->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionMessagesCopy->setEnabled(false);
}
@ -321,14 +321,24 @@ void UEFITool::replace(const UINT8 mode)
else
return;
}
if (model->type(index) == Types::Volume) {
if (mode == REPLACE_MODE_AS_IS) {
path = QFileDialog::getOpenFileName(this, tr("Select volume file to replace selected object"), currentDir, "Volume files (*.vol *.bin);;All files (*)");
}
else if (mode == REPLACE_MODE_BODY) {
path = QFileDialog::getOpenFileName(this, tr("Select volume body file to replace body"), currentDir, "Volume body files (*.vbd *.bin);;All files (*)");
}
else
return;
}
else if (model->type(index) == Types::File) {
if (mode == REPLACE_MODE_AS_IS) {
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to replace selected object"), currentDir, "FFS files (*.ffs *.bin);;All files (*)");
}
else if (mode == REPLACE_MODE_BODY) {
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW)
if (model->attributes(index) == EFI_FV_FILETYPE_ALL || model->attributes(index) == EFI_FV_FILETYPE_RAW)
path = QFileDialog::getOpenFileName(this, tr("Select raw file to replace body"), currentDir, "Raw files (*.raw *.bin);;All files (*)");
else if (model->subtype(index) == EFI_FV_FILETYPE_PAD) // Pad file body can't be replaced
else if (model->attributes(index) == EFI_FV_FILETYPE_PAD) // Pad file body can't be replaced
return;
else
path = QFileDialog::getOpenFileName(this, tr("Select FFS file body to replace body"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*)");
@ -341,11 +351,11 @@ void UEFITool::replace(const UINT8 mode)
path = QFileDialog::getOpenFileName(this, tr("Select section file to replace selected object"), currentDir, "Section files (*.sec *.bin);;All files (*)");
}
else if (mode == REPLACE_MODE_BODY) {
if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
if (model->attributes(index) == EFI_SECTION_COMPRESSION || model->attributes(index) == EFI_SECTION_GUID_DEFINED || model->attributes(index) == EFI_SECTION_DISPOSABLE)
path = QFileDialog::getOpenFileName(this, tr("Select FFS file body file to replace body"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
else if (model->attributes(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
path = QFileDialog::getOpenFileName(this, tr("Select volume file to replace body"), currentDir, "Volume files (*.vol *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_RAW)
else if (model->attributes(index) == EFI_SECTION_RAW)
path = QFileDialog::getOpenFileName(this, tr("Select raw file to replace body"), currentDir, "Raw files (*.raw *.bin);;All files (*)");
else
path = QFileDialog::getOpenFileName(this, tr("Select file to replace body"), currentDir, "Binary files (*.bin);;All files (*)");
@ -436,19 +446,22 @@ void UEFITool::extract(const UINT8 mode)
case Types::Capsule:
path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"), currentDir, "Image files (*.rom *.bin);;All files (*)");
break;
case Types::Volume:
path = QFileDialog::getSaveFileName(this, tr("Save volume body to file"), currentDir, "Volume body files (*.vbd *.bin);;All files (*)");
break;
case Types::File: {
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW)
if (model->attributes(index) == EFI_FV_FILETYPE_ALL || model->attributes(index) == EFI_FV_FILETYPE_RAW)
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"), currentDir, "Raw files (*.raw *.bin);;All files (*)");
else
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*)");
}
break;
case Types::Section: {
if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
if (model->attributes(index) == EFI_SECTION_COMPRESSION || model->attributes(index) == EFI_SECTION_GUID_DEFINED || model->attributes(index) == EFI_SECTION_DISPOSABLE)
path = QFileDialog::getSaveFileName(this, tr("Save encapsulation section body to FFS body file"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
else if (model->attributes(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
path = QFileDialog::getSaveFileName(this, tr("Save section body to volume file"), currentDir, "Volume files (*.vol *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_RAW)
else if (model->attributes(index) == EFI_SECTION_RAW)
path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"), currentDir, "Raw files (*.raw *.bin);;All files (*)");
else
path = QFileDialog::getSaveFileName(this, tr("Save section body to file"), currentDir, "Binary files (*.bin);;All files (*)");
@ -485,7 +498,7 @@ void UEFITool::extract(const UINT8 mode)
void UEFITool::about()
{
QMessageBox::about(this, tr("About UEFITool"), tr(
"Copyright (c) 2014, Nikolaj Schlej aka <b>CodeRush</b>.<br>"
"Copyright (c) 2015, Nikolaj Schlej aka <b>CodeRush</b>.<br>"
"Program icon made by <a href=https://www.behance.net/alzhidkov>Alexander Zhidkov</a>.<br><br>"
"The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>"
"The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.<br>"

View file

@ -180,7 +180,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -243,7 +243,8 @@
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
<addaction name="actionReplace"/>
<addaction name="actionReplaceBody"/>
</widget>
<widget class="QMenu" name="menuFileActions">
<property name="title">