Skip to content

Commit 831603d

Browse files
committed
Big update 0.20.0
- major refactoring round done - added replace actions for volumes - added better Intel signature handling - added support for unsigned Aptio capsules - more GUIDs added to known-GUIDs database - more information about PE and TE sections - shown information about item full size - hexadecimal numbers format changed from 0xAB to ABh - AppleCRC renamed to ZVCRC because it seems not Apple-specific feature after all
1 parent fb7e1c4 commit 831603d

23 files changed

+1215
-1143
lines changed

Tiano/EfiTianoCompressLegacy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* EFI11/Tiano Compress Implementation
22
3-
Copyright (c) 2014, Nikolaj Schlej
3+
Copyright (c) 2015, Nikolaj Schlej
44
Copyright (c) 2006 - 2008, Intel Corporation
55
This program and the accompanying materials
66
are licensed and made available under the terms and conditions of the BSD License
@@ -278,7 +278,7 @@ STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NU
278278
//
279279
// functions
280280
//
281-
UINT8
281+
EFI_STATUS
282282
EfiCompressLegacy(
283283
CONST VOID *SrcBuffer,
284284
UINT32 SrcSize,
@@ -373,7 +373,7 @@ EFI_INVALID_PARAMETER - Parameter supplied is wrong.
373373

374374
}
375375

376-
UINT8
376+
EFI_STATUS
377377
TianoCompressLegacy (
378378
CONST VOID *SrcBuffer,
379379
UINT32 SrcSize,

Tiano/EfiTianoDecompress.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* EfiTianoDecompress.h
22
3-
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.<BR>
3+
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.<BR>
44
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
55
This program and the accompanying materials
66
are licensed and made available under the terms and conditions of the BSD License
@@ -40,7 +40,7 @@ extern "C" {
4040
EFI_STATUS
4141
EFIAPI
4242
EfiTianoGetInfo(
43-
VOID *Source,
43+
const VOID *Source,
4444
UINT32 SrcSize,
4545
UINT32 *DstSize,
4646
UINT32 *ScratchSize
@@ -70,7 +70,7 @@ extern "C" {
7070
EFI_STATUS
7171
EFIAPI
7272
EfiDecompress(
73-
VOID *Source,
73+
const VOID *Source,
7474
UINT32 SrcSize,
7575
VOID *Destination,
7676
UINT32 DstSize,
@@ -104,7 +104,7 @@ extern "C" {
104104
EFI_STATUS
105105
EFIAPI
106106
TianoDecompress(
107-
VOID *Source,
107+
const VOID *Source,
108108
UINT32 SrcSize,
109109
VOID *Destination,
110110
UINT32 DstSize,

UEFIExtract/uefiextract_main.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,43 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
1818

1919
int main(int argc, char *argv[])
2020
{
21-
QCoreApplication a(argc, argv);
22-
a.setOrganizationName("CodeRush");
23-
a.setOrganizationDomain("coderush.me");
24-
a.setApplicationName("UEFIExtract");
25-
26-
UEFIExtract w;
27-
UINT8 result = ERR_SUCCESS;
28-
UINT32 returned = 0;
29-
30-
if (a.arguments().length() > 32) {
31-
std::cout << "Too many arguments" << std::endl;
32-
return 1;
33-
}
34-
35-
if (a.arguments().length() > 1 ) {
36-
if (w.init(a.arguments().at(1)))
37-
return 1;
38-
39-
if (a.arguments().length() == 2) {
40-
result = w.extract();
41-
if (result)
42-
return 2;
43-
}
44-
else {
45-
for (int i = 2; i < a.arguments().length(); i++) {
46-
result = w.extract(a.arguments().at(i));
47-
if (result)
48-
returned |= (1 << (i - 1));
49-
}
50-
return returned;
51-
}
52-
21+
QCoreApplication a(argc, argv);
22+
a.setOrganizationName("CodeRush");
23+
a.setOrganizationDomain("coderush.me");
24+
a.setApplicationName("UEFIExtract");
25+
26+
UEFIExtract w;
27+
UINT8 result = ERR_SUCCESS;
28+
UINT32 returned = 0;
29+
30+
if (a.arguments().length() > 32) {
31+
std::cout << "Too many arguments" << std::endl;
32+
return 1;
33+
}
34+
35+
if (a.arguments().length() > 1 ) {
36+
if (w.init(a.arguments().at(1)))
37+
return 1;
38+
39+
if (a.arguments().length() == 2) {
40+
result = w.extract();
41+
if (result)
42+
return 2;
5343
}
5444
else {
55-
std::cout << "UEFIExtract 0.3.5" << std::endl << std::endl <<
56-
"Usage: uefiextract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl <<
57-
"Returned value is a bit mask where 0 on position N meant File with GUID_N was found and unpacked, 1 otherwise" << std::endl;
58-
return 1;
59-
}
45+
for (int i = 2; i < a.arguments().length(); i++) {
46+
result = w.extract(a.arguments().at(i));
47+
if (result)
48+
returned |= (1 << (i - 1));
49+
}
50+
return returned;
51+
}
52+
53+
}
54+
else {
55+
std::cout << "UEFIExtract 0.4.0" << std::endl << std::endl <<
56+
"Usage: uefiextract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl <<
57+
"Returned value is a bit mask where 0 on position N meant File with GUID_N was found and unpacked, 1 otherwise" << std::endl;
58+
return 1;
59+
}
6060
}

UEFIFind/uefifind_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
6464
return ERR_SUCCESS;
6565
}
6666
else {
67-
std::cout << "UEFIFind 0.1.1" << std::endl << std::endl <<
67+
std::cout << "UEFIFind 0.2.0" << std::endl << std::endl <<
6868
"Usage: uefifind {header | body | all} {list | count} pattern imagefile\n";
6969
return ERR_INVALID_PARAMETER;
7070
}

UEFIPatch/uefipatch_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
3131
result = w.patchFromFile(a.arguments().at(1));
3232
}
3333
else {
34-
std::cout << "UEFIPatch 0.2.5 - UEFI image file patching utility" << std::endl << std::endl <<
34+
std::cout << "UEFIPatch 0.3.0 - UEFI image file patching utility" << std::endl << std::endl <<
3535
"Usage: UEFIPatch image_file" << std::endl << std::endl <<
3636
"Patches will be read from patches.txt file\n";
3737
return ERR_SUCCESS;

basetypes.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* basetypes.h
22
3-
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
3+
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
44
This program and the accompanying materials
55
are licensed and made available under the terms and conditions of the BSD License
66
which accompanies this distribution. The full text of the license may be found at
@@ -17,17 +17,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
1717
#include <stdarg.h>
1818
#include <stdint.h>
1919

20-
typedef uint8_t BOOLEAN;
21-
typedef int8_t INT8;
22-
typedef uint8_t UINT8;
23-
typedef int16_t INT16;
24-
typedef uint16_t UINT16;
25-
typedef int32_t INT32;
26-
typedef uint32_t UINT32;
27-
typedef int64_t INT64;
28-
typedef uint64_t UINT64;
29-
typedef char CHAR8;
30-
typedef uint16_t CHAR16;
20+
typedef uint8_t BOOLEAN;
21+
typedef int8_t INT8;
22+
typedef uint8_t UINT8;
23+
typedef int16_t INT16;
24+
typedef uint16_t UINT16;
25+
typedef int32_t INT32;
26+
typedef uint32_t UINT32;
27+
typedef int64_t INT64;
28+
typedef uint64_t UINT64;
29+
typedef char CHAR8;
30+
typedef uint16_t CHAR16;
31+
typedef unsigned int UINTN;
3132

3233
#define CONST const
3334
#define VOID void
@@ -90,12 +91,12 @@ typedef uint16_t CHAR16;
9091
#define IN
9192
#define OUT
9293
#define EFIAPI
93-
#define EFI_STATUS UINT8
94+
#define EFI_STATUS UINTN
9495
#define EFI_SUCCESS ERR_SUCCESS
9596
#define EFI_INVALID_PARAMETER ERR_INVALID_PARAMETER
9697
#define EFI_OUT_OF_RESOURCES ERR_OUT_OF_RESOURCES
9798
#define EFI_BUFFER_TOO_SMALL ERR_BUFFER_TOO_SMALL
98-
#define EFI_ERROR(X) X
99+
#define EFI_ERROR(X) (X)
99100

100101
// Compression algorithms
101102
#define COMPRESSION_ALGORITHM_UNKNOWN 0
@@ -124,21 +125,21 @@ typedef uint16_t CHAR16;
124125
#define PATCH_MODE_BODY 1
125126

126127
// Patch types
127-
#define PATCH_TYPE_OFFSET 'O'
128-
#define PATCH_TYPE_PATTERN 'P'
128+
#define PATCH_TYPE_OFFSET 'O'
129+
#define PATCH_TYPE_PATTERN 'P'
129130

130131
// Erase polarity types
131132
#define ERASE_POLARITY_FALSE 0
132133
#define ERASE_POLARITY_TRUE 1
133134
#define ERASE_POLARITY_UNKNOWN 0xFF
134135

135136
// Search modes
136-
#define SEARCH_MODE_HEADER 1
137-
#define SEARCH_MODE_BODY 2
138-
#define SEARCH_MODE_ALL 3
137+
#define SEARCH_MODE_HEADER 1
138+
#define SEARCH_MODE_BODY 2
139+
#define SEARCH_MODE_ALL 3
139140

140141
// EFI GUID
141-
typedef struct {
142+
typedef struct _EFI_GUID {
142143
UINT8 Data[16];
143144
} EFI_GUID;
144145

@@ -148,7 +149,9 @@ typedef struct {
148149
#include <assert.h>
149150
#define ASSERT(x) assert(x)
150151

151-
//Hexarg macro
152-
#define hexarg(X, Y) arg(QString("%1").arg((X),(Y),16,QChar('0')).toUpper())
152+
//Hexarg macros
153+
#define hexarg(X) arg(QString("%1").arg((X),0,16).toUpper())
154+
#define hexarg2(X, Y) arg(QString("%1").arg((X),(Y),16,QChar('0')).toUpper())
155+
153156

154157
#endif

descriptor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* descriptor.cpp
22
3-
Copyright (c) 2013, Nikolaj Schlej. All rights reserved.
3+
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
44
This program and the accompanying materials
55
are licensed and made available under the terms and conditions of the BSD License
66
which accompanies this distribution. The full text of the license may be found at
@@ -15,13 +15,13 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
1515

1616
// Calculate address of data structure addressed by descriptor address format
1717
// 8 bit base or limit
18-
UINT8* calculateAddress8(UINT8* baseAddress, const UINT8 baseOrLimit)
18+
const UINT8* calculateAddress8(const UINT8* baseAddress, const UINT8 baseOrLimit)
1919
{
2020
return baseAddress + baseOrLimit * 0x10;
2121
}
2222

2323
// 16 bit base or limit
24-
UINT8* calculateAddress16(UINT8* baseAddress, const UINT16 baseOrLimit)
24+
const UINT8* calculateAddress16(const UINT8* baseAddress, const UINT16 baseOrLimit)
2525
{
2626
return baseAddress + baseOrLimit * 0x1000;
2727
}

descriptor.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* descriptor.h
22
3-
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
3+
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
44
This program and the accompanying materials
55
are licensed and made available under the terms and conditions of the BSD License
66
which accompanies this distribution. The full text of the license may be found at
@@ -20,7 +20,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
2020
#pragma pack(push,1)
2121

2222
// Flash descriptor header
23-
typedef struct {
23+
typedef struct _FLASH_DESCRIPTOR_HEADER {
2424
UINT8 FfVector[16]; // Must be 16 0xFFs
2525
UINT32 Signature; // 0x0FF0A55A
2626
} FLASH_DESCRIPTOR_HEADER;
@@ -33,7 +33,7 @@ typedef struct {
3333

3434
// Descriptor map
3535
// Base fields are storing bits [11:4] of actual base addresses, all other bits are 0
36-
typedef struct {
36+
typedef struct _FLASH_DESCRIPTOR_MAP {
3737
UINT8 ComponentBase; // 0x03 on most machines
3838
UINT8 NumberOfFlashChips; // Zero-based number of flash chips installed on board
3939
UINT8 RegionBase; // 0x04 on most machines
@@ -53,7 +53,7 @@ typedef struct {
5353

5454
// Component section
5555
// Flash parameters DWORD structure
56-
typedef struct {
56+
typedef struct _FLASH_PARAMETERS {
5757
UINT8 FirstChipDensity : 3;
5858
UINT8 SecondChipDensity : 3;
5959
UINT8 ReservedZero0 : 2; // Still unknown, zeros in all descriptors I have seen
@@ -81,7 +81,7 @@ typedef struct {
8181
#define FLASH_FREQUENCY_50MHZ 0x04
8282

8383
// Component section structure
84-
typedef struct {
84+
typedef struct _FLASH_DESCRIPTOR_COMPONENT_SECTION {
8585
FLASH_PARAMETERS FlashParameters;
8686
UINT8 InvalidInstruction0; // Instructions for SPI chip, that must not be executed, like FLASH ERASE
8787
UINT8 InvalidInstruction1; //
@@ -94,7 +94,7 @@ typedef struct {
9494
// Region section
9595
// All base and limit register are storing upper part of actual UINT32 base and limit
9696
// If limit is zero - region is not present
97-
typedef struct {
97+
typedef struct _FLASH_DESCRIPTOR_REGION_SECTION {
9898
UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen
9999
UINT16 FlashBlockEraseSize; // Size of block erased by single BLOCK ERASE command
100100
UINT16 BiosBase;
@@ -113,7 +113,7 @@ typedef struct {
113113
#define FLASH_BLOCK_ERASE_SIZE_64KB 0x000F
114114

115115
// Master section
116-
typedef struct {
116+
typedef struct _FLASH_DESCRIPTOR_MASTER_SECTION {
117117
UINT16 BiosId;
118118
UINT8 BiosRead;
119119
UINT8 BiosWrite;
@@ -138,14 +138,14 @@ typedef struct {
138138
#define FLASH_DESCRIPTOR_UPPER_MAP_BASE 0x0EFC
139139

140140
// Descriptor upper map structure
141-
typedef struct {
141+
typedef struct _FLASH_DESCRIPTOR_UPPER_MAP {
142142
UINT8 VsccTableBase; // Base address of VSCC Table for ME, bits [11:4]
143143
UINT8 VsccTableSize; // Counted in UINT32s
144144
UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen
145145
} FLASH_DESCRIPTOR_UPPER_MAP;
146146

147147
// VSCC table entry structure
148-
typedef struct {
148+
typedef struct _VSCC_TABLE_ENTRY {
149149
UINT8 VendorId; // JEDEC VendorID byte
150150
UINT8 DeviceId0; // JEDEC DeviceID first byte
151151
UINT8 DeviceId1; // JEDEC DeviceID second byte
@@ -162,9 +162,9 @@ typedef struct {
162162

163163
// Calculate address of data structure addressed by descriptor address format
164164
// 8 bit base or limit
165-
extern UINT8* calculateAddress8(UINT8* baseAddress, const UINT8 baseOrLimit);
165+
extern const UINT8* calculateAddress8(const UINT8* baseAddress, const UINT8 baseOrLimit);
166166
// 16 bit base or limit
167-
extern UINT8* calculateAddress16(UINT8* baseAddress, const UINT16 baseOrLimit);
167+
extern const UINT8* calculateAddress16(const UINT8* baseAddress, const UINT16 baseOrLimit);
168168

169169
// Calculate offset of region using it's base
170170
extern UINT32 calculateRegionOffset(const UINT16 base);

0 commit comments

Comments
 (0)