Skip to content

Commit

Permalink
Enhancement: check the windows version meets the minimum requirement …
Browse files Browse the repository at this point in the history
…(launcher)
  • Loading branch information
luskaner committed Dec 18, 2024
1 parent e455f94 commit a6b6104
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions launcher/internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ var (
_ = lock.Unlock()
os.Exit(errorCode)
}()
if err := cmdUtils.CheckVersion(); err != nil {
fmt.Println(err)
errorCode = internal.ErrUnsupportedOS
return
}
canTrustCertificate := viper.GetString("Config.CanTrustCertificate")
if runtime.GOOS != "windows" {
canTrustCertificateValues.Remove("user")
Expand Down
7 changes: 7 additions & 0 deletions launcher/internal/cmdUtils/version_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !windows

package cmdUtils

func CheckVersion() error {
return nil
}
34 changes: 34 additions & 0 deletions launcher/internal/cmdUtils/version_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmdUtils

import (
"fmt"
"golang.org/x/sys/windows"
)

const minMajorVersion = 10
const minMinorVersion = 0
const minBuildNumber = 17763
const alias = "Windows 10 (1809 - Redstone 5)"

func CheckVersion() error {
major, minor, build := windows.RtlGetNtVersionNumbers()
if major > minMajorVersion {
return nil
}
if major == minMajorVersion && minor > minMinorVersion {
return nil
}
if major == minMajorVersion && minor == minMinorVersion && build >= minBuildNumber {
return nil
}
return fmt.Errorf(
"unsupported Windows version: %d.%d.%d, minimum is %d.%d.%d also known as %s. Update your system",
major,
minor,
build,
minMajorVersion,
minMinorVersion,
minBuildNumber,
alias,
)
}
1 change: 1 addition & 0 deletions launcher/internal/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ const (
ErrConfigCDNMap
ErrSteamRoot
ErrAnnouncementMulticastGroup
ErrUnsupportedOS
)

0 comments on commit a6b6104

Please sign in to comment.