mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-27 21:44:24 -04:00
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:
parent
434a350819
commit
cb430456bf
35 changed files with 2282 additions and 1994 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -37,4 +37,157 @@ UINT32 calculateRegionSize(const UINT16 base, const UINT16 limit)
|
|||
if (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");
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
1933
common/ffsparser.cpp
1933
common/ffsparser.cpp
File diff suppressed because it is too large
Load diff
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
1914
common/nvramparser.cpp
Normal file
File diff suppressed because it is too large
Load diff
90
common/nvramparser.h
Normal file
90
common/nvramparser.h
Normal 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
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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, ...)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -361,4 +361,13 @@ 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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue