Debian Codegraph @

types_windows.go

raw symbols SCIP
1 package ebpf
2
3 import (
4 "fmt"
5 "os"
6
7 "golang.org/x/sys/windows"
8
9 "github.com/cilium/ebpf/internal/efw"
10 "github.com/cilium/ebpf/internal/platform"
11 )
12
13 // WindowsProgramTypeForGUID resolves a GUID to a ProgramType.
14 //
15 // The GUID must be in the form of "{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}".
16 //
17 // Returns an error wrapping [os.ErrNotExist] if the GUID is not recignized.
18 func WindowsProgramTypeForGUID(guid string) (ProgramType, error) {
19 progTypeGUID, err := windows.GUIDFromString(guid)
20 if err != nil {
21 return 0, fmt.Errorf("parse GUID: %w", err)
22 }
23
24 rawProgramType, err := efw.EbpfGetBpfProgramType(progTypeGUID)
25 if err != nil {
26 return 0, fmt.Errorf("get program type: %w", err)
27 }
28
29 if rawProgramType == 0 {
30 return 0, fmt.Errorf("program type not found for GUID %v: %w", guid, os.ErrNotExist)
31 }
32
33 return ProgramTypeForPlatform(platform.Windows, rawProgramType)
34 }
35
36 // WindowsAttachTypeForGUID resolves a GUID to an AttachType.
37 //
38 // The GUID must be in the form of "{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}".
39 //
40 // Returns an error wrapping [os.ErrNotExist] if the GUID is not recignized.
41 func WindowsAttachTypeForGUID(guid string) (AttachType, error) {
42 attachTypeGUID, err := windows.GUIDFromString(guid)
43 if err != nil {
44 return 0, fmt.Errorf("parse GUID: %w", err)
45 }
46
47 rawAttachType, err := efw.EbpfGetBpfAttachType(attachTypeGUID)
48 if err != nil {
49 return 0, fmt.Errorf("get attach type: %w", err)
50 }
51
52 if rawAttachType == 0 {
53 return 0, fmt.Errorf("attach type not found for GUID %v: %w", attachTypeGUID, os.ErrNotExist)
54 }
55
56 return AttachTypeForPlatform(platform.Windows, rawAttachType)
57 }