Fix script patch signature causing crash (yubie-re) (#2523)

Redesigned the script patcher to assign the signatures names, so if they fail, it will print out its name.
This commit is contained in:
gir489
2023-12-12 17:37:31 -05:00
committed by GitHub
parent 5bf69531b5
commit efef962fe8
4 changed files with 48 additions and 26 deletions

View File

@ -4,8 +4,9 @@
namespace big
{
script_patch::script_patch(rage::joaat_t script, const memory::pattern pattern, int32_t offset, std::vector<uint8_t> patch, bool* enable_bool) :
script_patch::script_patch(rage::joaat_t script, std::string name, const memory::pattern pattern, int32_t offset, std::vector<uint8_t> patch, bool* enable_bool) :
m_script(script),
m_name(name),
m_pattern(pattern),
m_offset(offset),
m_patch(std::move(patch)),
@ -53,7 +54,7 @@ namespace big
{
auto result = get_code_location_by_pattern(data, m_pattern);
if (!result.has_value())
LOG(FATAL) << "Failed to find pattern";
LOG(FATAL) << "Failed to find pattern: " << m_name;
m_ip = result.value() + m_offset;

View File

@ -9,6 +9,7 @@ namespace big
{
rage::joaat_t m_script;
const memory::pattern m_pattern;
std::string m_name;
int32_t m_offset;
std::vector<uint8_t> m_patch;
std::vector<uint8_t> m_original;
@ -26,7 +27,7 @@ namespace big
return m_script;
}
script_patch(rage::joaat_t script, 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);
};
}

View File

@ -64,7 +64,7 @@ namespace big
SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED(RAGE_JOAAT("tuneables_processing"));
m_script_started = true;
g_script_patcher_service->add_patch({RAGE_JOAAT("tuneables_processing"), "2E ? ? 55 ? ? 38 06", 0, std::vector<uint8_t>(17, 0x0), &m_script_started}); // bool tunables registration hack
g_script_patcher_service->add_patch({RAGE_JOAAT("tuneables_processing"), "tuneables_processing1", "2E ? ? 55 ? ? 38 06", 0, std::vector<uint8_t>(17, 0x0), &m_script_started}); // bool tunables registration hack
if (auto program = gta_util::find_script_program(RAGE_JOAAT("tuneables_processing")))
g_script_patcher_service->on_script_load(program);
}