feat(Hooking): Added protections for remote events on GetEventData function.

This commit is contained in:
Yimura 2020-12-31 23:22:28 +01:00
parent fa2ca8ca6f
commit 2b8679289e
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
7 changed files with 170 additions and 0 deletions

View File

@ -12,7 +12,9 @@ namespace big::functions
using censor_chat = int(int64_t chat_menu, const char* user_text, const char** output_text);
using error_screen = void(char* entryHeader, char* entryLine1, int instructionalKey, char* entryLine2, BOOL p4, Any p5, Any* p6, Any* p7, BOOL background);
using increment_stat_event = bool(uint64_t net_event_struct, int64_t sender, int64_t a3);
using get_event_data = bool(int32_t eventGroup, int32_t eventIndex, int64_t* args, uint32_t argCount);
using get_player_name = char*(Player player);
using get_net_player = int(Player player);
using script_event_handler = bool(void* events, CNetGamePlayer* sourcePlayer, CNetGamePlayer* targetPlayer);
using set_session_weather = void(char a1, int a2, int a3, int64_t a4);
using spectate_player = bool(bool toggle, Ped player);

View File

@ -1686,3 +1686,29 @@ enum PedBones : std::uint32_t
FB_R_Lip_Bot_001 = 0xC33B,
FB_Tongue_001 = 0xB987
};
enum RemoteEvents : std::int32_t
{
// new 1.52 shit
Bounty = -116602735,
CeoBan = -738295409,
CeoKick = -1648921703,
CeoMoney = -2029779863,
ClearWantedLevel = 393068387,
FakeDeposit = -1949011582,
ForceMission = -545396442,
ForceMission2 = 915906776,
ForceMission3 = 1764541627,
GtaBanner = 639032041,
PersonalVehicleDestroyed = 891272013, //arg 3 = value
RemoteOffradar = 575518757,
RotateCam = 1120313136,
SendToCutscene = -1879618040,
SendToIsland = 1300962917,
SoundSpam = 1097312011,
SoundSpam2 = -1162153263,
Spectate = -2074614269,
Teleport = -171207973,
TransactionError = 1302185744,
VehicleKick = -1333236192,
};

View File

@ -40,6 +40,7 @@ namespace big
m_convert_thread_to_fiber_hook("ConvertThreadToFiber", memory::module("kernel32.dll").get_export("ConvertThreadToFiber").as<void*>(), &hooks::convert_thread_to_fiber),
m_censor_chat("Censor Chat", g_pointers->m_censor_chat, &hooks::censor_chat),
m_get_event_data("Get Event Data", g_pointers->m_get_event_data, &hooks::get_event_data),
m_error_screen_hook("Disable Warning/Error Screen", g_pointers->m_error_screen, &hooks::error_screen),
m_increment_stat_hook("Increment Stat Event", g_pointers->m_increment_stat_event, &hooks::increment_stat_event),
m_script_event_hook("Script Event Handler", g_pointers->m_script_event_handler, &hooks::script_event_handler)
@ -68,6 +69,8 @@ namespace big
m_convert_thread_to_fiber_hook.enable();
// New hooks enable
m_censor_chat.enable();
m_get_event_data.enable();
m_error_screen_hook.enable();
m_increment_stat_hook.enable();
m_script_event_hook.enable();
@ -87,6 +90,8 @@ namespace big
m_swapchain_hook.disable();
// New hooks disable
m_censor_chat.disable();
m_get_event_data.disable();
m_error_screen_hook.disable();
m_increment_stat_hook.disable();
m_script_event_hook.disable();

View File

@ -23,6 +23,7 @@ namespace big
// New Hook Definitions
static int censor_chat(int64_t chat_menu, const char* user_text, const char** output_text);
static bool get_event_data(int32_t eventGroup, int32_t eventIndex, int64_t* args, uint32_t argCount);
static void error_screen(char* entryHeader, char* entryLine1, int instructionalKey, char* entryLine2, BOOL p4, Any p5, Any* p6, Any* p7, BOOL background);
static bool increment_stat_event(uint64_t net_event_struct, int64_t sender, int64_t a3);
static bool script_event_handler(std::int64_t NetEventStruct, std::int64_t CNetGamePlayer);
@ -57,6 +58,7 @@ namespace big
// New Detour Hook Definitions
detour_hook m_censor_chat;
detour_hook m_get_event_data;
detour_hook m_error_screen_hook;
detour_hook m_increment_stat_hook;
detour_hook m_script_event_hook;

View File

@ -0,0 +1,123 @@
#include "features.hpp"
#include "hooking.hpp"
#include "pointers.hpp"
#include "natives.hpp"
namespace big
{
bool hooks::get_event_data(int32_t eventGroup, int32_t eventIndex, int64_t* args, uint32_t argCount)
{
bool result = g_hooking->m_get_event_data.get_original<decltype(&hooks::get_event_data)>()(eventGroup, eventIndex, args, argCount);
if (result)
{
Player player = (Player)args[1];
auto hash = args[0];
char type[16] = "";
switch (hash)
{
case RemoteEvents::Bounty:
strcpy(type, "Bounty");
break;
case RemoteEvents::CeoBan:
strcpy(type, "Ceo Ban");
break;
case RemoteEvents::CeoKick:
strcpy(type, "Ceok Kick");
break;
case RemoteEvents::CeoMoney:
strcpy(type, "Ceo Money");
break;
case RemoteEvents::ClearWantedLevel:
strcpy(type, "Clear Wanted Level");
break;
case RemoteEvents::FakeDeposit:
strcpy(type, "Fake Deposit");
break;
case RemoteEvents::ForceMission:
case RemoteEvents::ForceMission2:
case RemoteEvents::ForceMission3:
strcpy(type, "Force Mission");
break;
case RemoteEvents::GtaBanner:
strcpy(type, "GTA Banner");
break;
case RemoteEvents::PersonalVehicleDestroyed:
strcpy(type, "Personal Vehicle Destroyed");
break;
case RemoteEvents::RemoteOffradar:
strcpy(type, "Remote Off Radar");
break;
case RemoteEvents::RotateCam:
strcpy(type, "Rotate Cam");
break;
case RemoteEvents::SendToCutscene:
strcpy(type, "Send To Cutscene");
break;
case RemoteEvents::SendToIsland:
strcpy(type, "Send To Island");
break;
case RemoteEvents::SoundSpam:
case RemoteEvents::SoundSpam2:
strcpy(type, "Sound Spam");
break;
case RemoteEvents::Spectate:
strcpy(type, "Specate");
break;
case RemoteEvents::Teleport:
strcpy(type, "Force Teleport");
break;
case RemoteEvents::TransactionError:
strcpy(type, "Transaction Error");
break;
case RemoteEvents::VehicleKick:
strcpy(type, "Vehicle Kick");
break;
}
if (strlen(type) != 0)
{
char msg[128];
strcpy(msg, "~g~BLOCKED EVENT~s~\nFrom <C>");
strcat(msg, g_pointers->m_get_player_name(player));
strcat(msg, "</C>\nEvent Type: ~b~");
strcat(msg, type);
features::notify::above_map(msg);
return false;
}
const char* sender = g_pointers->m_get_player_name(player);
LOG(INFO) << "Player: " << sender;
LOG(INFO) << "Script hash: " << args[0];
LOG(INFO) << "Script event group: " << eventGroup;
LOG(INFO) << "Script event index: " << eventIndex;
LOG(INFO) << "Script event argcount: " << argCount;
for (std::uint32_t i = 0; i < argCount; i++)
LOG(INFO) << "Script event args[" << i << "] : " << args[i];
}
return result;
}
}

View File

@ -118,6 +118,16 @@ namespace big
m_censor_chat = ptr.as<decltype(m_censor_chat)>();
});
main_batch.add("Get Net player", "48 83 EC 28 33 C0 38 05 ? ? ? ? 74 0A", [this](memory::handle ptr)
{
m_get_net_game_player = ptr.as<decltype(m_get_net_game_player)>();
});
main_batch.add("Get Event Data", "48 85 C0 74 14 4C 8B 10", [this](memory::handle ptr)
{
m_get_event_data = ptr.sub(28).as<decltype(m_get_event_data)>();
});
main_batch.run(memory::module(nullptr));
m_hwnd = FindWindowW(L"grcWindow", nullptr);

View File

@ -37,7 +37,9 @@ namespace big
functions::censor_chat* m_censor_chat{};
functions::error_screen* m_error_screen{};
functions::get_event_data* m_get_event_data{};
functions::get_player_name* m_get_player_name{};
functions::get_net_player* m_get_net_game_player{};
functions::increment_stat_event* m_increment_stat_event{};
functions::script_event_handler* m_script_event_handler{};
functions::set_session_weather* m_set_session_weather{};