Add CEG patches
This commit is contained in:
@ -5,10 +5,6 @@ loader::loader(const launcher::mode mode) : mode_(mode)
|
||||
{
|
||||
}
|
||||
|
||||
void loader::patch()
|
||||
{
|
||||
}
|
||||
|
||||
FARPROC loader::load(const utils::nt::module& module) const
|
||||
{
|
||||
const auto buffer = this->load_binary();
|
||||
|
@ -7,7 +7,6 @@ class loader final
|
||||
public:
|
||||
explicit loader(launcher::mode mode);
|
||||
|
||||
void patch();
|
||||
FARPROC load(const utils::nt::module& module) const;
|
||||
|
||||
void set_import_resolver(const std::function<FARPROC(const std::string&, const std::string&)>& resolver);
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include "launcher/launcher.hpp"
|
||||
|
||||
class module
|
||||
{
|
||||
public:
|
||||
virtual ~module() {};
|
||||
virtual void pre_load() {}
|
||||
virtual void post_load() {}
|
||||
virtual void pre_destroy() {}
|
||||
};
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include <std_include.hpp>
|
||||
#include "module_loader.hpp"
|
||||
|
||||
launcher::mode module_loader::mode_ = launcher::mode::NONE;
|
||||
std::vector<std::unique_ptr<module>>* module_loader::modules_ = nullptr;
|
||||
|
||||
void module_loader::register_module(std::unique_ptr<module>&& module_)
|
||||
{
|
||||
if(!module_loader::modules_)
|
||||
if (!module_loader::modules_)
|
||||
{
|
||||
module_loader::modules_ = new std::vector<std::unique_ptr<module>>();
|
||||
atexit(module_loader::destroy_modules);
|
||||
@ -14,9 +15,45 @@ void module_loader::register_module(std::unique_ptr<module>&& module_)
|
||||
module_loader::modules_->push_back(std::move(module_));
|
||||
}
|
||||
|
||||
void module_loader::post_load()
|
||||
{
|
||||
static auto handled = false;
|
||||
if (handled || !module_loader::modules_) return;
|
||||
handled = true;
|
||||
|
||||
for (const auto& module_ : *module_loader::modules_)
|
||||
{
|
||||
module_->post_load();
|
||||
}
|
||||
}
|
||||
|
||||
void module_loader::pre_destroy()
|
||||
{
|
||||
static auto handled = false;
|
||||
if (handled || !module_loader::modules_) return;
|
||||
handled = true;
|
||||
|
||||
for (const auto& module_ : *module_loader::modules_)
|
||||
{
|
||||
module_->pre_destroy();
|
||||
}
|
||||
}
|
||||
|
||||
launcher::mode module_loader::get_mode()
|
||||
{
|
||||
return module_loader::mode_;
|
||||
}
|
||||
|
||||
void module_loader::set_mode(const launcher::mode mode)
|
||||
{
|
||||
module_loader::mode_ = mode;
|
||||
}
|
||||
|
||||
void module_loader::destroy_modules()
|
||||
{
|
||||
if(!module_loader::modules_) return;
|
||||
module_loader::pre_destroy();
|
||||
|
||||
if (!module_loader::modules_) return;
|
||||
|
||||
delete module_loader::modules_;
|
||||
module_loader::modules_ = nullptr;
|
||||
|
@ -18,7 +18,14 @@ public:
|
||||
|
||||
static void register_module(std::unique_ptr<module>&& module);
|
||||
|
||||
static void post_load();
|
||||
static void pre_destroy();
|
||||
|
||||
static launcher::mode get_mode();
|
||||
static void set_mode(launcher::mode mode);
|
||||
|
||||
private:
|
||||
static launcher::mode mode_;
|
||||
static std::vector<std::unique_ptr<module>>* modules_;
|
||||
|
||||
static void destroy_modules();
|
||||
|
Reference in New Issue
Block a user