Merge branch 'develop' of https://github.com/auroramod/iw7-mod
This commit is contained in:
commit
8c194d2fe3
@ -13,6 +13,8 @@
|
|||||||
#include <utils/smbios.hpp>
|
#include <utils/smbios.hpp>
|
||||||
#include <utils/info_string.hpp>
|
#include <utils/info_string.hpp>
|
||||||
#include <utils/cryptography.hpp>
|
#include <utils/cryptography.hpp>
|
||||||
|
#include <utils/properties.hpp>
|
||||||
|
#include <utils/io.hpp>
|
||||||
|
|
||||||
namespace auth
|
namespace auth
|
||||||
{
|
{
|
||||||
@ -31,13 +33,20 @@ namespace auth
|
|||||||
|
|
||||||
std::string get_hw_profile_guid()
|
std::string get_hw_profile_guid()
|
||||||
{
|
{
|
||||||
|
auto hw_profile_path = (utils::properties::get_appdata_path() / "iw7-guid.dat").generic_string();
|
||||||
|
if (utils::io::file_exists(hw_profile_path))
|
||||||
|
{
|
||||||
|
utils::io::remove_file(hw_profile_path);
|
||||||
|
}
|
||||||
|
|
||||||
HW_PROFILE_INFO info;
|
HW_PROFILE_INFO info;
|
||||||
if (!GetCurrentHwProfileA(&info))
|
if (!GetCurrentHwProfileA(&info))
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string{ info.szHwProfileGuid, sizeof(info.szHwProfileGuid) };
|
auto hw_profile_info = std::string{ info.szHwProfileGuid, sizeof(info.szHwProfileGuid) };
|
||||||
|
return hw_profile_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_protected_data()
|
std::string get_protected_data()
|
||||||
@ -52,7 +61,7 @@ namespace auth
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto size = std::min(data_out.cbData, 52ul);
|
const auto size = std::min<DWORD>(data_out.cbData, 52);
|
||||||
std::string result{ reinterpret_cast<char*>(data_out.pbData), size };
|
std::string result{ reinterpret_cast<char*>(data_out.pbData), size };
|
||||||
LocalFree(data_out.pbData);
|
LocalFree(data_out.pbData);
|
||||||
|
|
||||||
@ -76,9 +85,72 @@ namespace auth
|
|||||||
return entropy;
|
return entropy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool load_key(utils::cryptography::ecc::key& key)
|
||||||
|
{
|
||||||
|
std::string data{};
|
||||||
|
|
||||||
|
auto key_path = (utils::properties::get_appdata_path() / "iw7-private.key").generic_string();
|
||||||
|
if (!utils::io::read_file(key_path, &data))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
key.deserialize(data);
|
||||||
|
if (!key.is_valid())
|
||||||
|
{
|
||||||
|
console::error("Loaded key is invalid!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
utils::cryptography::ecc::key generate_key()
|
||||||
|
{
|
||||||
|
auto key = utils::cryptography::ecc::generate_key(512, get_key_entropy());
|
||||||
|
if (!key.is_valid())
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to generate cryptographic key!");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto key_path = (utils::properties::get_appdata_path() / "iw7-private.key").generic_string();
|
||||||
|
if (!utils::io::write_file(key_path, key.serialize()))
|
||||||
|
{
|
||||||
|
console::error("Failed to write cryptographic key!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
console::info("Generated cryptographic key: %llX\n", key.get_hash());
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
utils::cryptography::ecc::key load_or_generate_key()
|
||||||
|
{
|
||||||
|
utils::cryptography::ecc::key key{};
|
||||||
|
if (load_key(key))
|
||||||
|
{
|
||||||
|
console::info("Loaded cryptographic key: %llX\n", key.get_hash());
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return generate_key();
|
||||||
|
}
|
||||||
|
|
||||||
|
utils::cryptography::ecc::key get_key_internal()
|
||||||
|
{
|
||||||
|
auto key = load_or_generate_key();
|
||||||
|
|
||||||
|
auto key_path = (utils::properties::get_appdata_path() / "iw7-public.key").generic_string();
|
||||||
|
if (!utils::io::write_file(key_path, key.get_public_key()))
|
||||||
|
{
|
||||||
|
console::error("Failed to write public key!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
utils::cryptography::ecc::key& get_key()
|
utils::cryptography::ecc::key& get_key()
|
||||||
{
|
{
|
||||||
static auto key = utils::cryptography::ecc::generate_key(512, get_key_entropy());
|
static auto key = get_key_internal();
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +204,7 @@ namespace auth
|
|||||||
utils::hook::jump(patch.first, patch.second);
|
utils::hook::jump(patch.first, patch.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
command::add("guid", []()
|
command::add("guid", []() -> void
|
||||||
{
|
{
|
||||||
console::info("Your guid: %llX\n", steam::SteamUser()->GetSteamID().bits);
|
console::info("Your guid: %llX\n", steam::SteamUser()->GetSteamID().bits);
|
||||||
});
|
});
|
||||||
|
@ -335,7 +335,7 @@ namespace gsc
|
|||||||
const auto script_name = std::filesystem::path(included_path).replace_extension().string();
|
const auto script_name = std::filesystem::path(included_path).replace_extension().string();
|
||||||
|
|
||||||
std::string file_buffer;
|
std::string file_buffer;
|
||||||
if (!read_raw_script_file(script_name, &file_buffer) || file_buffer.empty())
|
if (!read_raw_script_file(included_path, &file_buffer) || file_buffer.empty())
|
||||||
{
|
{
|
||||||
const auto name = get_script_file_name(script_name);
|
const auto name = get_script_file_name(script_name);
|
||||||
if (game::DB_XAssetExists(game::ASSET_TYPE_SCRIPTFILE, name.data()))
|
if (game::DB_XAssetExists(game::ASSET_TYPE_SCRIPTFILE, name.data()))
|
||||||
@ -349,7 +349,7 @@ namespace gsc
|
|||||||
std::vector<std::uint8_t> script_data;
|
std::vector<std::uint8_t> script_data;
|
||||||
script_data.assign(file_buffer.begin(), file_buffer.end());
|
script_data.assign(file_buffer.begin(), file_buffer.end());
|
||||||
|
|
||||||
return { {}, script_data };
|
return {{}, script_data};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,14 +250,14 @@ namespace network
|
|||||||
void send_data(const game::netadr_s& address, const std::string& data)
|
void send_data(const game::netadr_s& address, const std::string& data)
|
||||||
{
|
{
|
||||||
auto size = static_cast<int>(data.size());
|
auto size = static_cast<int>(data.size());
|
||||||
if (size > 1280)
|
|
||||||
{
|
|
||||||
console::error("Packet was too long. Truncated!\n");
|
|
||||||
size = 1280;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (address.type == game::NA_LOOPBACK)
|
if (address.type == game::NA_LOOPBACK)
|
||||||
{
|
{
|
||||||
|
if (size > 1280)
|
||||||
|
{
|
||||||
|
console::error("Packet was too long. Truncated!\n");
|
||||||
|
size = 1280;
|
||||||
|
}
|
||||||
|
|
||||||
game::NET_SendLoopPacket(game::NS_CLIENT1, size, data.data(), &address);
|
game::NET_SendLoopPacket(game::NS_CLIENT1, size, data.data(), &address);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,6 +85,8 @@ namespace party
|
|||||||
|
|
||||||
std::unordered_map<std::string, std::string> hash_cache;
|
std::unordered_map<std::string, std::string> hash_cache;
|
||||||
|
|
||||||
|
const game::dvar_t* sv_say_name = nullptr;
|
||||||
|
|
||||||
std::string get_file_hash(const std::string& file)
|
std::string get_file_hash(const std::string& file)
|
||||||
{
|
{
|
||||||
const auto iter = hash_cache.find(file);
|
const auto iter = hash_cache.find(file);
|
||||||
@ -915,6 +917,71 @@ namespace party
|
|||||||
}, scheduler::pipeline::server);
|
}, scheduler::pipeline::server);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scheduler::once([]()
|
||||||
|
{
|
||||||
|
sv_say_name = game::Dvar_RegisterString("sv_sayName", "console", game::DvarFlags::DVAR_FLAG_NONE, "Custom name for RCON console");
|
||||||
|
}, scheduler::pipeline::main);
|
||||||
|
|
||||||
|
command::add("tell", [](const command::params& params)
|
||||||
|
{
|
||||||
|
if (params.size() < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto client_num = atoi(params.get(1));
|
||||||
|
const auto message = params.join(2);
|
||||||
|
const auto* const name = sv_say_name->current.string;
|
||||||
|
|
||||||
|
game::SV_GameSendServerCommand(client_num, game::SV_CMD_CAN_IGNORE,
|
||||||
|
utils::string::va("%c \"%s: %s\"", 84, name, message.data()));
|
||||||
|
console::info("%s -> %i: %s\n", name, client_num, message.data());
|
||||||
|
});
|
||||||
|
|
||||||
|
command::add("tellraw", [](const command::params& params)
|
||||||
|
{
|
||||||
|
if (params.size() < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto client_num = atoi(params.get(1));
|
||||||
|
const auto message = params.join(2);
|
||||||
|
|
||||||
|
game::SV_GameSendServerCommand(client_num, game::SV_CMD_CAN_IGNORE,
|
||||||
|
utils::string::va("%c \"%s\"", 84, message.data()));
|
||||||
|
console::info("%i: %s\n", client_num, message.data());
|
||||||
|
});
|
||||||
|
|
||||||
|
command::add("say", [](const command::params& params)
|
||||||
|
{
|
||||||
|
if (params.size() < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto message = params.join(1);
|
||||||
|
const auto* const name = sv_say_name->current.string;
|
||||||
|
|
||||||
|
game::SV_GameSendServerCommand(
|
||||||
|
-1, game::SV_CMD_CAN_IGNORE, utils::string::va("%c \"%s: %s\"", 84, name, message.data()));
|
||||||
|
console::info("%s: %s\n", name, message.data());
|
||||||
|
});
|
||||||
|
|
||||||
|
command::add("sayraw", [](const command::params& params)
|
||||||
|
{
|
||||||
|
if (params.size() < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto message = params.join(1);
|
||||||
|
|
||||||
|
game::SV_GameSendServerCommand(-1, game::SV_CMD_CAN_IGNORE,
|
||||||
|
utils::string::va("%c \"%s\"", 84, message.data()));
|
||||||
|
console::info("%s\n", message.data());
|
||||||
|
});
|
||||||
|
|
||||||
network::on("getInfo", [](const game::netadr_s& target, const std::string_view& data)
|
network::on("getInfo", [](const game::netadr_s& target, const std::string_view& data)
|
||||||
{
|
{
|
||||||
utils::info_string info{};
|
utils::info_string info{};
|
||||||
|
@ -219,6 +219,7 @@ namespace rcon
|
|||||||
if (!has_redirected_)
|
if (!has_redirected_)
|
||||||
{
|
{
|
||||||
network::send(redirect_target_, "print", "", '\n');
|
network::send(redirect_target_, "print", "", '\n');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_redirect();
|
clear_redirect();
|
||||||
|
@ -475,7 +475,11 @@ namespace updater
|
|||||||
void post_start() override
|
void post_start() override
|
||||||
{
|
{
|
||||||
delete_old_file();
|
delete_old_file();
|
||||||
run_update();
|
|
||||||
|
if (!utils::flags::has_flag("noupdate"))
|
||||||
|
{
|
||||||
|
run_update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component_priority priority() override
|
component_priority priority() override
|
||||||
|
49
src/client/component/wmi.cpp
Normal file
49
src/client/component/wmi.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include <std_include.hpp>
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
|
#include "console/console.hpp"
|
||||||
|
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
// Speeds up startup by disabling WMI
|
||||||
|
|
||||||
|
namespace wmi
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
HRESULT WINAPI co_initialize_ex_stub(LPVOID pvReserved, DWORD dwCoInit)
|
||||||
|
{
|
||||||
|
if ((uint64_t)_ReturnAddress() == 0x1412B36F2)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CoInitializeEx(pvReserved, dwCoInit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public component_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void* load_import(const std::string& library, const std::string& function) override
|
||||||
|
{
|
||||||
|
if (function == "CoInitializeEx")
|
||||||
|
{
|
||||||
|
return co_initialize_ex_stub;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
// disable WMI and remove Hardware query(uses WMI)
|
||||||
|
utils::hook::set<uint8_t>(0x140110260, 0xC3); // WMI
|
||||||
|
utils::hook::set<uint8_t>(0x14002D808, 0xC3); // Hardware query
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(wmi::component)
|
@ -123,4 +123,3 @@ ICON_IMAGE RCDATA "resources/icon.png"
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
#endif // not APSTUDIO_INVOKED
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ namespace utils::string
|
|||||||
|
|
||||||
void strip(const char* in, char* out, int max)
|
void strip(const char* in, char* out, int max)
|
||||||
{
|
{
|
||||||
if (!in || !out) return;
|
if (!in || !out || !max) return;
|
||||||
|
|
||||||
max--;
|
max--;
|
||||||
auto current = 0;
|
auto current = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user