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 FindFileFVPredicate(r string) (func(f uefi.Firmware) bool, error)
- func FindFileGUIDPredicate(r guid.GUID) func(f uefi.Firmware) bool
- func FindFilePredicate(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 Count
- type Dump
- type Extract
- type Find
- type Flatten
- type FlattenedFirmware
- type Insert
- type InsertType
- type JSON
- type ParseDir
- type Remove
- type ReplacePE32
- type Save
- type Table
- 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 FindFileFVPredicate ¶
FindFileFVPredicate is a generic predicate for searching FVs, files and UI sections.
func FindFileGUIDPredicate ¶
FindFileGUIDPredicate is a generic predicate for searching file GUIDs only.
func FindFilePredicate ¶
FindFilePredicate is a generic predicate for searching files and UI sections 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 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 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 func(f uefi.Firmware) bool
// 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 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 )
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 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
// Output
Matches []uefi.Firmware
}
Remove all firmware files with the given GUID.
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 ¶
Table prints the GUIDS, types and sizes as a compact table.
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.