2022-12-06 16:12:02 +00:00
|
|
|
#include "script_function.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
|
2022-12-06 16:12:02 +00:00
|
|
|
namespace big
|
|
|
|
{
|
2024-08-06 15:46:48 +03:00
|
|
|
script_function::script_function(const std::string& name, const rage::joaat_t script, const std::string& pattern) :
|
2023-03-01 21:27:15 +00:00
|
|
|
m_name(name),
|
|
|
|
m_script(script),
|
|
|
|
m_pattern(pattern),
|
|
|
|
m_ip(0)
|
2022-12-06 16:12:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-08-06 15:46:48 +03:00
|
|
|
uint32_t script_function::get_ip(rage::scrProgram* program)
|
2022-12-06 16:12:02 +00:00
|
|
|
{
|
2024-08-06 15:46:48 +03:00
|
|
|
if (m_ip != 0)
|
|
|
|
return m_ip;
|
2022-12-06 16:12:02 +00:00
|
|
|
|
2024-08-06 15:46:48 +03:00
|
|
|
if (auto location = scripts::get_code_location_by_pattern(program, m_pattern))
|
|
|
|
{
|
|
|
|
m_ip = *location;
|
|
|
|
LOG(VERBOSE) << "Found pattern " << m_name << " at " << HEX_TO_UPPER(m_ip) << " in script " << program->m_name;
|
2022-12-06 16:12:02 +00:00
|
|
|
}
|
2024-08-06 15:46:48 +03:00
|
|
|
else
|
2022-12-06 16:12:02 +00:00
|
|
|
{
|
2024-08-06 15:46:48 +03:00
|
|
|
LOG(FATAL) << "Failed to find pattern " << m_name << " in script " << program->m_name;
|
2022-12-06 16:12:02 +00:00
|
|
|
}
|
2024-08-06 15:46:48 +03:00
|
|
|
|
|
|
|
return m_ip;
|
2022-12-06 16:12:02 +00:00
|
|
|
}
|
|
|
|
}
|