Skip to content

Commit

Permalink
NE Alpha 33
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Alex Matrosov committed Oct 10, 2016
1 parent 434a350 commit cb43045
Show file tree
Hide file tree
Showing 35 changed files with 2,282 additions and 1,994 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](https://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.
8 changes: 6 additions & 2 deletions UEFIDump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,7 +17,7 @@ SET(PROJECT_SOURCES
../common/LZMA/LzmaDecompress.c
../common/LZMA/SDK/C/LzmaDec.c
../common/Tiano/EfiTianoDecompress.c
../common/ustring.cpp
../common/ustring.cpp
../bstrlib/bstrlib.c
../bstrlib/bstrwrap.cpp
)
Expand All @@ -29,7 +30,8 @@ SET(PROJECT_HEADERS
../common/me.h
../common/ffs.h
../common/fit.h
../common/nvram.h
../common/nvram.h
../common/nvramparser.h
../common/ffsparser.h
../common/ffsreport.h
../common/peimage.h
Expand All @@ -45,4 +47,6 @@ SET(PROJECT_HEADERS
../bstrlib/bstrwrap.h
)

ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT)

ADD_EXECUTABLE(UEFIDump ${PROJECT_SOURCES} ${PROJECT_HEADERS})
2 changes: 1 addition & 1 deletion UEFIDump/uefidump_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions UEFIExtract/uefiextract.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ TARGET = UEFIExtract
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
DEFINES += "U_ENABLE_NVRAM_PARSING_SUPPORT"

SOURCES += \
uefiextract_main.cpp \
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion UEFIExtract/uefiextract_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion UEFITool/uefitool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 3 additions & 0 deletions UEFITool/uefitool.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions UEFITool/uefitool_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions common/LZMA/LzmaCompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ UINT32 *DestinationSize

if (*DestinationSize < destLen)
{
*DestinationSize = destLen;
*DestinationSize = (UINT32)destLen;
return EFI_BUFFER_TOO_SMALL;
}

Expand All @@ -96,7 +96,7 @@ UINT32 *DestinationSize
&SzAllocForLzma,
&SzAllocForLzma);

*DestinationSize = destLen + LZMA_HEADER_SIZE;
*DestinationSize = (UINT32)(destLen + LZMA_HEADER_SIZE);

SetEncodedSizeOfBuf((UINT64)SourceSize, Destination);

Expand Down
155 changes: 154 additions & 1 deletion common/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
4 changes: 4 additions & 0 deletions common/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion common/ffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion common/ffs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions common/ffsbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions common/ffsbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions common/ffsops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit cb43045

Please sign in to comment.