fix(battleye): ensure we don't trigger the BE shadow ban by being in invite-only sessions

This commit is contained in:
maybegreat48
2025-06-03 21:43:38 -04:00
parent 684f6ee567
commit 0842941f96
9 changed files with 78 additions and 1 deletions
+1
View File
@@ -20,6 +20,7 @@ namespace YimMenu
BaseHook::Add<Hooks::Anticheat::PrepareMetricForSending>(new DetourHook("PrepareMetricForSending", Pointers.PrepareMetricForSending, Hooks::Anticheat::PrepareMetricForSending));
BaseHook::Add<Hooks::Anticheat::GetThreadContext>(new DetourHook("GetThreadContext", reinterpret_cast<void*>(GetProcAddress(LoadLibraryA("kernel32.dll"), "GetThreadContext")), Hooks::Anticheat::GetThreadContext));
BaseHook::Add<Hooks::Anticheat::HttpStartRequest>(new DetourHook("HttpStartRequest", Pointers.HttpStartRequest, Hooks::Anticheat::HttpStartRequest));
BaseHook::Add<Hooks::Anticheat::BattlEyeServerProcessPlayerJoin>(new DetourHook("BattlEyeServerProcessPlayerJoin", Pointers.BattlEyeServerProcessPlayerJoin, Hooks::Anticheat::BattlEyeServerProcessPlayerJoin));
BaseHook::Add<Hooks::Script::RunScriptThreads>(new DetourHook("RunScriptThreads", Pointers.RunScriptThreads, Hooks::Script::RunScriptThreads));
BaseHook::Add<Hooks::Script::InitNativeTables>(new DetourHook("InitNativeTables", Pointers.InitNativeTables, Hooks::Script::InitNativeTables));
+2
View File
@@ -205,5 +205,7 @@ namespace YimMenu
if (m_Global)
return true;
return false;
}
}
+2 -1
View File
@@ -74,7 +74,8 @@ namespace YimMenu
{
if (auto it = GetInstance().m_Tunables.find(hash); it != GetInstance().m_Tunables.end())
{
return ScriptGlobal(it->second);
if (ScriptGlobal(it->second).CanAccess())
return ScriptGlobal(it->second);
}
return std::nullopt;
@@ -0,0 +1,28 @@
#include "core/hooking/DetourHook.hpp"
#include "core/commands/BoolCommand.hpp"
#include "core/commands/Commands.hpp"
#include "game/hooks/Hooks.hpp"
#include "game/gta/Natives.hpp"
#include "types/battleye/CBattlEyePlayerModifyContext.hpp"
namespace YimMenu::Hooks
{
bool Anticheat::BattlEyeServerProcessPlayerJoin(CBattlEyePlayerModifyInterface* server_iface, CBattlEyePlayerModifyContext* context)
{
if (context->m_IsLocal)
{
if (NETWORK::NETWORK_SESSION_IS_CLOSED_FRIENDS() || NETWORK::NETWORK_SESSION_IS_CLOSED_CREW() || NETWORK::NETWORK_SESSION_IS_SOLO() || NETWORK::NETWORK_SESSION_IS_PRIVATE())
{
return true;
}
}
static auto cheater_pool = Commands::GetCommand<BoolCommand>("cheaterpool"_J);
if (cheater_pool->GetState())
{
return true;
}
return BaseHook::Get<Anticheat::BattlEyeServerProcessPlayerJoin, DetourHook<decltype(&Anticheat::BattlEyeServerProcessPlayerJoin)>>()->Original()(server_iface, context);
}
}
+4
View File
@@ -5,6 +5,9 @@ class CNetworkPlayerMgr;
class CNetGamePlayer;
class CProjectBaseSyncDataNode;
class CScriptedGameEvent;
class CBattlEyePlayerModifyInterface;
class CBattlEyePlayerModifyContext;
namespace rage
{
class netConnectionManager;
@@ -38,6 +41,7 @@ namespace YimMenu::Hooks
extern bool PrepareMetricForSending(rage::JsonSerializer* ser, void* a2, void* a3, rage::rlMetric* metric);
extern BOOL GetThreadContext(HANDLE hThread, LPCONTEXT lpContext);
extern void HttpStartRequest(void* request);
extern bool BattlEyeServerProcessPlayerJoin(CBattlEyePlayerModifyInterface* server_iface, CBattlEyePlayerModifyContext* context);
}
namespace Info
+4
View File
@@ -374,6 +374,10 @@ namespace YimMenu
HasGTAPlus = addr.Add(3).Rip().As<int*>();
});
constexpr auto battlEyeServerProcessPlayerJoinPtrn = Pattern<"BA 2D AD 45 3F">("BattlEyeServerProcessPlayerJoin");
scanner.Add(battlEyeServerProcessPlayerJoinPtrn, [this](PointerCalculator ptr) {
BattlEyeServerProcessPlayerJoin = ptr.Sub(0x72).As<PVOID>();
});
if (!scanner.Scan())
{
+1
View File
@@ -149,6 +149,7 @@ namespace YimMenu
BytePatch HandleJoinRequestIgnorePoolPatch;
CStatsMpCharacterMappingData* StatsMpCharacterMappingData;
int* HasGTAPlus;
PVOID BattlEyeServerProcessPlayerJoin;
};
struct Pointers : PointerData
@@ -0,0 +1,20 @@
#pragma once
#include "types/rage/atArray.hpp"
#include "types/network/netSocketAddress.hpp"
namespace rage
{
using atDynString = rage::atArray<char>; // this is technically true
}
class CBattlEyePlayerModifyContext
{
public:
rage::atDynString m_Ticket;
rage::atDynString m_GamerHandleHash;
netSocketAddress m_Address;
uint64_t m_HostToken;
char m_Name[17];
bool m_IsLocal;
};
static_assert(sizeof(CBattlEyePlayerModifyContext) == 0x48);
@@ -0,0 +1,16 @@
#pragma once
class CBattlEyeClient;
class CBattlEyeServer;
class CBattlEyePlayerModifyContext;
class CBattlEyePlayerModifyInterface
{
public:
virtual ~CBattlEyePlayerModifyInterface() = default;
virtual bool ProcessPlayerJoin(const CBattlEyePlayerModifyContext* context) = 0;
virtual bool ProcessPlayerLeave(const CBattlEyePlayerModifyContext* context) = 0;
CBattlEyeClient* m_Client;
CBattlEyeServer* m_Server;
};