Skip to content

Commit c356035

Browse files
[RAPPS] Hide packages not compatible with the current NT version (reactos#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 <carl.bialorucki@reactos.org>
1 parent 2be2032 commit c356035

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎base/applications/rapps/appinfo.cpp‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,37 @@ CAvailableApplicationInfo::RetrieveLanguages()
295295
}
296296
}
297297

298+
bool
299+
CAvailableApplicationInfo::IsCompatible() const
300+
{
301+
CStringW szBuffer;
302+
if (m_Parser->GetString(DB_NTVER, szBuffer))
303+
{
304+
LPWSTR start = szBuffer.GetString();
305+
LPWSTR p;
306+
ULONG MinNTVer = wcstoul(start, &p, 0);
307+
if (p > start)
308+
{
309+
ULONG NTVersion = GetNTVersion();
310+
// Treat as range if we have '-', otherwise treat it as XXX+
311+
ULONG MaxNTVer = (*p == '-') ? wcstoul(++p, NULL, 0) : UINT_MAX;
312+
// Handle the XXX- case (That version or lower)
313+
if (MaxNTVer == 0)
314+
{
315+
MaxNTVer = MinNTVer;
316+
MinNTVer = 0;
317+
}
318+
319+
return NTVersion >= MinNTVer && NTVersion <= MaxNTVer;
320+
}
321+
}
322+
return true;
323+
}
324+
298325
BOOL
299326
CAvailableApplicationInfo::Valid() const
300327
{
301-
return !szDisplayName.IsEmpty() && !m_szUrlDownload.IsEmpty();
328+
return !szDisplayName.IsEmpty() && !m_szUrlDownload.IsEmpty() && IsCompatible();
302329
}
303330

304331
BOOL

‎base/applications/rapps/include/appinfo.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ enum InstallerType
9898
#define DB_SCOPE L"Scope" // User or Machine
9999
#define DB_SAVEAS L"SaveAs"
100100
#define DB_SILENTARGS L"SilentParameters"
101+
#define DB_NTVER L"NTVersion" // "Max-" || "Min-Max" || "Min" || "Min+"
101102

102103
#define DB_GENINSTSECTION L"Generate"
103104
#define GENERATE_ARPSUBKEY L"RApps" // Our uninstall data is stored here
@@ -175,6 +176,9 @@ class CAvailableApplicationInfo : public CAppInfo
175176
CConfigParser *
176177
GetConfigParser() const { return m_Parser; }
177178

179+
bool
180+
IsCompatible() const;
181+
178182
virtual BOOL
179183
Valid() const override;
180184
virtual BOOL

‎base/applications/rapps/include/misc.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ ExtractFilesFromCab(LPCWSTR FullCabPath, const CStringW &szOutputDir,
8585

8686
BOOL
8787
IsSystem64Bit();
88+
ULONG
89+
GetNTVersion();
8890

8991
INT
9092
GetSystemColorDepth();

‎base/applications/rapps/misc.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,16 @@ IsSystem64Bit()
391391
#endif
392392
}
393393

394+
ULONG
395+
GetNTVersion()
396+
{
397+
RTL_OSVERSIONINFOW osvi = {0};
398+
osvi.dwOSVersionInfoSize = sizeof(osvi);
399+
RtlGetVersion(&osvi);
400+
401+
return (osvi.dwMajorVersion << 8) | (osvi.dwMinorVersion);
402+
}
403+
394404
INT
395405
GetSystemColorDepth()
396406
{

0 commit comments

Comments
 (0)