From 6ebd3d753f74d6566134dcd1c7af41bfdc1e57a1 Mon Sep 17 00:00:00 2001 From: Mr-X-GTA <110748953+Mr-X-GTA@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:15:42 +0200 Subject: [PATCH] Misc stuff (#3515) * feat(hotkeys): add support for mouse buttons * feat: show message box with version note if pattern scan fails * feat(exception handler): set destination register to 0 on move instructions * feat: update r* admin list * fix: fix spawned vehicle not being deleted when using bring player * fix: fix exceptions when using bring player * fix: fix gravity gun not working while requesting control * fix: dont request control of entities that are not CPhysical * fix: fix take_control_of not requesting control if timeout is 0 * fix: fix crash when executing commands on all players * fix: fix cmd executor style being applied to all windows if command is invalid * fix: fix rare exceptions in esp::draw_player * fix: fix exceptions when using gravity gun on objects or dying with some models * fix: fix incorrect reading of m_model_type --- cmake/gtav-classes.cmake | 2 +- src/backend/looped/weapons/gravity_gun.cpp | 6 ++-- src/backend/player_command.cpp | 12 ++++--- src/core/data/admin_rids.hpp | 2 +- src/gta_pointers.hpp | 1 + src/hooking/hooking.cpp | 2 ++ src/hooking/hooking.hpp | 3 +- src/hooks/protections/update_sync_tree.cpp | 13 +++++++ src/logger/exception_handler.cpp | 24 +++++++++++++ src/pointers.cpp | 14 +++++++- src/pointers.hpp | 25 +++++++++++-- .../context_menu/context_menu_service.cpp | 3 +- src/services/hotkey/hotkey_service.cpp | 36 +++++++++++++++++++ src/util/entity.cpp | 12 +++---- src/util/fuzzer.hpp | 14 ++++---- src/util/model_info.hpp | 8 ++--- src/util/protection.cpp | 6 ++-- src/util/teleport.hpp | 25 ++++++++----- src/views/core/view_cmd_executor.cpp | 2 +- src/views/esp/view_esp.cpp | 29 +++++++-------- 20 files changed, 180 insertions(+), 59 deletions(-) create mode 100644 src/hooks/protections/update_sync_tree.cpp diff --git a/cmake/gtav-classes.cmake b/cmake/gtav-classes.cmake index a3633ba2..78b091fa 100644 --- a/cmake/gtav-classes.cmake +++ b/cmake/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git - GIT_TAG a91475c198c59eff04de26929e83d86521299dda + GIT_TAG b9b832ab00c95a731f8472f696c5d026a29fd767 GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/backend/looped/weapons/gravity_gun.cpp b/src/backend/looped/weapons/gravity_gun.cpp index 3d1b926b..7f1fdf86 100644 --- a/src/backend/looped/weapons/gravity_gun.cpp +++ b/src/backend/looped/weapons/gravity_gun.cpp @@ -23,7 +23,7 @@ namespace big if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV)) dist += 5; - if (!entity::take_control_of(e)) + if (!entity::take_control_of(e, 0)) return; // TODO: remove from vector ENTITY::SET_ENTITY_COLLISION(e, false, false); @@ -83,7 +83,7 @@ namespace big } else { - if (entity::take_control_of(ent_to_add) && ENTITY::IS_ENTITY_A_PED(ent_to_add) && !PED::IS_PED_RAGDOLL(ent_to_add)) + if (entity::take_control_of(ent_to_add, 0) && ENTITY::IS_ENTITY_A_PED(ent_to_add) && !PED::IS_PED_RAGDOLL(ent_to_add)) { TASK::SET_HIGH_FALL_TASK(ent_to_add, 0, 0, 0); @@ -107,7 +107,7 @@ namespace big { for (const Entity& e : ents) { - if (entity::take_control_of(e)) + if (entity::take_control_of(e, 0)) { if (g.weapons.gravity_gun.launch_on_release) { diff --git a/src/backend/player_command.cpp b/src/backend/player_command.cpp index 930096b7..e88f86b0 100644 --- a/src/backend/player_command.cpp +++ b/src/backend/player_command.cpp @@ -12,10 +12,14 @@ namespace big void player_all_component::execute(const command_arguments& args, const std::shared_ptr ctx) { - g_fiber_pool->queue_job([this, args, &ctx] { - g_player_service->iterate([this, args, &ctx](const player_entry& player) { - m_parent->execute(player.second, args, ctx); - }); + g_fiber_pool->queue_job([this, args, ctx] { + for (uint32_t i = 0; i < 32; ++i) + { + if (auto player = g_player_service->get_by_id(i); player && player->is_valid()) + { + m_parent->execute(player, args, ctx); + } + } }); } diff --git a/src/core/data/admin_rids.hpp b/src/core/data/admin_rids.hpp index 21e36510..2a242042 100644 --- a/src/core/data/admin_rids.hpp +++ b/src/core/data/admin_rids.hpp @@ -3,5 +3,5 @@ namespace big { - const inline std::unordered_set admin_rids = {12435, 63457, 216820, 6597634, 9284553, 10552062, 10833148, 13934382, 14870763, 16395773, 16395782, 16395801, 16395840, 16395850, 16396080, 16396091, 16396096, 16396107, 16396118, 16396126, 16396133, 16396141, 16396148, 16396157, 16396170, 16417718, 16439132, 18965281, 20158751, 20158753, 20158757, 20158759, 21088063, 21765545, 22577121, 22577440, 22577458, 23659342, 23659351, 23659353, 23659354, 24037237, 24646485, 25667546, 25695975, 26658154, 27691740, 28776717, 28823614, 29454165, 31586721, 39573295, 41352312, 46469110, 49770174, 50850475, 53309582, 54445058, 54462116, 54468359, 54815152, 54815524, 56176623, 56321667, 56583239, 56778561, 57233573, 60331599, 61522786, 62409944, 62739248, 64074298, 64234321, 64499496, 64624133, 65428266, 67241866, 69079775, 69325516, 69991900, 70527952, 70703467, 70841434, 74716313, 75632221, 76384414, 76385407, 77205006, 78229643, 78934592, 80527019, 81691532, 85593421, 88047835, 88435236, 88435319, 88435362, 88435916, 88439202, 88440582, 89288299, 89705641, 89705672, 89705758, 89730037, 89730175, 89730345, 89797943, 90580674, 91003708, 91031119, 93759248, 93759254, 93759280, 93759401, 93759425, 93759462, 93800162, 93800269, 94028919, 99453882, 99922796, 100641297, 102519620, 103054099, 103318524, 103814653, 104041189, 104213911, 104432921, 105474714, 105919953, 106480467, 107713060, 107713114, 111262316, 111377226, 111439945, 112362134, 113097651, 114982881, 115641569, 115642993, 115643538, 115649691, 115670847, 115671687, 116815567, 117639172, 117639190, 119266383, 119958356, 121238364, 121397532, 121698158, 121708718, 121943600, 121970978, 123017343, 123849404, 124006884, 126156972, 126756566, 127403483, 127448079, 129159629, 130291511, 130291558, 130972490, 131037988, 131973478, 132258220, 132521200, 132826927, 133709045, 134385206, 134412628, 134933117, 134998109, 135811063, 136552330, 136553211, 136554213, 136554798, 137579070, 137601710, 137663665, 137667349, 137714280, 137851207, 138075198, 138097967, 138273823, 138302559, 138660450, 138831719, 139813495, 141594080, 141860986, 141884823, 142099256, 142536132, 142582982, 144372813, 146452200, 146999560, 147111499, 147405780, 147457094, 147604980, 149203647, 151018852, 151061557, 151158004, 151158634, 151159677, 151972200, 151975489, 152451452, 153034481, 153219155, 155527062, 156336742, 156436871, 156442381, 156575528, 159587479, 168226907, 170727774, 171093866, 171094021, 171480091, 171621041, 173200071, 173213117, 173229864, 173426004, 173709268, 173712102, 173717622, 174156763, 174194059, 174247774, 174607564, 174623904, 174623946, 174623951, 174624061, 174625194, 174625307, 174625407, 174625552, 174625647, 174626867, 174754789, 174875493, 176599903, 178440917, 179606757, 179607078, 179608067, 179654627, 179659205, 179848153, 179848203, 179848415, 179930265, 179936743, 179936852, 179942496, 179965835, 180015293, 180096359, 180096468, 182438142, 182516442, 182860908, 183314955, 183565013, 183746202, 183970446, 184269528, 184359255, 184360405, 185393703, 185405431, 186057650, 186058299, 186325468, 188498026, 192118902, 192796203, 193919365, 193947342, 193971479, 193971567, 193971908, 193972138, 193973221, 193975449, 194002589, 194003533, 194004216, 194060881, 194116470, 194125886, 194497396, 195246292, 195314410, 195404163, 195489237, 196222661, 196269807, 196270383, 196270581, 196271217, 196271907, 196524776, 196584699, 196588801, 197800858, 197872508, 197872817, 198439589, 198475036, 199788352, 199819506, 200121238, 200595661, 200613777, 201661227, 201663320, 201663467, 201664501, 201693153, 201693551, 201698392, 201701643, 201726181, 201727585, 201767917, 201983184, 201983223, 203209892, 203289934, 203294845, 203695911, 203720325, 203723447, 204061479, 204071275, 204339633, 204344395, 205005075, 205333914, 205904977, 205951017, 206624869, 207118252, 207819508, 208186004, 208206831, 208598427, 208854942, 208978576, 209191450, 209226460, 209260139, 209260714, 209260788, 209768906, 209842220, 209901120, 210340207, 210495239, 210495352, 210736452, 210993156, 210993185, 211136447, 211515349, 211532217, 211679972, 211680281, 211702584, 211750362, 212138766, 212464051, 212821044, 213182009, 213390165, 213498323, 213500078, 213550108, 213550783, 213560223, 213611914, 213612663, 213615794, 213616333, 214116086, 214250188, 214327469, 214516585, 214878420, 214921670, 215232482, 215629466, 216429141, 216753945, 217097347, 217254302, 217254350, 217255149, 217261805, 217353908, 217368373, 217858968, 217861358, 217861775, 217870124, 218035890, 218151680, 218152225, 218226925, 218308954, 218310715, 218487111, 218901089, 219365086, 219850254, 219850752, 219853753, 219855754, 219857662, 219857719, 219857745, 219866336, 220121187, 220143764, 220239069, 220506626, 220517406, 220538568, 220569666, 220591655, 220594438, 220930761, 221991933, 222524313, 222531414, 222549274, 222956471, 223787165, 223787707, 223843537, 223846253, 224166708, 224500725, 225107350}; + const inline std::unordered_set admin_rids = {12435, 24250, 63457, 121902, 181882, 216820, 6597634, 6833878, 8182732, 8577054, 9132602, 9275904, 9284553, 9808958, 10552062, 10833148, 12694972, 13854216, 13934382, 14712533, 14870763, 15213810, 16395773, 16395782, 16395801, 16395840, 16395850, 16396080, 16396091, 16396096, 16396107, 16396118, 16396126, 16396133, 16396141, 16396148, 16396157, 16396170, 16417718, 16439132, 16498099, 17718667, 18286248, 18965281, 19289552, 19375190, 20158751, 20158753, 20158757, 20158759, 20449579, 21088063, 21765545, 22577121, 22577440, 22577458, 23463300, 23659342, 23659351, 23659353, 23659354, 24037237, 24646485, 24967658, 25084913, 25421105, 25667546, 25695975, 26070387, 26658154, 27691740, 28452909, 28776717, 28823614, 29148482, 29336484, 29454165, 39573295, 41352312, 46469110, 49216566, 49770174, 50508248, 50850475, 51924350, 52558278, 53080699, 53309582, 54445058, 54462116, 54468359, 54815152, 54815524, 56176623, 56321667, 56583239, 56778561, 57233573, 60331599, 61522786, 62409944, 62739248, 64074298, 64234321, 64499496, 64624133, 64669991, 65428266, 66065028, 66635933, 67241866, 69079775, 69325516, 69617572, 69785202, 69991900, 69992324, 69993247, 69995555, 70527952, 70703467, 70841434, 74374444, 74716313, 75632221, 76137299, 76384122, 76384414, 76385407, 76385741, 77205006, 78229643, 78934592, 79238137, 80113641, 80527019, 80557105, 81639346, 81691532, 82920195, 83888328, 84179362, 85074635, 85593421, 88047835, 88223696, 88226249, 88418573, 88435236, 88435319, 88435362, 88435916, 88439202, 88440582, 89288299, 89705641, 89705672, 89705758, 89730037, 89730175, 89730345, 89797943, 89897681, 90580674, 91003708, 91031119, 93759248, 93759254, 93759280, 93759401, 93759425, 93759462, 93800162, 93800269, 94028919, 94947512, 95454397, 96018790, 96676052, 98148297, 99453882, 99733946, 99922796, 100250829, 100641297, 102519620, 102589550, 102765655, 102844945, 103054099, 103318524, 103814653, 104041189, 104213911, 104432921, 105411453, 105474714, 105919953, 106480467, 107437360, 107713060, 107713114, 111262316, 111377226, 111439945, 111533362, 111533919, 112362134, 112854877, 112863659, 112894767, 112897182, 113097651, 113765362, 114963242, 114982881, 115544711, 115574239, 115641569, 115642993, 115643538, 115649691, 115670847, 115671687, 116815567, 117639172, 117639190, 117641111, 119958356, 120038338, 121238364, 121397532, 121698158, 121708718, 121943600, 121970978, 122637663, 123017343, 123849404, 124006884, 125292194, 125511970, 125702179, 126156972, 126459395, 126756566, 127403483, 127448079, 129159629, 130254868, 130291511, 130291558, 130972490, 131037988, 131788679, 131973478, 132258220, 132521200, 132826927, 133154758, 133709045, 134385206, 134412628, 134933117, 134994376, 134998109, 135811063, 136552330, 136553211, 136554213, 136554798, 137579070, 137601710, 137663665, 137667349, 137714280, 137723460, 137851207, 138075198, 138097967, 138273823, 138302559, 138660450, 138831719, 139513812, 139813495, 141594080, 141860986, 141884823, 142099256, 142273066, 142302151, 142451623, 142452251, 142536132, 142582982, 142697410, 143001423, 143505323, 143873050, 144202963, 144372813, 146452200, 146999560, 147013210, 147111499, 147405780, 147457094, 147604980, 149203647, 149800986, 151018852, 151061557, 151158004, 151158634, 151159677, 151718424, 151972200, 151975489, 152451452, 153034481, 153219155, 155504245, 155527062, 155631415, 156336742, 156429864, 156434150, 156435941, 156436094, 156436871, 156436901, 156436998, 156437240, 156442381, 156448434, 156575528, 159587479, 162645788, 165379901, 168226907, 169084378, 170727774, 171093866, 171094021, 171480091, 171621041, 173200071, 173213117, 173229864, 173292524, 173426004, 173426061, 173709268, 173712102, 173717622, 174156763, 174194059, 174247774, 174607564, 174623904, 174623946, 174623951, 174624061, 174625194, 174625307, 174625407, 174625552, 174625647, 174626867, 174754789, 174875493, 176599903, 177700182, 178440917, 179068807, 179606757, 179607078, 179608067, 179654627, 179659205, 179848153, 179848203, 179848415, 179930265, 179936743, 179936852, 179942496, 179965835, 180015293, 180096359, 180096468, 180789380, 182209262, 182438142, 182516442, 182860908, 183314955, 183355145, 183565013, 183746202, 183970446, 184269528, 184327027, 184359255, 184360405, 185057920, 185393703, 185405431, 186057650, 186058299, 186325468, 188498026, 188714163, 192118902, 192796203, 193919365, 193947342, 193971479, 193971567, 193971908, 193972138, 193973221, 193975449, 194002589, 194003533, 194004216, 194060881, 194116470, 194125886, 194497396, 194939077, 195246292, 195314410, 195404163, 195489237, 196222661, 196269807, 196270383, 196270581, 196271217, 196271907, 196524776, 196584699, 196588801, 197800858, 197872508, 197872817, 198262641, 198439589, 198475036, 199788352, 199819506, 200113174, 200116104, 200121238, 200280910, 200595661, 200606534, 200613777, 201661227, 201663320, 201663467, 201664501, 201693153, 201693551, 201698392, 201701643, 201726181, 201727585, 201767917, 201983184, 201983223, 203209892, 203289934, 203294845, 203695911, 203720325, 203723447, 204061479, 204071275, 204073804, 204113779, 204339633, 204344395, 205005075, 205333914, 205904977, 205951017, 206624869, 207118252, 207119511, 207819508, 208186004, 208206831, 208598427, 208854942, 208978576, 209191450, 209226460, 209260139, 209260714, 209260788, 209536361, 209768906, 209842220, 209901120, 210340207, 210495239, 210495352, 210736452, 210993156, 210993185, 211136447, 211515349, 211532217, 211679972, 211680281, 211683762, 211685056, 211702584, 211750362, 212123418, 212138766, 212464051, 212821044, 212827049, 212880318, 213182009, 213390165, 213498323, 213500078, 213550108, 213550783, 213560223, 213611914, 213612663, 213615794, 213616333, 213985971, 214116086, 214250188, 214327469, 214516585, 214878420, 214921670, 215232482, 215629466, 216429141, 216753945, 217097347, 217254302, 217254350, 217255149, 217261805, 217353908, 217368373, 217577975, 217858968, 217861358, 217861775, 217870124, 218035890, 218151680, 218152225, 218226925, 218308954, 218310715, 218427885, 218487111, 218901089, 219107300, 219262211, 219365086, 219850254, 219850752, 219853753, 219855754, 219857662, 219857719, 219857745, 219866336, 220121187, 220143764, 220239069, 220239420, 220506626, 220517406, 220538568, 220569666, 220591655, 220594438, 220930761, 221991933, 222494768, 222524313, 222531414, 222549274, 222819820, 222956471, 222957209, 222959839, 223353228, 223787165, 223787707, 223816298, 223817123, 223830657, 223843184, 223843198, 223843537, 223846253, 224166708, 224166717, 224181940, 224187604, 224370573, 224425605, 224500725, 225107350, 225992552, 226440450, 226601638, 226631271, 226705720, 226857653, 227286088, 227625569, 228919196, 229089161, 229302993, 229304679, 229306819, 229308812, 229308845, 229308921, 229308970, 229318589, 229377578, 229633335, 229634225, 229744478, 229752962, 229762393, 229766882, 229797892, 230064028, 230066707, 230068635, 230108596, 230418679, 230481349, 230505778, 230557443, 230671018, 230742860, 230998258, 231011034, 231339347, 232028027, 232624610, 233345527, 233677970, 233912535, 234286379, 234805390, 235071861, 235822070, 235827111, 235871348, 236042631, 236244276, 236670801, 236975728, 236975762, 237287494, 237503349, 237577372, 237611438, 237623882, 237985610, 237990950, 238216886, 238306869, 239303427, 239347282, 239622698, 239844565, 240185296, 240339021, 241788273, 242120516, 242229784, 244247499, 244247799, 244250267, 244250365, 244250632, 244251977, 244711931, 245767677, 246988218, 247069230, 247849087, 248146041, 248224947, 248653369, 249031919, 249594532, 249643517, 249857912, 250004568, 250148121, 250703694, 250713852, 250918316, 250923151, 250973304, 250973693, 251330363, 251376342, 251591321, 251611421, 251708689, 252034766, 252693539, 253133244, 253187234, 253260363, 253506025, 253534123, 253534897, 253666405, 254279015, 254907574, 254931129, 255078460, 255404692, 255906524, 256040015, 256143571, 256410315, 256855263, 256947515, 257059335}; } \ No newline at end of file diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index a8664a09..dc0fd00a 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -154,6 +154,7 @@ namespace big functions::get_sync_type_info m_get_sync_type_info; functions::get_net_object m_get_net_object; functions::read_bitbuffer_into_sync_tree m_read_bitbuffer_into_sync_tree; + PVOID m_update_sync_tree; //Sync Signatures END PVOID m_receive_net_message; diff --git a/src/hooking/hooking.cpp b/src/hooking/hooking.cpp index 3553ac81..f97cfe24 100644 --- a/src/hooking/hooking.cpp +++ b/src/hooking/hooking.cpp @@ -61,6 +61,8 @@ namespace big detour_hook_helper::add("RCS", g_pointers->m_gta.m_received_clone_sync); detour_hook_helper::add("CAD", g_pointers->m_gta.m_can_apply_data); + detour_hook_helper::add("UST", g_pointers->m_gta.m_update_sync_tree); + detour_hook_helper::add("GNED", g_pointers->m_gta.m_get_network_event_data); detour_hook_helper::add("IDC", g_pointers->m_gta.m_invalid_decal_crash); diff --git a/src/hooking/hooking.hpp b/src/hooking/hooking.hpp index f75d85b1..5b784d13 100644 --- a/src/hooking/hooking.hpp +++ b/src/hooking/hooking.hpp @@ -107,7 +107,8 @@ namespace big static eAckCode received_clone_sync(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, eNetObjType object_type, uint16_t object_id, rage::datBitBuffer* bufer, uint16_t unk, uint32_t timestamp); static bool can_apply_data(rage::netSyncTree* tree, rage::netObject* object); - static void invalid_mods_crash_detour(int64_t a1, int64_t a2, int a3, char a4); + static void update_sync_tree(rage::netSyncTree* _this, rage::netObject* object, uint32_t flags, uint32_t timestamp, bool a5); + static void invalid_decal(uintptr_t a1, int a2); static int task_parachute_object(uint64_t _this, int a2, int a3); static int task_ambient_clips(uint64_t _this, int a2, int a3); diff --git a/src/hooks/protections/update_sync_tree.cpp b/src/hooks/protections/update_sync_tree.cpp new file mode 100644 index 00000000..14441ee0 --- /dev/null +++ b/src/hooks/protections/update_sync_tree.cpp @@ -0,0 +1,13 @@ +#include "hooking/hooking.hpp" +#include "pointers.hpp" + +namespace big +{ + void hooks::update_sync_tree(rage::netSyncTree* _this, rage::netObject* object, uint32_t flags, uint32_t timestamp, bool a5) + { + if (!object->GetSyncData()) [[unlikely]] + return; + + g_hooking->get_original()(_this, object, flags, timestamp, a5); + } +} \ No newline at end of file diff --git a/src/logger/exception_handler.cpp b/src/logger/exception_handler.cpp index d6a111ca..0f51ce76 100644 --- a/src/logger/exception_handler.cpp +++ b/src/logger/exception_handler.cpp @@ -87,6 +87,30 @@ namespace big else { exception_info->ContextRecord->Rip += opcode.len; + + if (opcode.opcode == 0x8B && opcode.modrm_mod != 3) // MOV + { + uint8_t reg_id = opcode.rex_r << 3 | opcode.modrm_reg; + switch (reg_id) + { + case 0: exception_info->ContextRecord->Rax = 0; break; + case 1: exception_info->ContextRecord->Rcx = 0; break; + case 2: exception_info->ContextRecord->Rdx = 0; break; + case 3: exception_info->ContextRecord->Rbx = 0; break; + case 4: exception_info->ContextRecord->Rsp = 0; break; + case 5: exception_info->ContextRecord->Rbp = 0; break; + case 6: exception_info->ContextRecord->Rsi = 0; break; + case 7: exception_info->ContextRecord->Rdi = 0; break; + case 8: exception_info->ContextRecord->R8 = 0; break; + case 9: exception_info->ContextRecord->R9 = 0; break; + case 10: exception_info->ContextRecord->R10 = 0; break; + case 11: exception_info->ContextRecord->R11 = 0; break; + case 12: exception_info->ContextRecord->R12 = 0; break; + case 13: exception_info->ContextRecord->R13 = 0; break; + case 14: exception_info->ContextRecord->R14 = 0; break; + case 15: exception_info->ContextRecord->R15 = 0; break; + } + } } } diff --git a/src/pointers.cpp b/src/pointers.cpp index eaeb7ec5..af71707c 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -3,6 +3,8 @@ #include "gta_pointers_layout_info.hpp" #include "sc_pointers_layout_info.hpp" +#define GTA_VERSION_TARGET "1.69-3274" + namespace big { constexpr auto pointers::get_gta_batch() @@ -449,6 +451,15 @@ namespace big g_pointers->m_gta.m_read_bitbuffer_into_sync_tree = ptr.add(1).rip().as(); } }, + // Update Sync Tree + { + "UST", + "E8 ? ? ? ? 45 84 ED 75 1B", + [](memory::handle ptr) + { + g_pointers->m_gta.m_update_sync_tree = ptr.add(1).rip().as(); + } + }, // Model Hash Table { "MHT", @@ -2024,7 +2035,8 @@ namespace big pointers::pointers() : m_gta_pointers_cache(g_file_manager.get_project_file("./cache/gta_pointers.bin")), - m_sc_pointers_cache(g_file_manager.get_project_file("./cache/sc_pointers.bin")) + m_sc_pointers_cache(g_file_manager.get_project_file("./cache/sc_pointers.bin")), + m_gta_version_target(GTA_VERSION_TARGET) { g_pointers = this; diff --git a/src/pointers.hpp b/src/pointers.hpp index 61641dc2..9f658cea 100644 --- a/src/pointers.hpp +++ b/src/pointers.hpp @@ -107,9 +107,26 @@ namespace big { if (!memory::batch_runner::run(batch, mem_region)) { - const std::string error_message = - std::string("Failed to find some patterns for ") + std::string(batch_name.str); - throw std::runtime_error(error_message); + auto message = std::format("Failed to find some patterns for {}", batch_name.str); + + if (m_gta.m_online_version && m_gta.m_game_version) + { + auto gta_version = std::format("{}-{}", m_gta.m_online_version, m_gta.m_game_version); + + if (gta_version != m_gta_version_target) + message = std::format("{} (Note: Found game version {} but this YimMenu version is for game version {})", message, gta_version, m_gta_version_target); + } + + LOG(FATAL) << message; + + if (!m_gta.m_is_session_started || !*m_gta.m_is_session_started) // AC not bypassed yet so exit directly when online + { + MessageBoxA(m_hwnd, message.c_str(), "YimMenu", MB_ICONWARNING | MB_TOPMOST); + } + + Logger::FlushQueue(); + + std::exit(EXIT_FAILURE); } } @@ -121,6 +138,8 @@ namespace big cache_file m_gta_pointers_cache; cache_file m_sc_pointers_cache; + const char* m_gta_version_target; + public: HWND m_hwnd{}; diff --git a/src/services/context_menu/context_menu_service.cpp b/src/services/context_menu/context_menu_service.cpp index 71cbfe11..cbd2b3e9 100644 --- a/src/services/context_menu/context_menu_service.cpp +++ b/src/services/context_menu/context_menu_service.cpp @@ -137,7 +137,7 @@ namespace big { if (m_pointer && m_pointer->m_model_info) { - switch (m_pointer->m_model_info->m_model_type) + switch (m_pointer->m_model_info->get_model_type()) { case eModelType::Object: { @@ -147,7 +147,6 @@ namespace big } return &options.at(ContextEntityType::OBJECT); } - case eModelType::OnlineOnlyPed: case eModelType::Ped: { if (const auto ped = reinterpret_cast(m_pointer); ped) diff --git a/src/services/hotkey/hotkey_service.cpp b/src/services/hotkey/hotkey_service.cpp index 92de8031..28641eda 100644 --- a/src/services/hotkey/hotkey_service.cpp +++ b/src/services/hotkey/hotkey_service.cpp @@ -102,6 +102,42 @@ namespace big || g.settings.hotkeys.is_mp_chat_active) return; + switch (state) + { + case WM_LBUTTONUP: + state = eKeyState::RELEASE; + key = VK_LBUTTON; + break; + case WM_RBUTTONUP: + state = eKeyState::RELEASE; + key = VK_RBUTTON; + break; + case WM_MBUTTONUP: + state = eKeyState::RELEASE; + key = VK_MBUTTON; + break; + case WM_XBUTTONUP: + state = eKeyState::RELEASE; + key = GET_XBUTTON_WPARAM(key) == XBUTTON1 ? VK_XBUTTON1 : VK_XBUTTON2; + break; + case WM_LBUTTONDOWN: + state = eKeyState::DOWN; + key = VK_LBUTTON; + break; + case WM_RBUTTONDOWN: + state = eKeyState::DOWN; + key = VK_RBUTTON; + break; + case WM_MBUTTONDOWN: + state = eKeyState::DOWN; + key = VK_MBUTTON; + break; + case WM_XBUTTONDOWN: + state = eKeyState::DOWN; + key = GET_XBUTTON_WPARAM(key) == XBUTTON1 ? VK_XBUTTON1 : VK_XBUTTON2; + break; + } + if (state == eKeyState::RELEASE || state == eKeyState::DOWN) { auto& hotkey_map = m_hotkeys[state == eKeyState::RELEASE]; diff --git a/src/util/entity.cpp b/src/util/entity.cpp index 29308c68..92f7848e 100644 --- a/src/util/entity.cpp +++ b/src/util/entity.cpp @@ -169,19 +169,19 @@ namespace big::entity auto hnd = g_pointers->m_gta.m_handle_to_ptr(ent); - if (!hnd || !hnd->m_net_object || !*g_pointers->m_gta.m_is_session_started) + if (!hnd || !hnd->m_net_object) return false; - if (network_has_control_of_entity(hnd->m_net_object)) - return true; + if (hnd->m_entity_type != 3 && hnd->m_entity_type != 4 && hnd->m_entity_type != 5) + return false; - for (int i = 0; i < timeout; i++) + for (int i = 0; i <= timeout; ++i) { - g_pointers->m_gta.m_request_control(hnd->m_net_object); - if (network_has_control_of_entity(hnd->m_net_object)) return true; + g_pointers->m_gta.m_request_control(hnd->m_net_object); + if (timeout != 0) script::get_current()->yield(); } diff --git a/src/util/fuzzer.hpp b/src/util/fuzzer.hpp index 820873e5..81d3582b 100644 --- a/src/util/fuzzer.hpp +++ b/src/util/fuzzer.hpp @@ -21,7 +21,7 @@ namespace big::fuzzer inline bool is_object_model(rage::joaat_t hash) { - return model_info::is_model_of_type(hash, eModelType::Object, eModelType::Time, eModelType::Weapon, eModelType::Destructable, eModelType::WorldObject, eModelType::Sprinkler, eModelType::Unk65, eModelType::LOD, eModelType::Unk132, eModelType::Building); + return model_info::is_model_of_type(hash, eModelType::Object, eModelType::Time, eModelType::Weapon, eModelType::Destructable); } inline rage::joaat_t get_mismatched_model(rage::joaat_t original) @@ -44,7 +44,7 @@ namespace big::fuzzer if (is_object_model(original)) std::erase(models, "apa_heist_apart2_door"_J); - else if (info && info->m_model_type == eModelType::Vehicle) + else if (info && info->get_model_type() == eModelType::Vehicle) { if (veh_model->m_vehicle_type == eVehicleType::VEHICLE_TYPE_BIKE) std::erase(models, "faggio"_J); @@ -61,7 +61,7 @@ namespace big::fuzzer else std::erase(models, "zentorno"_J); } - else if (info && (info->m_model_type == eModelType::Ped || info->m_model_type == eModelType::OnlineOnlyPed)) + else if (info && (info->get_model_type() == eModelType::Ped)) std::erase(models, "player_zero"_J); return models[math::rand(models.size())]; @@ -73,9 +73,9 @@ namespace big::fuzzer if (is_object_model(original)) return "urbanweeds01"_J; - else if (info && (info->m_model_type == eModelType::Ped || info->m_model_type == eModelType::OnlineOnlyPed)) + else if (info && (info->get_model_type() == eModelType::Ped)) return "slod_human"_J; - else if (info && info->m_model_type == eModelType::Vehicle) + else if (info && info->get_model_type() == eModelType::Vehicle) return "arbitergt"_J; else return math::rand(2) ? "urbanweeds01"_J : "slod_human"_J; @@ -126,9 +126,9 @@ namespace big::fuzzer if (is_object_model(entity->m_model_info->m_hash)) return math::rand(2) ? get_first_ped_id() : get_first_veh_id(); - else if (entity->m_model_info->m_model_type == eModelType::Ped || entity->m_model_info->m_model_type == eModelType::OnlineOnlyPed) + else if (entity->m_model_info->get_model_type() == eModelType::Ped) return math::rand(2) ? get_first_obj_id() : get_first_veh_id(); - else if (entity->m_model_info->m_model_type == eModelType::Vehicle) + else if (entity->m_model_info->get_model_type() == eModelType::Vehicle) return math::rand(2) ? get_first_obj_id() : get_first_ped_id(); return math::rand(2) ? get_first_ped_id() : get_first_veh_id(); diff --git a/src/util/model_info.hpp b/src/util/model_info.hpp index 576d7821..b52e8413 100644 --- a/src/util/model_info.hpp +++ b/src/util/model_info.hpp @@ -13,7 +13,7 @@ namespace big { if (const auto table_idx = node->m_idx; table_idx < m_model_table->m_size) { - if (const auto model = m_model_table->m_data[table_idx]; model && model->m_model_type == eModelType::Vehicle) + if (const auto model = m_model_table->m_data[table_idx]; model && model->get_model_type() == eModelType::Vehicle) { } @@ -50,7 +50,7 @@ namespace big static CVehicleModelInfo* get_vehicle_model(const rage::joaat_t hash) { - if (const auto model = model_info::get_model(hash); model && model->m_model_type == eModelType::Vehicle) + if (const auto model = model_info::get_model(hash); model && model->get_model_type() == eModelType::Vehicle) return model; return nullptr; } @@ -61,10 +61,10 @@ namespace big bool of_type = false; if (const auto model = model_info::get_model(hash)) { - of_type = model->m_model_type == arg; + of_type = model->get_model_type() == arg; ( [&of_type, &model](eModelType type) { - of_type |= model->m_model_type == type; + of_type |= model->get_model_type() == type; }(args), ...); } diff --git a/src/util/protection.cpp b/src/util/protection.cpp index 7ffe2ea0..e351d47e 100644 --- a/src/util/protection.cpp +++ b/src/util/protection.cpp @@ -11,7 +11,7 @@ namespace big::protection return true; if (!model_info::get_model(model)) return false; - if (!model_info::is_model_of_type(model, eModelType::Object, eModelType::Time, eModelType::Weapon, eModelType::Destructable, eModelType::WorldObject, eModelType::Sprinkler, eModelType::Unk65, eModelType::Plant, eModelType::LOD, eModelType::Unk132, eModelType::Building)) + if (!model_info::is_model_of_type(model, eModelType::Object, eModelType::Time, eModelType::Weapon, eModelType::Destructable)) return true; return false; } @@ -21,7 +21,7 @@ namespace big::protection { if (crash_peds.contains(model)) return true; - if (!model_info::is_model_of_type(model, eModelType::Ped, eModelType::OnlineOnlyPed)) + if (!model_info::is_model_of_type(model, eModelType::Ped)) return true; return false; } @@ -31,7 +31,7 @@ namespace big::protection { if (crash_vehicles.contains(model)) return true; - if (!model_info::is_model_of_type(model, eModelType::Vehicle, eModelType::Unk133)) + if (!model_info::is_model_of_type(model, eModelType::Vehicle)) return true; return false; } diff --git a/src/util/teleport.hpp b/src/util/teleport.hpp index 390e6419..045c1913 100644 --- a/src/util/teleport.hpp +++ b/src/util/teleport.hpp @@ -1,6 +1,7 @@ #pragma once #include "blip.hpp" #include "entity.hpp" +#include "fiber_pool.hpp" #include "gta/enums.hpp" #include "services/players/player_service.hpp" #include "vehicle.hpp" @@ -98,20 +99,28 @@ namespace big::teleport { script::get_current()->yield(25ms); - if (auto ptr = (rage::CDynamicEntity*)g_pointers->m_gta.m_handle_to_ptr(hnd)) - { - if (auto netobj = ptr->m_net_object) - { - g_pointers->m_gta.m_migrate_object(player->get_net_game_player(), netobj, 3); - } - } + auto ptr = (rage::CDynamicEntity*)g_pointers->m_gta.m_handle_to_ptr(hnd); + + if (!ptr || !ptr->m_net_object) + break; + + auto plyr = player->get_net_game_player(); + + if (!plyr) + break; + + g_pointers->m_gta.m_migrate_object(plyr, ptr->m_net_object, 3); auto new_coords = ENTITY::GET_ENTITY_COORDS(hnd, true); if (SYSTEM::VDIST2(coords.x, coords.y, coords.z, new_coords.x, new_coords.y, new_coords.z) < 20 * 20 && VEHICLE::GET_PED_IN_VEHICLE_SEAT(hnd, 0, true) == ent) break; } - entity::delete_entity(hnd); + g_fiber_pool->queue_job([hnd] { + auto ent = hnd; + entity::take_control_of(ent); + entity::delete_entity(ent); + }); std::erase_if(g.m_remote_player_teleports, [veh_id](auto& obj) { return obj.first == veh_id; diff --git a/src/views/core/view_cmd_executor.cpp b/src/views/core/view_cmd_executor.cpp index 10db0087..7c60755d 100644 --- a/src/views/core/view_cmd_executor.cpp +++ b/src/views/core/view_cmd_executor.cpp @@ -601,7 +601,7 @@ namespace big if (components::input_text_with_hint("", "CMD_EXECUTOR_TYPE_CMD"_T, command_buffer, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackAlways, nullptr, input_callback)) { if (!s_buffer.get_command_of_index(cursor_pos)) - return; + goto VIEW_END; if (command::process(command_buffer, std::make_shared(), false)) { diff --git a/src/views/esp/view_esp.cpp b/src/views/esp/view_esp.cpp index 73110007..8713e99c 100644 --- a/src/views/esp/view_esp.cpp +++ b/src/views/esp/view_esp.cpp @@ -18,10 +18,12 @@ namespace big void esp::draw_player(const player_ptr& plyr, ImDrawList* const draw_list) { - if (!plyr->is_valid() || !plyr->get_ped() || !plyr->get_ped()->m_navigation) + auto ped = plyr->get_ped(); + + if (!ped || !ped->m_navigation) return; - auto& player_pos = *plyr->get_ped()->m_navigation->get_position(); + auto& player_pos = *ped->m_navigation->get_position(); float screen_x, screen_y; @@ -31,7 +33,7 @@ namespace big if (multplr == -1.f || g.esp.global_render_distance[0] > distance) return; - uint32_t ped_damage_bits = plyr->get_ped()->m_damage_bits; + uint32_t ped_damage_bits = ped->m_damage_bits; if (g_pointers->m_gta.m_get_screen_coords_for_world_coords(player_pos.data, &screen_x, &screen_y)) { @@ -54,8 +56,8 @@ namespace big esp_color = g.esp.enemy_near_color; } - const auto armor_perc = plyr->get_ped()->m_armor / 50.f; - const auto health_perc = plyr->get_ped()->m_health / (plyr->get_ped()->m_maxhealth + 0.001f); + const auto armor_perc = ped->m_armor / 50.f; + const auto health_perc = ped->m_health / (ped->m_maxhealth + 0.001f); if (distance < g.esp.tracer_render_distance[1] && distance > g.esp.tracer_render_distance[0] && g.esp.tracer) draw_list->AddLine({(float)*g_pointers->m_gta.m_resolution_x * g.esp.tracer_draw_position[0], @@ -100,8 +102,8 @@ namespace big } } - if (auto player_vehicle = plyr->get_current_vehicle(); player_vehicle && (plyr->get_ped()->m_ped_task_flag & (uint32_t)ePedTask::TASK_DRIVING) - && (player_vehicle->m_damage_bits & (uint32_t)eEntityProofs::GOD)) + if (auto player_vehicle = plyr->get_current_vehicle(); + player_vehicle && (ped->m_ped_task_flag & (uint32_t)ePedTask::TASK_DRIVING) && (player_vehicle->m_damage_bits & (uint32_t)eEntityProofs::GOD)) { if (!mode_str.empty()) mode_str += ", "; @@ -153,7 +155,7 @@ namespace big 4); } } - if (g.esp.armor && plyr->get_ped()->m_armor > 0) + if (g.esp.armor && ped->m_armor > 0) { float offset = 5.f; offset = g.esp.health ? 10.f : 5.f; @@ -177,11 +179,10 @@ namespace big if (!g.esp.enabled) return; - if (const auto draw_list = ImGui::GetBackgroundDrawList(); draw_list) - { - g_player_service->iterate([draw_list](const player_entry& entry) { - draw_player(entry.second, draw_list); - }); - } + const auto draw_list = ImGui::GetBackgroundDrawList(); + + g_player_service->iterate([draw_list](const player_entry& entry) { + draw_player(entry.second, draw_list); + }); } } \ No newline at end of file