MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / findProcessID

Function findProcessID

pkg/pe/header_test.go:80–99  ·  view source on GitHub ↗
(image string)

Source from the content-addressed store, hash-verified

78}
79
80func findProcessID(image string) (uint32, error) {
81 const processEntrySize = 568
82 snap, err := windows.CreateToolhelp32Snapshot(windows.TH32CS_SNAPPROCESS, 0)
83 if err != nil {
84 return 0, err
85 }
86 defer windows.Close(snap)
87 p := windows.ProcessEntry32{Size: processEntrySize}
88 for {
89 err := windows.Process32Next(snap, &p)
90 if err != nil {
91 break
92 }
93 s := windows.UTF16ToString(p.ExeFile[:])
94 if strings.EqualFold(s, filepath.Base(image)) {
95 return p.ProcessID, nil
96 }
97 }
98 return 0, fmt.Errorf("no process for %s image", image)
99}

Callers 1

TestIsHeaderModifiedFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected