Desync kick protection (#3086)

This commit is contained in:
Mr-X-GTA 2024-05-10 21:09:10 +02:00 committed by GitHub
parent dada469c55
commit 86c63dfff5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 39 additions and 40 deletions

View File

@ -3,7 +3,7 @@ include(FetchContent)
FetchContent_Declare(
gtav_classes
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
GIT_TAG b13929ce04c86abb0b5aac3149bafca84de26677
GIT_TAG df0def702dac8f7ba9bf7107734ac30b4db54e96
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""

View File

@ -286,8 +286,9 @@ namespace big
bool kick_rejoin = true;
bool force_relay_connections = false;
bool stop_traffic = true;
bool desync_kick = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(protections, script_events, rid_join, receive_pickup, admin_check, kick_rejoin, force_relay_connections, stop_traffic)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(protections, script_events, rid_join, receive_pickup, admin_check, kick_rejoin, force_relay_connections, stop_traffic, desync_kick)
} protections{};
struct self

View File

@ -209,9 +209,9 @@ namespace big
PVOID m_sort_session_details;
PVOID m_process_matchmaking_find_response;
PVOID m_serialize_player_data_msg;
PVOID m_serialize_join_request_message;
PVOID m_serialize_join_request_message_2;
functions::give_pickup_rewards m_give_pickup_rewards;
functions::send_network_damage m_send_network_damage;

View File

@ -80,9 +80,9 @@ namespace big
detour_hook_helper::add<hooks::send_chat_message>("SCM", g_pointers->m_gta.m_send_chat_message);
detour_hook_helper::add<hooks::process_matchmaking_find_response>("PMFR", g_pointers->m_gta.m_process_matchmaking_find_response);
detour_hook_helper::add<hooks::serialize_player_data_msg>("SJPD", g_pointers->m_gta.m_serialize_player_data_msg);
detour_hook_helper::add<hooks::serialize_join_request_message>("SJRM", g_pointers->m_gta.m_serialize_join_request_message);
detour_hook_helper::add<hooks::serialize_join_request_message_2>("SJRM2", g_pointers->m_gta.m_serialize_join_request_message_2);
detour_hook_helper::add<hooks::start_matchmaking_find_sessions>("SMFS", g_pointers->m_gta.m_start_matchmaking_find_sessions);

View File

@ -119,8 +119,8 @@ namespace big
static bool process_matchmaking_find_response(void* _this, void* unused, rage::JSONNode* node, int* unk);
static bool serialize_player_data_msg(CNetGamePlayerDataMsg* msg, rage::datBitBuffer* buffer);
static bool serialize_join_request_message(RemoteGamerInfoMsg* info, void* data, int size, int* bits_serialized);
static bool serialize_join_request_message_2(__int64 msg, void* buf, int size, int* bits_serialized);
static bool start_matchmaking_find_sessions(int profile_index, int available_slots, NetworkGameFilterMatchmakingComponent* filter, unsigned int max_sessions, rage::rlSessionInfo* results, int* num_sessions_found, rage::rlTaskStatus* status);

View File

@ -1,6 +1,7 @@
#include "gta_util.hpp"
#include "hooking/hooking.hpp"
#include <network/CNetGamePlayerDataMsg.hpp>
#include <network/Network.hpp>
#include <network/RemoteGamerInfoMsg.hpp>
@ -11,7 +12,23 @@ namespace big
if (info->unk_0xC0 == 0)
info->unk_0xC0 = 1; // TODO: do we need this anymore?
if (g.protections.desync_kick)
info->m_gamer_info.m_nat_type = 0;
info->m_num_handles = 0;
return g_hooking->get_original<hooks::serialize_join_request_message>()(info, data, size, bits_serialized);
}
bool hooks::serialize_join_request_message_2(__int64 msg, void* buf, int size, int* bits_serialized)
{
auto& data = *(CNetGamePlayerDataMsg*)(msg + 0x128);
if (g.session.join_in_sctv_slots)
data.m_matchmaking_group = 4;
if (g.protections.desync_kick)
data.m_nat_type = 0;
return g_hooking->get_original<hooks::serialize_join_request_message_2>()(msg, buf, size, bits_serialized);
}
}

View File

@ -1,20 +0,0 @@
#include "gta_util.hpp"
#include "hooking/hooking.hpp"
#include <network/CNetGamePlayerDataMsg.hpp>
#include <network/Network.hpp>
namespace big
{
bool hooks::serialize_player_data_msg(CNetGamePlayerDataMsg* msg, rage::datBitBuffer* buffer)
{
int old_group = msg->m_matchmaking_group;
if (g.session.join_in_sctv_slots)
msg->m_matchmaking_group = 4;
bool ret = g_hooking->get_original<hooks::serialize_player_data_msg>()(msg, buffer);
msg->m_matchmaking_group = old_group;
return ret;
}
}

View File

@ -426,8 +426,8 @@ namespace big
break;
case sync_node_id("CDynamicEntityGameStateDataNode"):
LOG_FIELD(CDynamicEntityGameStateDataNode, m_interior_index);
LOG_FIELD_B(CDynamicEntityGameStateDataNode, unk_00C4);
LOG_FIELD_B(CDynamicEntityGameStateDataNode, unk_00C5);
LOG_FIELD_B(CDynamicEntityGameStateDataNode, m_loads_collisions);
LOG_FIELD_B(CDynamicEntityGameStateDataNode, m_retained);
LOG_FIELD(CDynamicEntityGameStateDataNode, m_decor_count);
for (int i = 0; i < ((CDynamicEntityGameStateDataNode*)node)->m_decor_count; i++)
{
@ -635,13 +635,13 @@ namespace big
LOG_FIELD_B(CPhysicalAttachDataNode, m_is_cargo_vehicle);
break;
case sync_node_id("CPhysicalHealthDataNode"):
LOG_FIELD_B(CPhysicalHealthDataNode, unk_00C0);
LOG_FIELD_B(CPhysicalHealthDataNode, m_has_max_health);
LOG_FIELD_B(CPhysicalHealthDataNode, m_has_max_health_changed);
LOG_FIELD(CPhysicalHealthDataNode, m_max_health);
LOG_FIELD(CPhysicalHealthDataNode, m_current_health);
LOG_FIELD_NI(CPhysicalHealthDataNode, m_weapon_damage_entity);
LOG_FIELD_H(CPhysicalHealthDataNode, m_weapon_damage_hash);
LOG_FIELD(CPhysicalHealthDataNode, unk_00D8);
LOG_FIELD(CPhysicalHealthDataNode, m_last_damaged_material_id);
break;
case sync_node_id("CPhysicalMigrationDataNode"):
LOG_FIELD_B(CPhysicalMigrationDataNode, m_unk);
@ -933,8 +933,8 @@ namespace big
LOG_FIELD_B(CPhysicalGameStateDataNode, m_flag2);
LOG_FIELD_B(CPhysicalGameStateDataNode, m_flag3);
LOG_FIELD_B(CPhysicalGameStateDataNode, m_flag4);
LOG_FIELD(CPhysicalGameStateDataNode, m_val1);
LOG_FIELD(CPhysicalGameStateDataNode, m_unk204);
LOG_FIELD(CPhysicalGameStateDataNode, m_alpha_type);
LOG_FIELD(CPhysicalGameStateDataNode, m_custom_fade_duration);
LOG_FIELD_B(CPhysicalGameStateDataNode, m_unk5);
break;
case sync_node_id("CPhysicalScriptGameStateDataNode"):

View File

@ -752,15 +752,6 @@ namespace big
g_pointers->m_gta.m_process_matchmaking_find_response = ptr.as<PVOID>();
}
},
// Serialize Player Data Message
{
"SPDM",
"48 89 5C 24 08 48 89 74 24 10 48 89 7C 24 18 41 56 48 83 EC 20 BF 01 00 00 00",
[](memory::handle ptr)
{
g_pointers->m_gta.m_serialize_player_data_msg = ptr.as<PVOID>();
}
},
// Serialize Join Request Message
{
"SJRM",
@ -770,6 +761,15 @@ namespace big
g_pointers->m_gta.m_serialize_join_request_message = ptr.add(1).rip().as<PVOID>();
}
},
// Serialize Join Request Message 2
{
"SJRM2",
"E8 ? ? ? ? 48 8D 8D 08 01 00 00 8A D8",
[](memory::handle ptr)
{
g_pointers->m_gta.m_serialize_join_request_message_2 = ptr.add(1).rip().as<PVOID>();
}
},
// Send Network Damage
{
"SND",

View File

@ -60,6 +60,7 @@ namespace big
ImGui::Checkbox("VIEW_PROTECTION_SETTINGS_KICK_REJOIN"_T.data(), &g.protections.kick_rejoin);
ImGui::Checkbox("BLOCK_TRAFFIC_MANIPULATION"_T.data(), &g.protections.stop_traffic);
components::command_checkbox<"forcerelays">();
ImGui::Checkbox("DESYNC_KICK"_T.data(), &g.protections.desync_kick);
ImGui::EndGroup();
ImGui::SeparatorText("VIEW_PROTECTION_SETTINGS_OPTIONS"_T.data());