move wine check to utils [skip ci]

This commit is contained in:
m 2022-12-03 20:39:55 -06:00
parent 77031a2617
commit e883a16d0c
7 changed files with 20 additions and 27 deletions

View File

@ -111,19 +111,6 @@ namespace arxan
}
}
bool is_wine()
{
static std::optional<bool> is_wine = {};
if (!is_wine.has_value())
{
const utils::nt::library ntdll("ntdll.dll");
is_wine = ntdll.get_proc<void*>("wine_get_version") != nullptr;
}
return is_wine.value();
}
class component final : public component_interface
{
public:

View File

@ -1,6 +0,0 @@
#pragma once
namespace arxan
{
bool is_wine();
}

View File

@ -1,11 +1,11 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "arxan.hpp"
#include "system_check.hpp"
#include "game/game.hpp"
#include <utils/nt.hpp>
#include <utils/io.hpp>
#include <utils/cryptography.hpp>
@ -69,7 +69,7 @@ namespace system_check
void verify_binary_version()
{
const auto value = *reinterpret_cast<DWORD*>(0x1337_b);
if (!arxan::is_wine())
if (!utils::nt::is_wine())
{
if (value == 0x60202B6A || value == 0xBC0E9FE)
{

View File

@ -4,8 +4,6 @@
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "component/arxan.hpp"
#include <utils/flags.hpp>
#include <utils/io.hpp>
#include <utils/string.hpp>
@ -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();

View File

@ -1,7 +1,6 @@
#include <std_include.hpp>
#include "steam.hpp"
#include "component/arxan.hpp"
#include "component/console.hpp"
#include <utils/nt.hpp>
@ -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)

View File

@ -206,6 +206,19 @@ namespace utils::nt
return nullptr;
}
bool is_wine()
{
static std::optional<bool> is_wine = {};
if (!is_wine.has_value())
{
const utils::nt::library ntdll("ntdll.dll");
is_wine = ntdll.get_proc<void*>("wine_get_version") != nullptr;
}
return is_wine.value();
}
void raise_hard_exception()
{
int data = false;

View File

@ -102,6 +102,8 @@ namespace utils::nt
HMODULE module_;
};
bool is_wine();
__declspec(noreturn) void raise_hard_exception();
std::string load_resource(int id);