From 7ddca9d877c71a2815ec65beb4fb2a1b4b07d62b Mon Sep 17 00:00:00 2001 From: Yimura Date: Tue, 10 May 2022 20:23:48 +0200 Subject: [PATCH] feat(Protection): Added TASK_TEMP_VEHICLE_ACTION anti-crash --- BigBaseV2/src/core/globals.hpp | 6 +++- BigBaseV2/src/hooks/received_event.cpp | 33 +++++++++++++++++++ .../settings/view_notification_settings.cpp | 5 +-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 1125a09b..0e6596bd 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -36,6 +36,7 @@ namespace big pair report_cash_spawn{}; pair modder_detect{}; pair request_control_event{}; + pair vehicle_temp_action{}; } received_event{}; 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.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.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.notify = j["notifications"]["reports"]["notify"]; @@ -521,7 +524,8 @@ namespace big { "clear_ped_task", return_notify_pair(g->notifications.received_event.clear_ped_task) }, { "modder_detect", return_notify_pair(g->notifications.received_event.modder_detect) }, { "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) }, diff --git a/BigBaseV2/src/hooks/received_event.cpp b/BigBaseV2/src/hooks/received_event.cpp index 12644390..1c02a743 100644 --- a/BigBaseV2/src/hooks/received_event.cpp +++ b/BigBaseV2/src/hooks/received_event.cpp @@ -31,6 +31,39 @@ namespace big 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: { const auto scripted_game_event = std::make_unique(); diff --git a/BigBaseV2/src/views/settings/view_notification_settings.cpp b/BigBaseV2/src/views/settings/view_notification_settings.cpp index df5ccdff..fac0402f 100644 --- a/BigBaseV2/src/views/settings/view_notification_settings.cpp +++ b/BigBaseV2/src/views/settings/view_notification_settings.cpp @@ -4,7 +4,7 @@ namespace big { 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::Checkbox("Log", &option.log); @@ -40,13 +40,14 @@ namespace big ImGui::BeginGroup(); draw_pair_option("Clear Ped Tasks", received_event.clear_ped_task); draw_pair_option("Modder Detection", received_event.modder_detect); + draw_pair_option("Report Cash Spawn", received_event.report_cash_spawn); ImGui::EndGroup(); ImGui::SameLine(); 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("Vehicle Temp Action", received_event.vehicle_temp_action); ImGui::EndGroup();