From cbc80e6caf8f2f613d4c5fa5813ff8295b66f8c2 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Wed, 5 Jul 2023 07:30:06 +0000 Subject: [PATCH] Mission fixes and modder detection improvements (#1598) * feat(protections): improve protections * fix: fix mission start --- src/backend/context/chat_command_context.cpp | 1 + .../looped/hud/hud_transition_state.cpp | 44 +++- src/backend/looped/self/dance_mode.cpp | 6 - src/byte_patch_manager.cpp | 3 + src/core/data/infractions.hpp | 24 ++- src/core/settings.hpp | 4 +- src/function_types.hpp | 4 + src/gta/net_array.hpp | 167 +++++++-------- src/gta_pointers.hpp | 6 +- src/hooking.cpp | 11 - src/hooking.hpp | 7 - src/hooks/info/get_network_event_data.cpp | 106 +++++++++- .../assign_physical_index.cpp | 31 +-- src/hooks/protections/can_apply_data.cpp | 195 +++++++++++++++--- .../protections/received_array_update.cpp | 4 +- src/hooks/script/script_handler.cpp | 57 ----- .../spoofing/write_player_gamer_data_node.cpp | 9 - src/invoker.cpp | 3 + src/main.cpp | 2 +- src/native_hooks/all_scripts.hpp | 20 +- src/native_hooks/freemode.hpp | 25 ++- src/pointers.cpp | 27 ++- .../script_connection/script_connection.cpp | 6 - src/util/notify.hpp | 9 - src/util/ped.hpp | 36 ++-- src/views/network/view_network.cpp | 8 + src/views/players/player/player_teleport.cpp | 27 +-- src/views/players/view_players.cpp | 8 +- src/views/world/view_world.cpp | 20 +- 29 files changed, 533 insertions(+), 337 deletions(-) delete mode 100644 src/hooks/script/script_handler.cpp diff --git a/src/backend/context/chat_command_context.cpp b/src/backend/context/chat_command_context.cpp index 02d1439d..ec324b78 100644 --- a/src/backend/context/chat_command_context.cpp +++ b/src/backend/context/chat_command_context.cpp @@ -1,5 +1,6 @@ #include "chat_command_context.hpp" +#include "fiber_pool.hpp" #include "hooking.hpp" #include "util/notify.hpp" diff --git a/src/backend/looped/hud/hud_transition_state.cpp b/src/backend/looped/hud/hud_transition_state.cpp index 1a1e0f9e..666a757e 100644 --- a/src/backend/looped/hud/hud_transition_state.cpp +++ b/src/backend/looped/hud/hud_transition_state.cpp @@ -1,6 +1,8 @@ #include "backend/looped/looped.hpp" #include "core/scr_globals.hpp" #include "gta/joaat.hpp" +#include "gta/net_array.hpp" +#include "gta_util.hpp" #include "natives.hpp" #include "script_global.hpp" #include "services/players/player_service.hpp" @@ -8,6 +10,7 @@ // Credits: QuickNET namespace big { + static float old_percent = NAN; constexpr char transition_states[][48] = {"TRANSITION_STATE_EMPTY", "Singleplayer Swoop Up", "Multiplayer Swoop Up", "Creator Swoop Up", "Pre-HUD Checks", "Wait HUD Exit", "Wait For Summon", "Singleplayer Swoop Down", "Multiplayer Swoop Down", "Cancel Joining", "Retry Loading", "Retry Loading Slot 1", "Retry Loading Slot 2", "Retry Loading Slot 3", "Retry Loading Slot 4", "Wait On Invite", "Prejoining Freemode Session Checks", "Look For Fresh Join Freemode", "Look To Join Another Session Freemode", "Confirm Freemode Session Joining", "Wait Join Freemode Session", "Creation Enter Session", "Pre-Freemode Launch Script", "Freemode Teamfull Check", "Start Freemode Launch Script", "Freemode Transition Create Player", "Is Freemode And Transition Ready", "Freemode Swoop Down", "Post Bink Video Warp", "Freemode Final Setup Player", "Move Freemode To Running State", "Freemode How To Terminate", "Start Creator Pre-Launch Script Check", "Start Creator Launch Script", "Creator Transition Create Player", "Is Creator And Transition Ready", "Creator Swoop Down", "Creator Final Setup Player", "Move Creator To Running State", "Prejoining Testbed Session Checks", "Look For Fresh Join Testbed", "Look For Fresh Host Testbed", "Look To Join Another Session Testbed", "Look To Host Session Testbed", "Confirm Testbed Session Joining", "Wait Join Testbed Session", "Start Testbed Launch Script", "Testbed Transition Create Player", "Is Testbed And Transition Ready", "Testbed Swoop Down", "Testbed Final Setup Player", "Move Testbed To Running State", "Testbed How To Terminate", "Quit Current Session Prompt", "Wait For Transition Session To Setup", "Terminate Singleplayer", "Wait Terminate Singleplayer", "Kick Terminate Session", "Terminate Session", "Wait Terminate Session", "Terminate Session And Hold", "Terminate Session And Move Into Holding State", "Team Swapping Checks", "Return To Singleplayer", "Wait For Singleplayer To Start", "Waiting For External Termination Call", "Terminate Maintransition", "Wait For Dirty Load Confirm", "DLC Intro Bink", "Spawn Into Personal Vehicle"}; eTransitionState last_state = eTransitionState::TRANSITION_STATE_EMPTY; @@ -24,22 +27,51 @@ namespace big SCRIPT::SHUTDOWN_LOADING_SCREEN(); } - if (last_state == state || state == eTransitionState::TRANSITION_STATE_EMPTY || state > eTransitionState::TRANSITION_STATE_SPAWN_INTO_PERSONAL_VEHICLE) + if ((last_state == state && state != eTransitionState::TRANSITION_STATE_FM_TRANSITION_CREATE_PLAYER) || state == eTransitionState::TRANSITION_STATE_EMPTY || state > eTransitionState::TRANSITION_STATE_SPAWN_INTO_PERSONAL_VEHICLE) { return; } - if (HUD::BUSYSPINNER_IS_ON()) + if (state != eTransitionState::TRANSITION_STATE_FM_TRANSITION_CREATE_PLAYER && HUD::BUSYSPINNER_IS_ON()) { HUD::BUSYSPINNER_OFF(); } if ((int)state > 0 && (int)state < std::size(transition_states)) { - HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING"); - auto const spinner_text = std::format("{} | {}", transition_states[(int)state], static_cast(state)); - HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(spinner_text.c_str()); - HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(5); + rage::scrThread* freemode{}; + if (state == eTransitionState::TRANSITION_STATE_FM_TRANSITION_CREATE_PLAYER + && (freemode = gta_util::find_script_thread(RAGE_JOAAT("freemode")), freemode && freemode->m_net_component)) + { + int num_array_handlers{}; + int received_array_handlers{}; + + while (auto handler = g_pointers->m_gta.m_get_host_array_handler_by_index(freemode->m_net_component, num_array_handlers++)) + if (handler->m_flags & 1) + received_array_handlers++; + + if (num_array_handlers == 0) + num_array_handlers = 1; + + float percent = round((static_cast(received_array_handlers) / num_array_handlers) * 100); + + if (percent != old_percent) + { + HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME( + std::format("Wait For Host Broadcast Data: {}%", (percent)).c_str()); + HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(5); + } + + old_percent = percent; + } + else + { + old_percent = NAN; + HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(transition_states[(int)state]); + HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(5); + } } last_state = state; diff --git a/src/backend/looped/self/dance_mode.cpp b/src/backend/looped/self/dance_mode.cpp index 3c400c28..2d744d32 100644 --- a/src/backend/looped/self/dance_mode.cpp +++ b/src/backend/looped/self/dance_mode.cpp @@ -36,12 +36,6 @@ namespace big // perform initial setup gta_util::execute_as_script(g.m_dance_thread, [] { - if (auto hook = g_hooking->m_handler_hooks[(CGameScriptHandler*)rage::scrThread::get()->m_handler].get()) - { - hook->disable(); - g_hooking->m_handler_hooks.erase((CGameScriptHandler*)rage::scrThread::get()->m_handler); - } - NETWORK::NETWORK_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(32, true, 32); scr_functions::init_nightclub_script({}); }); diff --git a/src/byte_patch_manager.cpp b/src/byte_patch_manager.cpp index bd8575d0..116d6b00 100644 --- a/src/byte_patch_manager.cpp +++ b/src/byte_patch_manager.cpp @@ -70,6 +70,9 @@ namespace big memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_6.add(2).as(), 0xd2310272)->apply(); memory::byte_patch::make(g_pointers->m_gta.m_script_vm_patch_6.add(6).as(), 0x9090)->apply(); + + // Patch script network check + memory::byte_patch::make(g_pointers->m_gta.m_model_spawn_bypass, std::vector{0x90, 0x90})->apply(); // this is no longer integrity checked } byte_patch_manager::byte_patch_manager() diff --git a/src/core/data/infractions.hpp b/src/core/data/infractions.hpp index 28e7b606..bb90ea71 100644 --- a/src/core/data/infractions.hpp +++ b/src/core/data/infractions.hpp @@ -7,14 +7,19 @@ namespace big enum class Infraction { DESYNC_PROTECTION, - BREAKUP_KICK_DETECTED, - LOST_CONNECTION_KICK_DETECTED, - SPOOFED_ROCKSTAR_ID, + BREAKUP_KICK_DETECTED, // do not use + LOST_CONNECTION_KICK_DETECTED, // do not use + SPOOFED_ROCKSTAR_ID, // do not use TRIGGERED_ANTICHEAT, - TRIED_CRASH_PLAYER, + TRIED_CRASH_PLAYER, // do not use TRIED_KICK_PLAYER, - BLAME_EXPLOSION_DETECTED, - ATTACKING_WITH_GODMODE + BLAME_EXPLOSION_DETECTED, // do not use (for now) + ATTACKING_WITH_GODMODE, + ATTACKING_WITH_INVISIBILITY, + ATTACKING_WHEN_HIDDEN_FROM_PLAYER_LIST, + SPOOFED_DATA, + SPOOFED_HOST_TOKEN, + INVALID_PLAYER_MODEL }; inline std::unordered_map infraction_desc = { @@ -26,6 +31,11 @@ namespace big {Infraction::TRIED_CRASH_PLAYER, "Tried to crash you"}, {Infraction::TRIED_KICK_PLAYER, "Tried to kick you"}, {Infraction::BLAME_EXPLOSION_DETECTED, "Tried to blame someone for their explosion"}, - {Infraction::ATTACKING_WITH_GODMODE, "Attacked someone when using godmode"}, + {Infraction::ATTACKING_WITH_GODMODE, "Attacked someone while using godmode"}, + {Infraction::ATTACKING_WITH_INVISIBILITY, "Attacked someone while being invisible"}, + {Infraction::ATTACKING_WHEN_HIDDEN_FROM_PLAYER_LIST, "Attacked someone while being hidden from the player list"}, + {Infraction::SPOOFED_DATA, "Had spoofed data"}, + {Infraction::SPOOFED_HOST_TOKEN, "Had spoofed their host token"}, + {Infraction::INVALID_PLAYER_MODEL, "Had used an invalid player model"}, }; } \ No newline at end of file diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 16eb33c8..33c810a9 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -392,7 +392,9 @@ namespace big bool show_cheating_message = false; bool anonymous_bounty = true; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(session, chat_force_clean, log_chat_messages, log_text_messages, decloak_players, force_session_host, force_script_host, player_magnet_enabled, player_magnet_count, is_team, join_in_sctv_slots, kick_chat_spammers, kick_host_when_forcing_host, explosion_karma, damage_karma, disable_traffic, disable_peds, force_thunder, block_ceo_money, randomize_ceo_colors, block_jobs, block_muggers, block_ceo_raids, send_to_apartment_idx, send_to_warehouse_idx, chat_commands, chat_command_default_access_level, show_cheating_message, anonymous_bounty, lock_session) + bool fast_join = false; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(session, chat_force_clean, log_chat_messages, log_text_messages, decloak_players, force_session_host, force_script_host, player_magnet_enabled, player_magnet_count, is_team, join_in_sctv_slots, kick_chat_spammers, kick_host_when_forcing_host, explosion_karma, damage_karma, disable_traffic, disable_peds, force_thunder, block_ceo_money, randomize_ceo_colors, block_jobs, block_muggers, block_ceo_raids, send_to_apartment_idx, send_to_warehouse_idx, chat_commands, chat_command_default_access_level, show_cheating_message, anonymous_bounty, lock_session, fast_join) } session{}; struct settings diff --git a/src/function_types.hpp b/src/function_types.hpp index 3d401e7b..85841d6d 100644 --- a/src/function_types.hpp +++ b/src/function_types.hpp @@ -6,6 +6,7 @@ class NetworkGameFilterMatchmakingComponent; class sCloudFile; class CPlayerGameStateDataNode; class CVehicleGadgetDataNode; +class CGameScriptHandlerNetComponent; enum eVehicleGadgetType : uint32_t; namespace rage @@ -22,6 +23,7 @@ namespace rage class rlScHandle; class rlQueryPresenceAttributesContext; enum class eThreadState : uint32_t; + class netArrayHandlerBase; } namespace datafile_commands @@ -141,4 +143,6 @@ namespace big::functions using handle_chat_message = void (*)(void* chat_data, void*, rage::rlGamerHandle* handle, const char* text, bool is_team); using update_language = void (*)(bool); + + using get_host_array_handler_by_index = rage::netArrayHandlerBase* (*)(CGameScriptHandlerNetComponent* component, int index); } diff --git a/src/gta/net_array.hpp b/src/gta/net_array.hpp index 4455db33..524cf86f 100644 --- a/src/gta/net_array.hpp +++ b/src/gta/net_array.hpp @@ -29,46 +29,47 @@ namespace rage class netSyncDataUnit_Dynamic { public: - virtual ~netSyncDataUnit_Dynamic() = default;// 0x00 + virtual ~netSyncDataUnit_Dynamic() = default; // 0x00 virtual void _0x08() = 0; virtual void _0x10() = 0; - virtual void set_data_counter(int index, uint16_t counter) = 0;// 0x18 + virtual void set_data_counter(int index, uint16_t counter) = 0; // 0x18 - virtual void reset_data_counter(int index) = 0;// 0x20 + virtual void reset_data_counter(int index) = 0; // 0x20 // ... - int m_players_need_ack; // 0x08 - int m_players_need_sync;// 0x0C + int m_players_need_ack; // 0x08 + int m_players_need_sync; // 0x0C }; class netSyncData_Dynamic { public: - virtual ~netSyncData_Dynamic() = default;// 0x00 + virtual ~netSyncData_Dynamic() = default; // 0x00 virtual rage::datBitBuffer* _0x08() = 0; virtual rage::datBitBuffer* _0x10() = 0; - virtual int get_num_receivers() = 0;// 0x18 + virtual int get_num_receivers() = 0; // 0x18 virtual int _0x20() = 0; - virtual void _0x28() = 0;// same as get_sync_unit_for_element + virtual void _0x28() = 0; // same as get_sync_unit_for_element - virtual netSyncDataUnit_Dynamic* get_sync_unit_for_element(uint32_t element) = 0;// 0x30 + virtual netSyncDataUnit_Dynamic* get_sync_unit_for_element(uint32_t element) = 0; // 0x30 // ... }; +#pragma pack(push, 1) class netArrayHandlerBase { public: - virtual ~netArrayHandlerBase() = default;// 0x00 + virtual ~netArrayHandlerBase() = default; // 0x00 virtual void _0x08() = 0; @@ -82,152 +83,134 @@ namespace rage virtual void _0x30() = 0; - virtual void _0x38() = 0;// + virtual void _0x38() = 0; // - virtual void _0x40() = 0;// + virtual void _0x40() = 0; // - virtual int _0x48(CNetGamePlayer* player, int max_size, uint32_t* a3, uint32_t* a4) = 0;// + virtual int _0x48(CNetGamePlayer* player, int max_size, uint32_t* a3, uint32_t* a4) = 0; // - virtual int get_size(CNetGamePlayer* player, int max_size, uint32_t element) = 0;// 0x50 + virtual int get_size(CNetGamePlayer* player, int max_size, uint32_t element) = 0; // 0x50 - virtual int pack_array_data(CNetGamePlayer* player, rage::datBitBuffer* bit_buffer, uint16_t counter, uint32_t* elem_start, bool silent) = 0;// 0x58 + virtual int pack_array_data(CNetGamePlayer* player, rage::datBitBuffer* bit_buffer, uint16_t counter, uint32_t* elem_start, bool silent) = 0; // 0x58 - virtual void _0x60() = 0;// + virtual void _0x60() = 0; // - virtual bool _0x68(CNetGamePlayer* player) = 0;// is_player_out_of_scope or something like that + virtual bool _0x68(CNetGamePlayer* player) = 0; // is_player_out_of_scope or something like that - virtual void _0x70() = 0;// + virtual void _0x70() = 0; // - virtual bool can_send_update(CNetGamePlayer* player) = 0;// 0x78 + virtual bool can_send_update(CNetGamePlayer* player) = 0; // 0x78 - virtual void _0x80() = 0;// + virtual void _0x80() = 0; // - virtual void _0x88() = 0;// + virtual void _0x88() = 0; // - virtual void* get_identifier() = 0;// 0x90 + virtual void* get_identifier() = 0; // 0x90 - virtual void* _0x98() = 0;// same as get_identifier + virtual void* _0x98() = 0; // same as get_identifier - virtual void _0xA0() = 0;// + virtual void _0xA0() = 0; // - virtual bool can_verify_array_data() = 0;// 0xA8 + virtual bool can_verify_array_data() = 0; // 0xA8 - virtual void _0xB0() = 0;// + virtual void _0xB0() = 0; // - virtual void _0xB8() = 0;// + virtual void _0xB8() = 0; // - virtual void should_sync_element(uint32_t element) = 0;// 0xC0 + virtual void should_sync_element(uint32_t element) = 0; // 0xC0 - virtual void _0xC8() = 0;// + virtual void _0xC8() = 0; // - virtual void _0xD0() = 0;// + virtual void _0xD0() = 0; // - virtual bool are_all_elements_in_scope() = 0;// 0xD8 + virtual bool are_all_elements_in_scope() = 0; // 0xD8 - virtual void _0xE0() = 0;// + virtual void _0xE0() = 0; // - virtual void verify_array_data() = 0;// 0xE8 + virtual void verify_array_data() = 0; // 0xE8 - virtual void _0xF0() = 0;// + virtual void _0xF0() = 0; // - virtual char* get_name() = 0;// 0xF8 + virtual char* get_name() = 0; // 0xF8 - virtual bool is_local_player_owner_of_array() = 0;// 0x100 + virtual bool is_local_player_owner_of_array() = 0; // 0x100 - virtual CNetGamePlayer* get_owner_of_array() = 0;// 0x108 + virtual CNetGamePlayer* get_owner_of_array() = 0; // 0x108 virtual void _0x110() = 0; virtual uint32_t get_array_hash() = 0; - virtual int _0x120() = 0;// gets array size for hashing + virtual int _0x120() = 0; // gets array size for hashing - virtual netSyncData_Dynamic* _0x128() = 0;// same as get_dynamic_sync_data + virtual netSyncData_Dynamic* _0x128() = 0; // same as get_dynamic_sync_data - virtual netSyncData_Dynamic* get_dynamic_sync_data() = 0;// 0x130 + virtual netSyncData_Dynamic* get_dynamic_sync_data() = 0; // 0x130 virtual void _0x138() = 0; - virtual bool is_element_in_scope(uint32_t element, CNetGamePlayer* player) = 0;// 0x140 + virtual bool is_element_in_scope(uint32_t element, CNetGamePlayer* player) = 0; // 0x140 - virtual int get_receiver_index_from_player(CNetGamePlayer*) = 0;// 0x148 + virtual int get_receiver_index_from_player(CNetGamePlayer*) = 0; // 0x148 virtual void _0x150() = 0; virtual void _0x158() = 0; // pasted from fivem - virtual bool is_element_empty(uint32_t element) = 0;// 0x160 + virtual bool is_element_empty(uint32_t element) = 0; // 0x160 - virtual void set_element_empty(uint32_t element) = 0;// 0x168 + virtual void set_element_empty(uint32_t element) = 0; // 0x168 - virtual void write_element_index(rage::datBitBuffer& buffer, uint32_t) = 0;// 0x170 + virtual void write_element_index(rage::datBitBuffer& buffer, uint32_t) = 0; // 0x170 - virtual void read_element_index(rage::datBitBuffer& buffer, uint32_t&) = 0;// 0x178 + virtual void read_element_index(rage::datBitBuffer& buffer, uint32_t&) = 0; // 0x178 - virtual bool is_valid_index(uint32_t) = 0;// 0x180 + virtual bool is_valid_index(uint32_t) = 0; // 0x180 - virtual void recalculate_dirty_elements() = 0;// 0x188 + virtual void recalculate_dirty_elements() = 0; // 0x188 - virtual void reset_element_sync_data(uint32_t element) = 0;// 0x190 + virtual void reset_element_sync_data(uint32_t element) = 0; // 0x190 - virtual void do_post_read_processing() = 0;// 0x198 + virtual void do_post_read_processing() = 0; // 0x198 - virtual void do_post_element_read_processing(uint32_t element) = 0;// 0x1A0 + virtual void do_post_element_read_processing(uint32_t element) = 0; // 0x1A0 - virtual bool can_apply_element_data(uint32_t element, const rage::netPlayer& sender, bool force) = 0;// 0x1A8 + virtual bool can_apply_element_data(uint32_t element, const rage::netPlayer& sender, bool force) = 0; // 0x1A8 - virtual void extract_data_for_serializing(uint32_t elem) = 0;// 0x1B0 + virtual void extract_data_for_serializing(uint32_t elem) = 0; // 0x1B0 - virtual void write_element(rage::datBitBuffer& buffer, uint32_t elem, void* logger) = 0;// 0x1B8 + virtual void write_element(rage::datBitBuffer& buffer, uint32_t elem, void* logger) = 0; // 0x1B8 - virtual void read_element(rage::datBitBuffer& buffer, uint32_t elem, void* logger) = 0;// 0x1C0 + virtual void read_element(rage::datBitBuffer& buffer, uint32_t elem, void* logger) = 0; // 0x1C0 - virtual void log_element(uint32_t elem, void* logger) = 0;// 0x1C8 + virtual void log_element(uint32_t elem, void* logger) = 0; // 0x1C8 - virtual uint32_t get_current_element_size_in_bits(uint32_t elem) = 0;// 0x1D0 + virtual uint32_t get_current_element_size_in_bits(uint32_t elem) = 0; // 0x1D0 - virtual void apply_element_data(uint32_t element, const rage::netPlayer& sender) = 0;// 0x1D8 + virtual void apply_element_data(uint32_t element, const rage::netPlayer& sender) = 0; // 0x1D8 virtual void _0x1E0() = 0; - virtual void _0x1E8(bool) = 0;// very important! changes send function to use some kind of cached buffer that prevents us from modifing array data per player + virtual void _0x1E8(bool) = 0; - void* m_something;// 0x10 + void* m_something; // 0x10 - netArrayHandlerBase* m_next;// 0x18 + netArrayHandlerBase* m_next; // 0x18 - uint8_t m_pad[100 - 0x18];// +8 + uint8_t m_pad[100 - 0x18]; // +8 uint32_t m_hash; - uint8_t m_pad2[244 - 104];// +8 - uint16_t m_index; // 244 - uint16_t m_count; // 246 - uint8_t m_max_elements; // 248 - uint8_t m_element_size; // 249 - uint8_t m_element_size_2; // 250 - uint8_t m_pad3[13]; // 251 - void* m_array; // 264 - -#if 0 - static inline netArrayHandlerBase* get_by_data(void* data) - { - if (auto array_mgr = *big::g_pointers->m_gta.m_game_array_mgr) - { - if (auto handler = array_mgr->m_start) - { - do - { - if (handler->m_array == data) - return handler; - } - while (handler = handler->m_next); - } - } - - return nullptr; - } -#endif + uint8_t m_pad2[244 - 104]; // +8 + uint16_t m_index; // 244 + uint16_t m_count; // 246 + uint8_t m_max_elements; // 248 + uint8_t m_element_size; // 249 + uint8_t m_element_size_2; // 250 + uint8_t m_pad3[13]; // 251 + void* m_array; // 264 + uint8_t m_pad4[341 - (264 + 8)]; + char m_flags; // 341 }; - - static_assert(sizeof(netArrayHandlerBase) == 272); +#pragma pack(pop) + static_assert(sizeof(netArrayHandlerBase) == 342); } \ No newline at end of file diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index 02f64b3c..67b4ab44 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -203,8 +203,6 @@ namespace big PVOID m_serialize_take_off_ped_variation_task; - PVOID m_create_script_handler; - functions::encode_session_info m_encode_session_info; functions::decode_session_info m_decode_session_info; functions::decode_peer_info m_decode_peer_info; @@ -263,6 +261,10 @@ namespace big int* m_language; functions::update_language m_update_language{}; + + PVOID m_model_spawn_bypass{}; + + functions::get_host_array_handler_by_index m_get_host_array_handler_by_index; }; #pragma pack(pop) static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned"); diff --git a/src/hooking.cpp b/src/hooking.cpp index 6ea950b5..cc9c8fa4 100644 --- a/src/hooking.cpp +++ b/src/hooking.cpp @@ -84,8 +84,6 @@ namespace big detour_hook_helper::add("STOPVT", g_pointers->m_gta.m_serialize_take_off_ped_variation_task); - detour_hook_helper::add("CSH", g_pointers->m_gta.m_create_script_handler); - detour_hook_helper::add("QD", g_pointers->m_gta.m_queue_dependency); detour_hook_helper::add("PMFS", g_pointers->m_gta.m_prepare_metric_for_sending); @@ -141,12 +139,6 @@ namespace big detour_hook_helper->m_detour_hook->enable(); } - for (auto& thread : *g_pointers->m_gta.m_script_threads) - { - if (thread->m_handler) - hook_script_handler((CGameScriptHandler*)thread->m_handler); - } - MH_ApplyQueued(); m_enabled = true; @@ -171,7 +163,6 @@ namespace big delete detour_hook_helper; } m_detour_hook_helpers.clear(); - m_handler_hooks.clear(); } hooking::detour_hook_helper::~detour_hook_helper() @@ -195,8 +186,6 @@ namespace big bool hooks::run_script_threads(std::uint32_t ops_to_execute) { - g_native_invoker.cache_handlers(); - if (g_running) { g_script_mgr.tick(); diff --git a/src/hooking.hpp b/src/hooking.hpp index be0a982b..4f563bde 100644 --- a/src/hooking.hpp +++ b/src/hooking.hpp @@ -123,10 +123,6 @@ namespace big static void serialize_take_off_ped_variation_task(ClonedTakeOffPedVariationInfo* info, rage::CSyncDataBase* serializer); - static CGameScriptHandler* create_script_handler(CGameScriptHandlerMgr* this_, void* unk); - static bool script_handler_is_networked(CGameScriptHandler* this_); - static bool script_handler_dtor(CGameScriptHandler* this_, bool free_memory); - static int nt_query_virtual_memory(void* _this, HANDLE handle, PVOID base_addr, int info_class, MEMORY_BASIC_INFORMATION* info, int size, size_t* return_len); static void queue_dependency(void* dependency); static void prepare_metric_for_sending(rage::datBitBuffer* bit_buffer, int unk, int time, rage::rlMetric* metric); @@ -241,9 +237,6 @@ namespace big return detour_hook_helper::hook_to_detour_hook_helper::m_detour_hook->get_original(); } - void hook_script_handler(CGameScriptHandler* handler); - std::unordered_map> m_handler_hooks; - private: bool m_enabled{}; minhook_keepalive m_minhook_keepalive; diff --git a/src/hooks/info/get_network_event_data.cpp b/src/hooks/info/get_network_event_data.cpp index 20be0350..eee1d115 100644 --- a/src/hooks/info/get_network_event_data.cpp +++ b/src/hooks/info/get_network_event_data.cpp @@ -1,12 +1,61 @@ #include "gta/net_game_event.hpp" #include "hooking.hpp" #include "services/players/player_service.hpp" +#include "util/globals.hpp" +#include "util/misc.hpp" #include "util/session.hpp" #include +#include