diff --git a/BigBaseV2/src/backend/backend.cpp b/BigBaseV2/src/backend/backend.cpp index ef7c0a1d..c5093e5a 100644 --- a/BigBaseV2/src/backend/backend.cpp +++ b/BigBaseV2/src/backend/backend.cpp @@ -9,16 +9,19 @@ namespace big { void backend::loop() { - g->attempt_save(); - looped::system_self_globals(); - looped::system_update_pointers(); + while (true) { + g->attempt_save(); + looped::system_self_globals(); + looped::system_update_pointers(); - if (g_local_player != nullptr && !api::util::signed_in()) - { - g_thread_pool->push([] + if (g_local_player != nullptr && !api::util::signed_in()) { - looped::api_login_session(); - }); + g_thread_pool->push([] + { + looped::api_login_session(); + }); + } + script::get_current()->yield(); } } diff --git a/BigBaseV2/src/common.cpp b/BigBaseV2/src/common.cpp index 7a1adb1e..7691e9d7 100644 --- a/BigBaseV2/src/common.cpp +++ b/BigBaseV2/src/common.cpp @@ -1 +1 @@ -#include "common.hpp" +#include "common.hpp" \ No newline at end of file diff --git a/BigBaseV2/src/common.hpp b/BigBaseV2/src/common.hpp index de615e66..ad9d0f54 100644 --- a/BigBaseV2/src/common.hpp +++ b/BigBaseV2/src/common.hpp @@ -45,6 +45,7 @@ #include #include +#define FMT_HEADER_ONLY #include #include diff --git a/BigBaseV2/src/detour_hook.cpp b/BigBaseV2/src/detour_hook.cpp index 993a2dbb..3ea73d08 100644 --- a/BigBaseV2/src/detour_hook.cpp +++ b/BigBaseV2/src/detour_hook.cpp @@ -19,7 +19,7 @@ namespace big } else { - throw std::runtime_error(fmt::format("Failed to create hook '{}' at 0x{:X} (error: {})", m_name, reinterpret_cast(m_target), MH_StatusToString(status))); + throw std::runtime_error(fmt::format("Failed to create hook '{}' at 0x{:X} (error: {})", m_name, uintptr_t(m_target), MH_StatusToString(status))); } } @@ -41,7 +41,7 @@ namespace big } else { - throw std::runtime_error(fmt::format("Failed to enable hook 0x{:X} ({})", reinterpret_cast(m_target), MH_StatusToString(status))); + throw std::runtime_error(fmt::format("Failed to enable hook 0x{:X} ({})", uintptr_t(m_target), MH_StatusToString(status))); } } @@ -66,20 +66,14 @@ namespace big void detour_hook::fix_hook_address() { - __try - { + __try { auto ptr = memory::handle(m_target); while (ptr.as() == 0xE9) - { ptr = ptr.add(1).rip(); - } - m_target = ptr.as(); } - __except (exp_handler(GetExceptionInformation(), m_name)) - { - [this]() - { + __except (exp_handler(GetExceptionInformation(), m_name)) { + [this]() { throw std::runtime_error(fmt::format("Failed to fix hook address for '{}'", m_name)); }(); } diff --git a/BigBaseV2/src/features.cpp b/BigBaseV2/src/features.cpp deleted file mode 100644 index c18b35c5..00000000 --- a/BigBaseV2/src/features.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "common.hpp" -#include "features.hpp" -#include "logger.hpp" -#include "script.hpp" - -#include "backend/backend.hpp" - -namespace big -{ - void features::run_tick() - { - backend::loop(); - } - - void features::script_func() - { - while (true) - { - TRY_CLAUSE - { - run_tick(); - } - EXCEPT_CLAUSE - script::get_current()->yield(); - } - } -} diff --git a/BigBaseV2/src/features.hpp b/BigBaseV2/src/features.hpp deleted file mode 100644 index ca20046b..00000000 --- a/BigBaseV2/src/features.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "common.hpp" - -namespace big::features -{ - void run_tick(); - void script_func(); -} diff --git a/BigBaseV2/src/function_types.hpp b/BigBaseV2/src/function_types.hpp index 1fbc0ae5..13c04fcb 100644 --- a/BigBaseV2/src/function_types.hpp +++ b/BigBaseV2/src/function_types.hpp @@ -7,37 +7,48 @@ namespace big::functions { - using run_script_threads_t = bool(*)(std::uint32_t ops_to_execute); - using get_native_handler_t = rage::scrNativeHandler(*)(rage::scrNativeRegistrationTable*, rage::scrNativeHash); - using fix_vectors_t = void(*)(rage::scrNativeCallContext*); + using run_script_threads = bool(*)(std::uint32_t ops_to_execute); + using get_native_handler = rage::scrNativeHandler(*)(rage::scrNativeRegistrationTable* registration_table, rage::scrNativeHash hash); + using fix_vectors = void(*)(rage::scrNativeCallContext* call_ctx); - using get_net_game_player = CNetGamePlayer*(Player player); + using get_net_game_player = CNetGamePlayer*(*)(Player player); - using trigger_script_event = void(int event_group, int64_t* args, int arg_count, int player_bits); + using trigger_script_event = void(*)(int event_group, int64_t* args, int arg_count, int player_bits); - using increment_stat_event = bool(uint64_t net_event_struct, int64_t sender, int64_t a3); + using increment_stat_event = bool(*)(uint64_t net_event_struct, int64_t sender, int64_t a3); - using ptr_to_handle = Entity(void* entity); + using ptr_to_handle = Entity(*)(void* entity); - using get_screen_coords_for_world_coords = bool(float* world_coords, float* out_x, float* out_y); + using get_gameplay_cam_coords = Vector3(*)(); - using get_gameplay_cam_coords = Vector3(); + using get_screen_coords_for_world_coords = bool(*)(float* world_coords, float* out_x, float* out_y); - using give_pickup_rewards = void(int players, uint32_t hash); + using give_pickup_rewards = void(*)(int players, uint32_t hash); + // Bitbuffer read/write START + using read_bitbuf_dword = bool(*)(rage::datBitBuffer* buffer, PVOID read, int bits); + using read_bitbuf_string = bool(*)(rage::datBitBuffer* buffer, char* read, int bits); + using read_bitbuf_bool = bool(*)(rage::datBitBuffer* buffer, bool* read, int bits); + using read_bitbuf_array = bool(*)(rage::datBitBuffer* buffer, PVOID read, int bits, int unk); + using write_bitbuf_qword = bool(*)(rage::datBitBuffer* buffer, uint64_t val, int bits); + using write_bitbuf_dword = bool(*)(rage::datBitBuffer* buffer, uint32_t val, int bits); + using write_bitbuf_int64 = bool(*)(rage::datBitBuffer* buffer, int64_t val, int bits); + using write_bitbuf_int32 = bool(*)(rage::datBitBuffer* buffer, int32_t val, int bits); + using write_bitbuf_bool = bool(*)(rage::datBitBuffer* buffer, bool val, int bits); + using write_bitbuf_array = bool(*)(rage::datBitBuffer* buffer, uint8_t* val, int bits, int unk); + + // Bitbuffer read/write END // Received Event Signatures START - using read_bitbuf_array = bool(rage::datBitBuffer* buffer, PVOID read, int bits, int); - using read_bitbuf_dword = bool(rage::datBitBuffer* buffer, PVOID read, int bits); - using send_event_ack = void(rage::netEventMgr* event_manager, CNetGamePlayer* source_player, CNetGamePlayer* target_player, int event_index, int event_handled_bitset); + using send_event_ack = void(*)(rage::netEventMgr* event_manager, CNetGamePlayer* source_player, CNetGamePlayer* target_player, int event_index, int event_handled_bitset); // Received Event Signatures END //Sync signatures START - using get_sync_type_info = const char* (uint16_t sync_type, char a2); + using get_sync_type_info = const char*(*)(uint16_t sync_type, char a2); - using get_sync_tree_for_type = __int64(CNetworkObjectMgr* mgr, uint16_t sync_type); + using get_sync_tree_for_type = int64_t(*)(CNetworkObjectMgr* mgr, uint16_t sync_type); - using get_net_object = rage::netObject* (__fastcall)(CNetworkObjectMgr* mgr, int16_t id, bool unk3); + using get_net_object = rage::netObject*(*)(CNetworkObjectMgr* mgr, int16_t id, bool unk3); - using get_net_object_for_player = rage::netObject* (__fastcall) (CNetworkObjectMgr*, int16_t, CNetGamePlayer*, bool); + using get_net_object_for_player = rage::netObject*(*)(CNetworkObjectMgr*, int16_t, CNetGamePlayer*, bool); //Sync signatures END -} +} \ No newline at end of file diff --git a/BigBaseV2/src/gta/enums.hpp b/BigBaseV2/src/gta/enums.hpp index d4646828..7990a85e 100644 --- a/BigBaseV2/src/gta/enums.hpp +++ b/BigBaseV2/src/gta/enums.hpp @@ -726,96 +726,96 @@ enum class NetObjEntityType : uint16_t NetObjEntityType_Max }; -enum class RockstarEvent : uint16_t +enum class eNetworkEvents : uint16_t { - OBJECT_ID_FREED_EVENT, - OBJECT_ID_REQUEST_EVENT, - ARRAY_DATA_VERIFY_EVENT, - SCRIPT_ARRAY_DATA_VERIFY_EVENT, - REQUEST_CONTROL_EVENT, - GIVE_CONTROL_EVENT, - WEAPON_DAMAGE_EVENT, - REQUEST_PICKUP_EVENT, - REQUEST_MAP_PICKUP_EVENT, - GAME_CLOCK_EVENT, - GAME_WEATHER_EVENT, - RESPAWN_PLAYER_PED_EVENT, - GIVE_WEAPON_EVENT, - REMOVE_WEAPON_EVENT, - REMOVE_ALL_WEAPONS_EVENT, - VEHICLE_COMPONENT_CONTROL_EVENT, - FIRE_EVENT, - EXPLOSION_EVENT, - START_PROJECTILE_EVENT, - UPDATE_PROJECTILE_TARGET_EVENT, - REMOVE_PROJECTILE_ENTITY_EVENT, - BREAK_PROJECTILE_TARGET_LOCK_EVENT, - ALTER_WANTED_LEVEL_EVENT, - CHANGE_RADIO_STATION_EVENT, - RAGDOLL_REQUEST_EVENT, - PLAYER_TAUNT_EVENT, - PLAYER_CARD_STAT_EVENT, - DOOR_BREAK_EVENT, - SCRIPTED_GAME_EVENT, - REMOTE_SCRIPT_INFO_EVENT, - REMOTE_SCRIPT_LEAVE_EVENT, - MARK_AS_NO_LONGER_NEEDED_EVENT, - CONVERT_TO_SCRIPT_ENTITY_EVENT, - SCRIPT_WORLD_STATE_EVENT, - CLEAR_AREA_EVENT, - CLEAR_RECTANGLE_AREA_EVENT, - NETWORK_REQUEST_SYNCED_SCENE_EVENT, - NETWORK_START_SYNCED_SCENE_EVENT, - NETWORK_STOP_SYNCED_SCENE_EVENT, - NETWORK_UPDATE_SYNCED_SCENE_EVENT, - INCIDENT_ENTITY_EVENT, - GIVE_PED_SCRIPTED_TASK_EVENT, - GIVE_PED_SEQUENCE_TASK_EVENT, - NETWORK_CLEAR_PED_TASKS_EVENT, - NETWORK_START_PED_ARREST_EVENT, - NETWORK_START_PED_UNCUFF_EVENT, - NETWORK_SOUND_CAR_HORN_EVENT, - NETWORK_ENTITY_AREA_STATUS_EVENT, - NETWORK_GARAGE_OCCUPIED_STATUS_EVENT, - PED_CONVERSATION_LINE_EVENT, - SCRIPT_ENTITY_STATE_CHANGE_EVENT, - NETWORK_PLAY_SOUND_EVENT, - NETWORK_STOP_SOUND_EVENT, - NETWORK_PLAY_AIRDEFENSE_FIRE_EVENT, - NETWORK_BANK_REQUEST_EVENT, - NETWORK_AUDIO_BARK_EVENT, - REQUEST_DOOR_EVENT, - NETWORK_TRAIN_REPORT_EVENT, - NETWORK_TRAIN_REQUEST_EVENT, - NETWORK_INCREMENT_STAT_EVENT, - MODIFY_VEHICLE_LOCK_WORD_STATE_DATA, - MODIFY_PTFX_WORD_STATE_DATA_SCRIPTED_EVOLVE_EVENT, - REQUEST_PHONE_EXPLOSION_EVENT, - REQUEST_DETACHMENT_EVENT, - KICK_VOTES_EVENT, - GIVE_PICKUP_REWARDS_EVENT, - NETWORK_CRC_HASH_CHECK_EVENT, - BLOW_UP_VEHICLE_EVENT, - NETWORK_SPECIAL_FIRE_EQUIPPED_WEAPON, - NETWORK_RESPONDED_TO_THREAT_EVENT, - NETWORK_SHOUT_TARGET_POSITION, - VOICE_DRIVEN_MOUTH_MOVEMENT_FINISHED_EVENT, - PICKUP_DESTROYED_EVENT, - UPDATE_PLAYER_SCARS_EVENT, - NETWORK_CHECK_EXE_SIZE_EVENT, - NETWORK_PTFX_EVENT, - NETWORK_PED_SEEN_DEAD_PED_EVENT, - REMOVE_STICKY_BOMB_EVENT, - NETWORK_CHECK_CODE_CRCS_EVENT, - INFORM_SILENCED_GUNSHOT_EVENT, - PED_PLAY_PAIN_EVENT, - CACHE_PLAYER_HEAD_BLEND_DATA_EVENT, - REMOVE_PED_FROM_PEDGROUP_EVENT, - REPORT_MYSELF_EVENT, - REPORT_CASH_SPAWN_EVENT, - ACTIVATE_VEHICLE_SPECIAL_ABILITY_EVENT, - BLOCK_WEAPON_SELECTION, - NETWORK_CHECK_CATALOG_CRC + CObjectIdFreedEvent, + CObjectIdRequestEvent, + CArrayDataVerifyEvent, + CScriptArrayDataVerifyEvent, + CRequestControlEvent, + CGiveControlEvent, + CWeaponDamageEvent, + CRequestPickupEvent, + CRequestMapPickupEvent, + CGameClockEvent, + CGameWeatherEvent, + CRespawnPlayerPedEvent, + CGiveWeaponEvent, + CRemoveWeaponEvent, + CRemoveAllWeaponsEvent, + CVehicleComponentControlEvent, + CFireEvent, + CExplosionEvent, + CStartProjectileEvent, + CUpdateProjectileTargetEvent, + CRemoveProjectileEntityEvent, + CBreakProjectileTargetLockEvent, + CAlterWantedLevelEvent, + CChangeRadioStationEvent, + CRagdollRequestEvent, + CPlayerTauntEvent, + CPlayerCardStatEvent, + CDoorBreakEvent, + CScriptedGameEvent, + CRemoteScriptInfoEvent, + CRemoteScriptLeaveEvent, + CMarkAsNoLongerNeededEvent, + CConvertToScriptEntityEvent, + CScriptWorldStateEvent, + CClearAreaEvent, + CClearRectangleAreaEvent, + CNetworkRequestSyncedSceneEvent, + CNetworkStartSyncedSceneEvent, + CNetworkStopSyncedSceneEvent, + CNetworkUpdateSyncedSceneEvent, + CIncidentEntityEvent, + CGivePedScriptedTaskEvent, + CGivePedSequenceTaskEvent, + CNetworkClearPedTasksEvent, + CNetworkStartPedArrestEvent, + CNetworkStartPedUncuffEvent, + CNetworkSoundCarHornEvent, + CNetworkEntityAreaStatusEvent, + CNetworkGarageOccupiedStatusEvent, + CPedConversationLineEvent, + CScriptEntityStateChangeEvent, + CNetworkPlaySoundEvent, + CNetworkStopSoundEvent, + CNetworkPlayAirdefenseFireEvent, + CNetworkBankRequestEvent, + CNetworkAudioBarkEvent, + CRequestDoorEvent, + CNetworkTrainReportEvent, + CNetworkTrainRequestEvent, + CNetworkIncrementStatEvent, + CModifyVehicleLockWordStateData, + CModifyPtfxWordStateDataScriptedEvolveEvent, + CRequestPhoneExplosionEvent, + CRequestDetachmentEvent, + CKickVotesEvent, + CGivePickupRewardsEvent, + CNetworkCrcHashCheckEvent, + CBlowUpVehicleEvent, + CNetworkSpecialFireEquippedWeapon, + CNetworkRespondedToThreatEvent, + CNetworkShoutTargetPosition, + CVoiceDrivenMouthMovementFinishedEvent, + CPickupDestroyedEvent, + CUpdatePlayerScarsEvent, + CNetworkCheckExeSizeEvent, + CNetworkPtfxEvent, + CNetworkPedSeenDeadPedEvent, + CRemoveStickyBombEvent, + CNetworkCheckCodeCrcsEvent, + CInformSilencedGunshotEvent, + CPedPlayPainEvent, + CCachePlayerHeadBlendDataEvent, + CRemovePedFromPedgroupEvent, + CUpdateFxnEvent, + CReportCashSpawnEvent, + CActivateVehicleSpecialAbilityEvent, + CBlockWeaponSelection, + CNetworkCheckCatalogCrc }; enum class BlipIcons diff --git a/BigBaseV2/src/gta/natives.hpp b/BigBaseV2/src/gta/natives.hpp index ceccf73f..0e4ae3a1 100644 --- a/BigBaseV2/src/gta/natives.hpp +++ b/BigBaseV2/src/gta/natives.hpp @@ -54,12 +54,45 @@ namespace rage std::int32_t m_data_count; std::uint32_t m_data[48]; }; - + static_assert(sizeof(scrNativeCallContext) == 0xE0); using scrNativeHash = std::uint64_t; using scrNativeMapping = std::pair; using scrNativeHandler = void(*)(scrNativeCallContext*); - class scrNativeRegistration; + class scrNativeRegistration { + public: + uint64_t m_nextRegistration1; + uint64_t m_nextRegistration2; + void* m_handlers[7]; + uint32_t m_numEntries1; + uint32_t m_numEntries2; + uint64_t m_hashes; + scrNativeRegistration* get_next_registration() { + std::uintptr_t result; + auto nextReg = uintptr_t(&m_nextRegistration1); + auto newReg = nextReg ^ m_nextRegistration2; + auto charTableOfRegs = (char*)&result - nextReg; + for (auto i = 0; i < 3; i++) { + *(DWORD*)&charTableOfRegs[nextReg] = static_cast(newReg) ^ *(DWORD*)nextReg; + nextReg += 4; + } + return reinterpret_cast(result); + } + std::uint32_t get_num_entries() { + return static_cast(((std::uintptr_t)&m_numEntries1) ^ m_numEntries1 ^ m_numEntries2); + } + std::uint64_t get_hash(std::uint32_t index) { + auto nativeAddress = 16 * index + std::uintptr_t(&m_nextRegistration1) + 0x54; + std::uint64_t result; + auto charTableOfRegs = (char*)&result - nativeAddress; + auto addressIndex = nativeAddress ^ *(DWORD*)(nativeAddress + 8); + for (auto i = 0; i < 3; i++) { + *(DWORD*)&charTableOfRegs[nativeAddress] = static_cast(addressIndex ^ *(DWORD*)(nativeAddress)); + nativeAddress += 4; + } + return result; + } + }; #pragma pack(push, 1) class scrNativeRegistrationTable @@ -69,8 +102,6 @@ namespace rage bool m_initialized; }; #pragma pack(pop) - - static_assert(sizeof(scrNativeCallContext) == 0xE0); } using Void = void; diff --git a/BigBaseV2/src/gta/net_game_event.hpp b/BigBaseV2/src/gta/net_game_event.hpp index 45ebc86e..0cf27f07 100644 --- a/BigBaseV2/src/gta/net_game_event.hpp +++ b/BigBaseV2/src/gta/net_game_event.hpp @@ -7,139 +7,266 @@ namespace rage { class netPlayer; + class datBitBuffer { public: - inline datBitBuffer(void* data, uint32_t size) - { + datBitBuffer(uint8_t* data, uint32_t size) { m_data = data; - m_f8 = 0; + m_bitOffset = 0; m_maxBit = size * 8; m_bitsRead = 0; m_curBit = 0; - m_unk2Bit = 0; + m_highestBitsRead = 0; m_flagBits = 0; } - - inline uint32_t GetPosition() - { + uint32_t GetPosition() { return m_bitsRead; } - - inline bool Seek(uint32_t bits) - { - if (bits >= 0) - { + bool Seek(uint32_t bits) { + if (bits >= 0) { uint32_t length = (m_flagBits & 1) ? m_maxBit : m_curBit; - if (bits <= length) - { m_bitsRead = bits; - } } - return false; } - - inline int GetDataLength() - { + bool WriteBool(bool integer) { + return big::g_pointers->m_write_bitbuf_bool(this, integer, 1); + } + bool ReadBool(bool* integer) { + return big::g_pointers->m_read_bitbuf_bool(this, integer, 1); + } + bool ReadPeerId(uint64_t* integer) { + return this->ReadQWord(integer, 0x32); + } + uint64_t ReadBits(size_t numBits) { + auto const totalBits = (m_flagBits & 1) ? m_maxBit : m_curBit; + if ((m_flagBits & 2) || m_bitsRead + numBits > totalBits) + return 0; + auto const bufPos = m_bitsRead + m_bitOffset; + auto const initialBitOffset = bufPos & 0b111; + auto const start = &m_data[bufPos / 8]; + auto const next = &start[1]; + auto result = (start[0] << initialBitOffset) & 0xff; + for (auto i = 0; i < ((numBits - 1) / 8); i++) { + result <<= 8; + result |= next[i] << initialBitOffset; + } + if (initialBitOffset) + result |= next[0] >> (8 - initialBitOffset); + m_bitsRead += static_cast(numBits); + if (m_bitsRead > m_highestBitsRead) + m_highestBitsRead = m_bitsRead; + return result >> ((8 - numBits) % 8); + } + int GetDataLength() { int leftoverBit = (m_curBit % 8) ? 1 : 0; - return (m_curBit / 8) + leftoverBit; } - - inline bool ReadByte(uint8_t* integer, int bits) - { + bool ReadString(char* string, int bits) { + return big::g_pointers->m_read_bitbuf_string(this, string, bits); + } + bool WriteByte(uint8_t integer, int bits) { + return big::g_pointers->m_write_bitbuf_dword(this, integer, bits); + } + bool ReadByte(uint8_t* integer, int bits) { uint32_t read; - if (big::g_pointers->m_read_bitbuf_dword(this, &read, bits)) - { + if (big::g_pointers->m_read_bitbuf_dword(this, &read, bits)) { *integer = read; return true; } return false; } - - inline bool ReadWord(uint16_t* integer, int bits) - { + bool WriteWord(uint16_t integer, int bits) { + return big::g_pointers->m_write_bitbuf_dword(this, integer, bits); + } + bool ReadWord(uint16_t* integer, int bits) { uint32_t read; - if (big::g_pointers->m_read_bitbuf_dword(this, &read, bits)) - { + if (big::g_pointers->m_read_bitbuf_dword(this, &read, bits)) { *integer = read; return true; } return false; } - - inline bool ReadDword(uint32_t* integer, int bits) - { + bool WriteDword(uint32_t integer, int bits) { + return big::g_pointers->m_write_bitbuf_dword(this, integer, bits); + } + bool ReadDword(uint32_t* integer, int bits) { return big::g_pointers->m_read_bitbuf_dword(this, integer, bits); } - - inline bool ReadInt32(int32_t* integer, int bits) - { + bool WriteInt32(int32_t integer, int bits) { + return big::g_pointers->m_write_bitbuf_int32(this, integer, bits); + } + bool ReadInt32(int32_t* integer, int bits) { int32_t v8; int32_t v9; - if (ReadDword((uint32_t*)&v8, 1u) && ReadDword((uint32_t*)&v9, bits - 1)) - { + if (ReadDword((uint32_t*)&v8, 1u) && ReadDword((uint32_t*)&v9, bits - 1)) { *integer = v8 + (v9 ^ -v8); return true; } return false; } - - inline bool ReadQWord(uint64_t* integer, int bits) - { - if (bits <= 32) - { - uint32_t v10{}; - if (ReadDword(&v10, bits)) - { + bool WriteQWord(uint64_t integer, int bits) { + return big::g_pointers->m_write_bitbuf_qword(this, integer, bits); + } + bool ReadQWord(uint64_t* integer, int bits) { + if (bits <= 32) { + uint32_t v10; + if (ReadDword(&v10, bits)) { *integer = v10; return true; } - return false; } - else - { - uint32_t v10{}, v11{}; - if (ReadDword(&v11, 32u) && ReadDword(&v10, bits - 32u)) - { + else { + uint32_t v10, v11; + if (ReadDword(&v11, 32u) && ReadDword(&v10, bits - 32u)) { *integer = v11 | ((uint64_t)v10 << 32); return true; } - return false; } + return false; } - - inline bool ReadInt64(int64_t* integer, int bits) - { + bool WriteInt64(int64_t integer, int bits) { + return big::g_pointers->m_write_bitbuf_int64(this, integer, bits); + } + bool ReadInt64(int64_t* integer, int bits) { uint32_t v8; uint64_t v9; - if (ReadDword(&v8, 1u) && ReadQWord(&v9, bits - 1)) - { + if (ReadDword(&v8, 1u) && ReadQWord(&v9, bits - 1)) { *integer = v8 + (v9 ^ -(int64_t)v8); return true; } return false; } - - inline bool ReadArray(PVOID array, int size) - { + bool WriteArray(uint8_t* array, int size) { + return big::g_pointers->m_write_bitbuf_array(this, array, size, 0); + } + bool ReadArray(PVOID array, int size) { return big::g_pointers->m_read_bitbuf_array(this, array, size, 0); } - public: - void* m_data; //0x0000 - uint32_t m_f8; //0x0008 + uint8_t* m_data; //0x0000 + uint32_t m_bitOffset; //0x0008 uint32_t m_maxBit; //0x000C uint32_t m_bitsRead; //0x0010 uint32_t m_curBit; //0x0014 - uint32_t m_unk2Bit; //0x0018 + uint32_t m_highestBitsRead; //0x0018 uint8_t m_flagBits; //0x001C - char pad_0x01D[3]; - uint32_t m_f20; }; + enum class eNetMessage : uint32_t { + CMsgInvalid = 0xFFFFF, + CMsgSessionAcceptChat = 0x62, + CMsgStartMatchCmd = 0x2D, + CMsgSetInvitableCmd = 0x1F, + CMsgSessionMemberIds = 0x23, + CMsgRequestGamerInfo = 0x54, + CMsgRemoveGamersFromSessionCmd = 0x53, + CMsgNotMigrating = 0x35, + CMsgMigrateHostResponse = 0x12, + CMsgMigrateHostRequest = 0x66, + CMsgJoinResponse = 0x2A, + CMsgJoinRequest = 0x41, + CMsgHostLeftWhilstJoiningCmd = 0x58, + CMsgConfigResponse = 0x5F, + CMsgConfigRequest = 0x48, + CMsgChangeSessionAttributesCmd = 0x5A, + CMsgAddGamerToSessionCmd = 0x64, // this is where send net info to lobby is called, among other things + CMsgReassignResponse = 0x10, + CMsgReassignNegotiate = 0x01, + CMsgReassignConfirm = 0x26, + CMsgPlayerData = 0x18, + CMsgPackedReliables = 0x30, + CMsgPackedCloneSyncACKs = 0x3B, + CMsgNonPhysicalData = 0x16, + CMsgNetArrayMgrUpdateAck = 0x5D, + CMsgNetArrayMgrUpdate = 0x60, + CMsgNetArrayMgrSplitUpdateAck = 0x25, + CMsgScriptVerifyHostAck = 0x0B, + CMsgScriptVerifyHost = 0x3E, + CMsgScriptNewHost = 0x0E, + CMsgScriptMigrateHostFailAck = 0x1A, + CMsgScriptMigrateHost = 0x33, + CMsgScriptLeaveAck = 0x40, + CMsgScriptLeave = 0x17, + CMsgScriptJoinHostAck = 0x4D, + CMsgScriptJoinAck = 0x43, + CMsgScriptJoin = 0x5C, + CMsgScriptHostRequest = 0x67, + CMsgScriptHandshakeAck = 0x5B, + CMsgScriptHandshake = 0x57, + CMsgScriptBotLeave = 0x2B, // unused? + CMsgScriptBotJoinAck = 0x63, // unused? + CMsgScriptBotJoin = 0x1C, // unused? + CMsgScriptBotHandshakeAck = 0x31, // unused? + CMsgScriptBotHandshake = 0x4B, // unused? + CMsgPartyLeaveGame = 0x3D, + CMsgPartyEnterGame = 0x1E, + CMsgCloneSync = 0x4E, // aka clone_create, clone_sync etc. + CMsgActivateNetworkBot = 0x65, // unused? + CMsgRequestObjectIds = 0x29, + CMsgInformObjectIds = 0x09, + CMsgTextMessage = 0x24, // this one is for chat + CMsgPlayerIsTyping = 0x61, + CMsgPackedEvents = 0x4F, // aka received_event + CMsgPackedEventReliablesCMsgs = 0x20, + CMsgRequestKickFromHost = 0x0D, + CMsgTransitionToGameStart = 0x50, + CMsgTransitionToGameNotify = 0x02, + CMsgTransitionToActivityStart = 0x06, + CMsgTransitionToActivityFinish = 0x36, + CMsgTransitionParameters = 0x3C, + CMsgTransitionParameterString = 0x37, + CMsgTransitionLaunchNotify = 0x1B, + CMsgTransitionLaunch = 0x19, + CMsgTransitionGamerInstruction = 0x14, + CMsgTextMessage2 = 0x0A, // this one is for phone message + CMsgSessionEstablishedRequest = 0x52, + CMsgSessionEstablished = 0x07, + CMsgRequestTransitionParameters = 0x42, + CMsgRadioStationSyncRequest = 0x47, + CMsgRadioStationSync = 0x46, + CMsgPlayerCardSync = 0x3A, + CMsgPlayerCardRequest = 0x6A, + CMsgLostConnectionToHost = 0x81, + CMsgKickPlayer = 0x34, // host kick + CMsgDebugStall = 0x7E, // unused? + CMsgCheckQueuedJoinRequestReply = 0x59, + CMsgCheckQueuedJoinRequest = 0x51, + CMsgBlacklist = 0x0C, + CMsgRoamingRequestBubbleRequiredResponse = 0x83, + CMsgRoamingRequestBubbleRequiredCheck = 0x82, + CMsgRoamingRequestBubble = 0x2E, + CMsgRoamingJoinBubble = 0x4C, + CMsgRoamingJoinBubbleAck = 0x3F, + CMsgRoamingInitialBubble = 0x32, + CMsgVoiceStatus = 0x03, + CMsgTextChatStatus = 0x00, + CMsgJoinResponse2 = 0x08, + CMsgJoinRequest2 = 0x68, + CMsgNetTimeSync = 0x38, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 37 + CMsgNetComplaint = 0x55, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 54 + CMsgNetLagPing = 0x27, // unused? ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 26 + CMsgSearchResponse = 0x6B, // unused? ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 6A + CMsgSearchRequest = 0x05, // unused? + CMsgQosProbeResponse = 0x2C, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 2B + CMsgQosProbeRequest = 0x1D, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 1C + CMsgCxnRelayAddressChanged = 0x49, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 48 + CMsgCxnRequestRemoteTimeout = 0x2F, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 2E + CMsgSessionDetailRequest = 0x22, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 21 + CMsgSessionDetailResponse = 0x13, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 12 + CMsgKeyExchangeOffer = 0x0F, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 0E (last result) + CMsgKeyExchangeAnswer = 0x44, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 43 + CMsg_0x87 = 0x87, + CMsg_0x88 = 0x88, + CMsg_0x80 = 0x80, + CMsg_0x28 = 0x28, + CMsg_0x11 = 0x11, + CMsg_0x45 = 0x45, + CMsg_0x89 = 0x89, + CMsg_0x86 = 0x86, + }; namespace netConnection { class InFrame { @@ -159,122 +286,6 @@ namespace rage char pad_007C[4]; //0x007C void* m_data; //0x0080 }; - - enum class MessageType : std::uint32_t - { - MsgInvalid = 0xFFFFF, - MsgSessionAcceptChat = 0x62, - MsgStartMatchCmd = 0x2D, - MsgSetInvitableCmd = 0x1F, - MsgSessionMemberIds = 0x23, - MsgRequestGamerInfo = 0x54, - MsgRemoveGamersFromSessionCmd = 0x53, - MsgNotMigrating = 0x35, - MsgMigrateHostResponse = 0x12, - MsgMigrateHostRequest = 0x66, - MsgJoinResponse = 0x2A, - MsgJoinRequest = 0x41, - MsgHostLeftWhilstJoiningCmd = 0x58, - MsgConfigResponse = 0x5F, - MsgConfigRequest = 0x48, - MsgChangeSessionAttributesCmd = 0x5A, - MsgAddGamerToSessionCmd = 0x64, // this is where send net info to lobby is called, among other things - MsgReassignResponse = 0x10, - MsgReassignNegotiate = 0x01, - MsgReassignConfirm = 0x26, - MsgPlayerData = 0x18, - MsgPackedReliables = 0x30, - MsgPackedCloneSyncACKs = 0x3B, - MsgNonPhysicalData = 0x16, - MsgNetArrayMgrUpdateAck = 0x5D, - MsgNetArrayMgrUpdate = 0x60, - MsgNetArrayMgrSplitUpdateAck = 0x25, - MsgScriptVerifyHostAck = 0x0B, - MsgScriptVerifyHost = 0x3E, - MsgScriptNewHost = 0x0E, - MsgScriptMigrateHostFailAck = 0x1A, - MsgScriptMigrateHost = 0x33, - MsgScriptLeaveAck = 0x40, - MsgScriptLeave = 0x17, - MsgScriptJoinHostAck = 0x4D, - MsgScriptJoinAck = 0x43, - MsgScriptJoin = 0x5C, - MsgScriptHostRequest = 0x67, - MsgScriptHandshakeAck = 0x5B, - MsgScriptHandshake = 0x57, - MsgScriptBotLeave = 0x2B, // unused? - MsgScriptBotJoinAck = 0x63, // unused? - MsgScriptBotJoin = 0x1C, // unused? - MsgScriptBotHandshakeAck = 0x31, // unused? - MsgScriptBotHandshake = 0x4B, // unused? - MsgPartyLeaveGame = 0x3D, - MsgPartyEnterGame = 0x1E, - MsgCloneSync = 0x4E, // aka clone_create, clone_sync etc. - MsgActivateNetworkBot = 0x65, // unused? - MsgRequestObjectIds = 0x29, - MsgInformObjectIds = 0x09, - MsgTextMessage = 0x24, // this one is for chat - MsgPlayerIsTyping = 0x61, - MsgPackedEvents = 0x4F, // aka received_event - MsgPackedEventReliablesMsgs = 0x20, - MsgRequestKickFromHost = 0x0D, - MsgTransitionToGameStart = 0x50, - MsgTransitionToGameNotify = 0x02, - MsgTransitionToActivityStart = 0x06, - MsgTransitionToActivityFinish = 0x36, - MsgTransitionParameters = 0x3C, - MsgTransitionParameterString = 0x37, - MsgTransitionLaunchNotify = 0x1B, - MsgTransitionLaunch = 0x19, - MsgTransitionGamerInstruction = 0x14, - MsgTextMessage2 = 0x0A, // this one is for phone message - MsgSessionEstablishedRequest = 0x52, - MsgSessionEstablished = 0x07, - MsgRequestTransitionParameters = 0x42, - MsgRadioStationSyncRequest = 0x47, - MsgRadioStationSync = 0x46, - MsgPlayerCardSync = 0x3A, - MsgPlayerCardRequest = 0x6A, - MsgLostConnectionToHost = 0x81, - MsgKickPlayer = 0x34, // host kick - MsgDebugStall = 0x7E, // unused? - MsgCheckQueuedJoinRequestReply = 0x59, - MsgCheckQueuedJoinRequest = 0x51, - MsgBlacklist = 0x0C, - MsgRoamingRequestBubbleRequiredResponse = 0x83, - MsgRoamingRequestBubbleRequiredCheck = 0x82, - MsgRoamingRequestBubble = 0x2E, - MsgRoamingJoinBubble = 0x4C, - MsgRoamingJoinBubbleAck = 0x3F, - MsgRoamingInitialBubble = 0x32, - MsgVoiceStatus = 0x03, - MsgTextChatStatus = 0x00, - MsgJoinResponse2 = 0x08, - MsgJoinRequest2 = 0x68, - - MsgNetTimeSync = 0x38, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 37 - MsgNetComplaint = 0x55, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 54 - MsgNetLagPing = 0x27, // unused? ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 26 - MsgSearchResponse = 0x6B, // unused? ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 6A - MsgSearchRequest = 0x05, // unused? - MsgQosProbeResponse = 0x2C, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 2B - MsgQosProbeRequest = 0x1D, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 1C - MsgCxnRelayAddressChanged = 0x49, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 48 - MsgCxnRequestRemoteTimeout = 0x2F, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 2E - MsgSessionDetailRequest = 0x22, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 21 - MsgSessionDetailResponse = 0x13, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 12 - MsgKeyExchangeOffer = 0x0F, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 0E (last result) - MsgKeyExchangeAnswer = 0x44, // ctor 40 53 48 83 EC 20 BA ? ? ? ? 4C 8D 0D ? ? ? ? 48 8B D9 44 8D 42 43 - - Msg_0x87 = 0x87, - Msg_0x88 = 0x88, - Msg_0x80 = 0x80, - Msg_0x28 = 0x28, - Msg_0x11 = 0x11, - Msg_0x45 = 0x45, - Msg_0x89 = 0x89, - Msg_0x86 = 0x86, - }; } class CEventNetwork diff --git a/BigBaseV2/src/gui.cpp b/BigBaseV2/src/gui.cpp index dab1c67a..15e68979 100644 --- a/BigBaseV2/src/gui.cpp +++ b/BigBaseV2/src/gui.cpp @@ -83,11 +83,6 @@ namespace big view::always(); } - void gui::script_init() - { - g_notification_service->push("Welcome", fmt::format("Loaded YimMenu. Press {} to open", ImGui::key_names[g->settings.hotkeys.menu_toggle])); - } - void gui::script_on_tick() { TRY_CLAUSE @@ -128,7 +123,7 @@ namespace big void gui::script_func() { - g_gui.script_init(); + g_notification_service->push("Welcome", fmt::format("Loaded YimMenu. Press {} to open", ImGui::key_names[g->settings.hotkeys.menu_toggle])); while (true) { g_gui.script_on_tick(); diff --git a/BigBaseV2/src/gui.hpp b/BigBaseV2/src/gui.hpp index 50d02cdd..6a4983b3 100644 --- a/BigBaseV2/src/gui.hpp +++ b/BigBaseV2/src/gui.hpp @@ -10,7 +10,6 @@ namespace big void dx_on_tick(); void always_draw(); - void script_init(); void script_on_tick(); static void script_func(); public: diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index f4b7ec6a..1c84569b 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -19,13 +19,9 @@ namespace big hooking::hooking() : // Swapchain m_swapchain_hook(*g_pointers->m_swapchain, hooks::swapchain_num_funcs), - // SetCursorPos - m_set_cursor_pos_hook("SCP", memory::module("user32.dll").get_export("SetCursorPos").as(), &hooks::set_cursor_pos), // Script Hook m_run_script_threads_hook("SH", g_pointers->m_run_script_threads, &hooks::run_script_threads), - // ConvertThreadToFibe - m_convert_thread_to_fiber_hook("CTTF", memory::module("kernel32.dll").get_export("ConvertThreadToFiber").as(), &hooks::convert_thread_to_fiber), // GTA Thead Start m_gta_thread_start_hook("GTS", g_pointers->m_gta_thread_start, &hooks::gta_thread_start), @@ -80,11 +76,9 @@ namespace big void hooking::enable() { m_swapchain_hook.enable(); - m_og_wndproc = reinterpret_cast(SetWindowLongPtrW(g_pointers->m_hwnd, GWLP_WNDPROC, reinterpret_cast(&hooks::wndproc))); - m_set_cursor_pos_hook.enable(); + m_og_wndproc = WNDPROC(SetWindowLongPtrW(g_pointers->m_hwnd, GWLP_WNDPROC, LONG_PTR(&hooks::wndproc))); m_run_script_threads_hook.enable(); - m_convert_thread_to_fiber_hook.enable(); m_gta_thread_start_hook.enable(); m_gta_thread_kill_hook.enable(); @@ -137,10 +131,8 @@ namespace big m_gta_thread_kill_hook.disable(); m_gta_thread_start_hook.disable(); - m_convert_thread_to_fiber_hook.disable(); m_run_script_threads_hook.disable(); - m_set_cursor_pos_hook.disable(); SetWindowLongPtrW(g_pointers->m_hwnd, GWLP_WNDPROC, reinterpret_cast(m_og_wndproc)); m_swapchain_hook.disable(); } @@ -164,34 +156,8 @@ namespace big g_script_mgr.tick(); } - return g_hooking->m_run_script_threads_hook.get_original()(ops_to_execute); + return g_hooking->m_run_script_threads_hook.get_original()(ops_to_execute); } EXCEPT_CLAUSE return false; } - - void *hooks::convert_thread_to_fiber(void *param) - { - TRY_CLAUSE - { - if (IsThreadAFiber()) - { - return GetCurrentFiber(); - } - - return g_hooking->m_convert_thread_to_fiber_hook.get_original()(param); - } EXCEPT_CLAUSE - return nullptr; - } - - BOOL hooks::set_cursor_pos(int x, int y) - { - TRY_CLAUSE - { - if (g_gui.m_opened) - return true; - - return g_hooking->m_set_cursor_pos_hook.get_original()(x, y); - } EXCEPT_CLAUSE - return FALSE; - } } diff --git a/BigBaseV2/src/hooking.hpp b/BigBaseV2/src/hooking.hpp index e045e651..db0dcadc 100644 --- a/BigBaseV2/src/hooking.hpp +++ b/BigBaseV2/src/hooking.hpp @@ -12,7 +12,6 @@ namespace big struct hooks { static bool run_script_threads(std::uint32_t ops_to_execute); - static void *convert_thread_to_fiber(void *param); static constexpr auto swapchain_num_funcs = 19; static constexpr auto swapchain_present_index = 8; @@ -21,7 +20,6 @@ namespace big static HRESULT swapchain_resizebuffers(IDXGISwapChain *this_, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT new_format, UINT swapchain_flags); static LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); - static BOOL set_cursor_pos(int x, int y); static GtaThread* gta_thread_start(unsigned int** a1, unsigned int a2); static rage::eThreadState gta_thread_kill(GtaThread* thread); @@ -55,10 +53,10 @@ namespace big static bool send_net_info_to_lobby(rage::netPlayerData* player, int64_t a2, int64_t a3, DWORD* a4); static bool receive_net_message(void* netConnectionManager, void* a2, rage::netConnection::InFrame* frame); - static void get_network_event_data(__int64 a1, rage::CEventNetwork* net_event); + static void get_network_event_data(int64_t unk, rage::CEventNetwork* net_event); //SYNC - static signed __int64 received_clone_sync(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, unsigned __int16 sync_type, unsigned __int16 obj_id, rage::datBitBuffer* a6, unsigned __int16 a7, unsigned int timestamp); + static int64_t received_clone_sync(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, uint16_t sync_type, uint16_t obj_id, rage::datBitBuffer* bufer, uint16_t unk, uint32_t timestamp); }; struct minhook_keepalive @@ -84,10 +82,8 @@ namespace big vmt_hook m_swapchain_hook; WNDPROC m_og_wndproc = nullptr; - detour_hook m_set_cursor_pos_hook; detour_hook m_run_script_threads_hook; - detour_hook m_convert_thread_to_fiber_hook; detour_hook m_gta_thread_start_hook; detour_hook m_gta_thread_kill_hook; diff --git a/BigBaseV2/src/hooks/info/get_network_event_data.cpp b/BigBaseV2/src/hooks/info/get_network_event_data.cpp index d6eaf42a..a40b2831 100644 --- a/BigBaseV2/src/hooks/info/get_network_event_data.cpp +++ b/BigBaseV2/src/hooks/info/get_network_event_data.cpp @@ -2,11 +2,9 @@ namespace big { - void hooks::get_network_event_data(__int64 a1, rage::CEventNetwork* net_event) + void hooks::get_network_event_data(int64_t unk, rage::CEventNetwork* net_event) { - __int64 event_type = net_event->get_type(); - - switch (event_type) { + switch (net_event->get_type()) { case 161: //CEventNetworkRemovedFromSessionDueToComplaints { g_notification_service->push_warning("Kicked", "You have been desync kicked."); @@ -14,6 +12,6 @@ namespace big } } - return g_hooking->m_get_network_event_data_hook.get_original()(a1, net_event); + return g_hooking->m_get_network_event_data_hook.get_original()(unk, net_event); } } \ No newline at end of file diff --git a/BigBaseV2/src/hooks/protections/receive_net_message.cpp b/BigBaseV2/src/hooks/protections/receive_net_message.cpp index dc5eed4b..d0e913c4 100644 --- a/BigBaseV2/src/hooks/protections/receive_net_message.cpp +++ b/BigBaseV2/src/hooks/protections/receive_net_message.cpp @@ -1,86 +1,50 @@ #include "hooking.hpp" #include "services/players/player_service.hpp" +#include namespace big { - - inline bool get_message_type(rage::netConnection::MessageType& msg_type, rage::datBitBuffer& buffer) + bool get_msg_type(rage::eNetMessage& msgType, rage::datBitBuffer& buffer) { uint32_t pos; uint32_t magic; uint32_t length; uint32_t extended{}; if ((buffer.m_flagBits & 2) != 0 || (buffer.m_flagBits & 1) == 0 ? (pos = buffer.m_curBit) : (pos = buffer.m_maxBit), - buffer.m_bitsRead + 15 > pos || !buffer.ReadDword(&magic, 14) || magic != 0x3246 || !buffer.ReadDword(&extended, 1)) - { - msg_type = rage::netConnection::MessageType::MsgInvalid; + buffer.m_bitsRead + 15 > pos || !buffer.ReadDword(&magic, 14) || magic != 0x3246 || !buffer.ReadDword(&extended, 1)) { + msgType = rage::eNetMessage::CMsgInvalid; return false; } - length = extended ? 16 : 8; - - if ((buffer.m_flagBits & 1) == 0 ? (pos = buffer.m_curBit) : (pos = buffer.m_maxBit), length + buffer.m_bitsRead <= pos && buffer.ReadDword((uint32_t*)&msg_type, length)) + if ((buffer.m_flagBits & 1) == 0 ? (pos = buffer.m_curBit) : (pos = buffer.m_maxBit), length + buffer.m_bitsRead <= pos && buffer.ReadDword((uint32_t*)&msgType, length)) return true; else return false; } - bool hooks::receive_net_message(void* netConnectionManager, void* a2, rage::netConnection::InFrame* frame) { if (frame->get_type() == 4) { rage::datBitBuffer buffer((uint8_t*)frame->m_data, frame->m_length); buffer.m_flagBits = 1; - rage::netConnection::MessageType msg_type; - + rage::eNetMessage msgType; const auto player = g_player_service->get_by_msg_id(frame->m_msg_id); - if (player && get_message_type(msg_type, buffer)) + if (player && get_msg_type(msgType, buffer)) { - switch (msg_type) + switch (msgType) { //Desync Kick - case rage::netConnection::MessageType::MsgNetComplaint: + case rage::eNetMessage::CMsgNetComplaint: { - uint64_t host_token{}; - buffer.ReadQWord(&host_token, 64); - - std::vector players; - - uint32_t num_of_host_token{}; - buffer.ReadDword(&num_of_host_token, 32); - - if (num_of_host_token <= 64) { - - std::vector host_token_list{}; - for (uint32_t i = 0; i < num_of_host_token; i++) { - - uint64_t array_element{}; - buffer.ReadQWord(&array_element, 64); - host_token_list.push_back(array_element); - - const auto big_player = g_player_service->get_by_host_token(array_element); - if (big_player) - if (CNetGamePlayer* net_player = big_player->get_net_game_player()) - players.push_back(net_player); - } - - } - + uint64_t hostToken; + buffer.ReadQWord(&hostToken, 0x40); + buffer.Seek(0); + player_ptr sender = g_player_service->get_by_host_token(hostToken); + sender->get_net_game_player()->m_complaints = USHRT_MAX; //Sender + g_notification_service->push_warning("Blocked Kick", fmt::format("Desync kick from {}", sender->get_name())); buffer.Seek(0); - - if (!players.empty()) - { - const auto& player = players.at(0); - if (player && player->is_valid()) - { - player->m_complaints = 65535; - g_notification_service->push_warning("Blocked Kick", std::string("Blocked desync kick from ") + player->get_name()); - } - } - return false; } - } } } diff --git a/BigBaseV2/src/hooks/protections/received_clone_sync.cpp b/BigBaseV2/src/hooks/protections/received_clone_sync.cpp index 96a46957..18f5ca84 100644 --- a/BigBaseV2/src/hooks/protections/received_clone_sync.cpp +++ b/BigBaseV2/src/hooks/protections/received_clone_sync.cpp @@ -26,14 +26,7 @@ namespace big { */ - signed __int64 hooks::received_clone_sync(CNetworkObjectMgr* mgr, - CNetGamePlayer* src, - CNetGamePlayer* dst, - unsigned __int16 sync_type, - unsigned __int16 obj_id, - rage::datBitBuffer* buffer, - unsigned __int16 a7, - unsigned int timestamp) { + int64_t hooks::received_clone_sync(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, uint16_t sync_type, uint16_t obj_id, rage::datBitBuffer* buffer, uint16_t unk, uint32_t timestamp) { auto sync_tree = g_pointers->m_get_sync_tree_for_type(mgr, sync_type); auto tree_name = g_pointers->m_get_sync_type_info(sync_type, 0); @@ -53,14 +46,15 @@ namespace big { if (invalidsync) { - - if (g->notifications.invalid_sync.log) LOG(WARNING) << "Invalid sync: " << "Type: " << sync_type << " Tree name: " << tree_name << " From: " << src->get_name(); - if (g->notifications.invalid_sync.notify) g_notification_service->push_warning("Invalid sync " + std::string(src->get_name()), "Type: " + std::to_string(sync_type) + "\nType name: " + tree_name); + if (g->notifications.invalid_sync.log) + LOG(WARNING) << "Invalid sync: " << "Type: " << sync_type << " Tree name: " << tree_name << " From: " << src->get_name(); + if (g->notifications.invalid_sync.notify) + g_notification_service->push_warning(fmt::format("Invalid Sync from {}", src->get_name()), fmt::format("Type {} in sync tree {}", sync_type, tree_name)); return 2; } - auto result = g_hooking->m_received_clone_sync_hook.get_original()(mgr, src, dst, sync_type, obj_id, buffer, a7, timestamp); + auto result = g_hooking->m_received_clone_sync_hook.get_original()(mgr, src, dst, sync_type, obj_id, buffer, unk, timestamp); return result; diff --git a/BigBaseV2/src/hooks/protections/received_event.cpp b/BigBaseV2/src/hooks/protections/received_event.cpp index c91fad8e..3a6b18a3 100644 --- a/BigBaseV2/src/hooks/protections/received_event.cpp +++ b/BigBaseV2/src/hooks/protections/received_event.cpp @@ -29,9 +29,9 @@ namespace big return; } - switch ((RockstarEvent)event_id) + switch (static_cast(event_id)) { - case RockstarEvent::NETWORK_INCREMENT_STAT_EVENT: + case eNetworkEvents::CNetworkIncrementStatEvent: { const auto increment_stat_event = std::make_unique(); buffer->ReadDword(&increment_stat_event->m_stat, 0x20); @@ -45,7 +45,7 @@ namespace big buffer->Seek(0); break; } - case RockstarEvent::SCRIPT_ENTITY_STATE_CHANGE_EVENT: + case eNetworkEvents::CScriptEntityStateChangeEvent: { uint16_t entity; buffer->ReadWord(&entity, 13); @@ -53,21 +53,15 @@ namespace big buffer->ReadDword(&type, 4); uint32_t unk; buffer->ReadDword(&unk, 32); - - if (type == 6) - { + if (type == 6) { uint16_t unk2; buffer->ReadWord(&unk2, 13); uint32_t action; buffer->ReadDword(&action, 8); - - if (action >= 15 && action <= 18) - { + if (action >= 15 && 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())); @@ -78,7 +72,7 @@ namespace big buffer->Seek(0); break; } - case RockstarEvent::SCRIPTED_GAME_EVENT: + case eNetworkEvents::CScriptedGameEvent: { const auto scripted_game_event = std::make_unique(); buffer->ReadDword(&scripted_game_event->m_args_size, 32); @@ -95,7 +89,7 @@ namespace big break; } - case RockstarEvent::NETWORK_CLEAR_PED_TASKS_EVENT: + case eNetworkEvents::CNetworkClearPedTasksEvent: { if (source_player->m_player_id < 32) { @@ -116,7 +110,7 @@ namespace big } // Don't block this event, we still want to report this player // because if we still report others, our account seems less fishy - case RockstarEvent::REPORT_CASH_SPAWN_EVENT: + case eNetworkEvents::CReportCashSpawnEvent: { uint32_t money; @@ -138,8 +132,8 @@ namespace big break; } // player sending this event is a modder - case RockstarEvent::NETWORK_CHECK_CODE_CRCS_EVENT: - case RockstarEvent::REPORT_MYSELF_EVENT: + case eNetworkEvents::CNetworkCheckCodeCrcsEvent: + case eNetworkEvents::CUpdateFxnEvent: { if (g->notifications.received_event.modder_detect.log) LOG(INFO) << "RECEIVED_EVENT_HANDLER : " << source_player->get_name() << " sent modder event."; @@ -151,7 +145,7 @@ namespace big break; } - case RockstarEvent::REQUEST_CONTROL_EVENT: + case eNetworkEvents::CRequestControlEvent: { g_pointers->m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); diff --git a/BigBaseV2/src/main.cpp b/BigBaseV2/src/main.cpp index 0773b02b..50eee711 100644 --- a/BigBaseV2/src/main.cpp +++ b/BigBaseV2/src/main.cpp @@ -1,6 +1,5 @@ #include "common.hpp" #include "core/globals.hpp" -#include "features.hpp" #include "fiber_pool.hpp" #include "gui.hpp" #include "logger.hpp" @@ -82,9 +81,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) auto gui_service_instance = std::make_unique(); LOG(INFO) << "Registered service instances..."; - g_script_mgr.add_script(std::make_unique