|
|
@ -136,6 +136,14 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) {
|
|
|
|
func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) {
|
|
|
|
|
|
|
|
platform, family, _, displayVersion, err := platformInformation(ctx)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return "", "", "", err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return platform, family, displayVersion, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func platformInformation(ctx context.Context) (platform, family, version, displayVersion string, err error) {
|
|
|
|
// GetVersionEx lies on Windows 8.1 and returns as Windows 8 if we don't declare compatibility in manifest
|
|
|
|
// GetVersionEx lies on Windows 8.1 and returns as Windows 8 if we don't declare compatibility in manifest
|
|
|
|
// RtlGetVersion bypasses this lying layer and returns the true Windows version
|
|
|
|
// RtlGetVersion bypasses this lying layer and returns the true Windows version
|
|
|
|
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-rtlgetversion
|
|
|
|
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-rtlgetversion
|
|
|
@ -199,6 +207,14 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
|
|
|
|
copy((*[4]byte)(unsafe.Pointer(&UBR))[:], regBuf)
|
|
|
|
copy((*[4]byte)(unsafe.Pointer(&UBR))[:], regBuf)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get DisplayVersion(ex: 23H2) as platformVersion
|
|
|
|
|
|
|
|
err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`DisplayVersion`), nil, &valType, nil, &bufLen)
|
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
|
|
|
|
regBuf := make([]uint16, bufLen/2+1)
|
|
|
|
|
|
|
|
err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`DisplayVersion`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen)
|
|
|
|
|
|
|
|
displayVersion = windows.UTF16ToString(regBuf[:])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PlatformFamily
|
|
|
|
// PlatformFamily
|
|
|
|
switch osInfo.wProductType {
|
|
|
|
switch osInfo.wProductType {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
@ -214,7 +230,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
|
|
|
|
osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, UBR,
|
|
|
|
osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, UBR,
|
|
|
|
osInfo.dwBuildNumber, UBR)
|
|
|
|
osInfo.dwBuildNumber, UBR)
|
|
|
|
|
|
|
|
|
|
|
|
return platform, family, version, nil
|
|
|
|
return platform, family, version, displayVersion, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func UsersWithContext(ctx context.Context) ([]UserStat, error) {
|
|
|
|
func UsersWithContext(ctx context.Context) ([]UserStat, error) {
|
|
|
@ -228,7 +244,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func KernelVersionWithContext(ctx context.Context) (string, error) {
|
|
|
|
func KernelVersionWithContext(ctx context.Context) (string, error) {
|
|
|
|
_, _, version, err := PlatformInformationWithContext(ctx)
|
|
|
|
_, _, version, _, err := platformInformation(ctx)
|
|
|
|
return version, err
|
|
|
|
return version, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|