Created
September 5, 2019 21:42
-
-
Save roblabla/d00d5fc46f92547cfdb03d1971a31ba5 to your computer and use it in GitHub Desktop.
What am I doing with my life
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------ | |
//--- 010 Editor v9.0.2 Binary Template | |
// | |
// File: | |
// Authors: | |
// Version: | |
// Purpose: | |
// Category: | |
// File Mask: | |
// ID Bytes: | |
// History: | |
//------------------------------------------------ | |
struct EFI_FV_BLOCK_MAP_ENTRY { | |
uint32 num_blocks; | |
uint32 length; | |
}; | |
struct EFI_FIRMWARE_VOLUME { | |
byte zero_vector[16]; | |
byte file_system_guid[16]; | |
uint64 fv_length; | |
uint32 signature; | |
uint32 attributes; | |
uint16 header_length; | |
uint16 checksum; | |
uint16 ext_header_offset; | |
byte reserved[1]; | |
// Terminated by an entry of {0, 0} | |
// Too lazy to do the actual parser, I don't use it. | |
// I just seek to header_length after reading. | |
EFI_FV_BLOCK_MAP_ENTRY block_map[1]; | |
}; | |
struct EFI_TIME { | |
uint16 year; | |
byte month; | |
byte day; | |
byte hour; | |
byte minute; | |
byte second; | |
byte pad1; | |
uint32 nanosecond; | |
int16 timezone; | |
byte daylight; | |
byte pad2; | |
}; | |
struct VARIABLE_STORE_HEADER { | |
byte signature[16]; | |
uint32 size; | |
byte format; | |
byte state; | |
uint16 reserved; | |
uint32 reserved1; | |
}; | |
struct VARIABLE_HEADER { | |
uint16 startid; | |
byte state; | |
byte reserved; | |
uint32 attributes; | |
uint32 name_size; | |
uint32 data_size; | |
byte vendorguid[16]; | |
}; | |
struct AUTHENTICATED_VARIABLE_HEADER { | |
uint16 startid; | |
byte state; | |
byte reserved; | |
uint32 attributes; | |
uint64 monotonic_count; | |
EFI_TIME timestamp; | |
uint32 pub_key_index; | |
uint32 name_size; | |
uint32 data_size; | |
byte vendor_guid[16]; | |
}; | |
EFI_FIRMWARE_VOLUME volume; | |
FSeek(volume.header_length); | |
VARIABLE_STORE_HEADER variable_header; | |
local byte EFI_VARIABLE_GUID[16] = | |
{ 0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41, 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }; | |
local byte EFI_AUTHENTICATED_VARIABLE_GUID[16] = | |
{ 0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43, 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }; | |
typedef struct { | |
if (variable_header.signature == EFI_AUTHENTICATED_VARIABLE_GUID) { | |
AUTHENTICATED_VARIABLE_HEADER header; | |
} else if (variable_header.signature == EFI_VARIABLE_GUID) { | |
VARIABLE_HEADER header; | |
} else { | |
Printf("Unsupported OVMF_VARS file!\n"); | |
} | |
wchar_t name[header.name_size / 2]; | |
byte data[header.data_size]; | |
byte padding[((FTell() + 4 - 1) & (~(4 - 1))) - FTell()]; | |
} VARIABLE <read=printvalue>; | |
string printvalue(VARIABLE &var) { | |
string s; | |
SPrintf(s, "%s", var.name); | |
return s; | |
} | |
#define VAR_ADDED 0x3f | |
local int curpos; | |
while (FTell() < variable_header.size) { | |
curpos = FTell(); | |
AUTHENTICATED_VARIABLE_HEADER var<hidden=true>; | |
if (var.startid == 0x55AA && var.state == VAR_ADDED) { | |
FSeek(curpos); | |
VARIABLE vars<fgcolor=0x00FF00>; | |
} else if (var.startid == 0x55AA) { | |
FSeek(curpos); | |
VARIABLE vars<hidden=false,fgcolor=0x0000FF>; | |
} else { | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment