-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
uefi_boot_entry.hexpat
74 lines (61 loc) · 1.65 KB
/
uefi_boot_entry.hexpat
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
// subsections in this pattern refer to subsections in the
// UEFI Specification Release 2.10 from Aug 29 2022
#pragma author iTrooz
#pragma description UEFI Boot Entry (Load option)
import std.io;
import type.guid;
// subsection 10.3.5.1
struct HARD_DRIVE {
u32 partitionNumber;
u64 partitionStart;
u64 partitionSize;
type::GUID partitionSig;
u8 format;
u8 sigType;
};
// subsection 10.3.5.4
struct FILE_PATH {
char16 path[];
};
// subsection 10.3.1
enum MEDIA_DEVICE_PATH_SUBTYPE : u8 {
HARD_DRIVE = 0x01,
FILE_PATH = 0x04,
};
enum DEVICE_PATH_TYPE : u8 {
MEDIA_DEVICE_PATH = 0x04,
};
// subsection 10.2
// EFI_DEVICE_PATH_PROTOCOL
struct DEVICE_PATH {
u8 type;
u8 subtype;
// length of this DEVICE_PATH structure
u16 length;
// the size of the data is the size of the structure minus the fields we know.
// not always used
u16 dataSize = length-1-1-2;
match (type, subtype) {
(DEVICE_PATH_TYPE::MEDIA_DEVICE_PATH, MEDIA_DEVICE_PATH_SUBTYPE::HARD_DRIVE): HARD_DRIVE data;
(DEVICE_PATH_TYPE::MEDIA_DEVICE_PATH, MEDIA_DEVICE_PATH_SUBTYPE::FILE_PATH): FILE_PATH data;
(_, _): u8 data[dataSize];
}
};
// subsections 3.1.3
// EFI_LOAD_OPTION
struct LOAD_OPTION {
u32 attributes;
// length of the filePathList data
u16 filePathLength;
char16 description[];
u64 startOffset = $;
DEVICE_PATH filePathList[while($ - startOffset < filePathLength)];
u8 optionalData;
};
// on Linux, variables are found in /sys/firmware/efi/efivars,
// and will be prefixed by their attributes
struct EFI_VAR {
u32 attributes;
LOAD_OPTION loadOption;
};
EFI_VAR data @0x0;