Skip to content

Commit

Permalink
Merge pull request #1374 from shirou/feature/add_ubr_on_host_windows
Browse files Browse the repository at this point in the history
feat(host, windows): add UBR (Update Build Revision) to kernel version
  • Loading branch information
shirou committed Nov 10, 2022
2 parents 2099ec6 + 68452e2 commit 672e251
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion host/host_windows.go
Expand Up @@ -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:
Expand All @@ -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
}
Expand Down

0 comments on commit 672e251

Please sign in to comment.