diff options
| author | Odd Stranne <odd@mullvad.net> | 2021-10-13 09:22:07 +0200 |
|---|---|---|
| committer | Odd Stranne <odd@mullvad.net> | 2021-10-13 09:22:07 +0200 |
| commit | 1005c38eb634eb67483b5d136b1109d112c32349 (patch) | |
| tree | d44fd340403e103d483d9c73756676792387a87f | |
| parent | 22f2331c7da67e3fab231e483fb3474075c76ff2 (diff) | |
| parent | b4edbcbc033af395bf4e9007b53848e1ff4d3a74 (diff) | |
| download | mullvadvpn-1005c38eb634eb67483b5d136b1109d112c32349.tar.xz mullvadvpn-1005c38eb634eb67483b5d136b1109d112c32349.zip | |
Merge branch 'fix-identifying-win11'
| -rw-r--r-- | talpid-platform-metadata/src/windows.rs | 8 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/log/log.cpp | 40 |
2 files changed, 46 insertions, 2 deletions
diff --git a/talpid-platform-metadata/src/windows.rs b/talpid-platform-metadata/src/windows.rs index 016d71ed4c..a44eb484d4 100644 --- a/talpid-platform-metadata/src/windows.rs +++ b/talpid-platform-metadata/src/windows.rs @@ -81,7 +81,13 @@ impl WindowsVersion { (6, 1) => "7".into(), (6, 2) => "8".into(), (6, 3) => "8.1".into(), - (10, 0) => "10".into(), + (10, 0) => { + if self.build_number() < 22000 { + "10".into() + } else { + "11".into() + } + } (major, minor) => format!("{}.{}", major, minor), } } diff --git a/windows/nsis-plugins/src/log/log.cpp b/windows/nsis-plugins/src/log/log.cpp index 23ca329eb1..a491dc9b2d 100644 --- a/windows/nsis-plugins/src/log/log.cpp +++ b/windows/nsis-plugins/src/log/log.cpp @@ -181,6 +181,44 @@ std::wstring GetWindowsVersion() return version; } + +// +// FixupWindows11ProductName() +// +// Patch product name based on Windows version. +// The registry value that holds the product name seems to be deprecated in Win11. +// +std::wstring FixupWindows11ProductName(const std::wstring &productName, const std::wstring &version) +{ + const auto versionTokens = common::string::Tokenize(version, L"."); + + if (versionTokens.size() < 3) + { + return productName; + } + + const auto major = common::string::LexicalCast<uint32_t>(versionTokens[0]); + const auto minor = common::string::LexicalCast<uint32_t>(versionTokens[1]); + const auto build = common::string::LexicalCast<uint32_t>(versionTokens[2]); + + if (major != 10 || minor != 0 || build < 22000) + { + return productName; + } + + auto productTokens = common::string::Tokenize(productName, L" "); + + for (auto &token : productTokens) + { + if (0 == token.compare(L"10")) + { + token = L"11"; + } + } + + return common::string::Join(productTokens, L" "); +} + } // anonymous namespace // @@ -374,7 +412,7 @@ void __declspec(dllexport) NSISCALL LogWindowsVersion std::wstringstream ss; ss << L"Windows version: " - << productName + << FixupWindows11ProductName(productName, version) << L", " << version; |
