diff --git a/src/client/component/resources.cpp b/src/client/component/resources.cpp index f1292527..1b4cd825 100644 --- a/src/client/component/resources.cpp +++ b/src/client/component/resources.cpp @@ -32,20 +32,34 @@ namespace resources public: ~component() { + if (utils::nt::is_wine()) + { + return; + } + if (icon) DestroyIcon(icon); if (splash) DeleteObject(splash); } void post_start() override { - const utils::nt::library self; + if (utils::nt::is_wine()) + { + return; + } + const utils::nt::library self; icon = LoadIconA(self.get_handle(), MAKEINTRESOURCEA(ID_ICON)); splash = LoadImageA(self.get_handle(), MAKEINTRESOURCEA(IMAGE_SPLASH), 0, 0, 0, LR_COPYFROMRESOURCE); } void* load_import(const std::string& library, const std::string& function) override { + if (utils::nt::is_wine()) + { + return nullptr; + } + if (library == "USER32.dll") { if (function == "LoadIconA") diff --git a/src/client/component/splash.cpp b/src/client/component/splash.cpp index c03e99bc..02964b84 100644 --- a/src/client/component/splash.cpp +++ b/src/client/component/splash.cpp @@ -13,13 +13,18 @@ namespace splash public: void post_start() override { + if (utils::nt::is_wine()) + { + return; + } + const utils::nt::library self; image_ = LoadImageA(self, MAKEINTRESOURCE(IMAGE_SPLASH), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); } void post_load() override { - if (game::environment::is_dedi()) + if (utils::nt::is_wine() || game::environment::is_dedi()) { return; } @@ -31,12 +36,20 @@ namespace splash { // Disable native splash screen utils::hook::set(0xD58240_b, 0xC3); - utils::hook::jump(0xD584F0_b, destroy_stub, true); - utils::hook::jump(0xD58530_b, destroy_stub, true); + if (!utils::nt::is_wine()) + { + utils::hook::jump(0xD584F0_b, destroy_stub, true); + utils::hook::jump(0xD58530_b, destroy_stub, true); + } } void pre_destroy() override { + if (utils::nt::is_wine() || game::environment::is_dedi()) + { + return; + } + this->destroy(); MSG msg; diff --git a/src/client/component/steam_proxy.cpp b/src/client/component/steam_proxy.cpp index 64ecda83..b93dc5e1 100644 --- a/src/client/component/steam_proxy.cpp +++ b/src/client/component/steam_proxy.cpp @@ -40,6 +40,12 @@ namespace steam_proxy error, }; + bool is_disabled() + { + static const auto disabled = utils::flags::has_flag("nosteam"); + return disabled; + } + void* load_client_engine() { if (!steam_client_module_) return nullptr; @@ -175,13 +181,18 @@ namespace steam_proxy public: void post_load() override { + if (game::environment::is_dedi() || is_disabled() || !FindWindowA(0, "Steam")) + { + return; + } + load_client(); perform_cleanup_if_needed(); } void post_unpack() override { - if (game::environment::is_dedi()) + if (game::environment::is_dedi() || is_disabled() || !FindWindowA(0, "Steam")) { return; } diff --git a/src/client/component/system_check.cpp b/src/client/component/system_check.cpp index 7ba2e874..32b38323 100644 --- a/src/client/component/system_check.cpp +++ b/src/client/component/system_check.cpp @@ -4,8 +4,9 @@ #include "game/game.hpp" -#include #include +#include +#include namespace system_check { @@ -66,9 +67,12 @@ namespace system_check void verify_binary_version() { const auto value = *reinterpret_cast(0x1337_b); - if (value != 0xB43C9275) + if (!utils::nt::is_wine()) { - throw std::runtime_error("Unsupported Call of Duty: Infinite Warfare version"); + if (value != 0xB43C9275) + { + throw std::runtime_error("Unsupported Call of Duty: Infinite Warfare version"); + } } } } diff --git a/src/client/steam/steam.cpp b/src/client/steam/steam.cpp index b777a91f..0e8f4589 100644 --- a/src/client/steam/steam.cpp +++ b/src/client/steam/steam.cpp @@ -115,8 +115,8 @@ namespace steam bool SteamAPI_Init() { - const std::filesystem::path steam_path = SteamAPI_GetSteamInstallPath(); - if (steam_path.empty()) return false; + const std::filesystem::path steam_path = steam::SteamAPI_GetSteamInstallPath(); + if (steam_path.empty()) return true; // h1-mod has this as true, is this right? ::utils::nt::library::load(steam_path / "tier0_s64.dll"); ::utils::nt::library::load(steam_path / "vstdlib_s64.dll"); @@ -165,17 +165,23 @@ namespace steam return install_path.data(); } + char path[MAX_PATH] = {0}; + DWORD length = sizeof(path); + + std::string path_str; + if (::utils::io::read_file("steam_path.txt", &path_str)) // steam_path.txt in root for directory + { + install_path = path_str; + return install_path.data(); + } + + // check if Steam contains information in registry for the install path HKEY reg_key; if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\WOW6432Node\\Valve\\Steam", 0, KEY_QUERY_VALUE, - ®_key) == - ERROR_SUCCESS) + ®_key) == ERROR_SUCCESS) { - char path[MAX_PATH] = {0}; - DWORD length = sizeof(path); - RegQueryValueExA(reg_key, "InstallPath", nullptr, nullptr, reinterpret_cast(path), - &length); + RegQueryValueExA(reg_key, "InstallPath", nullptr, nullptr, reinterpret_cast(path), &length); RegCloseKey(reg_key); - install_path = path; } diff --git a/src/common/utils/nt.cpp b/src/common/utils/nt.cpp index cf8dc220..93993c2a 100644 --- a/src/common/utils/nt.cpp +++ b/src/common/utils/nt.cpp @@ -213,6 +213,17 @@ namespace utils::nt return nullptr; } + bool is_wine() + { + static const auto has_wine_export = []() -> bool + { + const library ntdll("ntdll.dll"); + return ntdll.get_proc("wine_get_version"); + }(); + + return has_wine_export; + } + bool is_shutdown_in_progress() { static auto* shutdown_in_progress = [] diff --git a/src/common/utils/nt.hpp b/src/common/utils/nt.hpp index 5503e4d9..14c7397b 100644 --- a/src/common/utils/nt.hpp +++ b/src/common/utils/nt.hpp @@ -165,6 +165,8 @@ namespace utils::nt HANDLE handle_{ InvalidHandle }; }; + bool is_wine(); + bool is_shutdown_in_progress(); __declspec(noreturn) void raise_hard_exception();