Skip to content

Commit

Permalink
Log CVehicleGadgetData, Block Remote Animations & Trailer Crash (#148)
Browse files Browse the repository at this point in the history
* untested

* bump

* log it

* Block Remote Animations and such

* Block Trailer Crash
  • Loading branch information
Rxann authored Jun 20, 2024
1 parent f739bfc commit ed057e5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmake/rdr-classes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
22 changes: 19 additions & 3 deletions src/game/hooks/Protections/HandleNetGameEvent.cpp
Original file line number Diff line number Diff line change
@@ -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 <network/CNetGamePlayer.hpp>
#include <rage/datBitBuffer.hpp>
#include <network/netObject.hpp>
#include <rage/datBitBuffer.hpp>


namespace
{
Expand Down Expand Up @@ -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);
Expand Down
38 changes: 38 additions & 0 deletions src/game/hooks/Protections/ShouldBlockSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <network/sync/pickup/CPickupCreationData.hpp>
#include <network/sync/player/CPlayerAppearanceData.hpp>
#include <network/sync/vehicle/CVehicleCreationData.hpp>
#include <network/sync/vehicle/CVehicleGadgetData.hpp>
#include <network/sync/vehicle/CVehicleProximityMigrationData.hpp>
#include <ped/CPed.hpp>
#include <unordered_set>
Expand Down Expand Up @@ -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<CVehicleGadgetNodeData>().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<CVehicleGadgetNodeData>().m_num_gadgets; i++)
{
LOG(INFO) << "m_gadgets[" << i << "].m_type: " << node->GetData<CVehicleGadgetNodeData>().m_gadgets[i].m_type;
uint32_t sum = 0;
for (int j = 0; j < sizeof(node->GetData<CVehicleGadgetNodeData>().m_gadgets[i].m_data); j++)
{
sum += node->GetData<CVehicleGadgetNodeData>().m_gadgets[i].m_data[j];
}

LOG(INFO) << "\tm_data: " << HEX(sum);
}
break;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ed057e5

Please sign in to comment.