add system check and block on new windows versions
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Failing after 4m30s
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Successful in 5m42s
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Successful in 5m51s
ContinuousIntegration / linux (push) Successful in 4m11s
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Failing after 6m31s
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Failing after 5m16s
ContinuousDelivery / windows (push) Has been cancelled
ContinuousDelivery / windows-asan (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled

This commit is contained in:
Green Sky 2024-06-07 13:19:40 +02:00
parent a2001b34ea
commit 6b96be7a57
No known key found for this signature in database
4 changed files with 57 additions and 0 deletions

View File

@ -13,6 +13,9 @@ target_sources(tomato PUBLIC
./main.cpp
./icon.rc
./sys_check.hpp
./sys_check.cpp
./json_to_config.hpp
./json_to_config.cpp

View File

@ -8,6 +8,8 @@
#include "./theme.hpp"
#include "./chat_gui/theme.hpp"
#include "./sys_check.hpp"
#include "./start_screen.hpp"
#include <filesystem>
@ -24,6 +26,8 @@ int main(int argc, char** argv) {
args.push_back(argv[i]);
}
runSysCheck();
#ifdef __ANDROID__
// change current working dir to internal storage
std::filesystem::current_path(SDL_AndroidGetInternalStoragePath());

46
src/sys_check.cpp Normal file
View File

@ -0,0 +1,46 @@
#include "./sys_check.hpp"
// use message boxes to notify the user of system failure
#include <SDL3/SDL.h>
#include <cstdlib>
#if defined(_WIN32) || defined(WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
typedef LONG NTSTATUS, *PNTSTATUS;
#define STATUS_SUCCESS (0x00000000)
void runSysCheck(void) {
NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
OSVERSIONINFOEXW osInfo;
*(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
if (NULL != RtlGetVersion) {
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
RtlGetVersion(&osInfo);
// check
if (
osInfo.dwBuildNumber >= 26000 // canary versions of 11 24H2 included
) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Unsupported System", "Your version of windows is too new and endangers the privacy of all involved.", nullptr);
exit(0);
}
}
}
#else
void runSysCheck(void) {
// do nothing
}
#endif

4
src/sys_check.hpp Normal file
View File

@ -0,0 +1,4 @@
#pragma once
// perform system checks and potentially terminate
void runSysCheck(void);