diff --git a/src/Modules.hpp b/src/Modules.hpp index 0e77b9bfe..5a135a0b3 100644 --- a/src/Modules.hpp +++ b/src/Modules.hpp @@ -9,3 +9,4 @@ #include "Modules/Tier1.hpp" #include "Modules/VGui.hpp" #include "Modules/FileSystem.hpp" +#include "Modules/Matchmaking.hpp" diff --git a/src/Modules/Matchmaking.cpp b/src/Modules/Matchmaking.cpp new file mode 100644 index 000000000..e52525b1b --- /dev/null +++ b/src/Modules/Matchmaking.cpp @@ -0,0 +1,30 @@ +#include "Matchmaking.hpp" + +#include "Hook.hpp" +#include "SAR.hpp" + +REDECL(Matchmaking::UpdateLeaderboardData); + +extern Hook g_UpdateLeaderboardDataHook; +DETOUR(Matchmaking::UpdateLeaderboardData, KeyValues *a2) { + return 0; +} +Hook g_UpdateLeaderboardDataHook(&Matchmaking::UpdateLeaderboardData_Hook); + +bool Matchmaking::Init() { + if (!sar.game->Is(SourceGame_Portal2)) { +#ifdef _WIN32 + Matchmaking::UpdateLeaderboardData = (decltype(Matchmaking::UpdateLeaderboardData))Memory::Scan(matchmaking->Name(), "55 8B EC 83 EC 08 53 8B D9 8B 03 8B 50 08"); +#else + Matchmaking::UpdateLeaderboardData = (decltype(Matchmaking::UpdateLeaderboardData))Memory::Scan(matchmaking->Name(), "55 89 E5 57 56 53 83 EC 2C 8B 45 08 8B 5D 0C"); +#endif + + g_UpdateLeaderboardDataHook.SetFunc(Matchmaking::UpdateLeaderboardData); + } + + return this->hasLoaded; +} +void Matchmaking::Shutdown() { +} + +Matchmaking *matchmaking; diff --git a/src/Modules/Matchmaking.hpp b/src/Modules/Matchmaking.hpp new file mode 100644 index 000000000..66ab26599 --- /dev/null +++ b/src/Modules/Matchmaking.hpp @@ -0,0 +1,15 @@ +#pragma once +#include "Module.hpp" +#include "Utils.hpp" + +class Matchmaking : public Module { +public: + // PlayerLocal::UpdateLeaderboardData + DECL_DETOUR(UpdateLeaderboardData, KeyValues *a2); + + bool Init() override; + void Shutdown() override; + const char *Name() override { return MODULE("matchmaking"); } +}; + +extern Matchmaking *matchmaking; diff --git a/src/SAR.cpp b/src/SAR.cpp index d74047627..f0ca8fd34 100644 --- a/src/SAR.cpp +++ b/src/SAR.cpp @@ -102,6 +102,7 @@ bool SAR::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerF this->modules->AddModule(&server); this->modules->AddModule(&materialSystem); this->modules->AddModule(&fileSystem); + this->modules->AddModule(&matchmaking); this->modules->InitAll(); InitSARChecksum(); diff --git a/src/SourceAutoRecord.vcxproj b/src/SourceAutoRecord.vcxproj index 52677b3dc..95d3b95a9 100644 --- a/src/SourceAutoRecord.vcxproj +++ b/src/SourceAutoRecord.vcxproj @@ -154,6 +154,7 @@ + @@ -345,6 +346,7 @@ + diff --git a/src/SourceAutoRecord.vcxproj.filters b/src/SourceAutoRecord.vcxproj.filters index 56afc42d3..c1ac7971b 100644 --- a/src/SourceAutoRecord.vcxproj.filters +++ b/src/SourceAutoRecord.vcxproj.filters @@ -502,6 +502,9 @@ SourceAutoRecord\Features + + SourceAutoRecord\Modules + @@ -1290,6 +1293,9 @@ SourceAutoRecord\Features + + SourceAutoRecord\Modules +