mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-17 10:16:35 +00:00
mi: replace all WMI calls with MI calls (#1714)
This commit is contained in:
28
internal/testutils/handle.go
Normal file
28
internal/testutils/handle.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package testutils
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
|
||||
procGetProcessHandleCount = modkernel32.NewProc("GetProcessHandleCount")
|
||||
)
|
||||
|
||||
func GetProcessHandleCount(handle windows.Handle) (uint32, error) {
|
||||
var count uint32
|
||||
|
||||
r1, _, err := procGetProcessHandleCount.Call(
|
||||
uintptr(handle),
|
||||
uintptr(unsafe.Pointer(&count)),
|
||||
)
|
||||
|
||||
if r1 != 1 {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
Reference in New Issue
Block a user