From ed057e5dd103572e2f9df2355f0b738be262b22b Mon Sep 17 00:00:00 2001 From: Ryan <80224521+Rxann@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:14:29 -0400 Subject: [PATCH] Log CVehicleGadgetData, Block Remote Animations & Trailer Crash (#148) * untested * bump * log it * Block Remote Animations and such * Block Trailer Crash --- cmake/rdr-classes.cmake | 2 +- .../hooks/Protections/HandleNetGameEvent.cpp | 22 +++++++++-- .../hooks/Protections/ShouldBlockSync.cpp | 38 +++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/cmake/rdr-classes.cmake b/cmake/rdr-classes.cmake index 826aaa0f..d624c61c 100644 --- a/cmake/rdr-classes.cmake +++ b/cmake/rdr-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( rdr_classes GIT_REPOSITORY https://github.com/YimMenu/RDR-Classes.git - GIT_TAG 57dea47acc3645921ae630fee10350567f1461bb + GIT_TAG 79b0389bcfc7a616290ec3ec97ce4fa6a574d0ed GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/game/hooks/Protections/HandleNetGameEvent.cpp b/src/game/hooks/Protections/HandleNetGameEvent.cpp index aa33eab9..c6811e34 100644 --- a/src/game/hooks/Protections/HandleNetGameEvent.cpp +++ b/src/game/hooks/Protections/HandleNetGameEvent.cpp @@ -1,12 +1,14 @@ +#include "core/commands/BoolCommand.hpp" #include "core/hooking/DetourHook.hpp" +#include "game/backend/Protections.hpp" #include "game/hooks/Hooks.hpp" #include "game/pointers/Pointers.hpp" #include "game/rdr/Enums.hpp" -#include "game/backend/Protections.hpp" -#include "core/commands/BoolCommand.hpp" + #include -#include #include +#include + namespace { @@ -83,6 +85,20 @@ namespace YimMenu::Hooks return; } + if (type == NetEventType::GIVE_PED_SCRIPTED_TASK_EVENT && sourcePlayer) + { + LOG(WARNING) << "Blocked Remote Ped Animation from " << sourcePlayer->GetName(); + Pointers.SendEventAck(eventMgr, nullptr, sourcePlayer, targetPlayer, index, handledBits); + return; + } + + if (type == NetEventType::GIVE_PED_SEQUENCE_TASK_EVENT && sourcePlayer) + { + LOG(WARNING) << "Blocked Remote Ped Animation from " << sourcePlayer->GetName(); + Pointers.SendEventAck(eventMgr, nullptr, sourcePlayer, targetPlayer, index, handledBits); + return; + } + if (type == NetEventType::GIVE_CONTROL_EVENT && sourcePlayer) { YimMenu::Protections::SetSyncingPlayer(sourcePlayer); diff --git a/src/game/hooks/Protections/ShouldBlockSync.cpp b/src/game/hooks/Protections/ShouldBlockSync.cpp index 9ba493b4..3f1f8d0a 100644 --- a/src/game/hooks/Protections/ShouldBlockSync.cpp +++ b/src/game/hooks/Protections/ShouldBlockSync.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,24 @@ namespace LOG_FIELD_B(CPedAttachData, m_IsAttached); LOG_FIELD(CPedAttachData, m_AttachObjectId); break; + case "CVehicleGadgetDataNode"_J: + LOG_FIELD_B(CVehicleGadgetNodeData, m_has_position); + const auto& position = node->GetData().m_position; + LOG(INFO) << "\tm_position: X: " << position[0] << " Y: " << position[1] << " Z: " << position[2] << " W: " << position[3]; + LOG_FIELD(CVehicleGadgetNodeData, m_num_gadgets); + + for (int i = 0; i < node->GetData().m_num_gadgets; i++) + { + LOG(INFO) << "m_gadgets[" << i << "].m_type: " << node->GetData().m_gadgets[i].m_type; + uint32_t sum = 0; + for (int j = 0; j < sizeof(node->GetData().m_gadgets[i].m_data); j++) + { + sum += node->GetData().m_gadgets[i].m_data[j]; + } + + LOG(INFO) << "\tm_data: " << HEX(sum); + } + break; } } @@ -310,6 +329,16 @@ namespace NotificationType::Warning); return true; } + + if (data.m_IsAttached && object && object->m_ObjectType == (uint16_t)eNetObjType::Trailer) + { + LOG(WARNING) << "Blocked physical trailer attachment crash from " << Protections::GetSyncingPlayer().GetName(); + Notifications::Show("Protections", + std::string("Blocked physical trailer attachment crash from ") + .append(Protections::GetSyncingPlayer().GetName()), + NotificationType::Warning); + return true; + } } break; } @@ -356,6 +385,15 @@ namespace NotificationType::Warning); return true; } + + if (data.m_IsAttached && object && object->m_ObjectType == (uint16_t)eNetObjType::Trailer) + { + LOG(WARNING) << "Blocked trailer ped attachment crash from " << Protections::GetSyncingPlayer().GetName(); + Notifications::Show("Protections", + std::string("Blocked trailer ped attachment crash from ").append(Protections::GetSyncingPlayer().GetName()), + NotificationType::Warning); + return true; + } } break; }