feat: added rid joiner (#521)

This commit is contained in:
Quentin E. / iDeath 2022-10-26 14:12:29 +02:00 committed by GitHub
parent 8f63d1c65b
commit 839854a16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 104 additions and 13 deletions

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include "rage/rlSessionInfo.hpp"
#include "weapon/CAmmoInfo.hpp" #include "weapon/CAmmoInfo.hpp"
#include "weapon/CWeaponInfo.hpp" #include "weapon/CWeaponInfo.hpp"
#include "enums.hpp" #include "enums.hpp"
@ -172,6 +173,8 @@ namespace big
{ {
int hour{}, minute{}, second{}; int hour{}, minute{}, second{};
} custom_time; } custom_time;
bool join_queued = false;
rage::rlSessionInfo info;
}; };
struct settings { struct settings {

View File

@ -1,10 +1,4 @@
#pragma once #pragma once
#include "common.hpp"
#include "gta/fwddec.hpp"
#include "gta/player.hpp"
#include "gta/natives.hpp"
#include "gta/replay.hpp"
#include "network/CNetComplaintMgr.hpp"
namespace big::functions namespace big::functions
{ {
@ -59,4 +53,7 @@ namespace big::functions
using fipackfile_open_archive = bool(*)(rage::fiPackfile* this_, const char* archive, bool b_true, int type, intptr_t very_false); using fipackfile_open_archive = bool(*)(rage::fiPackfile* this_, const char* archive, bool b_true, int type, intptr_t very_false);
using fipackfile_mount = bool(*)(rage::fiPackfile* this_, const char* mount_point); using fipackfile_mount = bool(*)(rage::fiPackfile* this_, const char* mount_point);
using fipackfile_unmount = bool(*)(const char* mount_point); using fipackfile_unmount = bool(*)(const char* mount_point);
using start_get_session_by_gamer_handle = bool(*)(int metric_manager, rage::rlGamerHandle* handles, int count, rage::rlSessionByGamerTaskResult* result, int unk, bool* success, int* state);
using join_session_by_info = bool(*)(Network* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int handlecount);
} }

View File

@ -46,6 +46,9 @@ namespace rage
class fiDevice; class fiDevice;
class fiPackfile; class fiPackfile;
class rlSessionInfo;
class rlSessionByGamerTaskResult;
} }
class GtaThread; class GtaThread;
@ -65,7 +68,9 @@ class CPickup;
class CPedFactory; class CPedFactory;
class CVehicleFactory; class CVehicleFactory;
class Network;
class CNetGamePlayer; class CNetGamePlayer;
class CNetworkPlayerMgr; class CNetworkPlayerMgr;
class CPlayerInfo; class CPlayerInfo;
class CNetworkObjectMgr; class CNetworkObjectMgr;
class CNetComplaintMgr;

View File

@ -4,6 +4,7 @@
#include "freemode.hpp" #include "freemode.hpp"
#include "gta_util.hpp" #include "gta_util.hpp"
#include "shop_controller.hpp" #include "shop_controller.hpp"
#include "network_session_host.hpp"
namespace big namespace big
{ {
@ -18,6 +19,7 @@ namespace big
add_native_detour(RAGE_JOAAT("carmod_shop"), 0x767FBC2AC802EF3D, carmod_shop::STAT_GET_INT); add_native_detour(RAGE_JOAAT("carmod_shop"), 0x767FBC2AC802EF3D, carmod_shop::STAT_GET_INT);
add_native_detour(RAGE_JOAAT("freemode"), 0x95914459A87EBA28, freemode::NETWORK_BAIL); add_native_detour(RAGE_JOAAT("freemode"), 0x95914459A87EBA28, freemode::NETWORK_BAIL);
add_native_detour(RAGE_JOAAT("shop_controller"), 0xDC38CC1E35B6A5D7, shop_controller::SET_WARNING_MESSAGE_WITH_HEADER); add_native_detour(RAGE_JOAAT("shop_controller"), 0xDC38CC1E35B6A5D7, shop_controller::SET_WARNING_MESSAGE_WITH_HEADER);
add_native_detour(RAGE_JOAAT("maintransition"), 0x6F3D4ED9BEE4E61D, network::NETWORK_SESSION_HOST);
for (const auto& native_detours_for_script : m_native_registrations) for (const auto& native_detours_for_script : m_native_registrations)
if (const auto thread = gta_util::find_script_thread(native_detours_for_script.first); thread != nullptr && thread->m_context.m_state == rage::eThreadState::running) if (const auto thread = gta_util::find_script_thread(native_detours_for_script.first); thread != nullptr && thread->m_context.m_state == rage::eThreadState::running)

View File

@ -0,0 +1,24 @@
#pragma once
#include "native_hooks.hpp"
#include "natives.hpp"
#include "pointers.hpp"
namespace big
{
namespace network
{
inline void NETWORK_SESSION_HOST(rage::scrNativeCallContext* src)
{
if (g->session.join_queued)
{
g_pointers->m_join_session_by_info(*g_pointers->m_network, &g->session.info, 0, 0, nullptr, 0);
g->session.join_queued = false;
src->set_return_value<BOOL>(TRUE);
}
else
{
src->set_return_value<BOOL>(NETWORK::NETWORK_SESSION_HOST(src->get_arg<int>(0), src->get_arg<int>(1), src->get_arg<BOOL>(2)));
}
}
}
}

View File

@ -398,6 +398,18 @@ namespace big
m_format_metric_for_sending = ptr.as<PVOID>(); m_format_metric_for_sending = ptr.as<PVOID>();
}); });
// Get Session By Gamer Handle
main_batch.add("SGSBGH", "E8 ? ? ? ? 84 C0 0F 84 ? ? ? ? 8B 05 ? ? ? ? 48 8D 4C 24", [this](memory::handle ptr)
{
m_start_get_session_by_gamer_handle = ptr.add(1).rip().as<functions::start_get_session_by_gamer_handle>();
});
// Join Session By Info
main_batch.add("JSBI", "E8 ? ? ? ? 0F B6 CB 84 C0 41 0F 44 CD", [this](memory::handle ptr)
{
m_join_session_by_info = ptr.add(1).rip().as<functions::join_session_by_info>();
});
auto mem_region = memory::module(nullptr); auto mem_region = memory::module(nullptr);
main_batch.run(mem_region); main_batch.run(mem_region);

View File

@ -106,6 +106,9 @@ namespace big
Network** m_network; Network** m_network;
functions::start_get_session_by_gamer_handle m_start_get_session_by_gamer_handle;
functions::join_session_by_info m_join_session_by_info;
functions::reset_network_complaints m_reset_network_complaints{}; functions::reset_network_complaints m_reset_network_complaints{};
functions::fidevice_get_device m_fidevice_get_device{}; functions::fidevice_get_device m_fidevice_get_device{};

View File

@ -3,6 +3,9 @@
#include "script_global.hpp" #include "script_global.hpp"
#include "script.hpp" #include "script.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "gta/joaat.hpp"
#include "rage/rlSessionByGamerTaskResult.hpp"
#include "pointers.hpp"
namespace big::session namespace big::session
{ {
@ -33,4 +36,39 @@ namespace big::session
*script_global(262145).at(4723).as<bool*>() = g->session.local_weather == 13; *script_global(262145).at(4723).as<bool*>() = g->session.local_weather == 13;
} }
inline void join_by_rockstar_id(uint64_t rid)
{
if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) != 0 ||
STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS())
{
g_notification_service->push_error("RID Joiner", "Player switch in progress, wait a bit.");
return;
}
rage::rlGamerHandle player_handle(rid);
rage::rlSessionByGamerTaskResult result;
bool success = false;
int state = 0;
if (g_pointers->m_start_get_session_by_gamer_handle(0, &player_handle, 1, &result, 1, &success, &state))
{
while (state == 1)
script::get_current()->yield();
if (state == 3 && success)
{
g->session.join_queued = true;
g->session.info = result.m_session_info;
session::join_type({ eSessionType::NEW_PUBLIC });
if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0)
{
g->session.join_queued = false;
g_notification_service->push_error("RID Joiner", "Unable to launch maintransition");
}
return;
}
}
g_notification_service->push_error("RID Joiner", "Target Player is offline?");
}
} }

View File

@ -1,11 +1,18 @@
#include "views/view.hpp"
#include "fiber_pool.hpp" #include "fiber_pool.hpp"
#include "util/session.hpp" #include "util/session.hpp"
#include "views/view.hpp"
namespace big namespace big
{ {
void view::session() void view::session()
{ {
static uint64_t rid = 0;
ImGui::InputScalar("Input RID", ImGuiDataType_U64, &rid);
components::button("Join RID", []
{
session::join_by_rockstar_id(rid);
});
components::sub_title("Session Switcher"); components::sub_title("Session Switcher");
if (ImGui::ListBoxHeader("###session_switch")) if (ImGui::ListBoxHeader("###session_switch"))
{ {

2
vendor/GTAV-Classes vendored

@ -1 +1 @@
Subproject commit b37965211e80eb23be9a2bdb1bc58072defebcb0 Subproject commit 011018945d7a04ff818bd6961875309c2099709a