windows: prefer os version from registry

this value is not modified by compatibility mode
drop reporting service pack numbers. no longer used
This commit is contained in:
Shawn Hoffman
2023-01-17 01:23:44 -08:00
parent 10fd768898
commit dff7f20f9d
7 changed files with 102 additions and 45 deletions

View File

@ -10,6 +10,7 @@
#include "Common/IOFile.h"
#include "Common/ScopeGuard.h"
#include "Common/StringUtil.h"
#include "Common/WindowsRegistry.h"
#include "UpdaterCommon/Platform.h"
#include "UpdaterCommon/UI.h"
@ -133,9 +134,7 @@ static const char* VCRuntimeRegistrySubkey()
static bool ReadVCRuntimeVersionField(u32* value, const char* name)
{
DWORD value_len = sizeof(*value);
return RegGetValueA(HKEY_LOCAL_MACHINE, VCRuntimeRegistrySubkey(), name, RRF_RT_REG_DWORD,
nullptr, value, &value_len) == ERROR_SUCCESS;
return WindowsRegistry::ReadValue(value, VCRuntimeRegistrySubkey(), name);
}
static std::optional<BuildVersion> GetInstalledVCRuntimeVersion()
@ -219,11 +218,7 @@ static bool VCRuntimeUpdate(const BuildInfo& build_info)
static BuildVersion CurrentOSVersion()
{
typedef DWORD(WINAPI * RtlGetVersion_t)(PRTL_OSVERSIONINFOW);
auto RtlGetVersion =
(RtlGetVersion_t)GetProcAddress(GetModuleHandle(TEXT("ntdll")), "RtlGetVersion");
RTL_OSVERSIONINFOW info{.dwOSVersionInfoSize = sizeof(info)};
RtlGetVersion(&info);
OSVERSIONINFOW info = WindowsRegistry::GetOSVersion();
return {.major = info.dwMajorVersion, .minor = info.dwMinorVersion, .build = info.dwBuildNumber};
}