diff --git a/launcher/internal/cmd/root.go b/launcher/internal/cmd/root.go index 1686289..7c33d42 100644 --- a/launcher/internal/cmd/root.go +++ b/launcher/internal/cmd/root.go @@ -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") diff --git a/launcher/internal/cmdUtils/version_other.go b/launcher/internal/cmdUtils/version_other.go new file mode 100644 index 0000000..6a25825 --- /dev/null +++ b/launcher/internal/cmdUtils/version_other.go @@ -0,0 +1,7 @@ +//go:build !windows + +package cmdUtils + +func CheckVersion() error { + return nil +} diff --git a/launcher/internal/cmdUtils/version_windows.go b/launcher/internal/cmdUtils/version_windows.go new file mode 100644 index 0000000..35a77d8 --- /dev/null +++ b/launcher/internal/cmdUtils/version_windows.go @@ -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, + ) +} diff --git a/launcher/internal/errors.go b/launcher/internal/errors.go index 058fdfd..cfa54fd 100644 --- a/launcher/internal/errors.go +++ b/launcher/internal/errors.go @@ -39,4 +39,5 @@ const ( ErrConfigCDNMap ErrSteamRoot ErrAnnouncementMulticastGroup + ErrUnsupportedOS )