fiano icon indicating copy to clipboard operation
fiano copied to clipboard

How to get the GUID of a module?

Open xaionaro opened this issue 4 years ago • 1 comments

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)
}

xaionaro avatar Apr 10 '20 09:04 xaionaro

I'm ok with adding GUID() to the interface, for modules without we can just return nil

GanShun avatar Oct 09 '20 13:10 GanShun