diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-08-06 14:08:25 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-08-07 13:48:29 +0200 |
| commit | 35fa899e46316caf7669eee8bab7eb2fb6e84107 (patch) | |
| tree | da2c9c9161542e7619227c05c1fabdbf5fbdebae /windows | |
| parent | 26fddca7799ad01425458262d5ca774ded1ce96f (diff) | |
| download | mullvadvpn-35fa899e46316caf7669eee8bab7eb2fb6e84107.tar.xz mullvadvpn-35fa899e46316caf7669eee8bab7eb2fb6e84107.zip | |
Infer Windows version from ntoskrnl image in installer
Diffstat (limited to 'windows')
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleanup.cpp | 3 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/log/log.cpp | 38 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/log/log.def | 1 |
3 files changed, 40 insertions, 2 deletions
diff --git a/windows/nsis-plugins/src/cleanup/cleanup.cpp b/windows/nsis-plugins/src/cleanup/cleanup.cpp index ca943934a7..b52c269577 100644 --- a/windows/nsis-plugins/src/cleanup/cleanup.cpp +++ b/windows/nsis-plugins/src/cleanup/cleanup.cpp @@ -7,6 +7,9 @@ #include <functional> #include <vector> +// NOTE: Linker refuses to find the library unless specified here +#pragma comment(lib, "version.lib") + void __declspec(dllexport) NSISCALL RemoveLogsAndCache ( HWND hwndParent, diff --git a/windows/nsis-plugins/src/log/log.cpp b/windows/nsis-plugins/src/log/log.cpp index d1e37d7669..64eabedf8d 100644 --- a/windows/nsis-plugins/src/log/log.cpp +++ b/windows/nsis-plugins/src/log/log.cpp @@ -90,7 +90,7 @@ std::vector<std::wstring> BlockToRows(const std::wstring &textBlock) return common::string::Tokenize(textBlock, L"\r\n"); } -std::wstring GetWindowsVersion() +std::wstring GetWindowsVersionString() { std::vector<uint16_t> version(256); size_t bufferSize = version.size(); @@ -287,7 +287,7 @@ void __declspec(dllexport) NSISCALL LogWindowsVersion try { std::wstringstream version; - version << L"Windows version: " << GetWindowsVersion(); + version << L"Windows version: " << GetWindowsVersionString(); g_logger->log(version.str()); } catch (std::exception &err) @@ -306,6 +306,40 @@ void __declspec(dllexport) NSISCALL LogWindowsVersion } // +// GetWindowsMajorVersion +// +// Returns the current Windows major version on the stack. -1 on error. +// +void __declspec(dllexport) NSISCALL GetWindowsMajorVersion +( + HWND hwndParent, + int string_size, + LPTSTR variables, + stack_t **stacktop, + extra_parameters *extra, + ... +) +{ + EXDLL_INIT(); + + WindowsVer ver = { 0 }; + + if (get_system_version_struct(&ver) == Status::Ok) + { + pushint(ver.major_version); + return; + } + + + if (nullptr != g_logger) + { + g_logger->log(L"Windows version: Failed to determine version"); + } + + pushint(-1); +} + +// // PluginLog // // Writes a message to the log file. diff --git a/windows/nsis-plugins/src/log/log.def b/windows/nsis-plugins/src/log/log.def index d51b04ab7b..f8bafa4a57 100644 --- a/windows/nsis-plugins/src/log/log.def +++ b/windows/nsis-plugins/src/log/log.def @@ -6,6 +6,7 @@ SetLogTarget Log LogWithDetails LogWindowsVersion +GetWindowsMajorVersion PluginLog PluginLogWithDetails |
