t7x/src/client/game/game.cpp

35 lines
632 B
C++
Raw Normal View History

#include <std_include.hpp>
#include "game.hpp"
2022-06-02 07:49:43 -04:00
namespace game
{
2023-01-01 19:12:14 -05:00
const utils::nt::library& get_host_library()
2022-06-02 07:49:43 -04:00
{
2023-01-01 19:12:14 -05:00
static auto host_library = []
2022-06-02 07:49:43 -04:00
{
2023-01-01 19:12:14 -05:00
utils::nt::library host{};
if (!host || host == utils::nt::library::get_by_address(get_base))
2022-06-02 07:49:43 -04:00
{
2023-01-01 19:12:14 -05:00
throw std::runtime_error("Invalid host application");
}
2023-01-01 15:46:36 -05:00
2023-01-01 19:12:14 -05:00
return host;
}();
2023-01-01 15:51:04 -05:00
2023-01-01 19:12:14 -05:00
return host_library;
2023-01-01 15:46:36 -05:00
}
2022-10-28 16:16:14 -04:00
2023-01-01 15:46:36 -05:00
size_t get_base()
{
2023-01-02 07:57:00 -05:00
static const auto base = reinterpret_cast<size_t>(get_host_library().get_ptr());
2022-11-11 11:19:26 -05:00
return base;
2022-10-28 16:16:14 -04:00
}
2023-01-01 15:46:36 -05:00
bool is_server()
{
2023-01-02 07:57:00 -05:00
static const auto server = get_host_library().get_optional_header()->CheckSum == 0x14C28B4;
2023-01-01 15:46:36 -05:00
return server;
}
2022-06-02 07:49:43 -04:00
}