From 0b082d5540cd237a863714db6d17536cc73f2ccf Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 17 May 2022 10:38:54 +0200 Subject: [PATCH] Basic 1.15 support --- premake5.lua | 2 +- src/client/component/arxan.cpp | 20 +++++++++++++++++++- src/client/main.cpp | 3 ++- src/client/std_include.cpp | 13 +++++++------ src/client/std_include.hpp | 2 +- src/client/steam/steam.cpp | 9 +++++++++ 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/premake5.lua b/premake5.lua index 16043516..299c9b69 100644 --- a/premake5.lua +++ b/premake5.lua @@ -302,7 +302,7 @@ targetname "h1-mod" pchheader "std_include.hpp" pchsource "src/client/std_include.cpp" -linkoptions {"/IGNORE:4254", "/DYNAMICBASE:NO", "/SAFESEH:NO", "/LARGEADDRESSAWARE", "/LAST:.main", "/PDBCompress"} +linkoptions {"/IGNORE:4254", "/SAFESEH:NO", "/LARGEADDRESSAWARE", "/PDBCompress"} files {"./src/client/**.rc", "./src/client/**.hpp", "./src/client/**.cpp", "./src/client/resources/**.*"} diff --git a/src/client/component/arxan.cpp b/src/client/component/arxan.cpp index 02989710..98b3d108 100644 --- a/src/client/component/arxan.cpp +++ b/src/client/component/arxan.cpp @@ -9,6 +9,24 @@ namespace arxan { namespace { + DWORD get_steam_pid() + { + static DWORD pid = 0; //234567;//GetCurrentProcessId(); + if (pid) return pid; + + HKEY hRegKey; + + if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_QUERY_VALUE, + &hRegKey) != ERROR_SUCCESS) + return pid; + + DWORD dwLength = sizeof(pid); + RegQueryValueExA(hRegKey, "pid", nullptr, nullptr, reinterpret_cast(&pid), &dwLength); + RegCloseKey(hRegKey); + + return pid; + } + utils::hook::detour nt_close_hook; utils::hook::detour nt_query_information_process_hook; @@ -31,7 +49,7 @@ namespace arxan GetWindowThreadProcessId(shell_window, &explorer_pid); } - static_cast(info)->Reserved3 = PVOID(DWORD64(explorer_pid)); + static_cast(info)->Reserved3 = PVOID(DWORD64(get_steam_pid())); } else if (info_class == 30) // ProcessDebugObjectHandle { diff --git a/src/client/main.cpp b/src/client/main.cpp index c6f7ad62..a8c3a78b 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -57,7 +57,8 @@ FARPROC load_binary(const launcher::mode mode, uint64_t* base_address) loader.set_import_resolver([self](const std::string& library, const std::string& function) -> void* { - if (library == "steam_api64.dll") + if (library == "steam_api64.dll" + && function != "SteamAPI_GetSteamInstallPath") // Arxan requires one valid steam api import - maybe SteamAPI_Shutdown is better? { return self.get_proc(function); } diff --git a/src/client/std_include.cpp b/src/client/std_include.cpp index 75331ed0..5622d708 100644 --- a/src/client/std_include.cpp +++ b/src/client/std_include.cpp @@ -1,15 +1,15 @@ #include +#pragma comment(linker, "/stack:0x1000000") + +#ifdef INJECT_HOST_AS_LIB +//#pragma comment(linker, "/base:0x160000000") +#else +#pragma comment(linker, "/base:0x140000000") #pragma comment(linker, "/merge:.data=.cld") #pragma comment(linker, "/merge:.rdata=.clr") #pragma comment(linker, "/merge:.cl=.main") #pragma comment(linker, "/merge:.text=.main") -#pragma comment(linker, "/stack:0x1000000") - -#ifdef INJECT_HOST_AS_LIB -#pragma comment(linker, "/base:0x160000000") -#else -#pragma comment(linker, "/base:0x140000000") #endif #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language=''\"") @@ -47,3 +47,4 @@ extern "C" return -1; } } + diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index 0fd21793..e43275c3 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -3,7 +3,7 @@ #define BINARY_PAYLOAD_SIZE 0x14000000 // Decide whether to load the game as lib or to inject it -//#define INJECT_HOST_AS_LIB +#define INJECT_HOST_AS_LIB #pragma warning(push) #pragma warning(disable: 4100) diff --git a/src/client/steam/steam.cpp b/src/client/steam/steam.cpp index b6fb0dbe..bad30c5a 100644 --- a/src/client/steam/steam.cpp +++ b/src/client/steam/steam.cpp @@ -1,6 +1,8 @@ #include #include "steam.hpp" +#include + namespace steam { uint64_t callbacks::call_id_ = 0; @@ -108,6 +110,13 @@ namespace steam bool SteamAPI_Init() { + const std::filesystem::path steam_path = steam::SteamAPI_GetSteamInstallPath(); + if (steam_path.empty()) return true; + + ::utils::nt::library::load(steam_path / "tier0_s64.dll"); + ::utils::nt::library::load(steam_path / "vstdlib_s64.dll"); + ::utils::nt::library::load(steam_path / "gameoverlayrenderer64.dll"); + ::utils::nt::library::load(steam_path / "steamclient64.dll"); return true; }