NE Alpha 33

- human readable JEDEC ID
- NVRAM parser separated from FFS parser
- added support for LZMAF86 sections
- solved a bug with parsing of VSS variables with invalid sizes
This commit is contained in:
Alex Matrosov 2016-10-09 23:05:04 -07:00
parent 434a350819
commit cb430456bf
35 changed files with 2282 additions and 1994 deletions

View File

@ -53,4 +53,4 @@ You can either use [pre-built binaries for Windows and OSX](https://github.com/L
* Some vendor-specific firmware update files can be opened incorrectly or can't be opened at all. This includes encrypted HP update files, Dell HDR and EXE files, some InsydeFlash FD files and so on. Enabling support for such files will require massive amount of reverse-engineering which is almost pointless because the updated image can be obtained from BIOS chip where it's already decrypted and unpacked.
* Intel Firmware Interface Table (FIT) editing is not supported right now. FIT contains pointers to various image components that must be loaded before executing the first CPU instruction from the BIOS chip. Those components include CPU microcode updates, binaries and settings used by BIOS Guard and Boot Guard technologies and some other stuff. More information on FIT can be obtained [here](http://downloadmirror.intel.com/18931/eng/Intel%20TXT%20LAB%20Handout.pdf).
* Builder code is still not ready, but I'm working hard on it.
* Builder code is still not ready.

View File

@ -7,6 +7,7 @@ SET(PROJECT_SOURCES
../common/descriptor.cpp
../common/ffs.cpp
../common/nvram.cpp
../common/nvramparser.cpp
../common/ffsparser.cpp
../common/ffsreport.cpp
../common/peimage.cpp
@ -30,6 +31,7 @@ SET(PROJECT_HEADERS
../common/ffs.h
../common/fit.h
../common/nvram.h
../common/nvramparser.h
../common/ffsparser.h
../common/ffsreport.h
../common/peimage.h
@ -45,4 +47,6 @@ SET(PROJECT_HEADERS
../bstrlib/bstrwrap.h
)
ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT)
ADD_EXECUTABLE(UEFIDump ${PROJECT_SOURCES} ${PROJECT_HEADERS})

View File

@ -29,7 +29,7 @@ int main(int argc, char *argv[])
return (uefidumper.dump(buffer, UString(argv[1])) != U_SUCCESS);
}
std::cout << "UEFIDump 0.1.1" << std::endl << std::endl
std::cout << "UEFIDump 0.1.2" << std::endl << std::endl
<< "Usage: UEFIDump imagefile" << std::endl;
return 0;
}

View File

@ -5,6 +5,7 @@ TARGET = UEFIExtract
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
DEFINES += "U_ENABLE_NVRAM_PARSING_SUPPORT"
SOURCES += \
uefiextract_main.cpp \
@ -13,6 +14,7 @@ SOURCES += \
../common/descriptor.cpp \
../common/ffs.cpp \
../common/nvram.cpp \
../common/nvramparser.cpp \
../common/ffsparser.cpp \
../common/ffsreport.cpp \
../common/peimage.cpp \
@ -32,6 +34,7 @@ HEADERS += \
../common/me.h \
../common/ffs.h \
../common/nvram.h \
../common/nvramparser.h \
../common/ffsparser.h \
../common/ffsreport.h \
../common/peimage.h \

View File

@ -120,7 +120,7 @@ int main(int argc, char *argv[])
}
}
// If parameters are different, show version and usage information
std::cout << "UEFIExtract 0.13.0" << std::endl << std::endl
std::cout << "UEFIExtract 0.13.1" << std::endl << std::endl
<< "Usage: UEFIExtract imagefile - generate report and dump only leaf tree items into .dump folder." << std::endl
<< " UEFIExtract imagefile all - generate report and dump all tree items." << std::endl
<< " UEFIExtract imagefile dump - only generate dump, no report needed." << std::endl

View File

@ -17,7 +17,7 @@
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool),
version(tr("NE Alpha32"))
version(tr("NE Alpha33"))
{
clipboard = QApplication::clipboard();

View File

@ -3,6 +3,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = UEFITool
TEMPLATE = app
DEFINES += "U_ENABLE_NVRAM_PARSING_SUPPORT"
HEADERS += uefitool.h \
searchdialog.h \
@ -11,6 +12,7 @@ HEADERS += uefitool.h \
guidlineedit.h \
ffsfinder.h \
../common/nvram.h \
../common/nvramparser.h \
../common/ffsops.h \
../common/basetypes.h \
../common/descriptor.h \
@ -44,6 +46,7 @@ SOURCES += uefitool_main.cpp \
guidlineedit.cpp \
ffsfinder.cpp \
../common/nvram.cpp \
../common/nvramparser.cpp \
../common/ffsops.cpp \
../common/types.cpp \
../common/descriptor.cpp \

View File

@ -18,8 +18,8 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setOrganizationName("CodeRush");
a.setOrganizationDomain("coderush.me");
a.setOrganizationName("LongSoft");
a.setOrganizationDomain("longsoft.org");
a.setApplicationName("UEFITool");
UEFITool w;

View File

@ -74,7 +74,7 @@ UINT32 *DestinationSize
if (*DestinationSize < destLen)
{
*DestinationSize = destLen;
*DestinationSize = (UINT32)destLen;
return EFI_BUFFER_TOO_SMALL;
}
@ -96,7 +96,7 @@ UINT32 *DestinationSize
&SzAllocForLzma,
&SzAllocForLzma);
*DestinationSize = destLen + LZMA_HEADER_SIZE;
*DestinationSize = (UINT32)(destLen + LZMA_HEADER_SIZE);
SetEncodedSizeOfBuf((UINT64)SourceSize, Destination);

View File

@ -38,3 +38,156 @@ UINT32 calculateRegionSize(const UINT16 base, const UINT16 limit)
return (limit + 1 - base) * 0x1000;
return 0;
}
// Return human-readable chip name for given JEDEC ID
UString jedecIdToUString(UINT8 vendorId, UINT8 deviceId0, UINT8 deviceId1)
{
UINT32 jedecId = (UINT32)deviceId1 + ((UINT32)deviceId0 << 8) + ((UINT32)vendorId << 16);
switch (jedecId) {
// Winbond
case 0xEF3013: return UString("Winbond W25X40");
case 0xEF3014: return UString("Winbond W25X80");
case 0xEF3015: return UString("Winbond W25X16");
case 0xEF3016: return UString("Winbond W25X32");
case 0xEF3017: return UString("Winbond W25X64");
case 0xEF4013: return UString("Winbond W25Q40");
case 0xEF4014: return UString("Winbond W25Q80");
case 0xEF4015: return UString("Winbond W25Q16");
case 0xEF4016: return UString("Winbond W25Q32");
case 0xEF4017: return UString("Winbond W25Q64");
case 0xEF4018: return UString("Winbond W25Q128");
case 0xEF4019: return UString("Winbond W25Q256");
case 0xEF6015: return UString("Winbond W25Q16 1.8v");
case 0xEF6016: return UString("Winbond W25Q32 1.8v");
case 0xEF6017: return UString("Winbond W25Q64 1.8v");
case 0xEF6018: return UString("Winbond W25Q128 1.8v");
// Macronix
case 0xC22013: return UString("Macronix MX25L40");
case 0xC22014: return UString("Macronix MX25L80");
case 0xC22015:
case 0xC22415:
case 0xC22515: return UString("Macronix MX25L16");
case 0xC22016:
case 0xC22535: return UString("Macronix MX25U16");
case 0xC22536: return UString("Macronix MX25U32");
case 0xC22537: return UString("Macronix MX25U64");
case 0xC22538: return UString("Macronix MX25U128");
case 0xC22539: return UString("Macronix MX25U256");
case 0xC25E16: return UString("Macronix MX25L32");
case 0xC22017:
case 0xC29517: return UString("Macronix MX25L64");
case 0xC22018: return UString("Macronix MX25L128");
case 0xC22019: return UString("Macronix MX25L256");
// Micron
case 0x202014: return UString("Micron M25P80");
case 0x202015: return UString("Micron M25P16");
case 0x202016: return UString("Micron M25P32");
case 0x202017: return UString("Micron M25P64");
case 0x202018: return UString("Micron M25P128");
case 0x204011: return UString("Micron M45PE10");
case 0x204012: return UString("Micron M45PE20");
case 0x204013: return UString("Micron M45PE40");
case 0x204014: return UString("Micron M45PE80");
case 0x204015: return UString("Micron M45PE16");
case 0x207114: return UString("Micron M25PX80");
case 0x207115: return UString("Micron M25PX16");
case 0x207116: return UString("Micron M25PX32");
case 0x207117: return UString("Micron M25PX64");
case 0x208011: return UString("Micron M25PE10");
case 0x208012: return UString("Micron M25PE20");
case 0x208013: return UString("Micron M25PE40");
case 0x208014: return UString("Micron M25PE80");
case 0x208015: return UString("Micron M25PE16");
case 0x20BA15: return UString("Micron N25Q016");
case 0x20BA16: return UString("Micron N25Q032");
case 0x20BA17: return UString("Micron N25Q064");
case 0x20BA18: return UString("Micron N25Q128");
case 0x20BA19: return UString("Micron N25Q256");
case 0x20BA20: return UString("Micron N25Q512");
case 0x20BA21: return UString("Micron N25Q00A");
case 0x20BB15: return UString("Micron N25Q016 1.8v");
case 0x20BB16: return UString("Micron N25Q032 1.8v");
case 0x20BB17: return UString("Micron N25Q064 1.8v");
case 0x20BB18: return UString("Micron MT25Q128 1.8v");
case 0x20BB19: return UString("Micron MT25Q256 1.8v");
case 0x20BB20: return UString("Micron MT25Q512 1.8v");
// Atmel
case 0x1F4500: return UString("Atmel AT26DF081");
case 0x1F4501: return UString("Atmel AT26DF081A");
case 0x1F4502: return UString("Atmel AT25DF081");
case 0x1F4600: return UString("Atmel AT26DF161");
case 0x1F4601: return UString("Atmel AT26DF161A");
case 0x1F4602: return UString("Atmel AT25DF161");
case 0x1F8600: return UString("Atmel AT25DQ161");
case 0x1F4700: return UString("Atmel AT25DF321");
case 0x1F4701: return UString("Atmel AT25DF321A");
case 0x1F4800: return UString("Atmel AT25DF641");
case 0x1F8800: return UString("Atmel AT25DQ641");
// Microchip
case 0xBF2541: return UString("Microchip SST25VF016B");
case 0xBF254A: return UString("Microchip SST25VF032B");
case 0xBF258D: return UString("Microchip SST25VF040B");
case 0xBF258E: return UString("Microchip SST25VF080B");
case 0xBF254B: return UString("Microchip SST25VF064C");
// EON
case 0x1C3013: return UString("EON EN25Q40");
case 0x1C3014: return UString("EON EN25Q80");
case 0x1C3015: return UString("EON EN25Q16");
case 0x1C3016: return UString("EON EN25Q32");
case 0x1C3017: return UString("EON EN25Q64");
case 0x1C3018: return UString("EON EN25Q128");
case 0x1C3114: return UString("EON EN25F80");
case 0x1C3115: return UString("EON EN25F16");
case 0x1C3116: return UString("EON EN25F32");
case 0x1C3117: return UString("EON EN25F64");
case 0x1C7015: return UString("EON EN25QH16");
case 0x1C7016: return UString("EON EN25QH32");
case 0x1C7017: return UString("EON EN25QH64");
case 0x1C7018: return UString("EON EN25QH128");
case 0x1C7019: return UString("EON EN25QH256");
// GigaDevice
case 0xC84014: return UString("GigaDevice GD25x80");
case 0xC84015: return UString("GigaDevice GD25x16");
case 0xC84016: return UString("GigaDevice GD25x32");
case 0xC84017: return UString("GigaDevice GD25x64");
case 0xC84018: return UString("GigaDevice GD25x128");
case 0xC86017: return UString("GigaDevice GD25Lx64");
case 0xC86018: return UString("GigaDevice GD25Lx128");
// Fidelix
case 0xF83215: return UString("Fidelix FM25Q16");
case 0xF83216: return UString("Fidelix FM25Q32");
case 0xF83217: return UString("Fidelix FM25Q64");
case 0xF83218: return UString("Fidelix FM25Q128");
// Spansion
case 0x014015: return UString("Spansion S25FL116K");
case 0x014016: return UString("Spansion S25FL132K");
case 0x014017: return UString("Spansion S25FL164K");
// Amic
case 0x373015: return UString("Amic A25L016");
case 0x373016: return UString("Amic A25L032");
case 0x374016: return UString("Amic A25L032A");
// PMC
case 0x7F9D13: return UString("PMC Pm25LV080B");
case 0x7F9D14: return UString("PMC Pm25LV016B");
case 0x7F9D44: return UString("PMC Pm25LQ080C");
case 0x7F9D45: return UString("PMC Pm25LQ016C");
case 0x7F9D46: return UString("PMC Pm25LQ032C");
// ISSI
case 0x9D6017: return UString("ISSI Ix25LP064");
case 0x9D6018: return UString("ISSI Ix25LP128");
case 0x9D7018: return UString("ISSI Ix25WP128");
}
return UString("Unknown");
}

View File

@ -14,6 +14,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define DESCRIPTOR_H
#include "basetypes.h"
#include "ustring.h"
// Make sure we use right packing rules
#pragma pack(push,1)
@ -201,4 +202,7 @@ extern UINT32 calculateRegionOffset(const UINT16 base);
// Calculate size of region using it's base and limit
extern UINT32 calculateRegionSize(const UINT16 base, const UINT16 limit);
// Return human-readable chip name for given JEDEC ID
extern UString jedecIdToUString(UINT8 vendorId, UINT8 deviceId0, UINT8 deviceId1);
#endif // DESCRIPTOR_H

View File

@ -10,7 +10,6 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ustring.h"
#include "ffs.h"
// This is a workaround for the lack of static std::vector initializer before C++11

View File

@ -15,9 +15,9 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <vector>
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
#include "basetypes.h"
// Make sure we use right packing rules
#pragma pack(push,1)
@ -454,6 +454,9 @@ const UByteArray EFI_GUIDED_SECTION_TIANO // A31280AD-481E-41B6-95E8-127F4C98477
const UByteArray EFI_GUIDED_SECTION_LZMA // EE4E5898-3914-4259-9D6E-DC7BD79403CF
("\x98\x58\x4E\xEE\x14\x39\x59\x42\x9D\x6E\xDC\x7B\xD7\x94\x03\xCF", 16);
const UByteArray EFI_GUIDED_SECTION_LZMAF86 // D42AE6BD-1352-4BFB-909A-CA72A6EAE889
("\xBD\xE6\x2A\xD4\x52\x13\xFB\x4B\x90\x9A\xCA\x72\xA6\xEA\xE8\x89", 16);
const UByteArray EFI_FIRMWARE_CONTENTS_SIGNED_GUID // 0F9D89E8-9259-4F76-A5AF-0C89E34023DF
("\xE8\x89\x9D\x0F\x59\x92\x76\x4F\xA5\xAF\x0C\x89\xE3\x40\x23\xDF", 16);

View File

@ -12,6 +12,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ffsbuilder.h"
#include "descriptor.h"
#include "ffs.h"
#include "peimage.h"
#include "utility.h"
USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased)
{
// Sanity check

View File

@ -16,14 +16,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <vector>
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
#include "basetypes.h"
#include "treemodel.h"
#include "descriptor.h"
#include "ffs.h"
#include "peimage.h"
#include "utility.h"
class FfsBuilder
{

View File

@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ffsops.h"
#include "ffs.h"
#include "utility.h"
USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteArray & extracted, const UINT8 mode)
{

View File

@ -16,12 +16,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <vector>
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
#include "basetypes.h"
#include "treemodel.h"
#include "ffs.h"
#include "utility.h"
class FfsOperations
{

File diff suppressed because it is too large Load Diff

View File

@ -15,33 +15,27 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <vector>
#include "basetypes.h"
#include "ustring.h"
#include "ubytearray.h"
#include "basetypes.h"
#include "treemodel.h"
#include "utility.h"
#include "peimage.h"
#include "parsingdata.h"
#include "types.h"
#include "treemodel.h"
#include "descriptor.h"
#include "ffs.h"
#include "gbe.h"
#include "me.h"
#include "fit.h"
#include "nvram.h"
class TreeModel;
#include "nvramparser.h"
class FfsParser
{
public:
// Default constructor and destructor
FfsParser(TreeModel* treeModel) : model(treeModel), capsuleOffsetFixup(0) {}
FfsParser(TreeModel* treeModel) : model(treeModel), nvramParser(treeModel), capsuleOffsetFixup(0) {}
~FfsParser() {}
// Returns messages
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; }
std::vector<std::pair<UString, UModelIndex> > getMessages() const {
std::vector<std::pair<UString, UModelIndex> > nvramVector = nvramParser.getMessages();
std::vector<std::pair<UString, UModelIndex> > resultVector = messagesVector;
resultVector.insert(std::end(resultVector), std::begin(nvramVector), std::end(nvramVector));
return resultVector;
}
// Clears messages
void clearMessages() { messagesVector.clear(); }
@ -62,6 +56,8 @@ private:
UINT32 capsuleOffsetFixup;
std::vector<std::vector<UString> > fitTable;
NvramParser nvramParser;
// First pass
USTATUS performFirstPass(const UByteArray & imageFile, UModelIndex & index);
@ -100,36 +96,12 @@ private:
USTATUS parsePeImageSectionBody(const UModelIndex & index);
USTATUS parseTeImageSectionBody(const UModelIndex & index);
UINT8 getPaddingType(const UByteArray & padding);
USTATUS parseAprioriRawSection(const UByteArray & body, UString & parsed);
USTATUS findNextVolume(const UModelIndex & index, const UByteArray & bios, const UINT32 parentOffset, const UINT32 volumeOffset, UINT32 & nextVolumeOffset);
USTATUS getVolumeSize(const UByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize, UINT32 & bmVolumeSize);
UINT32 getFileSize(const UByteArray & volume, const UINT32 fileOffset, const UINT8 ffsVersion);
UINT32 getSectionSize(const UByteArray & file, const UINT32 sectionOffset, const UINT8 ffsVersion);
// NVRAM parsing
USTATUS parseNvramVolumeBody(const UModelIndex & index);
USTATUS findNextStore(const UModelIndex & index, const UByteArray & volume, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset);
USTATUS getStoreSize(const UByteArray & data, const UINT32 storeOffset, UINT32 & storeSize);
USTATUS parseStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseNvarStore(const UModelIndex & index);
USTATUS parseVssStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFtwStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFdcStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFsysStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseEvsaStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFlashMapStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseCmdbStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseSlicPubkeyHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseSlicMarkerHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseIntelMicrocodeHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseVssStoreBody(const UModelIndex & index);
USTATUS parseFsysStoreBody(const UModelIndex & index);
USTATUS parseEvsaStoreBody(const UModelIndex & index);
USTATUS parseFlashMapBody(const UModelIndex & index);
// Second pass
USTATUS performSecondPass(const UModelIndex & index);
USTATUS addOffsetsRecursive(const UModelIndex & index);

View File

@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ffsreport.h"
#include "ffs.h"
#include "utility.h"
std::vector<UString> FfsReport::generate()
{
@ -65,3 +67,4 @@ USTATUS FfsReport::generateRecursive(std::vector<UString> & report, UModelIndex
return U_SUCCESS;
}

View File

@ -16,12 +16,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <vector>
#include "../common/ubytearray.h"
#include "../common/ustring.h"
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
#include "treemodel.h"
#include "ffs.h"
#include "utility.h"
class FfsReport
{
@ -36,7 +35,7 @@ private:
TreeModel* model;
USTATUS generateRecursive(std::vector<UString> & report, UModelIndex index, UINT32 level = 0);
};
#endif // FFSREPORT_H

View File

@ -15,9 +15,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef NVRAM_H
#define NVRAM_H
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
#include "basetypes.h"
// Make sure we use right packing rules
#pragma pack(push, 1)

1914
common/nvramparser.cpp Normal file

File diff suppressed because it is too large Load Diff

90
common/nvramparser.h Normal file
View File

@ -0,0 +1,90 @@
/* nvramparser.h
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#ifndef NVRAMPARSER_H
#define NVRAMPARSER_H
#include <vector>
#include "basetypes.h"
#include "ustring.h"
#include "ubytearray.h"
#include "treemodel.h"
#ifdef U_ENABLE_NVRAM_PARSING_SUPPORT
class NvramParser
{
public:
// Default constructor and destructor
NvramParser(TreeModel* treeModel) : model(treeModel) {}
~NvramParser() {}
// Returns messages
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; }
// Clears messages
void clearMessages() { messagesVector.clear(); }
// NVRAM parsing
USTATUS parseNvramVolumeBody(const UModelIndex & index);
USTATUS parseNvarStore(const UModelIndex & index);
private:
TreeModel *model;
std::vector<std::pair<UString, UModelIndex> > messagesVector;
void msg(const UString message, const UModelIndex index = UModelIndex()) {
messagesVector.push_back(std::pair<UString, UModelIndex>(message, index));
};
USTATUS findNextStore(const UModelIndex & index, const UByteArray & volume, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset);
USTATUS getStoreSize(const UByteArray & data, const UINT32 storeOffset, UINT32 & storeSize);
USTATUS parseStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseVssStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFtwStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFdcStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFsysStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseEvsaStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseFlashMapStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseCmdbStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseSlicPubkeyHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseSlicMarkerHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseIntelMicrocodeHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
USTATUS parseVssStoreBody(const UModelIndex & index);
USTATUS parseFsysStoreBody(const UModelIndex & index);
USTATUS parseEvsaStoreBody(const UModelIndex & index);
USTATUS parseFlashMapBody(const UModelIndex & index);
};
#else
class NvramParser
{
public:
// Default constructor and destructor
NvramParser(TreeModel* treeModel) : model(treeModel) {}
~NvramParser() {}
// Returns messages
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; }
// Clears messages
void clearMessages() { messagesVector.clear(); }
// NVRAM parsing
USTATUS parseNvramVolumeBody(const UModelIndex &) { return U_SUCCESS; }
USTATUS parseNvarStore(const UModelIndex &) { return U_SUCCESS; }
private:
TreeModel *model;
std::vector<std::pair<UString, UModelIndex> > messagesVector;
};
#endif // U_ENABLE_NVRAM_PARSING_SUPPORT
#endif // NVRAMPARSER_H

View File

@ -16,8 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef PEIMAGE_H
#define PEIMAGE_H
#include "ustring.h"
#include "basetypes.h"
#include "ustring.h"
extern UString machineTypeToUString(UINT16 machineType);

View File

@ -17,9 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <list>
#include <iterator>
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
#include "basetypes.h"
class TreeItem
{
@ -38,7 +38,7 @@ public:
// Model support operations
TreeItem *child(int row); // Non-trivial implementation in CPP file
int childCount() const {return childItems.size(); }
int childCount() const {return (int)childItems.size(); }
int columnCount() const { return 5; }
UString data(int column) const; // Non-trivial implementation in CPP file
int row() const; // Non-trivial implementation in CPP file

View File

@ -11,7 +11,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "treeitem.h"
#include "treemodel.h"
#if defined(QT_CORE_LIB)

View File

@ -1,6 +1,6 @@
/* treemodel.h
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@ -10,7 +10,6 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ustring.h"
#include "types.h"
#include "ffs.h"
#include "fit.h"

View File

@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define TYPES_H
#include "basetypes.h"
#include "ustring.h"
// Actions
namespace Actions
@ -136,7 +137,7 @@ namespace Subtypes {
PubkeySlicData = 180,
MarkerSlicData
};
};
}
// *ToUString conversion routines
extern UString actionTypeToUString(const UINT8 action);

View File

@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define UByteArray QByteArray
#else
// Use own implementation
#include <stdint.h>
#include <cstdint>
#include <string>
#include <vector>
#include <algorithm>
@ -32,6 +32,7 @@ public:
UByteArray(const std::basic_string<char> & bs) : d(bs) {}
UByteArray(const std::vector<char> & bc) : d(bc.data(), bc.size()) {}
UByteArray(const char* bytes, int32_t size) : d(bytes, size) {}
UByteArray(const size_t n, char c) : d(n, c) {}
~UByteArray() {}
bool isEmpty() const { return d.length() == 0; }
@ -41,6 +42,9 @@ public:
const char* constData() const { return d.c_str(); }
void clear() { d.clear(); }
UByteArray toUpper() { std::basic_string<char> s = d; std::transform(s.begin(), s.end(), s.begin(), ::toupper); return UByteArray(s); }
uint32_t toUInt(bool* ok = NULL, const uint8_t base = 10) { return (uint32_t)std::strtoul(d.c_str(), NULL, base); }
int32_t size() const { return d.size(); }
int32_t count(char ch) const { return std::count(d.begin(), d.end(), ch); }
char at(uint32_t i) const { return d.at(i); }
@ -49,11 +53,19 @@ public:
bool startsWith(const UByteArray & ba) const { return 0 == d.find(ba.d, 0); }
int indexOf(const UByteArray & ba, int from = 0) const { return d.find(ba.d, from); }
int lastIndexOf(const UByteArray & ba, int from = 0) const { return d.rfind(ba.d, from); }
int lastIndexOf(const UByteArray & ba, int from = 0) const {
size_t old_index = d.npos;
size_t index = d.find(ba.d, from);
while (index != d.npos) {
old_index = index;
index = d.find(ba.d, index + 1);
}
return old_index;
}
UByteArray left(int32_t len) const { return d.substr(0, len); }
UByteArray right(int32_t len) const { return d.substr(d.size() - 1 - len, len); };
UByteArray mid(int32_t pos, int32_t len = -1) const { return d.substr(pos, len); };
UByteArray right(int32_t len) const { return d.substr(d.size() - 1 - len, len); }
UByteArray mid(int32_t pos, int32_t len = -1) const { return d.substr(pos, len); }
UByteArray & operator=(const UByteArray & ba) { d = ba.d; return *this; }
UByteArray & operator+=(const UByteArray & ba) { d += ba.d; return *this; }

View File

@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include "ustring.h"
#include <stdarg.h>
#include <cstdarg>
#if defined(QT_CORE_LIB)
UString usprintf(const char* fmt, ...)

View File

@ -243,9 +243,9 @@ USTATUS decompress(const UByteArray & compressedData, UINT8 & algorithm, UByteAr
efiDecompressed = (UINT8*)malloc(decompressedSize);
scratch = (UINT8*)malloc(scratchSize);
if (!decompressed || !efiDecompressed || !scratch) {
if (decompressed) free(decompressed);
if (efiDecompressed) free(efiDecompressed);
if (scratch) free(scratch);
free(decompressed);
free(efiDecompressed);
free(scratch);
return U_STANDARD_DECOMPRESSION_FAILED;
}
@ -362,3 +362,12 @@ UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize)
return (UINT16)(0x10000 - counter);
}
UINT8 getPaddingType(const UByteArray & padding)
{
if (padding.count('\x00') == padding.size())
return Subtypes::ZeroPadding;
if (padding.count('\xFF') == padding.size())
return Subtypes::OnePadding;
return Subtypes::DataPadding;
}

View File

@ -14,9 +14,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef UTILITY_H
#define UTILITY_H
#include "basetypes.h"
#include "ustring.h"
#include "treemodel.h"
#include "basetypes.h"
#include "parsingdata.h"
// Returns either new parsing data instance or obtains it from index
@ -46,4 +46,7 @@ UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize);
// 16bit checksum calculation routine
UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize);
// Return padding type from it's contents
UINT8 getPaddingType(const UByteArray & padding);
#endif // UTILITY_H

View File

@ -678,6 +678,8 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex();
for (qint64 idx = 32; idx < ba.size(); idx += 33)
ba.insert(idx, "\n");
if(_upperCase)
ba = ba.toUpper();
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(ba);
}