Bug fixes and improvements (#3324)

* feat: handle exceptions on jumps correctly
* fix(player_db): fix invite player
* fix: remove old stuff
* fix(script__vm): fix script vm crashes
* remove debug code
* fix(scr_globals): fix globals and locals
This commit is contained in:
Mr-X-GTA 2024-07-10 13:43:39 +02:00 committed by GitHub
parent 270ff255c2
commit 4b73782c27
19 changed files with 46 additions and 65 deletions

View File

@ -28,14 +28,9 @@ namespace big
cmd.m_num_peers = 1;
cmd.m_handles[0] = player->get_net_data()->m_gamer_handle;
if (g.session.show_cheating_message)
cmd.m_unk = 19;
g_pointers->m_gta.m_handle_remove_gamer_cmd(gta_util::get_network()->m_game_session_ptr, player->get_session_player(), &cmd);
}
};
breakup_kick g_breakup_kick("breakup", "BREAKUP_KICK", "BREAKUP_KICK_DESC", 0, false);
bool_command g_show_cheating_message("breakupcheating", "BREAKUP_KICK_SHOW_CHEATING", "BREAKUP_KICK_SHOW_CHEATING_DESC",
g.session.show_cheating_message);
}

View File

@ -19,14 +19,14 @@ namespace big
{
if (g_player_service->get_self()->is_host())
{
dynamic_cast<player_command*>(command::get("breakup"_J))->call(player, {});
player_command::get("breakup"_J)->call(player, {});
}
else
{
if (player->is_host())
dynamic_cast<player_command*>(command::get("oomkick"_J))->call(player, {});
player_command::get("oomkick"_J)->call(player, {});
else
dynamic_cast<player_command*>(command::get("desync"_J))->call(player, {});
player_command::get("desync"_J)->call(player, {});
}
}
};

View File

@ -14,7 +14,7 @@ namespace big
virtual void on_tick() override
{
if (g.self.ghost_org)
MISC::SET_BIT(scr_globals::freemode_global.at(4667).as<int*>(), 2);
MISC::SET_BIT(scr_globals::freemode_global.at(4682).as<int*>(), 2);
scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[self::id].OffRadarActive = true;
*scr_globals::freemode_properties.at(58).as<int*>() = NETWORK::GET_NETWORK_TIME() + 1;
}
@ -22,7 +22,7 @@ namespace big
virtual void on_disable() override
{
if (!g.self.ghost_org)
MISC::CLEAR_BIT(scr_globals::freemode_global.at(4667).as<int*>(), 2);
MISC::CLEAR_BIT(scr_globals::freemode_global.at(4682).as<int*>(), 2);
scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[self::id].OffRadarActive = false;
}
};

View File

@ -18,7 +18,7 @@ namespace big
if (plyr.second->is_host())
{
dynamic_cast<player_command*>(command::get("smartkick"_J))->call(plyr.second, {});
player_command::get("smartkick"_J)->call(plyr.second, {});
}
});
}

View File

@ -8,8 +8,8 @@ namespace big
{
void looped::system_self_globals()
{
if (!*g_pointers->m_gta.m_network_player_mgr || !(*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player
|| (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id == -1) [[unlikely]]
if (!(*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player
|| (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id == static_cast<uint8_t>(-1)) [[unlikely]]
self::id = 0;
else [[likely]]
self::id = (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id;

View File

@ -34,7 +34,7 @@ namespace big
if (kick)
{
g_fiber_pool->queue_job([player] {
dynamic_cast<player_command*>(command::get("smartkick"_J))->call(player, {});
player_command::get("smartkick"_J)->call(player, {});
});
}

View File

@ -8,7 +8,7 @@ namespace big::scr_globals
static inline const script_global gsbd_fm(1845281);
static inline const script_global gsbd_kicking(1877042);
static inline const script_global gsbd_fm_events(1916617);
static inline const script_global gsbd_block_c(2657971);
static inline const script_global gsbd_block_c(2652592);
static inline const script_global gsbd_property_instances(1936863);
static inline const script_global globalplayer_bd(2657971);
@ -71,7 +71,7 @@ namespace big::scr_locals
{
namespace am_hunt_the_beast
{
constexpr static auto broadcast_idx = 607; // (bParam0) != 0;
constexpr static auto broadcast_idx = 604; // (bParam0) != 0;
constexpr static auto player_broadcast_idx = 2588; // if (NETWORK::PARTICIPANT_ID_TO_INT() != -1)
}

View File

@ -192,13 +192,10 @@ namespace big
pair send_net_info_to_lobby{};
pair transaction_rate_limit{};
pair mismatch_sync_type{};
pair out_of_allowed_range_sync_type{};
pair invalid_sync{};
bool warn_metric = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(notifications, gta_thread_kill, gta_thread_start, network_player_mgr_init, network_player_mgr_shutdown, player_join, player_leave, send_net_info_to_lobby, transaction_rate_limit, mismatch_sync_type, out_of_allowed_range_sync_type, invalid_sync, warn_metric)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(notifications, gta_thread_kill, gta_thread_start, network_player_mgr_init, network_player_mgr_shutdown, player_join, player_leave, send_net_info_to_lobby, transaction_rate_limit, warn_metric)
} notifications{};
struct reactions
@ -305,9 +302,8 @@ namespace big
bool vehicle_kick = true;
bool teleport_to_warehouse = true;
bool start_activity = true;
bool send_sms = true;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(script_events, bounty, ceo_money, clear_wanted_level, force_mission, force_teleport, gta_banner, mc_teleport, personal_vehicle_destroyed, remote_off_radar, rotate_cam, send_to_cutscene, send_to_location, sound_spam, spectate, give_collectible, vehicle_kick, teleport_to_warehouse, start_activity, send_sms)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(script_events, bounty, ceo_money, clear_wanted_level, force_mission, force_teleport, gta_banner, mc_teleport, personal_vehicle_destroyed, remote_off_radar, rotate_cam, send_to_cutscene, send_to_location, sound_spam, spectate, give_collectible, vehicle_kick, teleport_to_warehouse, start_activity)
} script_events{};
bool rid_join = false;
@ -360,7 +356,6 @@ namespace big
bool no_water_collision = false;
int wanted_level = 0;
bool god_mode = false;
bool part_water = false;
bool proof_bullet = false;
bool proof_fire = false;
bool proof_collision = false;
@ -418,7 +413,7 @@ namespace big
NLOHMANN_DEFINE_TYPE_INTRUSIVE(super_hero_fly, gradual, explosions, auto_land, charge, ptfx, fly_speed, initial_launch)
} super_hero_fly{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(self, ipls, ptfx_effects, clean_player, never_wanted, force_wanted_level, passive, free_cam, invisibility, local_visibility, no_ragdoll, noclip, noclip_aim_speed_multiplier, noclip_speed_multiplier, off_radar, super_run, no_collision, unlimited_oxygen, no_water_collision, wanted_level, god_mode, part_water, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_water, proof_mask, mobile_radio, fast_respawn, auto_tp, super_jump, beast_jump, healthregen, healthregenrate, hud, superman, custom_weapon_stop, prompt_ambient_animations, persist_outfit, persist_outfits_mis, interaction_menu_freedom, super_hero_fly)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(self, ipls, ptfx_effects, clean_player, never_wanted, force_wanted_level, passive, free_cam, invisibility, local_visibility, no_ragdoll, noclip, noclip_aim_speed_multiplier, noclip_speed_multiplier, off_radar, super_run, no_collision, unlimited_oxygen, no_water_collision, wanted_level, god_mode, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_water, proof_mask, mobile_radio, fast_respawn, auto_tp, super_jump, beast_jump, healthregen, healthregenrate, hud, superman, custom_weapon_stop, prompt_ambient_animations, persist_outfit, persist_outfits_mis, interaction_menu_freedom, super_hero_fly)
} self{};
@ -484,7 +479,6 @@ namespace big
bool harass_players = false;
bool spam_killfeed = false;
bool show_cheating_message = false;
bool anonymous_bounty = true;
bool fast_join = false;
@ -501,7 +495,7 @@ namespace big
NLOHMANN_DEFINE_TYPE_INTRUSIVE(chat_translator, enabled, print_result, draw_result, bypass_same_language, target_language, endpoint);
} chat_translator{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(session, log_chat_messages, log_text_messages, decloak_players, spoof_host_token_type, custom_host_token, hide_token_spoofing_when_host, force_script_host, player_magnet_enabled, player_magnet_count, is_team, join_in_sctv_slots, kick_host_when_forcing_host, explosion_karma, damage_karma, disable_traffic, disable_peds, force_thunder, block_ceo_money, randomize_ceo_colors, block_jobs, block_muggers, block_ceo_raids, block_ceo_creation, send_to_apartment_idx, send_to_warehouse_idx, chat_commands, chat_command_default_access_level, show_cheating_message, anonymous_bounty, lock_session, fast_join, unhide_players_from_player_list, allow_friends_into_locked_session, trust_friends, use_spam_timer, spam_timer, spam_length, chat_translator, script_block_opts)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(session, log_chat_messages, log_text_messages, decloak_players, spoof_host_token_type, custom_host_token, hide_token_spoofing_when_host, force_script_host, player_magnet_enabled, player_magnet_count, is_team, join_in_sctv_slots, kick_host_when_forcing_host, explosion_karma, damage_karma, disable_traffic, disable_peds, force_thunder, block_ceo_money, randomize_ceo_colors, block_jobs, block_muggers, block_ceo_raids, block_ceo_creation, send_to_apartment_idx, send_to_warehouse_idx, chat_commands, chat_command_default_access_level, anonymous_bounty, lock_session, fast_join, unhide_players_from_player_list, allow_friends_into_locked_session, trust_friends, use_spam_timer, spam_timer, spam_length, chat_translator, script_block_opts)
} session{};
struct settings
@ -538,9 +532,8 @@ namespace big
int repairpv = 0;
int open_vehicle_controller = 0;
int clear_wanted = 0;
int random_ped_components = 0;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(hotkeys, editing_menu_toggle, menu_toggle, teleport_waypoint, teleport_objective, teleport_selected, teleport_pv, noclip, vehicle_flymode, bringvehicle, invis, heal, fill_inventory, skip_cutscene, freecam, superrun, passive, superjump, beastjump, invisveh, localinvisveh, fill_ammo, fast_quit, cmd_excecutor, repairpv, open_vehicle_controller, clear_wanted, random_ped_components)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(hotkeys, editing_menu_toggle, menu_toggle, teleport_waypoint, teleport_objective, teleport_selected, teleport_pv, noclip, vehicle_flymode, bringvehicle, invis, heal, fill_inventory, skip_cutscene, freecam, superrun, passive, superjump, beastjump, invisveh, localinvisveh, fill_ammo, fast_quit, cmd_excecutor, repairpv, open_vehicle_controller, clear_wanted)
} hotkeys{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(settings, hotkeys, dev_dlc, onboarding_complete)
@ -597,13 +590,6 @@ namespace big
bool derail_train = false;
} train{};
struct water
{
bool part_water = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(water, part_water)
} water{};
struct gravity
{
bool modify_gravity = false;
@ -699,7 +685,7 @@ namespace big
bool blackout = false;
bool ground_snow = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(world, water, spawn_ped, custom_time, blackhole, model_swapper, nearby, orbital_drone, local_weather, override_weather, blackout, ground_snow)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(world, spawn_ped, custom_time, blackhole, model_swapper, nearby, orbital_drone, local_weather, override_weather, blackout, ground_snow)
} world{};
struct spoofing
@ -723,7 +709,6 @@ namespace big
bool spoof_player_model = false;
std::string player_model = "";
std::string player_outfit = "";
bool spoof_cheater = false;

View File

@ -130,7 +130,7 @@ namespace big::functions
using start_get_presence_attributes = bool (*)(int profile_index, rage::rlScHandle* handle, int num_handles, rage::rlQueryPresenceAttributesContext** contexts, int count, rage::rlScTaskStatus* state);
using join_session_by_info = bool (*)(Network* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int handlecount);
using invite_player_by_gamer_handle = bool (*)(uint64_t config, rage::rlGamerHandle* handle, int unk1, int unk2, int unk3, int unk4);
using invite_player_by_gamer_handle = bool (*)(Network* network, rage::rlGamerHandle* handles, int handlecount, const char* subject, const char* msg, rage::rlTaskStatus* state);
using add_friend_by_gamer_handle = void (*)(rage::rlGamerHandle* handle, const char* unk);
using show_profile_by_gamer_handle = void (*)(rage::rlGamerHandle* handle);

View File

@ -169,7 +169,6 @@ namespace big
functions::invite_player_by_gamer_handle m_invite_player_by_gamer_handle;
functions::add_friend_by_gamer_handle m_add_friend_by_gamer_handle;
functions::show_profile_by_gamer_handle m_show_profile_by_gamer_handle;
uint64_t m_network_config;
functions::reset_network_complaints m_reset_network_complaints;

View File

@ -57,7 +57,7 @@ namespace big
template<template_str cmd_str, ImVec2 size = ImVec2(0, 0), ImVec4 color = ImVec4(0.24f, 0.23f, 0.29f, 1.00f)>
static void player_command_button(player_ptr player = g_player_service->get_selected(), const std::vector<uint64_t> args = {}, std::optional<const std::string_view> label_override = std::nullopt)
{
static player_command* command = dynamic_cast<player_command*>(command::get(rage::joaat(cmd_str.value)));
static player_command* command = player_command::get(rage::joaat(cmd_str.value));
if (command == nullptr)
return ImGui::Text("INVALID COMMAND");
@ -70,7 +70,7 @@ namespace big
template<template_str cmd_str>
static bool command_checkbox(std::optional<const std::string_view> label_override = std::nullopt)
{
static bool_command* command = dynamic_cast<bool_command*>(command::get(rage::joaat(cmd_str.value)));
static bool_command* command = static_cast<bool_command*>(command::get(rage::joaat(cmd_str.value)));
if (command == nullptr)
{
ImGui::Text("INVALID COMMAND");

View File

@ -115,7 +115,7 @@ namespace big
}
if (plyr->block_join && *g_pointers->m_gta.m_is_session_started)
dynamic_cast<player_command*>(command::get("smartkick"_J))->call(plyr, {});
player_command::get("smartkick"_J)->call(plyr, {});
if (is_spoofed_host_token(plyr->get_net_data()))
{

View File

@ -69,8 +69,26 @@ namespace big
LOG(FATAL) << "Cannot resume execution, crashing";
return EXCEPTION_CONTINUE_SEARCH;
}
if (opcode.opcode == 0xFF && opcode.modrm_reg == 4) // JMP (FF /4)
{
auto return_address_ptr = (uint64_t*)exception_info->ContextRecord->Rsp;
if (IsBadReadPtr(reinterpret_cast<void*>(return_address_ptr), 8))
{
LOG(FATAL) << "Cannot resume execution, crashing";
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
exception_info->ContextRecord->Rip = *return_address_ptr;
exception_info->ContextRecord->Rsp += 8;
}
}
else
{
exception_info->ContextRecord->Rip += opcode.len;
}
}
return EXCEPTION_CONTINUE_EXECUTION;
}

View File

@ -481,7 +481,7 @@ namespace big
// Network
{
"N",
"48 8B 0D ? ? ? ? 48 8B D7 E8 ? ? ? ? 84 C0 75 17 48 8B 0D ? ? ? ? 48 8B D7",
"48 8B 0D ? ? ? ? 45 33 C9 48 8B D7",
[](memory::handle ptr)
{
g_pointers->m_gta.m_network = ptr.add(3).rip().as<Network**>();
@ -617,15 +617,6 @@ namespace big
g_pointers->m_gta.m_show_profile_by_gamer_handle = ptr.add(1).rip().as<functions::show_profile_by_gamer_handle>();
}
},
// Network Config
{
"NC",
"48 8B 0D ? ? ? ? 45 33 C9 48 8B D7",
[](memory::handle ptr)
{
g_pointers->m_gta.m_network_config = ptr.add(3).rip().as<uint64_t>();
}
},
// Script VM
{
"VM",

View File

@ -132,7 +132,7 @@ namespace big
[this] {
if (ped::get_player_from_ped(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0)) != NULL)
{
static player_command* command = dynamic_cast<player_command*>(command::get("vehkick"_J));
static player_command* command = player_command::get("vehkick"_J);
command->call(ped::get_player_from_ped(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0)), {});
}
@ -205,17 +205,17 @@ namespace big
}},
{"KICK",
[this] {
static player_command* command = dynamic_cast<player_command*>(command::get("smartkick"_J));
static player_command* command = player_command::get("smartkick"_J);
command->call(ped::get_player_from_ped(m_handle), {});
script::get_current()->yield(500ms);
}},
{"DISARM",
[this] {
static player_command* command = dynamic_cast<player_command*>(command::get("remweaps"_J));
static player_command* command = player_command::get("remweaps"_J);
command->call(ped::get_player_from_ped(m_handle), {});
}},
{"RAGDOLL", [this] {
static player_command* command = dynamic_cast<player_command*>(command::get("ragdoll"_J));
static player_command* command = player_command::get("ragdoll"_J);
command->call(ped::get_player_from_ped(m_handle), {});
}}
}};

View File

@ -152,7 +152,7 @@ namespace big::session
{
rage::rlGamerHandle player_handle(rid);
bool success = g_pointers->m_gta.m_invite_player_by_gamer_handle(g_pointers->m_gta.m_network_config, &player_handle, 1, 0, 0, 0);
bool success = g_pointers->m_gta.m_invite_player_by_gamer_handle(*g_pointers->m_gta.m_network, &player_handle, 1, nullptr, nullptr, nullptr);
if (!success)
return g_notification_service.push_error("GUI_TAB_NETWORK"_T.data(), "RID_JOINER_INVITE_OFFLINE"_T.data());

View File

@ -16,9 +16,6 @@ namespace big
ImGui::SameLine();
components::player_command_button<"breakup">(g_player_service->get_selected());
ImGui::EndDisabled();
ImGui::SameLine();
components::command_checkbox<"breakupcheating">();
components::player_command_button<"smartkick">(g_player_service->get_selected());
ImGui::SameLine();

View File

@ -40,7 +40,6 @@ namespace big
ImGui::SameLine();
ImGui::BeginGroup();
ImGui::Checkbox("SEND_SMS"_T.data(), &g.protections.script_events.send_sms);
ImGui::Checkbox("SPECTATE"_T.data(), &g.protections.script_events.spectate);
ImGui::Checkbox("VEHICLE_KICK"_T.data(), &g.protections.script_events.vehicle_kick);
ImGui::Checkbox("WANTED_LEVEL"_T.data(), &g.protections.script_events.clear_wanted_level);

View File

@ -186,9 +186,6 @@ namespace big
components::sub_title("SETTINGS_NOTIFY_OTHER"_T);
draw_pair_option("SETTINGS_NOTIFY_TRANSACTION_RATE_LIMIT"_T, g.notifications.transaction_rate_limit);
draw_pair_option("SETTINGS_NOTIFY_MISMATCH_SYNC_TYPE"_T, g.notifications.mismatch_sync_type);
draw_pair_option("SETTINGS_NOTIFY_OUT_OF_ALLOWED_RANGE_SYNC_TYPE"_T, g.notifications.out_of_allowed_range_sync_type);
draw_pair_option("SETTINGS_NOTIFY_INVALID_SYNC"_T, g.notifications.invalid_sync);
}
}