From e660b7eceae3591f24f66b76ec73e5fd0bde899d Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Tue, 14 Jan 2014 21:09:18 +0100 Subject: [PATCH] Version 0.16.4 - code cleanup --- ffsengine.cpp | 11 ++++++++--- ffsengine.h | 22 ++++++++++++---------- uefitool.cpp | 6 +++--- uefitool.ui | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ffsengine.cpp b/ffsengine.cpp index 675f4ee..529f53e 100644 --- a/ffsengine.cpp +++ b/ffsengine.cpp @@ -69,7 +69,7 @@ bool FfsEngine::hasIntersection(const UINT32 begin1, const UINT32 end1, const UI } // Firmware image parsing -UINT8 FfsEngine::parseInputFile(const QByteArray & buffer) +UINT8 FfsEngine::parseImageFile(const QByteArray & buffer) { oldPeiCoreEntryPoint = 0; newPeiCoreEntryPoint = 0; @@ -81,7 +81,7 @@ UINT8 FfsEngine::parseInputFile(const QByteArray & buffer) // Check buffer size to be more then or equal to sizeof(EFI_CAPSULE_HEADER) if ((UINT32) buffer.size() <= sizeof(EFI_CAPSULE_HEADER)) { - msg(tr("parseInputFile: Input file is smaller then minimum size of %1 bytes").arg(sizeof(EFI_CAPSULE_HEADER))); + msg(tr("parseImageFile: Image file is smaller then minimum size of %1 bytes").arg(sizeof(EFI_CAPSULE_HEADER))); return ERR_INVALID_PARAMETER; } @@ -2501,7 +2501,7 @@ UINT8 FfsEngine::reconstruct(const QModelIndex &index, QByteArray& reconstructed return result; } else { - //Other images types can be reconstructed like region + //Other images types can be reconstructed like regions result = reconstructRegion(index, reconstructed); if (result) return result; @@ -2591,6 +2591,11 @@ UINT8 FfsEngine::growVolume(QByteArray & header, const UINT32 size, UINT32 & new return ERR_SUCCESS; } +UINT8 FfsEngine::reconstructImageFile(QByteArray & reconstructed) +{ + return reconstruct(model->index(0,0), reconstructed); +} + // Search routines UINT8 FfsEngine::findHexPattern(const QByteArray & pattern, const UINT8 mode) { diff --git a/ffsengine.h b/ffsengine.h index 65923e1..5a8cd14 100644 --- a/ffsengine.h +++ b/ffsengine.h @@ -44,19 +44,15 @@ public: void clearMessages(); // Firmware image parsing - UINT8 parseInputFile(const QByteArray & buffer); + UINT8 parseImageFile(const QByteArray & buffer); UINT8 parseIntelImage(const QByteArray & intelImage, QModelIndex & index, const QModelIndex & parent = QModelIndex()); UINT8 parseGbeRegion(const QByteArray & gbe, QModelIndex & index, const QModelIndex & parent); UINT8 parseMeRegion(const QByteArray & me, QModelIndex & index, const QModelIndex & parent); UINT8 parseBiosRegion(const QByteArray & bios, QModelIndex & index, const QModelIndex & parent); UINT8 parsePdrRegion(const QByteArray & pdr, QModelIndex & index, const QModelIndex & parent); UINT8 parseBios(const QByteArray & bios, const QModelIndex & parent = QModelIndex()); - UINT8 findNextVolume(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & nextVolumeOffset); - UINT8 getVolumeSize(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize); UINT8 parseVolume(const QByteArray & volume, QModelIndex & index, const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND); - UINT8 getFileSize(const QByteArray & volume, const UINT32 fileOffset, UINT32 & fileSize); UINT8 parseFile(const QByteArray & file, QModelIndex & index, const UINT8 erasePolarity = ERASE_POLARITY_UNKNOWN, const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND); - UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize); UINT8 parseSections(const QByteArray & body, const QModelIndex & parent = QModelIndex()); UINT8 parseSection(const QByteArray & section, QModelIndex & index, const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND); @@ -65,8 +61,7 @@ public: UINT8 compress(const QByteArray & data, const UINT8 algorithm, QByteArray & compressedData); // Construction routines - UINT8 constructPadFile(const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad); - UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize); + UINT8 reconstructImageFile(QByteArray &reconstructed); UINT8 reconstruct(const QModelIndex &index, QByteArray & reconstructed); UINT8 reconstructIntelImage(const QModelIndex& index, QByteArray & reconstructed); UINT8 reconstructRegion(const QModelIndex& index, QByteArray & reconstructed); @@ -77,13 +72,10 @@ public: // Operations on tree items UINT8 extract(const QModelIndex & index, QByteArray & extracted, const UINT8 mode); - UINT8 create(const QModelIndex & index, const UINT8 type, const QByteArray & header, const QByteArray & body, const UINT8 mode, const UINT8 action, const UINT8 algorithm = COMPRESSION_ALGORITHM_NONE); UINT8 insert(const QModelIndex & index, const QByteArray & object, const UINT8 mode); UINT8 replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode); - UINT8 remove(const QModelIndex & index); - UINT8 rebuild(const QModelIndex & index); // Search routines @@ -99,6 +91,16 @@ private: UINT32 oldPeiCoreEntryPoint; UINT32 newPeiCoreEntryPoint; + // Parsing helpers + UINT8 findNextVolume(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & nextVolumeOffset); + UINT8 getVolumeSize(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize); + UINT8 getFileSize(const QByteArray & volume, const UINT32 fileOffset, UINT32 & fileSize); + UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize); + + // Reconstruction helpers + UINT8 constructPadFile(const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad); + UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize); + // Rebase routines UINT8 getBase(const QByteArray& file, UINT32& base); UINT8 getEntryPoint(const QByteArray& file, UINT32 &entryPoint); diff --git a/uefitool.cpp b/uefitool.cpp index 2f5fe8a..d84c1ee 100644 --- a/uefitool.cpp +++ b/uefitool.cpp @@ -417,7 +417,7 @@ void UEFITool::extract(const UINT8 mode) void UEFITool::about() { QMessageBox::about(this, tr("About UEFITool"), tr( - "Copyright (c) 2013, Nikolaj Schlej aka CodeRush.

" + "Copyright (c) 2013-2014, Nikolaj Schlej aka CodeRush.

" "The program is dedicated to RevoGirl. Rest in peace, young genius.

" "The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.
" "The full text of the license may be found at OpenSource.org.

" @@ -448,7 +448,7 @@ void UEFITool::saveImageFile() } QByteArray reconstructed; - UINT8 result = ffsEngine->reconstruct(ffsEngine->treeModel()->index(0,0), reconstructed); + UINT8 result = ffsEngine->reconstructImageFile(reconstructed); showMessages(); if (result) { ui->statusBar->showMessage(tr("Reconstruction failed (%1)").arg(result)); @@ -487,7 +487,7 @@ void UEFITool::openImageFile(QString path) inputFile.close(); init(); - UINT8 result = ffsEngine->parseInputFile(buffer); + UINT8 result = ffsEngine->parseImageFile(buffer); showMessages(); if (result) ui->statusBar->showMessage(tr("Opened file can't be parsed (%1)").arg(result)); diff --git a/uefitool.ui b/uefitool.ui index 05a1234..ca9dbf6 100644 --- a/uefitool.ui +++ b/uefitool.ui @@ -20,7 +20,7 @@ true - UEFITool 0.16.3 + UEFITool 0.16.4