mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
windows: add EnumProcesses function
See https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumprocesses Change-Id: Ibccb0c3d8e4f32857547ee6d072d0b1cb2430366 Reviewed-on: https://go-review.googlesource.com/c/sys/+/205197 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
committed by
Tobias Klauser
parent
f43be2a459
commit
e8c54fb511
@@ -314,6 +314,9 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys rtlGetVersion(info *OsVersionInfoEx) (ret error) = ntdll.RtlGetVersion
|
||||
//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers
|
||||
|
||||
// Process Status API (PSAPI)
|
||||
//sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses
|
||||
|
||||
// syscall interface implementation for other packages
|
||||
|
||||
// GetCurrentProcess returns the handle for the current process.
|
||||
|
||||
@@ -44,6 +44,7 @@ var (
|
||||
moduser32 = NewLazySystemDLL("user32.dll")
|
||||
modole32 = NewLazySystemDLL("ole32.dll")
|
||||
modntdll = NewLazySystemDLL("ntdll.dll")
|
||||
modpsapi = NewLazySystemDLL("psapi.dll")
|
||||
modws2_32 = NewLazySystemDLL("ws2_32.dll")
|
||||
moddnsapi = NewLazySystemDLL("dnsapi.dll")
|
||||
modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
|
||||
@@ -247,6 +248,7 @@ var (
|
||||
procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
|
||||
procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
|
||||
procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
|
||||
procEnumProcesses = modpsapi.NewProc("EnumProcesses")
|
||||
procWSAStartup = modws2_32.NewProc("WSAStartup")
|
||||
procWSACleanup = modws2_32.NewProc("WSACleanup")
|
||||
procWSAIoctl = modws2_32.NewProc("WSAIoctl")
|
||||
@@ -2758,6 +2760,22 @@ func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNum
|
||||
return
|
||||
}
|
||||
|
||||
func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) {
|
||||
var _p0 *uint32
|
||||
if len(processIds) > 0 {
|
||||
_p0 = &processIds[0]
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(processIds)), uintptr(unsafe.Pointer(bytesReturned)))
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
|
||||
r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
|
||||
if r0 != 0 {
|
||||
|
||||
Reference in New Issue
Block a user