From c356035860456e096fd05ad1d881aa018c226236 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Thu, 8 Jan 2026 21:14:42 +0100 Subject: [PATCH] [RAPPS] Hide packages not compatible with the current NT version (#8398) - Add NTVersion to filter app packages and hide incompatible packages. The format is: "Max-", "Min-Max", "Min" or "Min+". --------- Co-authored-by: Carl J. Bialorucki --- base/applications/rapps/appinfo.cpp | 29 ++++++++++++++++++++++- base/applications/rapps/include/appinfo.h | 4 ++++ base/applications/rapps/include/misc.h | 2 ++ base/applications/rapps/misc.cpp | 10 ++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/base/applications/rapps/appinfo.cpp b/base/applications/rapps/appinfo.cpp index 4aea019ecf2..d43fa81acc2 100644 --- a/base/applications/rapps/appinfo.cpp +++ b/base/applications/rapps/appinfo.cpp @@ -295,10 +295,37 @@ CAvailableApplicationInfo::RetrieveLanguages() } } +bool +CAvailableApplicationInfo::IsCompatible() const +{ + CStringW szBuffer; + if (m_Parser->GetString(DB_NTVER, szBuffer)) + { + LPWSTR start = szBuffer.GetString(); + LPWSTR p; + ULONG MinNTVer = wcstoul(start, &p, 0); + if (p > start) + { + ULONG NTVersion = GetNTVersion(); + // Treat as range if we have '-', otherwise treat it as XXX+ + ULONG MaxNTVer = (*p == '-') ? wcstoul(++p, NULL, 0) : UINT_MAX; + // Handle the XXX- case (That version or lower) + if (MaxNTVer == 0) + { + MaxNTVer = MinNTVer; + MinNTVer = 0; + } + + return NTVersion >= MinNTVer && NTVersion <= MaxNTVer; + } + } + return true; +} + BOOL CAvailableApplicationInfo::Valid() const { - return !szDisplayName.IsEmpty() && !m_szUrlDownload.IsEmpty(); + return !szDisplayName.IsEmpty() && !m_szUrlDownload.IsEmpty() && IsCompatible(); } BOOL diff --git a/base/applications/rapps/include/appinfo.h b/base/applications/rapps/include/appinfo.h index 7f8dd72a720..f312c19e273 100644 --- a/base/applications/rapps/include/appinfo.h +++ b/base/applications/rapps/include/appinfo.h @@ -98,6 +98,7 @@ enum InstallerType #define DB_SCOPE L"Scope" // User or Machine #define DB_SAVEAS L"SaveAs" #define DB_SILENTARGS L"SilentParameters" +#define DB_NTVER L"NTVersion" // "Max-" || "Min-Max" || "Min" || "Min+" #define DB_GENINSTSECTION L"Generate" #define GENERATE_ARPSUBKEY L"RApps" // Our uninstall data is stored here @@ -175,6 +176,9 @@ class CAvailableApplicationInfo : public CAppInfo CConfigParser * GetConfigParser() const { return m_Parser; } + bool + IsCompatible() const; + virtual BOOL Valid() const override; virtual BOOL diff --git a/base/applications/rapps/include/misc.h b/base/applications/rapps/include/misc.h index 4eb47f1a020..73f5165141a 100644 --- a/base/applications/rapps/include/misc.h +++ b/base/applications/rapps/include/misc.h @@ -85,6 +85,8 @@ ExtractFilesFromCab(LPCWSTR FullCabPath, const CStringW &szOutputDir, BOOL IsSystem64Bit(); +ULONG +GetNTVersion(); INT GetSystemColorDepth(); diff --git a/base/applications/rapps/misc.cpp b/base/applications/rapps/misc.cpp index 0b28ec09985..cf6ad378322 100644 --- a/base/applications/rapps/misc.cpp +++ b/base/applications/rapps/misc.cpp @@ -391,6 +391,16 @@ IsSystem64Bit() #endif } +ULONG +GetNTVersion() +{ + RTL_OSVERSIONINFOW osvi = {0}; + osvi.dwOSVersionInfoSize = sizeof(osvi); + RtlGetVersion(&osvi); + + return (osvi.dwMajorVersion << 8) | (osvi.dwMinorVersion); +} + INT GetSystemColorDepth() {