From a0f2b015408e5630f85271ffd812d5f882060f90 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Sat, 22 Jul 2023 21:18:47 +0000 Subject: [PATCH] Improve protections and other random changes (#1803) * feat(protections): better logging * feat(protections): improve protections * fix(globals): save all spoofing settings --- scripts/gtav-classes.cmake | 2 +- src/backend/commands/player/kick/oom_kick.cpp | 26 +- src/byte_patch_manager.cpp | 3 + src/core/data/task_types.hpp | 437 ++++++++++++++++++ src/core/settings.hpp | 24 +- src/function_types.hpp | 17 +- src/gta/fidevice.hpp | 2 - src/gta/net_game_event.hpp | 51 +- src/gta/sysMemAllocator.hpp | 4 - src/gta_pointers.hpp | 14 +- src/hooking.cpp | 6 + src/hooking.hpp | 14 +- src/hooks/misc/log_message_error_box.cpp | 10 +- .../assign_physical_index.cpp | 4 +- .../protections/allocate_memory_reliable.cpp | 80 ++++ src/hooks/protections/receive_net_message.cpp | 22 +- src/hooks/protections/received_event.cpp | 6 +- src/hooks/protections/render_big_ped.cpp | 18 + src/hooks/protections/render_entity.cpp | 20 + src/hooks/protections/render_ped.cpp | 17 + .../send_non_physical_player_data.cpp | 3 +- src/packet.cpp | 10 +- src/pointers.cpp | 67 ++- .../creator_storage_service.cpp | 3 +- src/services/players/player.cpp | 8 +- src/services/players/player.hpp | 4 + src/util/spam.hpp | 1 + src/util/toxic.hpp | 4 +- src/views/players/player/player_info.cpp | 1 + 29 files changed, 757 insertions(+), 121 deletions(-) create mode 100644 src/core/data/task_types.hpp delete mode 100644 src/gta/sysMemAllocator.hpp create mode 100644 src/hooks/protections/allocate_memory_reliable.cpp create mode 100644 src/hooks/protections/render_big_ped.cpp create mode 100644 src/hooks/protections/render_entity.cpp create mode 100644 src/hooks/protections/render_ped.cpp diff --git a/scripts/gtav-classes.cmake b/scripts/gtav-classes.cmake index 349de6a5..f1df2198 100644 --- a/scripts/gtav-classes.cmake +++ b/scripts/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git - GIT_TAG 7ff656ae2b733bcf2bc621592f602654403eba67 + GIT_TAG fe0893ffb589da617442015b97a62c117ac5bed4 GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/backend/commands/player/kick/oom_kick.cpp b/src/backend/commands/player/kick/oom_kick.cpp index 3d5b423e..56239542 100644 --- a/src/backend/commands/player/kick/oom_kick.cpp +++ b/src/backend/commands/player/kick/oom_kick.cpp @@ -5,14 +5,14 @@ #include "pointers.hpp" #include "util/scripts.hpp" +#include + namespace big { class oom_kick : player_command { using player_command::player_command; - std::chrono::system_clock::time_point last_oom_kick_time{}; - virtual CommandAccessLevel get_access_level() { return CommandAccessLevel::TOXIC; @@ -20,26 +20,14 @@ namespace big virtual void execute(player_ptr player, const std::vector& _args, const std::shared_ptr ctx) { - if (std::chrono::system_clock::now() - last_oom_kick_time < 7s) - { - g_notification_service->push_error("Kick", "Don't spam this or it will backfire"); - return; - } + packet msg{}; - last_oom_kick_time = std::chrono::system_clock::now(); + msg.write_message(rage::eNetMessage::MsgRadioStationSyncRequest); + auto msg_id = player->get_session_player()->m_msg_id; - if (auto freemode = gta_util::find_script_thread(RAGE_JOAAT("freemode"))) + for (int j = 0; j < 2000; j++) { - packet msg{}; - msg.write_message(rage::eNetMessage::MsgScriptMigrateHost); - freemode->m_handler->get_id()->serialize(&msg.m_buffer); - msg.write(0, 16); - msg.write(0, 32); - auto msg_id = player->get_net_game_player()->m_msg_id; - for (int j = 0; j < 2100; j++) - { - msg.send(msg_id); - } + msg.send(msg_id); } } }; diff --git a/src/byte_patch_manager.cpp b/src/byte_patch_manager.cpp index 3c9aac10..1871377c 100644 --- a/src/byte_patch_manager.cpp +++ b/src/byte_patch_manager.cpp @@ -80,6 +80,9 @@ namespace big // window hook: pt1 memory::byte_patch::make(g_pointers->m_gta.m_window_hook.as(), std::to_array({0xC3, 0x90, 0x90, 0x90}))->apply(); + + // Prevent the game from crashing when flooded with outgoing events + memory::byte_patch::make(g_pointers->m_gta.m_free_event_error, std::vector{0x90, 0x90, 0x90, 0x90, 0x90})->apply(); } byte_patch_manager::byte_patch_manager() diff --git a/src/core/data/task_types.hpp b/src/core/data/task_types.hpp new file mode 100644 index 00000000..67f87f40 --- /dev/null +++ b/src/core/data/task_types.hpp @@ -0,0 +1,437 @@ +#pragma once + +const inline static std::vector> task_type_names = { + {0, "CTaskHandsUp"}, + {1, "CTaskClimbLadder"}, + {2, "CTaskExitVehicle"}, + {3, "CTaskCombatRoll"}, + {4, "CTaskAimGunOnFoot"}, + {5, "CTaskMovePlayer"}, + {6, "CTaskPlayerOnFoot"}, + {8, "CTaskWeapon"}, + {9, "CTaskPlayerWeapon"}, + {10, "CTaskPlayerIdles"}, + {12, "CTaskAimGun"}, + {12, "CTaskComplex"}, + {12, "CTaskFSMClone"}, + {12, "CTaskMotionBase"}, + {12, "CTaskMove"}, + {12, "CTaskMoveBase"}, + {12, "CTaskNMBehaviour"}, + {12, "CTaskNavBase"}, + {12, "CTaskScenario"}, + {12, "CTaskSearchBase"}, + {12, "CTaskSearchInVehicleBase"}, + {12, "CTaskShockingEvent"}, + {12, "CTaskTrainBase"}, + {12, "CTaskVehicleFSM"}, + {12, "CTaskVehicleGoTo"}, + {12, "CTaskVehicleMissionBase"}, + {12, "CTaskVehicleTempAction"}, + {14, "CTaskPause"}, + {15, "CTaskDoNothing"}, + {16, "CTaskGetUp"}, + {17, "CTaskGetUpAndStandStill"}, + {18, "CTaskFallOver"}, + {19, "CTaskFallAndGetUp"}, + {20, "CTaskCrawl"}, + {25, "CTaskComplexOnFire"}, + {26, "CTaskDamageElectric"}, + {28, "CTaskTriggerLookAt"}, + {29, "CTaskClearLookAt"}, + {30, "CTaskSetCharDecisionMaker"}, + {31, "CTaskSetPedDefensiveArea"}, + {32, "CTaskUseSequence"}, + {34, "CTaskMoveStandStill"}, + {35, "CTaskComplexControlMovement"}, + {36, "CTaskMoveSequence"}, + {38, "CTaskAmbientClips"}, + {39, "CTaskMoveInAir"}, + {40, "CTaskNetworkClone"}, + {41, "CTaskUseClimbOnRoute"}, + {42, "CTaskUseDropDownOnRoute"}, + {43, "CTaskUseLadderOnRoute"}, + {44, "CTaskSetBlockingOfNonTemporaryEvents"}, + {45, "CTaskForceMotionState"}, + {46, "CTaskSlopeScramble"}, + {47, "CTaskGoToAndClimbLadder"}, + {48, "CTaskClimbLadderFully"}, + {49, "CTaskRappel"}, + {50, "CTaskVault"}, + {51, "CTaskDropDown"}, + {52, "CTaskAffectSecondaryBehaviour"}, + {53, "CTaskAmbientLookAtEvent"}, + {54, "CTaskOpenDoor"}, + {55, "CTaskShovePed"}, + {56, "CTaskSwapWeapon"}, + {57, "CTaskGeneralSweep"}, + {58, "CTaskPolice"}, + {59, "CTaskPoliceOrderResponse"}, + {60, "CTaskPursueCriminal"}, + {62, "CTaskArrestPed"}, + {63, "CTaskArrestPed2"}, + {64, "CTaskBusted"}, + {65, "CTaskFirePatrol"}, + {66, "CTaskHeliOrderResponse"}, + {67, "CTaskHeliPassengerRappel"}, + {68, "CTaskAmbulancePatrol"}, + {69, "CTaskPoliceWantedResponse"}, + {70, "CTaskSwat"}, + {72, "CTaskSwatWantedResponse"}, + {73, "CTaskSwatOrderResponse"}, + {74, "CTaskSwatGoToStagingArea"}, + {75, "CTaskSwatFollowInLine"}, + {76, "CTaskWitness"}, + {77, "CTaskGangPatrol"}, + {78, "CTaskArmy"}, + {80, "CTaskShockingEventWatch"}, + {82, "CTaskShockingEventGoto"}, + {83, "CTaskShockingEventHurryAway"}, + {84, "CTaskShockingEventReactToAircraft"}, + {85, "CTaskShockingEventReact"}, + {86, "CTaskShockingEventBackAway"}, + {87, "CTaskShockingPoliceInvestigate"}, + {88, "CTaskShockingEventStopAndStare"}, + {89, "CTaskShockingNiceCarPicture"}, + {90, "CTaskShockingEventThreatResponse"}, + {92, "CTaskTakeOffHelmet"}, + {93, "CTaskCarReactToVehicleCollision"}, + {95, "CTaskCarReactToVehicleCollisionGetOut"}, + {97, "CTaskDyingDead"}, + {100, "CTaskWanderingScenario"}, + {101, "CTaskWanderingInRadiusScenario"}, + {103, "CTaskMoveBetweenPointsScenario"}, + {104, "CTaskChatScenario"}, + {106, "CTaskCowerScenario"}, + {107, "CTaskDeadBodyScenario"}, + {114, "CTaskSayAudio"}, + {116, "CTaskWaitForSteppingOut"}, + {117, "CTaskCoupleScenario"}, + {118, "CTaskUseScenario"}, + {119, "CTaskUseVehicleScenario"}, + {120, "CTaskUnalerted"}, + {121, "CTaskStealVehicle"}, + {122, "CTaskReactToPursuit"}, + {125, "CTaskHitWall"}, + {126, "CTaskCower"}, + {127, "CTaskCrouch"}, + {128, "CTaskMelee"}, + {129, "CTaskMoveMeleeMovement"}, + {130, "CTaskMeleeActionResult"}, + {131, "CTaskMeleeUpperbodyAnims"}, + {133, "CTaskMoVEScripted"}, + {134, "CTaskScriptedAnimation"}, + {135, "CTaskSynchronizedScene"}, + {137, "CTaskComplexEvasiveStep"}, + {138, "CTaskWalkRoundCarWhileWandering"}, + {140, "CTaskComplexStuckInAir"}, + {141, "CTaskWalkRoundEntity"}, + {142, "CTaskMoveWalkRoundVehicle"}, + {144, "CTaskReactToGunAimedAt"}, + {146, "CTaskDuckAndCover"}, + {147, "CTaskAggressiveRubberneck"}, + {150, "CTaskInVehicleBasic"}, + {151, "CTaskCarDriveWander"}, + {152, "CTaskLeaveAnyCar"}, + {153, "CTaskComplexGetOffBoat"}, + {155, "CTaskCarSetTempAction"}, + {156, "CTaskBringVehicleToHalt"}, + {157, "CTaskCarDrive"}, + {159, "CTaskPlayerDrive"}, + {160, "CTaskEnterVehicle"}, + {161, "CTaskEnterVehicleAlign"}, + {162, "CTaskOpenVehicleDoorFromOutside"}, + {163, "CTaskEnterVehicleSeat"}, + {164, "CTaskCloseVehicleDoorFromInside"}, + {165, "CTaskInVehicleSeatShuffle"}, + {167, "CTaskExitVehicleSeat"}, + {168, "CTaskCloseVehicleDoorFromOutside"}, + {169, "CTaskControlVehicle"}, + {170, "CTaskMotionInAutomobile"}, + {171, "CTaskMotionOnBicycle"}, + {172, "CTaskMotionOnBicycleController"}, + {173, "CTaskMotionInVehicle"}, + {174, "CTaskMotionInTurret"}, + {175, "CTaskReactToBeingJacked"}, + {176, "CTaskReactToBeingAskedToLeaveVehicle"}, + {177, "CTaskTryToGrabVehicleDoor"}, + {178, "CTaskGetOnTrain"}, + {179, "CTaskGetOffTrain"}, + {180, "CTaskRideTrain"}, + {190, "CTaskMountThrowProjectile"}, + {195, "CTaskGoToCarDoorAndStandStill"}, + {196, "CTaskMoveGoToVehicleDoor"}, + {197, "CTaskSetPedInVehicle"}, + {198, "CTaskSetPedOutOfVehicle"}, + {199, "CTaskVehicleMountedWeapon"}, + {200, "CTaskVehicleGun"}, + {201, "CTaskVehicleProjectile"}, + {204, "CTaskSmashCarWindow"}, + {205, "CTaskMoveGoToPoint"}, + {206, "CTaskMoveAchieveHeading"}, + {207, "CTaskMoveFaceTarget"}, + {208, "CTaskComplexGoToPointAndStandStillTimed"}, + {208, "CTaskMoveGoToPointAndStandStill"}, + {209, "CTaskMoveFollowPointRoute"}, + {210, "CTaskMoveSeekEntity_CEntitySeekPosCalculatorStandard"}, + {211, "CTaskMoveSeekEntity_CEntitySeekPosCalculatorLastNavMeshIntersection"}, + {212, "CTaskMoveSeekEntity_CEntitySeekPosCalculatorLastNavMeshIntersection2"}, + {213, "CTaskMoveSeekEntity_CEntitySeekPosCalculatorXYOffsetFixed"}, + {214, "CTaskMoveSeekEntity_CEntitySeekPosCalculatorXYOffsetFixed2"}, + {215, "CTaskExhaustedFlee"}, + {216, "CTaskGrowlAndFlee"}, + {217, "CTaskScenarioFlee"}, + {218, "CTaskSmartFlee"}, + {219, "CTaskFlyAway"}, + {220, "CTaskWalkAway"}, + {221, "CTaskWander"}, + {222, "CTaskWanderInArea"}, + {223, "CTaskFollowLeaderInFormation"}, + {224, "CTaskGoToPointAnyMeans"}, + {225, "CTaskTurnToFaceEntityOrCoord"}, + {226, "CTaskFollowLeaderAnyMeans"}, + {228, "CTaskFlyToPoint"}, + {229, "CTaskFlyingWander"}, + {230, "CTaskGoToPointAiming"}, + {231, "CTaskGoToScenario"}, + {233, "CTaskSeekEntityAiming"}, + {234, "CTaskSlideToCoord"}, + {235, "CTaskSwimmingWander"}, + {237, "CTaskMoveTrackingEntity"}, + {238, "CTaskMoveFollowNavMesh"}, + {239, "CTaskMoveGoToPointOnRoute"}, + {240, "CTaskEscapeBlast"}, + {241, "CTaskMoveWander"}, + {242, "CTaskMoveBeInFormation"}, + {243, "CTaskMoveCrowdAroundLocation"}, + {244, "CTaskMoveCrossRoadAtTrafficLights"}, + {245, "CTaskMoveWaitForTraffic"}, + {246, "CTaskMoveGoToPointStandStillAchieveHeading"}, + {251, "CTaskMoveGetOntoMainNavMesh"}, + {252, "CTaskMoveSlideToCoord"}, + {253, "CTaskMoveGoToPointRelativeToEntityAndStandStill"}, + {254, "CTaskHelicopterStrafe"}, + {256, "CTaskGetOutOfWater"}, + {259, "CTaskMoveFollowEntityOffset"}, + {261, "CTaskFollowWaypointRecording"}, + {264, "CTaskMotionPed"}, + {265, "CTaskMotionPedLowLod"}, + {268, "CTaskHumanLocomotion"}, + {269, "CTaskMotionBasicLocomotionLowLod"}, + {270, "CTaskMotionStrafing"}, + {271, "CTaskMotionTennis"}, + {272, "CTaskMotionAiming"}, + {273, "CTaskBirdLocomotion"}, + {274, "CTaskFlightlessBirdLocomotion"}, + {278, "CTaskFishLocomotion"}, + {279, "CTaskQuadLocomotion"}, + {280, "CTaskMotionDiving"}, + {281, "CTaskMotionSwimming"}, + {282, "CTaskMotionParachuting"}, + {283, "CTaskMotionDrunk"}, + {284, "CTaskRepositionMove"}, + {285, "CTaskMotionAimingTransition"}, + {286, "CTaskThrowProjectile"}, + {287, "CTaskCover"}, + {288, "CTaskMotionInCover"}, + {289, "CTaskAimAndThrowProjectile"}, + {290, "CTaskGun"}, + {291, "CTaskAimFromGround"}, + {295, "CTaskAimGunVehicleDriveBy"}, + {296, "CTaskAimGunScripted"}, + {298, "CTaskReloadGun"}, + {299, "CTaskWeaponBlocked"}, + {300, "CTaskEnterCover"}, + {301, "CTaskExitCover"}, + {302, "CTaskAimGunFromCoverIntro"}, + {303, "CTaskAimGunFromCoverOutro"}, + {304, "CTaskAimGunBlindFire"}, + {307, "CTaskCombatClosestTargetInArea"}, + {308, "CTaskCombatAdditionalTask"}, + {309, "CTaskInCover"}, + {313, "CTaskAimSweep"}, + {319, "CTaskSharkCircle"}, + {320, "CTaskSharkAttack"}, + {321, "CTaskAgitated"}, + {322, "CTaskAgitatedAction"}, + {323, "CTaskConfront"}, + {324, "CTaskIntimidate"}, + {325, "CTaskShove"}, + {326, "CTaskShoved"}, + {328, "CTaskCrouchToggle"}, + {329, "CTaskRevive"}, + {335, "CTaskParachute"}, + {336, "CTaskParachuteObject"}, + {337, "CTaskTakeOffPedVariation"}, + {340, "CTaskCombatSeekCover"}, + {342, "CTaskCombatFlank"}, + {343, "CTaskCombat"}, + {344, "CTaskCombatMounted"}, + {345, "CTaskMoveCircle"}, + {346, "CTaskMoveCombatMounted"}, + {347, "CTaskSearch"}, + {348, "CTaskSearchOnFoot"}, + {349, "CTaskSearchInAutomobile"}, + {350, "CTaskSearchInBoat"}, + {351, "CTaskSearchInHeli"}, + {352, "CTaskThreatResponse"}, + {353, "CTaskInvestigate"}, + {354, "CTaskStandGuardFSM"}, + {355, "CTaskPatrol"}, + {356, "CTaskShootAtTarget"}, + {357, "CTaskSetAndGuardArea"}, + {358, "CTaskStandGuard"}, + {359, "CTaskSeparate"}, + {360, "CTaskStayInCover"}, + {361, "CTaskVehicleCombat"}, + {362, "CTaskVehiclePersuit"}, + {363, "CTaskVehicleChase"}, + {364, "CTaskDraggingToSafety"}, + {365, "CTaskDraggedToSafety"}, + {366, "CTaskVariedAimPose"}, + {367, "CTaskMoveWithinAttackWindow"}, + {368, "CTaskMoveWithinDefensiveArea"}, + {369, "CTaskShootOutTire"}, + {370, "CTaskShellShocked"}, + {371, "CTaskBoatChase"}, + {372, "CTaskBoatCombat"}, + {373, "CTaskBoatStrafe"}, + {374, "CTaskHeliChase"}, + {375, "CTaskHeliCombat"}, + {376, "CTaskSubmarineCombat"}, + {377, "CTaskSubmarineChase"}, + {378, "CTaskPlaneChase"}, + {379, "CTaskTargetUnreachable"}, + {380, "CTaskTargetUnreachableInInterior"}, + {381, "CTaskTargetUnreachableInExterior"}, + {382, "CTaskStealthKill"}, + {383, "CTaskWrithe"}, + {384, "CTaskAdvance"}, + {385, "CTaskCharge"}, + {386, "CTaskMoveToTacticalPoint"}, + {387, "CTaskToHurtTransit"}, + {388, "CTaskAnimatedHitByExplosion"}, + {389, "CTaskNMRelax"}, + {391, "CTaskNMPose"}, + {392, "CTaskNMBrace"}, + {393, "CTaskNMBuoyancy"}, + {394, "CTaskNMInjuredOnGround"}, + {395, "CTaskNMShot"}, + {396, "CTaskNMHighFall"}, + {397, "CTaskNMBalance"}, + {398, "CTaskNMElectrocute"}, + {399, "CTaskNMPrototype"}, + {400, "CTaskNMExplosion"}, + {401, "CTaskNMOnFire"}, + {402, "CTaskNMScriptControl"}, + {403, "CTaskNMJumpRollFromRoadVehicle"}, + {404, "CTaskNMFlinch"}, + {405, "CTaskNMSit"}, + {406, "CTaskNMFallDown"}, + {407, "CTaskBlendFromNM"}, + {408, "CTaskNMControl"}, + {409, "CTaskNMDangle"}, + {412, "CTaskNMGenericAttach"}, + {414, "CTaskNMDraggingToSafety"}, + {415, "CTaskNMThroughWindscreen"}, + {416, "CTaskNMRiverRapids"}, + {417, "CTaskNMSimple"}, + {418, "CTaskRageRagdoll"}, + {421, "CTaskJumpVault"}, + {422, "CTaskJump"}, + {423, "CTaskFall"}, + {425, "CTaskReactAimWeapon"}, + {426, "CTaskChat"}, + {427, "CTaskMobilePhone"}, + {428, "CTaskReactToDeadPed"}, + {430, "CTaskSearchForUnknownThreat"}, + {432, "CTaskBomb"}, + {433, "CTaskDetonator"}, + {435, "CTaskAnimatedAttach"}, + {441, "CTaskCutScene"}, + {442, "CTaskReactToExplosion"}, + {443, "CTaskReactToImminentExplosion"}, + {444, "CTaskDiveToGround"}, + {445, "CTaskReactAndFlee"}, + {446, "CTaskSidestep"}, + {447, "CTaskCallPolice"}, + {448, "CTaskReactInDirection"}, + {449, "CTaskReactToBuddyShot"}, + {454, "CTaskVehicleGoToAutomobileNew"}, + {455, "CTaskVehicleGoToPlane"}, + {456, "CTaskVehicleGoToHelicopter"}, + {457, "CTaskVehicleGoToSubmarine"}, + {458, "CTaskVehicleGoToBoat"}, + {459, "CTaskVehicleGoToPointAutomobile"}, + {460, "CTaskVehicleGoToPointWithAvoidanceAutomobile"}, + {461, "CTaskVehiclePursue"}, + {462, "CTaskVehicleRam"}, + {463, "CTaskVehicleSpinOut"}, + {464, "CTaskVehicleApproach"}, + {465, "CTaskVehicleThreePointTurn"}, + {466, "CTaskVehicleDeadDriver"}, + {467, "CTaskVehicleCruiseNew"}, + {468, "CTaskVehicleCruiseBoat"}, + {469, "CTaskVehicleStop"}, + {470, "CTaskVehiclePullOver"}, + {471, "CTaskVehiclePassengerExit"}, + {472, "CTaskVehicleFlee"}, + {473, "CTaskVehicleFleeAirborne"}, + {474, "CTaskVehicleFleeBoat"}, + {475, "CTaskVehicleFollowRecording"}, + {476, "CTaskVehicleFollow"}, + {477, "CTaskVehicleBlock"}, + {478, "CTaskVehicleBlockCruiseInFront"}, + {479, "CTaskVehicleBlockBrakeInFront"}, + {478, "CTaskVehicleBlockBackAndForth"}, + {481, "CTaskVehicleCrash"}, + {482, "CTaskVehicleLand"}, + {483, "CTaskVehicleLandPlane"}, + {484, "CTaskVehicleHover"}, + {485, "CTaskVehicleAttack"}, + {486, "CTaskVehicleAttackTank"}, + {487, "CTaskVehicleCircle"}, + {488, "CTaskVehiclePoliceBehaviour"}, + {489, "CTaskVehiclePoliceBehaviourHelicopter"}, + {490, "CTaskVehiclePoliceBehaviourBoat"}, + {491, "CTaskVehicleEscort"}, + {492, "CTaskVehicleHeliProtect"}, + {494, "CTaskVehiclePlayerDriveAutomobile"}, + {495, "CTaskVehiclePlayerDriveBike"}, + {496, "CTaskVehiclePlayerDriveBoat"}, + {497, "CTaskVehiclePlayerDriveSubmarine"}, + {498, "CTaskVehiclePlayerDriveSubmarineCar"}, + {499, "CTaskVehiclePlayerDriveAmphibiousAutomobile"}, + {500, "CTaskVehiclePlayerDrivePlane"}, + {501, "CTaskVehiclePlayerDriveHeli"}, + {502, "CTaskVehiclePlayerDriveAutogyro"}, + {503, "CTaskVehiclePlayerDriveDiggerArm"}, + {504, "CTaskVehiclePlayerDriveTrain"}, + {505, "CTaskVehiclePlaneChase"}, + {506, "CTaskVehicleNoDriver"}, + {507, "CTaskVehicleAnimation"}, + {508, "CTaskVehicleConvertibleRoof"}, + {509, "CTaskVehicleParkNew"}, + {510, "CTaskVehicleFollowWaypointRecording"}, + {511, "CTaskVehicleGoToNavmesh"}, + {512, "CTaskVehicleReactToCopSiren"}, + {513, "CTaskVehicleGotoLongRange"}, + {514, "CTaskVehicleWait"}, + {515, "CTaskVehicleReverse"}, + {516, "CTaskVehicleBrake"}, + {517, "CTaskVehicleHandBrake"}, + {518, "CTaskVehicleTurn"}, + {519, "CTaskVehicleGoForward"}, + {520, "CTaskVehicleSwerve"}, + {521, "CTaskVehicleFlyDirection"}, + {522, "CTaskVehicleHeadonCollision"}, + {523, "CTaskVehicleBoostUseSteeringAngle"}, + {524, "CTaskVehicleShotTire"}, + {525, "CTaskVehicleBurnout"}, + {526, "CTaskVehicleRevEngine"}, + {527, "CTaskVehicleSurfaceInSubmarine"}, + {528, "CTaskVehiclePullAlongside"}, + {529, "CTaskVehicleTransformToSubmarine"}, + {530, "CTaskAnimatedFallback"}, + {531, "None"}, +}; \ No newline at end of file diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 5b420287..c745550b 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -620,7 +620,7 @@ namespace big bool voice_chat_audio = false; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(spoofing, hide_from_player_list, spoof_cheater, spoof_hide_god, spoof_hide_spectate, spoof_crew_data, crew_tag, rockstar_crew, square_crew_tag, spoof_session_region_type, session_region_type, spoof_session_language, session_language, spoof_session_player_count, session_player_count, voice_chat_audio, spoof_session_bad_sport_status, session_bad_sport) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(spoofing, hide_from_player_list, spoof_blip, blip_type, spoof_rank, rank, spoof_job_points, job_points, spoof_kd_ratio, kd_ratio, spoof_bad_sport, badsport_type, spoof_player_model, player_model, spoof_cheater, spoof_hide_god, spoof_hide_spectate, spoof_crew_data, crew_tag, rockstar_crew, square_crew_tag, spoof_session_region_type, session_region_type, spoof_session_language, session_language, spoof_session_player_count, session_player_count, spoof_session_bad_sport_status, session_bad_sport, voice_chat_audio) } spoofing{}; struct vehicle @@ -737,15 +737,15 @@ namespace big struct aimbot { - bool enable = false; - bool smoothing = true; - float smoothing_speed = 2.f; - bool on_player = true; - bool on_enemy = false; - bool on_police = false; - bool on_npc = false; - float fov = 90.f; - float distance = 200.f; + bool enable = false; + bool smoothing = true; + float smoothing_speed = 2.f; + bool on_player = true; + bool on_enemy = false; + bool on_police = false; + bool on_npc = false; + float fov = 90.f; + float distance = 200.f; uint32_t selected_bone = 0x796E; // Default to head NLOHMANN_DEFINE_TYPE_INTRUSIVE(aimbot, enable, smoothing, smoothing_speed, fov, distance, selected_bone) } aimbot{}; @@ -968,8 +968,6 @@ namespace big NLOHMANN_DEFINE_TYPE_INTRUSIVE(persist_weapons, enabled, weapon_loadout_file) } persist_weapons{}; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(menu_settings, debug, tunables, notifications, player, player_db, protections, self, session, settings, spawn_vehicle, clone_pv, spoofing, vehicle, weapons, window, context_menu, esp, session_browser, ugc, reactions, world, stat_editor, lua, persist_weapons) - struct vfx { bool enable_custom_sky_color = false; @@ -983,6 +981,8 @@ namespace big NLOHMANN_DEFINE_TYPE_INTRUSIVE(vfx, azimuth_east, azimuth_west, azimuth_transition, zenith, stars_intensity) } vfx{}; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(menu_settings, debug, tunables, notifications, player, player_db, protections, self, session, settings, spawn_vehicle, clone_pv, spoofing, vehicle, weapons, window, context_menu, esp, session_browser, ugc, reactions, world, stat_editor, lua, persist_weapons, vfx) }; inline auto g = menu_settings(); diff --git a/src/function_types.hpp b/src/function_types.hpp index e4ce6da0..4103d04b 100644 --- a/src/function_types.hpp +++ b/src/function_types.hpp @@ -12,7 +12,10 @@ enum eVehicleGadgetType : uint32_t; namespace rage { class netConnectionManager; - class netConnectionPeer; + class netPeerAddress; + class netConnection; + class netMessageQueue; + class netQueuedMessage; class snMsgRemoveGamersFromSessionCmd; class snSession; class snPlayer; @@ -117,8 +120,8 @@ namespace big::functions using request_ragdoll = void (*)(uint16_t object_id); using request_control = void (*)(rage::netObject* net_object); - using get_connection_peer = rage::netConnectionPeer* (*)(rage::netConnectionManager* manager, int peer_id); - using send_remove_gamer_cmd = void (*)(rage::netConnectionManager* net_connection_mgr, rage::netConnectionPeer* player, int connection_id, rage::snMsgRemoveGamersFromSessionCmd* cmd, int flags); + using get_peer_address = rage::netPeerAddress* (*)(rage::netConnectionManager* manager, int peer_id); + using send_remove_gamer_cmd = void (*)(rage::netConnectionManager* net_connection_mgr, rage::netPeerAddress* adde, int connection_id, rage::snMsgRemoveGamersFromSessionCmd* cmd, int flags); using handle_remove_gamer_cmd = void* (*)(rage::snSession* session, rage::snPlayer* origin, rage::snMsgRemoveGamersFromSessionCmd* cmd); using script_vm = rage::eThreadState (*)(uint64_t* stack, int64_t** scr_globals, rage::scrProgram* program, rage::scrThreadContext* ctx); @@ -131,8 +134,8 @@ namespace big::functions using set_as_active_cloud_file = void (*)(datafile_commands::SveFileObject* object, sCloudFile** file); using save_json_data = char* (*)(datafile_commands::SveFileObject* object, int* out_length, const char* reason); - using sync_network_time = bool (*)(rage::netConnectionManager* mgr, rage::netConnectionPeer* peer, int connection_id, rage::netTimeSyncMsg* msg, int flags); - using send_packet = bool (*)(rage::netConnectionManager* mgr, rage::netConnectionPeer* peer, int connection_id, void* data, int size, int flags); + using sync_network_time = bool (*)(rage::netConnectionManager* mgr, rage::netPeerAddress* addr, int connection_id, rage::netTimeSyncMsg* msg, int flags); + using send_packet = bool (*)(rage::netConnectionManager* mgr, rage::netPeerAddress* adde, int connection_id, void* data, int size, int flags); using connect_to_peer = bool (*)(rage::netConnectionManager* mgr, rage::rlGamerInfoBase* gamer_info, rage::snConnectToPeerTaskData* data, rage::snConnectToPeerTaskResult* result, rage::rlTaskStatus* status); using clear_ped_tasks_network = void (*)(CPed* ped, bool immediately); @@ -152,4 +155,8 @@ namespace big::functions using update_presence_attribute_int = void (*)(void* presence_data, int profile_index, char* attr, uint64_t value); using update_presence_attribute_string = void (*)(void* presence_data, int profile_index, char* attr, char* value); + + using connection_manager_try_free_memory = void (*)(rage::netConnectionManager* mgr); + using remove_message_from_queue = void (*)(rage::netMessageQueue* queue, rage::netQueuedMessage* message); + using remove_message_from_unacked_reliables = void (*)(void* list, uint16_t* unk); } diff --git a/src/gta/fidevice.hpp b/src/gta/fidevice.hpp index 9bbfcb06..0ea2fb15 100644 --- a/src/gta/fidevice.hpp +++ b/src/gta/fidevice.hpp @@ -1,7 +1,5 @@ #pragma once - #include "pointers.hpp" -#include "sysMemAllocator.hpp" #include diff --git a/src/gta/net_game_event.hpp b/src/gta/net_game_event.hpp index 0166dc01..d911f894 100644 --- a/src/gta/net_game_event.hpp +++ b/src/gta/net_game_event.hpp @@ -424,39 +424,6 @@ namespace rage Msg_0x86 = 0x86, }; - namespace netConnection - { - class InFrame - { - public: - enum class EventType - { - ConnectionClosed = 3, - FrameReceived = 4, - BandwidthExceeded = 6, - OutOfMemory = 7 - }; - - virtual ~InFrame() = default; - - virtual void destroy() = 0; - virtual EventType get_event_type() = 0; - virtual uint32_t _0x18() = 0; - - uint32_t m_timestamp; //0x0008 - char pad_0008[52]; //0x000C - uint32_t m_msg_id; //0x0040 - uint32_t m_connection_identifier; //0x0044 - InFrame* m_this; //0x0048 - uint32_t m_peer_id; //0x0050 - char pad_0050[44]; //0x0058 - uint32_t m_length; //0x0080 - char pad_007C[4]; //0x0084 - void* m_data; //0x0088 - }; - static_assert(sizeof(rage::netConnection::InFrame) == 0x90); - } - enum class eEventNetworkType : int64_t { CEventNetworkPlayerJoinScript = 153, @@ -645,14 +612,14 @@ namespace rage }; public: - uint16_t m_id; // 0x08 + uint16_t m_id; // 0x08 bool m_requires_reply; // 0x0A private: char m_padding1[0x05]; // 0x0B public: - netPlayer* m_source_player; // 0x10 - netPlayer* m_target_player; // 0x18 - uint32_t m_resend_time; // 0x20 + netPlayer* m_source_player; // 0x10 + netPlayer* m_target_player; // 0x18 + uint32_t m_resend_time; // 0x20 private: uint16_t m_0x24; // 0x24 uint8_t m_0x26; // 0x26 @@ -665,16 +632,16 @@ namespace rage class CScriptedGameEvent : public rage::netGameEvent { public: - char m_padding[0x40]; // 0x30 - std::int64_t m_args[54]; // 0x70 - uint32_t m_bitset; // 0x220 - uint32_t m_args_size; // 0x224 + char m_padding[0x40]; // 0x30 + std::int64_t m_args[54]; // 0x70 + uint32_t m_bitset; // 0x220 + uint32_t m_args_size; // 0x224 }; class CNetworkIncrementStatEvent : public rage::netGameEvent { public: - Hash m_stat; // 0x30 + Hash m_stat; // 0x30 uint32_t m_amount; // 0x34 }; #pragma pack(pop) diff --git a/src/gta/sysMemAllocator.hpp b/src/gta/sysMemAllocator.hpp deleted file mode 100644 index f67a5252..00000000 --- a/src/gta/sysMemAllocator.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "fwddec.hpp" - -#include \ No newline at end of file diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index 3c4a4586..1e766326 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -194,7 +194,7 @@ namespace big functions::request_control m_request_control; functions::clear_ped_tasks_network m_clear_ped_tasks_network; - functions::get_connection_peer m_get_connection_peer; + functions::get_peer_address m_get_peer_address; functions::send_remove_gamer_cmd m_send_remove_gamer_cmd; functions::handle_remove_gamer_cmd m_handle_remove_gamer_cmd; @@ -286,6 +286,18 @@ namespace big CBlipList* m_blip_list; PVOID m_timecycle_keyframe_override; + + PVOID m_allocate_memory_reliable; + functions::connection_manager_try_free_memory m_connection_manager_try_free_memory; + functions::remove_message_from_queue m_remove_message_from_queue; + functions::remove_message_from_unacked_reliables m_remove_message_from_unacked_reliables; + + PVOID m_free_event_error; + + PVOID* m_draw_handler_mgr; + PVOID m_render_ped; + PVOID m_render_entity; + PVOID m_render_big_ped; }; #pragma pack(pop) static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned"); diff --git a/src/hooking.cpp b/src/hooking.cpp index 387992c6..4c521f52 100644 --- a/src/hooking.cpp +++ b/src/hooking.cpp @@ -116,6 +116,12 @@ namespace big detour_hook_helper::add("UTCKD", g_pointers->m_gta.m_timecycle_keyframe_override); + detour_hook_helper::add("AMR", g_pointers->m_gta.m_allocate_memory_reliable); + + detour_hook_helper::add("RP", g_pointers->m_gta.m_render_ped); + detour_hook_helper::add("RE", g_pointers->m_gta.m_render_entity); + detour_hook_helper::add("RBP", g_pointers->m_gta.m_render_big_ped); + g_hooking = this; } diff --git a/src/hooking.hpp b/src/hooking.hpp index f4ada698..7d58ae46 100644 --- a/src/hooking.hpp +++ b/src/hooking.hpp @@ -7,6 +7,8 @@ #include "gta/script_thread.hpp" #include "vmt_hook.hpp" +#include + class CPlayerGamerDataNode; class CPlayerGameStateDataNode; class CPedInventoryDataNode; @@ -45,11 +47,6 @@ namespace rage class datBitBuffer; class rlMetric; class rlTaskStatus; - - namespace netConnection - { - class InFrame; - } } namespace big @@ -76,7 +73,6 @@ namespace big static void network_player_mgr_init(CNetworkPlayerMgr* _this, uint64_t a2, uint32_t a3, uint32_t a4[4]); static void network_player_mgr_shutdown(CNetworkPlayerMgr* _this); - static bool fragment_physics_crash(uintptr_t a1, uint32_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5); static bool fragment_physics_crash_2(float* a1, float* a2); static void received_event(rage::netEventMgr* event_manager, CNetGamePlayer* source_player, CNetGamePlayer* target_player, uint16_t event_id, int event_index, int event_handled_bitset, int unk, rage::datBitBuffer* bit_buffer); @@ -156,6 +152,12 @@ namespace big static void send_non_physical_player_data(CNetGamePlayer* player, __int64 message, int flags, void* a4, CNetGamePlayer* a5); static int64_t update_timecycle_keyframe_data(int64_t timecycleManager, TimecycleKeyframeData* timecycleKeyframeData); + + static void* allocate_memory_reliable(rage::netConnection* cxn, int required_memory); + + static void* render_ped(__int64 renderer, CPed* ped, __int64 a3, __int64 a4); + static void render_entity(__int64 renderer, rage::fwEntity* entity, int unk, bool a4); + static __int64 render_big_ped(__int64 renderer, CPed* ped, __int64 a3, __int64 a4); }; class minhook_keepalive diff --git a/src/hooks/misc/log_message_error_box.cpp b/src/hooks/misc/log_message_error_box.cpp index e00fb883..7fe7f697 100644 --- a/src/hooks/misc/log_message_error_box.cpp +++ b/src/hooks/misc/log_message_error_box.cpp @@ -1,7 +1,7 @@ #include "hooking.hpp" +#include "logger/stack_trace.hpp" #include "pointers.hpp" #include "util/string_conversions.hpp" -#include "logger/stack_trace.hpp" namespace big { @@ -31,10 +31,10 @@ namespace big void hooks::log_error_message_box(rage::joaat_t joaated_error_code, char a2) { - LOG(WARNING) << "Error Code: " << - string_conversions::utf_16_to_code_page( - CP_UTF8, - g_pointers->m_gta.m_get_title_caption_error_message_box(joaated_error_code)); + if (joaated_error_code == RAGE_JOAAT("ERR_NET_EVENT")) + return; + + LOG(WARNING) << "Error Code: " << string_conversions::utf_16_to_code_page(CP_UTF8, g_pointers->m_gta.m_get_title_caption_error_message_box(joaated_error_code)); log_stack_trace(); } diff --git a/src/hooks/player_management/assign_physical_index.cpp b/src/hooks/player_management/assign_physical_index.cpp index dd2d9bb0..c882619c 100644 --- a/src/hooks/player_management/assign_physical_index.cpp +++ b/src/hooks/player_management/assign_physical_index.cpp @@ -114,7 +114,7 @@ namespace big } } - if (plyr->block_join) + if (plyr->block_join && *g_pointers->m_gta.m_is_session_started) { if (g_player_service->get_self()->is_host()) { @@ -126,7 +126,7 @@ namespace big } } - if (g.session.lock_session && g_player_service->get_self()->is_host()) + if (g.session.lock_session && g_player_service->get_self()->is_host() && *g_pointers->m_gta.m_is_session_started) { if (plyr->is_friend() && g.session.allow_friends_into_locked_session) { diff --git a/src/hooks/protections/allocate_memory_reliable.cpp b/src/hooks/protections/allocate_memory_reliable.cpp new file mode 100644 index 00000000..56152e19 --- /dev/null +++ b/src/hooks/protections/allocate_memory_reliable.cpp @@ -0,0 +1,80 @@ +#include "gta/net_game_event.hpp" +#include "hooking.hpp" +#include "pointers.hpp" + +#include + +namespace big +{ + bool is_reliable_message(rage::netQueuedMessage* msg) + { + rage::datBitBuffer buffer(msg->m_data_buffer, INT_MAX); + buffer.m_flagBits |= 1; // read + buffer.Seek(10); // size + return buffer.ReadBits(1); // flags + } + + void free_message(rage::netQueuedMessage* msg, rage::sysMemAllocator* allocator) + { + if (msg->m_data_buffer) + allocator->TryFree(msg->m_data_buffer); + + allocator->TryFree(msg); + } + + void* hooks::allocate_memory_reliable(rage::netConnection* cxn, int required_memory) + { + if (!cxn || !required_memory) + return nullptr; + + auto memory = reinterpret_cast(cxn->m_allocator)->Allocate(required_memory, 0, 0); + + if (memory) + return memory; + + LOG(WARNING) << "Failed to allocate " << required_memory << " bytes for reliable message, free space: " + << reinterpret_cast(cxn->m_allocator)->GetMemoryAvailable() << ". Trying to free some memory"; + + g_pointers->m_gta.m_connection_manager_try_free_memory(cxn->m_net_connection_mgr); + + memory = reinterpret_cast(cxn->m_allocator)->Allocate(required_memory, 0, 0); + + if (memory) + return memory; + + LOG(WARNING) << "Failed to allocate " << required_memory << " bytes for reliable message, free space: " + << reinterpret_cast(cxn->m_allocator)->GetMemoryAvailable() << ". Failed to free some memory, clearing all messages (including reliables) for connection"; + + while (cxn->m_normal_message_queue.m_count) + { + auto msg = cxn->m_normal_message_queue.m_first; + + g_pointers->m_gta.m_remove_message_from_queue(&cxn->m_normal_message_queue, msg); + + if (is_reliable_message(msg)) + g_pointers->m_gta.m_remove_message_from_unacked_reliables(&cxn->m_unacked_reliable_message_list, &msg->word4C); + + free_message(msg, reinterpret_cast(cxn->m_allocator)); + } + + while (cxn->m_reliables_resend_queue.m_count) + { + auto msg = cxn->m_reliables_resend_queue.m_first; + + g_pointers->m_gta.m_remove_message_from_queue(&cxn->m_reliables_resend_queue, msg); + g_pointers->m_gta.m_remove_message_from_unacked_reliables(&cxn->m_unacked_reliable_message_list, + &msg->word4C); // messages in this queue are always reliables + free_message(msg, reinterpret_cast(cxn->m_allocator)); + } + + + memory = reinterpret_cast(cxn->m_allocator)->Allocate(required_memory, 0, 0); + + if (memory) + return memory; + + g_notification_service->push_error("Protections", "The network message allocator is out of memory"); // this never reaches here but why not + + return nullptr; + } +} \ No newline at end of file diff --git a/src/hooks/protections/receive_net_message.cpp b/src/hooks/protections/receive_net_message.cpp index d1611004..8f93b862 100644 --- a/src/hooks/protections/receive_net_message.cpp +++ b/src/hooks/protections/receive_net_message.cpp @@ -3,11 +3,11 @@ #include "backend/player_command.hpp" #include "core/data/packet_types.hpp" #include "gta/net_game_event.hpp" -#include "script/scriptIdBase.hpp" #include "gta_util.hpp" #include "hooking.hpp" #include "lua/lua_manager.hpp" #include "natives.hpp" +#include "script/scriptIdBase.hpp" #include "services/players/player_service.hpp" #include "util/session.hpp" #include "util/spam.hpp" @@ -229,6 +229,25 @@ namespace big break; } + case rage::eNetMessage::MsgRadioStationSyncRequest: + { + if (player->block_radio_requests) + return true; + + if (player->m_radio_request_rate_limit.process()) + { + if (player->m_radio_request_rate_limit.exceeded_last_process()) + { + session::add_infraction(player, Infraction::TRIED_KICK_PLAYER); + g_notification_service->push_error("PROTECTIONS"_T.data(), + std::vformat("OOM_KICK"_T, std::make_format_args(player->get_name()))); + player->block_radio_requests = true; + } + return true; + } + + break; + } } } else @@ -236,6 +255,7 @@ namespace big switch (msgType) { case rage::eNetMessage::MsgScriptMigrateHost: return true; + case rage::eNetMessage::MsgRadioStationSyncRequest: return true; } } diff --git a/src/hooks/protections/received_event.cpp b/src/hooks/protections/received_event.cpp index 69ad04b9..ee135c56 100644 --- a/src/hooks/protections/received_event.cpp +++ b/src/hooks/protections/received_event.cpp @@ -1,8 +1,8 @@ #include "fiber_pool.hpp" #include "gta/enums.hpp" #include "gta/net_game_event.hpp" -#include "script/scriptIdBase.hpp" #include "hooking.hpp" +#include "script/scriptIdBase.hpp" #include "util/math.hpp" #include "util/notify.hpp" #include "util/toxic.hpp" @@ -500,7 +500,7 @@ namespace big { int net_id = buffer->Read(13); if (g_local_player && g_local_player->m_vehicle && g_local_player->m_vehicle->m_net_object - && g_local_player->m_vehicle->m_net_object->m_object_id == net_id && g_local_player->m_vehicle->m_driver == g_local_player) + && g_local_player->m_vehicle->m_net_object->m_object_id == net_id && g_local_player->m_vehicle->m_driver == g_local_player && !NETWORK::NETWORK_IS_ACTIVITY_SESSION()) { g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); g.reactions.request_control_event.process(plyr); @@ -532,8 +532,6 @@ namespace big if (type == 0 || initial_length < min_length) // https://docs.fivem.net/natives/?_0xE832D760399EB220 { - // most definitely a crash - LOG(INFO) << std::hex << std::uppercase << "0x" << id.m_hash; notify::crash_blocked(source_player, "rope"); g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); return; diff --git a/src/hooks/protections/render_big_ped.cpp b/src/hooks/protections/render_big_ped.cpp new file mode 100644 index 00000000..20f58d3e --- /dev/null +++ b/src/hooks/protections/render_big_ped.cpp @@ -0,0 +1,18 @@ +#include "hooking.hpp" +#include "pointers.hpp" + +namespace big +{ + __int64 hooks::render_big_ped(__int64 renderer, CPed* ped, __int64 a3, __int64 a4) + { + if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 512) + { + *(int*)(a4 + 4) = -2; + return a4 + 0x14; + } + else + { + return g_hooking->get_original()(renderer, ped, a3, a4); + } + } +} \ No newline at end of file diff --git a/src/hooks/protections/render_entity.cpp b/src/hooks/protections/render_entity.cpp new file mode 100644 index 00000000..b2c06640 --- /dev/null +++ b/src/hooks/protections/render_entity.cpp @@ -0,0 +1,20 @@ +#include "hooking.hpp" +#include "pointers.hpp" + +namespace big +{ + void hooks::render_entity(__int64 renderer, rage::fwEntity* entity, int unk, bool a4) + { + if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 512) + { + *(int*)(renderer + 4) &= ~0x80000000; + *(int*)(renderer + 4) &= ~0x40000000; + *(int*)(renderer + 4) |= (a4 & 1) << 30; + *(int*)renderer = -2; + } + else + { + g_hooking->get_original()(renderer, entity, unk, a4); + } + } +} \ No newline at end of file diff --git a/src/hooks/protections/render_ped.cpp b/src/hooks/protections/render_ped.cpp new file mode 100644 index 00000000..b0b15be3 --- /dev/null +++ b/src/hooks/protections/render_ped.cpp @@ -0,0 +1,17 @@ +#include "hooking.hpp" +#include "pointers.hpp" + +namespace big +{ + void* hooks::render_ped(__int64 renderer, CPed* ped, __int64 a3, __int64 a4) + { + if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 499) + { + return nullptr; + } + else + { + return g_hooking->get_original()(renderer, ped, a3, a4); + } + } +} \ No newline at end of file diff --git a/src/hooks/protections/send_non_physical_player_data.cpp b/src/hooks/protections/send_non_physical_player_data.cpp index 534709c2..fd57ada4 100644 --- a/src/hooks/protections/send_non_physical_player_data.cpp +++ b/src/hooks/protections/send_non_physical_player_data.cpp @@ -1,4 +1,5 @@ #include "hooking.hpp" +#include "pointers.hpp" #include "services/players/player_service.hpp" #include @@ -12,7 +13,7 @@ namespace big auto data = *(CNonPhysicalPlayerData**)(message + 0x10); int old_bubble_id = data->m_bubble_id; - if (plyr && plyr->block_join) + if (plyr && plyr->block_join && *g_pointers->m_gta.m_is_session_started) { data->m_bubble_id = 10; g_notification_service->push("BLOCK_JOIN"_T.data(), std::vformat("BLOCK_JOIN_PREVENT_PLAYER_JOIN"_T, std::make_format_args(plyr->get_name()))); diff --git a/src/packet.cpp b/src/packet.cpp index a6308127..a7905ea1 100644 --- a/src/packet.cpp +++ b/src/packet.cpp @@ -15,12 +15,8 @@ namespace big void packet::send(uint32_t msg_id) { - g_pointers->m_gta.m_queue_packet(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, - msg_id, - m_data, - (m_buffer.m_curBit + 7) >> 3, - 1, - nullptr); + g_pointers->m_gta + .m_queue_packet(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, msg_id, m_data, (m_buffer.m_curBit + 7) >> 3, 1, nullptr); } void packet::send(player_ptr player, int connection_id) @@ -31,7 +27,7 @@ namespace big void packet::send(int peer_id, int connection_id) { auto mgr = gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr; - auto peer = g_pointers->m_gta.m_get_connection_peer(mgr, peer_id); + auto peer = g_pointers->m_gta.m_get_peer_address(mgr, peer_id); g_pointers->m_gta.m_send_packet(mgr, peer, connection_id, m_data, (m_buffer.m_curBit + 7) >> 3, 0x1000000); } } \ No newline at end of file diff --git a/src/pointers.cpp b/src/pointers.cpp index 8b4ab151..c9fd8a56 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -760,7 +760,7 @@ namespace big "8D 42 FF 83 F8 FD 77 3D", [](memory::handle ptr) { - g_pointers->m_gta.m_get_connection_peer = ptr.add(23).rip().as(); + g_pointers->m_gta.m_get_peer_address = ptr.add(23).rip().as(); g_pointers->m_gta.m_send_remove_gamer_cmd = ptr.add(65).rip().as(); } }, @@ -1226,6 +1226,62 @@ namespace big g_pointers->m_gta.m_presence_data = ptr.add(3).rip().as(); } }, + // Allocate Memory Reliable & Connection Manager Try Free Memory + { + "AMR&CMTFM", + "48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 83 EC 20 48 8B D9 48 8B 49 18", + [](memory::handle ptr) + { + g_pointers->m_gta.m_allocate_memory_reliable = ptr.as(); + g_pointers->m_gta.m_connection_manager_try_free_memory = ptr.add(0x52).rip().as(); + } + }, + // Remove Message From Queue & Remove Message From Unacked Reliables + { + "RMFQ&RMFUR", + "E8 ? ? ? ? 0F B7 43 4C 48 8D 55 20", + [](memory::handle ptr) + { + g_pointers->m_gta.m_remove_message_from_queue = ptr.add(1).rip().as(); + g_pointers->m_gta.m_remove_message_from_unacked_reliables = ptr.add(0x19).rip().as(); + } + }, + // Draw Handler Manager + { + "DHM", + "48 89 05 ? ? ? ? EB 07 48 89 1D ? ? ? ? 48 8B CB", + [](memory::handle ptr) + { + g_pointers->m_gta.m_draw_handler_mgr = ptr.add(3).rip().as(); + } + }, + // Render Ped + { + "RP", + "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 54 41 55 41 56 41 57 48 81 EC 80 00 00 00 48 8B FA", + [](memory::handle ptr) + { + g_pointers->m_gta.m_render_ped = ptr.as(); + } + }, + // Render Entity + { + "RE", + "48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 57 41 54 41 55 41 56 41 57 48 83 EC 70 0F BA", + [](memory::handle ptr) + { + g_pointers->m_gta.m_render_entity = ptr.as(); + } + }, + // Render Big Ped + { + "RE", + "48 89 5C 24 08 4C 89 44 24 18 55 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 81 EC 80 00 00 00 48", + [](memory::handle ptr) + { + g_pointers->m_gta.m_render_big_ped = ptr.as(); + } + }, // Max Wanted Level { "MWL", @@ -1409,6 +1465,15 @@ namespace big { g_pointers->m_gta.m_timecycle_keyframe_override = ptr.as(); } + }, + // Free Event Error + { + "FEE", + "48 8B 5C 24 40 48 8B 6C 24 48 48 8B 74 24 50 48 8B 7C 24 58 48 83 C4 30 41 5E C3 48 8B 0D", + [](memory::handle ptr) + { + g_pointers->m_gta.m_free_event_error = ptr.add(0x31).as(); + } } >(); // don't leave a trailing comma at the end diff --git a/src/services/creator_storage/creator_storage_service.cpp b/src/services/creator_storage/creator_storage_service.cpp index 57c3ebc5..1dab6040 100644 --- a/src/services/creator_storage/creator_storage_service.cpp +++ b/src/services/creator_storage/creator_storage_service.cpp @@ -1,11 +1,10 @@ #include "creator_storage_service.hpp" #include "gta/joaat.hpp" -#include "gta/sysMemAllocator.hpp" -#include "script/tlsContext.hpp" #include "natives.hpp" #include "pointers.hpp" #include "script.hpp" +#include "script/tlsContext.hpp" #include "script_function.hpp" namespace big diff --git a/src/services/players/player.cpp b/src/services/players/player.cpp index 18c0baed..3147d4b7 100644 --- a/src/services/players/player.cpp +++ b/src/services/players/player.cpp @@ -89,9 +89,9 @@ namespace big return get_net_data()->m_external_ip; if (auto session_player = get_session_player()) - if (auto peer = g_pointers->m_gta.m_get_connection_peer(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, + if (auto peer = g_pointers->m_gta.m_get_peer_address(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, (int)get_session_player()->m_player_data.m_peer_id_2)) - return netAddress{((netConnectionPeer*)peer)->m_external_ip}; + return netAddress{((rage::netPeerAddress*)peer)->m_external_ip}; return {0}; } @@ -102,9 +102,9 @@ namespace big return get_net_data()->m_external_port; if (auto session_player = get_session_player()) - if (auto peer = g_pointers->m_gta.m_get_connection_peer(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, + if (auto peer = g_pointers->m_gta.m_get_peer_address(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, (int)get_session_player()->m_player_data.m_peer_id_2)) - return ((netConnectionPeer*)peer)->m_external_port; + return ((rage::netPeerAddress*)peer)->m_external_port; return 0; } diff --git a/src/services/players/player.hpp b/src/services/players/player.hpp index 78a068bb..ffef0d10 100644 --- a/src/services/players/player.hpp +++ b/src/services/players/player.hpp @@ -68,6 +68,10 @@ namespace big rate_limiter m_host_migration_rate_limit{2s, 15}; rate_limiter m_play_sound_rate_limit{1s, 10}; rate_limiter m_invites_rate_limit{10s, 2}; + rate_limiter m_radio_request_rate_limit{5s, 2}; + + bool block_radio_requests = false; + int m_num_spawned_permanent_vehicles = 0; bool m_block_permanent_vehicles = false; diff --git a/src/util/spam.hpp b/src/util/spam.hpp index d5a1e38d..d9cb2633 100644 --- a/src/util/spam.hpp +++ b/src/util/spam.hpp @@ -55,6 +55,7 @@ namespace "cashlounge", "Fast Delivery", "yosativa", + "rich2day", }; } diff --git a/src/util/toxic.hpp b/src/util/toxic.hpp index 1595e11a..2ebe36c9 100644 --- a/src/util/toxic.hpp +++ b/src/util/toxic.hpp @@ -83,7 +83,7 @@ namespace big::toxic .count(); msg.increment = millis; - auto peer = g_pointers->m_gta.m_get_connection_peer(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, + auto peer = g_pointers->m_gta.m_get_peer_address(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, (int)target->get_session_player()->m_player_data.m_peer_id_2); for (int j = 0; j < 100; j++) @@ -149,7 +149,7 @@ namespace big::toxic .count(); msg.increment = millis; - auto peer = g_pointers->m_gta.m_get_connection_peer(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, + auto peer = g_pointers->m_gta.m_get_peer_address(gta_util::get_network()->m_game_session_ptr->m_net_connection_mgr, (int)plyr.second->get_session_player()->m_player_data.m_peer_id_2); for (int j = 0; j < 25; j++) diff --git a/src/views/players/player/player_info.cpp b/src/views/players/player/player_info.cpp index 0c555d1e..9878befc 100644 --- a/src/views/players/player/player_info.cpp +++ b/src/views/players/player/player_info.cpp @@ -72,6 +72,7 @@ namespace big ImGui::Checkbox("Block Clone Creates", &g_player_service->get_selected()->block_clone_create); ImGui::Checkbox("Block Clone Syncs", &g_player_service->get_selected()->block_clone_sync); ImGui::Checkbox("Block Network Events", &g_player_service->get_selected()->block_net_events); + ImGui::Checkbox("Log Clones", &g_player_service->get_selected()->log_clones); ImGui::Separator();