RECEIVED_CLONE_REMOVE player ped removal protection (#2732)

This commit is contained in:
Quentin 2024-02-20 20:26:12 +01:00 committed by GitHub
parent 4f9997d9ed
commit 3342d663f6
6 changed files with 34 additions and 1 deletions

View File

@ -208,4 +208,6 @@ namespace big::functions
using remove_player_from_sender_list = bool (*)(void* list, uint64_t* rockstar_id);
using get_ped_seat = CGetPedSeatReturnClass*(*)(PVOID seat_info, CPed* ped);
using received_clone_remove = void (*)(CNetworkObjectMgr*, CNetGamePlayer*, CNetGamePlayer*, int16_t, uint32_t);
}

View File

@ -360,6 +360,8 @@ namespace big
bool* m_is_social_club_overlay_active;
functions::get_ped_seat m_get_ped_seat;
functions::received_clone_remove m_received_clone_remove;
};
#pragma pack(pop)
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");

View File

@ -138,6 +138,8 @@ namespace big
detour_hook_helper::add<hooks::read_bits_single>("RBS", g_pointers->m_gta.m_read_bits_single);
detour_hook_helper::add<hooks::received_clone_remove>("RCR", g_pointers->m_gta.m_received_clone_remove);
g_hooking = this;
}

View File

@ -1,10 +1,10 @@
#pragma once
#include "MinHook.h"
#include "detour_hook.hpp"
#include "vmt_hook.hpp"
#include "vtable_hook.hpp"
#include <gta/enums.hpp>
#include <network/netConnection.hpp> // cannot stub this
class CPlayerGamerDataNode;
@ -176,6 +176,8 @@ namespace big
static bool read_bits_single(void* data, int* out_value, int size, int offset);
static void received_clone_remove(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, int16_t object_id, uint32_t ownership_token);
static bool sync_reader_serialize_dword(void* _this, uint32_t* dword, int size);
static bool sync_reader_serialize_word(void* _this, uint16_t* word, int size);
static bool sync_reader_serialize_byte(void* _this, uint8_t* byte, int size);

View File

@ -0,0 +1,16 @@
#include "hooking/hooking.hpp"
#include "util/notify.hpp"
namespace big
{
void hooks::received_clone_remove(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, int16_t object_id, uint32_t ownership_token)
{
if (dst->m_player_info->m_ped->m_net_object->m_object_id == object_id)
{
notify::crash_blocked(src, "player ped removal");
return;
}
g_hooking->get_original<hooks::received_clone_remove>()(mgr, src, dst, object_id, ownership_token);
}
}

View File

@ -1754,6 +1754,15 @@ namespace big
{
g_pointers->m_gta.m_get_ped_seat = ptr.add(1).rip().as<functions::get_ped_seat>();
}
},
// RECEIVED_CLONE_REMOVE
{
"RCR",
"48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 54 41 56 41 57 48 83 EC 50 4C 8B F2 4D 8B E0",
[](memory::handle ptr)
{
g_pointers->m_gta.m_received_clone_remove = ptr.as<functions::received_clone_remove>();
}
}
>(); // don't leave a trailing comma at the end