2019-03-21 20:18:31 +01:00
|
|
|
#include "common.hpp"
|
|
|
|
#include "function_types.hpp"
|
|
|
|
#include "logger.hpp"
|
|
|
|
#include "gta/array.hpp"
|
|
|
|
#include "gta/player.hpp"
|
|
|
|
#include "gta/script_thread.hpp"
|
|
|
|
#include "gui.hpp"
|
|
|
|
#include "hooking.hpp"
|
|
|
|
#include "memory/module.hpp"
|
|
|
|
#include "natives.hpp"
|
|
|
|
#include "pointers.hpp"
|
|
|
|
#include "renderer.hpp"
|
|
|
|
#include "script_mgr.hpp"
|
|
|
|
|
2019-06-23 22:00:18 +02:00
|
|
|
#include <MinHook.h>
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
hooking::hooking() :
|
2022-01-25 02:55:35 +01:00
|
|
|
// Swapchain
|
2019-03-21 20:18:31 +01:00
|
|
|
m_swapchain_hook(*g_pointers->m_swapchain, hooks::swapchain_num_funcs),
|
|
|
|
|
2021-07-23 21:15:55 +02:00
|
|
|
// Script Hook
|
|
|
|
m_run_script_threads_hook("SH", g_pointers->m_run_script_threads, &hooks::run_script_threads),
|
2021-05-18 23:03:42 +02:00
|
|
|
|
2022-07-29 14:32:02 +02:00
|
|
|
// Get Label Text
|
|
|
|
m_get_label_text("GLT", g_pointers->m_get_label_text, &hooks::get_label_text),
|
2022-10-26 15:38:01 -04:00
|
|
|
|
|
|
|
// Multiplayer chat filter
|
|
|
|
m_multiplayer_chat_filter("MCF", g_pointers->m_multiplayer_chat_filter, &hooks::multiplayer_chat_filter),
|
2022-07-29 14:32:02 +02:00
|
|
|
|
2022-10-29 05:54:32 -04:00
|
|
|
// Write Player Game State Data Node
|
|
|
|
m_write_player_game_state_data_node_hook("WPGSDN", g_pointers->m_write_player_game_state_data_node, &hooks::write_player_game_state_data_node),
|
|
|
|
|
2022-01-25 02:55:35 +01:00
|
|
|
// GTA Thead Start
|
|
|
|
m_gta_thread_start_hook("GTS", g_pointers->m_gta_thread_start, &hooks::gta_thread_start),
|
2021-07-23 21:15:55 +02:00
|
|
|
// GTA Thread Kill
|
|
|
|
m_gta_thread_kill_hook("GTK", g_pointers->m_gta_thread_kill, &hooks::gta_thread_kill),
|
2021-05-19 16:19:38 +02:00
|
|
|
|
2022-05-28 17:44:05 +02:00
|
|
|
// Network Player Mgr Init
|
|
|
|
m_network_player_mgr_init_hook("NPMI", g_pointers->m_network_player_mgr_init, &hooks::network_player_mgr_init),
|
2022-01-31 18:27:35 +01:00
|
|
|
// Network Player Mgr Shutdown
|
|
|
|
m_network_player_mgr_shutdown_hook("NPMS", g_pointers->m_network_player_mgr_shutdown, &hooks::network_player_mgr_shutdown),
|
2022-03-16 15:55:27 +01:00
|
|
|
|
2022-05-13 18:26:15 +02:00
|
|
|
// Network Group Override
|
|
|
|
m_network_group_override("NGO", g_pointers->m_network_group_override, &hooks::network_group_override),
|
2021-05-25 14:44:35 +02:00
|
|
|
|
2021-07-23 21:15:55 +02:00
|
|
|
// Received Event
|
2021-07-24 14:49:31 +02:00
|
|
|
m_received_event_hook("RE", g_pointers->m_received_event, &hooks::received_event),
|
|
|
|
|
2021-12-18 19:24:30 +01:00
|
|
|
// Send NET Info to Lobby
|
2022-01-21 23:11:37 +01:00
|
|
|
m_send_net_info_to_lobby("SNITL", g_pointers->m_send_net_info_to_lobby, &hooks::send_net_info_to_lobby),
|
|
|
|
|
2022-08-09 14:39:55 -04:00
|
|
|
// Assign Physical Index
|
|
|
|
m_assign_physical_index_hook("API", g_pointers->m_assign_physical_index, &hooks::assign_physical_index),
|
2022-05-20 18:17:41 -04:00
|
|
|
// Receive Net Message
|
|
|
|
m_receive_net_message_hook("RNM", g_pointers->m_receive_net_message, &hooks::receive_net_message),
|
2022-05-23 00:31:21 +02:00
|
|
|
// Received clone sync
|
|
|
|
m_received_clone_sync_hook("RCS", g_pointers->m_received_clone_sync, &hooks::received_clone_sync),
|
2022-05-20 18:17:41 -04:00
|
|
|
//Get Network Event Data
|
2022-10-06 13:30:04 +02:00
|
|
|
m_get_network_event_data_hook("GNED", g_pointers->m_get_network_event_data, &hooks::get_network_event_data),
|
2022-10-21 13:37:18 +02:00
|
|
|
m_write_player_gamer_data_node_hook("WPGDN", g_pointers->m_write_player_gamer_data_node, &hooks::write_player_gamer_data_node),
|
|
|
|
|
2022-10-21 23:47:50 +02:00
|
|
|
// Format Metric For Sending
|
|
|
|
m_format_metric_for_sending("FMFS", g_pointers->m_format_metric_for_sending, &hooks::format_metric_for_sending)
|
2019-03-21 20:18:31 +01:00
|
|
|
{
|
|
|
|
m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present);
|
|
|
|
m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers);
|
|
|
|
|
|
|
|
g_hooking = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
hooking::~hooking()
|
|
|
|
{
|
|
|
|
if (m_enabled)
|
|
|
|
disable();
|
|
|
|
|
|
|
|
g_hooking = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hooking::enable()
|
|
|
|
{
|
|
|
|
m_swapchain_hook.enable();
|
2022-07-05 16:54:45 -04:00
|
|
|
m_og_wndproc = WNDPROC(SetWindowLongPtrW(g_pointers->m_hwnd, GWLP_WNDPROC, LONG_PTR(&hooks::wndproc)));
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
m_run_script_threads_hook.enable();
|
2022-07-29 14:32:02 +02:00
|
|
|
m_get_label_text.enable();
|
2022-10-26 15:38:01 -04:00
|
|
|
m_multiplayer_chat_filter.enable();
|
2022-01-21 23:11:37 +01:00
|
|
|
m_gta_thread_start_hook.enable();
|
2021-05-19 00:41:55 +02:00
|
|
|
m_gta_thread_kill_hook.enable();
|
2022-05-23 15:32:38 +02:00
|
|
|
m_network_group_override.enable();
|
2022-05-28 17:44:05 +02:00
|
|
|
m_network_player_mgr_init_hook.enable();
|
2022-01-31 18:27:35 +01:00
|
|
|
m_network_player_mgr_shutdown_hook.enable();
|
2022-08-09 14:39:55 -04:00
|
|
|
m_assign_physical_index_hook.enable();
|
2021-05-25 12:58:33 +02:00
|
|
|
m_received_event_hook.enable();
|
2021-12-18 19:24:30 +01:00
|
|
|
m_send_net_info_to_lobby.enable();
|
2022-05-20 18:17:41 -04:00
|
|
|
m_receive_net_message_hook.enable();
|
|
|
|
m_get_network_event_data_hook.enable();
|
2022-05-23 00:31:21 +02:00
|
|
|
m_received_clone_sync_hook.enable();
|
2022-10-06 13:30:04 +02:00
|
|
|
m_write_player_gamer_data_node_hook.enable();
|
2022-10-29 05:54:32 -04:00
|
|
|
m_write_player_game_state_data_node_hook.enable();
|
2022-10-21 23:47:50 +02:00
|
|
|
m_format_metric_for_sending.enable();
|
2022-05-23 00:31:21 +02:00
|
|
|
|
2022-08-09 14:39:55 -04:00
|
|
|
MH_ApplyQueued();
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
m_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hooking::disable()
|
|
|
|
{
|
|
|
|
m_enabled = false;
|
|
|
|
|
2022-10-21 23:47:50 +02:00
|
|
|
m_format_metric_for_sending.disable();
|
2022-10-29 05:54:32 -04:00
|
|
|
m_write_player_game_state_data_node_hook.disable();
|
2022-10-06 13:30:04 +02:00
|
|
|
m_write_player_gamer_data_node_hook.disable();
|
2022-05-23 00:31:21 +02:00
|
|
|
m_received_clone_sync_hook.disable();
|
2022-05-20 18:17:41 -04:00
|
|
|
m_get_network_event_data_hook.disable();
|
|
|
|
m_receive_net_message_hook.disable();
|
2021-12-18 19:24:30 +01:00
|
|
|
m_send_net_info_to_lobby.disable();
|
2021-05-25 12:58:33 +02:00
|
|
|
m_received_event_hook.disable();
|
2022-08-09 14:39:55 -04:00
|
|
|
m_assign_physical_index_hook.disable();
|
2022-05-28 17:44:05 +02:00
|
|
|
m_network_player_mgr_init_hook.disable();
|
2022-01-31 18:27:35 +01:00
|
|
|
m_network_player_mgr_shutdown_hook.disable();
|
2022-05-23 15:32:38 +02:00
|
|
|
m_network_group_override.disable();
|
2021-05-19 00:41:55 +02:00
|
|
|
m_gta_thread_kill_hook.disable();
|
2022-01-21 23:11:37 +01:00
|
|
|
m_gta_thread_start_hook.disable();
|
2022-10-26 15:38:01 -04:00
|
|
|
m_multiplayer_chat_filter.disable();
|
2022-07-29 14:32:02 +02:00
|
|
|
m_get_label_text.disable();
|
2019-03-21 20:18:31 +01:00
|
|
|
m_run_script_threads_hook.disable();
|
|
|
|
|
2022-08-09 14:39:55 -04:00
|
|
|
MH_ApplyQueued();
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
SetWindowLongPtrW(g_pointers->m_hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_og_wndproc));
|
|
|
|
m_swapchain_hook.disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hooks::run_script_threads(std::uint32_t ops_to_execute)
|
|
|
|
{
|
2022-09-30 20:41:26 +02:00
|
|
|
g_native_invoker.cache_handlers();
|
|
|
|
|
|
|
|
if (g_running)
|
2019-03-21 20:18:31 +01:00
|
|
|
{
|
2022-09-30 20:41:26 +02:00
|
|
|
g_script_mgr.tick();
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_hooking->m_run_script_threads_hook.get_original<functions::run_script_threads>()(ops_to_execute);
|
2019-03-21 20:18:31 +01:00
|
|
|
}
|
|
|
|
}
|