diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-28 12:27:06 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-29 08:41:30 +0200 |
commit | e9682162ac908e9b9d81f3378faf8b38d1baa630 (patch) | |
tree | 1c3e6059569376c72336ba09f06e9a5ee5e1e833 /version/os_windows.go | |
parent | go.mod: use forked winio with no thirdparty deps (diff) | |
download | wireguard-windows-e9682162ac908e9b9d81f3378faf8b38d1baa630.tar.xz wireguard-windows-e9682162ac908e9b9d81f3378faf8b38d1baa630.zip |
updater: add initial skeleton
Diffstat (limited to 'version/os_windows.go')
-rw-r--r-- | version/os_windows.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/version/os_windows.go b/version/os_windows.go new file mode 100644 index 00000000..ac4e8957 --- /dev/null +++ b/version/os_windows.go @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2019 WireGuard LLC. All Rights Reserved. + */ + +package version + +import ( + "fmt" + "unsafe" +) + +type osVersionInfo struct { + osVersionInfoSize uint32 + majorVersion uint32 + minorVersion uint32 + buildNumber uint32 + platformId uint32 + csdVersion [128]uint16 + servicePackMajor uint16 + servicePackMinor uint16 + suiteMask uint16 + productType byte + reserved byte +} + +//sys rtlGetVersion(versionInfo *osVersionInfo) (nterr uint32) = ntdll.RtlGetVersion + +func OsName() string { + windowsVersion := "Windows Unknown" + versionInfo := &osVersionInfo{osVersionInfoSize: uint32(unsafe.Sizeof(osVersionInfo{}))} + if rtlGetVersion(versionInfo) == 0 { + winType := "" + switch versionInfo.productType { + case 3: + winType = " Server" + case 2: + winType = " Controller" + } + windowsVersion = fmt.Sprintf("Windows%s %d.%d.%d", winType, versionInfo.majorVersion, versionInfo.minorVersion, versionInfo.buildNumber) + } + return windowsVersion +} |