fiano
fiano copied to clipboard
How to get the GUID of a module?
Hello.
I was wondering what is the best practice to extract a GUID of a module? Right now I use this way:
func (v *visitor) Visit(f fianoUEFI.Firmware) error {
var guid *guid.GUID
switch f := f.(type) {
case *uefi.File:
guid = &f.Header.GUID
case *uefi.FirmwareVolume:
guid = &f.FVName
default:
return f.ApplyChildren(v)
}
fmt.Println(guid.String(), absOffsetOfModule(f, guid), len(f.Buf()))
return f.ApplyChildren(v)
}
Is there a better way to do it? It seems it is required to dive intofiano/pkg/uefi
internals to find a way to extract the value. May be it makes sense to add method GUID() *guid.GUID
to modules which has GUID?
func (v *visitor) Visit(f fianoUEFI.Firmware) error {
guider, ok := f.(interface{GUID() guid.GUID}) // guider, ok := f.(uefi.GUIDer)
if !ok {
return f.ApplyChildren(v)
}
fmt.Println(guider.GUID().String(), absOffsetOfModule(f, guid), len(f.Buf()))
return f.ApplyChildren(v)
}
I'm ok with adding GUID() to the interface, for modules without we can just return nil