From 899c116eca6d1456d3a3a67564e0688754b16950 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Sat, 21 Sep 2024 08:18:40 +0000 Subject: [PATCH] BE fixes and additions (#3706) * feat: add BE kick and ban * fix: use correct player ptr --- src/backend/commands/player/kick/battleye.cpp | 60 +++++++++++++++++++ src/gta/enums.hpp | 3 + src/hooks/protections/receive_net_message.cpp | 7 ++- .../matchmaking/matchmaking_service.cpp | 2 - src/views/players/player/player_kick.cpp | 4 ++ 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 src/backend/commands/player/kick/battleye.cpp diff --git a/src/backend/commands/player/kick/battleye.cpp b/src/backend/commands/player/kick/battleye.cpp new file mode 100644 index 00000000..025af9ef --- /dev/null +++ b/src/backend/commands/player/kick/battleye.cpp @@ -0,0 +1,60 @@ +#include "backend/player_command.hpp" +#include "gta_util.hpp" +#include "pointers.hpp" + +#include + +#include "packet.hpp" +#include + +namespace big +{ + class battleye_kick : player_command + { + using player_command::player_command; + + virtual CommandAccessLevel get_access_level() override + { + return CommandAccessLevel::TOXIC; + } + + virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr ctx) override + { + packet msg{}; + + msg.write_message(rage::eNetMessage::MsgKickPlayer); + msg.write(KickReason::BATTLEYE_KICK, 5); + msg.write(0, 32); + msg.write(false, 1); + + auto msg_id = player->get_session_player()->m_msg_id; + msg.send(msg_id); + } + }; + + class battleye_ban : player_command + { + using player_command::player_command; + + virtual CommandAccessLevel get_access_level() override + { + return CommandAccessLevel::TOXIC; + } + + virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr ctx) override + { + packet msg{}; + + msg.write_message(rage::eNetMessage::MsgKickPlayer); + msg.write(KickReason::BATTLEYE_BAN, 5); + msg.write(0, 32); + msg.write(false, 1); + + auto msg_id = player->get_session_player()->m_msg_id; + msg.send(msg_id); + } + }; + + battleye_kick g_battleye_kick("battlekick", "BATTLEYE_KICK", "BATTLEYE_KICK_DESC", 0); + battleye_ban g_battleye_ban("battleban", "BATTLEYE_FAKE_BAN", "BATTLEYE_FAKE_BAN_DESC", 0); +} \ No newline at end of file diff --git a/src/gta/enums.hpp b/src/gta/enums.hpp index 62b02591..4884e77e 100644 --- a/src/gta/enums.hpp +++ b/src/gta/enums.hpp @@ -534,6 +534,9 @@ enum class KickReason : uint8_t NAT_TYPE, SCADMIN, SCADMIN_BLACKLIST, + UNK, + BATTLEYE_KICK, + BATTLEYE_BAN, NUM_REASONS }; diff --git a/src/hooks/protections/receive_net_message.cpp b/src/hooks/protections/receive_net_message.cpp index 895e76e5..76739ae1 100644 --- a/src/hooks/protections/receive_net_message.cpp +++ b/src/hooks/protections/receive_net_message.cpp @@ -370,7 +370,7 @@ namespace big } case rage::eNetMessage::MsgKickPlayer: { - KickReason reason = buffer.Read(3); + KickReason reason = buffer.Read(5); if (!is_host_of_session(gta_util::get_network()->m_game_session_ptr, event->m_peer_id)) { @@ -378,13 +378,16 @@ namespace big return true; } + LOGF(stream::net_messages, VERBOSE, "{} sent us a MsgKickPlayer, reason = {}", peer->m_info.name, (int)reason); + if (reason == KickReason::VOTED_OUT) { g_notification_service.push_warning("PROTECTIONS"_T.data(), "YOU_HAVE_BEEN_KICKED"_T.data()); return true; } - LOGF(stream::net_messages, VERBOSE, "{} sent us a MsgKickPlayer, reason = {}", peer->m_info.name, (int)reason); + if (reason == KickReason::BATTLEYE_KICK || reason == KickReason::BATTLEYE_BAN) + return true; break; } case rage::eNetMessage::MsgRadioStationSyncRequest: diff --git a/src/services/matchmaking/matchmaking_service.cpp b/src/services/matchmaking/matchmaking_service.cpp index b605100c..29cb2e42 100644 --- a/src/services/matchmaking/matchmaking_service.cpp +++ b/src/services/matchmaking/matchmaking_service.cpp @@ -35,8 +35,6 @@ namespace big // TODO: the logic is incorrect - attributes->m_param_values[0] = -0x22F37A9E; - if (g.spoofing.spoof_session_bad_sport_status == 1) attributes->m_param_values[0] |= (1 << 14); // Bad Sport diff --git a/src/views/players/player/player_kick.cpp b/src/views/players/player/player_kick.cpp index dfad6a30..692ef64d 100644 --- a/src/views/players/player/player_kick.cpp +++ b/src/views/players/player/player_kick.cpp @@ -13,6 +13,10 @@ namespace big components::player_command_button<"hostkick">(g_player_service->get_selected()); ImGui::SameLine(); components::player_command_button<"breakup">(g_player_service->get_selected()); + ImGui::SameLine(); + components::player_command_button<"battlekick">(g_player_service->get_selected()); + ImGui::SameLine(); + components::player_command_button<"battleban">(g_player_service->get_selected()); ImGui::EndDisabled(); components::player_command_button<"smartkick">(g_player_service->get_selected());