Documentation
¶
Overview ¶
Package visitors uses the Visitor interface to recursively apply an operation over the firmware image. Also, functions are exported for using the visitors through the command line.
Index ¶
- func ExecuteCLI(f uefi.Firmware, v []uefi.Visitor) error
- func FindDXEFV(f uefi.Firmware) (*uefi.FirmwareVolume, error)
- func FindEnclosingFV(f uefi.Firmware, file *uefi.File) (*uefi.FirmwareVolume, error)
- func FindExactlyOne(f uefi.Firmware, pred func(f uefi.Firmware) bool) (uefi.Firmware, error)
- func FindFileFVPredicate(r string) (func(f uefi.Firmware) bool, error)
- func FindFilePredicate(r string) (func(f uefi.Firmware) bool, error)
- func FindNVarPredicate(r string) (func(f uefi.Firmware) bool, error)
- func ListCLI() string
- func ParseCLI(args []string) ([]uefi.Visitor, error)
- func RegisterCLI(name string, help string, numArgs int, ...)
- type Assemble
- type Cat
- type Comment
- type Count
- type CreateFV
- type DXECleaner
- type Dump
- type Extract
- type Find
- type FindPredicate
- type Flatten
- type FlattenedFirmware
- type Insert
- type InsertType
- type JSON
- type NVRamCompact
- type NVarInvalidate
- type ParseDir
- type Remove
- type Repack
- type ReplacePE32
- type Save
- type Table
- type TightenME
- type Validate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteCLI ¶
ExecuteCLI applies each Visitor over the firmware in sequence.
func FindDXEFV ¶
func FindDXEFV(f uefi.Firmware) (*uefi.FirmwareVolume, error)
FindDXEFV is a helper function to quickly retrieve the firmware volume that contains the DxeCore.
func FindEnclosingFV ¶
FindEnclosingFV finds the FV that contains a file.
func FindExactlyOne ¶
FindExactlyOne does a find using a supplied predicate and errors if there's more than one.
func FindFileFVPredicate ¶
FindFileFVPredicate is a generic predicate for searching FVs, files and UI sections.
func FindFilePredicate ¶
FindFilePredicate is a generic predicate for searching files and UI sections only.
func FindNVarPredicate ¶
FindNVarPredicate is a generic predicate for searching NVar only.
func ListCLI ¶
func ListCLI() string
ListCLI prints out the help entries in the visitor struct as a newline-separated string in the form:
name: help
func ParseCLI ¶
ParseCLI constructs a list of visitors from the given CLI argument list. TODO: display some type of help message
func RegisterCLI ¶
func RegisterCLI(name string, help string, numArgs int, createVisitor func([]string) (uefi.Visitor, error))
RegisterCLI registers a function `createVisitor` to be called when parsing the arguments with `ParseCLI`. For a Visitor to be accessible from the command line, it should have an init function which registers a `createVisitor` function here.
Types ¶
type Assemble ¶
type Assemble struct {
// contains filtered or unexported fields
}
Assemble reconstitutes the firmware tree assuming that the leaf node buffers are accurate
type Cat ¶
type Cat struct { // Input Predicate func(f uefi.Firmware) bool // Output io.Writer Matches []uefi.Firmware }
Cat concatenates all RAW data sections from a file into a single byte slice.
type Comment ¶
Comment holds the io.Writer and args for a comment
type Count ¶
type Count struct { // Optionally write result as JSON. W io.Writer `json:"-"` // Output FirmwareTypeCount map[string]int FileTypeCount map[string]int SectionTypeCount map[string]int }
Count counts the number of each firmware type.
type CreateFV ¶
type CreateFV struct { AbsOffset uint64 Size uint64 Name guid.GUID // contains filtered or unexported fields }
CreateFV creates a firmware volume at given offset
type DXECleaner ¶
type DXECleaner struct { // This function tests whether the firmware boots. The return values can be: // // - (false, nil): The firmware was tested and failed to boot. // - (false, err): The firmware was tested and failed to boot due to err. // - (true, nil): The firmware was tested and booted. // - (true, err): Failed to test the firmware due to err. Test func(f uefi.Firmware) (bool, error) // Predicate to determine whether a DXE can be removed. Predicate FindPredicate // List of GUIDs which were removed. Removals []guid.GUID // Logs are written to this writer. W io.Writer }
DXECleaner removes DXEs sequentially in multiple rounds. Each round, an attempt is made to remove each DXE. The Test function determines if the removal was successful. Additional rounds are performed until all DXEs are removed.
type Dump ¶
type Dump struct { // Input Predicate func(f uefi.Firmware) bool // Output // The file is written to this writer. W io.Writer }
Dump a firmware file using a GUID or a name
type Extract ¶
Extract extracts any Firmware node to DirPath
type Find ¶
type Find struct { // Input // Only when this functions returns true will the file appear in the // `Matches` slice. Predicate FindPredicate // Output Matches []uefi.Firmware // JSON is written to this writer. W io.Writer // contains filtered or unexported fields }
Find a firmware file given its name or GUID.
type FindPredicate ¶
FindPredicate is used to filter matches in the Find visitor.
func FindAndPredicate ¶
func FindAndPredicate(predicate1 FindPredicate, predicate2 FindPredicate) FindPredicate
FindAndPredicate is a generic predicate which takes the logical OR of two existing predicates.
func FindFileGUIDPredicate ¶
func FindFileGUIDPredicate(r guid.GUID) FindPredicate
FindFileGUIDPredicate is a generic predicate for searching file GUIDs only.
func FindFileTypePredicate ¶
func FindFileTypePredicate(t uefi.FVFileType) FindPredicate
FindFileTypePredicate is a generic predicate for searching file types only.
func FindNotPredicate ¶
func FindNotPredicate(predicate FindPredicate) FindPredicate
FindNotPredicate is a generic predicate which takes the logical NOT of an existing predicate.
type Flatten ¶
type Flatten struct { // Optionally write result as JSON. W io.Writer // Outputted flattened tree. List []FlattenedFirmware // contains filtered or unexported fields }
Flatten places all nodes into a single slice and removes their children. Each node contains the index of its parent (the root node's parent is itself). This format is suitable for insertion into a database.
type FlattenedFirmware ¶
FlattenedFirmware appears in the Flatten.List, contains the index of the parrent and has no children.
type Insert ¶
type Insert struct { // Input Predicate func(f uefi.Firmware) bool NewFile *uefi.File InsertType // Matched File FileMatch uefi.Firmware }
Insert inserts a firmware file into an FV
type InsertType ¶
type InsertType int
InsertType defines the insert type operation that is requested
const ( // InsertFront inserts a file at the beginning of the firmware volume, // which is specified by 1) FVname GUID, or (File GUID/File name) of a file // inside that FV. InsertFront InsertType = iota // InsertEnd inserts a file at the end of the specified firmware volume. InsertEnd // These two specify a File to insert before or after // InsertAfter inserts after the specified file, // which is specified by a File GUID or File name. InsertAfter // InsertBefore inserts before the specified file. InsertBefore // InsertDXE inserts into the Dxe Firmware Volume. This works by searching // for the DxeCore first to identify the Dxe Firmware Volume. InsertDXE // ReplaceFFS replaces the found file with the new FFS. This is used // as a shortcut for remove and insert combined, but also when we want to make // sure that the starting offset of the new file is the same as the old. ReplaceFFS )
Insert Types
func (InsertType) String ¶
func (i InsertType) String() string
String creates a string representation for the insert type.
type JSON ¶
JSON prints any Firmware node as JSON.
type NVRamCompact ¶
type NVRamCompact struct { }
NVRamCompact compact nvram content by removing old version of variables
type NVarInvalidate ¶
type NVarInvalidate struct { // Input Predicate func(f uefi.Firmware) bool // Output Matches []uefi.Firmware // logs are written to this writer. W io.Writer }
NVarInvalidate set NVar as Invalid
type ParseDir ¶
type ParseDir struct {
BasePath string
}
ParseDir creates the firmware tree and reads the binaries from the provided directory
type Remove ¶
type Remove struct { // Input Predicate func(f uefi.Firmware) bool Pad bool RemoveDxes bool // I hate this, but there's no good way to work around our current structure // Output Matches []uefi.Firmware // Calling this function undoes the removals performed by this visitor. Undo func() // logs are written to this writer. W io.Writer }
Remove all firmware files with the given GUID.
type Repack ¶
type Repack struct { // Input Predicate func(f uefi.Firmware) bool // Matched File FileMatch *uefi.File }
Repack repacks a per file compressed FV into a singularly compressed nested FV
type ReplacePE32 ¶
type ReplacePE32 struct { // Input Predicate func(f uefi.Firmware) bool NewPE32 []byte // Output Matches []uefi.Firmware }
ReplacePE32 replaces PE32 sections with NewPE32 for all files matching Predicate.
type Save ¶
type Save struct {
DirPath string
}
Save calls Assemble, then outputs the top image to a file.
type Table ¶
type Table struct { W *tabwriter.Writer Scan bool Layout bool Depth int // contains filtered or unexported fields }
Table prints the GUIDS, types and sizes as a compact table.
type TightenME ¶
type TightenME struct {
// contains filtered or unexported fields
}
TightenME tighten ME's belt to give more room for LinuxBoot This changes the ME Region Limit to fit the actual content as described in the ME partitions. Also update the BIOS Region Base to start just after the ME Region
type Validate ¶
type Validate struct { // An optional Writer for writing errors when validation is complete. // When the writer it set, Run will also call os.Exit(1) upon finding // an error. W io.Writer // List of validation errors. Errors []error }
Validate performs extra checks on the firmware image.