| 1 | package cage |
| 2 | |
| 3 | import ( |
| 4 | "strconv" |
| 5 | |
| 6 | "golang.org/x/sys/windows" |
| 7 | ) |
| 8 | |
| 9 | func profileProcessAlive(pid int) bool { |
| 10 | h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) |
| 11 | if err != nil { |
| 12 | return err == windows.ERROR_ACCESS_DENIED |
| 13 | } |
| 14 | defer windows.CloseHandle(h) |
| 15 | var code uint32 |
| 16 | return windows.GetExitCodeProcess(h, &code) == nil && code == 259 |
| 17 | } |
| 18 | |
| 19 | func processStartToken(pid int) string { |
| 20 | if pid <= 0 { |
| 21 | return "" |
| 22 | } |
| 23 | h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) |
| 24 | if err != nil { |
| 25 | return "" |
| 26 | } |
| 27 | defer windows.CloseHandle(h) |
| 28 | var created, exited, kernel, user windows.Filetime |
| 29 | if windows.GetProcessTimes(h, &created, &exited, &kernel, &user) != nil { |
| 30 | return "" |
| 31 | } |
| 32 | return strconv.FormatInt(created.Nanoseconds(), 10) |
| 33 | } |