mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
74ecf22ecf
* Complete player and network UI redesign, meant to show all features instead of stuffing them into tiny boxes * Added option to delete player vehicles * Better clone player (now clones head blend too) * Better host token spoofing, with an option to enter your own * Better host token spoofing detection * Better desync kick prot detections * A script blocker for the entire session (per-player options will be added later) * Added option to spoof data/DLC hashes * Logging framework that allows developers to easily debug false positives * Major protection improvements
136 lines
2.9 KiB
C++
136 lines
2.9 KiB
C++
#pragma once
|
|
#include "gta/script_thread.hpp"
|
|
#include "pointers.hpp"
|
|
#include "script/tlsContext.hpp"
|
|
|
|
#include <network/CNetworkPlayerMgr.hpp>
|
|
#include <ped/CPedFactory.hpp>
|
|
#include <script/scrProgramTable.hpp>
|
|
|
|
namespace rage
|
|
{
|
|
class netObjectIds;
|
|
}
|
|
|
|
namespace big::gta_util
|
|
{
|
|
inline CPed* get_local_ped()
|
|
{
|
|
if (auto ped_factory = *g_pointers->m_gta.m_ped_factory)
|
|
{
|
|
return ped_factory->m_local_ped;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
inline CVehicle* get_local_vehicle()
|
|
{
|
|
if (const auto ped = get_local_ped(); ped)
|
|
{
|
|
if (const auto veh = ped->m_vehicle; veh)
|
|
{
|
|
return veh;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
inline CPlayerInfo* get_local_playerinfo()
|
|
{
|
|
if (auto ped_factory = *g_pointers->m_gta.m_ped_factory)
|
|
{
|
|
if (auto ped = ped_factory->m_local_ped)
|
|
{
|
|
return ped->m_player_info;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
inline CNetworkPlayerMgr* get_network_player_mgr()
|
|
{
|
|
return *g_pointers->m_gta.m_network_player_mgr;
|
|
}
|
|
|
|
inline Network* get_network()
|
|
{
|
|
return *g_pointers->m_gta.m_network;
|
|
}
|
|
|
|
inline rage::netObjectIds* get_net_object_ids()
|
|
{
|
|
if (!*g_pointers->m_gta.m_network_object_mgr)
|
|
return nullptr;
|
|
|
|
return (rage::netObjectIds*)(((std::uintptr_t)*g_pointers->m_gta.m_network_object_mgr) + *g_pointers->m_gta.m_object_ids_offset); // TODO: map out CNetworkObjectMgr eventually
|
|
}
|
|
|
|
template<typename F, typename... Args>
|
|
void execute_as_script(rage::scrThread* thread, F&& callback, Args&&... args)
|
|
{
|
|
auto tls_ctx = rage::tlsContext::get();
|
|
auto og_thread = tls_ctx->m_script_thread;
|
|
|
|
tls_ctx->m_script_thread = thread;
|
|
tls_ctx->m_is_script_thread_active = true;
|
|
|
|
std::invoke(std::forward<F>(callback), std::forward<Args>(args)...);
|
|
|
|
tls_ctx->m_script_thread = og_thread;
|
|
tls_ctx->m_is_script_thread_active = og_thread != nullptr;
|
|
}
|
|
|
|
template<typename F, typename... Args>
|
|
void execute_as_script(rage::joaat_t script_hash, F&& callback, Args&&... args)
|
|
{
|
|
for (auto thread : *g_pointers->m_gta.m_script_threads)
|
|
{
|
|
if (!thread || !thread->m_context.m_thread_id || thread->m_context.m_script_hash != script_hash)
|
|
continue;
|
|
|
|
execute_as_script(thread, callback, args...);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
inline GtaThread* find_script_thread(rage::joaat_t hash)
|
|
{
|
|
for (auto thread : *g_pointers->m_gta.m_script_threads)
|
|
{
|
|
if (thread && thread->m_context.m_thread_id && thread->m_handler && thread->m_script_hash == hash)
|
|
{
|
|
return thread;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
inline GtaThread* find_script_thread_by_id(uint32_t id)
|
|
{
|
|
for (auto thread : *g_pointers->m_gta.m_script_threads)
|
|
{
|
|
if (thread && thread->m_handler && thread->m_context.m_thread_id == id)
|
|
{
|
|
return thread;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
inline rage::scrProgram* find_script_program(rage::joaat_t hash)
|
|
{
|
|
for (auto& script : *g_pointers->m_gta.m_script_program_table)
|
|
{
|
|
if (script.m_program && script.m_program->m_name_hash == hash)
|
|
return script.m_program;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
}
|