diff --git a/UEFIExtract/ffsdumper.cpp b/UEFIExtract/ffsdumper.cpp index d4954b6..d4e0d1c 100644 --- a/UEFIExtract/ffsdumper.cpp +++ b/UEFIExtract/ffsdumper.cpp @@ -76,6 +76,23 @@ USTATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path file.close(); } } + + if (dumpMode == DUMP_FILE && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType)) { + UModelIndex fileIndex = model->findParentOfType(index, Types::File); + if (!fileIndex.isValid()) + fileIndex = index; + if (counter == 0) + file.setFileName(QObject::tr("%1/file.ffs").arg(path)); + else + file.setFileName(QObject::tr("%1/file_%2.ffs").arg(path).arg(counter)); + counter++; + if (!file.open(QFile::WriteOnly)) + return U_FILE_OPEN; + file.write(model->header(fileIndex)); + file.write(model->body(fileIndex)); + file.write(model->tail(fileIndex)); + file.close(); + } } // Always dump info unless explicitly prohibited diff --git a/UEFIExtract/ffsdumper.h b/UEFIExtract/ffsdumper.h index fee8cca..870bff4 100644 --- a/UEFIExtract/ffsdumper.h +++ b/UEFIExtract/ffsdumper.h @@ -32,7 +32,8 @@ public: DUMP_ALL, DUMP_BODY, DUMP_HEADER, - DUMP_INFO + DUMP_INFO, + DUMP_FILE }; static const UINT8 IgnoreSectionType = 0xFF; diff --git a/UEFIExtract/uefiextract_main.cpp b/UEFIExtract/uefiextract_main.cpp index 208144c..a909eb0 100644 --- a/UEFIExtract/uefiextract_main.cpp +++ b/UEFIExtract/uefiextract_main.cpp @@ -122,6 +122,8 @@ int main(int argc, char *argv[]) modes.push_back(FfsDumper::DUMP_HEADER); else if (arg == QString("info")) modes.push_back(FfsDumper::DUMP_INFO); + else if (arg == QString("file")) + modes.push_back(FfsDumper::DUMP_FILE); else return U_INVALID_PARAMETER; } else if (readType == READ_SECTION) { @@ -185,7 +187,7 @@ int main(int argc, char *argv[]) << " UEFIExtract imagefile report - only generate report, no dump needed." << std::endl << " UEFIExtract imagefile GUID_1 ... [ -o FILE_1 ... ] [ -m MODE_1 ... ] [ -t TYPE_1 ... ] -" << std::endl << " Dump only FFS file(s) with specific GUID(s), without report." << std::endl - << " Type is section type or FF to ignore. Mode is one of: all, body, header, info." << std::endl + << " Type is section type or FF to ignore. Mode is one of: all, body, header, info, file." << std::endl << "Return value is a bit mask where 0 at position N means that file with GUID_N was found and unpacked, 1 otherwise." << std::endl; return 1; }