diff --git a/src/game/scripting/executer.cpp b/src/game/scripting/executer.cpp index 4e02fc6..14c0c1c 100644 --- a/src/game/scripting/executer.cpp +++ b/src/game/scripting/executer.cpp @@ -28,7 +28,7 @@ namespace game::scripting if (offset) { const auto index = 4 * (offset + 0xC800 * (class_id & 1)); - return PINT(SELECT_VALUE(0x1A3BC80, 0x1EFE180, 0x1DC8800))[index]; + return PINT(SELECT_VALUE(0x1A3BC80, 0x1EFE180))[index]; } return -1; diff --git a/src/game/scripting/functions.cpp b/src/game/scripting/functions.cpp index 1861179..8a1336a 100644 --- a/src/game/scripting/functions.cpp +++ b/src/game/scripting/functions.cpp @@ -72,8 +72,8 @@ namespace scripting game::native::scr_call_t get_function_by_index(const std::uint32_t index) { - static const auto function_table = SELECT_VALUE(0x186C68C, 0x1D6EB34, 0x1C152A4); - static const auto method_table = SELECT_VALUE(0x184CDB0, 0x1D4F258, 0x1BF59C8); + static const auto function_table = SELECT_VALUE(0x186C68C, 0x1D6EB34); + static const auto method_table = SELECT_VALUE(0x184CDB0, 0x1D4F258); if (index < 0x1C7) { diff --git a/src/game/structs.hpp b/src/game/structs.hpp index 17af678..fb937aa 100644 --- a/src/game/structs.hpp +++ b/src/game/structs.hpp @@ -623,7 +623,7 @@ namespace game const char* name; }; - enum dvar_flags : std::uint16_t + enum : std::uint16_t { DVAR_NONE = 0, DVAR_ARCHIVE = 1 << 0, diff --git a/src/module/file_system.cpp b/src/module/file_system.cpp index 7b50dff..ce99372 100644 --- a/src/module/file_system.cpp +++ b/src/module/file_system.cpp @@ -7,8 +7,6 @@ #include "file_system.hpp" #include "log_file.hpp" -#define _CRT_SECURE_NO_WARNINGS - static utils::hook::detour sys_default_install_path_hook; static const game::native::dvar_t** fs_homepath; diff --git a/src/module/patches.cpp b/src/module/patches.cpp index 3ffd927..dcc464c 100644 --- a/src/module/patches.cpp +++ b/src/module/patches.cpp @@ -37,6 +37,9 @@ private: utils::hook::set(0x663B5A, 0xEB); utils::hook::set(0x663C54, 0xEB); + // archive "name" dvar + utils::hook::set(0x4296F9, game::native::DVAR_ARCHIVE); + utils::hook(0x44C640, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick(); } @@ -45,6 +48,9 @@ private: // Note: on SP the max value is already 1000 utils::hook(0x55411F, &dvar_register_com_max_fps, HOOK_CALL).install()->quick(); + // archive "name" dvar + utils::hook::set(0x492C82, game::native::DVAR_USERINFO | game::native::DVAR_ARCHIVE); + utils::hook(0x5C9980, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick(); } @@ -72,8 +78,7 @@ private: static const game::native::dvar_t* dvar_register_com_max_fps(const char* dvarName, int value, int min, int /*max*/, unsigned __int16 /*flags*/, const char* description) { - return game::native::Dvar_RegisterInt(dvarName, value, min, 1000, - game::native::dvar_flags::DVAR_ARCHIVE, description); + return game::native::Dvar_RegisterInt(dvarName, value, min, 1000, game::native::DVAR_ARCHIVE, description); } static const char* live_get_local_client_name_stub() diff --git a/src/module/scripting.cpp b/src/module/scripting.cpp index b2d86be..250fd7d 100644 --- a/src/module/scripting.cpp +++ b/src/module/scripting.cpp @@ -73,7 +73,7 @@ namespace scripting add_function(current_file, thread_name, code_pos); } - utils::hook::invoke(SELECT_VALUE(0x4845F0, 0x5616D0, 0x0), thread_name, code_pos); + utils::hook::invoke(SELECT_VALUE(0x4845F0, 0x5616D0), thread_name, code_pos); } void process_script(const char* filename) @@ -91,7 +91,7 @@ namespace scripting current_file = filename; } - utils::hook::invoke(SELECT_VALUE(0x446850, 0x56B130, 0x0), filename); + utils::hook::invoke(SELECT_VALUE(0x446850, 0x56B130), filename); } } diff --git a/src/module/steam_proxy.cpp b/src/module/steam_proxy.cpp index ead1cf8..f7dd3c1 100644 --- a/src/module/steam_proxy.cpp +++ b/src/module/steam_proxy.cpp @@ -69,7 +69,7 @@ private: void run_mod() const { const auto command = "-proc "; - const char* parent_proc = strstr(GetCommandLineA(), command); + const char* parent_proc = std::strstr(GetCommandLineA(), command); if (parent_proc) { @@ -89,11 +89,10 @@ private: { if (!this->steam_client_module_) return nullptr; - for (auto i = 1; i > 0; ++i) + for (auto i = 1; i < 1000; ++i) { - std::string name = utils::string::va("CLIENTENGINE_INTERFACE_VERSION%03i", i); - const auto client_engine = this->steam_client_module_ - .invoke("CreateInterface", name.data(), nullptr); + const auto* name = utils::string::va("CLIENTENGINE_INTERFACE_VERSION%03i", i); + const auto client_engine = this->steam_client_module_.invoke("CreateInterface", name, nullptr); if (client_engine) return client_engine; } @@ -102,12 +101,12 @@ private: void load_client() { - const auto steam_path = ::steam::get_steam_install_directory(); + const std::filesystem::path steam_path = ::steam::get_steam_install_directory(); if (steam_path.empty()) return; - utils::nt::library::load(steam_path + "tier0_s.dll"); - utils::nt::library::load(steam_path + "vstdlib_s.dll"); - this->steam_client_module_ = utils::nt::library::load(steam_path + "steamclient.dll"); + utils::nt::library::load(steam_path / "tier0_s.dll"); + utils::nt::library::load(steam_path / "vstdlib_s.dll"); + this->steam_client_module_ = utils::nt::library::load(steam_path / "steamclient.dll"); if (!this->steam_client_module_) return; this->client_engine_ = load_client_engine(); @@ -136,7 +135,7 @@ private: char our_directory[MAX_PATH] = {0}; GetCurrentDirectoryA(sizeof(our_directory), our_directory); - const std::string cmdline = utils::string::va("\"%s\" -proc %d", path.data(), GetCurrentProcessId()); + const auto* cmdline = utils::string::va("\"%s\" -proc %d", path.data(), GetCurrentProcessId()); game_id game_id; game_id.raw.type = 1; // k_EGameIDTypeGameMod @@ -145,8 +144,7 @@ private: const auto mod_id = "OIW5"; game_id.raw.mod_id = *reinterpret_cast(mod_id) | 0x80000000; - this->client_user_.invoke("SpawnProcess", self.get_path().data(), cmdline.data(), our_directory, - game_id.bits, title.data(), app_id, 0, 0); + this->client_user_.invoke("SpawnProcess", self.get_path().data(), cmdline, our_directory, game_id.bits, title.data(), app_id, 0, 0, 0); } void clean_up_on_error() @@ -157,7 +155,11 @@ private: && this->steam_client_module_.invoke("Steam_BConnected", this->global_user_, this->steam_pipe_) && this->steam_client_module_.invoke("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)) { - scheduler::once(std::bind(&steam_proxy::clean_up_on_error, this)); + scheduler::once([this] + { + clean_up_on_error(); + }); + return; } diff --git a/src/std_include.hpp b/src/std_include.hpp index 6da3ae9..2f1f3b2 100644 --- a/src/std_include.hpp +++ b/src/std_include.hpp @@ -16,6 +16,7 @@ #pragma warning(disable: 26495) #pragma warning(disable: 28020) +#define _CRT_SECURE_NO_WARNINGS #define WIN32_LEAN_AND_MEAN #include diff --git a/src/utils/nt.cpp b/src/utils/nt.cpp index 3bf7538..ebba6d2 100644 --- a/src/utils/nt.cpp +++ b/src/utils/nt.cpp @@ -93,8 +93,7 @@ namespace utils::nt if (!this->is_valid()) return; DWORD protection; - VirtualProtect(this->get_ptr(), this->get_optional_header()->SizeOfImage, PAGE_EXECUTE_READWRITE, - &protection); + VirtualProtect(this->get_ptr(), this->get_optional_header()->SizeOfImage, PAGE_EXECUTE_READWRITE, &protection); } size_t library::get_relative_entry_point() const @@ -116,7 +115,7 @@ namespace utils::nt std::string library::get_name() const { - if (!this->is_valid()) return ""; + if (!this->is_valid()) return {}; auto path = this->get_path(); const auto pos = path.find_last_of("/\\"); @@ -127,17 +126,17 @@ namespace utils::nt std::string library::get_path() const { - if (!this->is_valid()) return ""; + if (!this->is_valid()) return {}; char name[MAX_PATH] = {0}; GetModuleFileNameA(this->module_, name, sizeof name); - return name; + return {name}; } std::string library::get_folder() const { - if (!this->is_valid()) return ""; + if (!this->is_valid()) return {}; const auto path = std::filesystem::path(this->get_path()); return path.parent_path().generic_string();