diff --git a/src/client/component/arxan.cpp b/src/client/component/arxan.cpp index 9ea695ba..fa29f6dd 100644 --- a/src/client/component/arxan.cpp +++ b/src/client/component/arxan.cpp @@ -13,7 +13,7 @@ namespace arxan { namespace { - const auto pseudo_steam_id = 0x1337; + constexpr auto pseudo_steam_id = 0x1337; const auto pseudo_steam_handle = reinterpret_cast(reinterpret_cast(INVALID_HANDLE_VALUE) - pseudo_steam_id); @@ -28,16 +28,6 @@ namespace arxan return reinterpret_cast(static_cast(pid)); } - void check_steam_install() - { - if (!*steam::SteamAPI_GetSteamInstallPath()) - { - MessageBoxA(nullptr, "Steam must be installed for the game to run. Please install steam!", "Error", - MB_ICONERROR); - TerminateProcess(GetCurrentProcess(), 1); - } - } - HANDLE WINAPI open_process_stub(const DWORD access, const BOOL inherit, const DWORD pid) { if (pid == pseudo_steam_id) @@ -372,8 +362,6 @@ namespace arxan public: void post_load() override { - check_steam_install(); - hide_being_debugged(); scheduler::loop(hide_being_debugged, scheduler::pipeline::async); diff --git a/src/client/component/console.cpp b/src/client/component/console.cpp index 6e1bb186..1f6efe59 100644 --- a/src/client/component/console.cpp +++ b/src/client/component/console.cpp @@ -11,7 +11,7 @@ namespace console { void create_game_console() { - reinterpret_cast(utils::nt::library{}.get_ptr() + 0x2333F80)(); + reinterpret_cast(0x142333F80_g)(); } } @@ -20,11 +20,23 @@ namespace console public: void post_unpack() override { + this->terminate_runner_ = false; this->console_runner_ = utils::thread::create_named_thread("Console IO", [this] { - create_game_console(); + { + utils::hook::detour d; + d.create(0x142333B40_g, utils::hook::assemble([](utils::hook::assembler& a) + { + a.mov(r8, "BOIII Console"); + a.mov(r9d, 0x80CA0000); + a.sub(eax, edx); + a.jmp(0x142333B4F_g); + })); + + create_game_console(); + } MSG msg{}; while (!this->terminate_runner_) diff --git a/src/client/loader/component_loader.cpp b/src/client/loader/component_loader.cpp index 41abba14..55d06200 100644 --- a/src/client/loader/component_loader.cpp +++ b/src/client/loader/component_loader.cpp @@ -1,6 +1,8 @@ #include #include "component_loader.hpp" +#include + void component_loader::register_component(std::unique_ptr&& component_) { get_components().push_back(std::move(component_)); @@ -88,3 +90,10 @@ std::vector>& component_loader::get_compone return *components; } + +size_t operator"" _g(const size_t val) +{ + static auto base = size_t(utils::nt::library{}.get_ptr()); + assert(base && "Failed to resolve base"); + return base + (val - 0x140000000); +} diff --git a/src/client/loader/component_loader.hpp b/src/client/loader/component_loader.hpp index 2a21f724..c4e40863 100644 --- a/src/client/loader/component_loader.hpp +++ b/src/client/loader/component_loader.hpp @@ -56,3 +56,5 @@ namespace \ { \ static component_loader::installer __component; \ } + +size_t operator"" _g(const size_t val); diff --git a/src/client/main.cpp b/src/client/main.cpp index f4f9b253..bdafc3d8 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -77,7 +77,7 @@ namespace bool run() { - srand(uint32_t(time(nullptr)) ^ (~GetTickCount())); + srand(uint32_t(time(nullptr)) ^ ~(GetTickCount() * GetCurrentProcessId())); { auto premature_shutdown = true; diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index 78673d8d..493109cc 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -76,6 +76,7 @@ #include #include #include +#include #include #include diff --git a/src/client/steam/steam.cpp b/src/client/steam/steam.cpp index 9dbdae42..6c933c1f 100644 --- a/src/client/steam/steam.cpp +++ b/src/client/steam/steam.cpp @@ -2,6 +2,7 @@ #include "steam.hpp" #include +#include namespace steam { @@ -105,12 +106,21 @@ namespace steam bool SteamAPI_RestartAppIfNecessary() { - return false; + const std::string steam_path = SteamAPI_GetSteamInstallPath(); + if (!steam_path.empty() && ::utils::io::file_exists(steam_path + "/steam.exe")) + { + return false; + } + + MessageBoxA(nullptr, "Steam must be installed for the game to run. Please install steam!", "Error", MB_ICONERROR); + ShellExecuteA(nullptr, "open", "https://store.steampowered.com/about/", nullptr, nullptr, SW_SHOWNORMAL); + TerminateProcess(GetCurrentProcess(), 1); + return true; } bool SteamAPI_Init() { - const std::filesystem::path steam_path = steam::SteamAPI_GetSteamInstallPath(); + const std::filesystem::path steam_path = SteamAPI_GetSteamInstallPath(); if (steam_path.empty()) return true; ::utils::nt::library::load(steam_path / "tier0_s64.dll");