Install first hook and do cleanup
This commit is contained in:
parent
60915bd335
commit
47d6d960d8
@ -13,7 +13,7 @@ namespace arxan
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const auto pseudo_steam_id = 0x1337;
|
constexpr auto pseudo_steam_id = 0x1337;
|
||||||
const auto pseudo_steam_handle = reinterpret_cast<HANDLE>(reinterpret_cast<uint64_t>(INVALID_HANDLE_VALUE) -
|
const auto pseudo_steam_handle = reinterpret_cast<HANDLE>(reinterpret_cast<uint64_t>(INVALID_HANDLE_VALUE) -
|
||||||
pseudo_steam_id);
|
pseudo_steam_id);
|
||||||
|
|
||||||
@ -28,16 +28,6 @@ namespace arxan
|
|||||||
return reinterpret_cast<HANDLE>(static_cast<DWORD64>(pid));
|
return reinterpret_cast<HANDLE>(static_cast<DWORD64>(pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_steam_install()
|
|
||||||
{
|
|
||||||
if (!*steam::SteamAPI_GetSteamInstallPath())
|
|
||||||
{
|
|
||||||
MessageBoxA(nullptr, "Steam must be installed for the game to run. Please install steam!", "Error",
|
|
||||||
MB_ICONERROR);
|
|
||||||
TerminateProcess(GetCurrentProcess(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE WINAPI open_process_stub(const DWORD access, const BOOL inherit, const DWORD pid)
|
HANDLE WINAPI open_process_stub(const DWORD access, const BOOL inherit, const DWORD pid)
|
||||||
{
|
{
|
||||||
if (pid == pseudo_steam_id)
|
if (pid == pseudo_steam_id)
|
||||||
@ -372,8 +362,6 @@ namespace arxan
|
|||||||
public:
|
public:
|
||||||
void post_load() override
|
void post_load() override
|
||||||
{
|
{
|
||||||
check_steam_install();
|
|
||||||
|
|
||||||
hide_being_debugged();
|
hide_being_debugged();
|
||||||
scheduler::loop(hide_being_debugged, scheduler::pipeline::async);
|
scheduler::loop(hide_being_debugged, scheduler::pipeline::async);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace console
|
|||||||
{
|
{
|
||||||
void create_game_console()
|
void create_game_console()
|
||||||
{
|
{
|
||||||
reinterpret_cast<void(*)()>(utils::nt::library{}.get_ptr() + 0x2333F80)();
|
reinterpret_cast<void(*)()>(0x142333F80_g)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +20,23 @@ namespace console
|
|||||||
public:
|
public:
|
||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
|
|
||||||
this->terminate_runner_ = false;
|
this->terminate_runner_ = false;
|
||||||
|
|
||||||
this->console_runner_ = utils::thread::create_named_thread("Console IO", [this]
|
this->console_runner_ = utils::thread::create_named_thread("Console IO", [this]
|
||||||
{
|
{
|
||||||
create_game_console();
|
{
|
||||||
|
utils::hook::detour d;
|
||||||
|
d.create(0x142333B40_g, utils::hook::assemble([](utils::hook::assembler& a)
|
||||||
|
{
|
||||||
|
a.mov(r8, "BOIII Console");
|
||||||
|
a.mov(r9d, 0x80CA0000);
|
||||||
|
a.sub(eax, edx);
|
||||||
|
a.jmp(0x142333B4F_g);
|
||||||
|
}));
|
||||||
|
|
||||||
|
create_game_console();
|
||||||
|
}
|
||||||
|
|
||||||
MSG msg{};
|
MSG msg{};
|
||||||
while (!this->terminate_runner_)
|
while (!this->terminate_runner_)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <std_include.hpp>
|
#include <std_include.hpp>
|
||||||
#include "component_loader.hpp"
|
#include "component_loader.hpp"
|
||||||
|
|
||||||
|
#include <utils/nt.hpp>
|
||||||
|
|
||||||
void component_loader::register_component(std::unique_ptr<component_interface>&& component_)
|
void component_loader::register_component(std::unique_ptr<component_interface>&& component_)
|
||||||
{
|
{
|
||||||
get_components().push_back(std::move(component_));
|
get_components().push_back(std::move(component_));
|
||||||
@ -88,3 +90,10 @@ std::vector<std::unique_ptr<component_interface>>& component_loader::get_compone
|
|||||||
|
|
||||||
return *components;
|
return *components;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t operator"" _g(const size_t val)
|
||||||
|
{
|
||||||
|
static auto base = size_t(utils::nt::library{}.get_ptr());
|
||||||
|
assert(base && "Failed to resolve base");
|
||||||
|
return base + (val - 0x140000000);
|
||||||
|
}
|
||||||
|
@ -56,3 +56,5 @@ namespace \
|
|||||||
{ \
|
{ \
|
||||||
static component_loader::installer<name> __component; \
|
static component_loader::installer<name> __component; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t operator"" _g(const size_t val);
|
||||||
|
@ -77,7 +77,7 @@ namespace
|
|||||||
|
|
||||||
bool run()
|
bool run()
|
||||||
{
|
{
|
||||||
srand(uint32_t(time(nullptr)) ^ (~GetTickCount()));
|
srand(uint32_t(time(nullptr)) ^ ~(GetTickCount() * GetCurrentProcessId()));
|
||||||
|
|
||||||
{
|
{
|
||||||
auto premature_shutdown = true;
|
auto premature_shutdown = true;
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <MinHook.h>
|
#include <MinHook.h>
|
||||||
#include <asmjit/core/jitruntime.h>
|
#include <asmjit/core/jitruntime.h>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "steam.hpp"
|
#include "steam.hpp"
|
||||||
|
|
||||||
#include <utils/nt.hpp>
|
#include <utils/nt.hpp>
|
||||||
|
#include <utils/io.hpp>
|
||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
@ -105,12 +106,21 @@ namespace steam
|
|||||||
|
|
||||||
bool SteamAPI_RestartAppIfNecessary()
|
bool SteamAPI_RestartAppIfNecessary()
|
||||||
{
|
{
|
||||||
return false;
|
const std::string steam_path = SteamAPI_GetSteamInstallPath();
|
||||||
|
if (!steam_path.empty() && ::utils::io::file_exists(steam_path + "/steam.exe"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBoxA(nullptr, "Steam must be installed for the game to run. Please install steam!", "Error", MB_ICONERROR);
|
||||||
|
ShellExecuteA(nullptr, "open", "https://store.steampowered.com/about/", nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
|
TerminateProcess(GetCurrentProcess(), 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SteamAPI_Init()
|
bool SteamAPI_Init()
|
||||||
{
|
{
|
||||||
const std::filesystem::path steam_path = steam::SteamAPI_GetSteamInstallPath();
|
const std::filesystem::path steam_path = SteamAPI_GetSteamInstallPath();
|
||||||
if (steam_path.empty()) return true;
|
if (steam_path.empty()) return true;
|
||||||
|
|
||||||
::utils::nt::library::load(steam_path / "tier0_s64.dll");
|
::utils::nt::library::load(steam_path / "tier0_s64.dll");
|
||||||
|
Loading…
Reference in New Issue
Block a user