mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
license collector (#1524)
This commit is contained in:
40
pkg/headers/slc/slc.go
Normal file
40
pkg/headers/slc/slc.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package slc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
slc = windows.NewLazySystemDLL("slc.dll")
|
||||
procSLIsWindowsGenuineLocal = slc.NewProc("SLIsWindowsGenuineLocal")
|
||||
)
|
||||
|
||||
// Define SL_GENUINE_STATE enumeration
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/slpublic/ne-slpublic-sl_genuine_state
|
||||
type SL_GENUINE_STATE uint32
|
||||
|
||||
const (
|
||||
SL_GEN_STATE_IS_GENUINE SL_GENUINE_STATE = iota
|
||||
SL_GEN_STATE_INVALID_LICENSE
|
||||
SL_GEN_STATE_TAMPERED
|
||||
SL_GEN_STATE_OFFLINE
|
||||
SL_GEN_STATE_LAST
|
||||
)
|
||||
|
||||
// SLIsWindowsGenuineLocal function wrapper
|
||||
func SLIsWindowsGenuineLocal() (SL_GENUINE_STATE, error) {
|
||||
var genuineState SL_GENUINE_STATE
|
||||
|
||||
_, _, err := procSLIsWindowsGenuineLocal.Call(
|
||||
uintptr(unsafe.Pointer(&genuineState)),
|
||||
)
|
||||
|
||||
if !errors.Is(err, windows.NTE_OP_OK) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return genuineState, nil
|
||||
}
|
||||
Reference in New Issue
Block a user