Better unpack hook
This commit is contained in:
parent
4097ed37d5
commit
d9b834bede
@ -1,5 +1,4 @@
|
|||||||
#include <std_include.hpp>
|
#include <std_include.hpp>
|
||||||
#include "console.hpp"
|
|
||||||
#include "loader/component_loader.hpp"
|
#include "loader/component_loader.hpp"
|
||||||
|
|
||||||
#include <utils/thread.hpp>
|
#include <utils/thread.hpp>
|
||||||
@ -9,10 +8,32 @@ namespace console
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
volatile bool g_started = false;
|
||||||
|
|
||||||
void create_game_console()
|
void create_game_console()
|
||||||
{
|
{
|
||||||
reinterpret_cast<void(*)()>(0x142333F80_g)();
|
reinterpret_cast<void(*)()>(0x142333F80_g)();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_message(const char* message)
|
||||||
|
{
|
||||||
|
if (g_started)
|
||||||
|
{
|
||||||
|
reinterpret_cast<void(*)(int, int, const char*, ...)>(0x1421499C0_g)(0, 0, "%s", message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_stub(const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
char buffer[1024]{0};
|
||||||
|
const int res = vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, fmt, ap);
|
||||||
|
print_message(buffer);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
@ -20,6 +41,8 @@ namespace console
|
|||||||
public:
|
public:
|
||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
|
utils::hook::jump(printf, print_stub);
|
||||||
|
|
||||||
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]
|
||||||
@ -33,8 +56,8 @@ namespace console
|
|||||||
a.sub(eax, edx);
|
a.sub(eax, edx);
|
||||||
a.jmp(0x142333B4F_g);
|
a.jmp(0x142333B4F_g);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
create_game_console();
|
create_game_console();
|
||||||
|
g_started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MSG msg{};
|
MSG msg{};
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace console
|
|
||||||
{
|
|
||||||
void print(int type, const char* fmt, ...);
|
|
||||||
}
|
|
@ -58,7 +58,7 @@ namespace
|
|||||||
patch_steam_import("SteamAPI_Init");
|
patch_steam_import("SteamAPI_Init");
|
||||||
patch_steam_import("SteamAPI_RestartAppIfNecessary");
|
patch_steam_import("SteamAPI_RestartAppIfNecessary");
|
||||||
|
|
||||||
utils::hook::set(game.get_iat_entry("kernel32.dll", "InitializeCriticalSection"), initialize_critical_section);
|
//utils::hook::set(game.get_iat_entry("kernel32.dll", "InitializeCriticalSection"), initialize_critical_section);
|
||||||
utils::hook::set(game.get_iat_entry("kernel32.dll", "ExitProcess"), exit_hook);
|
utils::hook::set(game.get_iat_entry("kernel32.dll", "ExitProcess"), exit_hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <utils/nt.hpp>
|
#include <utils/nt.hpp>
|
||||||
#include <utils/io.hpp>
|
#include <utils/io.hpp>
|
||||||
|
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
uint64_t callbacks::call_id_ = 0;
|
uint64_t callbacks::call_id_ = 0;
|
||||||
@ -109,6 +111,7 @@ namespace steam
|
|||||||
const std::string steam_path = SteamAPI_GetSteamInstallPath();
|
const std::string steam_path = SteamAPI_GetSteamInstallPath();
|
||||||
if (!steam_path.empty() && ::utils::io::file_exists(steam_path + "/steam.exe"))
|
if (!steam_path.empty() && ::utils::io::file_exists(steam_path + "/steam.exe"))
|
||||||
{
|
{
|
||||||
|
component_loader::post_unpack();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ namespace utils::string
|
|||||||
class entry final
|
class entry final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
entry() = default;
|
||||||
|
|
||||||
explicit entry(const size_t _size = MinBufferSize) : size(_size), buffer(nullptr)
|
explicit entry(const size_t _size = MinBufferSize) : size(_size), buffer(nullptr)
|
||||||
{
|
{
|
||||||
if (this->size < MinBufferSize) this->size = MinBufferSize;
|
if (this->size < MinBufferSize) this->size = MinBufferSize;
|
||||||
@ -70,12 +72,12 @@ namespace utils::string
|
|||||||
this->allocate();
|
this->allocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size;
|
size_t size{};
|
||||||
char* buffer;
|
char* buffer{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t current_buffer_;
|
size_t current_buffer_{};
|
||||||
entry string_pool_[Buffers];
|
entry string_pool_[Buffers]{};
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* va(const char* fmt, ...);
|
const char* va(const char* fmt, ...);
|
||||||
|
Loading…
Reference in New Issue
Block a user