From 5b43099d7836b302ea7006da90882a52d895b79d Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Sat, 16 Jul 2016 03:48:21 +0200 Subject: [PATCH] UEFIDump 0.1.1 - ported after engine refactoring, no new features --- UEFIDump/CMakeLists.txt | 3 ++- UEFIDump/uefidump.cpp | 40 ++++++++++++-------------------------- UEFIDump/uefidump.h | 5 +---- UEFIDump/uefidump_main.cpp | 17 +++++----------- 4 files changed, 20 insertions(+), 45 deletions(-) diff --git a/UEFIDump/CMakeLists.txt b/UEFIDump/CMakeLists.txt index 6130845..723e0af 100644 --- a/UEFIDump/CMakeLists.txt +++ b/UEFIDump/CMakeLists.txt @@ -27,7 +27,8 @@ SET(PROJECT_HEADERS ../common/descriptor.h ../common/gbe.h ../common/me.h - ../common/ffs.h + ../common/ffs.h + ../common/fit.h ../common/nvram.h ../common/ffsparser.h ../common/ffsreport.h diff --git a/UEFIDump/uefidump.cpp b/UEFIDump/uefidump.cpp index df26ede..101e88d 100644 --- a/UEFIDump/uefidump.cpp +++ b/UEFIDump/uefidump.cpp @@ -76,34 +76,18 @@ USTATUS UEFIDumper::dump(const UByteArray & buffer, const UString & inPath, cons std::cout << messages[i].first << std::endl; } - // Get last VTF - UModelIndex lastVtf = ffsParser.getLastVtf(); - if (lastVtf.isValid()) { - // Create fitParser - FitParser fitParser(&model); - // Find and parse FIT table - result = fitParser.parse(model.index(0, 0), lastVtf); - if (U_SUCCESS == result) { - // Show fitParser's messages - std::vector > fitMessages = fitParser.getMessages(); - for (size_t i = 0; i < fitMessages.size(); i++) { - std::cout << (const char*)fitMessages[i].first.toLocal8Bit() << std::endl; - } - - // Show FIT table - std::vector > fitTable = fitParser.getFitTable(); - if (fitTable.size()) { - std::cout << "-------------------------------------------------------------------" << std::endl; - std::cout << " Address | Size | Ver | Type | CS " << std::endl; - std::cout << "-------------------------------------------------------------------" << std::endl; - for (size_t i = 0; i < fitTable.size(); i++) { - std::cout << (const char*)fitTable[i][0].toLocal8Bit() << " | " - << (const char*)fitTable[i][1].toLocal8Bit() << " | " - << (const char*)fitTable[i][2].toLocal8Bit() << " | " - << (const char*)fitTable[i][3].toLocal8Bit() << " | " - << (const char*)fitTable[i][4].toLocal8Bit() << std::endl; - } - } + // Show FIT table + std::vector > fitTable = ffsParser.getFitTable(); + if (fitTable.size()) { + std::cout << "-------------------------------------------------------------------" << std::endl; + std::cout << " Address | Size | Ver | CS | Type " << std::endl; + std::cout << "-------------------------------------------------------------------" << std::endl; + for (size_t i = 0; i < fitTable.size(); i++) { + std::cout << (const char*)fitTable[i][0].toLocal8Bit() << " | " + << (const char*)fitTable[i][1].toLocal8Bit() << " | " + << (const char*)fitTable[i][2].toLocal8Bit() << " | " + << (const char*)fitTable[i][3].toLocal8Bit() << " | " + << (const char*)fitTable[i][4].toLocal8Bit() << std::endl; } } diff --git a/UEFIDump/uefidump.h b/UEFIDump/uefidump.h index b61b909..058d062 100644 --- a/UEFIDump/uefidump.h +++ b/UEFIDump/uefidump.h @@ -19,13 +19,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "../common/treemodel.h" #include "../common/ffsparser.h" #include "../common/ffsreport.h" -#include "../common/fitparser.h" - class UEFIDumper { public: - explicit UEFIDumper() : model(), ffsParser(&model), ffsReport(&model), fitParser(&model), currentBuffer(), initialized(false), dumped(false) {} + explicit UEFIDumper() : model(), ffsParser(&model), ffsReport(&model), currentBuffer(), initialized(false), dumped(false) {} ~UEFIDumper() {} USTATUS dump(const UByteArray & buffer, const UString & path, const UString & guid = UString()); @@ -36,7 +34,6 @@ private: TreeModel model; FfsParser ffsParser; FfsReport ffsReport; - FitParser fitParser; UByteArray currentBuffer; bool initialized; diff --git a/UEFIDump/uefidump_main.cpp b/UEFIDump/uefidump_main.cpp index 48a7a28..4fcbedf 100644 --- a/UEFIDump/uefidump_main.cpp +++ b/UEFIDump/uefidump_main.cpp @@ -17,12 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. int main(int argc, char *argv[]) { - if (argc > 32) { - std::cout << "Too many arguments" << std::endl; - return 1; - } - - if (argc > 1) { + + if (argc > 1) { std::ifstream inputFile; inputFile.open(argv[1], std::ios::in | std::ios::binary); std::vector buffer(std::istreambuf_iterator(inputFile), @@ -32,11 +28,8 @@ int main(int argc, char *argv[]) UEFIDumper uefidumper; return (uefidumper.dump(buffer, UString(argv[1])) != U_SUCCESS); } - else { - std::cout << "UEFIDump 0.1.0" << std::endl << std::endl - << "Usage: UEFIDump imagefile" << std::endl; - return 1; - } - return 1; + std::cout << "UEFIDump 0.1.1" << std::endl << std::endl + << "Usage: UEFIDump imagefile" << std::endl; + return 0; }