This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
forked from donovan6000/Universal-IFR-Extractor
-
Notifications
You must be signed in to change notification settings - Fork 48
/
EFI.h
433 lines (371 loc) · 9.4 KB
/
EFI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
// Header guard
#ifndef EFI_H
#define EFI_H
// Header files
#include <string.h>
#include <vector>
#include <stdint.h>
#include <stdlib.h>
using namespace std;
// Global definitions
#define EFI_IFR_FORM_OP '\x01'
#define EFI_IFR_SUBTITLE_OP '\x02'
#define EFI_IFR_TEXT_OP '\x03'
#define EFI_IFR_GRAPHIC_OP '\x04'
#define EFI_IFR_ONE_OF_OP '\x05'
#define EFI_IFR_CHECKBOX_OP '\x06'
#define EFI_IFR_NUMERIC_OP '\x07'
#define EFI_IFR_PASSWORD_OP '\x08'
#define EFI_IFR_ONE_OF_OPTION_OP '\x09'
#define EFI_IFR_SUPPRESS_IF_OP '\x0A'
#define EFI_IFR_END_FORM_OP '\x0B'
#define EFI_IFR_HIDDEN_OP '\x0C'
#define EFI_IFR_END_FORM_SET_OP '\x0D'
#define EFI_IFR_FORM_SET_OP '\x0E'
#define EFI_IFR_REF_OP '\x0F'
#define EFI_IFR_END_ONE_OF_OP '\x10'
#define EFI_IFR_END_OP EFI_IFR_END_ONE_OF_OP
#define EFI_IFR_INCONSISTENT_IF_OP '\x11'
#define EFI_IFR_EQ_ID_VAL_OP '\x12'
#define EFI_IFR_EQ_ID_ID_OP '\x13'
#define EFI_IFR_EQ_ID_LIST_OP '\x14'
#define EFI_IFR_AND_OP '\x15'
#define EFI_IFR_OR_OP '\x16'
#define EFI_IFR_NOT_OP '\x17'
#define EFI_IFR_END_IF_OP '\x18'
#define EFI_IFR_GRAYOUT_IF_OP '\x19'
#define EFI_IFR_DATE_OP '\x1A'
#define EFI_IFR_TIME_OP '\x1B'
#define EFI_IFR_STRING_OP '\x1C'
#define EFI_IFR_LABEL_OP '\x1D'
#define EFI_IFR_SAVE_DEFAULTS_OP '\x1E'
#define EFI_IFR_RESTORE_DEFAULTS_OP '\x1F'
#define EFI_IFR_BANNER_OP '\x20'
#define EFI_IFR_INVENTORY_OP '\x21'
#define EFI_IFR_EQ_VAR_VAL_OP '\x22'
#define EFI_IFR_ORDERED_LIST_OP '\x23'
#define EFI_IFR_VARSTORE_OP '\x24'
#define EFI_IFR_VARSTORE_SELECT_OP '\x25'
#define EFI_IFR_VARSTORE_SELECT_PAIR_OP '\x26'
#define EFI_IFR_TRUE_OP '\x27'
#define EFI_IFR_FALSE_OP '\x28'
#define EFI_IFR_GT_OP '\x29'
#define EFI_IFR_GE_OP '\x2A'
#define EFI_IFR_OEM_DEFINED_OP '\x2B'
#define EFI_IFR_LAST_OPCODE EFI_IFR_OEM_DEFINED_OP
#define EFI_IFR_OEM_OP '\xFE'
#define EFI_IFR_NV_ACCESS_COMMAND '\xFF'
// Classes/structs
struct EFI_HII_PACK_HEADER {
uint32_t offset;
uint32_t length;
uint16_t type;
};
struct EFI_IFR_STRING_PACK {
EFI_HII_PACK_HEADER header;
uint32_t numberOfStrings;
uint32_t attributes;
string language;
uint32_t structureOffset;
};
struct EFI_IFR_FORM_SET_PACK {
EFI_HII_PACK_HEADER header;
uint16_t titleString;
uint32_t usingStringPackage;
string title;
};
struct EFI_IFR_OP_HEADER {
uint32_t offset;
uint8_t opcode;
uint8_t length;
};
struct EFI_IFR_FORM_SET {
EFI_IFR_OP_HEADER header;
string guid;
uint16_t titleString;
uint16_t helpString;
uint64_t callbackHandle;
uint16_t mainClass;
uint16_t subClass;
uint16_t nvDataSize;
};
struct EFI_IFR_FORM {
EFI_IFR_OP_HEADER header;
uint16_t formId;
uint16_t titleString;
};
struct EFI_IFR_LABEL {
EFI_IFR_OP_HEADER header;
uint16_t labelId;
};
struct EFI_IFR_SUBTITLE {
EFI_IFR_OP_HEADER header;
uint16_t subtitleString;
};
struct EFI_IFR_TEXT {
EFI_IFR_OP_HEADER header;
uint16_t helpString;
uint16_t primaryTextString;
uint16_t secondaryTextString;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_REF {
EFI_IFR_OP_HEADER header;
uint16_t formId;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_END_FORM {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_END_FORM_SET {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_ONE_OF {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t promptString;
uint16_t helpString;
};
struct EFI_IFR_CHECKBOX {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_ORDERED_LIST {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t maximumEntries;
uint16_t promptString;
uint16_t helpString;
};
struct EFI_IFR_CHECK_BOX {
EFI_IFR_OP_HEADER header;
uint16_t option;
uint16_t value;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_ONE_OF_OPTION {
EFI_IFR_OP_HEADER header;
uint16_t optionString;
uint16_t value;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_NUMERIC {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
uint16_t minimum;
uint16_t maximum;
uint16_t step;
uint16_t defaultValue;
};
struct EFI_IFR_TIME {
EFI_IFR_NUMERIC hour;
EFI_IFR_NUMERIC minute;
EFI_IFR_NUMERIC second;
};
struct EFI_IFR_DATE {
EFI_IFR_NUMERIC year;
EFI_IFR_NUMERIC month;
EFI_IFR_NUMERIC day;
};
struct EFI_IFR_PASSWORD {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
uint8_t minimumSize;
uint8_t maximumSize;
uint16_t encoding;
};
struct EFI_IFR_STRING {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
uint8_t minimumSize;
uint8_t maximumSize;
};
struct EFI_IFR_END_ONE_OF {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_HIDDEN {
EFI_IFR_OP_HEADER header;
uint16_t value;
uint16_t key;
};
struct EFI_IFR_SUPPRESS {
EFI_IFR_OP_HEADER header;
uint8_t flags;
};
struct EFI_IFR_GRAYOUT {
EFI_IFR_OP_HEADER header;
uint8_t flags;
};
struct EFI_IFR_INCONSISTENT {
EFI_IFR_OP_HEADER header;
uint16_t popup;
uint8_t flags;
};
struct EFI_IFR_EQ_ID_VAL {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t value;
};
struct EFI_IFR_EQ_ID_LIST {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t width;
uint16_t listLength;
vector<uint16_t> valueList;
};
struct EFI_IFR_EQ_ID_ID {
EFI_IFR_OP_HEADER header;
uint16_t primaryQuestionId;
uint8_t width;
uint16_t secondaryQuestionId;
};
struct EFI_IFR_EQ_VAR_VAL {
EFI_IFR_OP_HEADER header;
uint16_t variableId;
uint16_t value;
};
struct EFI_IFR_AND {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_OR {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_NOT {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_END_IF {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_SAVE_DEFAULTS {
EFI_IFR_OP_HEADER header;
uint16_t formId;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_RESTORE_DEFAULTS {
EFI_IFR_OP_HEADER header;
uint16_t formId;
uint16_t promptString;
uint16_t helpString;
uint8_t flags;
uint16_t key;
};
struct EFI_IFR_INVENTORY {
EFI_IFR_OP_HEADER header;
uint16_t helpString;
uint16_t primaryTextString;
uint16_t secondaryTextString;
};
struct EFI_IFR_VARSTORE {
EFI_IFR_OP_HEADER header;
string guid;
uint16_t varId;
uint16_t size;
// 255 (max size allowed by EFI_IFR_OP_HEADER:Length - 2 - 16 - 2 - 2 = 233 bytes max name (?)
uint8_t name[233];
};
struct EFI_IFR_VARSTORE_SELECT {
EFI_IFR_OP_HEADER header;
uint16_t varId;
};
struct EFI_IFR_VARSTORE_SELECT_PAIR {
EFI_IFR_OP_HEADER header;
uint16_t primaryVarId;
uint16_t secondaryVarId;
};
struct EFI_IFR_TRUE {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_FALSE {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_GT {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_GE {
EFI_IFR_OP_HEADER header;
};
struct EFI_IFR_BANNER {
EFI_IFR_OP_HEADER header;
uint16_t titleString;
uint16_t lineNumber;
uint8_t alignment;
};
struct EFI_IFR_NV_DATA {
EFI_IFR_OP_HEADER header;
uint16_t questionId;
uint8_t storageWidth;
vector<char> data;
};
// Function prototypes
/*
Name: getEFIStringPackages
Purpose: Gets EFI string packages
*/
void getEFIStringPackages(vector<EFI_IFR_STRING_PACK> &stringPackages, const string &buffer);
/*
Name: displayEFIStringPackages
Purpose: Displays EFI string packages
*/
void displayEFIStringPackages(const vector<EFI_IFR_STRING_PACK> &stringPackages);
/*
Name: getEFIStrings
Purpose: Gets strings from string package
*/
void getEFIStrings(vector<EFI_IFR_STRING_PACK> &stringPackages, vector<string> &strings, const string &buffer);
/*
Name: displayEFIStrings
Purpose: Displays EFI strings
*/
void displayEFIStrings(const vector<string> &strings);
/*
Name: getEFIFormSets
Purpose: Gets EFI form sets
*/
void getEFIFormSets(vector<EFI_IFR_FORM_SET_PACK> &formSets, const string &buffer, const vector<EFI_IFR_STRING_PACK> &stringPackages, const vector<string> &strings);
/*
Name: displayEFIFormSets
Purpose: Displays EFI form sets
*/
void displayEFIFormSets(const vector<EFI_IFR_FORM_SET_PACK> &formSets);
/*
Name: generateEFIIFRDump
Purpose: Generates EFI IFR dump
*/
void generateEFIIFRDump(const string &outputFile, const vector<EFI_IFR_STRING_PACK> &stringPackages, const vector<EFI_IFR_FORM_SET_PACK> &formSets, const string &buffer, const vector<string> &strings);
/*
Name: endEFICondition
Purpose: Returns if opcode ends a conditional statement
*/
bool endEFICondition(const string &buffer, uint32_t j);
#endif