mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Disables script patches from the Lua layer on eject. (#3628)
This commit is contained in:
parent
2519de72f6
commit
a63279dde9
@ -25,6 +25,12 @@ namespace lua::scr_patch
|
|||||||
module->m_registered_script_patches.push_back(std::make_unique<scr_patch>(*this));
|
module->m_registered_script_patches.push_back(std::make_unique<scr_patch>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scr_patch::~scr_patch()
|
||||||
|
{
|
||||||
|
disable();
|
||||||
|
big::g_script_patcher_service->remove_patch(m_patch_name);
|
||||||
|
}
|
||||||
|
|
||||||
void scr_patch::enable()
|
void scr_patch::enable()
|
||||||
{
|
{
|
||||||
if (!m_enable)
|
if (!m_enable)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace lua::scr_patch
|
namespace lua::scr_patch
|
||||||
{
|
{
|
||||||
struct scr_patch
|
class scr_patch
|
||||||
{
|
{
|
||||||
rage::joaat_t m_script;
|
rage::joaat_t m_script;
|
||||||
std::string m_patch_name;
|
std::string m_patch_name;
|
||||||
@ -21,6 +21,7 @@ namespace lua::scr_patch
|
|||||||
// Param: patch_: table: The bytes to be written into the script's bytecode.
|
// Param: patch_: table: The bytes to be written into the script's bytecode.
|
||||||
// Adds a patch for the specified script.
|
// Adds a patch for the specified script.
|
||||||
explicit scr_patch(const std::string& script_name, const std::string& patch_name, const std::string& pattern, const int offset, sol::table patch_, sol::this_state state);
|
explicit scr_patch(const std::string& script_name, const std::string& patch_name, const std::string& pattern, const int offset, sol::table patch_, sol::this_state state);
|
||||||
|
~scr_patch();
|
||||||
|
|
||||||
// Lua API: Function
|
// Lua API: Function
|
||||||
// Class: scr_patch
|
// Class: scr_patch
|
||||||
|
@ -126,6 +126,7 @@ namespace big
|
|||||||
{
|
{
|
||||||
std::lock_guard guard(m_registered_scripts_mutex);
|
std::lock_guard guard(m_registered_scripts_mutex);
|
||||||
m_registered_scripts.clear();
|
m_registered_scripts.clear();
|
||||||
|
m_registered_script_patches.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto owned_tab : m_owned_tabs)
|
for (const auto owned_tab : m_owned_tabs)
|
||||||
|
@ -28,6 +28,11 @@ namespace big
|
|||||||
return m_script;
|
return m_script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string get_name()
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
script_patch(rage::joaat_t script, std::string name, const memory::pattern pattern, int32_t offset, std::vector<uint8_t> patch, bool* enable_bool);
|
script_patch(rage::joaat_t script, std::string name, const memory::pattern pattern, int32_t offset, std::vector<uint8_t> patch, bool* enable_bool);
|
||||||
void update(script_data* data);
|
void update(script_data* data);
|
||||||
};
|
};
|
||||||
|
@ -70,6 +70,21 @@ namespace big
|
|||||||
m_script_patches.push_back(std::move(patch));
|
m_script_patches.push_back(std::move(patch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void script_patcher_service::remove_patch(std::string_view patch_name)
|
||||||
|
{
|
||||||
|
for (auto it = m_script_patches.begin(); it != m_script_patches.end();)
|
||||||
|
{
|
||||||
|
if (it->get_name() == patch_name)
|
||||||
|
{
|
||||||
|
it = m_script_patches.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void script_patcher_service::on_script_load(rage::scrProgram* program)
|
void script_patcher_service::on_script_load(rage::scrProgram* program)
|
||||||
{
|
{
|
||||||
if (get_data_for_script(program->m_name_hash) == nullptr && does_script_have_patches(program->m_name_hash))
|
if (get_data_for_script(program->m_name_hash) == nullptr && does_script_have_patches(program->m_name_hash))
|
||||||
|
@ -9,7 +9,7 @@ namespace big
|
|||||||
{
|
{
|
||||||
class script_patcher_service
|
class script_patcher_service
|
||||||
{
|
{
|
||||||
std::vector<script_patch> m_script_patches;
|
std::list<script_patch> m_script_patches;
|
||||||
std::unordered_map<rage::joaat_t, std::unique_ptr<script_data>> m_script_data;
|
std::unordered_map<rage::joaat_t, std::unique_ptr<script_data>> m_script_data;
|
||||||
script_data* get_data_for_script(rage::joaat_t script);
|
script_data* get_data_for_script(rage::joaat_t script);
|
||||||
bool does_script_have_patches(rage::joaat_t script);
|
bool does_script_have_patches(rage::joaat_t script);
|
||||||
@ -20,6 +20,7 @@ namespace big
|
|||||||
~script_patcher_service();
|
~script_patcher_service();
|
||||||
|
|
||||||
void add_patch(script_patch&& patch);
|
void add_patch(script_patch&& patch);
|
||||||
|
void remove_patch(std::string_view patch_name);
|
||||||
void on_script_load(rage::scrProgram* program);
|
void on_script_load(rage::scrProgram* program);
|
||||||
uint8_t** get_script_bytecode(rage::joaat_t script);
|
uint8_t** get_script_bytecode(rage::joaat_t script);
|
||||||
void update_all_patches_for_script(rage::joaat_t script);
|
void update_all_patches_for_script(rage::joaat_t script);
|
||||||
|
Loading…
Reference in New Issue
Block a user