fix compilation
This commit is contained in:
parent
3620facbdf
commit
c17787c206
@ -28,7 +28,7 @@ namespace game::scripting
|
|||||||
if (offset)
|
if (offset)
|
||||||
{
|
{
|
||||||
const auto index = 4 * (offset + 0xC800 * (class_id & 1));
|
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;
|
return -1;
|
||||||
|
@ -72,8 +72,8 @@ namespace scripting
|
|||||||
|
|
||||||
game::native::scr_call_t get_function_by_index(const std::uint32_t index)
|
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 function_table = SELECT_VALUE(0x186C68C, 0x1D6EB34);
|
||||||
static const auto method_table = SELECT_VALUE(0x184CDB0, 0x1D4F258, 0x1BF59C8);
|
static const auto method_table = SELECT_VALUE(0x184CDB0, 0x1D4F258);
|
||||||
|
|
||||||
if (index < 0x1C7)
|
if (index < 0x1C7)
|
||||||
{
|
{
|
||||||
|
@ -623,7 +623,7 @@ namespace game
|
|||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum dvar_flags : std::uint16_t
|
enum : std::uint16_t
|
||||||
{
|
{
|
||||||
DVAR_NONE = 0,
|
DVAR_NONE = 0,
|
||||||
DVAR_ARCHIVE = 1 << 0,
|
DVAR_ARCHIVE = 1 << 0,
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
#include "file_system.hpp"
|
#include "file_system.hpp"
|
||||||
#include "log_file.hpp"
|
#include "log_file.hpp"
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
|
|
||||||
static utils::hook::detour sys_default_install_path_hook;
|
static utils::hook::detour sys_default_install_path_hook;
|
||||||
|
|
||||||
static const game::native::dvar_t** fs_homepath;
|
static const game::native::dvar_t** fs_homepath;
|
||||||
|
@ -37,6 +37,9 @@ private:
|
|||||||
utils::hook::set<std::uint8_t>(0x663B5A, 0xEB);
|
utils::hook::set<std::uint8_t>(0x663B5A, 0xEB);
|
||||||
utils::hook::set<std::uint8_t>(0x663C54, 0xEB);
|
utils::hook::set<std::uint8_t>(0x663C54, 0xEB);
|
||||||
|
|
||||||
|
// archive "name" dvar
|
||||||
|
utils::hook::set<std::uint8_t>(0x4296F9, game::native::DVAR_ARCHIVE);
|
||||||
|
|
||||||
utils::hook(0x44C640, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick();
|
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
|
// Note: on SP the max value is already 1000
|
||||||
utils::hook(0x55411F, &dvar_register_com_max_fps, HOOK_CALL).install()->quick();
|
utils::hook(0x55411F, &dvar_register_com_max_fps, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
|
// archive "name" dvar
|
||||||
|
utils::hook::set<std::uint32_t>(0x492C82, game::native::DVAR_USERINFO | game::native::DVAR_ARCHIVE);
|
||||||
|
|
||||||
utils::hook(0x5C9980, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick();
|
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,
|
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)
|
int min, int /*max*/, unsigned __int16 /*flags*/, const char* description)
|
||||||
{
|
{
|
||||||
return game::native::Dvar_RegisterInt(dvarName, value, min, 1000,
|
return game::native::Dvar_RegisterInt(dvarName, value, min, 1000, game::native::DVAR_ARCHIVE, description);
|
||||||
game::native::dvar_flags::DVAR_ARCHIVE, description);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* live_get_local_client_name_stub()
|
static const char* live_get_local_client_name_stub()
|
||||||
|
@ -73,7 +73,7 @@ namespace scripting
|
|||||||
add_function(current_file, thread_name, code_pos);
|
add_function(current_file, thread_name, code_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::hook::invoke<void>(SELECT_VALUE(0x4845F0, 0x5616D0, 0x0), thread_name, code_pos);
|
utils::hook::invoke<void>(SELECT_VALUE(0x4845F0, 0x5616D0), thread_name, code_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_script(const char* filename)
|
void process_script(const char* filename)
|
||||||
@ -91,7 +91,7 @@ namespace scripting
|
|||||||
current_file = filename;
|
current_file = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::hook::invoke<void>(SELECT_VALUE(0x446850, 0x56B130, 0x0), filename);
|
utils::hook::invoke<void>(SELECT_VALUE(0x446850, 0x56B130), filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
void run_mod() const
|
void run_mod() const
|
||||||
{
|
{
|
||||||
const auto command = "-proc ";
|
const auto command = "-proc ";
|
||||||
const char* parent_proc = strstr(GetCommandLineA(), command);
|
const char* parent_proc = std::strstr(GetCommandLineA(), command);
|
||||||
|
|
||||||
if (parent_proc)
|
if (parent_proc)
|
||||||
{
|
{
|
||||||
@ -89,11 +89,10 @@ private:
|
|||||||
{
|
{
|
||||||
if (!this->steam_client_module_) return nullptr;
|
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* name = utils::string::va("CLIENTENGINE_INTERFACE_VERSION%03i", i);
|
||||||
const auto client_engine = this->steam_client_module_
|
const auto client_engine = this->steam_client_module_.invoke<void*>("CreateInterface", name, nullptr);
|
||||||
.invoke<void*>("CreateInterface", name.data(), nullptr);
|
|
||||||
if (client_engine) return client_engine;
|
if (client_engine) return client_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,12 +101,12 @@ private:
|
|||||||
|
|
||||||
void load_client()
|
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;
|
if (steam_path.empty()) return;
|
||||||
|
|
||||||
utils::nt::library::load(steam_path + "tier0_s.dll");
|
utils::nt::library::load(steam_path / "tier0_s.dll");
|
||||||
utils::nt::library::load(steam_path + "vstdlib_s.dll");
|
utils::nt::library::load(steam_path / "vstdlib_s.dll");
|
||||||
this->steam_client_module_ = utils::nt::library::load(steam_path + "steamclient.dll");
|
this->steam_client_module_ = utils::nt::library::load(steam_path / "steamclient.dll");
|
||||||
if (!this->steam_client_module_) return;
|
if (!this->steam_client_module_) return;
|
||||||
|
|
||||||
this->client_engine_ = load_client_engine();
|
this->client_engine_ = load_client_engine();
|
||||||
@ -136,7 +135,7 @@ private:
|
|||||||
char our_directory[MAX_PATH] = {0};
|
char our_directory[MAX_PATH] = {0};
|
||||||
GetCurrentDirectoryA(sizeof(our_directory), our_directory);
|
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 game_id;
|
||||||
game_id.raw.type = 1; // k_EGameIDTypeGameMod
|
game_id.raw.type = 1; // k_EGameIDTypeGameMod
|
||||||
@ -145,8 +144,7 @@ private:
|
|||||||
const auto mod_id = "OIW5";
|
const auto mod_id = "OIW5";
|
||||||
game_id.raw.mod_id = *reinterpret_cast<const unsigned int*>(mod_id) | 0x80000000;
|
game_id.raw.mod_id = *reinterpret_cast<const unsigned int*>(mod_id) | 0x80000000;
|
||||||
|
|
||||||
this->client_user_.invoke<bool>("SpawnProcess", self.get_path().data(), cmdline.data(), our_directory,
|
this->client_user_.invoke<bool>("SpawnProcess", self.get_path().data(), cmdline, our_directory, game_id.bits, title.data(), app_id, 0, 0, 0);
|
||||||
game_id.bits, title.data(), app_id, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clean_up_on_error()
|
void clean_up_on_error()
|
||||||
@ -157,7 +155,11 @@ private:
|
|||||||
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_, this->steam_pipe_)
|
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_, this->steam_pipe_)
|
||||||
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_))
|
&& this->steam_client_module_.invoke<bool>("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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#pragma warning(disable: 26495)
|
#pragma warning(disable: 26495)
|
||||||
#pragma warning(disable: 28020)
|
#pragma warning(disable: 28020)
|
||||||
|
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
@ -93,8 +93,7 @@ namespace utils::nt
|
|||||||
if (!this->is_valid()) return;
|
if (!this->is_valid()) return;
|
||||||
|
|
||||||
DWORD protection;
|
DWORD protection;
|
||||||
VirtualProtect(this->get_ptr(), this->get_optional_header()->SizeOfImage, PAGE_EXECUTE_READWRITE,
|
VirtualProtect(this->get_ptr(), this->get_optional_header()->SizeOfImage, PAGE_EXECUTE_READWRITE, &protection);
|
||||||
&protection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t library::get_relative_entry_point() const
|
size_t library::get_relative_entry_point() const
|
||||||
@ -116,7 +115,7 @@ namespace utils::nt
|
|||||||
|
|
||||||
std::string library::get_name() const
|
std::string library::get_name() const
|
||||||
{
|
{
|
||||||
if (!this->is_valid()) return "";
|
if (!this->is_valid()) return {};
|
||||||
|
|
||||||
auto path = this->get_path();
|
auto path = this->get_path();
|
||||||
const auto pos = path.find_last_of("/\\");
|
const auto pos = path.find_last_of("/\\");
|
||||||
@ -127,17 +126,17 @@ namespace utils::nt
|
|||||||
|
|
||||||
std::string library::get_path() const
|
std::string library::get_path() const
|
||||||
{
|
{
|
||||||
if (!this->is_valid()) return "";
|
if (!this->is_valid()) return {};
|
||||||
|
|
||||||
char name[MAX_PATH] = {0};
|
char name[MAX_PATH] = {0};
|
||||||
GetModuleFileNameA(this->module_, name, sizeof name);
|
GetModuleFileNameA(this->module_, name, sizeof name);
|
||||||
|
|
||||||
return name;
|
return {name};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string library::get_folder() const
|
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());
|
const auto path = std::filesystem::path(this->get_path());
|
||||||
return path.parent_path().generic_string();
|
return path.parent_path().generic_string();
|
||||||
|
Loading…
Reference in New Issue
Block a user