parent
b64c57ff40
commit
0e2e142c32
@ -118,12 +118,13 @@ namespace big
|
||||
|
||||
bool hooks::run_script_threads(std::uint32_t ops_to_execute)
|
||||
{
|
||||
TRY_CLAUSE
|
||||
g_native_invoker.cache_handlers();
|
||||
|
||||
if (g_running)
|
||||
{
|
||||
if (g_running)
|
||||
g_script_mgr.tick();
|
||||
return g_hooking->m_run_script_threads_hook.get_original<functions::run_script_threads>()(ops_to_execute);
|
||||
} EXCEPT_CLAUSE
|
||||
return false;
|
||||
g_script_mgr.tick();
|
||||
}
|
||||
|
||||
return g_hooking->m_run_script_threads_hook.get_original<functions::run_script_threads>()(ops_to_execute);
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,17 @@ namespace big
|
||||
|
||||
void native_invoker::cache_handlers()
|
||||
{
|
||||
if (m_handlers_cached)
|
||||
return;
|
||||
|
||||
for (const rage::scrNativeMapping& mapping : g_crossmap)
|
||||
{
|
||||
rage::scrNativeHandler handler = g_pointers->m_get_native_handler(
|
||||
g_pointers->m_native_registration_table, mapping.second);
|
||||
|
||||
m_handler_cache.emplace(mapping.first, handler);
|
||||
}
|
||||
|
||||
m_handlers_cached = true;
|
||||
}
|
||||
|
||||
void native_invoker::begin_call()
|
||||
|
@ -38,6 +38,7 @@ namespace big
|
||||
private:
|
||||
native_call_context m_call_context;
|
||||
std::unordered_map<rage::scrNativeHash, rage::scrNativeHandler> m_handler_cache;
|
||||
bool m_handlers_cached = false;
|
||||
};
|
||||
|
||||
inline native_invoker g_native_invoker;
|
||||
|
@ -103,12 +103,12 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
||||
g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu, "Context Menu"));
|
||||
LOG(INFO) << "Scripts registered.";
|
||||
|
||||
auto native_hooks_instance = std::make_unique<native_hooks>();
|
||||
LOG(INFO) << "Dynamic native hooker initialized.";
|
||||
|
||||
g_hooking->enable();
|
||||
LOG(INFO) << "Hooking enabled.";
|
||||
|
||||
auto native_hooks_instance = std::make_unique<native_hooks>();
|
||||
LOG(INFO) << "Dynamic native hooker initialized.";
|
||||
|
||||
g_running = true;
|
||||
|
||||
while (g_running)
|
||||
|
@ -34,7 +34,6 @@ namespace big
|
||||
void script_mgr::tick_internal()
|
||||
{
|
||||
static bool ensure_main_fiber = (ConvertThreadToFiber(nullptr), true);
|
||||
static bool ensure_native_handlers = (g_native_invoker.cache_handlers(), true);
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
for (auto const& script : m_scripts)
|
||||
|
Reference in New Issue
Block a user