UEFI Firmware#

exception cle.backends.uefi_firmware.UefiDriverLoadError[source]#

Bases: Exception

This error is raised (and caught internally) if the data contained in the UEFI entity tree doesn’t make sense.

class cle.backends.uefi_firmware.UefiFirmware[source]#

Bases: Backend

A UEFI firmware blob loader. Support is provided by the uefi_firmware package.

is_default = True#
classmethod is_compatible(stream)[source]#

Determine quickly whether this backend can load an object from this stream

__init__(*args, **kwargs) None[source]#
Parameters:
  • binary – The path to the binary to load

  • binary_stream – The open stream to this binary. The reference to this will be held until you call close.

  • is_main_bin – Whether this binary should be loaded as the main executable

Return type:

None

imports: typing.Dict[str, 'Relocation']#
relocs: List[Relocation]#
child_objects: List['Backend']#
exception_handlings: List[ExceptionHandling]#
function_hints: List[FunctionHint]#
memory: Clemory#
cached_content: Optional[bytes]#
class cle.backends.uefi_firmware.UefiModulePending[source]#

Bases: object

A worklist entry for the UEFI firmware loader.

name: Optional[str] = None#
pe_image: Optional[bytes] = None#
te_image: Optional[bytes] = None#
build(parent: UefiFirmware, guid: UUID) UefiModuleMixin[source]#
Return type:

UefiModuleMixin

Parameters:
__init__(name: str | None = None, pe_image: bytes | None = None, te_image: bytes | None = None) None#
Parameters:
  • name (str | None) –

  • pe_image (bytes | None) –

  • te_image (bytes | None) –

Return type:

None

class cle.backends.uefi_firmware.UefiModuleMixin[source]#

Bases: Backend

A mixin to make other kinds of backends load as UEFI modules.

__init__(*args, guid: UUID, name: str | None, **kwargs)[source]#
Parameters:
  • binary – The path to the binary to load

  • binary_stream – The open stream to this binary. The reference to this will be held until you call close.

  • is_main_bin – Whether this binary should be loaded as the main executable

  • guid (UUID) –

  • name (str | None) –

imports: typing.Dict[str, 'Relocation']#
relocs: List[Relocation]#
child_objects: List['Backend']#
exception_handlings: List[ExceptionHandling]#
function_hints: List[FunctionHint]#
memory: Clemory#
cached_content: Optional[bytes]#
class cle.backends.uefi_firmware.UefiPE[source]#

Bases: UefiModuleMixin, PE

A PE file contained in a UEFI image.

imports: typing.Dict[str, 'Relocation']#
relocs: List[Relocation]#
child_objects: List['Backend']#
exception_handlings: List[ExceptionHandling]#
function_hints: List[FunctionHint]#
memory: Clemory#
cached_content: Optional[bytes]#
class cle.backends.uefi_firmware.UefiTE[source]#

Bases: UefiModuleMixin, TE

A TE file contained in a UEFI image.

imports: typing.Dict[str, 'Relocation']#
relocs: List[Relocation]#
child_objects: List['Backend']#
exception_handlings: List[ExceptionHandling]#
function_hints: List[FunctionHint]#
memory: Clemory#
cached_content: Optional[bytes]#
class cle.backends.te.HeaderType#

Bases: tuple

HeaderType(signature, machine, number_of_sections, subsystem, stripped_size, address_of_entry_point, base_of_code, image_base, data_directory_0_virtual_address, data_directory_0_size, data_directory_1_virtual_address, data_directory_1_size)

static __new__(_cls, signature, machine, number_of_sections, subsystem, stripped_size, address_of_entry_point, base_of_code, image_base, data_directory_0_virtual_address, data_directory_0_size, data_directory_1_virtual_address, data_directory_1_size)#

Create new instance of HeaderType(signature, machine, number_of_sections, subsystem, stripped_size, address_of_entry_point, base_of_code, image_base, data_directory_0_virtual_address, data_directory_0_size, data_directory_1_virtual_address, data_directory_1_size)

address_of_entry_point#

Alias for field number 5

base_of_code#

Alias for field number 6

data_directory_0_size#

Alias for field number 9

data_directory_0_virtual_address#

Alias for field number 8

data_directory_1_size#

Alias for field number 11

data_directory_1_virtual_address#

Alias for field number 10

image_base#

Alias for field number 7

machine#

Alias for field number 1

number_of_sections#

Alias for field number 2

signature#

Alias for field number 0

stripped_size#

Alias for field number 4

subsystem#

Alias for field number 3

class cle.backends.te.SectionHeaderType#

Bases: tuple

SectionHeaderType(section_name, physical_address_virtual_size, virtual_address, size_of_raw_data, pointer_to_raw_data, pointer_to_relocations, pointer_to_line_numbers, number_of_relocations, number_of_line_numbers, characteristics)

static __new__(_cls, section_name, physical_address_virtual_size, virtual_address, size_of_raw_data, pointer_to_raw_data, pointer_to_relocations, pointer_to_line_numbers, number_of_relocations, number_of_line_numbers, characteristics)#

Create new instance of SectionHeaderType(section_name, physical_address_virtual_size, virtual_address, size_of_raw_data, pointer_to_raw_data, pointer_to_relocations, pointer_to_line_numbers, number_of_relocations, number_of_line_numbers, characteristics)

characteristics#

Alias for field number 9

number_of_line_numbers#

Alias for field number 8

number_of_relocations#

Alias for field number 7

physical_address_virtual_size#

Alias for field number 1

pointer_to_line_numbers#

Alias for field number 6

pointer_to_raw_data#

Alias for field number 4

pointer_to_relocations#

Alias for field number 5

section_name#

Alias for field number 0

size_of_raw_data#

Alias for field number 3

virtual_address#

Alias for field number 2

class cle.backends.te.TE[source]#

Bases: Backend

A “Terse Executable” format image, commonly used as part of UEFI firmware drivers.

is_default = True#
classmethod is_compatible(stream)[source]#

Determine quickly whether this backend can load an object from this stream

__init__(*args, **kwargs)[source]#
Parameters:
  • binary – The path to the binary to load

  • binary_stream – The open stream to this binary. The reference to this will be held until you call close.

  • is_main_bin – Whether this binary should be loaded as the main executable

imports: typing.Dict[str, 'Relocation']#
relocs: List[Relocation]#
child_objects: List['Backend']#
exception_handlings: List[ExceptionHandling]#
function_hints: List[FunctionHint]#
memory: Clemory#
cached_content: Optional[bytes]#