From e883a16d0c1d1dcbca9875c14910a2b231e658d9 Mon Sep 17 00:00:00 2001 From: m Date: Sat, 3 Dec 2022 20:39:55 -0600 Subject: [PATCH] move wine check to utils [skip ci] --- src/client/component/arxan.cpp | 13 ------------- src/client/component/arxan.hpp | 6 ------ src/client/component/system_check.cpp | 4 ++-- src/client/main.cpp | 6 ++---- src/client/steam/steam.cpp | 3 +-- src/common/utils/nt.cpp | 13 +++++++++++++ src/common/utils/nt.hpp | 2 ++ 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/client/component/arxan.cpp b/src/client/component/arxan.cpp index 34ef481e..6bb915e7 100644 --- a/src/client/component/arxan.cpp +++ b/src/client/component/arxan.cpp @@ -111,19 +111,6 @@ namespace arxan } } - bool is_wine() - { - static std::optional is_wine = {}; - - if (!is_wine.has_value()) - { - const utils::nt::library ntdll("ntdll.dll"); - is_wine = ntdll.get_proc("wine_get_version") != nullptr; - } - - return is_wine.value(); - } - class component final : public component_interface { public: diff --git a/src/client/component/arxan.hpp b/src/client/component/arxan.hpp index 5a67dece..e69de29b 100644 --- a/src/client/component/arxan.hpp +++ b/src/client/component/arxan.hpp @@ -1,6 +0,0 @@ -#pragma once - -namespace arxan -{ - bool is_wine(); -} \ No newline at end of file diff --git a/src/client/component/system_check.cpp b/src/client/component/system_check.cpp index 10002dde..da1dc452 100644 --- a/src/client/component/system_check.cpp +++ b/src/client/component/system_check.cpp @@ -1,11 +1,11 @@ #include #include "loader/component_loader.hpp" -#include "arxan.hpp" #include "system_check.hpp" #include "game/game.hpp" +#include #include #include @@ -69,7 +69,7 @@ namespace system_check void verify_binary_version() { const auto value = *reinterpret_cast(0x1337_b); - if (!arxan::is_wine()) + if (!utils::nt::is_wine()) { if (value == 0x60202B6A || value == 0xBC0E9FE) { diff --git a/src/client/main.cpp b/src/client/main.cpp index c9468f02..c61a57cc 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -4,8 +4,6 @@ #include "loader/component_loader.hpp" #include "game/game.hpp" -#include "component/arxan.hpp" - #include #include #include @@ -95,7 +93,7 @@ FARPROC load_binary(const launcher::mode mode, uint64_t* base_address) && function != "SteamAPI_GetSteamInstallPath") // Arxan requires one valid steam api import - maybe SteamAPI_Shutdown is better? { static bool check_for_steam_install = false; - if (!check_for_steam_install && !arxan::is_wine()) + if (!check_for_steam_install && !utils::nt::is_wine()) { HKEY key; if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS) @@ -208,7 +206,7 @@ int main() FARPROC entry_point; // leaving these for Windows only for now, need to test to see if we can have for Wine -mikey - if (!arxan::is_wine()) + if (!utils::nt::is_wine()) { enable_dpi_awareness(); diff --git a/src/client/steam/steam.cpp b/src/client/steam/steam.cpp index cde3b72c..32c0c0b7 100644 --- a/src/client/steam/steam.cpp +++ b/src/client/steam/steam.cpp @@ -1,7 +1,6 @@ #include #include "steam.hpp" -#include "component/arxan.hpp" #include "component/console.hpp" #include @@ -239,7 +238,7 @@ namespace steam // however, on [other] Wine [forks], this should be hit. also, the file dialog may not work.. :P HKEY steam_install_reg; - if (arxan::is_wine()) + if (::utils::nt::is_wine()) { // let's check the registry to see if the user has already manually selected the Steam installation path if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\h1-mod", 0, KEY_QUERY_VALUE, &steam_install_reg) diff --git a/src/common/utils/nt.cpp b/src/common/utils/nt.cpp index 28f027f8..4cead0fa 100644 --- a/src/common/utils/nt.cpp +++ b/src/common/utils/nt.cpp @@ -206,6 +206,19 @@ namespace utils::nt return nullptr; } + bool is_wine() + { + static std::optional is_wine = {}; + + if (!is_wine.has_value()) + { + const utils::nt::library ntdll("ntdll.dll"); + is_wine = ntdll.get_proc("wine_get_version") != nullptr; + } + + return is_wine.value(); + } + void raise_hard_exception() { int data = false; diff --git a/src/common/utils/nt.hpp b/src/common/utils/nt.hpp index ec479e88..c4f58afe 100644 --- a/src/common/utils/nt.hpp +++ b/src/common/utils/nt.hpp @@ -102,6 +102,8 @@ namespace utils::nt HMODULE module_; }; + bool is_wine(); + __declspec(noreturn) void raise_hard_exception(); std::string load_resource(int id);