-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathos_release_windows.go
More file actions
36 lines (28 loc) · 910 Bytes
/
os_release_windows.go
File metadata and controls
36 lines (28 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//go:build windows
// +build windows
package gospice
import (
"fmt"
"unsafe"
"golang.org/x/sys/windows"
)
func GetOSRelease() string {
// Define the structure that will hold the version info
type OsVersionInfoExW struct {
DwOSVersionInfoSize uint32
DwMajorVersion uint32
DwMinorVersion uint32
DwBuildNumber uint32
DwPlatformId uint32
SzCSDVersion [128]uint16
}
// Load the ntdll.dll using the windows package
ntdll := windows.NewLazySystemDLL("ntdll.dll")
rtlGetVersion := ntdll.NewProc("RtlGetVersion")
var osVersion OsVersionInfoExW
osVersion.DwOSVersionInfoSize = uint32(unsafe.Sizeof(osVersion))
// Call the RtlGetVersion function
_, _, _ = rtlGetVersion.Call(uintptr(unsafe.Pointer(&osVersion)))
// Format the version information
return fmt.Sprintf("%d.%d.%d", osVersion.DwMajorVersion, osVersion.DwMinorVersion, osVersion.DwBuildNumber)
}