Rename pre_start to post load and introduce pre_load event
This commit is contained in:
parent
c974e12731
commit
9a7b72dcd5
@ -698,7 +698,7 @@ namespace arxan
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void pre_start() override
|
||||
void post_load() override
|
||||
{
|
||||
auto* dll_characteristics = &utils::nt::library().get_optional_header()->DllCharacteristics;
|
||||
utils::hook::set<WORD>(dll_characteristics, *dll_characteristics | IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE);
|
||||
|
@ -456,7 +456,7 @@ namespace demonware
|
||||
tcp_servers.create<umbrella_server>("prod.umbrella.demonware.net");
|
||||
}
|
||||
|
||||
void pre_start() override
|
||||
void post_load() override
|
||||
{
|
||||
register_hook("send", io::send_stub);
|
||||
register_hook("recv", io::recv_stub);
|
||||
|
@ -202,7 +202,7 @@ namespace exception
|
||||
SetUnhandledExceptionFilter(exception_filter);
|
||||
}
|
||||
|
||||
void pre_start() override
|
||||
void post_load() override
|
||||
{
|
||||
const utils::nt::library ntdll("ntdll.dll");
|
||||
auto* set_filter = ntdll.get_proc<void(*)(LPTOP_LEVEL_EXCEPTION_FILTER)>("RtlSetUnhandledExceptionFilter");
|
||||
|
@ -32,7 +32,7 @@ namespace icon
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void pre_start() override
|
||||
void post_load() override
|
||||
{
|
||||
load_icon_a_hook.create(LoadIconA, load_icon_a_stub);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ namespace scheduler
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void pre_start() override
|
||||
void post_load() override
|
||||
{
|
||||
thread = utils::thread::create_named_thread("Async Scheduler", []()
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ namespace steam_proxy
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void pre_start() override
|
||||
void post_load() override
|
||||
{
|
||||
load_client();
|
||||
perform_cleanup_if_needed();
|
||||
|
@ -5,7 +5,11 @@ class component_interface
|
||||
public:
|
||||
virtual ~component_interface() = default;
|
||||
|
||||
virtual void pre_start()
|
||||
virtual void pre_load()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void post_load()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ void component_loader::register_component(std::unique_ptr<component_interface>&&
|
||||
});
|
||||
}
|
||||
|
||||
bool component_loader::pre_start()
|
||||
bool component_loader::pre_load()
|
||||
{
|
||||
static auto res = []
|
||||
{
|
||||
@ -25,7 +25,36 @@ bool component_loader::pre_start()
|
||||
{
|
||||
for (const auto& component_ : get_components())
|
||||
{
|
||||
component_->pre_start();
|
||||
component_->pre_load();
|
||||
}
|
||||
}
|
||||
catch (premature_shutdown_trigger&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
MessageBoxA(nullptr, e.what(), "Error", MB_ICONERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool component_loader::post_load()
|
||||
{
|
||||
static auto res = []
|
||||
{
|
||||
clean();
|
||||
|
||||
try
|
||||
{
|
||||
for (const auto& component_ : get_components())
|
||||
{
|
||||
component_->post_load();
|
||||
}
|
||||
}
|
||||
catch (premature_shutdown_trigger&)
|
||||
|
@ -40,7 +40,8 @@ public:
|
||||
|
||||
static void register_component(std::unique_ptr<component_interface>&& component);
|
||||
|
||||
static bool pre_start();
|
||||
static bool pre_load();
|
||||
static bool post_load();
|
||||
static void post_unpack();
|
||||
static void pre_destroy();
|
||||
static void clean();
|
||||
|
@ -157,6 +157,11 @@ namespace
|
||||
{
|
||||
remove_crash_file();
|
||||
|
||||
if (!component_loader::pre_load())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
entry_point = load_process("BlackOps3.exe");
|
||||
if (!entry_point)
|
||||
{
|
||||
@ -165,7 +170,7 @@ namespace
|
||||
|
||||
patch_imports();
|
||||
|
||||
if (!component_loader::pre_start())
|
||||
if (!component_loader::post_load())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user