Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the GUID of a module? #315

Open
xaionaro opened this issue Apr 10, 2020 · 1 comment
Open

How to get the GUID of a module? #315

xaionaro opened this issue Apr 10, 2020 · 1 comment

Comments

@xaionaro
Copy link
Member

xaionaro commented Apr 10, 2020

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 xaionaro changed the title How to extract GUID? How to get the GUID of a module? Apr 10, 2020
@GanShun
Copy link
Member

GanShun commented Oct 9, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants