Uefi multi phase
uefi_multi_phase ¶
Module for working with UEFI Authenticated Variable Atrributes.
EfiVariableAttributes ¶
Object representing the different efi variable attributes.
__init__ ¶
__init__(
attributes: Union[int, str] = 0, decodefs: IO = None
) -> EfiVariableAttributes
Creates a EfiVariableAttributes object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attributes |
int | str
|
attributes to parse |
0
|
decodefs |
BytesIO
|
filestream to decode from |
None
|
Returns:
Type | Description |
---|---|
EfiVariableAttributes
|
None |
update ¶
update(attributes: Union[int, str] = 0) -> None
Updates instance to provided attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attributes |
Union[int, str]
|
attributes to parse |
0
|
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
TypeError
|
If the attribute provided is neither int or string |
parse_attributes_str
staticmethod
¶
parse_attributes_str(attributes_str: str) -> int
Converts attributes string into integer representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attributes_str |
str
|
string containing attributes that have been comma delimated. |
required |
Examples:
parse_attributes_str("EFI_VARIABLE_BOOTSERVICE_ACCESS,EFI_VARIABLE_NON_VOLATILE")
parse_attributes_str("EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE")
parse_attributes_str("BS,NV")
parse_attributes_str("BS, NV")
Returns:
Type | Description |
---|---|
int
|
Integer representation of the attributes |
Raises:
Type | Description |
---|---|
ValueError
|
if the attribute provided is not supported |
decode ¶
decode(fs: IO) -> int
Reads in attributes from a file stream.
This updates the attributes value of the object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fs |
BytesIO
|
file stream to read from |
required |
Examples
with open (my_data_file, 'rb') as f:
attributes = EfiVariableAttributes()
attributes.decode(f)
Returns:
Type | Description |
---|---|
int
|
Attributes in integer form |
encode ¶
encode() -> bytes
Returns the attributes as a packed structure.
Examples
my_byte_array = b""
attributes = EfiVariableAttributes("EFI_VARIABLE_NON_VOLATILE")
my_byte_array += attributes.encode()
Returns:
Type | Description |
---|---|
bytes
|
Attributes in packed byte form |
get_short_string ¶
get_short_string() -> str
Short form string representation of the attributes.
Examples
attributes = EfiVariableAttributes("EFI_VARIABLE_NON_VOLATILE")
attributes.get_short_string() # "NV"
Returns:
Type | Description |
---|---|
str
|
Short form of the attributes (Ex. "BS,NV") |
__str__ ¶
__str__() -> str
String representation of the attributes.
Returns:
Type | Description |
---|---|
str
|
Long form of the attributes (Ex. "EFI_VARIABLE_BOOTSERVICE_ACCESS,EFI_VARIABLE_NON_VOLATILE") |