Merge pull request #1374 from shirou/feature/add_ubr_on_host_windows

feat(host, windows): add UBR (Update Build Revision) to kernel version
This commit is contained in:
shirou 2022-11-10 10:22:20 +09:00 committed by GitHub
commit 672e2518f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -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(&regBuf[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
}