Documentation ¶
Overview ¶
package efi implements support for parsing and reassembling EFI Firmware Volumes, as used in some Apple device firmware components.
This library is similar in functionality and scope to UEFITool or uefi-firmware-parser. However, some differences remain:
- This implements the small subset of EFI FV as used by Apple devices, and is only tested against them. This is in contrast to UEFITool and uefi-firmware-parser which attempt to parse all possible images out there.
- This implementation is in pure Go, with Tiano compression routines implemented via WebAssembly (emscripten-compiled C from EDK2). This is in contrast to uefi-firmware-parser and UEFITool which link against a binary build of the functionality from EDK2.
- This implementation focuses on bit-perfect reconstruction of images. A back-to-back Read-to-Serialize of any image should result in exactly the same data outputted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FirmwareFile ¶
type FirmwareFile struct { FirmwareFileHeader Sections []Section // ReadOffset is the offset within the volume at which the file has been // encountered. ReadOffset int }
FirmwareFile represents an EFI Firmware File within a Firmware Volume.
func (*FirmwareFile) Serialize ¶
func (f *FirmwareFile) Serialize() ([]byte, error)
type FirmwareFileHeader ¶
type FirmwareFileHeader struct { GUID GUID // ChecksumHeader is recalculated when Serialize is called. ChecksumHeader uint8 // ChecksumData is recalculated when Serialize is called. ChecksumData uint8 FileType FileType Attributes uint8 // Size is recalculated when Serialize is called. Size Uint24 State uint8 }
FirmwareFileHeader as per EFI standard.
type FirmwareVolumeHeader ¶
type FirmwareVolumeHeader struct { Reserved [16]byte GUID GUID // Length is recalculated when Serialize is called. Length uint64 Signature [4]byte AttributeMask uint32 HeaderLength uint16 // Checksum is recalculated when Serialize is called. Checksum uint16 ExtHeaderOffset uint16 Reserved2 uint8 Revision uint8 }
FirmwareVolumeHeader as per EFI spec.
type NestedImageSection ¶
type NestedImageSection struct { Vol *Volume // contains filtered or unexported fields }
func (*NestedImageSection) Raw ¶
func (c *NestedImageSection) Raw() []byte
func (*NestedImageSection) Serialize ¶
func (c *NestedImageSection) Serialize() ([]byte, error)
func (*NestedImageSection) SetRaw ¶
func (c *NestedImageSection) SetRaw(d []byte)
func (*NestedImageSection) Sub ¶
func (c *NestedImageSection) Sub() []SectionOrFile
type NestedReader ¶
type NestedReader struct {
// contains filtered or unexported fields
}
NestedReader is a io.Reader which implements carving out a subelement of itself into another io.Reader. It also allows keeping track of the position of a reader within the original backing data.
func NewNestedReader ¶
func NewNestedReader(underlying []byte) *NestedReader
func (*NestedReader) Advance ¶
func (r *NestedReader) Advance(count int)
func (*NestedReader) Len ¶
func (r *NestedReader) Len() int
func (*NestedReader) Sub ¶
func (r *NestedReader) Sub(start, length int) *NestedReader
func (*NestedReader) TellGlobal ¶
func (r *NestedReader) TellGlobal() int
type Section ¶
type Section interface { // Header returns the common header of this section. Header() *commonSectionHeader // Sub returns all Sections nested within this section, if applicable. Sub() []SectionOrFile // Serialize serializes this section into a binary. Serialize() ([]byte, error) // Raw returns the inner data within this section, if this section is a // PE32/TE/DXE/Raw section. Raw() []byte // SetRaw overrides the inner data within this section, if this section is // a PE32/TE/DXE/Raw section. SetRaw([]byte) }
Section is the interface implemented by all EFI Firmware Volume File Sections.
type SectionOrFile ¶
type SectionOrFile struct { Section Section File *FirmwareFile }
type SectionType ¶
type SectionType uint8
const ( SectionTypeCompression SectionType = 1 SectionTypeGUIDDefined SectionType = 2 SectionTypePE32 SectionType = 16 SectionTypeTE SectionType = 18 SectionTypeDXEDEPEX SectionType = 19 SectionTypeVersion SectionType = 20 SectionTypeUserInterface SectionType = 21 SectionTypeFirmwareVolumeImage SectionType = 23 SectionTypeRaw SectionType = 25 )
func (SectionType) String ¶
func (s SectionType) String() string
type Volume ¶
type Volume struct { FirmwareVolumeHeader Files []*FirmwareFile // Custom is trailing data at the end of the Volume. Custom []byte MinSize int }
Volume is an EFI Firmware Volume. It contains an array of Files, all of which contain recursively nested Sections.
func ReadVolume ¶
func ReadVolume(r *NestedReader) (*Volume, error)
Parse an EFI Firmware Volume from a NestedReader. After parsing, all files and sections within them will be available. These can then be arbitrarily modified, and Serialize can be called on the resulting Volume to rebuild a binary.
Directories ¶
Path | Synopsis |
---|---|
package compression implements EFI compression/decompression routines by calling out into edk2 Tiano{Dec,C}ompres functions compiled into WebAssembly.
|
package compression implements EFI compression/decompression routines by calling out into edk2 Tiano{Dec,C}ompres functions compiled into WebAssembly. |