mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Desync kick protection (#3086)
This commit is contained in:
parent
c77ffe1788
commit
9ad4885a8f
@ -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 ""
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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",
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user