From 65e29d33c2398c79dab7a00ae99fc8247c384d21 Mon Sep 17 00:00:00 2001 From: tupoy-ya <72797377+tupoy-ya@users.noreply.github.com> Date: Sun, 18 May 2025 18:52:12 +0500 Subject: [PATCH] feat: Cheater Pool. (#318) Barely tested. Co-authored-by: tupoy-ya --- src/core/hooking/Hooking.cpp | 2 ++ src/game/features/network/CheaterPool.cpp | 37 +++++++++++++++++++++++ src/game/frontend/submenus/Network.cpp | 1 + src/game/hooks/Hooks.hpp | 1 + src/game/pointers/Pointers.cpp | 16 ++++++++++ src/game/pointers/Pointers.hpp | 3 ++ 6 files changed, 60 insertions(+) create mode 100644 src/game/features/network/CheaterPool.cpp diff --git a/src/core/hooking/Hooking.cpp b/src/core/hooking/Hooking.cpp index 56a6707..786f7e0 100644 --- a/src/core/hooking/Hooking.cpp +++ b/src/core/hooking/Hooking.cpp @@ -37,6 +37,8 @@ namespace YimMenu BaseHook::Add(new DetourHook("WriteSyncTree", Pointers.WriteSyncTree, Hooks::Spoofing::WriteSyncTree)); BaseHook::Add(new DetourHook("OpenPauseMenu", Pointers.OpenPauseMenu, Hooks::Features::OpenPauseMenu)); + + BaseHook::Add(new DetourHook("GetPoolType", Pointers.GetPoolType, Hooks::Network::GetPoolType)); } Hooking::~Hooking() diff --git a/src/game/features/network/CheaterPool.cpp b/src/game/features/network/CheaterPool.cpp new file mode 100644 index 0000000..5db4089 --- /dev/null +++ b/src/game/features/network/CheaterPool.cpp @@ -0,0 +1,37 @@ +#include "core/commands/BoolCommand.hpp" +#include "core/hooking/DetourHook.hpp" +#include "game/hooks/Hooks.hpp" +#include "game/pointers/Pointers.hpp" + +namespace YimMenu::Features +{ + class CheaterPool : public BoolCommand + { + using BoolCommand::BoolCommand; + + virtual void OnEnable() override + { + Pointers.SetJoinRequestPoolTypePatch->Apply(); + Pointers.HandleJoinRequestIgnorePoolPatch->Apply(); + } + + virtual void OnDisable() override + { + Pointers.SetJoinRequestPoolTypePatch->Restore(); + Pointers.HandleJoinRequestIgnorePoolPatch->Restore(); + } + }; + + static CheaterPool _CheaterPool{"cheaterpool", "Cheater Pool", "Matchmaking will put you into sessions with other YimMenu users.", true}; +} + +namespace YimMenu::Hooks +{ + int Network::GetPoolType() + { + if (YimMenu::Features::_CheaterPool.GetState()) + return 1; + + return BaseHook::Get>()->Original()(); + } +} \ No newline at end of file diff --git a/src/game/frontend/submenus/Network.cpp b/src/game/frontend/submenus/Network.cpp index f8d8623..babf5b2 100644 --- a/src/game/frontend/submenus/Network.cpp +++ b/src/game/frontend/submenus/Network.cpp @@ -94,6 +94,7 @@ namespace YimMenu::Submenus spoofMMRegion->AddItem(std::make_shared("spoofmmregion"_J, "Spoof Region")); spoofMMRegion->AddItem(std::make_shared("spoofmmregion"_J, std::make_shared("mmregion"_J, "##mmregion"))); matchmakingGroup->AddItem(spoofMMRegion); + matchmakingGroup->AddItem(std::make_shared("cheaterpool"_J)); spoofing->AddItem(matchmakingGroup); AddCategory(std::move(session)); diff --git a/src/game/hooks/Hooks.hpp b/src/game/hooks/Hooks.hpp index 8e8d3a6..74ec357 100644 --- a/src/game/hooks/Hooks.hpp +++ b/src/game/hooks/Hooks.hpp @@ -67,6 +67,7 @@ namespace YimMenu::Hooks extern void ReceiveNetMessage(void* a1, rage::netConnectionManager* mgr, rage::netEvent* event); extern void ReceiveNetGameEvent(Player player, uint16_t event_id, uint32_t event_index, uint32_t event_handled_bits, rage::datBitBuffer& buffer); extern bool HandleScriptedGameEvent(Player player, CScriptedGameEvent& event); + extern int GetPoolType(); } namespace Window diff --git a/src/game/pointers/Pointers.cpp b/src/game/pointers/Pointers.cpp index fda6d8d..f156075 100644 --- a/src/game/pointers/Pointers.cpp +++ b/src/game/pointers/Pointers.cpp @@ -353,6 +353,22 @@ namespace YimMenu OpenPauseMenu = ptr.Add(1).Rip().As(); }); + constexpr auto getPoolTypePtrn = Pattern<"BA CE 94 A6 ED E8">("GetPoolType"); + scanner.Add(getPoolTypePtrn, [this](PointerCalculator ptr) { + GetPoolType = ptr.Sub(19).As(); + }); + + constexpr auto setJoinRequestPoolTypePatchPtrn = Pattern<"89 86 ? ? ? ? E8 ? ? ? ? 89 C0">("SetJoinRequestPoolTypePatch"); + scanner.Add(setJoinRequestPoolTypePatchPtrn, [this](PointerCalculator ptr) { + // MOV EAX, 0; 0 is the normal pool + SetJoinRequestPoolTypePatch = BytePatches::Add(ptr.Sub(5).As(), std::to_array({0xB8, 0x00, 0x00, 0x00, 0x00})); + }); + + constexpr auto handleJoinRequestIgnorePoolPatchPtrn = Pattern<"41 83 FF 05 ? 30 43">("HandleJoinRequestIgnorePoolPatch"); + scanner.Add(handleJoinRequestIgnorePoolPatchPtrn, [this](PointerCalculator ptr) { + HandleJoinRequestIgnorePoolPatch = BytePatches::Add(ptr.Add(4).As(), 0xEB); + }); + if (!scanner.Scan()) { LOG(FATAL) << "Some patterns could not be found, unloading."; diff --git a/src/game/pointers/Pointers.hpp b/src/game/pointers/Pointers.hpp index 34e632f..8a05c9b 100644 --- a/src/game/pointers/Pointers.hpp +++ b/src/game/pointers/Pointers.hpp @@ -144,6 +144,9 @@ namespace YimMenu BytePatch ShouldAllowDriverLockOnPatch; BytePatch AllowPausingInSessionPatch; PVOID OpenPauseMenu; + PVOID GetPoolType; + BytePatch SetJoinRequestPoolTypePatch; + BytePatch HandleJoinRequestIgnorePoolPatch; }; struct Pointers : PointerData