headers: fail Build on missing native exports and assert MI/COM layouts (#2739)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-16 02:32:29 +02:00
committed by GitHub
parent af2a7c3f6c
commit 2f5781ff13
43 changed files with 866 additions and 16 deletions
+13
View File
@@ -23,14 +23,27 @@ import (
"unsafe"
"github.com/prometheus-community/windows_exporter/internal/headers/hcs"
"github.com/prometheus-community/windows_exporter/internal/headers/lazyproc"
"github.com/prometheus-community/windows_exporter/internal/utils"
"golang.org/x/sys/windows"
)
// Load checks that vmcompute.dll, and the hcs functions this package uses,
// export every function of this package. Call it in Build: a missing export
// panics on the first call otherwise.
func Load() error {
if err := load(); err != nil {
return err
}
return hcs.Load()
}
//nolint:gochecknoglobals
var (
modvmcompute = windows.NewLazySystemDLL("vmcompute.dll")
procHNSCall = modvmcompute.NewProc("HNSCall")
load = lazyproc.Once(modvmcompute, procHNSCall)
hcnBodyEmpty = utils.Must(windows.UTF16PtrFromString(""))
hcnMethodGet = utils.Must(windows.UTF16PtrFromString("GET"))