Add file extraction mode to UEFIExtract

This commit is contained in:
vit9696 2018-06-13 19:53:18 +03:00
parent d23c1a682a
commit c70d448056
3 changed files with 22 additions and 2 deletions

View file

@ -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

View file

@ -32,7 +32,8 @@ public:
DUMP_ALL,
DUMP_BODY,
DUMP_HEADER,
DUMP_INFO
DUMP_INFO,
DUMP_FILE
};
static const UINT8 IgnoreSectionType = 0xFF;

View file

@ -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;
}