Skip to content
Permalink
Browse files

Initial ME parser, improved ucode parser, reset vector info

  • Loading branch information
NikolajSchlej committed Jul 24, 2019
1 parent f386eda commit 2e7aa8133a8b3d03ee2105bad66f1081b30e3b54
@@ -192,21 +192,36 @@ void UEFITool::populateUi(const QModelIndex &current)
ui->menuVolumeActions->setEnabled(type == Types::Volume);
ui->menuFileActions->setEnabled(type == Types::File);
ui->menuSectionActions->setEnabled(type == Types::Section);
ui->menuEntryActions->setEnabled(type == Types::NvarEntry
ui->menuEntryActions->setEnabled(type == Types::Microcode
|| type == Types::SlicData
|| type == Types::NvarEntry
|| type == Types::VssEntry
|| type == Types::FsysEntry
|| type == Types::EvsaEntry
|| type == Types::FlashMapEntry);
|| type == Types::FlashMapEntry
|| type == Types::IfwiHeader
|| type == Types::IfwiPartition
|| type == Types::FptPartition
|| type == Types::FptEntry
|| type == Types::BpdtPartition
|| type == Types::BpdtEntry
|| type == Types::CpdPartition
|| type == Types::CpdEntry
|| type == Types::CpdExtension
|| type == Types::CpdSpiEntry
);
ui->menuStoreActions->setEnabled(type == Types::VssStore
|| type == Types::Vss2Store
|| type == Types::FdcStore
|| type == Types::FsysStore
|| type == Types::EvsaStore
|| type == Types::FtwStore
|| type == Types::FlashMapStore
|| type == Types::CmdbStore
|| type == Types::Microcode
|| type == Types::SlicData);
|| type == Types::CmdbStore
|| type == Types::FptStore
|| type == Types::BpdtStore
|| type == Types::CpdStore
);

// Enable actions
ui->actionHexView->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current) && model->hasEmptyTail(current));
@@ -481,7 +496,7 @@ void UEFITool::extract(const UINT8 mode)
if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey to file"), name + ".spk", tr("SLIC pubkey files (*.spk *.bin);;All files (*)"));
else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker to file"), name + ".smk", tr("SLIC marker files (*.smk *.bin);;All files (*)"));
break;
default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)"));
default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)"));
}
}
else if (mode == EXTRACT_MODE_BODY || mode == EXTRACT_MODE_BODY_UNCOMPRESSED) {
@@ -553,7 +568,7 @@ void UEFITool::remove()
void UEFITool::about()
{
QMessageBox::about(this, tr("About UEFITool"), tr(
"Copyright (c) 2018, LongSoft.<br>"
"Copyright (c) 2019, Nikolaj Schlej.<br>"
"Program icon made by <a href=https://www.behance.net/alzhidkov>Alexander Zhidkov</a>.<br>"
"The program uses QHexEdit2 library made by <a href=https://github.com/Simsys/>Simsys</a>.<br>"
"Qt-less engine is using Bstrlib made by <a href=https://github.com/websnarf/>Paul Hsieh</a>.<br><br>"
@@ -858,8 +873,11 @@ void UEFITool::contextMenuEvent(QContextMenuEvent* event)
case Types::EvsaStore:
case Types::FtwStore:
case Types::FlashMapStore:
case Types::CmdbStore: ui->menuStoreActions->exec(event->globalPos()); break;
case Types::FreeSpace: break;
case Types::CmdbStore:
case Types::FptStore:
case Types::CpdStore:
case Types::BpdtStore: ui->menuStoreActions->exec(event->globalPos()); break;
case Types::FreeSpace: break; // No menu needed for FreeSpace item
default: ui->menuEntryActions->exec(event->globalPos()); break;
}
}
@@ -5,6 +5,7 @@ TARGET = UEFITool
TEMPLATE = app
DEFINES += "U_ENABLE_FIT_PARSING_SUPPORT"
DEFINES += "U_ENABLE_NVRAM_PARSING_SUPPORT"
DEFINES += "U_ENABLE_ME_PARSING_SUPPORT"
DEFINES += "U_ENABLE_GUID_DATABASE_SUPPORT"

HEADERS += uefitool.h \
@@ -70,6 +71,7 @@ SOURCES += uefitool_main.cpp \
../common/guiddatabase.cpp \
../common/nvram.cpp \
../common/nvramparser.cpp \
../common/meparser.cpp \
../common/ffsops.cpp \
../common/types.cpp \
../common/descriptor.cpp \
@@ -711,10 +711,6 @@ Decode (
UINT32 DataIdx;
UINT16 CharC;

BytesRemain = (UINT16)(-1);

DataIdx = 0;

for (;;) {
//
// Get one code from mBitBuf
@@ -68,6 +68,19 @@ typedef size_t USTATUS;
#define U_INVALID_BG_BOOT_POLICY 46
#define U_INVALID_TXT_CONF 47
#define U_ELEMENTS_NOT_FOUND 48
#define U_PEI_CORE_ENTRY_POINT_NOT_FOUND 49
#define U_INVALID_STORE_SIZE 50
#define U_UNKNOWN_COMPRESSION_ALGORITHM 51
#define U_NOTHING_TO_PATCH 52
#define U_UNKNOWN_PATCH_TYPE 53
#define U_PATCH_OFFSET_OUT_OF_BOUNDS 54
#define U_INVALID_SYMBOL 55

#define U_INVALID_MANIFEST 251
#define U_UNKNOWN_MANIFEST_HEADER_VERSION 252
#define U_INVALID_ME_PARTITION_TABLE 253
#define U_INVALID_ME_PARTITION 254

#define U_NOT_IMPLEMENTED 0xFF

// EDK2 porting definitions
@@ -39,16 +39,16 @@ const UINT8 ffsAlignment2Table[] =

VOID uint32ToUint24(UINT32 size, UINT8* ffsSize)
{
ffsSize[2] = (UINT8)((size) >> 16);
ffsSize[1] = (UINT8)((size) >> 8);
ffsSize[2] = (UINT8)((size) >> 16U);
ffsSize[1] = (UINT8)((size) >> 8U);
ffsSize[0] = (UINT8)((size));
}

UINT32 uint24ToUint32(const UINT8* ffsSize)
{
return (UINT32) ffsSize[0]
+ ((UINT32) ffsSize[1] << 8U)
+ ((UINT32) ffsSize[2] << 16U);
+ ((UINT32) ffsSize[1] << 8U)
+ ((UINT32) ffsSize[2] << 16U);
}

UString guidToUString(const EFI_GUID & guid, bool convertToString)
@@ -84,17 +84,17 @@ bool ustringToGuid(const UString & str, EFI_GUID & guid)
if (err == 0)
return false;

guid.Data1 = p0;
guid.Data2 = p1;
guid.Data3 = p2;
guid.Data4[0] = p3;
guid.Data4[1] = p4;
guid.Data4[2] = p5;
guid.Data4[3] = p6;
guid.Data4[4] = p7;
guid.Data4[5] = p8;
guid.Data4[6] = p9;
guid.Data4[7] = p10;
guid.Data1 = (UINT32)p0;
guid.Data2 = (UINT16)p1;
guid.Data3 = (UINT16)p2;
guid.Data4[0] = (UINT8)p3;
guid.Data4[1] = (UINT8)p4;
guid.Data4[2] = (UINT8)p5;
guid.Data4[3] = (UINT8)p6;
guid.Data4[4] = (UINT8)p7;
guid.Data4[5] = (UINT8)p8;
guid.Data4[6] = (UINT8)p9;
guid.Data4[7] = (UINT8)p10;

return true;
}
@@ -571,6 +571,21 @@ typedef struct POSTCODE_SECTION_ {
///
#define EFI_DEP_SOR 0x09

//*****************************************************************************
// X86 Reset Vector Data
//*****************************************************************************
typedef struct X86_RESET_VECTOR_DATA_ {
UINT8 ApEntryVector[8]; // Base: 0xffffffd0
UINT8 Reserved0[8];
UINT32 PeiCoreEntryPoint; // Base: 0xffffffe0
UINT8 Reserved1[12];
UINT8 ResetVector[8]; // Base: 0xfffffff0
UINT32 ApStartupSegment; // Base: 0xfffffff8
UINT32 BootFvBaseAddress; // Base: 0xfffffffc
} X86_RESET_VECTOR_DATA;

#define X86_RESET_VECTOR_DATA_UNPOPULATED 0x12345678

// Restore previous packing rules
#pragma pack(pop)

0 comments on commit 2e7aa81

Please sign in to comment.
You can’t perform that action at this time.