From 68452e260206bdac09707931e314f5e952f27f7d Mon Sep 17 00:00:00 2001 From: shirou Date: Sat, 5 Nov 2022 20:59:15 +0900 Subject: [PATCH] feat(host, windows): add UBR (Update Build Revision) to kernel version --- host/host_windows.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/host/host_windows.go b/host/host_windows.go index fcd1d59..a16892d 100644 --- a/host/host_windows.go +++ b/host/host_windows.go @@ -188,6 +188,14 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil } } + var UBR uint32 // Update Build Revision + err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`UBR`), nil, &valType, nil, &bufLen) + if err == nil { + regBuf := make([]byte, 4) + err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`UBR`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen) + copy((*[4]byte)(unsafe.Pointer(&UBR))[:], regBuf) + } + // PlatformFamily switch osInfo.wProductType { case 1: @@ -199,7 +207,9 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil } // Platform Version - version = fmt.Sprintf("%d.%d.%d Build %d", osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, osInfo.dwBuildNumber) + version = fmt.Sprintf("%d.%d.%d.%d Build %d.%d", + osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, UBR, + osInfo.dwBuildNumber, UBR) return platform, family, version, nil }