-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.go
57 lines (46 loc) · 1023 Bytes
/
image.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) WithSecure Corporation
//
// Use of this source code is governed by the license
// that can be found in the LICENSE file.
package uefi
import (
"io/fs"
)
// EFI Boot Services offsets
const (
loadImage = 0xc8
startImage = 0xd0
)
// LoadImage calls EFI_BOOT_SERVICES.LoadImage().
func (s *BootServices) LoadImage(boot int, root *FS, name string) (imageHandle uint64, err error) {
buf, err := fs.ReadFile(root, name)
if err != nil {
return
}
_, _, devicePath, err := root.FilePath(name)
if err != nil {
return
}
status := callService(s.base+loadImage,
[]uint64{
uint64(boot),
s.imageHandle,
ptrval(&devicePath[0]),
ptrval(&buf[0]),
uint64(len(buf)),
ptrval(&imageHandle),
},
)
return imageHandle, parseStatus(status)
}
// StartImage calls EFI_BOOT_SERVICES.StartImage().
func (s *BootServices) StartImage(imageHandle uint64) (err error) {
status := callService(s.base+startImage,
[]uint64{
imageHandle,
0,
0,
},
)
return parseStatus(status)
}