feat(Protection): Added TASK_TEMP_VEHICLE_ACTION anti-crash

This commit is contained in:
Yimura 2022-05-10 20:23:48 +02:00
parent 5b87f640f9
commit 7ddca9d877
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
3 changed files with 41 additions and 3 deletions

View File

@ -36,6 +36,7 @@ namespace big
pair report_cash_spawn{}; pair report_cash_spawn{};
pair modder_detect{}; pair modder_detect{};
pair request_control_event{}; pair request_control_event{};
pair vehicle_temp_action{};
} received_event{}; } received_event{};
struct struct
@ -318,6 +319,8 @@ namespace big
g->notifications.received_event.request_control_event.notify = j["notifications"]["received_event"]["request_control_event"]["notify"]; g->notifications.received_event.request_control_event.notify = j["notifications"]["received_event"]["request_control_event"]["notify"];
g->notifications.received_event.report_cash_spawn.log = j["notifications"]["received_event"]["report_cash_spawn"]["log"]; g->notifications.received_event.report_cash_spawn.log = j["notifications"]["received_event"]["report_cash_spawn"]["log"];
g->notifications.received_event.report_cash_spawn.notify = j["notifications"]["received_event"]["report_cash_spawn"]["notify"]; g->notifications.received_event.report_cash_spawn.notify = j["notifications"]["received_event"]["report_cash_spawn"]["notify"];
g->notifications.received_event.vehicle_temp_action.log = j["notifications"]["received_event"]["vehicle_temp_action"]["log"];
g->notifications.received_event.vehicle_temp_action.notify = j["notifications"]["received_event"]["vehicle_temp_action"]["notify"];
g->notifications.reports.log = j["notifications"]["reports"]["log"]; g->notifications.reports.log = j["notifications"]["reports"]["log"];
g->notifications.reports.notify = j["notifications"]["reports"]["notify"]; g->notifications.reports.notify = j["notifications"]["reports"]["notify"];
@ -521,7 +524,8 @@ namespace big
{ "clear_ped_task", return_notify_pair(g->notifications.received_event.clear_ped_task) }, { "clear_ped_task", return_notify_pair(g->notifications.received_event.clear_ped_task) },
{ "modder_detect", return_notify_pair(g->notifications.received_event.modder_detect) }, { "modder_detect", return_notify_pair(g->notifications.received_event.modder_detect) },
{ "report_cash_spawn", return_notify_pair(g->notifications.received_event.report_cash_spawn) }, { "report_cash_spawn", return_notify_pair(g->notifications.received_event.report_cash_spawn) },
{ "request_control_event", return_notify_pair(g->notifications.received_event.request_control_event) } { "request_control_event", return_notify_pair(g->notifications.received_event.request_control_event) },
{ "vehicle_temp_action", return_notify_pair(g->notifications.received_event.vehicle_temp_action) }
} }
}, },
{ "reports", return_notify_pair(g->notifications.reports) }, { "reports", return_notify_pair(g->notifications.reports) },

View File

@ -31,6 +31,39 @@ namespace big
switch ((RockstarEvent)event_id) switch ((RockstarEvent)event_id)
{ {
case RockstarEvent::SCRIPT_ENTITY_STATE_CHANGE_EVENT:
{
uint16_t entity;
buffer->ReadWord(&entity, 13);
uint32_t type;
buffer->ReadDword(&type, 4);
uint32_t unk;
buffer->ReadDword(&unk, 32);
if (type == 6)
{
uint16_t unk2;
buffer->ReadWord(&unk2, 13);
uint32_t action;
buffer->ReadDword(&action, 8);
if (action > 16 && action < 18)
{
g_pointers->m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset);
if (g->notifications.received_event.vehicle_temp_action.log)
LOG(INFO) << "RECEIVED_EVENT_HANDLER : " << source_player->get_name() << "sent TASK_VEHICLE_TEMP_ACTION crash.";
if (g->notifications.received_event.vehicle_temp_action.notify)
g_notification_service->push_warning("Protection",
fmt::format("{} sent TASK_VEHICLE_TEMP_ACTION crash.", source_player->get_name()));
return false;
}
}
buffer->Seek(0);
break;
}
case RockstarEvent::SCRIPTED_GAME_EVENT: case RockstarEvent::SCRIPTED_GAME_EVENT:
{ {
const auto scripted_game_event = std::make_unique<CScriptedGameEvent>(); const auto scripted_game_event = std::make_unique<CScriptedGameEvent>();

View File

@ -4,7 +4,7 @@ namespace big
{ {
void draw_pair_option(const std::string_view name, decltype(g->notifications.gta_thread_kill)& option) void draw_pair_option(const std::string_view name, decltype(g->notifications.gta_thread_kill)& option)
{ {
ImGui::Text(name.data()); ImGui::Text("%s", name.data());
ImGui::PushID(name.data()); ImGui::PushID(name.data());
ImGui::Checkbox("Log", &option.log); ImGui::Checkbox("Log", &option.log);
@ -40,13 +40,14 @@ namespace big
ImGui::BeginGroup(); ImGui::BeginGroup();
draw_pair_option("Clear Ped Tasks", received_event.clear_ped_task); draw_pair_option("Clear Ped Tasks", received_event.clear_ped_task);
draw_pair_option("Modder Detection", received_event.modder_detect); draw_pair_option("Modder Detection", received_event.modder_detect);
draw_pair_option("Report Cash Spawn", received_event.report_cash_spawn);
ImGui::EndGroup(); ImGui::EndGroup();
ImGui::SameLine(); ImGui::SameLine();
ImGui::BeginGroup(); ImGui::BeginGroup();
draw_pair_option("Report Cash Spawn", received_event.report_cash_spawn);
draw_pair_option("Request Control Event", received_event.request_control_event); draw_pair_option("Request Control Event", received_event.request_control_event);
draw_pair_option("Vehicle Temp Action", received_event.vehicle_temp_action);
ImGui::EndGroup(); ImGui::EndGroup();